Commit 510679e9 authored by neo's avatar neo

[DEV] saveVourcherMappings impl

parent 1b005937
package pwc.taxtech.atms.constant;
public class DataImport {
public static final String DuplicateInputInvoices = "DuplicateInputInvoice";
public static final String InputInvoiceAlreadyPassed = "InputInvoiceAlreadyPassed";
public static final String NotHaveTotalInvoice = "NotHaveTotalInvoice";
public static final String LessThanDetailsTotal = "LessThanDetailsTotal";
public static final String DuplicateInDB = "DuplicateInDB";
public static final String DuplicateInFile = "DuplicateInFile";
public static final String EmptyField = "EmptyField";
public static final String OverLengthField = "OverLengthField";
}
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.vat.entity.VoucherMapping;
import java.util.Date;
import java.util.List;
public class VoucherMappingDto {
public String ID;
......@@ -12,4 +15,18 @@ public class VoucherMappingDto {
public String CreatorID;
public Date CreateTime;
public Boolean IsDuplicate;
public VoucherMapping extractVoucherMapping(){
VoucherMapping voucherMapping = new VoucherMapping();
voucherMapping.setID(ID);
voucherMapping.setTranCode(TranCode);
voucherMapping.setVID(VID);
voucherMapping.setGroup(Group);
voucherMapping.setPeriod(Period);
voucherMapping.setItemID(ItemID);
voucherMapping.setCreatorID(CreatorID);
voucherMapping.setCreateTime(CreateTime);
return voucherMapping;
}
}
package pwc.taxtech.atms.vat.service.impl;
import com.mysql.jdbc.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dao.AreaRegionMapper;
import pwc.taxtech.atms.constant.DataImport;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.InvoiceMappingDto;
import pwc.taxtech.atms.dto.vatdto.VoucherMappingDto;
......@@ -13,8 +14,10 @@ import pwc.taxtech.atms.vat.entity.InvoiceMappingExample;
import pwc.taxtech.atms.vat.entity.VoucherMapping;
import pwc.taxtech.atms.vat.entity.VoucherMappingExample;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class VoucherInvoiceMappingServiceImpl {
......@@ -45,11 +48,56 @@ public class VoucherInvoiceMappingServiceImpl {
public OperationResultDto<List<OperationResultDto<List<VoucherMappingDto>>>> saveVourcherMappings(List<VoucherMappingDto> list,
int period, boolean isAddition) {
return null;
OperationResultDto<List<OperationResultDto<List<VoucherMappingDto>>>> result = new OperationResultDto<>();
result.setResult(true);
result.setData(new ArrayList<OperationResultDto<List<VoucherMappingDto>>>());
List<VoucherMappingDto> emptyItems = list.stream().filter(m ->
StringUtils.isEmptyOrWhitespaceOnly(m.TranCode)
|| StringUtils.isEmptyOrWhitespaceOnly(m.VID)
|| StringUtils.isEmptyOrWhitespaceOnly(m.Group)
|| StringUtils.isEmptyOrWhitespaceOnly(m.ItemID)).collect(Collectors.toList());
if (emptyItems.size() > 0) {
result.setResult(false);
OperationResultDto<List<VoucherMappingDto>> rr = new OperationResultDto<>();
rr.setData(emptyItems);
rr.setResult(false);
rr.setResultMsg(DataImport.EmptyField);
result.getData().add(rr);
}
emptyItems = list.stream().filter(dto ->
dto.TranCode != null && dto.TranCode.length() > 50
|| (dto.VID != null && dto.VID.length() > 50) ||
(dto.Group != null && dto.Group.length() > 50) ||
(dto.ItemID != null && dto.ItemID.length() > 50)
).collect(Collectors.toList());
if (emptyItems.size() > 0) {
result.setResult(false);
OperationResultDto<List<VoucherMappingDto>> rr = new OperationResultDto<>();
rr.setData(emptyItems);
rr.setResult(false);
rr.setResultMsg(DataImport.OverLengthField);
result.getData().add(rr);
}
if (result.getResult()) {
if (!isAddition) {
VoucherMappingExample voucherMappingExample = new VoucherMappingExample();
voucherMappingExample.createCriteria().andPeriodEqualTo(period);
voucherMappingMapper.deleteByExample(voucherMappingExample);
}
list.forEach(m -> voucherMappingMapper.insert(m.extractVoucherMapping()));
}
// ValidDBVoucherMapping(period); todo:[validation] to be continue (neo)
return result;
}
public OperationResultDto<List<OperationResultDto<List<InvoiceMappingDto>>>> SaveInvoiceMappings(List<InvoiceMappingDto> list,
int period, boolean isAddition) {
int period, boolean isAddition) {
return null;
}
}
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