Commit b5dd8e9c authored by frank.xa.zhang's avatar frank.xa.zhang

add new api inputInvoicePreviewList

add new api queryOutputInvoiceList
parent de46aed1
package pwc.taxtech.atms.common;
import pwc.taxtech.atms.dto.PagingDto;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class PagingList<T> {
private List<T> sourceData;
private PagingDto pagingDto;
/**
* 总页数
*/
private int totalPage = 0;
/**
* 当前是第几页
*/
private int curPageNo = 0;
/**
* 每页的大小
*/
private int pageSize = 0;
/**
* 每页默认大小
*/
private static final int DEFAULT_PAGE_SIZE = 500;
private int totalCount = 0;
public PagingList(List<T> sourceData, PagingDto pagingDto) {
this.sourceData = sourceData;
this.pagingDto = pagingDto;
this.pageSize = pagingDto.getPageSize();
this.curPageNo = pagingDto.getPageIndex();
this.totalCount = pagingDto.getTotalCount();
init();
}
private void init() {
if (pagingDto.getPageSize() <= 0) {
throw new IllegalArgumentException("Paging size must be greater than zero.");
}
if (null == sourceData) {
throw new NullPointerException("Paging resource list must be not null.");
}
if (totalCount % pageSize > 0) {
this.totalPage = (totalCount / pageSize) + 1;
} else {
this.totalPage = totalCount / pageSize;
}
}
public List<T> getPagingList() {
if (curPageNo <= totalPage) {
if (curPageNo < totalCount) {
return sourceData.stream().skip((curPageNo - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
} else {
int lastPageItemCount = totalCount - (curPageNo - 1) * pageSize;
return sourceData.stream().skip((curPageNo - 1) * pageSize).limit(lastPageItemCount).collect(Collectors.toList());
}
} else {
return new ArrayList<>();
}
}
}
package pwc.taxtech.atms.constant.enums;
public enum EnumInvoiceType {
VATInvoice(1, "增值税专票"),
FreightTransport(2, "货运发票"),
MotorVehicle(3, "机动车发票"),
AgriculturalProduct(4, "农产品发票"),
Other(5, "其他发票");
private int code;
private String name;
EnumInvoiceType(int code, String name) {
this.code = code;
this.name = name;
}
public int getCode() {
return code;
}
public String getName() {
return name;
}
}
package pwc.taxtech.atms.constant.enums;
public enum EnumOutputInvoiceType {
Normal(0, "普通发票"),
Special(1, "专用发票"),
MotorVehicle(2, "机动车销售发票");
private int code;
private String name;
EnumOutputInvoiceType(int code, String name) {
this.code = code;
this.name = name;
}
public int getCode() {
return code;
}
public String getName() {
return name;
}
}
package pwc.taxtech.atms.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.InputInvoicePreviewQueryParam;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceDto;
import pwc.taxtech.atms.vat.service.InputInvoiceDataImportService;
@RestController
@RequestMapping(value = "api/v1/inputInvoiceImport")
public class InputInvoiceImportController {
@Autowired
InputInvoiceDataImportService inputInvoiceDataImportService;
@RequestMapping(value = "inputInvoicePreviewList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public PagingResultDto<InputVATInvoiceDto> getInputInvoiceTreeViewData(InputInvoicePreviewQueryParam paras) {
return inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras);
}
}
package pwc.taxtech.atms.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceInfoDto;
import pwc.taxtech.atms.dto.vatdto.QueryOutputDto;
import pwc.taxtech.atms.vat.service.OutputInvoiceService;
@RestController
@RequestMapping(value = "api/v1/outputInvoiceImport")
public class OutputInvoiceController {
@Autowired
OutputInvoiceService outputInvoiceService;
@RequestMapping(value = "queryOutputInvoiceList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public PagingResultDto<OutputVATInvoiceInfoDto> queryOutputInvoiceList(QueryOutputDto queryDto) {
return outputInvoiceService.queryOutputInvoiceList(queryDto);
}
}
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.dto.PagingDto;
import java.math.BigDecimal;
import java.util.Date;
public class InputInvoicePreviewQueryParam {
private PagingDto pageInfo;
private int periodStart;
private int periodEnd;
private Date certificationDateStart;
private Date certificationDateEnd;
private String invoiceCode;
private String invoiceNumber;
private String sellerTaxNumber;
private BigDecimal amountStart;
private BigDecimal amountEnd;
private Integer invoiceType;
private BigDecimal taxAmountStart;
private BigDecimal taxAmountEnd;
/**
* 1:认证通过,2:认证不通过,3:全部
*/
private int certificationStatus;
public PagingDto getPageInfo() {
return pageInfo;
}
public void setPageInfo(PagingDto pageInfo) {
this.pageInfo = pageInfo;
}
public int getPeriodStart() {
return periodStart;
}
public void setPeriodStart(int periodStart) {
this.periodStart = periodStart;
}
public int getPeriodEnd() {
return periodEnd;
}
public void setPeriodEnd(int periodEnd) {
this.periodEnd = periodEnd;
}
public Date getCertificationDateStart() {
return certificationDateStart;
}
public void setCertificationDateStart(Date certificationDateStart) {
this.certificationDateStart = certificationDateStart;
}
public Date getCertificationDateEnd() {
return certificationDateEnd;
}
public void setCertificationDateEnd(Date certificationDateEnd) {
this.certificationDateEnd = certificationDateEnd;
}
public String getInvoiceCode() {
return invoiceCode;
}
public void setInvoiceCode(String invoiceCode) {
this.invoiceCode = invoiceCode;
}
public String getInvoiceNumber() {
return invoiceNumber;
}
public void setInvoiceNumber(String invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
public String getSellerTaxNumber() {
return sellerTaxNumber;
}
public void setSellerTaxNumber(String sellerTaxNumber) {
this.sellerTaxNumber = sellerTaxNumber;
}
public BigDecimal getAmountStart() {
return amountStart;
}
public void setAmountStart(BigDecimal amountStart) {
this.amountStart = amountStart;
}
public BigDecimal getAmountEnd() {
return amountEnd;
}
public void setAmountEnd(BigDecimal amountEnd) {
this.amountEnd = amountEnd;
}
public Integer getInvoiceType() {
return invoiceType;
}
public void setInvoiceType(Integer invoiceType) {
this.invoiceType = invoiceType;
}
public BigDecimal getTaxAmountStart() {
return taxAmountStart;
}
public void setTaxAmountStart(BigDecimal taxAmountStart) {
this.taxAmountStart = taxAmountStart;
}
public BigDecimal getTaxAmountEnd() {
return taxAmountEnd;
}
public void setTaxAmountEnd(BigDecimal taxAmountEnd) {
this.taxAmountEnd = taxAmountEnd;
}
}
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.constant.enums.EnumInvoiceType;
import java.math.BigDecimal;
import java.util.Date;
public class InputVATInvoiceDto {
private String ID ;
private int periodID ;
private String invoiceCode ;
private String invoiceNumber ;
private Date invoiceDate ;
private String sellerTaxNumber ;
private BigDecimal amount ;
private BigDecimal taxAmount ;
private String invoiceTypeName;
private int invoiceType ;
private String certificationResult ;
private Date certificationDate ;
private String creatorID ;
private Date createTime ;
private boolean isDuplicate ;
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public int getPeriodID() {
return periodID;
}
public void setPeriodID(int periodID) {
this.periodID = periodID;
}
public String getInvoiceCode() {
return invoiceCode;
}
public void setInvoiceCode(String invoiceCode) {
this.invoiceCode = invoiceCode;
}
public String getInvoiceNumber() {
return invoiceNumber;
}
public void setInvoiceNumber(String invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
public Date getInvoiceDate() {
return invoiceDate;
}
public void setInvoiceDate(Date invoiceDate) {
this.invoiceDate = invoiceDate;
}
public String getSellerTaxNumber() {
return sellerTaxNumber;
}
public void setSellerTaxNumber(String sellerTaxNumber) {
this.sellerTaxNumber = sellerTaxNumber;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public BigDecimal getTaxAmount() {
return taxAmount;
}
public void setTaxAmount(BigDecimal taxAmount) {
this.taxAmount = taxAmount;
}
public int getInvoiceType() {
return invoiceType;
}
public void setInvoiceType(int invoiceType) {
this.invoiceType = invoiceType;
}
public String getCertificationResult() {
return certificationResult;
}
public void setCertificationResult(String certificationResult) {
this.certificationResult = certificationResult;
}
public Date getCertificationDate() {
return certificationDate;
}
public void setCertificationDate(Date certificationDate) {
this.certificationDate = certificationDate;
}
public String getCreatorID() {
return creatorID;
}
public void setCreatorID(String creatorID) {
this.creatorID = creatorID;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public boolean isDuplicate() {
return isDuplicate;
}
public void setDuplicate(boolean duplicate) {
isDuplicate = duplicate;
}
public String getInvoiceTypeName() {
return EnumInvoiceType.values()[this.invoiceType].getName();
}
}
package pwc.taxtech.atms.dto.vatdto;
public class OutputVATInvoiceDto {
}
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.constant.enums.EnumOutputInvoiceType;
import java.math.BigDecimal;
import java.util.Date;
public class OutputVATInvoiceInfoDto {
private String invoiceID;
private Integer invoiceType;
private String invoiceTypeName;
private String classCode;
private String invoiceNumber;
private String buyerName;
private String buyerTaxNumber;
private String bankAccount;
private String phoneNum;
private Date invoiceDate;
private String codeVersion;
private String productName;
private String documentNum;
private String productStandard;
private String unit;
private Integer quantity;
private Double unitPrice;
private BigDecimal amount;
private BigDecimal taxRate;
private BigDecimal taxAmount;
private String taxClassCode;
private int periodID;
private boolean isDuplicate;
private BigDecimal amountDifference;
public String getInvoiceID() {
return invoiceID;
}
public void setInvoiceID(String invoiceID) {
this.invoiceID = invoiceID;
}
public Integer getInvoiceType() {
return invoiceType;
}
public void setInvoiceType(Integer invoiceType) {
this.invoiceType = invoiceType;
}
public String getClassCode() {
return classCode;
}
public void setClassCode(String classCode) {
this.classCode = classCode;
}
public String getInvoiceNumber() {
return invoiceNumber;
}
public void setInvoiceNumber(String invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
public String getBuyerName() {
return buyerName;
}
public void setBuyerName(String buyerName) {
this.buyerName = buyerName;
}
public String getBuyerTaxNumber() {
return buyerTaxNumber;
}
public void setBuyerTaxNumber(String buyerTaxNumber) {
this.buyerTaxNumber = buyerTaxNumber;
}
public String getBankAccount() {
return bankAccount;
}
public void setBankAccount(String bankAccount) {
this.bankAccount = bankAccount;
}
public String getPhoneNum() {
return phoneNum;
}
public void setPhoneNum(String phoneNum) {
this.phoneNum = phoneNum;
}
public Date getInvoiceDate() {
return invoiceDate;
}
public void setInvoiceDate(Date invoiceDate) {
this.invoiceDate = invoiceDate;
}
public String getCodeVersion() {
return codeVersion;
}
public void setCodeVersion(String codeVersion) {
this.codeVersion = codeVersion;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getDocumentNum() {
return documentNum;
}
public void setDocumentNum(String documentNum) {
this.documentNum = documentNum;
}
public String getProductStandard() {
return productStandard;
}
public void setProductStandard(String productStandard) {
this.productStandard = productStandard;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
public Double getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(Double unitPrice) {
this.unitPrice = unitPrice;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public BigDecimal getTaxRate() {
return taxRate;
}
public void setTaxRate(BigDecimal taxRate) {
this.taxRate = taxRate;
}
public BigDecimal getTaxAmount() {
return taxAmount;
}
public void setTaxAmount(BigDecimal taxAmount) {
this.taxAmount = taxAmount;
}
public String getTaxClassCode() {
return taxClassCode;
}
public void setTaxClassCode(String taxClassCode) {
this.taxClassCode = taxClassCode;
}
public int getPeriodID() {
return periodID;
}
public void setPeriodID(int periodID) {
this.periodID = periodID;
}
public boolean isDuplicate() {
return isDuplicate;
}
public void setDuplicate(boolean duplicate) {
isDuplicate = duplicate;
}
public BigDecimal getAmountDifference() {
return amountDifference;
}
public void setAmountDifference(BigDecimal amountDifference) {
this.amountDifference = amountDifference;
}
public String getInvoiceTypeName() {
return EnumOutputInvoiceType.values()[this.invoiceType].getName();
}
}
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.dto.PagingDto;
import java.math.BigDecimal;
import java.util.Date;
public class QueryOutputDto {
private PagingDto pageInfo;
private int periodStart;
private int periodEnd;
private Integer invoiceType;
private Date startInvoiceDate;
private Date endInvoiceDate;
private String classCode;
private String invoiceNumber;
private String buyerName;
private String productName;
private BigDecimal amountStart;
private BigDecimal amountEnd;
private BigDecimal taxAmountStart;
private BigDecimal taxAmountEnd;
public PagingDto getPageInfo() {
return pageInfo;
}
public void setPageInfo(PagingDto pageInfo) {
this.pageInfo = pageInfo;
}
public int getPeriodStart() {
return periodStart;
}
public void setPeriodStart(int periodStart) {
this.periodStart = periodStart;
}
public int getPeriodEnd() {
return periodEnd;
}
public void setPeriodEnd(int periodEnd) {
this.periodEnd = periodEnd;
}
public Integer getInvoiceType() {
return invoiceType;
}
public void setInvoiceType(Integer invoiceType) {
this.invoiceType = invoiceType;
}
public Date getStartInvoiceDate() {
return startInvoiceDate;
}
public void setStartInvoiceDate(Date startInvoiceDate) {
this.startInvoiceDate = startInvoiceDate;
}
public Date getEndInvoiceDate() {
return endInvoiceDate;
}
public void setEndInvoiceDate(Date endInvoiceDate) {
this.endInvoiceDate = endInvoiceDate;
}
public String getClassCode() {
return classCode;
}
public void setClassCode(String classCode) {
this.classCode = classCode;
}
public String getInvoiceNumber() {
return invoiceNumber;
}
public void setInvoiceNumber(String invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
public String getBuyerName() {
return buyerName;
}
public void setBuyerName(String buyerName) {
this.buyerName = buyerName;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public BigDecimal getAmountStart() {
return amountStart;
}
public void setAmountStart(BigDecimal amountStart) {
this.amountStart = amountStart;
}
public BigDecimal getAmountEnd() {
return amountEnd;
}
public void setAmountEnd(BigDecimal amountEnd) {
this.amountEnd = amountEnd;
}
public BigDecimal getTaxAmountStart() {
return taxAmountStart;
}
public void setTaxAmountStart(BigDecimal taxAmountStart) {
this.taxAmountStart = taxAmountStart;
}
public BigDecimal getTaxAmountEnd() {
return taxAmountEnd;
}
public void setTaxAmountEnd(BigDecimal taxAmountEnd) {
this.taxAmountEnd = taxAmountEnd;
}
}
...@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper; import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.dto.vatdto.InputInvoicePreviewQueryParam;
import pwc.taxtech.atms.vat.entity.InputVATInvoice; import pwc.taxtech.atms.vat.entity.InputVATInvoice;
import pwc.taxtech.atms.vat.entity.InputVATInvoiceExample; import pwc.taxtech.atms.vat.entity.InputVATInvoiceExample;
...@@ -105,4 +106,8 @@ public interface InputVATInvoiceMapper extends MyVatMapper { ...@@ -105,4 +106,8 @@ public interface InputVATInvoiceMapper extends MyVatMapper {
* @mbg.generated * @mbg.generated
*/ */
int updateByPrimaryKey(InputVATInvoice record); int updateByPrimaryKey(InputVATInvoice record);
int getInputVATInvoiceCountByCondition(@Param("paras") InputInvoicePreviewQueryParam param);
List<InputVATInvoice> getInputVATInvoiceCountByConditionWithPaging(@Param("paras") InputInvoicePreviewQueryParam param,@Param("limitFrom") int limitFrom);
} }
\ No newline at end of file
...@@ -5,6 +5,8 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -5,6 +5,8 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper; import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceInfoDto;
import pwc.taxtech.atms.dto.vatdto.QueryOutputDto;
import pwc.taxtech.atms.vat.entity.OutputVATInvoice; import pwc.taxtech.atms.vat.entity.OutputVATInvoice;
import pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample; import pwc.taxtech.atms.vat.entity.OutputVATInvoiceExample;
...@@ -105,4 +107,6 @@ public interface OutputVATInvoiceMapper extends MyVatMapper { ...@@ -105,4 +107,6 @@ public interface OutputVATInvoiceMapper extends MyVatMapper {
* @mbg.generated * @mbg.generated
*/ */
int updateByPrimaryKey(OutputVATInvoice record); int updateByPrimaryKey(OutputVATInvoice record);
List<OutputVATInvoiceInfoDto> selectOutputVATInvoiceInfoLeftJoinItem(@Param("queryDto")QueryOutputDto queryDto);
} }
\ No newline at end of file
package pwc.taxtech.atms.vat.service;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.InputInvoicePreviewQueryParam;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceDto;
public interface InputInvoiceDataImportService {
PagingResultDto<InputVATInvoiceDto> getInputInvoiceTreeViewData(InputInvoicePreviewQueryParam paras);
}
package pwc.taxtech.atms.vat.service;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceInfoDto;
import pwc.taxtech.atms.dto.vatdto.QueryOutputDto;
public interface OutputInvoiceService {
PagingResultDto<OutputVATInvoiceInfoDto> queryOutputInvoiceList(QueryOutputDto queryDto);
}
package pwc.taxtech.atms.vat.service.impl;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.InputInvoicePreviewQueryParam;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceDto;
import pwc.taxtech.atms.vat.service.InputInvoiceDataImportService;
import java.util.ArrayList;
import java.util.List;
@Service
public class InputInvoiceDataImportServiceImpl extends VatAbstractService implements InputInvoiceDataImportService {
@Override
public PagingResultDto<InputVATInvoiceDto> getInputInvoiceTreeViewData(InputInvoicePreviewQueryParam paras) {
PagingResultDto<InputVATInvoiceDto> qResult = new PagingResultDto<>();
qResult.setPageInfo(paras.getPageInfo());
qResult.setList(new ArrayList<>());
long result = inputVATInvoiceMapper.getInputVATInvoiceCountByCondition(paras);
qResult.getPageInfo().setTotalCount((int) result);
if (result > 0) {
int limitFrom = paras.getPageInfo().getPageSize() * (paras.getPageInfo().getPageIndex() - 1);
List<InputVATInvoiceDto> fResult = new ArrayList<>();
inputVATInvoiceMapper.getInputVATInvoiceCountByConditionWithPaging(paras, limitFrom).forEach(a -> {
InputVATInvoiceDto inputVATInvoiceDto = new InputVATInvoiceDto();
CommonUtils.copyProperties(a, inputVATInvoiceDto);
fResult.add(inputVATInvoiceDto);
});
qResult.setList(fResult);
}
return qResult;
}
}
package pwc.taxtech.atms.vat.service.impl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.PagingList;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.OutputVATInvoiceInfoDto;
import pwc.taxtech.atms.dto.vatdto.QueryOutputDto;
import pwc.taxtech.atms.vat.service.OutputInvoiceService;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service
public class OutputInvoiceServiceImpl extends VatAbstractService implements OutputInvoiceService {
@Override
public PagingResultDto<OutputVATInvoiceInfoDto> queryOutputInvoiceList(QueryOutputDto queryDto) {
PagingResultDto<OutputVATInvoiceInfoDto> qResult = new PagingResultDto<>();
qResult.setPageInfo(queryDto.getPageInfo());
qResult.setList(new ArrayList<>());
List<OutputVATInvoiceInfoDto> rList = outputVATInvoiceMapper.selectOutputVATInvoiceInfoLeftJoinItem(queryDto);
Function<OutputVATInvoiceInfoDto, List<Object>> compositeKey = outputVATInvoiceInfoDto ->
Arrays.asList(outputVATInvoiceInfoDto.getInvoiceID()
, outputVATInvoiceInfoDto.getClassCode()
, outputVATInvoiceInfoDto.getInvoiceNumber());
List<OutputVATInvoiceInfoDto> groupedList = new ArrayList<>();
rList.stream().collect(Collectors.groupingBy(compositeKey, Collectors.toList())).forEach((k, v) -> {
if (v.stream().findFirst().isPresent()) {
OutputVATInvoiceInfoDto fItem = v.stream().findFirst().get();
OutputVATInvoiceInfoDto outputVATInvoiceInfoDto = new OutputVATInvoiceInfoDto();
CommonUtils.copyProperties(fItem, outputVATInvoiceInfoDto);
outputVATInvoiceInfoDto.setAmount(new BigDecimal(v.stream().mapToDouble(a -> a.getAmount().doubleValue()).sum()));
outputVATInvoiceInfoDto.setTaxAmount(new BigDecimal(v.stream().mapToDouble(a -> a.getTaxAmount().doubleValue()).sum()));
groupedList.add(outputVATInvoiceInfoDto);
}
});
Stream<OutputVATInvoiceInfoDto> stream = groupedList.stream();
if (queryDto.getInvoiceType() != null && queryDto.getInvoiceType() != 999) {
stream = stream.filter(a -> a.getInvoiceType().equals(queryDto.getInvoiceType()));
}
if (queryDto.getStartInvoiceDate() != null) {
stream = stream.filter(a -> a.getInvoiceDate().after(queryDto.getStartInvoiceDate()));
}
if (queryDto.getEndInvoiceDate() != null) {
stream = stream.filter(a -> a.getInvoiceDate().before(queryDto.getEndInvoiceDate()));
}
if (StringUtils.isNotBlank(queryDto.getClassCode())) {
stream = stream.filter(a -> a.getClassCode().contains(queryDto.getClassCode()));
}
if (StringUtils.isNotBlank(queryDto.getInvoiceNumber())) {
stream = stream.filter(a -> a.getInvoiceNumber().contains(queryDto.getInvoiceNumber()));
}
if (StringUtils.isNotBlank(queryDto.getBuyerName())) {
stream = stream.filter(a -> a.getBuyerName().contains(queryDto.getBuyerName()));
}
if (queryDto.getAmountStart() != null) {
stream = stream.filter(a -> a.getAmount().compareTo(queryDto.getAmountStart()) > 0);
}
if (queryDto.getAmountEnd() != null) {
stream = stream.filter(a -> a.getAmount().compareTo(queryDto.getAmountEnd()) < 0);
}
if (queryDto.getTaxAmountStart() != null) {
stream = stream.filter(a -> a.getTaxAmount().compareTo(queryDto.getTaxAmountStart()) > 0);
}
if (queryDto.getTaxAmountEnd() != null) {
stream = stream.filter(a -> a.getTaxAmount().compareTo(queryDto.getTaxAmountEnd()) < 0);
}
List<OutputVATInvoiceInfoDto> finalList = stream.sorted(Comparator.comparing(OutputVATInvoiceInfoDto::getInvoiceDate)).collect(Collectors.toList());
qResult.getPageInfo().setTotalCount(finalList.size());
if (finalList.size() > 0) {
PagingList pagingList = new PagingList(finalList, qResult.getPageInfo());
qResult.setList(pagingList.getPagingList());
}
return qResult;
}
}
...@@ -3,9 +3,7 @@ package pwc.taxtech.atms.vat.service.impl; ...@@ -3,9 +3,7 @@ package pwc.taxtech.atms.vat.service.impl;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import pwc.taxtech.atms.vat.dao.CompanyBalanceMapper; import pwc.taxtech.atms.vat.dao.*;
import pwc.taxtech.atms.vat.dao.VatEnterpriseAccountMapper;
import pwc.taxtech.atms.vat.dao.VatStandardAccountMapper;
public class VatAbstractService { public class VatAbstractService {
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); protected final Logger logger = LoggerFactory.getLogger(this.getClass());
...@@ -16,4 +14,9 @@ public class VatAbstractService { ...@@ -16,4 +14,9 @@ public class VatAbstractService {
VatEnterpriseAccountMapper vatEnterpriseAccountMapper; VatEnterpriseAccountMapper vatEnterpriseAccountMapper;
@Autowired @Autowired
VatStandardAccountMapper vatStandardAccountMapper; VatStandardAccountMapper vatStandardAccountMapper;
@Autowired
InputVATInvoiceMapper inputVATInvoiceMapper;
@Autowired
OutputVATInvoiceMapper outputVATInvoiceMapper;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment