Commit 2d52fc08 authored by neo's avatar neo

[dev] use page helper query input and output invoice

parent 29bd98ce
......@@ -533,6 +533,21 @@ public class DateUtils {
return true;
}
public static String getPeriodBegin(int year, int period) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.set(year, period - 1, 1, 0, 0, 0);
return sdf.format(calendar.getTime());
}
public static String getPeriodEnd(int year, int period) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.set(year, period - 1, -1, 23, 59, 59);
return sdf.format(calendar.getTime());
}
// /***************************************************************************
// * //nd=1表示返回的值中包含年度 //yf=1表示返回的值中包含月份 //rq=1表示返回的值中包含日期 //format表示返回的格式 1
// * 以年月日中文返回 2 以横线-返回 // 3 以斜线/返回 4 以缩写不带其它符号形式返回 // 5 以点号.返回
......
......@@ -48,6 +48,16 @@ public final class Constant {
public static final String EMPTY = "";
public static final String DateTimeFormate = "%d年%d月";
public static final String INPUT_RZJG_SUCCESS="0";
public static final String INPUT_RZJG_FAILED="1";
public static final String INPUT_RZZT_NOT_BEGIN="0";
public static final String INPUT_RZZT_BEGINNING="1";
public static final String INPUT_RZZT_OVER="2";
public static final String OUTPUT_KPZT_NO="0";
public static final String OUTPUT_KPZT_YES="1";
public static class DataSourceName {
public static final String KeyValueDataSource = "KeyValueDataSource";
public static final String InputInvoiceDataSource = "IncomeDataSource";
......
......@@ -37,12 +37,14 @@ public class InputInvoiceImportController {
@RequestMapping(value = "inputInvoicePreviewList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
PageInfo<InputInvoice> getInputInvoiceTreeViewData(@RequestBody InputInvoicePreviewQueryParam paras) {
return inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras);
PageInfo<InputInvoice> getInputInvoiceTreeViewData(@RequestBody InputInvoicePreviewQueryParam paras,
@RequestHeader("from") String projectId) {
return inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras, projectId);
}
@RequestMapping(value = "exportQueryData/get", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void downloadInvoiceQueryData(@RequestBody InputInvoicePreviewQueryParam paras, HttpServletResponse response) {
public void downloadInvoiceQueryData(@RequestBody InputInvoicePreviewQueryParam paras, HttpServletResponse response,
@RequestHeader("from") String projectId) {
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + UUID.randomUUID() + ".xlsx");
response.setHeader("x-file-name", UUID.randomUUID() + ".xlsx");
......@@ -50,7 +52,7 @@ public class InputInvoiceImportController {
OutputStream os = null;
try {
os = response.getOutputStream();
int count = getDownloadFilePath(paras, os);
int count = getDownloadFilePath(paras, os, projectId);
if (count == 0) {
response.setStatus(SC_NO_CONTENT);
......@@ -73,8 +75,8 @@ public class InputInvoiceImportController {
return ResponseEntity.ok().body(inputInvoiceDataImportService.getInputInvoiceItemList(period));
}
private int getDownloadFilePath(InputInvoicePreviewQueryParam paras, OutputStream outputStream) {
List<InputInvoice> list = inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras).getList();
private int getDownloadFilePath(InputInvoicePreviewQueryParam paras, OutputStream outputStream, String projectId) {
List<InputInvoice> list = inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras, projectId).getList();
if (list.size() == 0) {
return 0;
}
......
......@@ -5,11 +5,7 @@ import com.github.pagehelper.util.StringUtil;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import pwc.taxtech.atms.constant.enums.EnumModule;
import pwc.taxtech.atms.dpo.PagingResultDto;
......@@ -50,8 +46,9 @@ public class OutputInvoiceController {
private FileUploadAdapter fileUploadAdapter;
@RequestMapping(value = "queryOutputInvoiceList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public PageInfo<OutputInvoice> queryOutputInvoiceList(@RequestBody QueryOutputDto queryDto) {
return outputInvoiceService.queryOutputInvoiceList(queryDto);
public PageInfo<OutputInvoice> queryOutputInvoiceList(@RequestBody QueryOutputDto queryDto,
@RequestHeader("from") String projectId) {
return outputInvoiceService.queryOutputInvoiceList(queryDto,projectId);
}
@RequestMapping(value = "getExportOutputInvoiceList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
......
......@@ -7,11 +7,14 @@ import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.constant.enums.EnumValidationType;
import pwc.taxtech.atms.dao.ProjectMapper;
import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceDto;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.invoice.InputInvoiceMapper;
import pwc.taxtech.atms.vat.dao.InputVatInvoiceItemMapper;
import pwc.taxtech.atms.vat.dao.InputVatInvoiceMapper;
......@@ -21,6 +24,9 @@ import pwc.taxtech.atms.vat.entity.*;
import java.io.StringReader;
import java.util.*;
import static pwc.taxtech.atms.constant.Constant.INPUT_RZJG_SUCCESS;
import static pwc.taxtech.atms.constant.Constant.INPUT_RZZT_OVER;
@Service
public class InputInvoiceDataImportServiceImpl {
private static final String _tableName = "InputVATInvoice";
......@@ -35,10 +41,18 @@ public class InputInvoiceDataImportServiceImpl {
private InputVatInvoiceItemMapper inputVATInvoiceItemMapper;
@Autowired
private InputInvoiceMapper inputInvoiceMapper;
@Autowired
private ProjectMapper projectMapper;
public PageInfo<InputInvoice> getInputInvoiceTreeViewData(InputInvoicePreviewQueryParam paras, String projectId) {
Project project = projectMapper.selectByPrimaryKey(projectId);
InputInvoiceExample invoiceExample = new InputInvoiceExample();
invoiceExample.createCriteria().andCOMPANYIDEqualTo(project.getCode()).andRZSJBetween(DateUtils.getPeriodBegin(
project.getYear(), paras.getPeriodStart()), DateUtils.getPeriodEnd(project.getYear(), paras.getPeriodEnd()))
.andRZJGEqualTo(INPUT_RZJG_SUCCESS).andRZZTEqualTo(INPUT_RZZT_OVER);
public PageInfo<InputInvoice> getInputInvoiceTreeViewData(InputInvoicePreviewQueryParam paras) {
PageHelper.startPage(paras.getPageInfo().getPageIndex(), paras.getPageInfo().getPageSize());
List<InputInvoice> invoices = inputInvoiceMapper.selectByExample(new InputInvoiceExample());
List<InputInvoice> invoices = inputInvoiceMapper.selectByExample(invoiceExample);
PageInfo<InputInvoice> pageInfo = new PageInfo<>(invoices);
return pageInfo;
}
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import javafx.geometry.Orientation;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
......@@ -17,12 +18,19 @@ import org.reflections.util.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.dao.OrganizationMapper;
import pwc.taxtech.atms.dao.ProjectMapper;
import pwc.taxtech.atms.dpo.PagingResultDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.ImportOutputInvoiceDto;
import pwc.taxtech.atms.dto.vatdto.QueryEvidenceDto;
import pwc.taxtech.atms.entity.Organization;
import pwc.taxtech.atms.entity.OrganizationExample;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.invoice.OutputInvoiceMapper;
import pwc.taxtech.atms.service.impl.Message;
import pwc.taxtech.atms.vat.dao.ImportFileMapper;
import pwc.taxtech.atms.vat.dao.OutputVatInvoiceItemMapper;
import pwc.taxtech.atms.vat.dao.OutputVatInvoiceMapper;
......@@ -38,6 +46,8 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static pwc.taxtech.atms.constant.Constant.OUTPUT_KPZT_YES;
@Service
public class OutputInvoiceServiceImpl {
@Autowired
......@@ -52,10 +62,22 @@ public class OutputInvoiceServiceImpl {
private OutputVatInvoiceItemMapper outputVATInvoiceItemMapper;
@Autowired
private OutputInvoiceMapper outputInvoiceMapper;
@Autowired
private ProjectMapper projectMapper;
@Autowired
private OrganizationMapper organizationMapper;
public PageInfo<OutputInvoice> queryOutputInvoiceList(QueryOutputDto queryDto, String projectId) {
Project project = projectMapper.selectByPrimaryKey(projectId);
Organization organization = organizationMapper.selectByPrimaryKey(project.getOrganizationId());
OutputInvoiceExample outputInvoiceExample = new OutputInvoiceExample();
outputInvoiceExample.createCriteria().andXFSHEqualTo(organization.getTaxPayerNumber()).andKPZTEqualTo(OUTPUT_KPZT_YES).
andKPRQBetween(DateUtils.getPeriodBegin(project.getYear(), queryDto.getPeriodStart()),
DateUtils.getPeriodEnd(project.getYear(), queryDto.getPeriodEnd()));
public PageInfo<OutputInvoice> queryOutputInvoiceList(QueryOutputDto queryDto) {
PageHelper.startPage(queryDto.getPageInfo().getPageIndex(),queryDto.getPageInfo().getPageSize());
List<OutputInvoice> invoices = outputInvoiceMapper.selectByExample(new OutputInvoiceExample());
PageHelper.startPage(queryDto.getPageInfo().getPageIndex(), queryDto.getPageInfo().getPageSize());
List<OutputInvoice> invoices = outputInvoiceMapper.selectByExample(outputInvoiceExample);
PageInfo<OutputInvoice> pageInfo = new PageInfo<>(invoices);
return pageInfo;
}
......
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