Commit 966b7204 authored by sherlock's avatar sherlock

import excel template with Key-in

parent c2921303
......@@ -51,7 +51,7 @@ public class OutputInvoiceController {
}
@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.setHeader("Content-Disposition", "attachment;filename="
+ UUID.randomUUID() + ".xls");
......@@ -59,7 +59,7 @@ public class OutputInvoiceController {
OutputStream os = null;
try {
os = response.getOutputStream();
int count = getDownloadFilePath(paras, os);
int count = getDownloadFilePath(paras, projectId, os);
if (count == 0) {
response.setStatus(SC_NO_CONTENT);
......@@ -81,8 +81,8 @@ public class OutputInvoiceController {
return ResponseEntity.ok().body(outputInvoiceService.getOutputInvoiceList(period));
}
private int getDownloadFilePath(QueryOutputDto paras, OutputStream outputStream) {
List<OutputVATInvoiceInfoDto> list = outputInvoiceService.getExportOutputInvoiceList(paras).getData();
private int getDownloadFilePath(QueryOutputDto paras, String projectId, OutputStream outputStream) {
List<OutputVATInvoiceInfoDto> list = outputInvoiceService.getExportOutputInvoiceList(paras, projectId).getData();
if (list.size() == 0) {
return 0;
}
......
......@@ -97,6 +97,7 @@ public class TemplateGroupController {
@RequestMapping(value = "importTemplateGroupExcelFile", method = RequestMethod.POST)
public OperationResultDto importTemplateGroupExcelFile(@RequestParam MultipartFile file,
@RequestParam String filename,
@RequestParam Boolean allowManual,
@RequestParam String tempFileName,
@RequestParam String jsonModel) {
try {
......@@ -107,7 +108,8 @@ public class TemplateGroupController {
if (CollectionUtils.isEmpty(templateGroupDto.getSheetNameList())) {
return OperationResultDto.error(ErrorMessage.NoSelectSheet);
}
templateGroupService.importTemplateGroupExcelFile(file, templateGroupDto);
if(allowManual == null) allowManual = Boolean.FALSE;
templateGroupService.importTemplateGroupExcelFile(file, allowManual, templateGroupDto);
return OperationResultDto.success();
} catch (ServiceException e) {
return OperationResultDto.error(e.getMessage());
......@@ -117,17 +119,20 @@ public class TemplateGroupController {
return OperationResultDto.error(ErrorMessage.SystemError);
}
@ResponseBody
@ApiOperation(value = "导入报表")
@RequestMapping(value = "importTemplateExcelFile", method = RequestMethod.POST)
public OperationResultDto importTemplateExcelFile(@RequestParam MultipartFile file,
@RequestParam Long templateGroupID,
@RequestParam String sheetList,
@RequestParam Boolean allowManual,
@RequestParam String tempFileName,
@RequestParam String reportType,
@RequestParam String filename) {
try {
templateGroupService.importTemplateExcelFile(file, templateGroupID, reportType, sheetList);
if(allowManual == null) allowManual = Boolean.FALSE;
templateGroupService.importTemplateExcelFile(file, allowManual, templateGroupID, reportType, sheetList);
return OperationResultDto.success();
} catch (ServiceException e) {
return OperationResultDto.error(e.getMessage());
......
......@@ -15,6 +15,7 @@ import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.POIUtil;
import pwc.taxtech.atms.common.message.ErrorMessage;
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.dao.CellTemplateConfigDao;
import pwc.taxtech.atms.dao.CellTemplateConfigMapper;
......@@ -184,7 +185,7 @@ public class TemplateGroupServiceImpl extends AbstractService {
}
@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();
if (CollectionUtils.isEmpty(sheetNameList)) {
throw new ServiceException(ErrorMessage.NoSelectSheet);
......@@ -269,13 +270,27 @@ public class TemplateGroupServiceImpl extends AbstractService {
config.setId(distributedIdService.nextId());
config.setCellTemplateId(cellTemplate.getId());
config.setReportTemplateId(template.getId());
config.setDataSourceType(1);//todo 枚举
config.setDataSourceType(CellDataSourceType.Formula.getCode());//todo 枚举
config.setFormula(POIUtil.getCellFormulaString(cell));
// config.setFormula(cell.getCellFormula());
config.setFormulaDataSource("报表数据"); //todo KV相关
config.setUpdateTime(now);
config.setUpdateBy(authUserHelper.getCurrentUserId());
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();
pds.setAmount(BigDecimal.ZERO);
pds.setUpdateBy("Admin");
......@@ -310,7 +325,7 @@ public class TemplateGroupServiceImpl extends AbstractService {
}
@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) {
throw new ServiceException(ErrorMessage.NoFile);
}
......@@ -388,6 +403,19 @@ public class TemplateGroupServiceImpl extends AbstractService {
config.setUpdateTime(now);
config.setUpdateBy(authUserHelper.getCurrentUserId());
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();
pds.setAmount(BigDecimal.ZERO);
pds.setUpdateBy("Admin");
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import javafx.geometry.Orientation;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
......@@ -100,9 +101,9 @@ public class OutputInvoiceServiceImpl {
return pageInfo;
}
public OperationResultDto<List<OutputVATInvoiceInfoDto>> getExportOutputInvoiceList(QueryOutputDto queryDto) {
public OperationResultDto<List<OutputVATInvoiceInfoDto>> getExportOutputInvoiceList(QueryOutputDto queryDto, String projectId) {
OperationResultDto<List<OutputVATInvoiceInfoDto>> result = new OperationResultDto<>();
List<OutputVATInvoiceInfoDto> finalList = getQueryList(queryDto);
List<OutputVATInvoiceInfoDto> finalList = getQueryList(queryDto, projectId);
finalList = getOutputDetailInfoList(finalList);
result.setData(finalList);
result.setResult(true);
......@@ -256,9 +257,16 @@ public class OutputInvoiceServiceImpl {
// 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);
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());
x.setPeriodId(CAL.get(Calendar.MONTH) + 1);
});
......
......@@ -71,7 +71,7 @@ controller('editTemplategroupModalController', ['$scope', '$log', '$translate',
Upload.upload({
url: thisConstant.uploadUrl,
data: {
allowManual: $('#allowManual').is(':checked'),
filename: $scope.editModel.file.name,
tempFileName: tempFileName,
},
......@@ -264,6 +264,7 @@ controller('editTemplategroupModalController', ['$scope', '$log', '$translate',
Upload.upload({
url: thisConstant.importTemplateExcelFile,
data: {
allowManual: $('#allowManual').is(':checked'),
jsonModel: json,
filename: $scope.editModel.file.name,
tempFileName: tempFileName
......
......@@ -28,6 +28,10 @@
<div id={{::editModel.sheetSelectDxID}}></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>
</div>
<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