Commit 1904bd2a authored by kevin's avatar kevin

#

parent 0457636b
...@@ -16,6 +16,7 @@ import pwc.taxtech.atms.dto.vatdto.*; ...@@ -16,6 +16,7 @@ import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.entity.OrganizationExample; import pwc.taxtech.atms.entity.OrganizationExample;
import pwc.taxtech.atms.entity.Project; import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.entity.ProjectExample; import pwc.taxtech.atms.entity.ProjectExample;
import pwc.taxtech.atms.service.impl.BaseService;
import pwc.taxtech.atms.service.impl.DataImportService; import pwc.taxtech.atms.service.impl.DataImportService;
import pwc.taxtech.atms.vat.dao.PwcReportAttachMapper; import pwc.taxtech.atms.vat.dao.PwcReportAttachMapper;
import pwc.taxtech.atms.vat.entity.*; import pwc.taxtech.atms.vat.entity.*;
...@@ -90,11 +91,11 @@ public class ReportController { ...@@ -90,11 +91,11 @@ public class ReportController {
@RequestMapping(value = "reportEbitData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "reportEbitData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<ReportDataDto> reportEbitData(@RequestBody RequestParameterDto requestParameterDto) { public OperationResultDto<ReportDataDto> reportEbitData(@RequestBody RequestParameterDto requestParameterDto) {
/*OperationResultDto resultDto = new OperationResultDto(); /*OperationResultDto resultDto = new OperationResultDto();
*//* if (requestParameterDto.getProjectId() == null || requestParameterDto.getReportId() == null) { *//* if (requestParameterDto.getProjectId() == null || requestParameterDto.getReportId() == null) {
resultDto.setResult(false); resultDto.setResult(false);
return resultDto; return resultDto;
}*/ }*/
operationResultDto = reportService.getCellData(Long.parseLong(requestParameterDto.getReportId()), requestParameterDto.getOrgId(),requestParameterDto.getPeriod()); operationResultDto = reportService.getCellData(Long.parseLong(requestParameterDto.getReportId()), requestParameterDto.getOrgId(), requestParameterDto.getPeriod());
return operationResultDto; return operationResultDto;
} }
...@@ -124,10 +125,6 @@ public class ReportController { ...@@ -124,10 +125,6 @@ public class ReportController {
} }
@RequestMapping(value = "getCellTemplateConfig/{reportTemplateId}/{period}/{rowIndex}/{columnIndex}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "getCellTemplateConfig/{reportTemplateId}/{period}/{rowIndex}/{columnIndex}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<PeriodCellTemplateConfig> getCellTemplateConfig(@PathVariable Long reportTemplateId, public OperationResultDto<PeriodCellTemplateConfig> getCellTemplateConfig(@PathVariable Long reportTemplateId,
@PathVariable Integer period, @PathVariable Integer period,
...@@ -213,16 +210,18 @@ public class ReportController { ...@@ -213,16 +210,18 @@ public class ReportController {
@Autowired @Autowired
private PwcReportAttachMapper pwcReportAttachMapper; private PwcReportAttachMapper pwcReportAttachMapper;
@RequestMapping("") @RequestMapping("")
public OperationResultDto downLoadAttach(Long id){ public OperationResultDto downLoadAttach(Long id) {
OperationResultDto operationResultDto = new OperationResultDto(); OperationResultDto operationResultDto = new OperationResultDto();
PwcReportAttachExample example = new PwcReportAttachExample(); PwcReportAttachExample example = new PwcReportAttachExample();
PwcReportAttachExample.Criteria criteria = example.createCriteria(); PwcReportAttachExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(id); criteria.andIdEqualTo(id);
if(FileUploadUtil.downLoad(pwcReportAttachMapper.selectByExample(example).get(0).getFileUrl()) == true){ if (FileUploadUtil.downLoad(pwcReportAttachMapper.selectByExample(example).get(0).getFileUrl()) == true) {
return operationResultDto.success(); return operationResultDto.success();
}; }
operationResultDto.setResultMsg("附件导出失败"); ;
operationResultDto.setResultMsg("附件导出失败");
return operationResultDto; return operationResultDto;
} }
...@@ -239,6 +238,7 @@ public class ReportController { ...@@ -239,6 +238,7 @@ public class ReportController {
/** /**
* 获取模板的report,通过reportid可以获取模板数据 * 获取模板的report,通过reportid可以获取模板数据
*
* @param templateId * @param templateId
* @param period * @param period
* @param orgId * @param orgId
...@@ -256,38 +256,41 @@ public class ReportController { ...@@ -256,38 +256,41 @@ public class ReportController {
} }
@RequestMapping(value = "saveAndRefresh", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "saveAndRefresh", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<EbitDataDto> saveAndRefresh(@RequestParam(value ="orgId") String orgId, @RequestParam(value ="period") Integer period, @RequestParam(value = "specialConsiderations", defaultValue = "0") Integer specialConsiderations, @RequestParam(value = "ebitRate", defaultValue = "1") String ebitRate) { public OperationResultDto saveAndRefresh(@RequestParam(value = "orgId") String orgId,
OperationResultDto operationResultDto = new OperationResultDto(); @RequestParam(value = "period") Integer period,
operationResultDto.setData(reportService.loadEbitData(orgId, period, specialConsiderations, ebitRate)); @RequestParam(value = "specialConsiderations", defaultValue = "0") Integer specialConsiderations,
reportService.saveDatasource(orgId, period, specialConsiderations, ebitRate, operationResultDto); @RequestParam(value = "ebitRate", defaultValue = "1") String ebitRate,
return operationResultDto; @RequestParam(value = "reportId") Long reportId) {
OperationResultDto operationResultDto<EbitCell> = new OperationResultDto();
try{
operationResultDto.setData(reportService.loadEbitData(orgId, period, specialConsiderations, ebitRate));
new Thread(()->{
reportService.saveDatasource(orgId, period, specialConsiderations, ebitRate, operationResultDto, BaseService._cellData);
}).start();
}catch (Exception e){
return operationResultDto.error();
}
return operationResultDto.success();
} }
/** /**
*批量导出利润表 * 批量导出利润表
*/ */
@RequestMapping("manyExport") @RequestMapping("manyExport")
public OperationResultDto manyExport(@RequestBody RequestParameterDto requestParameterDto){ public OperationResultDto manyExport(@RequestBody RequestParameterDto requestParameterDto) {
OperationResultDto operationResultDto = new OperationResultDto(); OperationResultDto operationResultDto = new OperationResultDto();
operationResultDto.setResult(null); operationResultDto.setResult(null);
return operationResultDto; return operationResultDto;
} }
/** /**
* 将spread序列化字符串保存到数据库 * 将spread序列化字符串保存到数据库
*/ */
@RequestMapping("spreadToDb") @RequestMapping("spreadToDb")
public OperationResultDto spreadToDb(@RequestBody RequestParameterDto.EbitParam ebitParam){ public OperationResultDto spreadToDb(@RequestBody RequestParameterDto.EbitParam ebitParam) {
OperationResultDto operationResultDto = new OperationResultDto(); return reportService.spreadToDb(ebitParam);
try{
reportService.spreadToDb(ebitParam);
return operationResultDto.success();
}catch (Exception e){
e.printStackTrace();
return operationResultDto.error();
}
} }
} }
\ No newline at end of file
...@@ -24,4 +24,6 @@ public class Exceptions { ...@@ -24,4 +24,6 @@ public class Exceptions {
public static final ApiException NOT_FOUND_INSTANCE_EXCEPTION = new NotFoundException("not found instance"); public static final ApiException NOT_FOUND_INSTANCE_EXCEPTION = new NotFoundException("not found instance");
public static final FormulaException parameterError = new FormulaException("formula parameter is error"); public static final FormulaException parameterError = new FormulaException("formula parameter is error");
public static final FormulaException IMPORT_TEMPLATE_HEADER_ERROR = new FormulaException("导入模板不匹配"); public static final FormulaException IMPORT_TEMPLATE_HEADER_ERROR = new FormulaException("导入模板不匹配");
} }
...@@ -8,8 +8,13 @@ import pwc.taxtech.atms.common.AtmsApiSettings; ...@@ -8,8 +8,13 @@ import pwc.taxtech.atms.common.AtmsApiSettings;
import pwc.taxtech.atms.common.AuthUserHelper; import pwc.taxtech.atms.common.AuthUserHelper;
import pwc.taxtech.atms.common.ResponseMessageBuilder; import pwc.taxtech.atms.common.ResponseMessageBuilder;
import pwc.taxtech.atms.common.util.BeanUtil; import pwc.taxtech.atms.common.util.BeanUtil;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.CellDataDto;
import pwc.taxtech.atms.security.dd.DtsTokenService; import pwc.taxtech.atms.security.dd.DtsTokenService;
import java.util.ArrayList;
import java.util.List;
public class BaseService { public class BaseService {
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); protected final Logger logger = LoggerFactory.getLogger(this.getClass());
...@@ -31,5 +36,7 @@ public class BaseService { ...@@ -31,5 +36,7 @@ public class BaseService {
protected ResponseMessageBuilder responseMessageBuilder; protected ResponseMessageBuilder responseMessageBuilder;
@Autowired @Autowired
protected DtsTokenService dtsTokenService; protected DtsTokenService dtsTokenService;
public OperationResultDto operationResultDto;
public static List<CellDataDto> _cellData = new ArrayList<>();
} }
...@@ -1498,6 +1498,8 @@ public class ReportServiceImpl extends BaseService { ...@@ -1498,6 +1498,8 @@ public class ReportServiceImpl extends BaseService {
} }
}); });
dataDto.setCellData(cellDataDtoList); dataDto.setCellData(cellDataDtoList);
//将cellData复制给静态变量
_cellData = cellDataDtoList;
resultDto.setData(dataDto); resultDto.setData(dataDto);
resultDto.setResult(true); resultDto.setResult(true);
} catch (Exception ex) { } catch (Exception ex) {
...@@ -2252,17 +2254,32 @@ public class ReportServiceImpl extends BaseService { ...@@ -2252,17 +2254,32 @@ public class ReportServiceImpl extends BaseService {
} }
public void saveDatasource(String orgId, Integer period, Integer specialConsiderations, String ebitRate, OperationResultDto<ReportDataDto> operationResultDto) { @Transactional
public void saveDatasource(String orgId, Integer period, Integer specialConsiderations, String ebitRate,
OperationResultDto<ReportDataDto> operationResultDto,
List<CellDataDto> cellDataList) {
EbitCellDataExample example = null;
List<EbitCellData> ebitCellDataList = new ArrayList<>();
for (int i = 37; i <= 43; i++) { for (int i = 37; i <= 43; i++) {
EbitCellDataExample example = new EbitCellDataExample(); example = new EbitCellDataExample();
EbitCellDataExample.Criteria criteria = example.createCriteria(); EbitCellDataExample.Criteria criteria = example.createCriteria();
criteria.andOrganizationIdEqualTo(orgId); criteria.andOrganizationIdEqualTo(orgId).andPeriodEqualTo(period).andColEqualTo(1).andRowEqualTo(i);
criteria.andPeriodEqualTo(period);
criteria.andColEqualTo(1);
criteria.andRowEqualTo(i);
List<EbitCellData> ebitCellData = ebitCellDataMapper.selectByExample(example); List<EbitCellData> ebitCellData = ebitCellDataMapper.selectByExample(example);
if (ebitCellData.size() == 0) { if (ebitCellData.size() == 0) {
ebitCellDataMapper.insert(switchMeth(i, new EbitCellData(), operationResultDto, specialConsiderations, ebitRate, orgId, period)); for (CellDataDto cellDataDto : cellDataList) {
EbitCellData ebitCellData1 = new EbitCellData();
ebitCellData1.setId(idService.nextId());
ebitCellData1.setOrganizationId(orgId);
ebitCellData1.setPeriod(period);
ebitCellData1.setCreateTime(new Date());
ebitCellData1.setCol(cellDataDto.getColumnIndex());
ebitCellData1.setRow(cellDataDto.getRowIndex());
ebitCellData1.setData(cellDataDto.getCellValue());
ebitCellDataList.add(ebitCellData1);
}
ebitCellDataList.add(switchMeth(i, new EbitCellData(), operationResultDto, specialConsiderations, ebitRate, orgId, period));
ebitCellDataMapper.insertBatch(ebitCellDataList);
} else { } else {
ebitCellDataMapper.updateByExampleSelective(switchMeth(i, new EbitCellData(), operationResultDto, specialConsiderations, ebitRate, orgId, period), example); ebitCellDataMapper.updateByExampleSelective(switchMeth(i, new EbitCellData(), operationResultDto, specialConsiderations, ebitRate, orgId, period), example);
} }
...@@ -2299,10 +2316,38 @@ public class ReportServiceImpl extends BaseService { ...@@ -2299,10 +2316,38 @@ public class ReportServiceImpl extends BaseService {
return ebitCellData1; return ebitCellData1;
} }
public void spreadToDb(RequestParameterDto.EbitParam ebitParam) {
EbitSpreadDataExample example = new EbitSpreadDataExample(); @Autowired
EbitSpreadDataExample.Criteria criteria = example.createCriteria(); private EbitSpreadDataMapper ebitSpreadDataMapper;
EbitSpreadDataExample.Criteria criteria1 = criteria.andOrganizationIdEqualTo(ebitParam.getOrgId()).andPeriodEqualTo(ebitParam.getPeriod());
public OperationResultDto spreadToDb(RequestParameterDto.EbitParam ebitParam) {
try {
EbitSpreadDataExample example = new EbitSpreadDataExample();
EbitSpreadDataExample.Criteria criteria = example.createCriteria();
EbitSpreadDataExample.Criteria criteria1 = criteria.andOrganizationIdEqualTo(ebitParam.getOrgId()).andPeriodEqualTo(ebitParam.getPeriod());
List<EbitSpreadData> ebitSpreadData = ebitSpreadDataMapper.selectByExample(example);
if (ebitSpreadData.size() != 0) {
EbitSpreadData ebitSpreadData1 = new EbitSpreadData();
ebitSpreadData1.setSpreadJsonString(ebitParam.getJsonString().getBytes());
ebitSpreadData1.setOrganizationId(ebitParam.getOrgId());
ebitSpreadData1.setPeriod(ebitParam.getPeriod());
ebitSpreadData1.setUpdateTime(new Date());
ebitSpreadDataMapper.updateByExample(ebitSpreadData1, example);
} else {
EbitSpreadData ebitSpreadData1 = new EbitSpreadData();
ebitSpreadData1.setSpreadJsonString(ebitParam.getJsonString().getBytes());
ebitSpreadData1.setOrganizationId(ebitParam.getOrgId());
ebitSpreadData1.setPeriod(ebitParam.getPeriod());
ebitSpreadData1.setCreateTime(new Date());
ebitSpreadDataMapper.insert(ebitSpreadData1);
}
} catch (Exception e) {
e.printStackTrace();
operationResultDto.error();
operationResultDto.setResultMsg("spread【json序列化字符串】保存失败");
return operationResultDto;
}
return operationResultDto.success();
} }
} }
...@@ -110,7 +110,20 @@ ...@@ -110,7 +110,20 @@
}); });
}; };
var initSpreadExcel = function (reportSpread) { //初始化spread
vat _init = function(){
return templateService.getPeriodTemplateJsonByOrg(templateId, scope.relation.period, scope.relation.orgId).then(function (reportSpread) {
if (!_.isEmpty(reportSpread)) {
initSpreadExcel(reportSpread, true).then(function (spread) {
/* return locateCell(spread, true);*/
});
}
}, function (data) {
$log.info(data);
});
}
var initSpreadExcel = function (reportSpread, noCycle) {
var spread = getSpreadControl(); var spread = getSpreadControl();
spread.suspendPaint(); spread.suspendPaint();
...@@ -152,10 +165,13 @@ ...@@ -152,10 +165,13 @@
} }
scope.spread = spread; scope.spread = spread;
addEbitRow(sheet) addEbitRow(sheet)
if (scope.templateId && scope.reportSource) { if (scope.templateId && scope.reportSource&& !noCycle) {
setData(true); setData(true);
} }
spread.resumePaint(); spread.resumePaint();
return $q.when(spread); return $q.when(spread);
}; };
...@@ -279,7 +295,7 @@ ...@@ -279,7 +295,7 @@
scope.spread.suspendPaint(); scope.spread.suspendPaint();
scope.relation.loadEbitCell(sheet); scope.relation.loadEbitCell(sheet);
if (scope.reportSource.length == 0 && scope.relation.emptyData && scope.relation.emptyData == true) { if (scope.reportSource.length == 0 && scope.relation.emptyData && scope.relation.emptyData == true) {
loadSheet(sheet, true);///如果没有数据,需要重新加载 _init(scope.templateId, true);///如果没有数据,需要重新加载
setEditable(scope.spread); setEditable(scope.spread);
return; return;
} }
...@@ -309,6 +325,8 @@ ...@@ -309,6 +325,8 @@
} }
setEditable(scope.spread); setEditable(scope.spread);
scope.spread.resumePaint(); scope.spread.resumePaint();
scope.relation.saveToDbFlag = Math.random();
} }
}; };
(function initialize() { (function initialize() {
......
...@@ -2919,8 +2919,11 @@ ...@@ -2919,8 +2919,11 @@
var specialConsiderations = sheet.getCell(38,3).value(); var specialConsiderations = sheet.getCell(38,3).value();
var ebitRate = sheet.getCell(40,3).value(); var ebitRate = sheet.getCell(40,3).value();
vatReportService.saveAndRefresh($scope.relation.orgId, $scope.relation.period, specialConsiderations, ebitRate).success(function(res){ vatReportService.saveAndRefresh($scope.relation.orgId, $scope.relation.period, specialConsiderations, ebitRate).success(function(res){
if(res.data){ if(res.result){
$scope.relation.data = res.data; $scope.relation.data = res.data;
$timeout(function(){//
spreadTODb();
}, 7000);
} }
}).error(function(error){ }).error(function(error){
......
...@@ -14,11 +14,11 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt ...@@ -14,11 +14,11 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
//} //}
}; };
var getPeriodTemplateJson = function (templateId,period,projectId) { var getPeriodTemplateJson = function (templateId,period,projectId) {
return getJsonFromExcelForPeriod(templateId,period,projectId); return getJsonFromExcelForPeriod(templateId,period,projectId, false);
}; };
var getPeriodTemplateJsonByOrg = function (templateId,period,orgId) { var getPeriodTemplateJsonByOrg = function (templateId,period,orgId) {
return getJsonFromExcelForPeriod(templateId,period,orgId); return getJsonFromExcelForPeriod(templateId,period,orgId, true);
}; };
var getPeriodTemplateJsonByInit = function (templateId,period,orgId) { var getPeriodTemplateJsonByInit = function (templateId,period,orgId) {
...@@ -115,11 +115,15 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt ...@@ -115,11 +115,15 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
}; };
var getJsonFromExcelForPeriod = function (templateID,period,projectId, init) { var getJsonFromExcelForPeriod = function (templateID,period,projectIdOrOrgId, ebit) {
var deferred = $q.defer(); var deferred = $q.defer();
var promise = deferred.promise; var promise = deferred.promise;
var url = null; var url = loginContext.apiHost + constant.webapi.prefix + '/template/getPeriodTemplateJson?templateId=' + templateID+"&period="+period;
url = loginContext.apiHost + constant.webapi.prefix + '/template/getPeriodTemplateJson?templateId=' + templateID+"&period="+period+"&orgId="+projectId; if(ebit){
url += "&orgId="+projectIdOrOrgId
}else{
url += "&projectId=" +projectIdOrOrgId;
}
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('POST', url, true); // 也可以使用POST方式,根据接口 xhr.open('POST', url, true); // 也可以使用POST方式,根据接口
xhr.responseType = "blob"; // 返回类型blob xhr.responseType = "blob"; // 返回类型blob
......
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