Commit 1904bd2a authored by kevin's avatar kevin

#

parent 0457636b
......@@ -16,6 +16,7 @@ import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.entity.OrganizationExample;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.entity.ProjectExample;
import pwc.taxtech.atms.service.impl.BaseService;
import pwc.taxtech.atms.service.impl.DataImportService;
import pwc.taxtech.atms.vat.dao.PwcReportAttachMapper;
import pwc.taxtech.atms.vat.entity.*;
......@@ -90,11 +91,11 @@ public class ReportController {
@RequestMapping(value = "reportEbitData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<ReportDataDto> reportEbitData(@RequestBody RequestParameterDto requestParameterDto) {
/*OperationResultDto resultDto = new OperationResultDto();
*//* if (requestParameterDto.getProjectId() == null || requestParameterDto.getReportId() == null) {
*//* if (requestParameterDto.getProjectId() == null || requestParameterDto.getReportId() == null) {
resultDto.setResult(false);
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;
}
......@@ -124,10 +125,6 @@ public class ReportController {
}
@RequestMapping(value = "getCellTemplateConfig/{reportTemplateId}/{period}/{rowIndex}/{columnIndex}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<PeriodCellTemplateConfig> getCellTemplateConfig(@PathVariable Long reportTemplateId,
@PathVariable Integer period,
......@@ -213,16 +210,18 @@ public class ReportController {
@Autowired
private PwcReportAttachMapper pwcReportAttachMapper;
@RequestMapping("")
public OperationResultDto downLoadAttach(Long id){
public OperationResultDto downLoadAttach(Long id) {
OperationResultDto operationResultDto = new OperationResultDto();
PwcReportAttachExample example = new PwcReportAttachExample();
PwcReportAttachExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(id);
if(FileUploadUtil.downLoad(pwcReportAttachMapper.selectByExample(example).get(0).getFileUrl()) == true){
return operationResultDto.success();
};
operationResultDto.setResultMsg("附件导出失败");
if (FileUploadUtil.downLoad(pwcReportAttachMapper.selectByExample(example).get(0).getFileUrl()) == true) {
return operationResultDto.success();
}
;
operationResultDto.setResultMsg("附件导出失败");
return operationResultDto;
}
......@@ -239,6 +238,7 @@ public class ReportController {
/**
* 获取模板的report,通过reportid可以获取模板数据
*
* @param templateId
* @param period
* @param orgId
......@@ -256,38 +256,41 @@ public class ReportController {
}
@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) {
OperationResultDto operationResultDto = new OperationResultDto();
operationResultDto.setData(reportService.loadEbitData(orgId, period, specialConsiderations, ebitRate));
reportService.saveDatasource(orgId, period, specialConsiderations, ebitRate, operationResultDto);
return operationResultDto;
public OperationResultDto 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,
@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")
public OperationResultDto manyExport(@RequestBody RequestParameterDto requestParameterDto){
public OperationResultDto manyExport(@RequestBody RequestParameterDto requestParameterDto) {
OperationResultDto operationResultDto = new OperationResultDto();
operationResultDto.setResult(null);
return operationResultDto;
return operationResultDto;
}
/**
* 将spread序列化字符串保存到数据库
*/
@RequestMapping("spreadToDb")
public OperationResultDto spreadToDb(@RequestBody RequestParameterDto.EbitParam ebitParam){
OperationResultDto operationResultDto = new OperationResultDto();
try{
reportService.spreadToDb(ebitParam);
return operationResultDto.success();
}catch (Exception e){
e.printStackTrace();
return operationResultDto.error();
}
public OperationResultDto spreadToDb(@RequestBody RequestParameterDto.EbitParam ebitParam) {
return reportService.spreadToDb(ebitParam);
}
}
\ No newline at end of file
......@@ -24,4 +24,6 @@ public class Exceptions {
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 IMPORT_TEMPLATE_HEADER_ERROR = new FormulaException("导入模板不匹配");
}
......@@ -8,8 +8,13 @@ import pwc.taxtech.atms.common.AtmsApiSettings;
import pwc.taxtech.atms.common.AuthUserHelper;
import pwc.taxtech.atms.common.ResponseMessageBuilder;
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 java.util.ArrayList;
import java.util.List;
public class BaseService {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
......@@ -31,5 +36,7 @@ public class BaseService {
protected ResponseMessageBuilder responseMessageBuilder;
@Autowired
protected DtsTokenService dtsTokenService;
public OperationResultDto operationResultDto;
public static List<CellDataDto> _cellData = new ArrayList<>();
}
......@@ -1498,6 +1498,8 @@ public class ReportServiceImpl extends BaseService {
}
});
dataDto.setCellData(cellDataDtoList);
//将cellData复制给静态变量
_cellData = cellDataDtoList;
resultDto.setData(dataDto);
resultDto.setResult(true);
} catch (Exception ex) {
......@@ -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++) {
EbitCellDataExample example = new EbitCellDataExample();
example = new EbitCellDataExample();
EbitCellDataExample.Criteria criteria = example.createCriteria();
criteria.andOrganizationIdEqualTo(orgId);
criteria.andPeriodEqualTo(period);
criteria.andColEqualTo(1);
criteria.andRowEqualTo(i);
criteria.andOrganizationIdEqualTo(orgId).andPeriodEqualTo(period).andColEqualTo(1).andRowEqualTo(i);
List<EbitCellData> ebitCellData = ebitCellDataMapper.selectByExample(example);
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 {
ebitCellDataMapper.updateByExampleSelective(switchMeth(i, new EbitCellData(), operationResultDto, specialConsiderations, ebitRate, orgId, period), example);
}
......@@ -2299,10 +2316,38 @@ public class ReportServiceImpl extends BaseService {
return ebitCellData1;
}
public void spreadToDb(RequestParameterDto.EbitParam ebitParam) {
EbitSpreadDataExample example = new EbitSpreadDataExample();
EbitSpreadDataExample.Criteria criteria = example.createCriteria();
EbitSpreadDataExample.Criteria criteria1 = criteria.andOrganizationIdEqualTo(ebitParam.getOrgId()).andPeriodEqualTo(ebitParam.getPeriod());
@Autowired
private EbitSpreadDataMapper ebitSpreadDataMapper;
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 @@
});
};
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();
spread.suspendPaint();
......@@ -152,10 +165,13 @@
}
scope.spread = spread;
addEbitRow(sheet)
if (scope.templateId && scope.reportSource) {
if (scope.templateId && scope.reportSource&& !noCycle) {
setData(true);
}
spread.resumePaint();
return $q.when(spread);
};
......@@ -279,7 +295,7 @@
scope.spread.suspendPaint();
scope.relation.loadEbitCell(sheet);
if (scope.reportSource.length == 0 && scope.relation.emptyData && scope.relation.emptyData == true) {
loadSheet(sheet, true);///如果没有数据,需要重新加载
_init(scope.templateId, true);///如果没有数据,需要重新加载
setEditable(scope.spread);
return;
}
......@@ -309,6 +325,8 @@
}
setEditable(scope.spread);
scope.spread.resumePaint();
scope.relation.saveToDbFlag = Math.random();
}
};
(function initialize() {
......
......@@ -2919,8 +2919,11 @@
var specialConsiderations = sheet.getCell(38,3).value();
var ebitRate = sheet.getCell(40,3).value();
vatReportService.saveAndRefresh($scope.relation.orgId, $scope.relation.period, specialConsiderations, ebitRate).success(function(res){
if(res.data){
if(res.result){
$scope.relation.data = res.data;
$timeout(function(){//
spreadTODb();
}, 7000);
}
}).error(function(error){
......
......@@ -14,11 +14,11 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
//}
};
var getPeriodTemplateJson = function (templateId,period,projectId) {
return getJsonFromExcelForPeriod(templateId,period,projectId);
return getJsonFromExcelForPeriod(templateId,period,projectId, false);
};
var getPeriodTemplateJsonByOrg = function (templateId,period,orgId) {
return getJsonFromExcelForPeriod(templateId,period,orgId);
return getJsonFromExcelForPeriod(templateId,period,orgId, true);
};
var getPeriodTemplateJsonByInit = function (templateId,period,orgId) {
......@@ -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 promise = deferred.promise;
var url = null;
url = loginContext.apiHost + constant.webapi.prefix + '/template/getPeriodTemplateJson?templateId=' + templateID+"&period="+period+"&orgId="+projectId;
var url = loginContext.apiHost + constant.webapi.prefix + '/template/getPeriodTemplateJson?templateId=' + templateID+"&period="+period;
if(ebit){
url += "&orgId="+projectIdOrOrgId
}else{
url += "&projectId=" +projectIdOrOrgId;
}
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true); // 也可以使用POST方式,根据接口
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