Commit e99a0db2 authored by neo's avatar neo

[DEV] ] query Invoice Voucher mapping

parent 2473dbeb
package pwc.taxtech.atms.common;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
......@@ -151,4 +152,6 @@ public class CommonUtils {
}
return result;
}
}
package pwc.taxtech.atms.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
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.vat.service.impl.VoucherInvoiceMappingServiceImpl;
@RequestMapping(value = "api/v1/vimapping")
@RestController
public class VoucherInvoiceMappingController {
@Autowired
private VoucherInvoiceMappingServiceImpl voucherInvoiceMappingService;
@RequestMapping(value = "getvmappings/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity GetInvoiceMappings(@PathVariable Integer period) {
return ResponseEntity.ok().body(voucherInvoiceMappingService.getVourcherMappings(period));
}
@RequestMapping(value = "getimappings/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity ValidDBVoucherMapping(@PathVariable Integer period) {
return ResponseEntity.ok().body(voucherInvoiceMappingService.getInvoiceMappings(period));
}
}
......@@ -2,13 +2,16 @@ package pwc.taxtech.atms.vat.service.impl;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.vatdto.CustomsInvoiceDto;
import pwc.taxtech.atms.vat.entity.CustomsInvoice;
import pwc.taxtech.atms.vat.entity.CustomsInvoiceExample;
import pwc.taxtech.atms.vat.service.CustomsInvoiceService;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@Service
......@@ -43,8 +46,29 @@ public class CustomsInvoiceServiceImpl extends VatAbstractService implements Cus
@Override
public List<CustomsInvoiceDto> getCustomsInvoicesByPeriodId(Integer periodId) {
CustomsInvoiceExample example = new CustomsInvoiceExample();
// example.createCriteria().andPeriodIdEqualTo(periodId)
example.createCriteria().andPeriodIdEqualTo(periodId);
return null;
List<CustomsInvoice> result=customsInvoiceMapper.selectByExample(example);
result.sort(Comparator.comparing(CustomsInvoice::getPayNum));
int seqNo = 1;
List<CustomsInvoiceDto> dtos = new ArrayList<>(result.size());
for(CustomsInvoice ci:result){
CustomsInvoiceDto dto = new CustomsInvoiceDto();
try {
FieldsMapper.map(ci,dto);
dto.setSeqNo(seqNo++);
dto.setInvoiceAmount(ci.getInvoiceAmount().setScale(2,BigDecimal.ROUND_HALF_UP));
dto.setInvoiceTaxAmount(ci.getInvoiceTaxAmount().setScale(2,BigDecimal.ROUND_HALF_UP));
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
return dtos;
}
}
package pwc.taxtech.atms.vat.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dao.AreaRegionMapper;
import pwc.taxtech.atms.vat.dao.InvoiceMappingMapper;
import pwc.taxtech.atms.vat.dao.VoucherMappingMapper;
import pwc.taxtech.atms.vat.entity.InvoiceMapping;
import pwc.taxtech.atms.vat.entity.InvoiceMappingExample;
import pwc.taxtech.atms.vat.entity.VoucherMapping;
import pwc.taxtech.atms.vat.entity.VoucherMappingExample;
import java.util.Comparator;
import java.util.List;
@Service
public class VoucherInvoiceMappingServiceImpl {
@Autowired
private InvoiceMappingMapper invoiceMappingMapper;
@Autowired
private VoucherMappingMapper voucherMappingMapper;
public List<VoucherMapping> getVourcherMappings(Integer period) {
VoucherMappingExample example = new VoucherMappingExample();
example.createCriteria().andPeriodEqualTo(period);
List<VoucherMapping> result = voucherMappingMapper.selectByExample(example);
result.sort(Comparator.comparing(invoiceMapping -> invoiceMapping.getTranCode() + "_"
+ invoiceMapping.getGroup() + "_" + invoiceMapping.getItemID()));
return result;
}
public List<InvoiceMapping> getInvoiceMappings(Integer period) {
InvoiceMappingExample example = new InvoiceMappingExample();
example.createCriteria().andPeriodEqualTo(period);
List<InvoiceMapping> result = invoiceMappingMapper.selectByExample(example);
result.sort(Comparator.comparing(invoiceMapping -> invoiceMapping.getPeriod() + "_"
+ invoiceMapping.getInvoiceCode() + "_" + invoiceMapping.getInvoiceNumber()));
return result;
}
}
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