Commit d25958d5 authored by sherlock's avatar sherlock

显示公式bug

parent 84b2aeb6
......@@ -33,6 +33,11 @@ public class ReportController {
return reportService.getReportTemplate(projectId, EnumServiceType.getEnumByCode(serviceType), period);
}
@RequestMapping(value = "filterTemplate/{projectId}/{serviceType}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<List<ReportDto>> getFilterTemplate(@PathVariable String projectId, @PathVariable int serviceType, @PathVariable Integer period) {
return reportService.getFilterReportTemplate(projectId, EnumServiceType.getEnumByCode(serviceType), period);
}
@RequestMapping(value = "generateByTotal/{projectId}/{mergeManual}/{period}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto generateAllData(@PathVariable String projectId, @PathVariable Integer period, @RequestParam Optional<String> generator,
@PathVariable Boolean mergeManual) {
......
......@@ -346,7 +346,19 @@ public class TemplateGroupServiceImpl extends AbstractService {
throw new ServiceException(ErrorMessage.SystemError);
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
optional.get().write(bos);
Workbook wtemp = optional.get();
Sheet temp = wtemp.getSheetAt(0);
for(int j = temp.getFirstRowNum(); j < temp.getLastRowNum(); j ++){
Row row = temp.getRow(j);
for(int k = row.getFirstCellNum(); k < row.getLastCellNum(); k++){
Cell cell = row.getCell(k);
if(!cell.getCellStyle().getLocked() && StringUtils.isNotBlank(cell.getStringCellValue())
&& cell.getStringCellValue().equalsIgnoreCase("${KeyIn}")){
cell.setCellValue("");
}
}
}
wtemp.write(bos);
String tmpPath = httpFileService.uploadTemplate(newName, file);
String[] arr = sheetName.split("_");
String name = arr.length >= 2 ? arr[1] : arr[0];
......
......@@ -15,7 +15,9 @@ import pwc.taxtech.atms.dpo.TemplateUniqDto;
import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.dto.vatdto.TemplateByGroupDto;
import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.vat.dao.PeriodReportMapper;
import pwc.taxtech.atms.vat.dao.PeriodTemplateMapper;
import pwc.taxtech.atms.vat.entity.PeriodReportExample;
import pwc.taxtech.atms.vat.entity.PeriodTemplateExample;
import java.util.*;
......@@ -27,7 +29,7 @@ import static java.util.stream.Collectors.groupingBy;
public class TemplateServiceImpl extends AbstractService {
@Autowired
private PeriodTemplateMapper periodTemplateMapper;
private PeriodReportMapper periodReportMapper;
public void addExistTemplate(TemplateAddExistDto templateAddExistDto){
TemplateExample t = new TemplateExample();
......@@ -308,10 +310,10 @@ public class TemplateServiceImpl extends AbstractService {
taxReturnGroup.setName(TemplateGroupType.TaxReturn.name());
List<TemplateDto> templateDtos2 = new ArrayList<>();
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;
PeriodReportExample periodReportExample = new PeriodReportExample();
periodReportExample.createCriteria().andTemplateIdEqualTo(x.getId())
.andProjectIdEqualTo(projectId);
return x.getTemplateGroupId().equals(templateGroupId) && periodReportMapper.selectByExample(periodReportExample).size() > 0;
}).collect(Collectors.toList()).forEach(a -> {
TemplateDto templateDto = new TemplateDto();
CommonUtils.copyProperties(a, templateDto);
......
......@@ -10,6 +10,7 @@ import org.apache.poi.ss.formula.udf.DefaultUDFFinder;
import org.apache.poi.ss.formula.udf.UDFFinder;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -89,6 +90,7 @@ public class ReportGeneratorImpl {
@Transactional
public void updateWorkbookCaclsValueToDb(String projectId, Integer period, Workbook workbook, PeriodResources resources,
Boolean isMergeMunual, PeriodJob job) {
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
String code = sheet.getSheetName();
......@@ -196,12 +198,24 @@ public class ReportGeneratorImpl {
dataSource.setColumnIndex(colNum - 1);
dataSource.setRowIndex(rowNum - 1);
if (((XSSFCell) cell).getRawValue() != "#VALUE!") {
dataSource.setAmount(new BigDecimal(
((XSSFCell) cell).getRawValue() != null ?
((XSSFCell) cell).getRawValue()
: (StringUtils.isNotBlank(cell.getStringCellValue())) ?
cell.getStringCellValue()
: Double.toString(cell.getNumericCellValue())));
if(StringUtils.isNotBlank(cell.getStringCellValue())
&& StringUtils.isNumeric(cell.getStringCellValue().replace(".", ""))){
dataSource.setAmount(new BigDecimal(cell.getStringCellValue()));
}
else if(StringUtils.isBlank(cell.getStringCellValue())){
dataSource.setAmount(new BigDecimal(Double.toString(cell.getNumericCellValue())));
}
// else {
// cell.setCellFormula(cell.getStringCellValue());
// FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook);
// dataSource.setAmount(new BigDecimal(formulaEvaluator.evaluate(cell).getNumberValue()));
// }
// dataSource.setAmount(new BigDecimal(
// ((XSSFCell) cell).getRawValue() != null ?
// ((XSSFCell) cell).getRawValue()
// : (StringUtils.isNotBlank(cell.getStringCellValue())) ?
// cell.getStringCellValue()
// : Double.toString(cell.getNumericCellValue())));
} else {
dataSource.setAmount(new BigDecimal("0.0"));
}
......@@ -241,9 +255,16 @@ public class ReportGeneratorImpl {
.getCell(tempPeriodCellTemplate.get().getColumnIndex()) != null) {
Cell cell = sheet.getRow(tempPeriodCellTemplate.get().getRowIndex())
.getCell(tempPeriodCellTemplate.get().getColumnIndex());
data = ((XSSFCell) cell).getRawValue();
if (data != null && data.equals("#VALUE!")) {
data = "0.0";
FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook);
try{
data = formulaEvaluator.evaluate(cell).getStringValue();
}catch (Exception e){
logger.error(e.getStackTrace().toString());
data = "0.0";
}
}
//evaluator.evaluate(cell);
// if (cell.getCellTypeEnum().equals(CellType.NUMERIC)||cell.getCellTypeEnum().equals(CellType.FORMULA)) {
......
......@@ -3,6 +3,7 @@ package pwc.taxtech.atms.vat.service.impl;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Workbook;
......@@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.util.BeanUtil;
import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.enums.*;
......@@ -30,7 +32,6 @@ import pwc.taxtech.atms.vat.dpo.DataSourceCellDataDto;
import pwc.taxtech.atms.vat.dpo.DataSourceExtendDto;
import pwc.taxtech.atms.vat.dpo.InputVATInvoiceItemExtendDto;
import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext;
import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaHelper;
import java.io.File;
......@@ -103,6 +104,25 @@ public class ReportServiceImpl {
@Autowired
private PeriodJobMapper periodJobMapper;
public OperationResultDto<List<ReportDto>> getFilterReportTemplate(String projectId, EnumServiceType serviceType, Integer periodParam) {
OperationResultDto<List<ReportDto>> result = new OperationResultDto<>();
CommonUtils.copyProperties(getReportTemplate(projectId,serviceType,periodParam),result);
if(!result.getResult() || CollectionUtils.isEmpty(result.getData())) return result;
int period = periodParam != null ? periodParam : 0;
PeriodTemplateExample periodTemplateExample = new PeriodTemplateExample();
periodTemplateExample.createCriteria().andProjectIdEqualTo(projectId)
.andPeriodEqualTo(period);
List<PeriodTemplate> periodTemplateList = periodTemplateMapper.selectByExample(periodTemplateExample);
List<String> ids = Lists.newArrayList();
periodTemplateList.stream().forEach(x -> ids.add(x.getTemplateId() + ""));
List<ReportDto> reportDtos = result.getData().stream().filter(x -> {
return ids.contains(x.getTemplateId());
}).collect(Collectors.toList());
result.setData(reportDtos);
return result;
}
public OperationResultDto<List<ReportDto>> getReportTemplate(String projectId, EnumServiceType serviceType, Integer periodParam) {
int period = periodParam != null ? periodParam : 0;
OperationResultDto<List<ReportDto>> operationResult = new OperationResultDto<>();
......@@ -155,7 +175,10 @@ public class ReportServiceImpl {
map.put("projectId", projectId);
map.put("templateGroupID", templateGroupId);
List<ReportDto> reportDtos = templateMapper.getTemplateLeftJoinReport(map);
if (reportDtos.isEmpty()) {
operationResult.setResultMsg("No Template");
return operationResult;
......
......@@ -98,7 +98,7 @@
</where>
</select>
<resultMap id="reportDto" type="pwc.taxtech.atms.dto.vatdto.ReportDto">
<resultMap id="reportDto" type="pwc.taxtech.atms.dpo.ReportDto">
<id column="ID" jdbcType="VARCHAR" property="id"/>
<result column="PERIOD" jdbcType="INTEGER" property="period"/>
<result column="TEMPLATE_ID" jdbcType="INTEGER" property="templateId"/>
......
......@@ -76,6 +76,13 @@
return $http.get('/Report/template/' + projectId + '/' + serviceType + '/' + period, apiConfig.createVat());
},
getFilterTemplate: function (projectId, serviceType, period) {
if (!_.isNumber(period)) {
period = 0;
}
return $http.get('/Report/filterTemplate/' + projectId + '/' + serviceType + '/' + period, apiConfig.createVat());
},
getCellVoucher: function (cellDataID) {
return $http.get('/Report/cellVoucher/' + cellDataID, apiConfig.createVat());
},
......
......@@ -19,7 +19,7 @@
//projectID = '0cf0945f-d41c-4df3-8235-ae693d5e724d';
$q.all([
templateGroupService.getGroupTemplateByGroupID(48372654336679936, projectID),
vatReportService.getTemplate(vatSessionService.project.id, constant.serviceType.VAT, vatSessionService.month)
vatReportService.getFilterTemplate(vatSessionService.project.id, constant.serviceType.VAT, vatSessionService.month)
]).then(function (result) {
if (!_.isEmpty(result[0]) && !_.isEmpty(result[0].data) && !_.isEmpty(result[0].data.data)
&& !_.isEmpty(result[1]) && !_.isEmpty(result[1].data) && !_.isEmpty(result[1].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