Commit 966b7204 authored by sherlock's avatar sherlock

import excel template with Key-in

parent c2921303
...@@ -51,7 +51,7 @@ public class OutputInvoiceController { ...@@ -51,7 +51,7 @@ public class OutputInvoiceController {
} }
@RequestMapping(value = "getExportOutputInvoiceList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "getExportOutputInvoiceList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void downloadInvoiceQueryData(@RequestBody QueryOutputDto paras, HttpServletResponse response) { public void downloadInvoiceQueryData(@RequestBody QueryOutputDto paras, @RequestHeader("from") String projectId, HttpServletResponse response) {
response.setContentType("application/vnd.ms-excel;charset=utf-8"); response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" response.setHeader("Content-Disposition", "attachment;filename="
+ UUID.randomUUID() + ".xls"); + UUID.randomUUID() + ".xls");
...@@ -59,7 +59,7 @@ public class OutputInvoiceController { ...@@ -59,7 +59,7 @@ public class OutputInvoiceController {
OutputStream os = null; OutputStream os = null;
try { try {
os = response.getOutputStream(); os = response.getOutputStream();
int count = getDownloadFilePath(paras, os); int count = getDownloadFilePath(paras, projectId, os);
if (count == 0) { if (count == 0) {
response.setStatus(SC_NO_CONTENT); response.setStatus(SC_NO_CONTENT);
...@@ -81,8 +81,8 @@ public class OutputInvoiceController { ...@@ -81,8 +81,8 @@ public class OutputInvoiceController {
return ResponseEntity.ok().body(outputInvoiceService.getOutputInvoiceList(period)); return ResponseEntity.ok().body(outputInvoiceService.getOutputInvoiceList(period));
} }
private int getDownloadFilePath(QueryOutputDto paras, OutputStream outputStream) { private int getDownloadFilePath(QueryOutputDto paras, String projectId, OutputStream outputStream) {
List<OutputVATInvoiceInfoDto> list = outputInvoiceService.getExportOutputInvoiceList(paras).getData(); List<OutputVATInvoiceInfoDto> list = outputInvoiceService.getExportOutputInvoiceList(paras, projectId).getData();
if (list.size() == 0) { if (list.size() == 0) {
return 0; return 0;
} }
......
...@@ -97,6 +97,7 @@ public class TemplateGroupController { ...@@ -97,6 +97,7 @@ public class TemplateGroupController {
@RequestMapping(value = "importTemplateGroupExcelFile", method = RequestMethod.POST) @RequestMapping(value = "importTemplateGroupExcelFile", method = RequestMethod.POST)
public OperationResultDto importTemplateGroupExcelFile(@RequestParam MultipartFile file, public OperationResultDto importTemplateGroupExcelFile(@RequestParam MultipartFile file,
@RequestParam String filename, @RequestParam String filename,
@RequestParam Boolean allowManual,
@RequestParam String tempFileName, @RequestParam String tempFileName,
@RequestParam String jsonModel) { @RequestParam String jsonModel) {
try { try {
...@@ -107,7 +108,8 @@ public class TemplateGroupController { ...@@ -107,7 +108,8 @@ public class TemplateGroupController {
if (CollectionUtils.isEmpty(templateGroupDto.getSheetNameList())) { if (CollectionUtils.isEmpty(templateGroupDto.getSheetNameList())) {
return OperationResultDto.error(ErrorMessage.NoSelectSheet); return OperationResultDto.error(ErrorMessage.NoSelectSheet);
} }
templateGroupService.importTemplateGroupExcelFile(file, templateGroupDto); if(allowManual == null) allowManual = Boolean.FALSE;
templateGroupService.importTemplateGroupExcelFile(file, allowManual, templateGroupDto);
return OperationResultDto.success(); return OperationResultDto.success();
} catch (ServiceException e) { } catch (ServiceException e) {
return OperationResultDto.error(e.getMessage()); return OperationResultDto.error(e.getMessage());
...@@ -117,17 +119,20 @@ public class TemplateGroupController { ...@@ -117,17 +119,20 @@ public class TemplateGroupController {
return OperationResultDto.error(ErrorMessage.SystemError); return OperationResultDto.error(ErrorMessage.SystemError);
} }
@ResponseBody @ResponseBody
@ApiOperation(value = "导入报表") @ApiOperation(value = "导入报表")
@RequestMapping(value = "importTemplateExcelFile", method = RequestMethod.POST) @RequestMapping(value = "importTemplateExcelFile", method = RequestMethod.POST)
public OperationResultDto importTemplateExcelFile(@RequestParam MultipartFile file, public OperationResultDto importTemplateExcelFile(@RequestParam MultipartFile file,
@RequestParam Long templateGroupID, @RequestParam Long templateGroupID,
@RequestParam String sheetList, @RequestParam String sheetList,
@RequestParam Boolean allowManual,
@RequestParam String tempFileName, @RequestParam String tempFileName,
@RequestParam String reportType, @RequestParam String reportType,
@RequestParam String filename) { @RequestParam String filename) {
try { try {
templateGroupService.importTemplateExcelFile(file, templateGroupID, reportType, sheetList); if(allowManual == null) allowManual = Boolean.FALSE;
templateGroupService.importTemplateExcelFile(file, allowManual, templateGroupID, reportType, sheetList);
return OperationResultDto.success(); return OperationResultDto.success();
} catch (ServiceException e) { } catch (ServiceException e) {
return OperationResultDto.error(e.getMessage()); return OperationResultDto.error(e.getMessage());
......
...@@ -15,6 +15,7 @@ import pwc.taxtech.atms.common.CommonUtils; ...@@ -15,6 +15,7 @@ import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.POIUtil; import pwc.taxtech.atms.common.POIUtil;
import pwc.taxtech.atms.common.message.ErrorMessage; import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.common.message.TemplateMessage; import pwc.taxtech.atms.common.message.TemplateMessage;
import pwc.taxtech.atms.constant.enums.CellDataSourceType;
import pwc.taxtech.atms.constant.enums.TemplateGroupType; import pwc.taxtech.atms.constant.enums.TemplateGroupType;
import pwc.taxtech.atms.dao.CellTemplateConfigDao; import pwc.taxtech.atms.dao.CellTemplateConfigDao;
import pwc.taxtech.atms.dao.CellTemplateConfigMapper; import pwc.taxtech.atms.dao.CellTemplateConfigMapper;
...@@ -184,7 +185,7 @@ public class TemplateGroupServiceImpl extends AbstractService { ...@@ -184,7 +185,7 @@ public class TemplateGroupServiceImpl extends AbstractService {
} }
@Transactional @Transactional
public void importTemplateGroupExcelFile(MultipartFile file, TemplateGroupDto templateGroupDto) throws ServiceException { public void importTemplateGroupExcelFile(MultipartFile file, boolean allowManual, TemplateGroupDto templateGroupDto) throws ServiceException {
List<String> sheetNameList = templateGroupDto.getSheetNameList(); List<String> sheetNameList = templateGroupDto.getSheetNameList();
if (CollectionUtils.isEmpty(sheetNameList)) { if (CollectionUtils.isEmpty(sheetNameList)) {
throw new ServiceException(ErrorMessage.NoSelectSheet); throw new ServiceException(ErrorMessage.NoSelectSheet);
...@@ -269,13 +270,27 @@ public class TemplateGroupServiceImpl extends AbstractService { ...@@ -269,13 +270,27 @@ public class TemplateGroupServiceImpl extends AbstractService {
config.setId(distributedIdService.nextId()); config.setId(distributedIdService.nextId());
config.setCellTemplateId(cellTemplate.getId()); config.setCellTemplateId(cellTemplate.getId());
config.setReportTemplateId(template.getId()); config.setReportTemplateId(template.getId());
config.setDataSourceType(1);//todo 枚举 config.setDataSourceType(CellDataSourceType.Formula.getCode());//todo 枚举
config.setFormula(POIUtil.getCellFormulaString(cell)); config.setFormula(POIUtil.getCellFormulaString(cell));
// config.setFormula(cell.getCellFormula()); // config.setFormula(cell.getCellFormula());
config.setFormulaDataSource("报表数据"); //todo KV相关 config.setFormulaDataSource("报表数据"); //todo KV相关
config.setUpdateTime(now); config.setUpdateTime(now);
config.setUpdateBy(authUserHelper.getCurrentUserId()); config.setUpdateBy(authUserHelper.getCurrentUserId());
cellTemplateConfigList.add(config); cellTemplateConfigList.add(config);
if(allowManual){
CellTemplateConfig configManual = new CellTemplateConfig();
configManual.setId(distributedIdService.nextId());
configManual.setCellTemplateId(cellTemplate.getId());
configManual.setReportTemplateId(template.getId());
configManual.setDataSourceType(CellDataSourceType.KeyIn.getCode());//todo 枚举
configManual.setFormula(POIUtil.getCellFormulaString(cell));
// config.setFormula(cell.getCellFormula());
// configManual.setFormulaDataSource("报表数据"); //todo KV相关
configManual.setUpdateTime(now);
configManual.setUpdateBy(authUserHelper.getCurrentUserId());
cellTemplateConfigList.add(configManual);
}
PeriodDataSource pds = new PeriodDataSource(); PeriodDataSource pds = new PeriodDataSource();
pds.setAmount(BigDecimal.ZERO); pds.setAmount(BigDecimal.ZERO);
pds.setUpdateBy("Admin"); pds.setUpdateBy("Admin");
...@@ -310,7 +325,7 @@ public class TemplateGroupServiceImpl extends AbstractService { ...@@ -310,7 +325,7 @@ public class TemplateGroupServiceImpl extends AbstractService {
} }
@Transactional @Transactional
public void importTemplateExcelFile(MultipartFile file, Long templateGroupId, String reportType, String sheetList) throws ServiceException { public void importTemplateExcelFile(MultipartFile file, boolean allowManual, Long templateGroupId, String reportType, String sheetList) throws ServiceException {
if (null == file) { if (null == file) {
throw new ServiceException(ErrorMessage.NoFile); throw new ServiceException(ErrorMessage.NoFile);
} }
...@@ -388,6 +403,19 @@ public class TemplateGroupServiceImpl extends AbstractService { ...@@ -388,6 +403,19 @@ public class TemplateGroupServiceImpl extends AbstractService {
config.setUpdateTime(now); config.setUpdateTime(now);
config.setUpdateBy(authUserHelper.getCurrentUserId()); config.setUpdateBy(authUserHelper.getCurrentUserId());
cellTemplateConfigList.add(config); cellTemplateConfigList.add(config);
if(allowManual){
CellTemplateConfig configManual = new CellTemplateConfig();
configManual.setId(distributedIdService.nextId());
configManual.setCellTemplateId(cellTemplate.getId());
configManual.setReportTemplateId(template.getId());
configManual.setDataSourceType(CellDataSourceType.KeyIn.getCode());//todo 枚举
configManual.setFormula(POIUtil.getCellFormulaString(cell));
// config.setFormula(cell.getCellFormula());
// configManual.setFormulaDataSource("报表数据"); //todo KV相关
configManual.setUpdateTime(now);
configManual.setUpdateBy(authUserHelper.getCurrentUserId());
cellTemplateConfigList.add(configManual);
}
PeriodDataSource pds = new PeriodDataSource(); PeriodDataSource pds = new PeriodDataSource();
pds.setAmount(BigDecimal.ZERO); pds.setAmount(BigDecimal.ZERO);
pds.setUpdateBy("Admin"); pds.setUpdateBy("Admin");
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import javafx.geometry.Orientation; import javafx.geometry.Orientation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
...@@ -100,9 +101,9 @@ public class OutputInvoiceServiceImpl { ...@@ -100,9 +101,9 @@ public class OutputInvoiceServiceImpl {
return pageInfo; return pageInfo;
} }
public OperationResultDto<List<OutputVATInvoiceInfoDto>> getExportOutputInvoiceList(QueryOutputDto queryDto) { public OperationResultDto<List<OutputVATInvoiceInfoDto>> getExportOutputInvoiceList(QueryOutputDto queryDto, String projectId) {
OperationResultDto<List<OutputVATInvoiceInfoDto>> result = new OperationResultDto<>(); OperationResultDto<List<OutputVATInvoiceInfoDto>> result = new OperationResultDto<>();
List<OutputVATInvoiceInfoDto> finalList = getQueryList(queryDto); List<OutputVATInvoiceInfoDto> finalList = getQueryList(queryDto, projectId);
finalList = getOutputDetailInfoList(finalList); finalList = getOutputDetailInfoList(finalList);
result.setData(finalList); result.setData(finalList);
result.setResult(true); result.setResult(true);
...@@ -256,9 +257,16 @@ public class OutputInvoiceServiceImpl { ...@@ -256,9 +257,16 @@ public class OutputInvoiceServiceImpl {
// return stream.sorted(Comparator.comparing(OutputVATInvoiceInfoDto::getInvoiceDate)).collect(Collectors.toList()); // return stream.sorted(Comparator.comparing(OutputVATInvoiceInfoDto::getInvoiceDate)).collect(Collectors.toList());
// } // }
private List<OutputVATInvoiceInfoDto> getQueryList(QueryOutputDto queryDto) { private List<OutputVATInvoiceInfoDto> getQueryList(QueryOutputDto queryDto, String projectId) {
List<OutputVATInvoiceInfoDto> rList = outputInvoiceMapper.selectOutputInvoiceInfoLeftJoinItem(queryDto); List<OutputVATInvoiceInfoDto> rList = outputInvoiceMapper.selectOutputInvoiceInfoLeftJoinItem(queryDto);
rList.stream().forEach(x -> { Organization organization = organizationMapper.selectByPrimaryKey(projectMapper.selectByPrimaryKey(projectId).getOrganizationId());
if(organization == null){
return Lists.newArrayList();
}
OutputInvoiceExample e = new OutputInvoiceExample();
e.createCriteria().andXFSHEqualTo(organization.getTaxPayerNumber());
List<String> fpqqlshList = outputInvoiceMapper.selectByExample(e).stream().map(OutputInvoice::getFPQQLSH).collect(Collectors.toList());
rList.stream().filter(a -> fpqqlshList.contains(a.getFpqqlsh())).forEach(x -> {
CAL.setTime(x.getInvoiceDate()); CAL.setTime(x.getInvoiceDate());
x.setPeriodId(CAL.get(Calendar.MONTH) + 1); x.setPeriodId(CAL.get(Calendar.MONTH) + 1);
}); });
......
...@@ -71,7 +71,7 @@ controller('editTemplategroupModalController', ['$scope', '$log', '$translate', ...@@ -71,7 +71,7 @@ controller('editTemplategroupModalController', ['$scope', '$log', '$translate',
Upload.upload({ Upload.upload({
url: thisConstant.uploadUrl, url: thisConstant.uploadUrl,
data: { data: {
allowManual: $('#allowManual').is(':checked'),
filename: $scope.editModel.file.name, filename: $scope.editModel.file.name,
tempFileName: tempFileName, tempFileName: tempFileName,
}, },
...@@ -264,6 +264,7 @@ controller('editTemplategroupModalController', ['$scope', '$log', '$translate', ...@@ -264,6 +264,7 @@ controller('editTemplategroupModalController', ['$scope', '$log', '$translate',
Upload.upload({ Upload.upload({
url: thisConstant.importTemplateExcelFile, url: thisConstant.importTemplateExcelFile,
data: { data: {
allowManual: $('#allowManual').is(':checked'),
jsonModel: json, jsonModel: json,
filename: $scope.editModel.file.name, filename: $scope.editModel.file.name,
tempFileName: tempFileName tempFileName: tempFileName
......
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
<div id={{::editModel.sheetSelectDxID}}></div> <div id={{::editModel.sheetSelectDxID}}></div>
</div> </div>
</div> </div>
<div class="form-group">
<label for="telCode" class="col-sm-5 control-label"><input type="radio" id="allowManual"></label>
<label for="telCode" class="col-sm-5 control-label"><span>允许手工录入</span></label>
</div>
</form> </form>
</div> </div>
<div class="modal-footer" style="padding-left: 22px;text-align: left;"> <div class="modal-footer" style="padding-left: 22px;text-align: left;">
......
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