Commit a8ebb8bb authored by ken.q.you's avatar ken.q.you

Ken 发票导出

parent fd860975
.*
rebel.xml
!.gitignore
!.mvn
/tmp
/temp
/target
/build
/logs
/atms-web/src/main/webapp/node_modules
**/*.iml
.*
rebel.xml
!.gitignore
!.mvn
/tmp
/temp
/target
/build
/logs
/atms-web/src/main/webapp/node_modules
**/*.iml
**/.idea/
/bin/
......@@ -2,4 +2,4 @@ rem see http://www.mybatis.org/generator/running/runningFromCmdLine.html
cd /d %~dp0
call java -classpath .;./* org.mybatis.generator.api.ShellRunner -configfile vatGeneratorConfig.xml -overwrite -verbose
echo @@@@@@@@@@@ DONE @@@@@@@@@@@
pause
pause
\ No newline at end of file
package pwc.taxtech.atms;
import pwc.taxtech.atms.dto.user.UserDto;
import pwc.taxtech.atms.service.OperationLogService;
import java.util.HashMap;
import java.util.Map;
public class AppCachePool {
private static Map<String, UserDto> CACHED_USERS = null;
private static Object _locker = new Object();
static {
CACHED_USERS = new HashMap<>();
}
public static UserDto getCachedUser(String name) {
String userName = name.toLowerCase();
synchronized (_locker) {
if (!CACHED_USERS.containsKey(userName)) {
UserDto dto = new UserDto();//TODO:should fixed to load from db (neo)
dto.setUserName("cach_test");
dto.setID("1");
CACHED_USERS.put(userName,dto);
}
return CACHED_USERS.get(userName);
}
}
}
package pwc.taxtech.atms;
import pwc.taxtech.atms.dto.user.UserDto;
import pwc.taxtech.atms.service.OperationLogService;
import java.util.HashMap;
import java.util.Map;
public class AppCachePool {
private static Map<String, UserDto> CACHED_USERS = null;
private static Object _locker = new Object();
static {
CACHED_USERS = new HashMap<>();
}
public static UserDto getCachedUser(String name) {
String userName = name.toLowerCase();
synchronized (_locker) {
if (!CACHED_USERS.containsKey(userName)) {
UserDto dto = new UserDto();//TODO:should fixed to load from db (neo)
dto.setUserName("cach_test");
dto.setID("1");
CACHED_USERS.put(userName,dto);
}
return CACHED_USERS.get(userName);
}
}
}
package pwc.taxtech.atms.controller;
import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.thirdparty.ExcelSheet;
import pwc.taxtech.atms.thirdparty.ExcelUtil;
import pwc.taxtech.atms.vat.service.InputInvoiceDataImportService;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
@RestController
@RequestMapping(value = "api/v1/inputInvoiceImport")
public class InputInvoiceImportController {
@Autowired
InputInvoiceDataImportService inputInvoiceDataImportService;
@RequestMapping(value = "inputInvoicePreviewList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
PagingResultDto<InputVATInvoiceDto> getInputInvoiceTreeViewData(@RequestBody InputInvoicePreviewQueryParam paras) {
return inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras);
}
@RequestMapping(value = "exportQueryData/get", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void downloadInvoiceQueryData(@RequestBody InputInvoicePreviewQueryParam paras, HttpServletResponse response) {
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");
OutputStream os = null;
try {
os = response.getOutputStream();
int count = getDownloadFilePath(paras, os);
if (count == 0) {
response.setStatus(HttpStatus.SC_NO_CONTENT);
} else {
response.setStatus(HttpStatus.SC_OK);
}
} catch (IOException e) {
e.printStackTrace();
}
}
private int getDownloadFilePath(InputInvoicePreviewQueryParam paras, OutputStream outputStream) {
List<InputVATInvoiceDto> list = inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras).getList();
if (list.size() == 0) {
//return 0;
}
Map<String, String> header = new HashMap<>();
header.put("PeriodID", "期间");
header.put("InvoiceDate", "开票日期");
header.put("InvoiceCode", "发票代码");
header.put("InvoiceNumber", "发票号码");
header.put("SellerTaxNumber", "供货方税号");
header.put("InvoiceTypeName", "发票类型");
header.put("Amount", "金额");
header.put("TaxAmount", "税额");
header.put("CertificationDate", "认证日期");
ExcelSheet excelSheetA = new ExcelSheet<>();
excelSheetA.setHeaders(header);
excelSheetA.setDataset(list);
excelSheetA.setSheetName("sheetA");
Map<String, String> header2 = new HashMap<>();
header2.put("PeriodID", "期间");
header2.put("InvoiceCode", "发票代码");
header2.put("InvoiceNumber", "发票号码");
header2.put("Amount", "金额");
header2.put("TaxAmount", "税额");
header2.put("TaxRate", "税率");
header2.put("ProductionName", "货物名称");
ExcelSheet excelSheetB = new ExcelSheet<>();
excelSheetB.setHeaders(header2);
excelSheetB.setSheetName("sheetB");
List<InputVATInvoiceItemDto> inputInvoiceItemList = new ArrayList<>();
for (InputVATInvoiceDto item : list) {
List<InputVATInvoiceItemDto> tempResult = inputInvoiceDataImportService.getInputInvoiceItemTreeViewData(item.getID());
for (InputVATInvoiceItemDto r : tempResult) {
inputInvoiceItemList.add(r);
}
}
excelSheetB.setDataset(inputInvoiceItemList);
List<ExcelSheet<InputVATInvoiceBaseDto>> sheets = new ArrayList<>();
sheets.add(excelSheetA);
sheets.add(excelSheetB);
ExcelUtil.exportExcel(sheets, outputStream);
return list.size();
}
}
package pwc.taxtech.atms.controller;
import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.thirdparty.ExcelSheet;
import pwc.taxtech.atms.thirdparty.ExcelUtil;
import pwc.taxtech.atms.vat.service.InputInvoiceDataImportService;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
@RestController
@RequestMapping(value = "api/v1/inputInvoiceImport")
public class InputInvoiceImportController {
@Autowired
InputInvoiceDataImportService inputInvoiceDataImportService;
@RequestMapping(value = "inputInvoicePreviewList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
PagingResultDto<InputVATInvoiceDto> getInputInvoiceTreeViewData(@RequestBody InputInvoicePreviewQueryParam paras) {
return inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras);
}
@RequestMapping(value = "exportQueryData/get", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void downloadInvoiceQueryData(@RequestBody InputInvoicePreviewQueryParam paras, HttpServletResponse response) {
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");
OutputStream os = null;
try {
os = response.getOutputStream();
int count = getDownloadFilePath(paras, os);
if (count == 0) {
response.setStatus(HttpStatus.SC_NO_CONTENT);
} else {
response.setStatus(HttpStatus.SC_OK);
}
} catch (IOException e) {
e.printStackTrace();
}
}
private int getDownloadFilePath(InputInvoicePreviewQueryParam paras, OutputStream outputStream) {
List<InputVATInvoiceDto> list = inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras).getList();
if (list.size() == 0) {
//return 0;
}
Map<String, String> header = new HashMap<>();
header.put("PeriodID", "期间");
header.put("InvoiceDate", "开票日期");
header.put("InvoiceCode", "发票代码");
header.put("InvoiceNumber", "发票号码");
header.put("SellerTaxNumber", "供货方税号");
header.put("InvoiceTypeName", "发票类型");
header.put("Amount", "金额");
header.put("TaxAmount", "税额");
header.put("CertificationDate", "认证日期");
ExcelSheet excelSheetA = new ExcelSheet<>();
excelSheetA.setHeaders(header);
excelSheetA.setDataset(list);
excelSheetA.setSheetName("sheetA");
Map<String, String> header2 = new HashMap<>();
header2.put("PeriodID", "期间");
header2.put("InvoiceCode", "发票代码");
header2.put("InvoiceNumber", "发票号码");
header2.put("Amount", "金额");
header2.put("TaxAmount", "税额");
header2.put("TaxRate", "税率");
header2.put("ProductionName", "货物名称");
ExcelSheet excelSheetB = new ExcelSheet<>();
excelSheetB.setHeaders(header2);
excelSheetB.setSheetName("sheetB");
List<InputVATInvoiceItemDto> inputInvoiceItemList = new ArrayList<>();
for (InputVATInvoiceDto item : list) {
List<InputVATInvoiceItemDto> tempResult = inputInvoiceDataImportService.getInputInvoiceItemTreeViewData(item.getID());
for (InputVATInvoiceItemDto r : tempResult) {
inputInvoiceItemList.add(r);
}
}
excelSheetB.setDataset(inputInvoiceItemList);
List<ExcelSheet<InputVATInvoiceBaseDto>> sheets = new ArrayList<>();
sheets.add(excelSheetA);
sheets.add(excelSheetB);
ExcelUtil.exportExcel(sheets, outputStream);
return list.size();
}
}
......@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.github.pagehelper.PageHelper;
import io.swagger.annotations.ApiOperation;
import pwc.taxtech.atms.controller.BaseController;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.input.CamelPagingDto;
......@@ -27,13 +28,14 @@ public class InvoiceManageController extends BaseController {
@Autowired
private InvoiceManageService invoiceManageService;
@ApiOperation(value = "查询所有发票")
@ResponseBody
@RequestMapping(value = "getInputInvoiceList", method = RequestMethod.POST)
public CamelPagingResultDto<InputInvoice> getInputInvoiceList(@RequestBody InputInvoiceQueryDto inputInvoiceQueryDto) {
CamelPagingResultDto<InputInvoice> resultDto = new CamelPagingResultDto<InputInvoice>();
try {
CamelPagingDto camelPagingDto=inputInvoiceQueryDto.getPagingDto()==null?new CamelPagingDto():inputInvoiceQueryDto.getPagingDto();
resultDto = invoiceManageService.getInputInvoiceList(inputInvoiceQueryDto);
//todo 业务代码
} catch (Exception e) {
......@@ -41,5 +43,14 @@ public class InvoiceManageController extends BaseController {
}
return resultDto;
}
@ApiOperation(value = "导出所有关联发票")
@ResponseBody
@RequestMapping(value = "exportInvoiceAllInfoList", method = RequestMethod.POST)
public String exportInvoiceAllInfoList(@RequestBody InputInvoiceQueryDto inputInvoiceQueryDto,String filename) {
String filePath=invoiceManageService.exportInvoiceAllInfoList(inputInvoiceQueryDto, inputInvoiceQueryDto.getPagingDto(), filename);
return null;
}
}
......@@ -2,14 +2,22 @@ package pwc.taxtech.atms.dto.input;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
public class CamelPagingResultDto<T> {
@JSONField(name="List")
private List<T> list;
@JSONField(name="PageInfo")
private CamelPagingDto pageInfo;
private T calculateData;
public CamelPagingResultDto() {
super();
}
public List<T> getList() {
public List<T> getList() {
return list;
}
......
......@@ -20,49 +20,29 @@ public class InputInvoiceQueryDto {
//发票类型
private Integer invoiceType;
//开票日期范围
private Date invoiceDate;
private Date invoiceDateForm;
private Date invoiceDateTo;
//上传日期范围
private Date uploadDate;
private Date uploadDateForm;
private Date uploadDateTo;
//票面金额范围
private BigDecimal amount;
private BigDecimal amountForm;
private BigDecimal amountTo;
//发票实体
private Integer invoiceEntityType;
//发票来源
private Integer invoiceSourceType;
//验真分类
private Integer verifyType;
//创建者
private String staffId;
private String createBy;
//序列号
private String serialNo;
// private String buyerAddress;
//
// private String buyerBankAccountNumber;
//
// private String buyerName;
//
// private String buyerPhone;
//
// private String buyerTaxNumber;
//
// private String checkCode;
//
// private String createBy;
//
// private Date createTime;
@Override
public String toString() {
return "InputInvoiceQueryDto [buyerBankName=" + buyerBankName + ", sellerName=" + sellerName
+ ", invoiceNumber=" + invoiceNumber + ", status=" + status + ", uploadType=" + uploadType
+ ", invoiceType=" + invoiceType + ", invoiceDate=" + invoiceDate + ", uploadDate=" + uploadDate
+ ", amount=" + amount + ", invoiceEntityType=" + invoiceEntityType + ", invoiceSourceType="
+ invoiceSourceType + ", staffId=" + staffId + ", serialNo=" + serialNo + ", pagingDto=" + pagingDto
+ "]";
}
private CamelPagingDto pagingDto;
......@@ -122,28 +102,71 @@ public class InputInvoiceQueryDto {
this.invoiceType = invoiceType;
}
public Date getInvoiceDate() {
return invoiceDate;
public Date getInvoiceDateForm() {
return invoiceDateForm;
}
public void setInvoiceDateForm(Date invoiceDateForm) {
this.invoiceDateForm = invoiceDateForm;
}
public Date getInvoiceDateTo() {
return invoiceDateTo;
}
public void setInvoiceDateTo(Date invoiceDateTo) {
this.invoiceDateTo = invoiceDateTo;
}
public Date getUploadDateForm() {
return uploadDateForm;
}
public void setUploadDateForm(Date uploadDateForm) {
this.uploadDateForm = uploadDateForm;
}
public Date getUploadDateTo() {
return uploadDateTo;
}
public void setUploadDateTo(Date uploadDateTo) {
this.uploadDateTo = uploadDateTo;
}
public void setInvoiceDate(Date invoiceDate) {
this.invoiceDate = invoiceDate;
public BigDecimal getAmountForm() {
return amountForm;
}
public Date getUploadDate() {
return uploadDate;
public void setAmountForm(BigDecimal amountForm) {
this.amountForm = amountForm;
}
public void setUploadDate(Date uploadDate) {
this.uploadDate = uploadDate;
public BigDecimal getAmountTo() {
return amountTo;
}
public BigDecimal getAmount() {
return amount;
public void setAmountTo(BigDecimal amountTo) {
this.amountTo = amountTo;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
public Integer getVerifyType() {
return verifyType;
}
public void setVerifyType(Integer verifyType) {
this.verifyType = verifyType;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Integer getInvoiceEntityType() {
......@@ -162,13 +185,7 @@ public class InputInvoiceQueryDto {
this.invoiceSourceType = invoiceSourceType;
}
public String getStaffId() {
return staffId;
}
public void setStaffId(String staffId) {
this.staffId = staffId;
}
public String getSerialNo() {
return serialNo;
......
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.input.CamelPagingDto;
import pwc.taxtech.atms.dto.input.CamelPagingResultDto;
import pwc.taxtech.atms.dto.input.InputInvoiceQueryDto;
import pwc.taxtech.atms.entitiy.InputInvoice;
......@@ -13,4 +14,14 @@ public interface InvoiceManageService {
* @return list
*/
CamelPagingResultDto<InputInvoice> getInputInvoiceList(InputInvoiceQueryDto inputInvoiceQueryDto);
/**
* 导出所有关联发票
* @param inputInvoiceQueryDto
* @param pagingDto
* @param fileName
* @return
*/
String exportInvoiceAllInfoList(InputInvoiceQueryDto inputInvoiceQueryDto, CamelPagingDto pagingDto, String fileName);
}
package pwc.taxtech.atms.service.impl;
import org.apache.commons.lang.ObjectUtils.Null;
import org.aspectj.weaver.WeakClassLoaderReference;
import org.hamcrest.core.Is;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import net.sf.jsqlparser.statement.select.Select;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.dao.CustomerMapper;
import pwc.taxtech.atms.dao.InputInvoiceMapper;
import pwc.taxtech.atms.dto.input.CamelPagingDto;
import pwc.taxtech.atms.dto.input.CamelPagingResultDto;
......@@ -21,11 +17,6 @@ import pwc.taxtech.atms.entitiy.InputInvoice;
import pwc.taxtech.atms.entitiy.InputInvoiceExample;
import pwc.taxtech.atms.service.InvoiceManageService;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class InvoiceManageServiceImpl extends BaseService implements InvoiceManageService {
......@@ -37,14 +28,20 @@ public class InvoiceManageServiceImpl extends BaseService implements InvoiceMana
InputInvoiceExample example=new InputInvoiceExample();
InputInvoiceExample.Criteria criteria=example.createCriteria();
if (inputInvoiceQueryDto.getAmount()!=null ) {
criteria.andAmountEqualTo(inputInvoiceQueryDto.getAmount());
if (inputInvoiceQueryDto.getAmountForm()!=null ) {
criteria.andAmountGreaterThanOrEqualTo(inputInvoiceQueryDto.getAmountForm());
}
if (inputInvoiceQueryDto.getAmountTo()!=null ) {
criteria.andAmountLessThanOrEqualTo(inputInvoiceQueryDto.getAmountTo());
}
if (inputInvoiceQueryDto.getBuyerBankName()!=null ) {
criteria.andBuyerBankNameEqualTo(inputInvoiceQueryDto.getBuyerBankName());
}
if (inputInvoiceQueryDto.getInvoiceDate()!=null ) {
criteria.andInvoiceDateEqualTo(inputInvoiceQueryDto.getInvoiceDate());
if (inputInvoiceQueryDto.getInvoiceDateForm()!=null ) {
criteria.andInvoiceDateGreaterThanOrEqualTo(inputInvoiceQueryDto.getInvoiceDateForm());
}
if (inputInvoiceQueryDto.getInvoiceDateTo()!=null ) {
criteria.andInvoiceDateLessThanOrEqualTo(inputInvoiceQueryDto.getInvoiceDateTo());
}
if (inputInvoiceQueryDto.getInvoiceEntityType()!=null ) {
criteria.andInvoiceEntityTypeEqualTo(inputInvoiceQueryDto.getInvoiceEntityType());
......@@ -64,18 +61,25 @@ public class InvoiceManageServiceImpl extends BaseService implements InvoiceMana
if (inputInvoiceQueryDto.getSerialNo()!=null ) {
criteria.andSerialNoEqualTo(inputInvoiceQueryDto.getSerialNo());
}
if (inputInvoiceQueryDto.getStaffId()!=null ) {
criteria.andStaffIdEqualTo(inputInvoiceQueryDto.getStaffId());
}
if (inputInvoiceQueryDto.getStatus()!=null ) {
criteria.andStatusEqualTo(inputInvoiceQueryDto.getStatus());
}
if (inputInvoiceQueryDto.getUploadDate()!=null ) {
criteria.andUploadDateEqualTo(inputInvoiceQueryDto.getUploadDate());
if (inputInvoiceQueryDto.getUploadDateForm()!=null ) {
criteria.andUploadDateGreaterThanOrEqualTo(inputInvoiceQueryDto.getUploadDateForm());
}
if (inputInvoiceQueryDto.getUploadDateTo()!=null ) {
criteria.andUploadDateLessThanOrEqualTo(inputInvoiceQueryDto.getUploadDateTo());
}
if (inputInvoiceQueryDto.getUploadType()!=null ) {
criteria.andUploadTypeEqualTo(inputInvoiceQueryDto.getUploadType());
}
if (inputInvoiceQueryDto.getVerifyType()!=null ) {
criteria.andVerifyTypeEqualTo(inputInvoiceQueryDto.getVerifyType());
}
if(inputInvoiceQueryDto.getCreateBy()!=null) {
criteria.andCreateByEqualTo(inputInvoiceQueryDto.getCreateBy());
}
Integer pageIndex=inputInvoiceQueryDto.getPagingDto().getPageIndex()!=null?inputInvoiceQueryDto.getPagingDto().getPageIndex():1;
Integer pageSize=inputInvoiceQueryDto.getPagingDto().getPageSize()!=null?inputInvoiceQueryDto.getPagingDto().getPageSize():10;
......@@ -94,4 +98,11 @@ public class InvoiceManageServiceImpl extends BaseService implements InvoiceMana
camelPagingResultDto.setCalculateData(inputInvoice);
return camelPagingResultDto;
}
@Override
public String exportInvoiceAllInfoList(InputInvoiceQueryDto inputInvoiceQueryDto, CamelPagingDto pagingDto,
String fileName) {
// TODO Auto-generated method stub
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