Commit ccaa0add authored by neo's avatar neo

[dev] QueryAuditAdjust impl

parent a3a74c96
......@@ -4,6 +4,8 @@ import com.google.common.collect.Lists;
import com.mysql.jdbc.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.PagingList;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.DataImport;
import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.constant.enums.EnumValidationType;
......@@ -26,10 +28,13 @@ import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction;
import java.util.stream.Collectors;
import static pwc.taxtech.atms.constant.Constant.WholeYear;
......@@ -166,7 +171,7 @@ public class JournalEntryImportServiceImpl {
List<VoucherDtoOnlyForImport> emptyItems = voucherList.stream().filter(dto -> StringUtils.isEmptyOrWhitespaceOnly(dto.AcctCode)
|| dto.Credit == null || dto.Debit == null).collect(Collectors.toList());
if(emptyItems.size()>0){
if (emptyItems.size() > 0) {
result.setResult(false);
OperationResultDto<List<VoucherDtoOnlyForImport>> rr = new OperationResultDto<>();
rr.setData(emptyItems);
......@@ -175,9 +180,9 @@ public class JournalEntryImportServiceImpl {
result.getData().add(rr);
}
emptyItems=voucherList.stream().filter(dto->(dto.AcctCode != null && dto.AcctCode.length() > 50)
emptyItems = voucherList.stream().filter(dto -> (dto.AcctCode != null && dto.AcctCode.length() > 50)
|| (dto.Summary != null && dto.Summary.length() > 500)).collect(Collectors.toList());
if(emptyItems.size()>0){
if (emptyItems.size() > 0) {
result.setResult(false);
result.setResult(false);
OperationResultDto<List<VoucherDtoOnlyForImport>> rr = new OperationResultDto<>();
......@@ -187,8 +192,8 @@ public class JournalEntryImportServiceImpl {
result.getData().add(rr);
}
if(result.getResult()){
if(importType==EnumTbImportType.CoverImport.getCode()){
if (result.getResult()) {
if (importType == EnumTbImportType.CoverImport.getCode()) {
Set<Integer> perods = voucherList.stream().collect(Collectors.groupingBy(VoucherDtoOnlyForImport::getPeriod,
Collectors.counting())).keySet();
......@@ -197,18 +202,46 @@ public class JournalEntryImportServiceImpl {
voucherMapper.deleteByExample(example);
}
voucherList.forEach(m->voucherMapper.insert(m.extractVoucher()));
voucherList.forEach(m -> voucherMapper.insert(m.extractVoucher()));
}
return result;
}
public List<VoucherDto> GetAuditAdjust(int period) {
return null;
public List<Voucher> GetAuditAdjust(int period) {
VoucherExample example = new VoucherExample();
example.createCriteria().andPeriodEqualTo(period).andImportTypeEqualTo(VatImportType.AuditAdjust.getCode());
List<Voucher> result = voucherMapper.selectByExample(example);
result.stream().sorted(Comparator.comparing(Voucher::getAcctCode));
return result;
}
public PagingResultDto<VoucherDto> QueryAuditAdjust(QueryJeDto queryDto) {
return null;
public PagingResultDto<Voucher> QueryAuditAdjust(QueryJeDto queryDto) {
PagingResultDto<Voucher> qRsult = new PagingResultDto<>();
qRsult.setPageInfo(queryDto.getPageInfo());
qRsult.setList(new ArrayList<>());
qRsult.setCalculateData(new Voucher());
VoucherExample example = new VoucherExample();
VoucherExample.Criteria criteria = example.createCriteria();
criteria.andImportTypeEqualTo(VatImportType.AuditAdjust.getCode());
if (queryDto.getPeriodId() > Constant.WholeYear) criteria.andPeriodEqualTo(queryDto.getPeriodId());
List<Voucher> query = voucherMapper.selectByExample(example);
qRsult.getPageInfo().setTotalCount(query.size());
BigDecimal sumDebit = new BigDecimal(0);
BigDecimal sumCredit = new BigDecimal(0);
if (query.size() > 0)
for (Voucher v : query) {
sumDebit = sumDebit.add(v.getDebit());
sumCredit = sumCredit.add(v.getCredit());
}
qRsult.getCalculateData().setDebit(sumDebit);
qRsult.getCalculateData().setCredit(sumCredit);
if(qRsult.getPageInfo().getTotalCount()>0){
PagingList pagingList = new PagingList(query, qRsult.getPageInfo());
qRsult.setList(pagingList.getPagingList());
}
return qRsult;
}
}
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