Commit 6913e0dc authored by sherlock's avatar sherlock

inputInvoice export

template import
parent caacb89a
package pwc.taxtech.atms.controller; package pwc.taxtech.atms.controller;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.dto.vatdto.ImportInputInvoiceDto; import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.dto.vatdto.ImportInputInvoiceItemDto;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceBaseDto;
import pwc.taxtech.atms.service.impl.IdentityServiceImpl; import pwc.taxtech.atms.service.impl.IdentityServiceImpl;
import pwc.taxtech.atms.thirdparty.ExcelSheet; import pwc.taxtech.atms.thirdparty.ExcelSheet;
import pwc.taxtech.atms.thirdparty.ExcelUtil; import pwc.taxtech.atms.thirdparty.ExcelUtil;
...@@ -76,11 +76,38 @@ public class InputInvoiceImportController { ...@@ -76,11 +76,38 @@ public class InputInvoiceImportController {
return ResponseEntity.ok().body(inputInvoiceDataImportService.getInputInvoiceItemList(fpid)); return ResponseEntity.ok().body(inputInvoiceDataImportService.getInputInvoiceItemList(fpid));
} }
private String getFplx(String fplx){
if(StringUtils.isBlank(fplx)) return "";
switch (fplx){
case "004":
return "增值税专票";
case "007":
return "普票";
case "026":
return "电子发票";
default:
return fplx;
}
}
private int getDownloadFilePath(InputInvoicePreviewQueryParam paras, OutputStream outputStream, String projectId) { private int getDownloadFilePath(InputInvoicePreviewQueryParam paras, OutputStream outputStream, String projectId) {
List<InputInvoice> list = inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras, projectId).getList(); List<InputInvoice> list = inputInvoiceDataImportService.getInputInvoiceTreeViewData(paras, projectId).getList();
if (list.size() == 0) { if (list.size() == 0) {
return 0; return 0;
} }
List<InputInvoiceExportDto> inputInvoiceExportDtos = Lists.newArrayList();
for(InputInvoice inputInvoice : list){
InputInvoiceExportDto inputInvoiceExportDto = new InputInvoiceExportDto();
inputInvoiceExportDto.setAmount(inputInvoice.getHJJE());
inputInvoiceExportDto.setCertificationDate(inputInvoice.getRZSJ());
inputInvoiceExportDto.setInvoiceCode(inputInvoice.getFPDM());
inputInvoiceExportDto.setInvoiceDate(inputInvoice.getKPRQ());
inputInvoiceExportDto.setInvoiceNumber(inputInvoice.getFPHM());
inputInvoiceExportDto.setInvoiceTypeName(getFplx(inputInvoice.getFPLX()));
inputInvoiceExportDto.setPeriodId(Integer.parseInt(inputInvoice.getRZSJ().substring(5, 7)));
inputInvoiceExportDto.setSellerTaxNumber(inputInvoice.getXFSH());
inputInvoiceExportDto.setTaxAmount(inputInvoice.getHJSE());
inputInvoiceExportDtos.add(inputInvoiceExportDto);
}
Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
header.put("PeriodId", "期间"); header.put("PeriodId", "期间");
header.put("InvoiceDate", "开票日期"); header.put("InvoiceDate", "开票日期");
...@@ -94,7 +121,7 @@ public class InputInvoiceImportController { ...@@ -94,7 +121,7 @@ public class InputInvoiceImportController {
ExcelSheet excelSheetA = new ExcelSheet<>(); ExcelSheet excelSheetA = new ExcelSheet<>();
excelSheetA.setHeaders(header); excelSheetA.setHeaders(header);
excelSheetA.setDataset(list); excelSheetA.setDataset(inputInvoiceExportDtos);
excelSheetA.setSheetName("sheetA"); excelSheetA.setSheetName("sheetA");
...@@ -111,9 +138,20 @@ public class InputInvoiceImportController { ...@@ -111,9 +138,20 @@ public class InputInvoiceImportController {
excelSheetB.setHeaders(header2); excelSheetB.setHeaders(header2);
excelSheetB.setSheetName("sheetB"); excelSheetB.setSheetName("sheetB");
List<InputInvoiceDetail> inputInvoiceItemList = new ArrayList<>(); List<InputInvoiceDetailExportDto> inputInvoiceItemList = new ArrayList<>();
for (InputInvoice item : list) { for (InputInvoice item : list) {
inputInvoiceItemList.addAll(inputInvoiceDataImportService.getInputInvoiceItemList(item.getID())); List<InputInvoiceDetail> inputInvoiceDetailList = inputInvoiceDataImportService.getInputInvoiceItemList(item.getID());
for(InputInvoiceDetail inputInvoiceDetail : inputInvoiceDetailList){
InputInvoiceDetailExportDto inputInvoiceDetailExportDto = new InputInvoiceDetailExportDto();
inputInvoiceDetailExportDto.setAmount(inputInvoiceDetail.getJE());
inputInvoiceDetailExportDto.setInvoiceCode(inputInvoiceDetail.getFPDM());
inputInvoiceDetailExportDto.setInvoiceNumber(inputInvoiceDetail.getFPHM());
inputInvoiceDetailExportDto.setPeriodId(Integer.parseInt(item.getRZSJ().substring(5, 7)));
inputInvoiceDetailExportDto.setProductionName(inputInvoiceDetail.getSPMC());
inputInvoiceDetailExportDto.setTaxAmount(inputInvoiceDetail.getSE());
inputInvoiceDetailExportDto.setTaxRate(inputInvoiceDetail.getSLV());
inputInvoiceItemList.add(inputInvoiceDetailExportDto);
}
} }
excelSheetB.setDataset(inputInvoiceItemList); excelSheetB.setDataset(inputInvoiceItemList);
List<ExcelSheet<InputVATInvoiceBaseDto>> sheets = new ArrayList<>(); List<ExcelSheet<InputVATInvoiceBaseDto>> sheets = new ArrayList<>();
......
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import java.io.Serializable;
public class InputInvoiceDetailExportDto implements Serializable {
@ExcelCell(index=5)
private Integer periodId;
@ExcelCell(index=4)
private String invoiceCode;
@ExcelCell(index=6)
private String invoiceNumber;
@ExcelCell(index=2)
private String amount;
@ExcelCell(index=1)
private String taxAmount;
@ExcelCell(index=3)
private String taxRate;
@ExcelCell(index=7)
private String productionName;
public Integer getPeriodId() {
return periodId;
}
public void setPeriodId(Integer periodId) {
this.periodId = periodId;
}
public String getInvoiceCode() {
return invoiceCode;
}
public void setInvoiceCode(String invoiceCode) {
this.invoiceCode = invoiceCode;
}
public String getInvoiceNumber() {
return invoiceNumber;
}
public void setInvoiceNumber(String invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getTaxAmount() {
return taxAmount;
}
public void setTaxAmount(String taxAmount) {
this.taxAmount = taxAmount;
}
public String getTaxRate() {
return taxRate;
}
public void setTaxRate(String taxRate) {
this.taxRate = taxRate;
}
public String getProductionName() {
return productionName;
}
public void setProductionName(String productionName) {
this.productionName = productionName;
}
}
\ No newline at end of file
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.thirdparty.ExcelCell;
import java.io.Serializable;
public class InputInvoiceExportDto implements Serializable {
@ExcelCell(index=6)
private int periodId;
@ExcelCell(index=7)
private String invoiceDate;
@ExcelCell(index=5)
private String invoiceCode;
@ExcelCell(index=8)
private String invoiceNumber;
@ExcelCell(index=9)
private String sellerTaxNumber;
@ExcelCell(index=3)
private String invoiceTypeName;
@ExcelCell(index=4)
private String amount;
@ExcelCell(index=1)
private String taxAmount;
@ExcelCell(index=2)
private String certificationDate;
public int getPeriodId() {
return periodId;
}
public void setPeriodId(int periodId) {
this.periodId = periodId;
}
public String getInvoiceDate() {
return invoiceDate;
}
public void setInvoiceDate(String invoiceDate) {
this.invoiceDate = invoiceDate;
}
public String getInvoiceCode() {
return invoiceCode;
}
public void setInvoiceCode(String invoiceCode) {
this.invoiceCode = invoiceCode;
}
public String getInvoiceNumber() {
return invoiceNumber;
}
public void setInvoiceNumber(String invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
public String getSellerTaxNumber() {
return sellerTaxNumber;
}
public void setSellerTaxNumber(String sellerTaxNumber) {
this.sellerTaxNumber = sellerTaxNumber;
}
public String getInvoiceTypeName() {
return invoiceTypeName;
}
public void setInvoiceTypeName(String invoiceTypeName) {
this.invoiceTypeName = invoiceTypeName;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getTaxAmount() {
return taxAmount;
}
public void setTaxAmount(String taxAmount) {
this.taxAmount = taxAmount;
}
public String getCertificationDate() {
return certificationDate;
}
public void setCertificationDate(String certificationDate) {
this.certificationDate = certificationDate;
}
@Override
public String toString() {
return "InputInvoice{" +
"periodId=" + periodId +
", invoiceDate='" + invoiceDate + '\'' +
", invoiceCode='" + invoiceCode + '\'' +
", invoiceNumber='" + invoiceNumber + '\'' +
", sellerTaxNumber='" + sellerTaxNumber + '\'' +
", invoiceTypeName='" + invoiceTypeName + '\'' +
", amount='" + amount + '\'' +
", taxAmount='" + taxAmount + '\'' +
", certificationDate='" + certificationDate + '\'' +
'}';
}
}
\ No newline at end of file
...@@ -3,6 +3,7 @@ package pwc.taxtech.atms.service.impl; ...@@ -3,6 +3,7 @@ package pwc.taxtech.atms.service.impl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.grapecity.documents.excel.C; import com.grapecity.documents.excel.C;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -14,6 +15,8 @@ import pwc.taxtech.atms.dpo.TemplateUniqDto; ...@@ -14,6 +15,8 @@ import pwc.taxtech.atms.dpo.TemplateUniqDto;
import pwc.taxtech.atms.dto.*; import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.dto.vatdto.TemplateByGroupDto; import pwc.taxtech.atms.dto.vatdto.TemplateByGroupDto;
import pwc.taxtech.atms.entity.*; import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.vat.dao.PeriodTemplateMapper;
import pwc.taxtech.atms.vat.entity.PeriodTemplateExample;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -23,6 +26,9 @@ import static java.util.stream.Collectors.groupingBy; ...@@ -23,6 +26,9 @@ import static java.util.stream.Collectors.groupingBy;
@Service @Service
public class TemplateServiceImpl extends AbstractService { public class TemplateServiceImpl extends AbstractService {
@Autowired
private PeriodTemplateMapper periodTemplateMapper;
public void addExistTemplate(TemplateAddExistDto templateAddExistDto){ public void addExistTemplate(TemplateAddExistDto templateAddExistDto){
TemplateExample t = new TemplateExample(); TemplateExample t = new TemplateExample();
t.createCriteria().andTemplateGroupIdEqualTo(templateAddExistDto.getTemplateGroupId()); t.createCriteria().andTemplateGroupIdEqualTo(templateAddExistDto.getTemplateGroupId());
...@@ -31,8 +37,10 @@ public class TemplateServiceImpl extends AbstractService { ...@@ -31,8 +37,10 @@ public class TemplateServiceImpl extends AbstractService {
TemplateExample templateExample = new TemplateExample(); TemplateExample templateExample = new TemplateExample();
templateExample.createCriteria().andIdIn(templateAddExistDto.getTemplateIdList()); templateExample.createCriteria().andIdIn(templateAddExistDto.getTemplateIdList());
List<Template> templates = templateMapper.selectByExample(templateExample); List<Template> templates = templateMapper.selectByExample(templateExample);
List<CellTemplateConfig> cellTemplateConfigList = Lists.newArrayList();
for(Template x : templates){ for(Template x : templates){
// 复制添加template // 复制添加template
Long originTemplateId = x.getId(); Long originTemplateId = x.getId();
x.setId(distributedIdService.nextId()); x.setId(distributedIdService.nextId());
x.setTemplateGroupId(templateAddExistDto.getTemplateGroupId()); x.setTemplateGroupId(templateAddExistDto.getTemplateGroupId());
...@@ -43,15 +51,16 @@ public class TemplateServiceImpl extends AbstractService { ...@@ -43,15 +51,16 @@ public class TemplateServiceImpl extends AbstractService {
CellTemplateExample cellTemplateExample = new CellTemplateExample(); CellTemplateExample cellTemplateExample = new CellTemplateExample();
cellTemplateExample.createCriteria().andReportTemplateIdEqualTo(originTemplateId); cellTemplateExample.createCriteria().andReportTemplateIdEqualTo(originTemplateId);
List<CellTemplate> cellTemplates = cellTemplateMapper.selectByExample(cellTemplateExample); List<CellTemplate> cellTemplates = cellTemplateMapper.selectByExample(cellTemplateExample);
List<CellTemplateConfig> cellTemplateConfigList = Lists.newArrayList();
if(cellTemplates.isEmpty()) return;
cellTemplates.forEach(cellTemplate -> { cellTemplates.forEach(cellTemplate -> {
cellTemplate.setId(distributedIdService.nextId());
cellTemplate.setReportTemplateId(x.getId());
// 复制添加cellTemplateConfig // 复制添加cellTemplateConfig
CellTemplateConfigExample cellTemplateConfigExample = new CellTemplateConfigExample(); CellTemplateConfigExample cellTemplateConfigExample = new CellTemplateConfigExample();
cellTemplateConfigExample.createCriteria().andCellTemplateIdEqualTo(cellTemplate.getId()) cellTemplateConfigExample.createCriteria().andCellTemplateIdEqualTo(cellTemplate.getId())
.andReportTemplateIdEqualTo(x.getId()); .andReportTemplateIdEqualTo(originTemplateId);
List<CellTemplateConfig> cellTemplateConfigs = cellTemplateConfigMapper.selectByExample(cellTemplateConfigExample); List<CellTemplateConfig> cellTemplateConfigs = cellTemplateConfigMapper.selectByExample(cellTemplateConfigExample);
cellTemplate.setId(distributedIdService.nextId());
cellTemplate.setReportTemplateId(x.getId());
if(CollectionUtils.isNotEmpty(cellTemplateConfigs)){ if(CollectionUtils.isNotEmpty(cellTemplateConfigs)){
CellTemplateConfig cellTemplateConfig = cellTemplateConfigs.get(0); CellTemplateConfig cellTemplateConfig = cellTemplateConfigs.get(0);
cellTemplateConfig.setId(distributedIdService.nextId()); cellTemplateConfig.setId(distributedIdService.nextId());
...@@ -61,8 +70,9 @@ public class TemplateServiceImpl extends AbstractService { ...@@ -61,8 +70,9 @@ public class TemplateServiceImpl extends AbstractService {
} }
}); });
cellTemplateMapper.batchInsert2(cellTemplates); cellTemplateMapper.batchInsert2(cellTemplates);
cellTemplateConfigMapper.batchInsert2(cellTemplateConfigList);
} }
if(cellTemplateConfigList.isEmpty()) return ;
cellTemplateConfigMapper.batchInsert2(cellTemplateConfigList);
} }
public List<TemplateDto> get(Long templateGroupId, Integer reportType) { public List<TemplateDto> get(Long templateGroupId, Integer reportType) {
...@@ -297,7 +307,12 @@ public class TemplateServiceImpl extends AbstractService { ...@@ -297,7 +307,12 @@ public class TemplateServiceImpl extends AbstractService {
taxReturnGroup.setId(templateGroupId); taxReturnGroup.setId(templateGroupId);
taxReturnGroup.setName(TemplateGroupType.TaxReturn.name()); taxReturnGroup.setName(TemplateGroupType.TaxReturn.name());
List<TemplateDto> templateDtos2 = new ArrayList<>(); List<TemplateDto> templateDtos2 = new ArrayList<>();
templates.stream().filter(x -> x.getTemplateGroupId().equals(templateGroupId)).collect(Collectors.toList()).forEach(a -> { templates.stream().filter(x -> {
PeriodTemplateExample periodTemplateExample = new PeriodTemplateExample();
periodTemplateExample.createCriteria().andTemplateGroupIdEqualTo(templateGroupId)
.andTemplateIdEqualTo(x.getId());
return x.getTemplateGroupId().equals(templateGroupId) && periodTemplateMapper.selectByExample(periodTemplateExample).size() > 0;
}).collect(Collectors.toList()).forEach(a -> {
TemplateDto templateDto = new TemplateDto(); TemplateDto templateDto = new TemplateDto();
CommonUtils.copyProperties(a, templateDto); CommonUtils.copyProperties(a, templateDto);
templateDtos2.add(templateDto); templateDtos2.add(templateDto);
......
...@@ -266,7 +266,8 @@ public class OutputInvoiceServiceImpl { ...@@ -266,7 +266,8 @@ public class OutputInvoiceServiceImpl {
OutputInvoiceExample e = new OutputInvoiceExample(); OutputInvoiceExample e = new OutputInvoiceExample();
e.createCriteria().andXFSHEqualTo(organization.getTaxPayerNumber()); e.createCriteria().andXFSHEqualTo(organization.getTaxPayerNumber());
List<String> fpqqlshList = outputInvoiceMapper.selectByExample(e).stream().map(OutputInvoice::getFPQQLSH).collect(Collectors.toList()); List<String> fpqqlshList = outputInvoiceMapper.selectByExample(e).stream().map(OutputInvoice::getFPQQLSH).collect(Collectors.toList());
rList.stream().filter(a -> fpqqlshList.contains(a.getFpqqlsh())).forEach(x -> { rList = rList.stream().filter(a -> fpqqlshList.contains(a.getFpqqlsh())).collect(Collectors.toList());
rList.forEach(x -> {
CAL.setTime(x.getInvoiceDate()); CAL.setTime(x.getInvoiceDate());
x.setPeriodId(CAL.get(Calendar.MONTH) + 1); x.setPeriodId(CAL.get(Calendar.MONTH) + 1);
}); });
......
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
<if test="productName!=null and productName!=''"> <if test="productName!=null and productName!=''">
AND OI.SPMC LIKE concat ( AND OI.SPMC LIKE concat (
'%', '%',
#{ productName,jdbcType=VARCHAR,'%'} #{productName,jdbcType=VARCHAR,'%'}
) )
</if> </if>
</select> </select>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
$('#busy-indicator-container').show(); $('#busy-indicator-container').show();
var defer = $q.defer(); var defer = $q.defer();
var octetStreamMime = 'application/octet-stream'; var octetStreamMime = 'application/vnd.ms-excel';
var success = false; var success = false;
// Get the headers // Get the headers
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
$log.debug('VatReportLayoutController.ctor()...'); $log.debug('VatReportLayoutController.ctor()...');
$scope.$on('refreshGenerateReport', function (event, data) { $scope.$on('refreshGenerateReport', function (event, data) {
//$scope.selectedTemplateId = data.templateId; // $scope.selectedTemplateId = data.templateId;
loadTemplateMenu(); loadTemplateMenu();
}); });
var loadTemplateMenu = function () { var loadTemplateMenu = function () {
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
//房地产 //房地产
//projectID = '0cf0945f-d41c-4df3-8235-ae693d5e724d'; //projectID = '0cf0945f-d41c-4df3-8235-ae693d5e724d';
$q.all([ $q.all([
templateGroupService.getGroupTemplateByGroupID(6390933830635520, projectID), templateGroupService.getGroupTemplateByGroupID(48372654336679936, projectID),
vatReportService.getTemplate(vatSessionService.project.id, constant.serviceType.VAT, vatSessionService.month) vatReportService.getTemplate(vatSessionService.project.id, constant.serviceType.VAT, vatSessionService.month)
]).then(function (result) { ]).then(function (result) {
if (!_.isEmpty(result[0]) && !_.isEmpty(result[0].data) && !_.isEmpty(result[0].data.data) if (!_.isEmpty(result[0]) && !_.isEmpty(result[0].data) && !_.isEmpty(result[0].data.data)
......
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