Commit 1f17ba7b authored by Memorydoc's avatar Memorydoc

#

parent d17a613b
package pwc.taxtech.atms.common.pwc.Exception;
/**
* @version 1.0
* @program: atms
* @description: Controller统一处理
* @author: Kevin
* @create: 2019-04-22 19:22
**/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.ui.Model;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import pwc.taxtech.atms.dto.OperationResultDto;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 异常统一处理
* @author lhzhian
* @date 2016年4月28日
*/
@ControllerAdvice
class GloalHander{
private final static String ERROR_PAGE = "系统错误";
private static Logger logger = LoggerFactory.getLogger(GloalHander.class);
@ExceptionHandler(PwcException.class)
@ResponseBody
public OperationResultDto handle(Exception e){
OperationResultDto operationResultDto = new OperationResultDto();
/* ModelAndView mv = new ModelAndView();
mv.addObject("message", e.getMessage());
mv.setViewName(ERROR_PAGE);*/
operationResultDto.error(e.getMessage());
return operationResultDto;
}
@ExceptionHandler(PageException.class)
@ResponseBody
public ModelAndView handSql(Exception ex){
logger.info("-->to error view " + ex.getMessage());
ModelAndView mv = new ModelAndView();
if(ex == null){
mv.addObject("message",ERROR_PAGE);
}
mv.setViewName("error.html");
return mv;
}
@ModelAttribute
//应用到所有@RequestMapping注解方法
//此处将键值对添加到全局,注解了@RequestMapping的方法都可以获得此键值对
public void addUser(Model model) {
//model.addAttribute("pwc.message", "sizegang");
}
@InitBinder
//应用到所有@RequestMapping注解方法,在其执行之前初始化数据绑定器
//用来设置WebDataBinder,用于自动绑定前台请求参数到Model中。
public void initBinder(WebDataBinder binder) {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
CustomDateEditor orderDateEditor = new CustomDateEditor(dateFormat, true);
binder.registerCustomEditor(Date.class, orderDateEditor);
}
}
\ No newline at end of file
package pwc.taxtech.atms.common.pwc.Exception;
/**
* @version 1.0
* @program: atms
* @description: 跳转页面异常
* @author: Kevin
* @create: 2019-04-22 19:33
**/
public class PageException extends Exception {
private static final long serialVersionUID = 1L;
//业务类型
private String bizType;
//业务代码
private int bizCode;
//错误信息
private String message;
public PageException(String bizType, int bizCode, String message){
super(message);
this.bizType = bizType;
this.bizCode = bizCode;
this.message = message;
}
public PageException(String message){
super(message);
this.bizType = "";
this.bizCode = -1;
this.message = message;
}
public PageException(String bizType, String message){
super(message);
this.bizType = bizType;
this.bizCode = -1;
this.message = message;
}
public PageException(int bizCode, String message){
super(message);
this.bizType = "";
this.bizCode = bizCode;
this.message = message;
}
public String getBizType() {
return bizType;
}
public void setBizType(String bizType) {
this.bizType = bizType;
}
public int getBizCode() {
return bizCode;
}
public void setBizCode(int bizCode) {
this.bizCode = bizCode;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package pwc.taxtech.atms.common.pwc.Exception;
/**
* @version 1.0
* @program: atms
* @description: 自定义运行时异常
* @author: Kevin
* @create: 2019-04-22 19:26
**/
public class PwcException extends Exception {
private static final long serialVersionUID = 1L;
//业务类型
private String bizType;
//业务代码
private int bizCode;
//错误信息
private String message;
public PwcException(String bizType, int bizCode, String message){
super(message);
this.bizType = bizType;
this.bizCode = bizCode;
this.message = message;
}
public PwcException(String message){
super(message);
this.bizType = "";
this.bizCode = -1;
this.message = message;
}
public PwcException(String bizType, String message){
super(message);
this.bizType = bizType;
this.bizCode = -1;
this.message = message;
}
public PwcException(int bizCode, String message){
super(message);
this.bizType = "";
this.bizCode = bizCode;
this.message = message;
}
public String getBizType() {
return bizType;
}
public void setBizType(String bizType) {
this.bizType = bizType;
}
public int getBizCode() {
return bizCode;
}
public void setBizCode(int bizCode) {
this.bizCode = bizCode;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
......@@ -3,15 +3,14 @@ package pwc.taxtech.atms.controller;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.controller.BaseController;
import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.analysis.AnalysisDomesticlParam;
import pwc.taxtech.atms.dto.analysis.AnalysisInternationlParam;
import pwc.taxtech.atms.dto.vatdto.CertifiedInvoicesListParam;
import pwc.taxtech.atms.exception.ServiceException;
import pwc.taxtech.atms.service.impl.AnalysisServiceImpl;
......@@ -79,7 +78,7 @@ public class AnalysisController extends BaseController {
@ResponseBody
@RequestMapping(value = "DomesitcExcelFile", method = RequestMethod.POST)
public OperationResultDto importDomesitcExcelFile(@RequestParam MultipartFile file, @RequestParam String period, @RequestParam Integer type) {
public OperationResultDto importDomesitcExcelFile(@RequestParam MultipartFile file, @RequestParam String period, @RequestParam Integer type, Model model) {
try {
String valMsg = valParameter(file,period,type);
if(StringUtils.isNotEmpty(valMsg)){
......@@ -87,9 +86,7 @@ public class AnalysisController extends BaseController {
}
return analysisServiceImpl.importDomesitcExcelFile(file,period, type);
} catch (ServiceException e) {
String message = e.getMessage();
String[] split = message.split(":");
return OperationResultDto.error(split[1]);
return OperationResultDto.error(e.getMessage());
} catch (Exception e) {
logger.error("importDomesitcExcelFile error.", e);
return OperationResultDto.error(ErrorMessage.SystemError);
......
......@@ -362,17 +362,16 @@ public class ReportController {
* 批量导出利润表
*/
@RequestMapping("manyExport")
public ResponseEntity manyExport(@RequestBody RequestParameterDto requestParameterDto, HttpServletResponse response, HttpServletRequest request) {
public OperationResultDto manyExport(@RequestBody RequestParameterDto requestParameterDto, HttpServletResponse response, HttpServletRequest request) {
OperationResultDto operationResultDto = new OperationResultDto();
try {
//taskExecutor.execute(new EbitBatchExportJob( reportService,requestParameterDto, request, response));
reportService.manyExport(requestParameterDto, request, response);
} catch (Exception e) {
e.printStackTrace();
operationResultDto.error(e.getMessage());
return new ResponseEntity(HttpStatus.NO_CONTENT);
return operationResultDto.error(e.getMessage());
}
return new ResponseEntity(HttpStatus.OK);
return OperationResultDto.success();
}
@Autowired
......
......@@ -289,7 +289,7 @@ public class AnalysisServiceImpl extends BaseService {
} catch (Exception e) {
throw new ServiceException(e);
}
return notMatchOrg.append(orgNotList + "机构匹配失败");
return notMatchOrg.append(orgNotList + "行, 机构匹配失败");
}
private AnalysisTax getAnalysisTax(Integer period, Sheet sheet, int k, int j, Organization org) {
......
......@@ -26,6 +26,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.POIUtil;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.common.pwc.Exception.PwcException;
import pwc.taxtech.atms.common.util.*;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.*;
......@@ -232,7 +233,8 @@ public class ReportServiceImpl extends BaseService {
return operationResult;
}
private void clearPeriodData(String projectId, Integer period, boolean isMergeManualData) {
private void clearPeriodData(String projectId, Integer period, List<Long> templateIds, boolean isMergeManualData) {
if (templateIds.isEmpty()) templateIds.add(Long.MAX_VALUE);
PeriodFormulaBlockExample periodFormulaBlockExample = new PeriodFormulaBlockExample();
periodFormulaBlockExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
periodFormulaBlockMapper.deleteByExample(periodFormulaBlockExample);
......@@ -242,15 +244,15 @@ public class ReportServiceImpl extends BaseService {
periodTaxRuleSettingMapper.deleteByExample(periodTaxRuleSettingExample);
PeriodCellTemplateExample periodCellTemplateExample = new PeriodCellTemplateExample();
periodCellTemplateExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
periodCellTemplateExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period).andReportTemplateIdNotIn(templateIds);
periodCellTemplateMapper.deleteByExample(periodCellTemplateExample);
PeriodCellTemplateConfigExample periodCellTemplateConfigExample = new PeriodCellTemplateConfigExample();
periodCellTemplateConfigExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
periodCellTemplateConfigExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period).andReportTemplateIdNotIn(templateIds);
periodCellTemplateConfigMapper.deleteByExample(periodCellTemplateConfigExample);
PeriodTemplateExample periodTemplateExample = new PeriodTemplateExample();
periodTemplateExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
periodTemplateExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period).andTemplateIdNotIn(templateIds);
periodTemplateMapper.deleteByExample(periodTemplateExample);
PeriodTaxPayerReportRuleExample periodTaxPayerReportRuleExample = new PeriodTaxPayerReportRuleExample();
......@@ -304,13 +306,12 @@ public class ReportServiceImpl extends BaseService {
}
private void updateConfig(String projectId, Integer period, Boolean isMergeManualData, List<Template> templates, PeriodJob job) {
//财务报表不删除,这个逻辑用不到,先注释掉
// List<Long> exceptTemplateIds = templateMapper.getIdsForExceptTemplate();
List<Long> exceptTemplateIds = templateMapper.getIdsForExceptTemplate();
//根据收入类型映射生成开票记录关联数据
assembleInvoiceRecord(projectId, period, isMergeManualData);
//生成trial_balance_final数据
assembleTrialBalanceFinal(projectId, period);
clearPeriodData(projectId, period, isMergeManualData);
clearPeriodData(projectId, period, exceptTemplateIds, isMergeManualData);
copyTemplateAndConfigFromAdmin(projectId, templates, period);
setStatus(job, STATUS_END);
periodJobMapper.updateByPrimaryKey(job);
......@@ -374,10 +375,8 @@ public class ReportServiceImpl extends BaseService {
destRecord.setRevenueCofId(map.get(mapping.getContent()));
InvoiceRecordExample recordExample = new InvoiceRecordExample();
recordExample.createCriteria().andProjectIdEqualTo(projectId)
.andOrganizationIdEqualTo(mapping.getOrgId()).andBillingContentEqualTo(mapping.getContent())
.andTaxRateEqualTo(mapping.getTaxRate())
.andDepartmentEqualTo(mapping.getOuName())
.andPeriodEqualTo(Integer.valueOf(queryDate.replace("-", "")));
.andOrganizationIdEqualTo(mapping.getOrgId()).andBillingContentEqualTo(mapping.getContent()).
andPeriodEqualTo(Integer.valueOf(queryDate.replace("-", "")));
invoiceRecordMapper.updateByExampleSelective(destRecord, recordExample);
}
}
......@@ -878,8 +877,8 @@ public class ReportServiceImpl extends BaseService {
row.getCell(TaxesCalculateReportEnum.Column.Column_4.getIndex()).setCellValue(0.00);
} else if (1 == config.getAccountType()) {//科目
row.getCell(TaxesCalculateReportEnum.Column.Column_4.getIndex()).setCellValue(
"DFFS(\"" + config.getTbSegment3() + "\"," + project.getYear() + "," + period + ",3,\"" + config.getTbSegment5() + "\",\"" + config.getTbSegment6() + "\")-"
+ "JFFS(\"" + config.getTbSegment3() + "\"," + project.getYear() + "," + period + ",3,\"" + config.getTbSegment5() + "\",\"" + config.getTbSegment6() + "\")");
"DFFS(\"" + config.getTbSegment3() + "\"," + project.getYear() + "," + period + ",1,\"" + config.getTbSegment5() + "\",\"" + config.getTbSegment6() + "\")-"
+ "JFFS(\"" + config.getTbSegment3() + "\"," + project.getYear() + "," + period + ",1,\"" + config.getTbSegment5() + "\",\"" + config.getTbSegment6() + "\")");
} else if (2 == config.getAccountType()) {//手工输入
} else {
......@@ -897,9 +896,9 @@ public class ReportServiceImpl extends BaseService {
} else if (3 == config.getTaxBase()) {//手工录入
} else if (4 == config.getTaxBase()) {//借方发生额
row.getCell(TaxesCalculateReportEnum.Column.Column_9.getIndex()).setCellValue("JFFS(\"" + config.getBaseDrCode() + "\"," + project.getYear() + "," + period + ",3,,)");
row.getCell(TaxesCalculateReportEnum.Column.Column_9.getIndex()).setCellValue("JFFS(\"" + config.getBaseDrCode() + "\"," + project.getYear() + "," + period + ",1,,)");
} else if (5 == config.getTaxBase()) {//贷方发生额
row.getCell(TaxesCalculateReportEnum.Column.Column_9.getIndex()).setCellValue("DFFS(\"" + config.getBaseCrCode() + "\"," + project.getYear() + "," + period + ",3,,)");
row.getCell(TaxesCalculateReportEnum.Column.Column_9.getIndex()).setCellValue("DFFS(\"" + config.getBaseCrCode() + "\"," + project.getYear() + "," + period + ",1,,)");
} else {
row.getCell(TaxesCalculateReportEnum.Column.Column_9.getIndex()).setCellValue("");
}
......@@ -935,7 +934,7 @@ public class ReportServiceImpl extends BaseService {
sumStr += cellNum + ",";
}
sumStr += "\")";
// sumStr = sumStr.replace(",\")", "\")");
sumStr = sumStr.replace(",\")", "\")");
sumRow.getCell(entry.getKey()).setCellValue(sumStr);
}
......@@ -2092,17 +2091,16 @@ public class ReportServiceImpl extends BaseService {
PeriodDataSource dataSourceModel = null;
if (dataSourceExtendDtos.size() > 0) {
dataSourceModel = dataSourceExtendDtos.get(0).getDataSource();
dataSourceModel= periodDataSourceMapper.selectByPrimaryKey(dataSourceModel.getId());
if (StringUtils.isBlank(data.getKeyinData()))
updateCellValueForDataSourceChange(dataSourceModel, data.getAmount());
originalAmount = dataSourceModel.getAmount() != null ? dataSourceModel.getAmount() : new BigDecimal("0");
dataSourceModel.setName(data.getName());
dataSourceModel.setDescription(data.getDescription());
dataSourceModel.setAmount(data.getAmount()==null?new BigDecimal(0):data.getAmount());
dataSourceModel.setAmount(data.getAmount());
dataSourceModel.setUpdateBy("Admin");
dataSourceModel.setKeyinData(data.getKeyinData());
dataSourceModel.setUpdateTime(new Date());
periodDataSourceMapper.updateByPrimaryKey(dataSourceModel);
periodDataSourceMapper.updateByPrimaryKeySelective(dataSourceModel);
} else {
dataSourceModel = new PeriodDataSource();
Long cellDataSourceId = distributedIdService.nextId();
......@@ -2659,7 +2657,7 @@ public class ReportServiceImpl extends BaseService {
templateExample.createCriteria().andCodeEqualTo(EBITTemplateCode).andNameEqualTo(EBITTemplateCode);//todo 这里是利润表模板的固定code,禁止重复
List<Template> templates1 = templateMapper.selectByExample(templateExample);
if (templates1.size() == 0)
throw new Exception("没有利润表模板,无法批量导出,请上传模板");
throw new PwcException("没有利润表模板,无法批量导出,请上传模板");
MyAsserts.assertNotEmpty(templates1, new NotFoundException());
Template template = templates1.get(0);
String templatePath = template.getPath();
......
......@@ -3144,7 +3144,6 @@
}
setTimeout(function(){spreadTODb();}, 1000)
}
$scope.singleExport = function () {
if ($scope.spread != undefined && $scope.spread) {
var excelIo = new GC.Spread.Excel.IO();
......@@ -3153,7 +3152,6 @@
fileName += '.xlsx';
}
var json = $scope.spread.toJSON();
// here is excel IO API
excelIo.save(json, function (blob) {
saveAs(blob, ($scope.relation.orgName != undefined ? $scope.relation.orgName : "" + $scope.relation.period) + fileName);
......@@ -3171,45 +3169,8 @@
templateId: $scope.templateId
}
/* $timeout(function () {
$('#busy-indicator-container').show();
var mainSpread = new GC.Spread.Sheets.Workbook(document.getElementById("report"), {sheetCount: 1});
mainSpread.isPaintSuspended(true);
mainSpread.sheets.pop();
for (var index = 0; index < $scope.spreads.length; index++) {
var currentSheet = $scope.spreads[index].getActiveSheet();
currentSheet.options.isProtected = false;
for (var rowIndex = 0; rowIndex < currentSheet.getRowCount(); rowIndex++) {
for (var columnIndex = 0; columnIndex < currentSheet.getColumnCount(); columnIndex++) {
var cellStyle = currentSheet.getActualStyle(rowIndex, columnIndex, GC.Spread.Sheets.SheetArea.viewport, true);
currentSheet.setStyle(rowIndex, columnIndex, cellStyle, GC.Spread.Sheets.SheetArea.viewport);
}
}
mainSpread.sheets.push(currentSheet);
}
var excelIo = new GC.Spread.Excel.IO();
excelIo.save(mainSpread.toJSON(), function (blob) {
if ('export' == $scope.evenType) {
saveAs(blob, vatSessionService.project.name + '-' + vatSessionService.month + '-纳税申报.xlsx');
$('#busy-indicator-container').hide();
}
}, function (e) {
alert(e);
});
$('.export-container').html('');
$('#export').html('');
$log.debug(mainSpread);
}, 500);*/
vatReportService.manyExport(param);
};
/* $scope.relation._orgId = null;
$scope.$watch('relation._orgId', function (n, o) {
if (n != undefined)
$scope.relation.orgId = n.pop();
});*/
var initCompanyList = function () {
var joinText = "";
......
......@@ -71,18 +71,10 @@
manyExport: function (param) {
var toParam = JSON.stringify(param);
return $http.post('/Report/manyExport', toParam, apiConfig.createVat({responseType: 'arraybuffer'})).then(function (response) {
if(response.status == 204){
SweetAlert.error("当前期间没有可导出的数据");
return
if(!response.result){
SweetAlert.error(response.resultMsg);
}
var a = document.createElement('a');
var data = new Blob([response.data], {type: response.headers('Content-Type')});
//FileSaver.saveAs(data, '利润表.zip');
a.href = URL.createObjectURL(data);
a.download = param.period + "-汇总利润表.xlsx";
a.click();
PWC.downloadCallBack(new Blob([response.data], {type: response.headers('Content-Type')}),null, null,param.period + "-汇总利润表.xlsx" );
});
}
,
......
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