Commit 24f65265 authored by neo's avatar neo

[dev] custmons invoice get data for display impl

parent bc625ef9
......@@ -2,12 +2,18 @@ package pwc.taxtech.atms.controller;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSON;
import org.nutz.lang.Lang;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -18,12 +24,19 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.thymeleaf.util.StringUtils;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.PagingDto;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.customer.CustomerDto;
import pwc.taxtech.atms.dto.customer.CustomerValidateInfoDto;
import pwc.taxtech.atms.dto.vatdto.CustomsInvoiceDto;
import pwc.taxtech.atms.dto.vatdto.CustomsInvoiceFilter;
import pwc.taxtech.atms.dto.vatdto.JsonCustomsInvoice;
import pwc.taxtech.atms.service.CustomerService;
/** @see PwC.Tax.Tech.Atms.WebApi.Controllers.CustomerController.cs */
/**
*/
@RestController
@RequestMapping("/api/v1/customer")
public class CustomerController {
......@@ -37,7 +50,8 @@ public class CustomerController {
// @ApiImplicitParam(name = "customerDtoList", value = "customerDto List",
// required = true, dataType = "List<CustomerDto>")
@RequestMapping(value = "/AddRange", method = RequestMethod.POST)
public @ResponseBody List<OperationResultDto<CustomerDto>> addRange(
public @ResponseBody
List<OperationResultDto<CustomerDto>> addRange(
@RequestBody List<CustomerDto> customerDtoList) {
logger.debug("CustomerController /AddRange");
return customerService.addRange(customerDtoList);
......@@ -46,14 +60,16 @@ public class CustomerController {
@ApiOperation(value = "财务数据账套下客户查询")
@ApiImplicitParam(name = "ID", value = "记录ID", required = true, dataType = "java.lang.String")
@RequestMapping(value = "/getByID", method = RequestMethod.GET)
public @ResponseBody CustomerValidateInfoDto getByID(@RequestParam(name = "ID") String setID) {
public @ResponseBody
CustomerValidateInfoDto getByID(@RequestParam(name = "ID") String setID) {
logger.debug("enter getByID");
return customerService.getByEnterpriseAccountSetID(setID);
}
@ApiOperation(value = "财务数据所有客户查询")
@RequestMapping(value = "/get", method = RequestMethod.GET)
public @ResponseBody List<CustomerDto> getCustomer() {
public @ResponseBody
List<CustomerDto> getCustomer() {
logger.debug("enter getCustomer");
return customerService.getCustomer();
}
......@@ -62,7 +78,8 @@ public class CustomerController {
// @ApiImplicitParam(name = "customerDtoList", value = "customerDto List",
// required = true, dataType = "List<CustomerDto>")
@RequestMapping(value = "/DeleteRange", method = RequestMethod.POST)
public @ResponseBody OperationResultDto<String> deleteRange(@RequestBody List<CustomerDto> customerDtoList) {
public @ResponseBody
OperationResultDto<String> deleteRange(@RequestBody List<CustomerDto> customerDtoList) {
logger.debug("enter deleteRange");
return customerService.deleteRange(customerDtoList);
}
......@@ -71,7 +88,8 @@ public class CustomerController {
// @ApiImplicitParam(name = "customerDtoList", value = "customerDto List",
// required = true, dataType = "List<CustomerDto>")
@RequestMapping(value = "/UpdateRange", method = RequestMethod.POST)
public @ResponseBody List<OperationResultDto<CustomerDto>> updateRange(
public @ResponseBody
List<OperationResultDto<CustomerDto>> updateRange(
@RequestBody List<CustomerDto> customerDtoList) {
logger.debug("enter updateRange");
return customerService.updateRange(customerDtoList);
......@@ -81,7 +99,8 @@ public class CustomerController {
// @ApiImplicitParam(name = "file", value = "file", required = true, dataType =
// "CommonsMultipartFile")
@RequestMapping(value = "/Upload", method = RequestMethod.POST)
public @ResponseBody Object upload(@RequestParam(value = "file", required = false) CommonsMultipartFile inputFile,
public @ResponseBody
Object upload(@RequestParam(value = "file", required = false) CommonsMultipartFile inputFile,
@RequestParam(value = "enterpriseAccountID", required = false) String enterpriseAccountID,
@RequestParam(value = "action", required = false) String action) {
logger.debug("enter upload");
......@@ -104,4 +123,138 @@ public class CustomerController {
}
return customerService.upload(input, inputFile.getOriginalFilename(), action, enterpriseAccountID);
}
@RequestMapping(value = "GetCustomsInvoiceDataForDisplay", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity GetCustomsInvoiceDataForDisplay(@RequestParam Integer fromPeriod, @RequestParam Integer toPeriod,
@RequestParam String criteria, @RequestParam String pagination) {
CustomsInvoiceFilter filter = new CustomsInvoiceFilter();
if (!StringUtils.isEmpty(criteria) && criteria != "null")
filter = JSON.parseObject(criteria, CustomsInvoiceFilter.class);
else
filter = null;
// PAGINATION INFORMATION:
PagingDto paging = new PagingDto();
if (!StringUtils.isEmpty(pagination) && pagination != "null") {
paging = JSON.parseObject(pagination, PagingDto.class);
} else
paging = null;
String passResponse = ConvertCustomsInvoiceDataToJson(fromPeriod, toPeriod, filter, paging);
return ResponseEntity.ok(passResponse);
}
private String ConvertCustomsInvoiceDataToJson(int fromPeriod, int toPeriod, CustomsInvoiceFilter filter, PagingDto pagination) {
String result = "";
List<CustomsInvoiceDto> balanceList = customerService.GetCustomsInvoicesByPeriodIds(fromPeriod, toPeriod);
if (filter != null && !balanceList.isEmpty())
balanceList = FilterCustomsInvoiceDataList(filter, balanceList);
if (pagination != null) {
int pageAskingFor = 0;
if (pagination.getPageIndex() > 0)
pageAskingFor = pagination.getPageIndex() - 1;
// Update Total Counts:
pagination.setTotalCount(balanceList.size());
balanceList = balanceList.subList(pageAskingFor * pagination.getPageSize(), pageAskingFor * pagination.getPageSize() + pagination.getPageSize());
}
List<JsonCustomsInvoice> recordList = new ArrayList<>();
JsonCustomsInvoice record;
int indexNumber = 1;
for (CustomsInvoiceDto item : balanceList) {
record = new JsonCustomsInvoice();
record.RecordNumber = indexNumber + "";
record.CustomsId = item.getCustomsId();
record.PayNum = item.getPayNum();
record.IssueDate = new SimpleDateFormat("yyyy-MM-dd").format(item.getIssueDate());
record.InvoiceTaxAmount = item.getInvoiceTaxAmount() != null ? item.getInvoiceTaxAmount().toString() : "0.00";
record.InvoiceAmount = item.getInvoiceAmount() != null ? item.getInvoiceAmount().toString() : "0.00";
record.AuditResult = item.getAuditResult();
record.PeriodId = item.getPeriodId();
recordList.add(record);
indexNumber++;
}
PagingResultDto<JsonCustomsInvoice> listWithPaging = new PagingResultDto<>();
listWithPaging.setPageInfo(pagination);
listWithPaging.setList(recordList);
result = JSON.toJSONString(listWithPaging);
return result;
}
private List<CustomsInvoiceDto> FilterCustomsInvoiceDataList(CustomsInvoiceFilter filter, List<CustomsInvoiceDto> dataList) {
// Do filters:
if (!dataList.isEmpty()) {
// period:
//if (filter.getPeriodFrom ()!=null&& filter.PeriodFrom.Value > 0)
// dataList = dataList.stream().filter((-=> x.PeriodId.Value == filter.getPeriodFrom().doubleValue().ToList();
// payment number -- Added Like operation
if (!StringUtils.isEmpty(filter.getPayNum())) {
String[] names = filter.getPayNum().split(" ");
List<CustomsInvoiceDto> ds = new ArrayList<>();
for (String name : names) {
ds.addAll(dataList.stream().filter(x -> x.getPayNum().contains(name)).collect(Collectors.toList()));
}
dataList = ds;
}
// tax amount
if (filter.getTaxAmountFrom() != null || filter.getTaxAmountTo() != null) {
//both start and end dates are there
if (filter.getTaxAmountFrom() != null && filter.getTaxAmountTo() != null)
dataList = dataList.stream().filter(x -> x.getInvoiceAmount() != null && (filter.getTaxAmountFrom().doubleValue()
<= x.getInvoiceTaxAmount().doubleValue() && filter.getTaxAmountTo().doubleValue() >= x.getInvoiceTaxAmount().doubleValue()))
.collect(Collectors.toList());
else if (filter.getTaxAmountFrom() != null)
dataList = dataList.stream().filter(x -> x.getInvoiceTaxAmount() != null && filter.getTaxAmountFrom()
.doubleValue() <= x.getInvoiceTaxAmount().doubleValue()).collect(Collectors.toList());
else
dataList = dataList.stream().filter(x -> x.getInvoiceTaxAmount() != null && filter.getTaxAmountTo()
.doubleValue() >= x.getInvoiceTaxAmount().doubleValue()).collect(Collectors.toList());
}
// amount
if (filter.getInvoiceAmountFrom() != null || filter.getInvoiceAmountTo() != null) {
//both start and end dates are there
if (filter.getInvoiceAmountFrom() != null && filter.getInvoiceAmountTo() != null)
dataList = dataList.stream().filter(x -> x.getInvoiceAmount() != null && (filter.getInvoiceAmountFrom().doubleValue()
<= x.getInvoiceAmount().doubleValue() && filter.getInvoiceAmountTo().doubleValue()
>= x.getInvoiceAmount().doubleValue())).collect(Collectors.toList());
else if (filter.getInvoiceAmountFrom() != null)
dataList = dataList.stream().filter(x -> x.getInvoiceAmount() != null && filter.getInvoiceAmountFrom().doubleValue()
<= x.getInvoiceAmount().doubleValue()).collect(Collectors.toList());
else
dataList = dataList.stream().filter(x -> x.getInvoiceAmount() != null && filter.getInvoiceAmountTo().doubleValue()
>= x.getInvoiceAmount().doubleValue()).collect(Collectors.toList());
}
// invoice start date and/or invoice end date
if (filter.getInvoiceStartDate() != null || filter.getInvoiceEndDate() != null) {
//both start and end dates are there
if (filter.getInvoiceStartDate() != null && filter.getInvoiceEndDate() != null)
dataList = dataList.stream().filter(x -> x.getIssueDate() != null && (filter.getInvoiceStartDate()
.before(x.getIssueDate()) && filter.getInvoiceEndDate().after(x.getIssueDate()))).collect(Collectors.toList());
else if (filter.getInvoiceStartDate() != null)
dataList = dataList.stream().filter(x -> x.getIssueDate() != null && filter.getInvoiceStartDate()
.before(x.getIssueDate())).collect(Collectors.toList());
else
dataList = dataList.stream().filter(x -> x.getIssueDate() != null && filter.getInvoiceEndDate()
.after(x.getIssueDate())).collect(Collectors.toList());
}
}
return dataList;
}
}
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.vat.entity.CustomsInvoice;
import java.math.BigDecimal;
import java.util.Date;
......@@ -113,4 +115,17 @@ public class CustomsInvoiceDto {
public void setSeqNo(int seqNo) {
this.seqNo = seqNo;
}
public CustomsInvoiceDto extractFromEntity(CustomsInvoice entity){
setCustomsId(entity.getCustomsId());
setPayNum(entity.getPayNum());
setIssueDate(entity.getIssueDate());
setInvoiceTaxAmount(entity.getInvoiceTaxAmount());
setInvoiceAmount(entity.getInvoiceAmount());
setAuditResult(entity.getAuditResult());
setCreateTime(entity.getCreateTime());
setCreatorID(entity.getCreatorID());
setPeriodId(entity.getPeriodId());
return this;
}
}
package pwc.taxtech.atms.dto.vatdto;
import com.fasterxml.jackson.annotation.JsonProperty;
public class JsonCustomsInvoice {
@JsonProperty(value = "recordNumber", required = false)
public String RecordNumber;
@JsonProperty(value = "customsId", required = false)
public String CustomsId;
@JsonProperty(value = "payNum", required = false)
public String PayNum;
@JsonProperty(value = "issueDate", required = false)
public String IssueDate;
@JsonProperty(value = "invoiceTaxAmount", required = false)
public String InvoiceTaxAmount;
@JsonProperty(value = "invoiceAmount", required = false)
public String InvoiceAmount;
@JsonProperty(value = "auditResult", required = false)
public String AuditResult;
@JsonProperty(value = "createTime", required = false)
public String CreateTime;
@JsonProperty(value = "creatorID", required = false)
public String CreatorID;
@JsonProperty(value = "periodId", required = false)
public Integer PeriodId;
}
......@@ -6,6 +6,7 @@ import java.util.List;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.customer.CustomerDto;
import pwc.taxtech.atms.dto.customer.CustomerValidateInfoDto;
import pwc.taxtech.atms.dto.vatdto.CustomsInvoiceDto;
public interface CustomerService {
......@@ -20,4 +21,6 @@ public interface CustomerService {
List<OperationResultDto<CustomerDto>> updateRange(List<CustomerDto> customerDtoList);
Object upload(InputStream inputStream, String fileName, String action, String enterpriseAccountID);
List<CustomsInvoiceDto> GetCustomsInvoicesByPeriodIds(int fromPeriod, int toPeriod);
}
......@@ -4,6 +4,7 @@ import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -19,6 +20,7 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import pwc.taxtech.atms.dto.vatdto.CustomsInvoiceDto;
import pwc.taxtech.atms.exception.ApplicationException;
import pwc.taxtech.atms.common.AuthUserHelper;
import pwc.taxtech.atms.common.CommonConstants;
......@@ -41,8 +43,13 @@ import pwc.taxtech.atms.entitiy.CustomerExample.Criteria;
import pwc.taxtech.atms.entitiy.EnterpriseAccountSet;
import pwc.taxtech.atms.service.CustomerService;
import pwc.taxtech.atms.service.OperationLogService;
import pwc.taxtech.atms.vat.dao.CustomsInvoiceMapper;
import pwc.taxtech.atms.vat.entity.CustomsInvoice;
import pwc.taxtech.atms.vat.entity.CustomsInvoiceExample;
/** @see PwC.Tax.Tech.Atms.Admin.Application.Services.Impl.CustomerService.cs */
/**
* @see PwC.Tax.Tech.Atms.Admin.Application.Services.Impl.CustomerService.cs
*/
@Service
public class CustomerServiceImpl implements CustomerService {
......@@ -62,6 +69,8 @@ public class CustomerServiceImpl implements CustomerService {
@Autowired
private FileService fileService;
@Autowired
private CustomsInvoiceMapper customsInvoiceMapper;
@Override
public List<OperationResultDto<CustomerDto>> addRange(List<CustomerDto> customerDtoList) {
......@@ -249,6 +258,30 @@ public class CustomerServiceImpl implements CustomerService {
return finalResult;
}
@Override
public List<CustomsInvoiceDto> GetCustomsInvoicesByPeriodIds(int fromPeriod, int toPeriod) {
CustomsInvoiceExample example = new CustomsInvoiceExample();
example.createCriteria().andPeriodIdGreaterThanOrEqualTo(fromPeriod).andPeriodIdLessThanOrEqualTo(toPeriod);
List<CustomsInvoice> reuslt = customsInvoiceMapper.selectByExample(example);
reuslt.stream().sorted(Comparator.comparing(CustomsInvoice::getPayNum));
List<CustomsInvoiceDto> returnResult = new ArrayList<>();
int seqNo = 1;
for (CustomsInvoice r : reuslt) {
CustomsInvoiceDto dto = new CustomsInvoiceDto();
dto.setSeqNo(seqNo++);
if (r.getInvoiceAmount() != null) {
r.setInvoiceAmount(r.getInvoiceAmount().setScale(2));
}
if (r.getInvoiceTaxAmount() != null) {
r.setInvoiceTaxAmount(r.getInvoiceTaxAmount().setScale(2));
}
returnResult.add(dto.extractFromEntity(r));
}
return returnResult;
}
private List<OperationResultDto<CustomerDto>> saveData(String enterpriseAccountID,
List<CustomerDto> customerDtoList, String action) {
logger.debug("enter customerDtoList, enterpriseAccountID:{}, customerDtoList.size:{}, action:{}",
......
......@@ -61,7 +61,6 @@ import static pwc.taxtech.atms.constant.Constant.*;
@Service
public class ProjectServiceImpl implements ProjectService {
/**
* @see PwC.Tax.Tech.Atms..Admin.Application\Services\impl\ProjectService.cs
*/
private static final int FIRST_OR_DEFAULT = 0;
private static Logger LOGGER = LoggerFactory.getLogger(ProjectServiceImpl.class);
......
......@@ -43,7 +43,6 @@ import pwc.taxtech.atms.service.DimensionService;
import pwc.taxtech.atms.service.StatisticAttributeService;
/**
* @see PwC.Tax.Tech.Atms..Admin.Application\Services\impl\StatisticAttributeService.cs
*/
@Service
public class StatisticAttributeServiceImpl extends AbstractService implements StatisticAttributeService {
......
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