Commit 73da29b8 authored by neo's avatar neo

[DEV] serios data import query

parent 2e04d14f
package pwc.taxtech.atms.constant.enums;
public enum VatImportType {
ERP (1), //财务数据导入
IncomeInvoice (2),
JournalEntry (3), //序时账导入
OutputInvoice (4),
TB (5), //TB导入
Mapping (6),
AuditAdjust (7),
Voucher (8);
private int code;
VatImportType(int code) {
this.code = code;
}
public int getCode() {
return code;
}
}
package pwc.taxtech.atms.controller;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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 pwc.taxtech.atms.dto.vatdto.QueryJeDto;
import pwc.taxtech.atms.vat.service.JournalEntryImportService;
@RestController
@RequestMapping(value = "/api/v1/journalEntryImport")
public class JournalEntryImportController {
@Autowired
private JournalEntryImportService journalEntryDataImportService;
@ApiOperation(value = "queryJournalEntryData", notes = "")
@RequestMapping(value = "/queryJournalEntryData", method = RequestMethod.POST)
public ResponseEntity queryJournalEntryData(@RequestBody QueryJeDto queryJeDto) {
return ResponseEntity.ok( journalEntryDataImportService.qeryJournalEntryData(queryJeDto));
}
}
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.dto.PagingDto;
public class QueryJeDto {
private PagingDto pageInfo;
private int periodId;
public PagingDto getPageInfo() {
return pageInfo;
}
public void setPageInfo(PagingDto pageInfo) {
this.pageInfo = pageInfo;
}
public int getPeriodId() {
return periodId;
}
public void setPeriodId(int periodId) {
this.periodId = periodId;
}
}
......@@ -47,6 +47,12 @@ public class VoucherDto {
private String stdCodeAndNameShow; //界面显示
private String groupShow; //界面显示
private int vIDCount;//凭证总数
private int itemIDCount;//分录总数
private BigDecimal debitSum;
private BigDecimal creditSum;
private int auditCount;//审计调整总数
public String getVoucherID() {
return voucherID;
}
......@@ -350,4 +356,44 @@ public class VoucherDto {
public void setGroupShow(String groupShow) {
this.groupShow = groupShow;
}
public int getvIDCount() {
return vIDCount;
}
public void setvIDCount(int vIDCount) {
this.vIDCount = vIDCount;
}
public int getItemIDCount() {
return itemIDCount;
}
public void setItemIDCount(int itemIDCount) {
this.itemIDCount = itemIDCount;
}
public BigDecimal getDebitSum() {
return debitSum;
}
public void setDebitSum(BigDecimal debitSum) {
this.debitSum = debitSum;
}
public BigDecimal getCreditSum() {
return creditSum;
}
public void setCreditSum(BigDecimal creditSum) {
this.creditSum = creditSum;
}
public int getAuditCount() {
return auditCount;
}
public void setAuditCount(int auditCount) {
this.auditCount = auditCount;
}
}
package pwc.taxtech.atms.vat.dao;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.dto.PagingDto;
import pwc.taxtech.atms.vat.entity.Voucher;
import java.util.List;
@Mapper
public interface JournalEntryImportMapper extends MyVatMapper {
@Select("<script>" +
"SELECT " +
" `VoucherID`, " +
" `VID`, " +
" `Date`, " +
" `Group`, " +
" `Period`, " +
" `CustomerCode`, " +
" `CustomerName`, " +
" `Summary`, " +
" `AcctCode`, " +
" `Debit`, " +
" `Credit`, " +
" `Attach`, " +
" `ItemID`, " +
" `CreateTime`, " +
" `ImportType`, " +
" `CreatorID`, " +
" `MonthID`, " +
" `OriginalPeriod`, " +
" `Status`, " +
" `PartBilledPeriod`, " +
" `BilledPeriod`, " +
" `StdCode`, " +
" `MappingReason`, " +
" `MappingUser`, " +
" `MappingTime`, " +
" `RemapId` " +
"FROM " +
" Voucher " +
"WHERE " +
" 1 = 1 " +
" AND `ImportType` = #{importType} AND `Period` = #{period} " +
" ORDER BY `Period`,`Group`,`VID`,`ItemID`" +
" LIMIT #{start},#{size}" +
"</script>")
List<Voucher> pageQuery(@Param("importType") int code, @Param("period") int periodId, @Param("start") int start ,
@Param("size") int size);
@Select("<script>" +
"SELECT " +
" COUNT(1) " +
"FROM " +
" Voucher " +
"WHERE " +
" 1 = 1" +
" AND `ImportType` = #{importType} AND `Period` = #{period}" +
"</script>")
Integer pageQueryCount(@Param("importType") int code, @Param("period") int periodId);
@Select("<script>" +
"SELECT " +
" COUNT(1) " +
"FROM " +
" Voucher " +
"WHERE " +
" 1 = 1" +
" AND `ImportType` = #{importType} AND `Period` = #{period}" +
" GROUP BY `VID` ,`Group`,`Period`" +
"</script>")
Integer pageVIDCount(@Param("importType") int code, @Param("period") int periodId);
}
package pwc.taxtech.atms.vat.service;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.QueryJeDto;
import pwc.taxtech.atms.dto.vatdto.VoucherDto;
public interface JournalEntryImportService {
PagingResultDto<VoucherDto> qeryJournalEntryData(QueryJeDto queryJeDto);
}
package pwc.taxtech.atms.vat.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.constant.enums.VatImportType;
import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.PagingResultDto;
import pwc.taxtech.atms.dto.vatdto.QueryJeDto;
import pwc.taxtech.atms.dto.vatdto.VoucherDto;
import pwc.taxtech.atms.vat.dao.JournalEntryImportMapper;
import pwc.taxtech.atms.vat.entity.Voucher;
import pwc.taxtech.atms.vat.service.JournalEntryImportService;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@Service
public class JournalEntryImportServiceImpl implements JournalEntryImportService {
@Autowired
JournalEntryImportMapper journalEntryImportMapper;
@Override
public PagingResultDto<VoucherDto> qeryJournalEntryData(QueryJeDto queryJeDto) {
PagingResultDto<VoucherDto> qResult = new PagingResultDto<VoucherDto>();
qResult.setPageInfo(queryJeDto.getPageInfo());
qResult.setList(new ArrayList<>());
qResult.setCalculateData(new VoucherDto());
List<Voucher> pageResultList = journalEntryImportMapper.pageQuery(VatImportType.JournalEntry.getCode(),
queryJeDto.getPeriodId(), queryJeDto.getPageInfo().getPageIndex()*queryJeDto.getPageInfo().getPageSize(),
queryJeDto.getPageInfo().getPageSize());
Integer pageCount = journalEntryImportMapper.pageQueryCount(VatImportType.JournalEntry.getCode(),
queryJeDto.getPeriodId());
Integer vIDCount = journalEntryImportMapper.pageVIDCount(VatImportType.JournalEntry.getCode(),
queryJeDto.getPeriodId());
//查询结果总数
qResult.getPageInfo().setTotalCount(pageCount);
//分录总数
qResult.getCalculateData().setItemIDCount(pageCount==null?0:pageCount);
//凭证总数
qResult.getCalculateData().setvIDCount(vIDCount==null?0:vIDCount);
//所有凭证的借贷方sum
BigDecimal debitSum = new BigDecimal(0);
BigDecimal creditSum = new BigDecimal(0);
int MonthID = 0, Summary = 0;
for (Voucher voucher : pageResultList) {
debitSum.add(voucher.getDebit() != null ? voucher.getDebit() : new BigDecimal(0));
creditSum.add(voucher.getDebit() != null ? voucher.getCredit() : new BigDecimal(0));
if (voucher.getMonthID() != null) MonthID = 1;
if (voucher.getSummary() != null) Summary = 1;
}
for (Voucher voucher : pageResultList) {
if (voucher.getMonthID() == null && MonthID == 1) voucher.setMonthID(0);
if (voucher.getSummary() == null && Summary == 1) voucher.setSummary("");
VoucherDto voucherDto = new VoucherDto();
try {
FieldsMapper.map(voucher,voucherDto);
} catch (ClassNotFoundException e) {//TODO replace exception filter (neo)
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
qResult.getList().add(voucherDto);
}
return qResult;
}
}
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