Commit 4b47db19 authored by kevin's avatar kevin

Merge branch 'dev_mysql' of https://gitee.com/Memorydoc/atms into dev_mysql

parents 3fd60ed7 35ce6e92
......@@ -37,9 +37,12 @@ public class AnalysisJob extends QuartzJobBean {
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
Integer period = DateUtils.getPeriodNow();
OrganizationExample e = new OrganizationExample();
e.createCriteria().andIsActiveEqualTo(true);
//e.createCriteria().andIsActiveEqualTo(true);
List<Organization> orgs = organizationMapper.selectByExample(e);
logger.info(String.format("开始分析%s机构数据",period));
analysisJobService.analysisMaster(orgs,period, EnumTbImportType.CoverImport.getCode());
logger.info(String.format("开始分析%s预期返还税数据",period));
analysisJobService.analysisExpectedTax(orgs,period, EnumTbImportType.CoverImport.getCode());
......@@ -49,15 +52,16 @@ public class AnalysisJob extends QuartzJobBean {
logger.info(String.format("开始分析%s档案管理数据",period));
analysisJobService.analysisFileManagement(orgs,period, EnumTbImportType.CoverImport.getCode());
logger.info(String.format("开始分析%s机构数据",period));
analysisJobService.analysisMaster(orgs,period, EnumTbImportType.CoverImport.getCode());
logger.info(String.format("开始分析%s申报表数据",period));
analysisJobService.analysisSales(orgs,period, EnumTbImportType.CoverImport.getCode());
logger.info(String.format("开始分析%s返还后税数据",period));
analysisJobService.analysisTaxReturnEnd(orgs,period, EnumTbImportType.CoverImport.getCode());
logger.info(String.format("开始分析%税种税金计算数据",period));
analysisJobService.analysisTax(orgs,period, EnumTbImportType.CoverImport.getCode());
}
}
......@@ -11,6 +11,7 @@ package pwc.taxtech.atms.common.util;
import com.google.common.collect.Lists;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.nutz.http.Http;
......@@ -23,6 +24,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.List;
import java.util.zip.ZipEntry;
......@@ -379,4 +381,50 @@ public class FileExcelUtil {
}
}
/**
*
* @param cell 获取值的单元格
* @param zero 是否将空 或者null转换成 zero
* @return
*/
public static Object getCellValue(Cell cell, Boolean zero) {
String cellValue = null;
switch (cell.getCellType()) {
case Cell.CELL_TYPE_STRING://字符串类型
cellValue = cell.getStringCellValue();
if (cellValue.trim().equals("") || cellValue.trim().length() <= 0)
cellValue = "";
break;
case Cell.CELL_TYPE_NUMERIC: //数值类型
cellValue = String.valueOf(cell.getNumericCellValue());
break;
case Cell.CELL_TYPE_FORMULA: //公式
cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
cellValue = String.valueOf(cell.getNumericCellValue());
break;
case Cell.CELL_TYPE_BLANK:
cellValue = "";
break;
case Cell.CELL_TYPE_BOOLEAN:
break;
case Cell.CELL_TYPE_ERROR:
break;
default:
break;
}
if("".equals(cellValue) && zero)
return BigDecimal.ZERO;
if(zero){
try{
return new BigDecimal(cellValue);
}catch (Exception e){
logger.warn("获取Cell,在值转换成数字的地方出错");
return BigDecimal.ZERO;
}
}
return cellValue;
}
}
\ No newline at end of file
package pwc.taxtech.atms.service.impl;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.*;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.analysis.dao.*;
import pwc.taxtech.atms.analysis.entity.*;
import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.common.util.FileExcelUtil;
import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.dpo.AnalysisSalesValueDto;
import pwc.taxtech.atms.dpo.ProjectAnaylsisDto;
import pwc.taxtech.atms.dto.didiFileUpload.DidiFileIUploadParam;
import pwc.taxtech.atms.dto.didiFileUpload.DidiFileUploadDetailResult;
import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.vat.dao.EbitSpreadDataMapper;
import pwc.taxtech.atms.vat.dao.PeriodCellDataMapper;
import pwc.taxtech.atms.vat.dao.ProfitLossStatementFinalMapper;
import pwc.taxtech.atms.vat.dao.TrialBalanceFinalMapper;
import pwc.taxtech.atms.vat.entity.ProfitLossStatement;
import pwc.taxtech.atms.vat.entity.ProfitLossStatementExample;
import pwc.taxtech.atms.vat.entity.TrialBalanceFinal;
import pwc.taxtech.atms.vat.entity.TrialBalanceFinalExample;
import pwc.taxtech.atms.vat.entity.*;
import javax.annotation.Resource;
import java.util.function.Function;
......@@ -99,15 +109,15 @@ public class AnalysisJobServiceImpl extends BaseService {
* @return
* @author Gary J Li
*/
public void analysisMaster(List<Organization> orgs, Integer period,Integer type) {
public void analysisMaster(List<Organization> orgs, Integer period, Integer type) {
List<String> orgIds = orgs.stream().map(Organization::getId).collect(Collectors.toList());
if(type.equals(EnumTbImportType.CoverImport.getCode())){
if (type.equals(EnumTbImportType.CoverImport.getCode())) {
AnalysisMasterExample example = new AnalysisMasterExample();
example.createCriteria().andOrganizationIdIn(orgIds).andPeriodEqualTo(period);
analysisMasterMapper.deleteByExample(example);
}
OrganizationExample e1 = new OrganizationExample();
e1.createCriteria().andIsActiveEqualTo(true);
/* OrganizationExample e1 = new OrganizationExample();
e1.createCriteria().andIsActiveEqualTo(true);*/
List<String> currencys = orgs.stream().map(Organization::getCurrencyCode).collect(Collectors.toList());
......@@ -136,7 +146,7 @@ public class AnalysisJobServiceImpl extends BaseService {
try {
AnalysisMaster am = new AnalysisMaster();
am.setId(idService.nextId());
am.setSeqNo(o.getCode() + "" + period);
am.setSeqNo(UUID.randomUUID().toString());
List<Organization> parents = orgs.stream().filter(org -> org.getId().equals(o.getParentId())).collect(Collectors.toList());
String parentAbbreviation = "";
if (!parents.isEmpty()) {
......@@ -150,7 +160,7 @@ public class AnalysisJobServiceImpl extends BaseService {
am.setName(o.getName());
am.setArea(areaMap.get(o.getAreaId()));
am.setCountry(o.getCountry());
am.setOrganizationId(o.getId());
String regionMeg = regionMap.get(o.getRegionId());
List<String> regionMs = Lists.newArrayList();
if (StringUtils.isNotEmpty(regionMeg)) {
......@@ -179,6 +189,15 @@ public class AnalysisJobServiceImpl extends BaseService {
}
}
public String getSeqNoByPeriod(String orgId, Integer period) {
AnalysisMasterExample analysisMasterExample = new AnalysisMasterExample();
analysisMasterExample.createCriteria().andPeriodEqualTo(period).andOrganizationIdEqualTo(orgId);
List<AnalysisMaster> analysisMasters = analysisMasterMapper.selectByExample(analysisMasterExample);
if (analysisMasters.size() != 0)
return analysisMasters.get(0).getSeqNo();
return null;
}
/**
* 19/03/2019 15:55
* VAT、CIT申报表取数
......@@ -192,9 +211,9 @@ public class AnalysisJobServiceImpl extends BaseService {
* @return
* @author Gary J Li
*/
public void analysisSales(List<Organization> orgs, Integer period,Integer type) {
public void analysisSales(List<Organization> orgs, Integer period, Integer type) {
List<String> orgIds = orgs.stream().map(Organization::getId).collect(Collectors.toList());
if(type.equals(EnumTbImportType.CoverImport.getCode())){
if (type.equals(EnumTbImportType.CoverImport.getCode())) {
AnalysisSalesExample example = new AnalysisSalesExample();
example.createCriteria().andOrganizationIdIn(orgIds).andPeriodEqualTo(period);
analysisSalesMapper.deleteByExample(example);
......@@ -206,7 +225,8 @@ public class AnalysisJobServiceImpl extends BaseService {
try {
AnalysisSales as = new AnalysisSales();
as.setId(idService.nextId());
as.setSeqNo(o.getCode() + "" + period);
//as.setSeqNo(o.getCode() + "" + period);
as.setSeqNo(getSeqNoByPeriod(vatDto.getOrgId(), period));
List<AnalysisSalesValueDto> values = periodCellDataMapper.selectAnalysisSalesValueDto(vatDto.getReportId(), vatDto.getProjectId());
......@@ -218,22 +238,22 @@ public class AnalysisJobServiceImpl extends BaseService {
vMap.get(9 + ":" + 18);
// S-19 AJ-33
BigDecimal segment1 = getSegmentAmount(vMap, 9, 18).
add(getSegmentAmount(vMap, 9, 32)).
add(getSegmentAmount(vMap, 9, 35)).
add(getSegmentAmount(vMap, 13, 18)).
add(getSegmentAmount(vMap, 13, 32)).
add(getSegmentAmount(vMap, 13, 35)).
add(getSegmentAmount(vMap, 15, 18)).
add(getSegmentAmount(vMap, 17, 18));
BigDecimal segment2 = getSegmentAmount(vMap, 19, 18).add(getSegmentAmount(vMap, 19, 32));
BigDecimal segment3 = getSegmentAmount(vMap, 20, 18).add(getSegmentAmount(vMap, 20, 32));
BigDecimal segment4 = getSegmentAmount(vMap, 22, 18).add(getSegmentAmount(vMap, 22, 32));
BigDecimal segment5 = getSegmentAmount(vMap, 21, 18).add(getSegmentAmount(vMap, 21, 32));
BigDecimal segment6 = getSegmentAmount(vMap, 28, 18).add(getSegmentAmount(vMap, 28, 32));
BigDecimal segment7 = getSegmentAmount(vMap, 29, 18).add(getSegmentAmount(vMap, 29, 32));
BigDecimal segment8 = getSegmentAmount(vMap, 31, 18).add(getSegmentAmount(vMap, 31, 32));
BigDecimal segment9 = getSegmentAmount(vMap, 32, 18).add(getSegmentAmount(vMap, 32, 32));
BigDecimal segment10 = getSegmentAmount(vMap, 35, 18).add(getSegmentAmount(vMap, 35, 32));
BigDecimal segment11 = getSegmentAmount(vMap, 42, 18).add(getSegmentAmount(vMap, 42, 32));
BigDecimal segment2 = getSegmentAmount(vMap, 19, 18).add(getSegmentAmount(vMap, 19, 35));
BigDecimal segment3 = getSegmentAmount(vMap, 20, 18).add(getSegmentAmount(vMap, 20, 35));
BigDecimal segment4 = getSegmentAmount(vMap, 22, 18).add(getSegmentAmount(vMap, 22, 35));
BigDecimal segment5 = getSegmentAmount(vMap, 21, 18).add(getSegmentAmount(vMap, 21, 35));
BigDecimal segment6 = getSegmentAmount(vMap, 28, 18).add(getSegmentAmount(vMap, 28, 35));
BigDecimal segment7 = getSegmentAmount(vMap, 29, 18).add(getSegmentAmount(vMap, 29, 35));
BigDecimal segment8 = getSegmentAmount(vMap, 31, 18).add(getSegmentAmount(vMap, 31, 35));
BigDecimal segment9 = getSegmentAmount(vMap, 32, 18).add(getSegmentAmount(vMap, 32, 35));
BigDecimal segment10 = getSegmentAmount(vMap, 35, 18).add(getSegmentAmount(vMap, 35, 35));
BigDecimal segment11 = getSegmentAmount(vMap, 42, 18).add(getSegmentAmount(vMap, 42, 35));
// 查询小微纳税人表
List<ProjectAnaylsisDto> tinyDto = projectMapper.getTemlateWithServiceType2(vatDto.getOrgId(), period / 100, period % 100, "VAT100");
......@@ -247,7 +267,7 @@ public class AnalysisJobServiceImpl extends BaseService {
Map<String, String> tvMap = new HashMap<>();
tinyValues.forEach(v -> {
tvMap.put(v.getRowIndex() + "" + v.getColumnIndex(), v.getData());
tvMap.put(v.getRowIndex() + ":" + v.getColumnIndex(), v.getData());
});
//E10+F10+E15+F15+E18+F18+E21+F21+E25+F25
......@@ -282,7 +302,7 @@ public class AnalysisJobServiceImpl extends BaseService {
as.setSegment12(segment12);
as.setSegment13(segment13);
as.setSegment14(segment14);
setEbitData(as, o.getId(), period);
segment1 = segment1.add(segment1Tiny);
segment9 = segment9.add(segment9Tiny);
segment10 = segment10.add(segment10Tiny);
......@@ -299,9 +319,10 @@ public class AnalysisJobServiceImpl extends BaseService {
as.setSegment9(segment9);
as.setSegment10(segment10);
as.setSegment11(segment11);
as.setSegment15(getPLData(vatDto, "一、营业收入"));
/* as.setSegment15(getPLData(vatDto, "一、营业收入"));
as.setSegment16(getPLData(vatDto, "减:营业成本"));
as.setSegment17(getPLData(vatDto, "三、利润总额(亏损总额以“-”号填列)"));
as.setSegment17(getPLData(vatDto, "三、利润总额(亏损总额以“-”号填列)"));*/
setEbitData(as, o.getId(), period);
//todo segment18需求未定义
as.setOrganizationId(o.getId());
as.setCompanyName(o.getName());
......@@ -312,7 +333,65 @@ public class AnalysisJobServiceImpl extends BaseService {
}
});
}
@Autowired
private EbitSpreadDataMapper ebitSpreadDataMapper;
@Autowired
private DidiFileUploadService didiFileUploadService;
@Autowired
private HttpFileService httpFileService;
private void setEbitData(AnalysisSales analysisSales, String orgId, Integer period) {
EbitSpreadDataExample example = new EbitSpreadDataExample();
example.createCriteria().andPeriodEqualTo(period).andOrganizationIdEqualTo(orgId);
List<EbitSpreadData> ebitSpreadData = ebitSpreadDataMapper.selectByExample(example);
if (ebitSpreadData.size() != 0) {
DidiFileIUploadParam fileParam = new DidiFileIUploadParam();
fileParam.setUuids(Arrays.asList(ebitSpreadData.get(0).getFileKey()));
PageInfo<DidiFileUploadDetailResult> uploadDetail = didiFileUploadService.queryPage(fileParam);
String path = null;
if (CollectionUtils.isNotEmpty(uploadDetail.getList())) {
path = uploadDetail.getList().get(0).getViewHttpUrl();
}
InputStream inputStream = httpFileService.getUserTemplate(path);
Workbook workbook = null;
try {
workbook = WorkbookFactory.create(inputStream);
Sheet sheet = workbook.getSheetAt(0);
analysisSales.setSegment15((BigDecimal) FileExcelUtil.getCellValue(sheet.getRow(11).getCell(1), true));
analysisSales.setSegment15((BigDecimal) FileExcelUtil.getCellValue(sheet.getRow(12).getCell(1), true));
analysisSales.setSegment15((BigDecimal) FileExcelUtil.getCellValue(sheet.getRow(27).getCell(1), true));
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidFormatException e) {
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} else {
// 查询利润表
List<AnalysisSalesValueDto> tinyValues = Lists.newArrayList();
List<ProjectAnaylsisDto> tinyDto = projectMapper.getTemlateWithServiceType2(orgId, period / 100, period % 100, "VAT10086");
if (!tinyDto.isEmpty()) {
tinyValues = periodCellDataMapper.selectAnalysisSalesValueDto(tinyDto.get(0).getReportId(), tinyDto.get(0).getProjectId());
}
if (!tinyValues.isEmpty()) {
Map<String, String> tvMap = new HashMap<>();
tinyValues.forEach(v -> {
tvMap.put(v.getRowIndex() + ":" + v.getColumnIndex(), v.getData());
});
analysisSales.setSegment15(getSegmentAmount(tvMap, 11, 1));
analysisSales.setSegment15(getSegmentAmount(tvMap, 12, 1));
analysisSales.setSegment15(getSegmentAmount(tvMap, 27, 1));
}
}
}
......@@ -339,9 +418,9 @@ public class AnalysisJobServiceImpl extends BaseService {
* @return
* @author Gary J Li
*/
public void analysisTaxReturnEnd(List<Organization> orgs, Integer period,Integer type) {
public void analysisTaxReturnEnd(List<Organization> orgs, Integer period, Integer type) {
List<String> orgIds = orgs.stream().map(Organization::getId).collect(Collectors.toList());
if(type.equals(EnumTbImportType.CoverImport.getCode())){
if (type.equals(EnumTbImportType.CoverImport.getCode())) {
AnalysisTaxReturnEndExample example = new AnalysisTaxReturnEndExample();
example.createCriteria().andOrganizationIdIn(orgIds).andPeriodEqualTo(period);
analysisTaxReturnEndMapper.deleteByExample(example);
......@@ -370,7 +449,7 @@ public class AnalysisJobServiceImpl extends BaseService {
private void generalAnaysisReturnTaxEnd(Organization org, List<AnalysisTax> orgATList, List<AnalysisActualTaxReturn> aatrs) {
BigDecimal selfTax = new BigDecimal(0);
if(null!=orgATList){
if (null != orgATList) {
for (AnalysisTax at : orgATList) {
if ("员工个税".equals(at.getTaxGroup()) || "司机个税".equals(at.getTaxGroup())) {
selfTax.add(at.getTaxAmount());
......@@ -380,11 +459,11 @@ public class AnalysisJobServiceImpl extends BaseService {
taxReturnEnd.setOrganizationId(org.getId());
taxReturnEnd.setCompanyName(at.getCompanyName());
taxReturnEnd.setPeriod(at.getPeriod());
taxReturnEnd.setSeqNo(org.getCode() + "" + at.getPeriod());
taxReturnEnd.setSeqNo(at.getSeqNo());
taxReturnEnd.setTaxGroup(at.getTaxGroup());
BigDecimal taxAmount = at.getTaxAmount();
// 该机构返还税信息不空时进行计算
if(null!=aatrs){
if (null != aatrs) {
if ("城建税".equals(at.getTaxGroup())) {
String returnTaxName = "城建税返还";
for (AnalysisActualTaxReturn attr : aatrs) {
......@@ -437,15 +516,15 @@ public class AnalysisJobServiceImpl extends BaseService {
selfTaxReturnEnd.setOrganizationId(org.getId());
selfTaxReturnEnd.setCompanyName(orgATList.get(0).getCompanyName());
selfTaxReturnEnd.setPeriod(orgATList.get(0).getPeriod());
selfTaxReturnEnd.setSeqNo(org.getCode() + "" + orgATList.get(0).getPeriod());
selfTaxReturnEnd.setSeqNo(orgATList.get(0).getSeqNo());
selfTaxReturnEnd.setTaxGroup(orgATList.get(0).getTaxGroup());
BigDecimal taxAmount = selfTax.subtract(selfTaxReturn);
selfTaxReturnEnd.setTaxAmount(taxAmount);
analysisTaxReturnEndMapper.insertSelective(selfTaxReturnEnd);
}
}
/**
* 19/03/2019 15:57
* analysis_tax 与 organization_return_rate 计算预期返还税额
......@@ -454,10 +533,10 @@ public class AnalysisJobServiceImpl extends BaseService {
* @return
* @author Gary J Li
*/
public void analysisExpectedTax(List<Organization> orgs, Integer period,Integer type) {
public void analysisExpectedTax(List<Organization> orgs, Integer period, Integer type) {
List<String> orgIds = orgs.stream().map(Organization::getId).collect(Collectors.toList());
if(type.equals(EnumTbImportType.CoverImport.getCode())){
if (type.equals(EnumTbImportType.CoverImport.getCode())) {
AnalysisExpectedTaxReturnExample example = new AnalysisExpectedTaxReturnExample();
example.createCriteria().andOrganizationIdIn(orgIds).andPeriodEqualTo(period);
analysisExpectedTaxReturnMapper.deleteByExample(example);
......@@ -509,9 +588,9 @@ public class AnalysisJobServiceImpl extends BaseService {
* @return
* @author Gary J Li
*/
public void analysisFee(List<Organization> orgs, Integer period,Integer type) {
public void analysisFee(List<Organization> orgs, Integer period, Integer type) {
List<String> orgIds = orgs.stream().map(Organization::getId).collect(Collectors.toList());
if(type.equals(EnumTbImportType.CoverImport.getCode())){
if (type.equals(EnumTbImportType.CoverImport.getCode())) {
AnalysisFeeExample example = new AnalysisFeeExample();
example.createCriteria().andOrganizationIdIn(orgIds).andPeriodEqualTo(period);
analysisFeeMapper.deleteByExample(example);
......@@ -531,7 +610,7 @@ public class AnalysisJobServiceImpl extends BaseService {
af.setId(idService.nextId());
Organization org = orgMap.get(k);
String subjectCode = tb.getSegment3();
af.setSeqNo(org.getCode() + "" + period);
af.setSeqNo(getSeqNoByPeriod(tb.getOrganizationId(), period));
af.setSubject(subjectCode);
af.setFeeClassification1(tb.getAcctName1());
af.setFeeClassification2(tb.getAcctName2());
......@@ -562,9 +641,9 @@ public class AnalysisJobServiceImpl extends BaseService {
* @return
* @author Gary J Li
*/
public void analysisFileManagement(List<Organization> orgs, Integer period,Integer type) {
public void analysisFileManagement(List<Organization> orgs, Integer period, Integer type) {
List<String> orgIds = orgs.stream().map(Organization::getId).collect(Collectors.toList());
if(type.equals(EnumTbImportType.CoverImport.getCode())){
if (type.equals(EnumTbImportType.CoverImport.getCode())) {
AnalysisFileManagementExample example = new AnalysisFileManagementExample();
example.createCriteria().andOrganizationIdIn(orgIds).andPeriodEqualTo(period);
analysisFileManagementMapper.deleteByExample(example);
......@@ -580,20 +659,20 @@ public class AnalysisJobServiceImpl extends BaseService {
Map<String, List<OrganizationTaxRule>> ruleMap = taxRules.stream().collect(Collectors.groupingBy(OrganizationTaxRule::getGroupName));
for(TaxDocument td : taxDocuments){
for (TaxDocument td : taxDocuments) {
Organization o = orgMap.get(td.getCompanyId());
AnalysisFileManagement afm = new AnalysisFileManagement();
afm.setId(idService.nextId());
afm.setSeqNo(o.getCode() + "" + period);
afm.setSeqNo(getSeqNoByPeriod(o.getId(), period));
afm.setFileType(td.getFileType());
// 周期性上传 校验当年的当前及之前的周期是否有上传文件
if (StringUtils.isNotEmpty(td.getTaxType()) && null != td.getOwnTime()) {
List<OrganizationTaxRule> otrs = ruleMap.get(td.getTaxType());
Optional<OrganizationTaxRule> otrOP= otrs.stream().filter(otr->otr.getGroupName().equals(td.getTaxType())).map(OrganizationTaxRule::getUpdateTime).max(new ComparatorDate());
Optional<OrganizationTaxRule> otrOP = otrs.stream().filter(otr -> otr.getGroupName().equals(td.getTaxType())).map(OrganizationTaxRule::getUpdateTime).max(new ComparatorDate());
OrganizationTaxRule rule = otrOP.get();
if(null==rule){
if (null == rule) {
break;
}
......@@ -619,7 +698,7 @@ public class AnalysisJobServiceImpl extends BaseService {
archivingStatus = taxDocumentMapper.countByExample(example) > 0 ? "已归档" : archivingStatus;
}
afm.setArchivingStatus(archivingStatus);
}else{
} else {
afm.setReportingFrequency("/");
// 由于是根据文档列表查询 必然已归档
afm.setArchivingStatus("已归档");
......@@ -631,6 +710,72 @@ public class AnalysisJobServiceImpl extends BaseService {
}
}
public void analysisTax(List<Organization> orgs, Integer period, Integer type) {
List<String> orgIds = orgs.stream().map(Organization::getId).collect(Collectors.toList());
if (type.equals(EnumTbImportType.CoverImport.getCode())) {
AnalysisTaxExample example = new AnalysisTaxExample();
example.createCriteria().andOrganizationIdIn(orgIds).andPeriodEqualTo(period).andTaxGroupNotEqualTo("企业所得税")
.andTaxGroupNotEqualTo("员工个税")
.andTaxGroupNotEqualTo("印花税")
.andTaxGroupNotEqualTo("司机个税")
.andTaxGroupNotEqualTo("返还后增值税")
.andTaxGroupNotEqualTo("返还后个人所得税")
.andTaxGroupNotEqualTo("员工个税");
analysisTaxMapper.deleteByExample(example);
}
List<ProjectAnaylsisDto> vatDtos = projectMapper.getTemlateWithServiceType(orgIds, period / 100, period % 100, "增值税纳税申报表");
Map<String, Organization> orgMap = orgs.stream().collect(Collectors.toMap(Organization::getId, Function.identity()));
vatDtos.forEach(vatDto -> {
Organization o = orgMap.get(vatDto.getOrgId());
try {
AnalysisTax as = new AnalysisTax();
as.setId(idService.nextId());
as.setTaxGroup("增值税");
as.setSeqNo(getSeqNoByPeriod(vatDto.getOrgId(), period));
List<AnalysisSalesValueDto> values = periodCellDataMapper.selectAnalysisSalesValueDto(vatDto.getReportId(), vatDto.getProjectId());
Map<String, String> vMap = new HashMap<>();
values.forEach(v -> {
vMap.put(v.getRowIndex() + ":" + v.getColumnIndex(), v.getData());
});
BigDecimal zzse = getSegmentAmount(vMap, 42, 35).add(getSegmentAmount(vMap, 42, 18));
analysisTaxMapper.insertSelective(as);
} catch (Exception e) {
logger.error(String.format("公司:[%s]生成应缴税额表分析数据失败!", o.getName()), e);
}
});
//企业所得税
List<ProjectAnaylsisDto> qysdsDto = projectMapper.getTemlateWithServiceType(orgIds, period / 100, period % 100, "企业所得税纳税申报表");
qysdsDto.forEach(qd -> {
Organization o = orgMap.get(qd.getOrgId());
try {
AnalysisTax as = new AnalysisTax();
as.setId(idService.nextId());
as.setTaxGroup("企业所得税");
as.setSeqNo(getSeqNoByPeriod(qd.getOrgId(), period));
List<AnalysisSalesValueDto> values = periodCellDataMapper.selectAnalysisSalesValueDto(qd.getReportId(), qd.getProjectId());
Map<String, String> vMap = new HashMap<>();
values.forEach(v -> {
vMap.put(v.getRowIndex() + ":" + v.getColumnIndex(), v.getData());
});
BigDecimal zzse = getSegmentAmount(vMap, 42, 35).add(getSegmentAmount(vMap, 42, 18));
analysisTaxMapper.insertSelective(as);
} catch (Exception e) {
logger.error(String.format("公司:[%s]生成应缴税额表分析数据失败!", o.getName()), e);
}
});
}
public class ComparatorDate implements Comparator {
public static final String TAG = "ComparatorDate";
......
......@@ -285,7 +285,7 @@ public class AnalysisServiceImpl extends BaseService {
AnalysisTax model = new AnalysisTax();
model.setId(idService.nextId());
model.setOrganizationId(org.getId());
model.setSeqNo(org.getCode()+""+period);
model.setSeqNo(getSeqNoByPeriod(org.getId(), period));
model.setPeriod(period);
model.setCompanyName(org.getName());
model.setTaxGroup(getCellStringValue(sheet.getRow(0).getCell(k)));
......@@ -293,6 +293,16 @@ public class AnalysisServiceImpl extends BaseService {
return model;
}
public String getSeqNoByPeriod(String orgId, Integer period){
AnalysisMasterExample analysisMasterExample = new AnalysisMasterExample();
analysisMasterExample.createCriteria().andPeriodEqualTo(period).andOrganizationIdEqualTo(orgId);
List<AnalysisMaster> analysisMasters = analysisMasterMapper.selectByExample(analysisMasterExample);
if(analysisMasters.size() != 0)
return analysisMasters.get(0).getSeqNo();
return null;
}
private void importAnalysisReturnTaxExcelFile(MultipartFile file, String periodDate) {
try{
InputStream inputStream = file.getInputStream();
......@@ -346,7 +356,7 @@ public class AnalysisServiceImpl extends BaseService {
AnalysisActualTaxReturn model = new AnalysisActualTaxReturn();
model.setId(idService.nextId());
model.setOrganizationId(org.getId());
model.setSeqNo(org.getCode()+""+period);
model.setSeqNo(getSeqNoByPeriod(org.getId(), period));
model.setPeriod(period);
model.setCompanyName(org.getName());
model.setTaxReturnGroup(getCellStringValue(sheet.getRow(0).getCell(k)));
......@@ -381,6 +391,10 @@ public class AnalysisServiceImpl extends BaseService {
model.setInternAmount(getCellBigDecimalValue(sheet.getRow(j).getCell(2)));
model.setVendorAmount(getCellBigDecimalValue(sheet.getRow(j).getCell(3)));
model.setTotalAmount(getCellBigDecimalValue(sheet.getRow(j).getCell(4)));
//通过公司名称查询orgId
OrganizationExample example = new OrganizationExample();
example.createCriteria().andNameEqualTo(getCellStringValue(sheet.getRow(j).getCell(0)));
model.setSeqNo(getSeqNoByPeriod(organizationMapper.selectByExample(example).get(0).getId(), Integer.parseInt(periodDate)));
lists.add(model);
}
AnalysisEmployeeNumExample example = new AnalysisEmployeeNumExample();
......@@ -487,7 +501,6 @@ public class AnalysisServiceImpl extends BaseService {
throw new ServiceException(e);
}
}
private void importAnalysisInterTaxDataExcelFile(MultipartFile file, String periodDate,
String companyName,String country) {
try{
......
......@@ -2465,6 +2465,7 @@ public class ReportServiceImpl extends BaseService {
for (int m = 0; m < 3; m++) {
FileExcelUtil.cloneCell(sheetAt.getRow(m).getCell(2), sheetAt.getRow(m).getCell(1));
sheetAt.getRow(m).getCell(3).setCellValue("");
sheetAt.getRow(m).getCell(1).setCellValue("");
}
style1.setFillBackgroundColor(IndexedColors.YELLOW.getIndex());
......@@ -2472,7 +2473,7 @@ public class ReportServiceImpl extends BaseService {
sheetAt.getRow(2).getCell(2).setCellValue("本期:" + spreadData.get(0).getPeriod());
}
/* public String getCellStringValue(Cell cell) {
public String getCellStringValue(Cell cell) {
String cellValue = null;
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_STRING://字符串类型
......@@ -2498,7 +2499,7 @@ public class ReportServiceImpl extends BaseService {
break;
}
return cellValue;
}*/
}
@Autowired
private OrganizationMapper organizationMapper;
......@@ -2525,7 +2526,7 @@ public class ReportServiceImpl extends BaseService {
}
}
private String getCellStringValue(Cell cell) {
/* private String getCellStringValue(Cell cell) {
if (cell.getCellTypeEnum().equals(CellType.STRING)) {
return cell.getStringCellValue();
} else if (cell.getCellTypeEnum().equals(CellType.NUMERIC)) {
......@@ -2534,5 +2535,5 @@ public class ReportServiceImpl extends BaseService {
}
logger.warn("获取单元格数据类型未匹配");
return null;
}
}*/
}
......@@ -28,7 +28,7 @@ public class AnalysisTest extends CommonIT {
public void analysisExpectedTax(){
Integer period = DateUtils.getPeriodNow();
OrganizationExample e = new OrganizationExample();
e.createCriteria().andIsActiveEqualTo(true);
//e.createCriteria().andIsActiveEqualTo(true);
List<Organization> orgs = organizationMapper.selectByExample(e);
logger.info(String.format("开始分析%s预期返还税数据",period));
analysisJobService.analysisExpectedTax(orgs,period, EnumTbImportType.CoverImport.getCode());
......@@ -39,7 +39,7 @@ public class AnalysisTest extends CommonIT {
public void analysisFee(){
Integer period = DateUtils.getPeriodNow();
OrganizationExample e = new OrganizationExample();
e.createCriteria().andIsActiveEqualTo(true);
//e.createCriteria().andIsActiveEqualTo(true);
List<Organization> orgs = organizationMapper.selectByExample(e);
logger.info(String.format("开始分析%s费用数据",period));
analysisJobService.analysisFee(orgs,period, EnumTbImportType.CoverImport.getCode());
......@@ -49,7 +49,7 @@ public class AnalysisTest extends CommonIT {
public void analysisFileManagement(){
Integer period = DateUtils.getPeriodNow();
OrganizationExample e = new OrganizationExample();
e.createCriteria().andIsActiveEqualTo(true);
// e.createCriteria().andIsActiveEqualTo(true);
List<Organization> orgs = organizationMapper.selectByExample(e);
logger.info(String.format("开始分析%s文档管理数据",period));
......@@ -60,7 +60,7 @@ public class AnalysisTest extends CommonIT {
public void analysisMaster(){
Integer period = DateUtils.getPeriodNow();
OrganizationExample e = new OrganizationExample();
e.createCriteria().andIsActiveEqualTo(true);
//e.createCriteria().andIsActiveEqualTo(true);
List<Organization> orgs = organizationMapper.selectByExample(e);
logger.info(String.format("开始分析%s机构数据",period));
analysisJobService.analysisMaster(orgs,period, EnumTbImportType.CoverImport.getCode());
......@@ -70,7 +70,7 @@ public class AnalysisTest extends CommonIT {
public void analysisSales(){
Integer period = DateUtils.getPeriodNow();
OrganizationExample e = new OrganizationExample();
e.createCriteria().andIsActiveEqualTo(true);
//e.createCriteria().andIsActiveEqualTo(true);
List<Organization> orgs = organizationMapper.selectByExample(e);
logger.info(String.format("开始分析%s申报表数据",period));
analysisJobService.analysisSales(orgs,period, EnumTbImportType.CoverImport.getCode());
......@@ -80,9 +80,19 @@ public class AnalysisTest extends CommonIT {
public void analysisTaxReturnEnd(){
Integer period = DateUtils.getPeriodNow();
OrganizationExample e = new OrganizationExample();
e.createCriteria().andIsActiveEqualTo(true);
//e.createCriteria().andIsActiveEqualTo(true);
List<Organization> orgs = organizationMapper.selectByExample(e);
logger.info(String.format("开始分析%s返还后税数据",period));
analysisJobService.analysisTaxReturnEnd(orgs,period, EnumTbImportType.CoverImport.getCode());
}
@Test
public void analysisTax(){
Integer period = DateUtils.getPeriodNow();
OrganizationExample e = new OrganizationExample();
//e.createCriteria().andIsActiveEqualTo(true);
List<Organization> orgs = organizationMapper.selectByExample(e);
logger.info(String.format("开始分析%s返还后税数据",period));
analysisJobService.analysisTax(orgs,period, EnumTbImportType.CoverImport.getCode());
}
}
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