Commit 302ebf47 authored by neo's avatar neo

[DEV] ImportJournalEntryData impl

parent 55d2266d
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.vat.entity.Voucher;
import java.math.BigDecimal;
import java.util.Date;
......@@ -25,4 +27,34 @@ public class VoucherDtoOnlyForImport {
public Integer Status;
public Integer PartBilledPeriod;
public Integer BilledPeriod;
public Integer getPeriod() {
return Period;
}
public Voucher extractVoucher(){
Voucher voucher = new Voucher();
voucher.setVoucherID(VoucherID);
voucher.setVID(VID);
voucher.setDate(date);
voucher.setGroup(Group);
voucher.setPeriod(Period);
voucher.setCustomerCode(CustomerCode);
voucher.setCustomerName(CustomerName);
voucher.setSummary(Summary);
voucher.setAcctCode(AcctCode);
voucher.setDebit(Debit);
voucher.setCredit(Credit);
voucher.setAttach(Attach);
voucher.setItemID(ItemID);
voucher.setCreateTime(CreateTime);
voucher.setImportType(ImportType);
voucher.setCreatorID(CreatorID);
voucher.setMonthID(MonthID);
voucher.setOriginalPeriod(OriginalPeriod);
voucher.setStatus(Status);
voucher.setPartBilledPeriod(PartBilledPeriod);
voucher.setBilledPeriod(BilledPeriod);
return voucher;
}
}
......@@ -2,6 +2,8 @@ package pwc.taxtech.atms.vat.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.constant.enums.EnumValidationType;
import pwc.taxtech.atms.constant.enums.VatImportType;
import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
......@@ -11,13 +13,19 @@ import pwc.taxtech.atms.dto.vatdto.VoucherDto;
import pwc.taxtech.atms.dto.vatdto.VoucherDtoOnlyForImport;
import pwc.taxtech.atms.vat.dao.JournalEntryImportMapper;
import pwc.taxtech.atms.vat.dao.ValidationInfoMapper;
import pwc.taxtech.atms.vat.dao.VoucherMapper;
import pwc.taxtech.atms.vat.entity.ValidationInfo;
import pwc.taxtech.atms.vat.entity.ValidationInfoExample;
import pwc.taxtech.atms.vat.entity.Voucher;
import pwc.taxtech.atms.vat.entity.VoucherExample;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import static pwc.taxtech.atms.constant.Constant.WholeYear;
......@@ -29,6 +37,11 @@ public class JournalEntryImportServiceImpl {
@Autowired
ValidationInfoMapper validationInfoMapper;
private final static String _tableName = "Voucher";
private final static String _validationTableName = "ValidationInfo";
@Autowired
private VoucherMapper voucherMapper;
public PagingResultDto<VoucherDto> qeryJournalEntryData(QueryJeDto queryJeDto) {
PagingResultDto<VoucherDto> qResult = new PagingResultDto<VoucherDto>();
qResult.setPageInfo(queryJeDto.getPageInfo());
......@@ -88,13 +101,41 @@ public class JournalEntryImportServiceImpl {
if (period.intValue() != WholeYear)
validationInfoExample.createCriteria().andImportTypeIdEqualTo(type).andPeriodIdEqualTo(period);
else validationInfoExample.createCriteria().andImportTypeIdEqualTo(type);
return validationInfoMapper.selectByExample(validationInfoExample);
}
public void ImportJournalEntryData(List<VoucherDtoOnlyForImport> voucherList, Integer importType, String id) {
public void ImportJournalEntryData(List<VoucherDtoOnlyForImport> journalEntryList, Integer importType, String userID) {
if (journalEntryList.size() > 0) {
Set<Integer> periods = journalEntryList.stream().collect(Collectors.groupingBy(
VoucherDtoOnlyForImport::getPeriod, Collectors.counting())).keySet();
journalEntryList.forEach(m -> {
m.VoucherID = UUID.randomUUID().toString();
m.CreatorID = userID;
m.CreateTime = new Date();
});
if (importType == EnumTbImportType.CoverImport.getCode()) {
periods.forEach(m -> ClearTableData(m, _tableName));
}
journalEntryList.forEach(m->voucherMapper.insert(m.extractVoucher()));
// ValidateJournalEntryByPeriods(userID);//todo:[validation] to be continue (neo)
}
}
private void ClearTableData(Integer period, String tableName) {
switch (tableName) {
case _tableName:
VoucherExample example = new VoucherExample();
example.createCriteria().andPeriodEqualTo(period).andImportTypeEqualTo(VatImportType.JournalEntry.getCode());
voucherMapper.deleteByExample(period > 0 ? example : null);
break;
case _validationTableName:
ValidationInfoExample example1 = new ValidationInfoExample();
example1.createCriteria().andPeriodIdEqualTo(period).andImportTypeIdEqualTo(EnumValidationType.JournalEntry.getCode());
validationInfoMapper.deleteByExample(period > 0 ? example1 : null);
}
}
public OperationResultDto<List<OperationResultDto<List<VoucherDtoOnlyForImport>>>> ImportAuditAdjust(List<VoucherDtoOnlyForImport> voucherList,
......
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