Commit e6927810 authored by sherlock's avatar sherlock

export order

parents 3a20ec59 778416ae
...@@ -38,6 +38,10 @@ public class MyAsserts { ...@@ -38,6 +38,10 @@ public class MyAsserts {
if (obj == null || obj.isEmpty()) throw exception; if (obj == null || obj.isEmpty()) throw exception;
} }
public static void assertNotEmpty(Collection obj, FormulaException exception) {
if (obj == null || obj.isEmpty()) throw exception;
}
public static void assertNotEmpty(Collection obj, ApiException exception) { public static void assertNotEmpty(Collection obj, ApiException exception) {
if (obj == null || obj.isEmpty()) throw exception; if (obj == null || obj.isEmpty()) throw exception;
} }
......
...@@ -113,6 +113,7 @@ public final class Constant { ...@@ -113,6 +113,7 @@ public final class Constant {
public static class DateFormat { public static class DateFormat {
public static final String DEFAULT = "yyyy-MM-dd"; public static final String DEFAULT = "yyyy-MM-dd";
public static final String YEAR_MONTH = "yyyy-MM"; public static final String YEAR_MONTH = "yyyy-MM";
public static final String YYYYMM = "yyyyMM";
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
} }
......
...@@ -118,20 +118,6 @@ public class BBParasBo { ...@@ -118,20 +118,6 @@ public class BBParasBo {
return formulaExpression; return formulaExpression;
} }
public String expressionData() {
if (!expressionData.isEmpty()) {
StringBuilder builder = new StringBuilder("PCT(");
for (int i = 0; i < expressionData.size(); i++) {
builder.append(expressionData.get(i).toString());
if (i < expressionData.size() - 1)
builder.append(",");
}
builder.append(")");
return builder.toString();
}
return "0";
}
@Override @Override
public String toString() { public String toString() {
return "BBParasBo{" + return "BBParasBo{" +
......
...@@ -19,4 +19,6 @@ public class Exceptions { ...@@ -19,4 +19,6 @@ public class Exceptions {
public static final ApiException NOT_FOUND_TEMPLATE_GROUP_EXCEPTION = new NotFoundException("not found template group"); public static final ApiException NOT_FOUND_TEMPLATE_GROUP_EXCEPTION = new NotFoundException("not found template group");
public static final ApiException NOT_FOUND_EXCEPTION = new NotFoundException("not found resources"); public static final ApiException NOT_FOUND_EXCEPTION = new NotFoundException("not found resources");
public static final ApiException REPORT_IN_PROCESS_OR_AGREED_EXCEPTION = new PreconditionFailedException("report in approval or agreed result"); public static final ApiException REPORT_IN_PROCESS_OR_AGREED_EXCEPTION = new PreconditionFailedException("report in approval or agreed result");
public static final FormulaException PROJECT_NOT_FOUND = new FormulaException("project not found");;
public static final FormulaException PSUM_CELL_TEMP_NULL = new FormulaException("cell template group is null or empty"); ;
} }
...@@ -21,13 +21,12 @@ public class InputInvoiceDao { ...@@ -21,13 +21,12 @@ public class InputInvoiceDao {
public List<InputInvoice> getInputInvoice(Integer period, String invoiceType, String checkPass, String scanPass, String notPass) { public List<InputInvoice> getInputInvoice(Integer period, String invoiceType, String checkPass, String scanPass, String notPass) {
InputInvoiceExample example = new InputInvoiceExample(); InputInvoiceExample example = new InputInvoiceExample();
InputInvoiceExample.Criteria criteria = example.createCriteria(); InputInvoiceExample.Criteria criteria = example.createCriteria();
// InputInvoiceExample.Criteria criteria1 = example.createCriteria();
// if(period != null){ if (period != null) {
// Calendar date = Calendar.getInstance(); Calendar date = Calendar.getInstance();
// String year = String.valueOf(date.get(Calendar.YEAR)); String year = String.valueOf(date.get(Calendar.YEAR));
// criteria.andRZSQEqualTo(year + "-" + (period > 9 ? period.toString() : "0" + period.toString())); criteria.andRZSQEqualTo(year + (period > 9 ? period.toString() : "0" + period.toString()));
// } }
if (invoiceType != null) { if (invoiceType != null) {
criteria.andFPLXEqualTo(String.valueOf(invoiceType)); criteria.andFPLXEqualTo(String.valueOf(invoiceType));
...@@ -44,11 +43,11 @@ public class InputInvoiceDao { ...@@ -44,11 +43,11 @@ public class InputInvoiceDao {
// criteria1.andRZJGEqualTo(pass); // criteria1.andRZJGEqualTo(pass);
// example.or(criteria1); // example.or(criteria1);
} }
criteria.andFPZTNotEqualTo("1"); // 过滤作废状态
List<InputInvoice> list = inputInvoiceMapper.selectByExample(example).stream().filter(x -> { // List<InputInvoice> list = inputInvoiceMapper.selectByExample(example).stream().filter(x -> {
return x.getRZSQ().endsWith("-" + (period.intValue() > 9 ? period.toString() : "0" + period.toString())); // return x.getRZSQ().endsWith("-" + (period.intValue() > 9 ? period.toString() : "0" + period.toString()));
}).collect(Collectors.toList()); // }).collect(Collectors.toList());
// return inputInvoiceMapper.selectByExample(example); return inputInvoiceMapper.selectByExample(example);
return list;
} }
} }
...@@ -8,16 +8,15 @@ import pwc.taxtech.atms.dao.FormulaAdminMapper; ...@@ -8,16 +8,15 @@ import pwc.taxtech.atms.dao.FormulaAdminMapper;
import pwc.taxtech.atms.dao.ProjectServiceTypeMapper; import pwc.taxtech.atms.dao.ProjectServiceTypeMapper;
import pwc.taxtech.atms.dpo.CellTemplatePerGroupDto; import pwc.taxtech.atms.dpo.CellTemplatePerGroupDto;
import pwc.taxtech.atms.dpo.GroupId; import pwc.taxtech.atms.dpo.GroupId;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.entity.ProjectServiceType; import pwc.taxtech.atms.entity.ProjectServiceType;
import pwc.taxtech.atms.entity.ProjectServiceTypeExample; import pwc.taxtech.atms.entity.ProjectServiceTypeExample;
import pwc.taxtech.atms.exception.Exceptions; import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.vat.dao.CellDataMapper; import pwc.taxtech.atms.vat.dao.CellDataMapper;
import pwc.taxtech.atms.vat.dao.PeriodCellDataMapper; import pwc.taxtech.atms.vat.dao.PeriodCellDataMapper;
import pwc.taxtech.atms.vat.dao.PeriodDataSourceMapper;
import pwc.taxtech.atms.vat.dao.PeriodReportMapper; import pwc.taxtech.atms.vat.dao.PeriodReportMapper;
import pwc.taxtech.atms.vat.entity.PeriodCellData; import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.entity.PeriodCellDataExample;
import pwc.taxtech.atms.vat.entity.PeriodReport;
import pwc.taxtech.atms.vat.entity.PeriodReportExample;
import java.util.List; import java.util.List;
...@@ -35,25 +34,23 @@ public class FormulaAgent { ...@@ -35,25 +34,23 @@ public class FormulaAgent {
private PeriodCellDataMapper periodCellDataMapper; private PeriodCellDataMapper periodCellDataMapper;
@Autowired @Autowired
private ProjectServiceTypeMapper projectServiceTypeMapper; private ProjectServiceTypeMapper projectServiceTypeMapper;
@Autowired
private PeriodDataSourceMapper periodDataSourceMapper;
public List<CellTemplatePerGroupDto> getCellTemplateGroupDto(Long templateGroupId, String projectId,String code,Integer rowIndex,Integer columnIndex,Integer period) {
return adminMp.getCellTemplatePerGroupDto(templateGroupId,code,rowIndex,columnIndex,projectId,period);
}
public Project getFixedProject(String projectId, Integer year) {
return adminMp.getFixedProject(projectId,year);
}
public List<PeriodDataSource> queryManualDataSource(Long templateId, String projectId,Integer period){
PeriodDataSourceExample example = new PeriodDataSourceExample();
example.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period)
.andCellTemplateIdEqualTo(templateId).andTypeEqualTo(10);
return periodDataSourceMapper.selectByExample(example);
public List<CellTemplatePerGroupDto> getCellTemplateGroupDto(Long templateGroupId, String projectId) {
ProjectServiceTypeExample pst = new ProjectServiceTypeExample();
pst.createCriteria().andTemplateGroupIdEqualTo(Long.valueOf(templateGroupId))
.andServiceTypeIdEqualTo(EnumServiceType.VAT.getCode() + "");
List<ProjectServiceType> pstReult = projectServiceTypeMapper.selectByExample(pst);
List<CellTemplatePerGroupDto> cellTemplates = adminMp.getCellTemplatePerGroupDto(templateGroupId);
if (pstReult == null || pstReult.isEmpty()) {
List<GroupId> groupIds = adminMp.getTemplateGroupId(projectId);
GroupId groupId;
if (groupIds.size() > 0) {
groupId = groupIds.stream().filter(m -> m.isDefault != 1).findFirst().get();
if (groupId == null) groupId = groupIds.get(0);
cellTemplates.addAll(adminMp.getCellTemplatePerGroupDto(groupId.groupId));
}
}
return cellTemplates;
} }
private PeriodReport getReportByTemplate(String templateId, Integer periodId, String projectId) { private PeriodReport getReportByTemplate(String templateId, Integer periodId, String projectId) {
......
...@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import pwc.taxtech.atms.common.util.DateUtils; import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.EnumTbImportType; import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.constant.enums.EnumValidationType; import pwc.taxtech.atms.constant.enums.EnumValidationType;
import pwc.taxtech.atms.dao.OrganizationMapper; import pwc.taxtech.atms.dao.OrganizationMapper;
...@@ -58,17 +59,18 @@ public class InputInvoiceDataImportServiceImpl { ...@@ -58,17 +59,18 @@ public class InputInvoiceDataImportServiceImpl {
Project project = projectMapper.selectByPrimaryKey(projectId); Project project = projectMapper.selectByPrimaryKey(projectId);
Organization organization = organizationMapper.selectByPrimaryKey(project.getOrganizationId()); Organization organization = organizationMapper.selectByPrimaryKey(project.getOrganizationId());
InputInvoiceExample invoiceExample = new InputInvoiceExample(); InputInvoiceExample invoiceExample = new InputInvoiceExample();
invoiceExample.createCriteria().andGFSHEqualTo(organization.getTaxPayerNumber()).andRZSJBetween(DateUtils.getPeriodBeginFormat( invoiceExample.createCriteria().andGFSHEqualTo(organization.getTaxPayerNumber()).andRZSQBetween(DateUtils.getPeriodBeginFormat(
project.getYear(), paras.getPeriodStart()), DateUtils.getPeriodEndFormat(project.getYear(), paras.getPeriodEnd())) project.getYear(), paras.getPeriodStart(), Constant.DateFormat.YYYYMM), DateUtils.getPeriodEndFormat(project.getYear(),
.andRZJGEqualTo(INPUT_RZJG_SUCCESS).andRZZTEqualTo(INPUT_RZZT_OVER); paras.getPeriodEnd(), Constant.DateFormat.YYYYMM)).andRZJGEqualTo(INPUT_RZJG_SUCCESS).andRZZTEqualTo(INPUT_RZZT_OVER)
.andFPZTNotEqualTo("1");
PageHelper.startPage(paras.getPageInfo().getPageIndex(), paras.getPageInfo().getPageSize()); PageHelper.startPage(paras.getPageInfo().getPageIndex(), paras.getPageInfo().getPageSize());
List<InputInvoice> invoices = inputInvoiceMapper.selectByExample(invoiceExample); List<InputInvoice> invoices = inputInvoiceMapper.selectByExample(invoiceExample);
DecimalFormat df = new DecimalFormat("#,###.00"); DecimalFormat df = new DecimalFormat("#,###.00");
invoices.stream().forEach(x -> { invoices.stream().forEach(x -> {
x.setHJJE(df.format(new BigDecimal(x.getHJJE()))); x.setHJJE(df.format(new BigDecimal(x.getHJJE())));
x.setHJSE(df.format(new BigDecimal(x.getHJSE()))); x.setHJSE(df.format(new BigDecimal(x.getHJSE())));
x.setRZJG(convertRzjg(x.getRZJG())); x.setRZJG(convertRzjg(x.getRZJG()));
} }
); );
PageInfo<InputInvoice> pageInfo = new PageInfo<>(invoices); PageInfo<InputInvoice> pageInfo = new PageInfo<>(invoices);
......
...@@ -78,14 +78,16 @@ public class OutputInvoiceServiceImpl { ...@@ -78,14 +78,16 @@ public class OutputInvoiceServiceImpl {
Organization organization = organizationMapper.selectByPrimaryKey(project.getOrganizationId()); Organization organization = organizationMapper.selectByPrimaryKey(project.getOrganizationId());
OutputInvoiceExample outputInvoiceExample = new OutputInvoiceExample(); OutputInvoiceExample outputInvoiceExample = new OutputInvoiceExample();
if(organization.getTaxPayerNumber() == null){ if (organization.getTaxPayerNumber() == null) {
outputInvoiceExample.createCriteria().andXFSHIsNull().andKPZTEqualTo(OUTPUT_KPZT_YES). outputInvoiceExample.createCriteria().andXFSHIsNull().andKPZTEqualTo(OUTPUT_KPZT_YES).
andKPRQBetween(DateUtils.getPeriodBegin(project.getYear(), queryDto.getPeriodStart()), andKPRQBetween(DateUtils.getPeriodBegin(project.getYear(), queryDto.getPeriodStart()),
DateUtils.getPeriodEnd(project.getYear(), queryDto.getPeriodEnd())); DateUtils.getPeriodEnd(project.getYear(), queryDto.getPeriodEnd()))
.andFPZTNotEqualTo("1");
} else { } else {
outputInvoiceExample.createCriteria().andXFSHEqualTo(organization.getTaxPayerNumber()).andKPZTEqualTo(OUTPUT_KPZT_YES). outputInvoiceExample.createCriteria().andXFSHEqualTo(organization.getTaxPayerNumber()).andKPZTEqualTo(OUTPUT_KPZT_YES).
andKPRQBetween(DateUtils.getPeriodBegin(project.getYear(), queryDto.getPeriodStart()), andKPRQBetween(DateUtils.getPeriodBegin(project.getYear(), queryDto.getPeriodStart()),
DateUtils.getPeriodEnd(project.getYear(), queryDto.getPeriodEnd())); DateUtils.getPeriodEnd(project.getYear(), queryDto.getPeriodEnd()))
.andFPZTNotEqualTo("1");
} }
...@@ -260,7 +262,7 @@ public class OutputInvoiceServiceImpl { ...@@ -260,7 +262,7 @@ public class OutputInvoiceServiceImpl {
private List<OutputVATInvoiceInfoDto> getQueryList(QueryOutputDto queryDto, String projectId) { private List<OutputVATInvoiceInfoDto> getQueryList(QueryOutputDto queryDto, String projectId) {
List<OutputVATInvoiceInfoDto> rList = outputInvoiceMapper.selectOutputInvoiceInfoLeftJoinItem(queryDto); List<OutputVATInvoiceInfoDto> rList = outputInvoiceMapper.selectOutputInvoiceInfoLeftJoinItem(queryDto);
Organization organization = organizationMapper.selectByPrimaryKey(projectMapper.selectByPrimaryKey(projectId).getOrganizationId()); Organization organization = organizationMapper.selectByPrimaryKey(projectMapper.selectByPrimaryKey(projectId).getOrganizationId());
if(organization == null){ if (organization == null) {
return Lists.newArrayList(); return Lists.newArrayList();
} }
OutputInvoiceExample e = new OutputInvoiceExample(); OutputInvoiceExample e = new OutputInvoiceExample();
...@@ -268,14 +270,14 @@ public class OutputInvoiceServiceImpl { ...@@ -268,14 +270,14 @@ public class OutputInvoiceServiceImpl {
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 = rList.stream().filter(a -> fpqqlshList.contains(a.getFpqqlsh())).collect(Collectors.toList()); rList = rList.stream().filter(a -> fpqqlshList.contains(a.getFpqqlsh())).collect(Collectors.toList());
rList.forEach(x -> { rList.forEach(x -> {
if(x.getInvoiceDate() != null){ if (x.getInvoiceDate() != null) {
CAL.setTime(x.getInvoiceDate()); CAL.setTime(x.getInvoiceDate());
x.setPeriodId(CAL.get(Calendar.MONTH) + 1); x.setPeriodId(CAL.get(Calendar.MONTH) + 1);
} }
if(x.getTaxAmount() == null || x.getAmount() == null || x.getTaxRate() == null){ if (x.getTaxAmount() == null || x.getAmount() == null || x.getTaxRate() == null) {
OutputInvoiceExample outputInvoiceExample = new OutputInvoiceExample(); OutputInvoiceExample outputInvoiceExample = new OutputInvoiceExample();
outputInvoiceExample.createCriteria().andIDEqualTo(x.getInvoiceId()); outputInvoiceExample.createCriteria().andIDEqualTo(x.getInvoiceId());
OutputInvoice outputInvoice = outputInvoiceMapper.selectByExample(outputInvoiceExample).get(0); OutputInvoice outputInvoice = outputInvoiceMapper.selectByExample(outputInvoiceExample).get(0);
x.setAmount(outputInvoice.getHJJE() == null ? BigDecimal.ZERO : new BigDecimal(outputInvoice.getHJJE())); x.setAmount(outputInvoice.getHJJE() == null ? BigDecimal.ZERO : new BigDecimal(outputInvoice.getHJJE()));
x.setTaxRate(outputInvoice.getSLV() == null ? BigDecimal.ZERO : new BigDecimal(outputInvoice.getSLV())); x.setTaxRate(outputInvoice.getSLV() == null ? BigDecimal.ZERO : new BigDecimal(outputInvoice.getSLV()));
x.setTaxAmount(outputInvoice.getHJSE() == null ? BigDecimal.ZERO : new BigDecimal(outputInvoice.getHJSE())); x.setTaxAmount(outputInvoice.getHJSE() == null ? BigDecimal.ZERO : new BigDecimal(outputInvoice.getHJSE()));
......
...@@ -50,7 +50,7 @@ import static pwc.taxtech.atms.dto.vatdto.WrapPeriodJobDto.*; ...@@ -50,7 +50,7 @@ import static pwc.taxtech.atms.dto.vatdto.WrapPeriodJobDto.*;
public class ReportServiceImpl { public class ReportServiceImpl {
private final static Logger logger = LoggerFactory.getLogger(ReportServiceImpl.class); private final static Logger logger = LoggerFactory.getLogger(ReportServiceImpl.class);
private BlockingQueue<PeriodJob> queue = new LinkedBlockingQueue<>(); private BlockingQueue<PeriodJob> queue = new LinkedBlockingQueue<>();
private final static String[] functions = {"SGSR", "FSJZ", "ND", "BB", "XXFP", "GZSD", "ProjectContext", "JXFPMX", "JXFP"}; private final static String[] functions = {"SGSR", "FSJZ", "ND", "BB", "XXFP", "GZSD", "ProjectContext", "JXFPMX", "JXFP","PSUM","DFFS"};
@Autowired @Autowired
private ReportGeneratorImpl reportGenerator; private ReportGeneratorImpl reportGenerator;
......
...@@ -12,9 +12,11 @@ import pwc.taxtech.atms.dpo.CellTemplatePerGroupDto; ...@@ -12,9 +12,11 @@ import pwc.taxtech.atms.dpo.CellTemplatePerGroupDto;
import pwc.taxtech.atms.dto.vatdto.BBParasBo; import pwc.taxtech.atms.dto.vatdto.BBParasBo;
import pwc.taxtech.atms.dto.vatdto.CurrentPeriodBo; import pwc.taxtech.atms.dto.vatdto.CurrentPeriodBo;
import pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto; import pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.exception.Exceptions; import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.exception.FormulaException; import pwc.taxtech.atms.exception.FormulaException;
import pwc.taxtech.atms.vat.entity.PeriodCellData; import pwc.taxtech.atms.vat.entity.PeriodCellData;
import pwc.taxtech.atms.vat.entity.PeriodDataSource;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -59,14 +61,18 @@ public class BB extends FunctionBase implements FreeRefFunction { ...@@ -59,14 +61,18 @@ public class BB extends FunctionBase implements FreeRefFunction {
BigDecimal cellValue = BigDecimal.ZERO; BigDecimal cellValue = BigDecimal.ZERO;
try { try {
CellTemplatePerGroupDto cellTemplateData = agent.getCellTemplateGroupDto(formulaContext.getReportTemplateGroupId(), List<CellTemplatePerGroupDto> cellTemplateDataList;
formulaContext.getProjectId()).stream().filter(dto -> dto.getRowIndex() == bo.getRowIndex() - 1 if (curPeriod.getCurYear() != formulaContext.getYear()) {
&& dto.getColumnIndex() == bo.getColumnIndex() - 1 && dto.getReportCode().equals(bo.getReportCode())) Project project = agent.getFixedProject(formulaContext.getProjectId(), curPeriod.getCurYear());
.findFirst().orElseThrow(() -> { MyAsserts.assertNotNull(project, Exceptions.PROJECT_NOT_FOUND);
return Exceptions.BB_CELL_TEMP_NULL; cellTemplateDataList = agent.getCellTemplateGroupDto(formulaContext.getReportTemplateGroupId(),
}); project.getId(), bo.getReportCode(), bo.getRowIndex() - 1, bo.getColumnIndex() - 1, curPeriod.getCurPeriod());
} else {
MyAsserts.assertNotNull(cellTemplateData, Exceptions.BB_CELL_TEMP_NULL); cellTemplateDataList = agent.getCellTemplateGroupDto(formulaContext.getReportTemplateGroupId(),
formulaContext.getProjectId(), bo.getReportCode(), bo.getRowIndex() - 1, bo.getColumnIndex() - 1, curPeriod.getCurPeriod());
}
MyAsserts.assertNotEmpty(cellTemplateDataList, Exceptions.BB_CELL_TEMP_NULL);
CellTemplatePerGroupDto cellTemplateData = cellTemplateDataList.get(0);
nullCellDto.fixedWithGroup(cellTemplateData); nullCellDto.fixedWithGroup(cellTemplateData);
// todo: fix datasource name by templateList(neo) // todo: fix datasource name by templateList(neo)
...@@ -94,24 +100,40 @@ public class BB extends FunctionBase implements FreeRefFunction { ...@@ -94,24 +100,40 @@ public class BB extends FunctionBase implements FreeRefFunction {
WorkbookEvaluator evaluator = (WorkbookEvaluator) evaluatorField.get(ec); WorkbookEvaluator evaluator = (WorkbookEvaluator) evaluatorField.get(ec);
int index = ec.getWorkbook().getSheetIndex(bo.getReportCode()); int index = ec.getWorkbook().getSheetIndex(bo.getReportCode());
if (index < 0) logger.warn("not found sheet code {}", bo.getReportCode()); if (index < 0)
logger.warn("[BB_Exception] not found sheet code {} with {}", bo.getReportCode(), bo.toString());
ValueEval eval = evaluator.evaluate(ec.getWorkbook().getSheet(index) ValueEval eval = evaluator.evaluate(ec.getWorkbook().getSheet(index)
.getCell(bo.getRowIndex() - 1, bo.getColumnIndex() - 1)); .getCell(bo.getRowIndex() - 1, bo.getColumnIndex() - 1));
bo.putPeriodCellTempate(formulaContext.getPeriod(), Long.parseLong(cellTemplateData.getCellTemplateId())); bo.putPeriodCellTempate(formulaContext.getPeriod(), Long.parseLong(cellTemplateData.getCellTemplateId()));
if (eval instanceof ErrorEval) { List<PeriodDataSource> dss = agent.queryManualDataSource(Long.parseLong(cellTemplateData.getCellTemplateId()),
LOGGER.warn("error eval for bb {} and error code {} and error String {}", bo.toString(), formulaContext.getProjectId(), formulaContext.getPeriod());
if (eval instanceof ErrorEval || eval == null || eval instanceof BlankEval) {
LOGGER.warn("[BB_Exception] error eval for bb {} and error code {} and error String {}", bo.toString(),
((ErrorEval) eval).getErrorCode(), ((ErrorEval) eval).getErrorString()); ((ErrorEval) eval).getErrorCode(), ((ErrorEval) eval).getErrorString());
if (!dss.isEmpty()) cellValue = dss.get(0).getAmount();
} else {
String evalStr = OperandResolver.coerceValueToString(eval);
logger.debug("[BB_debug] eval other cell value {}", evalStr);
try {
cellValue = new BigDecimal(evalStr).setScale(4,
BigDecimal.ROUND_HALF_DOWN);
if (!dss.isEmpty())
cellValue = cellValue.add(dss.get(0).getAmount());
} catch (Exception e) {
if (!dss.isEmpty())
cellValue = dss.get(0).getAmount();
else throw e;
}
} }
cellValue = new BigDecimal(OperandResolver.coerceValueToDouble(eval));
nullCellDto.extractFromGroup(bo, formulaContext.getPeriod(), formulaContext.getYear(), cellTemplateData); nullCellDto.extractFromGroup(bo, formulaContext.getPeriod(), formulaContext.getYear(), cellTemplateData);
nullCellDto.setAmount(cellValue); nullCellDto.setAmount(cellValue);
return cellValue; return cellValue;
} }
// bo.disCount();
PeriodCellData cellData = null; PeriodCellData cellData = null;
String projectId = agent.getPastProjectId(curPeriod.getCurYear(), String projectId = agent.getPastProjectId(curPeriod.getCurYear(),
...@@ -120,15 +142,22 @@ public class BB extends FunctionBase implements FreeRefFunction { ...@@ -120,15 +142,22 @@ public class BB extends FunctionBase implements FreeRefFunction {
MyAsserts.assertNotEmpty(projectId, Exceptions.PROJECT_EMPTY); MyAsserts.assertNotEmpty(projectId, Exceptions.PROJECT_EMPTY);
cellData = agent.getCellData(cellTemplateData.getReportTemplateId(), cellData = agent.getCellData(cellTemplateData.getReportTemplateId(),
cellTemplateData.getCellTemplateId(), curPeriod.getCurPeriod(), formulaContext.getProjectId()); cellTemplateData.getCellTemplateId(), curPeriod.getCurPeriod(), formulaContext.getProjectId());
List<PeriodDataSource> dss = agent.queryManualDataSource(Long.parseLong(cellTemplateData.getCellTemplateId()),
formulaContext.getProjectId(), bo.getPeriod());
nullCellDto.extractFromGroup(bo, curPeriod, cellData, cellTemplateData); nullCellDto.extractFromGroup(bo, curPeriod, cellData, cellTemplateData);
// todo: fix datasource name by templateList(neo)
MyAsserts.assertNotNull(cellData.getData(), Exceptions.BB_CELL_DATA_NULL);
// cellValue= RoundValue(cellValue, cellDataType)TODO:maybe fixd round by cellDataTyep(KV neo) if (cellData.getData() == null && !dss.isEmpty()) {
cellValue = new BigDecimal(cellData.getData()).setScale(4, cellValue = dss.get(0).getAmount();
BigDecimal.ROUND_HALF_DOWN); } else if (cellData.getData() != null && dss.isEmpty()) {
cellValue = new BigDecimal(cellData.getData()).setScale(4,
BigDecimal.ROUND_HALF_DOWN);
} else if (cellData.getData() != null && !dss.isEmpty()) {
cellValue = dss.get(0).getAmount().add(new BigDecimal(cellData.getData()).setScale(4,
BigDecimal.ROUND_HALF_DOWN));
} else throw Exceptions.BB_CELL_DATA_NULL;
nullCellDto.setAmount(cellValue); nullCellDto.setAmount(cellValue);
if (rootBo != null) { if (rootBo != null) {
rootBo.putPeriodCellTempate(curPeriod.getCurPeriod(), Long.parseLong(cellTemplateData.getCellTemplateId())); rootBo.putPeriodCellTempate(curPeriod.getCurPeriod(), Long.parseLong(cellTemplateData.getCellTemplateId()));
...@@ -138,15 +167,18 @@ public class BB extends FunctionBase implements FreeRefFunction { ...@@ -138,15 +167,18 @@ public class BB extends FunctionBase implements FreeRefFunction {
LOGGER.debug("cell static value "); LOGGER.debug("cell static value ");
return cellValue; return cellValue;
} catch (Exception e) {
logger.warn("[BB_Exception] some error {}", bo.toString());
throw e;
} finally { } finally {
if (rootBo == null) { if (rootBo == null) {
LOGGER.warn("error for bb cacls for {} and current for {}", bo.toString(), curPeriod.toString()); LOGGER.warn("[BB_Exception] error for bb cacls for {} and current for {}", bo.toString(), curPeriod.toString());
Long dataSourceId = saveDataSource(ec, dataSource, FormulaDataSourceDetailType.ReportCellDataSourceDto, Long dataSourceId = saveDataSource(ec, dataSource, FormulaDataSourceDetailType.ReportCellDataSourceDto,
cellValue, formulaContext.getPeriod(), cellValue, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupId(), bo.getColumnIndex() - 1, bo.getRowIndex() - 1, formulaContext.getReportTemplateGroupId(), bo.getColumnIndex() - 1, bo.getRowIndex() - 1,
formulaContext.getProjectId()); formulaContext.getProjectId());
saveFormulaBlock(formulaContext.getPeriod(), ec, saveFormulaBlock(formulaContext.getPeriod(), ec,
bo.expression(), bo.expressionData(), dataSourceId, formulaContext.getProjectId()); bo.expression(), cellValue, dataSourceId, formulaContext.getProjectId());
} }
} }
} }
......
...@@ -178,25 +178,4 @@ public class FunctionBase { ...@@ -178,25 +178,4 @@ public class FunctionBase {
periodFormulaBlock.setUpdateTime(creatime); periodFormulaBlock.setUpdateTime(creatime);
SpringContextUtil.periodFormulaBlockMapper.insertSelective(periodFormulaBlock); SpringContextUtil.periodFormulaBlockMapper.insertSelective(periodFormulaBlock);
} }
public void saveFormulaBlock(int period, OperationEvaluationContext ec,
String formulaExpression, String val, Long dataSourceId, String projectId) {
Long cellTemplateId = getCellTemplateId(period, ec);
Date creatime = new Date();
PeriodFormulaBlock periodFormulaBlock = new PeriodFormulaBlock();
periodFormulaBlock.setProjectId(projectId);
periodFormulaBlock.setId(SpringContextUtil.distributedIdService.nextId());
periodFormulaBlock.setPeriod(period);
periodFormulaBlock.setReportId(0L);
periodFormulaBlock.setCellTemplateId(cellTemplateId);
periodFormulaBlock.setFormulaExpression(formulaExpression);
periodFormulaBlock.setData(val);
periodFormulaBlock.setDataSourceId(dataSourceId);
periodFormulaBlock.setCreateBy("Admin");
periodFormulaBlock.setCreateTime(creatime);
periodFormulaBlock.setUpdateBy("Admin");
periodFormulaBlock.setUpdateTime(creatime);
SpringContextUtil.periodFormulaBlockMapper.insertSelective(periodFormulaBlock);
}
} }
package pwc.taxtech.atms.vat.service.impl.report.functions;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.WorkbookEvaluator;
import org.apache.poi.ss.formula.eval.*;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType;
import pwc.taxtech.atms.dpo.CellTemplatePerGroupDto;
import pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto;
import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.vat.entity.PeriodDataSource;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
public class PSUM extends FunctionBase implements FreeRefFunction {
private Logger LOGGER = LoggerFactory.getLogger(PSUM.class);
final static ValueEval defaultEval = new StringEval("0");
public PSUM(FormulaContext formulaContext) {
super(formulaContext);
}
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
String param = getStringParam(args[0], ec);
String expression = "PSUM(\"" + param + "\")";
List<Object> dataSource = new ArrayList<>();
BigDecimal cellValue = new BigDecimal(0);
try {
List<PCell> pCells;
if (param.contains(":")) {
pCells = getPCellListFromArea(param);
} else if (param.contains(",")) {
pCells = getPCellList(param);
} else {
LOGGER.error("[PSUM] error , psum must contains : or ,");
throw Exceptions.BAD_BBVO_PARAMS;
}
cellValue = evaluatePCells(pCells, ec, this.formulaContext, dataSource);
return new NumberEval(cellValue.doubleValue());
} catch (Exception e) {
e.printStackTrace();
return defaultEval;
} finally {
Long dataSourceId = saveDataSource(ec, dataSource, FormulaDataSourceDetailType.ReportCellDataSourceDto,
cellValue, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupId(), ec.getColumnIndex() - 1, ec.getRowIndex() - 1,
formulaContext.getProjectId());
saveFormulaBlock(formulaContext.getPeriod(), ec,
expression, cellValue, dataSourceId, formulaContext.getProjectId());
}
}
private BigDecimal evaluatePCells(List<PCell> pCells, OperationEvaluationContext ec, FormulaContext formulaContext,
List<Object> dataSource) throws NoSuchFieldException, IllegalAccessException {
BigDecimal bigDecimal = new BigDecimal(0);
for (PCell pCell : pCells) {
Field evaluatorField = OperationEvaluationContext.class.getDeclaredField("_bookEvaluator");
evaluatorField.setAccessible(true);
WorkbookEvaluator evaluator = (WorkbookEvaluator) evaluatorField.get(ec);
ValueEval eval = evaluator.evaluate(ec.getWorkbook().getSheet(ec.getSheetIndex())
.getCell(pCell.rowIndex - 1, pCell.columnIndex - 1));
List<CellTemplatePerGroupDto> cellTemplateDataList = agent.getCellTemplateGroupDto(formulaContext.getReportTemplateGroupId(),
formulaContext.getProjectId(), ec.getWorkbook().getSheetName(ec.getSheetIndex()), pCell.rowIndex-1,
pCell.columnIndex-1, formulaContext.getPeriod());
MyAsserts.assertNotEmpty(cellTemplateDataList, Exceptions.PSUM_CELL_TEMP_NULL);
CellTemplatePerGroupDto cellTemplateData = cellTemplateDataList.get(0);
List<PeriodDataSource> dss = agent.queryManualDataSource(Long.parseLong(cellTemplateData.getCellTemplateId()),
formulaContext.getProjectId(), formulaContext.getPeriod());
BigDecimal cellValue = new BigDecimal(0);
if (eval instanceof ErrorEval || eval == null || eval instanceof BlankEval) {
LOGGER.warn("[PSUM_Exception] error eval for pcell {} and error code {} and error String {}", pCell.toString(),
((ErrorEval) eval).getErrorCode(), ((ErrorEval) eval).getErrorString());
if (!dss.isEmpty()) cellValue=dss.get(0).getAmount();
} else {
String evalStr = OperandResolver.coerceValueToString(eval);
logger.debug("[PSUM_debug] eval other cell value {}", evalStr);
try {
cellValue = new BigDecimal(evalStr).setScale(4,
BigDecimal.ROUND_HALF_DOWN);
if (!dss.isEmpty())
cellValue = cellValue.add(dss.get(0).getAmount());
} catch (Exception e) {
if (!dss.isEmpty())
cellValue = dss.get(0).getAmount();
else throw e;
}
}
ReportCellDataSourceDto dto = new ReportCellDataSourceDto();
dto.fixedWithGroup(cellTemplateData );
dto.setAmount(cellValue);
dto.setPeriod(formulaContext.getPeriod());
dto.setProjectId(formulaContext.getProjectId());
dto.setReportName(cellTemplateData.getReportCode());
dataSource.add(dto);
bigDecimal=bigDecimal.add(cellValue);
}
return bigDecimal;
}
public static class PCell {
int rowIndex;
int columnIndex;
public PCell(int rowIndex, int columnIndex) {
this.rowIndex = rowIndex;
this.columnIndex = columnIndex;
}
@Override
public String toString() {
return "PCell{" +
"rowIndex=" + rowIndex +
", columnIndex=" + columnIndex +
'}';
}
}
public static PCell getColumnIndex(String columnStr) {
columnStr = columnStr.toUpperCase();
char[] excelCol = columnStr.toCharArray();
int c = 0;
int r = 0;
int splitIndex = 0;
for (int i = columnStr.length() - 1; i >= 0; i--) {
if (excelCol[i] >= 'A' && excelCol[i] <= 'Z') {
c += ((int) Math.pow(26, splitIndex - i - 1) * (excelCol[i] - 64));
} else if (excelCol[i] >= '0' && excelCol[i] <= '9') {
r += ((int) Math.pow(10, excelCol.length - 1 - i) * (excelCol[i] - 48));
splitIndex = i;
} else {
c = -1;
r = -1;
}
}
return new PCell(r, c);
}
public static void main(String[] args) {
List<PCell> result = getPCellListFromArea("A1:C3");
System.out.println(result.size());
}
static List<PCell> getPCellListFromArea(String areaStr) {
String[] area = areaStr.split(":");
List<PCell> pCells = new ArrayList<>();
PCell begin = getColumnIndex(area[0]);
PCell end = getColumnIndex(area[1]);
for (int i = begin.rowIndex; i <= end.rowIndex; i++) {
for (int j = begin.columnIndex; j <= end.columnIndex; j++) {
pCells.add(new PCell(i, j));
}
}
return pCells;
}
static List<PCell> getPCellList(String listStr) {
String[] list = listStr.split(",");
List<PCell> pCells = new ArrayList<>(list.length);
for (String s : list) {
pCells.add(getColumnIndex(s));
}
return pCells;
}
}
...@@ -93,7 +93,7 @@ public class DataInitTest extends CommonIT { ...@@ -93,7 +93,7 @@ public class DataInitTest extends CommonIT {
@Test @Test
public void initInput() throws Exception { public void initInput() throws Exception {
Workbook workbook = WorkbookFactory.create(new File("C:\\Users\\Eddie Wu\\Desktop\\导入/导入模板_进项主表_绿能_201809.xls")); Workbook workbook = WorkbookFactory.create(new File("C:\\Users\\Eddie Wu\\Desktop\\导入\\进销项/导入模板_进项主表_乐叶_201807.xls"));
Sheet sheet = workbook.getSheetAt(0); Sheet sheet = workbook.getSheetAt(0);
for (int r = 1; r <= sheet.getLastRowNum(); r++) { for (int r = 1; r <= sheet.getLastRowNum(); r++) {
try { try {
...@@ -119,7 +119,7 @@ public class DataInitTest extends CommonIT { ...@@ -119,7 +119,7 @@ public class DataInitTest extends CommonIT {
invoice.setFPZT(sheet.getRow(r).getCell(27).getStringCellValue()); invoice.setFPZT(sheet.getRow(r).getCell(27).getStringCellValue());
invoice.setCYZT(sheet.getRow(r).getCell(28).getStringCellValue()); invoice.setCYZT(sheet.getRow(r).getCell(28).getStringCellValue());
invoice.setRZZT(sheet.getRow(r).getCell(29).getStringCellValue()); invoice.setRZZT(sheet.getRow(r).getCell(29).getStringCellValue());
invoice.setRZSQ(sheet.getRow(r).getCell(30).getStringCellValue()); invoice.setRZSQ(StringUtils.replace(sheet.getRow(r).getCell(30).getStringCellValue(), "-", ""));
invoice.setRZSJ(sheet.getRow(r).getCell(31).getStringCellValue()); invoice.setRZSJ(sheet.getRow(r).getCell(31).getStringCellValue());
invoice.setRZJG(sheet.getRow(r).getCell(32).getStringCellValue()); invoice.setRZJG(sheet.getRow(r).getCell(32).getStringCellValue());
invoice.setCJSJ(sheet.getRow(r).getCell(34).getStringCellValue()); invoice.setCJSJ(sheet.getRow(r).getCell(34).getStringCellValue());
...@@ -172,7 +172,7 @@ public class DataInitTest extends CommonIT { ...@@ -172,7 +172,7 @@ public class DataInitTest extends CommonIT {
@Test @Test
public void initOutput() throws Exception { public void initOutput() throws Exception {
Workbook workbook = WorkbookFactory.create(new File("C:\\Users\\Eddie Wu\\Desktop\\导入/导入模板_销项主表_绿能_201809(1).xlsx")); Workbook workbook = WorkbookFactory.create(new File("C:\\Users\\Eddie Wu\\Desktop\\导入\\进销项/导入模板_销项主表_绿能_201809.xlsx"));
Sheet sheet = workbook.getSheetAt(0); Sheet sheet = workbook.getSheetAt(0);
for (int r = 1; r <= sheet.getLastRowNum(); r++) { for (int r = 1; r <= sheet.getLastRowNum(); r++) {
try { try {
...@@ -184,7 +184,7 @@ public class DataInitTest extends CommonIT { ...@@ -184,7 +184,7 @@ public class DataInitTest extends CommonIT {
} }
OutputInvoice outputInvoice = new OutputInvoice(); OutputInvoice outputInvoice = new OutputInvoice();
outputInvoice.setID(CommonUtils.getUUID()); outputInvoice.setID(CommonUtils.getUUID());
outputInvoice.setFPQQLSH(CommonUtils.getUUID()); outputInvoice.setFPQQLSH(sheet.getRow(r).getCell(1).getStringCellValue());
outputInvoice.setFPDM(sheet.getRow(r).getCell(2).getStringCellValue()); outputInvoice.setFPDM(sheet.getRow(r).getCell(2).getStringCellValue());
outputInvoice.setFPHM(sheet.getRow(r).getCell(3).getStringCellValue()); outputInvoice.setFPHM(sheet.getRow(r).getCell(3).getStringCellValue());
outputInvoice.setKPRQ(sheet.getRow(r).getCell(4).getStringCellValue()); outputInvoice.setKPRQ(sheet.getRow(r).getCell(4).getStringCellValue());
...@@ -202,7 +202,52 @@ public class DataInitTest extends CommonIT { ...@@ -202,7 +202,52 @@ public class DataInitTest extends CommonIT {
outputInvoice.setJSHJ(sheet.getRow(r).getCell(35).getStringCellValue()); outputInvoice.setJSHJ(sheet.getRow(r).getCell(35).getStringCellValue());
// outputInvoice.setSLV(sheet.getRow(r).getCell(42).getStringCellValue()); // outputInvoice.setSLV(sheet.getRow(r).getCell(42).getStringCellValue());
// outputInvoice.setHTBH(sheet.getRow(r).getCell(54).getStringCellValue()); // outputInvoice.setHTBH(sheet.getRow(r).getCell(54).getStringCellValue());
outputInvoiceMapper.insertSelective(outputInvoice); OutputInvoiceExample example = new OutputInvoiceExample();
example.createCriteria().andFPDMEqualTo(outputInvoice.getFPDM()).andFPHMEqualTo(outputInvoice.getFPHM());
if (outputInvoiceMapper.selectByExample(example).size() > 0) {
outputInvoiceMapper.updateByExampleSelective(outputInvoice, example);
} else {
outputInvoiceMapper.insertSelective(outputInvoice);
}
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("end");
}
@Test
public void initOutputDetail() throws Exception {
Workbook workbook = WorkbookFactory.create(new File("C:\\Users\\Eddie Wu\\Desktop\\导入\\进销项/导入模板_销项明细_绿能_201809.xlsx"));
Sheet sheet = workbook.getSheetAt(0);
for (int r = 1; r <= sheet.getLastRowNum(); r++) {
try {
for (int c = 0; c <= sheet.getRow(r).getLastCellNum(); c++) {
Cell cell = sheet.getRow(r).getCell(c);
if (null != cell) {
cell.setCellType(CellType.STRING);
}
}
OutputInvoiceDetail detail = new OutputInvoiceDetail();
detail.setID(CommonUtils.getUUID());
detail.setFPQQLSH(sheet.getRow(r).getCell(1).getStringCellValue());
detail.setSPMC(sheet.getRow(r).getCell(2).getStringCellValue());
detail.setGGXH(sheet.getRow(r).getCell(3).getStringCellValue());
detail.setDW(sheet.getRow(r).getCell(4).getStringCellValue());
detail.setDJ(sheet.getRow(r).getCell(5).getStringCellValue());
detail.setSL(sheet.getRow(r).getCell(6).getStringCellValue());
detail.setJE(sheet.getRow(r).getCell(7).getStringCellValue());
detail.setSLV(sheet.getRow(r).getCell(8).getStringCellValue());
detail.setSE(sheet.getRow(r).getCell(9).getStringCellValue());
detail.setMXXH(NumberUtils.createBigDecimal(sheet.getRow(r).getCell(15).getStringCellValue()));
detail.setFPHXZ(sheet.getRow(r).getCell(16).getStringCellValue());
OutputInvoiceDetailExample example = new OutputInvoiceDetailExample();
example.createCriteria().andFPQQLSHEqualTo(detail.getFPQQLSH());
if (outputInvoiceDetailMapper.selectByExample(example).size() > 0) {
outputInvoiceDetailMapper.updateByExampleSelective(detail, example);
} else {
outputInvoiceDetailMapper.insertSelective(detail);
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -6,37 +6,43 @@ import org.apache.ibatis.annotations.Select; ...@@ -6,37 +6,43 @@ import org.apache.ibatis.annotations.Select;
import pwc.taxtech.atms.MyMapper; import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.dpo.CellTemplatePerGroupDto; import pwc.taxtech.atms.dpo.CellTemplatePerGroupDto;
import pwc.taxtech.atms.dpo.GroupId; import pwc.taxtech.atms.dpo.GroupId;
import pwc.taxtech.atms.entity.Project;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface FormulaAdminMapper extends MyMapper { public interface FormulaAdminMapper extends MyMapper {
@Select("SELECT " + @Select("" +
" cell_template.id AS cellTemplateID, " + "SELECT " +
" template.id AS reportTemplateID, " + " cell_template.CELL_TEMPLATE_ID AS cellTemplateID, " +
" template.template_group_id AS reportTemplateGroupID, " + " template.TEMPLATE_ID AS reportTemplateID, " +
" cell_template.row_index AS rowIndex, " + " template.template_group_id AS reportTemplateGroupID, " +
" cell_template.column_index AS columnIndex, " + " cell_template.row_index AS rowIndex, " +
" template.Code AS reportCode, " + " cell_template.column_index AS columnIndex, " +
" cell_template.column_name AS columnName, " + " template.Code AS reportCode, " +
" cell_template.row_name AS rowName, " + " cell_template.column_name AS columnName, " +
" cell_template.data_type AS resultType " + " cell_template.row_name AS rowName, " +
"FROM " + " cell_template.data_type AS resultType " +
" template " + "FROM " +
" JOIN " + " period_template template " +
" cell_template ON template.id = cell_template.report_template_id " + " JOIN period_cell_template cell_template ON template.TEMPLATE_ID = cell_template.report_template_id " +
"WHERE " + "WHERE " +
" template.id IN ( " + " template.TEMPLATE_ID IN ( SELECT TEMPLATE_ID FROM period_template WHERE TEMPLATE_GROUP_ID = #{templateGroupId} " +
" SELECT " + " AND IS_ACTIVE_ASSOCIATION = 1 AND CODE = #{code} ) " +
" ID " + " AND ROW_INDEX = #{rowIndex} " +
" FROM " + " AND COLUMN_INDEX = #{columnIndex} " +
" TEMPLATE " + " AND template.PROJECT_ID = #{projectId} " +
" WHERE " + " AND template.PERIOD = #{period} " +
" TEMPLATE_GROUP_ID = #{groupId} " + " AND cell_template.PROJECT_ID = #{projectId} " +
" AND IS_ACTIVE_ASSOCIATION = 1 " + " AND cell_template.PERIOD = #{period}" +
" )") "")
List<CellTemplatePerGroupDto> getCellTemplatePerGroupDto(@Param("groupId") Long groupId); List<CellTemplatePerGroupDto> getCellTemplatePerGroupDto(@Param("templateGroupId") Long templateGroupId,
@Param("code") String code,
@Param("rowIndex") Integer rowIndex,
@Param("columnIndex") Integer columnIndex,
@Param("projectId") String projectId,
@Param("period") Integer period);
@Select("SELECT " + @Select("SELECT " +
...@@ -64,4 +70,17 @@ public interface FormulaAdminMapper extends MyMapper { ...@@ -64,4 +70,17 @@ public interface FormulaAdminMapper extends MyMapper {
" AND ROWNUM=1"+ " AND ROWNUM=1"+
"ORDER BY ps.Service_Type_ID ") "ORDER BY ps.Service_Type_ID ")
String getPastProjectId(@Param("year") int year, @Param("orgId") String organizationId); String getPastProjectId(@Param("year") int year, @Param("orgId") String organizationId);
@Select("" +
"SELECT " +
" p.ID AS id, " +
" p.CODE AS code, " +
" p.NAME AS name, " +
" p.ORGANIZATION_ID AS organizationId " +
"FROM " +
" PROJECT p " +
" JOIN ( SELECT CODE, ORGANIZATION_ID FROM PROJECT WHERE ID = #{projectId} ) t ON p.CODE = t.CODE " +
" AND p.ORGANIZATION_ID = t.ORGANIZATION_ID AND p.YEAR = #{year}" +
"")
Project getFixedProject(@Param("projectId") String projectId, @Param("year") Integer year);
} }
...@@ -2,15 +2,12 @@ package pwc.taxtech.atms.vat.dao; ...@@ -2,15 +2,12 @@ package pwc.taxtech.atms.vat.dao;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper; import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.entity.CellData; import pwc.taxtech.atms.vat.entity.CellData;
import pwc.taxtech.atms.vat.entity.CellDataExample; import pwc.taxtech.atms.vat.entity.CellDataExample;
import pwc.taxtech.atms.vat.entity.PCTEntity;
import java.util.List; import java.util.List;
import java.util.Set;
@Mapper @Mapper
public interface CellDataMapper extends MyVatMapper { public interface CellDataMapper extends MyVatMapper {
...@@ -110,19 +107,4 @@ public interface CellDataMapper extends MyVatMapper { ...@@ -110,19 +107,4 @@ public interface CellDataMapper extends MyVatMapper {
*/ */
int updateByPrimaryKey(CellData record); int updateByPrimaryKey(CellData record);
@Select("<script>" +
"SELECT " +
" R.PERIOD, C.CELL_TEMPLATE_ID AS CELLTEMPLATEID, DATA " +
"FROM " +
" CELL_DATA C, " +
" REPORT R " +
"WHERE " +
" C.REPORT_ID = R.ID AND " +
" " +
" <foreach item=\"item\" index=\"index\" collection=\"list\"" +
" open=\"(\" separator=\"OR\" close=\")\">" +
" ( R.PERIOD=#{item.period} AND C.CELL_TEMPLATE_ID=#{item.cellTemplateId} )" +
" </foreach>" +
"</script>")
List<PCTEntity> queryByPCTs(@Param("list") Set<PCTEntity> parameter);
} }
\ No newline at end of file
...@@ -2,16 +2,12 @@ package pwc.taxtech.atms.vat.dao; ...@@ -2,16 +2,12 @@ package pwc.taxtech.atms.vat.dao;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper; import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.dpo.MergerManaualCellData;
import pwc.taxtech.atms.vat.entity.PCTEntity;
import pwc.taxtech.atms.vat.entity.PeriodCellData; import pwc.taxtech.atms.vat.entity.PeriodCellData;
import pwc.taxtech.atms.vat.entity.PeriodCellDataExample; import pwc.taxtech.atms.vat.entity.PeriodCellDataExample;
import java.util.List; import java.util.List;
import java.util.Set;
@Mapper @Mapper
public interface PeriodCellDataMapper extends MyVatMapper { public interface PeriodCellDataMapper extends MyVatMapper {
...@@ -111,51 +107,5 @@ public interface PeriodCellDataMapper extends MyVatMapper { ...@@ -111,51 +107,5 @@ public interface PeriodCellDataMapper extends MyVatMapper {
*/ */
int updateByPrimaryKey(PeriodCellData record); int updateByPrimaryKey(PeriodCellData record);
int batchInsert2(List<PeriodCellData> list);
int batchInsert(List<PeriodCellData> list); int batchInsert(List<PeriodCellData> list);
@Select("<script>" +
"SELECT " +
" count( pcds.DATA_SOURCE_ID ) AS dsCount, " +
" pcd.ID as cellId, " +
" pcd.DATA as data, " +
" pcd.FORMULA_EXP as formulaExp, " +
" pcd.CELL_TEMPLATE_ID as cellTemplateId, " +
" pcd.PERIOD as period, " +
" temp.AMOUNT as amount " +
"FROM " +
" PERIOD_CELL_DATA pcd " +
" JOIN PERIOD_CELL_DATA_SOURCE pcds ON pcd.ID = pcds.CELL_DATA_ID " +
" LEFT JOIN ( " +
" SELECT " +
" pcd.ID, " +
" pds.TYPE, " +
" pds.AMOUNT, " +
" pds.PERIOD, " +
" pds.PROJECT_ID " +
" FROM " +
" PERIOD_CELL_DATA pcd " +
" JOIN PERIOD_CELL_DATA_SOURCE pcds ON pcd.ID = pcds.CELL_DATA_ID " +
" JOIN PERIOD_DATA_SOURCE pds ON pcds.DATA_SOURCE_ID = pds.ID " +
" WHERE " +
" pcd.PROJECT_ID = #{projectId} " +
" AND pds.TYPE = 10 " +
" ) temp ON pcd.ID = temp.ID AND pcd.PROJECT_ID = temp.PROJECT_ID and pcd.PERIOD = temp.period " +
"WHERE " +
" pcd.PERIOD = 10 " +
" AND pcd.PROJECT_ID = #{projectId} AND " +
" <foreach item=\"item\" index=\"index\" collection=\"list\"" +
" open=\"(\" separator=\"OR\" close=\")\">" +
" ( pcd.PERIOD=#{item.period} AND pcd.CELL_TEMPLATE_ID=#{item.cellTemplateId} )" +
" </foreach>" +
"GROUP BY " +
" pcd.ID, " +
" pcd.DATA, " +
" pcd.FORMULA_EXP, " +
" pcd.CELL_TEMPLATE_ID, " +
" pcd.PERIOD, " +
" temp.AMOUNT" +
"</script>")
List<PCTEntity> queryByPCTs(@Param("list") Set<PCTEntity> parameter, @Param("projectId") String projectId);
} }
\ No newline at end of file
package pwc.taxtech.atms.vat.entity;
public class PCTEntity {
Integer period;
Long cellTemplateId;
String data;
String formulaExp;
Long cellId;
String amount;
Integer dsCount;
public PCTEntity() {
}
public PCTEntity(String pctStr) {
String[] pct = pctStr.split(":");
this.period = Integer.parseInt(pct[0]);
this.cellTemplateId = Long.parseLong(pct[1]);
}
@Override
public int hashCode() {
return (period + "" + cellTemplateId).hashCode();
}
@Override
public boolean equals(Object obj) {
PCTEntity target = (PCTEntity) obj;
return period.intValue() == target.period.intValue()
&& cellTemplateId.longValue() == target.cellTemplateId.longValue();
}
public Integer getPeriod() {
return period;
}
public void setPeriod(Integer period) {
this.period = period;
}
public Long getCellTemplateId() {
return cellTemplateId;
}
public void setCellTemplateId(Long cellTemplateId) {
this.cellTemplateId = cellTemplateId;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public String getFormulaExp() {
return formulaExp;
}
public void setFormulaExp(String formulaExp) {
this.formulaExp = formulaExp;
}
public Long getCellId() {
return cellId;
}
public void setCellId(Long cellId) {
this.cellId = cellId;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public Integer getDsCount() {
return dsCount;
}
public void setDsCount(Integer dsCount) {
this.dsCount = dsCount;
}
}
...@@ -284,7 +284,7 @@ ...@@ -284,7 +284,7 @@
JOIN JOIN
OUTPUT_INVOICE_DETAIL INVOICEDETAIL OUTPUT_INVOICE_DETAIL INVOICEDETAIL
ON ON
INVOICE.FPQQLSH = INVOICEDETAIL.FPQQLSH INVOICE.FPQQLSH = INVOICEDETAIL.FPQQLSH and INVOICE.FPZT != '1'
ORDER BY ORDER BY
INVOICE.FPHM INVOICE.FPHM
</select> </select>
......
kill -9 `ps -ef |grep java | grep atms-invoice | awk '{print $2}'`
nohup mvn clean spring-boot:run &
...@@ -182,6 +182,17 @@ ...@@ -182,6 +182,17 @@
if (treeData && treeData.calculateData) { if (treeData && treeData.calculateData) {
treeData.calculateData.TitleName = $translate.instant('Total'); treeData.calculateData.TitleName = $translate.instant('Total');
$scope.subtotals = treeData.calculateData; $scope.subtotals = treeData.calculateData;
var tmp = parseInt($scope.subtotals.begDebitBal.replace(/\,/g, '')) - parseInt($scope.subtotals.begCreditBal.replace(/\,/g, ''))
+ parseInt($scope.subtotals.debitBal.replace(/\,/g, '')) - parseInt($scope.subtotals.creditBal.replace(/\,/g, ''))
- parseInt($scope.subtotals.endDebitBal.replace(/\,/g, '')) + parseInt($scope.subtotals.endCreditBal.replace(/\,/g, ''));
if (0 !== tmp) {
swal({
title: $translate.instant('WarningTitle'),
text: '试算平衡表金额不平衡!差异:' + tmp,
type: "warning",
confirmButtonText: $translate.instant('Confirm')
});
}
} }
$('.filter-button').popover("hide"); $('.filter-button').popover("hide");
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
class="fa fa-floppy-o"></i>&nbsp;{{'报表提审'}}</span> class="fa fa-floppy-o"></i>&nbsp;{{'报表提审'}}</span>
<span ng-if="!isBSPL" ng-click="doApprove();"><i <span ng-if="!isBSPL" ng-click="doApprove();"><i
class="fa fa-floppy-o"></i>&nbsp;{{'报表审批'}}</span> class="fa fa-floppy-o"></i>&nbsp;{{'报表审批'}}</span>
<span ng-if="!isBSPL" ng-click="saveReportCache();"><i <!--<span ng-if="!isBSPL" ng-click="saveReportCache();"><i-->
class="fa fa-floppy-o"></i>&nbsp;{{'Save' | translate}}</span> <!--class="fa fa-floppy-o"></i>&nbsp;{{'Save' | translate}}</span>-->
</div> </div>
<div class='report-container' id="reportContainer"> <div class='report-container' id="reportContainer">
......
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