Commit a3a74c96 authored by neo's avatar neo

[dev] ImportAuditAdjust impl

parent 302ebf47
package pwc.taxtech.atms.vat.service.impl;
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.constant.DataImport;
import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.constant.enums.EnumValidationType;
import pwc.taxtech.atms.constant.enums.VatImportType;
......@@ -20,7 +23,9 @@ import pwc.taxtech.atms.vat.entity.Voucher;
import pwc.taxtech.atms.vat.entity.VoucherExample;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Set;
......@@ -119,7 +124,7 @@ public class JournalEntryImportServiceImpl {
periods.forEach(m -> ClearTableData(m, _tableName));
}
journalEntryList.forEach(m->voucherMapper.insert(m.extractVoucher()));
journalEntryList.forEach(m -> voucherMapper.insert(m.extractVoucher()));
// ValidateJournalEntryByPeriods(userID);//todo:[validation] to be continue (neo)
}
}
......@@ -139,8 +144,64 @@ public class JournalEntryImportServiceImpl {
}
public OperationResultDto<List<OperationResultDto<List<VoucherDtoOnlyForImport>>>> ImportAuditAdjust(List<VoucherDtoOnlyForImport> voucherList,
int period, Integer importType, String id) {
return null;
int period, Integer importType, String userID) {
OperationResultDto<List<OperationResultDto<List<VoucherDtoOnlyForImport>>>> result = new OperationResultDto<>();
result.setResult(true);
int num = 1;
for (VoucherDtoOnlyForImport v : voucherList) {
v.VoucherID = UUID.randomUUID().toString();
v.VID = String.format("%sNO%s", new SimpleDateFormat("MMddHHmmss").format(new Date()), num);
v.Group = v.VID;
num++;
v.CreatorID = userID;
if (v.CreateTime == null) {
v.date = new Date();
v.CreateTime = v.date;
}
v.ImportType = VatImportType.AuditAdjust.getCode();
}
result.setData(new ArrayList<>());
List<VoucherDtoOnlyForImport> emptyItems = voucherList.stream().filter(dto -> StringUtils.isEmptyOrWhitespaceOnly(dto.AcctCode)
|| dto.Credit == null || dto.Debit == null).collect(Collectors.toList());
if(emptyItems.size()>0){
result.setResult(false);
OperationResultDto<List<VoucherDtoOnlyForImport>> rr = new OperationResultDto<>();
rr.setData(emptyItems);
rr.setResult(false);
rr.setResultMsg(DataImport.EmptyField);
result.getData().add(rr);
}
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){
result.setResult(false);
result.setResult(false);
OperationResultDto<List<VoucherDtoOnlyForImport>> rr = new OperationResultDto<>();
rr.setData(emptyItems);
rr.setResult(false);
rr.setResultMsg(DataImport.OverLengthField);
result.getData().add(rr);
}
if(result.getResult()){
if(importType==EnumTbImportType.CoverImport.getCode()){
Set<Integer> perods = voucherList.stream().collect(Collectors.groupingBy(VoucherDtoOnlyForImport::getPeriod,
Collectors.counting())).keySet();
VoucherExample example = new VoucherExample();
example.createCriteria().andPeriodIn(Lists.newArrayList(period)).andImportTypeEqualTo(VatImportType.AuditAdjust.getCode());
voucherMapper.deleteByExample(example);
}
voucherList.forEach(m->voucherMapper.insert(m.extractVoucher()));
}
return result;
}
public List<VoucherDto> GetAuditAdjust(int period) {
......
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