Commit 12ac07af authored by kevin's avatar kevin

#

parent eded4cfd
......@@ -69,7 +69,7 @@ public class FileExcelUtil {
* @param path
* @throws IOException
*/
public static ZipOutputStream craeteZipPath(String path) throws IOException {
public static File craeteZipPath(String path) throws IOException {
ZipOutputStream zipOutputStream = null;
File file = new File(path + DateUtils.nowDateFormat() + ".zip");
zipOutputStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
......@@ -98,7 +98,7 @@ public class FileExcelUtil {
/*if(zipOutputStream !=null){
zipOutputStream.close();
}*/
return zipOutputStream;
return file;
}
......@@ -195,15 +195,15 @@ public class FileExcelUtil {
* @throws Exception
*/
public static File generateExcelToPath(Workbook wb, String path) throws Exception {
String[] pathArr = path.split("\\\\");
/* String[] pathArr = path.split("\\\\");
String zipDir = pathArr[0];
FileExcelUtil.createFile(zipDir);
FileExcelUtil.createFile(zipDir);*/
File file = new File(path);
FileOutputStream fos = null;
List<File> listFile = Lists.newArrayList();
try {
fos = new FileOutputStream(path);
fos = new FileOutputStream(file);
wb.write(fos);
return new File(path);
return file;
}catch (Exception e ){
e.printStackTrace();
return null;
......@@ -235,6 +235,8 @@ public class FileExcelUtil {
srcfile[i] = files.get(i);
}
//生成.zip文件;
//File zip = craeteZipPath(zipPath);
FileInputStream inStream = null;
ServletOutputStream os = null;
try {
......
......@@ -8,6 +8,9 @@ public final class Constant {
public static final String Other = "其他";
public static final int WholeYear = -1;
/* ----------------------------- kevin insert -----------------*/
public static String ebitRate = "1%";
/*-----------------------------------------------------------------*/
public static final int CREATE_DB_SUCCESS = 1;
public static final int CREATE_DB_EXISTS = 0;
public static final int CREATE_DB_FAILED = -1;
......
......@@ -5,6 +5,7 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
......@@ -15,6 +16,7 @@ import pwc.taxtech.atms.dao.OrganizationMapper;
import pwc.taxtech.atms.dao.ProjectMapper;
import pwc.taxtech.atms.dpo.ReportDto;
import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.dto.didiFileUpload.DidiFileIUploadParam;
import pwc.taxtech.atms.dto.periodReport.PeriodReportDataParam;
import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.entity.OrganizationExample;
......@@ -22,7 +24,9 @@ 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.DidiFileUploadService;
import pwc.taxtech.atms.service.impl.DistributedIdService;
import pwc.taxtech.atms.service.impl.ReportUploadService;
import pwc.taxtech.atms.vat.dao.EbitSpreadDataMapper;
import pwc.taxtech.atms.vat.dao.PwcReportAttachMapper;
import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.service.impl.ReportServiceImpl;
......@@ -34,6 +38,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.OutputStream;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
......@@ -331,18 +336,19 @@ public class ReportController {
}
@RequestMapping(value = "saveAndRefresh", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto saveAndRefresh(@RequestParam(value = "orgId") String orgId,
@RequestMapping(value = "saveAndRefresh", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
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) {
@RequestParam(value = "reportId") Long reportId,*/ @RequestBody RequestParameterDto requestParameterDto) {
OperationResultDto operationResultDto = new OperationResultDto();
String projId = getProjId(requestParameterDto.getOrgId(), requestParameterDto.getPeriod());
try{
operationResultDto.setData(reportService.loadEbitData(orgId, period, specialConsiderations, ebitRate));
new Thread(()->{
reportService.saveDatasource(orgId, period, specialConsiderations, ebitRate, operationResultDto, BaseService._cellData);
}).start();
operationResultDto.setData(reportService.loadEbitData(requestParameterDto.getOrgId(), requestParameterDto.getPeriod(), requestParameterDto.getSpecialConsiderations(), requestParameterDto.getEbitRate()));
/* new Thread(()->{
reportService.saveDatasource(orgId, period, specialConsiderations, ebitRate, operationResultDto, reportService.getCellData(Long.parseLong(requestParameterDto.getReportId()),projId ).getData().getCellData());
}).start();*/
}catch (Exception e){
return operationResultDto.error();
}
......@@ -356,30 +362,35 @@ public class ReportController {
OperationResultDto operationResultDto = new OperationResultDto();
String zipName = "利润表";
try {
String zipPath = "/zipDir";
//生成zip文件夹
FileExcelUtil.createFile(zipPath);
reportService.manyExport(requestParameterDto, zipName,request, response, zipPath);
} catch (URISyntaxException e) {
reportService.manyExport(requestParameterDto, zipName,request, response);
} catch (Exception e) {
e.printStackTrace();
operationResultDto.error(e.getMessage());
return operationResultDto;
}
return operationResultDto;
return operationResultDto.success();
}
@Autowired
private EbitSpreadDataMapper ebitSpreadDataMapper;
@Autowired
protected DistributedIdService idService;
/**
* 将spread序列化字符串保存到数据库
*/
@RequestMapping("spreadToDb")
public OperationResultDto spreadToDb(@RequestBody HttpServletRequest request) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String,MultipartFile> fileMap = multipartRequest.getFileMap();
MultipartFile file = fileMap.get("llb.xlsx");
//didiFileUploadService.uploadFile(file, );
return null;
//return reportService.spreadToDb(ebitParam);
public OperationResultDto spreadToDb( HttpServletRequest request, Integer period, String orgId) {
OperationResultDto operationResultDto = new OperationResultDto();
try{
reportService.spreadToDb(request, period, orgId);
}catch (Exception e){
e.printStackTrace();
operationResultDto.error("保存失败");
}
return operationResultDto.success();
}
}
\ No newline at end of file
package pwc.taxtech.atms.controller;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -36,6 +37,9 @@ import pwc.taxtech.atms.service.impl.DidiFileUploadService;
import pwc.taxtech.atms.service.impl.HttpFileService;
import pwc.taxtech.atms.service.impl.ReportUploadService;
import pwc.taxtech.atms.service.impl.TemplateServiceImpl;
import pwc.taxtech.atms.vat.dao.EbitSpreadDataMapper;
import pwc.taxtech.atms.vat.entity.EbitSpreadData;
import pwc.taxtech.atms.vat.entity.EbitSpreadDataExample;
import pwc.taxtech.atms.vat.entity.PeriodTemplate;
import pwc.taxtech.atms.vat.entity.ReportUpload;
......@@ -66,6 +70,7 @@ public class TemplateController extends BaseController {
@Autowired
DidiFileUploadService didiFileUploadService;
@RequestMapping(value = "get", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
List<TemplateDto> get(@RequestParam(name = "templateGroupID") Long templateGroupId, @RequestParam(name = "reportType") String reportType) {
......@@ -93,11 +98,11 @@ public class TemplateController extends BaseController {
Sheet sheet = workbook.getSheetAt(i);
for (int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++) {
Row row = sheet.getRow(r);
if(row == null){
if (row == null) {
continue;
}
for (int c = row.getFirstCellNum(); c <= row.getLastCellNum(); c++) {
if(c < 0){
if (c < 0) {
continue;
}
Cell cell = row.getCell(c);
......@@ -189,15 +194,17 @@ public class TemplateController extends BaseController {
@Autowired
private ProjectMapper projectMapper;
private String getProjId(String orgId, Integer tmsPeriod) {
ProjectExample pExample = new ProjectExample();
pExample.createCriteria().andOrganizationIdEqualTo(orgId).andYearEqualTo(tmsPeriod/100);
pExample.createCriteria().andOrganizationIdEqualTo(orgId).andYearEqualTo(tmsPeriod / 100);
List<Project> pList = projectMapper.selectByExample(pExample);
if(!pList.isEmpty()){
if (!pList.isEmpty()) {
return pList.get(0).getId();
}
return "";
}
@RequestMapping(value = "getPeriodTemplateJson", method = RequestMethod.POST, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public @ResponseBody
void getPeriodTemplateBlob(@RequestParam(name = "templateId") Long templateId,
......@@ -208,10 +215,10 @@ public class TemplateController extends BaseController {
File templateFile;
InputStream inputStream = null;
List<PeriodTemplate> templates = null;
if(period == null || projectId == null){
if (period == null || projectId == null) {
templates = templateService.getTemplates(templateId);
}else{
templates = templateService.getPeriodTemplates(templateId,period,projectId);
} else {
templates = templateService.getPeriodTemplates(templateId, period, projectId);
}
MyAsserts.assertNotEmpty(templates, new NotFoundException());
PeriodTemplate template = templates.get(0);
......@@ -277,6 +284,9 @@ public class TemplateController extends BaseController {
}
}
@Autowired
private EbitSpreadDataMapper ebitSpreadDataMapper;
@RequestMapping(value = "getPeriodTemplateJsonOrg", method = RequestMethod.POST, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public @ResponseBody
void getPeriodTemplateJsonOrg(@RequestParam(name = "templateId") Long templateId,
......@@ -284,14 +294,78 @@ public class TemplateController extends BaseController {
@RequestParam(name = "orgId") String orgId,
HttpServletResponse response) throws URISyntaxException {
String projectId = null;
if(orgId != null)
if (orgId != null)
projectId = getProjId(orgId, period);
projectId = "1942295d-6fe6-4aa7-b2e7-b66a5772697c";
String filePath;
File templateFile;
InputStream inputStream = null;
period = 0;
List<PeriodTemplate> templates = templateService.getPeriodTemplates(templateId,period,projectId);
OperationResultDto operationResultDto = new OperationResultDto();
EbitSpreadDataExample ebitSpreadData = new EbitSpreadDataExample();
ebitSpreadData.createCriteria().andPeriodEqualTo(period).andOrganizationIdEqualTo(orgId);
List<EbitSpreadData> ebitSpreadData1 = ebitSpreadDataMapper.selectByExample(ebitSpreadData);
OutputStream out = null;
//客户端保存的文件名
String customFileName = "template_" + DateTime.now().toString("yyyyMMddHHmmss") + ".xlsx";
response.setHeader("Content-Disposition", String.format("inline; filename=\"" + customFileName + "\""));
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
// int len = 0;
// byte[] buffer = new byte[1024];
// out = response.getOutputStream();
// while ((len = inputStream.read(buffer)) > 0) {
// out.write(buffer, 0, len);
// }
try {
out = response.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
if (ebitSpreadData1.size() != 0) {
DidiFileIUploadParam didiFileIUploadParam = new DidiFileIUploadParam();
didiFileIUploadParam.setUuids(Arrays.asList(ebitSpreadData1.get(0).getFileKey()));
PageInfo<DidiFileUploadDetailResult> uploadDetail = didiFileUploadService.queryPage(didiFileIUploadParam);
String path = null;
if (CollectionUtils.isNotEmpty(uploadDetail.getList())) {
path = uploadDetail.getList().get(0).getViewHttpUrl();
}
InputStream inputStream1 = httpFileService.getUserTemplate(path);
try {
IOUtils.copy(inputStream1, out);
} catch (IOException e) {
e.printStackTrace();
}
try {
out.flush();
return;
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
out = null;
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
inputStream = null;
}
}
}
List<PeriodTemplate> templates = Lists.newArrayList();
if (projectId == null || "".equals(projectId)) {
templates = templateService.getTemplates(templateId);
} else {
templates = templateService.getPeriodTemplates(templateId, period, projectId);
}
MyAsserts.assertNotEmpty(templates, new NotFoundException());
PeriodTemplate template = templates.get(0);
String templatePath = template.getPath();
......@@ -299,7 +373,7 @@ public class TemplateController extends BaseController {
filePath = this.getClass().getResource("").toURI().getPath();
String tempPath = filePath.substring(0, filePath.indexOf("classes") + "\\classes".length());
templateFile = new File(tempPath + templatePath);
OutputStream out = null;
try {
//如果是系统报表就取本地文件夹,如果不是就取FTP
if (template.getIsSystemType()) {
......@@ -316,21 +390,9 @@ public class TemplateController extends BaseController {
}
inputStream = httpFileService.getUserTemplate(templatePath);
}
//客户端保存的文件名
String customFileName = "template_" + DateTime.now().toString("yyyyMMddHHmmss") + ".xlsx";
response.setHeader("Content-Disposition", String.format("inline; filename=\"" + customFileName + "\""));
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
// int len = 0;
// byte[] buffer = new byte[1024];
// out = response.getOutputStream();
// while ((len = inputStream.read(buffer)) > 0) {
// out.write(buffer, 0, len);
// }
out = response.getOutputStream();
IOUtils.copy(handleFomularView(inputStream), out);
out.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
......@@ -355,6 +417,7 @@ public class TemplateController extends BaseController {
}
}
}
private File getTempFile(String templatePath) throws URISyntaxException {
String filePath = this.getClass().getResource("").toURI().getPath();
String tempPath = filePath.substring(0, filePath.indexOf("classes") + "\\classes".length());
......@@ -458,7 +521,7 @@ public class TemplateController extends BaseController {
//获取网站部署路径(通过ServletContext对象),用于确定下载文件位置,从而实现下载
String fileName = "";
fileName = EnumAnalysisImportType.getNameByCode(fileType);
if(StringUtils.isEmpty(fileName)){
if (StringUtils.isEmpty(fileName)) {
throw new ServiceException(ErrorMessage.SystemError);
}
response.setContentType("multipart/form-data");
......
......@@ -9,10 +9,5 @@ package pwc.taxtech.atms.dto;
**/
public class RequestParameterBaseDto {
public String orgId;
public Integer period;
public String templateId;
public String projectId;
public String reportId;
}
......@@ -10,23 +10,27 @@ import java.io.Serializable;
* Version 1.0
* 请求参数封装
**/
public class RequestParameterDto extends RequestParameterBaseDto implements Serializable {
public class RequestParameterDto implements Serializable {
public class EbitParam extends RequestParameterDto{
private String jsonString;//excel传过来的数据 已经被序列化成字符串了
private Integer specialConsiderations;
private String ebitRate;
public String getEbitRate() {
return ebitRate;
public String orgId;
public Integer period;
public String templateId;
public String projectId;
public String reportId;
public String getJsonString() {
return jsonString;
}
public void setEbitRate(String ebitRate) {
this.ebitRate = ebitRate;
public void setJsonString(String jsonString) {
this.jsonString = jsonString;
}
public Integer getSpecialConsiderations() {
return specialConsiderations;
}
......@@ -34,21 +38,12 @@ public class RequestParameterDto extends RequestParameterBaseDto implements Se
this.specialConsiderations = specialConsiderations;
}
public String getJsonString() {
return jsonString;
}
public void setJsonString(String jsonString) {
this.jsonString = jsonString;
}
}
public String getReportId() {
return reportId;
public String getEbitRate() {
return ebitRate;
}
public void setReportId(String reportId) {
this.reportId = reportId;
public void setEbitRate(String ebitRate) {
this.ebitRate = ebitRate;
}
public String getOrgId() {
......@@ -83,15 +78,25 @@ public class RequestParameterDto extends RequestParameterBaseDto implements Se
this.projectId = projectId;
}
public String getReportId() {
return reportId;
}
public void setReportId(String reportId) {
this.reportId = reportId;
}
@Override
public String toString() {
return "RequestParameterDto{" +
"reportId='" + reportId + '\'' +
"jsonString='" + jsonString + '\'' +
", specialConsiderations=" + specialConsiderations +
", ebitRate='" + ebitRate + '\'' +
", orgId='" + orgId + '\'' +
", period=" + period +
", templateId='" + templateId + '\'' +
", projectId='" + projectId + '\'' +
", reportId='" + reportId + '\'' +
'}';
}
}
......@@ -12,9 +12,9 @@ import java.math.BigDecimal;
public class EbitDataDto {
private BigDecimal ebitSubtraction; // 1. EBIT(考虑资产减值损失)
private BigDecimal specialFactors; //考虑特殊因素
private double ebitRate;// ebit比率 默认1%(可更改)
private String ebitRate;// ebit比率 默认1%(可更改)
private BigDecimal transactionAmount; //关联交易金额
private String sixAddTax; //6%增值税
private BigDecimal sixAddTax; //6%增值税
private BigDecimal totalAmountTax;// 价税合计金额
private String specialConsiderations;//特殊因素考虑
public String getSpecialConsiderations() {
......@@ -44,11 +44,11 @@ public class EbitDataDto {
this.specialFactors = specialFactors;
}
public double getEbitRate() {
public String getEbitRate() {
return ebitRate;
}
public void setEbitRate(double ebitRate) {
public void setEbitRate(String ebitRate) {
this.ebitRate = ebitRate;
}
......@@ -60,11 +60,11 @@ public class EbitDataDto {
this.transactionAmount = transactionAmount;
}
public String getSixAddTax() {
public BigDecimal getSixAddTax() {
return sixAddTax;
}
public void setSixAddTax(String sixAddTax) {
public void setSixAddTax(BigDecimal sixAddTax) {
this.sixAddTax = sixAddTax;
}
......
......@@ -5,15 +5,11 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.common.util.StringUtil;
import pwc.taxtech.atms.constant.enums.EnumServiceType;
import pwc.taxtech.atms.dao.CitTbamMapper;
import pwc.taxtech.atms.dao.FormulaAdminMapper;
import pwc.taxtech.atms.dao.ProjectMapper;
import pwc.taxtech.atms.dao.ProjectServiceTypeMapper;
import pwc.taxtech.atms.dpo.CellTemplatePerGroupDto;
import pwc.taxtech.atms.dpo.GroupId;
import pwc.taxtech.atms.dto.TableRule;
import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.exception.Exceptions;
......
......@@ -8,6 +8,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCell;
......@@ -19,6 +20,8 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
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;
......@@ -305,7 +308,7 @@ public class ReportServiceImpl extends BaseService {
private void updateConfig(String projectId, Integer period, Boolean isMergeManualData, List<Template> templates, PeriodJob job) {
List<Long> exceptTemplateIds = templateMapper.getIdsForExceptTemplate();
//根据收入类型映射生成开票记录关联数据
assembleInvoiceRecord(projectId, period,isMergeManualData);
assembleInvoiceRecord(projectId, period, isMergeManualData);
//生成trial_balance_final数据
assembleTrialBalanceFinal(projectId, period);
clearPeriodData(projectId, period, exceptTemplateIds, isMergeManualData);
......@@ -333,7 +336,7 @@ public class ReportServiceImpl extends BaseService {
trialBalanceFinalMapper.generateFinalData(projectId, Integer.valueOf(queryPeriod), lastProject == null ? "0" : lastProject.getId(), Integer.valueOf(lastPeriod));
}
public void assembleInvoiceRecord(String projectId, Integer period,Boolean isMergeManualData) {
public void assembleInvoiceRecord(String projectId, Integer period, Boolean isMergeManualData) {
Project project = projectMapper.selectByPrimaryKey(projectId);
MyAsserts.assertNotNull(project, Exceptions.NOT_FOUND_REPORT_EXCEPTION);
String queryDate = project.getYear() + "-" + (period < 10 ? ("0" + period) : (period + ""));
......@@ -345,7 +348,7 @@ public class ReportServiceImpl extends BaseService {
//先清除数据
InvoiceRecord delRecord = new InvoiceRecord();
delRecord.setRevenueCofId(null);
if(!isMergeManualData){
if (!isMergeManualData) {
delRecord.setModifyRevenueCofId(null);
}
InvoiceRecordExample delExample = new InvoiceRecordExample();
......@@ -1227,7 +1230,6 @@ public class ReportServiceImpl extends BaseService {
}
private static final Integer specialConsideration = 0;//特殊因素考虑
private static final String ebitRate = "1%";//ebit 比率
public List<CellTemplateReferenceDto> getTemplateReferences(int period) {
return new ArrayList<>();
......@@ -1242,7 +1244,7 @@ public class ReportServiceImpl extends BaseService {
OperationResultDto<ReportDataDto> cellData = getCellData(reportId, getProjId(orgId, period));
ReportDataDto reportDataDto = new ReportDataDto();
//特殊因素考虑 默认为0 rate 默认为1%
EbitDataDto ebitDataDto1 = loadEbitData(orgId, period, specialConsideration, ebitRate);
EbitDataDto ebitDataDto1 = loadEbitData(orgId, period, specialConsideration, Constant.ebitRate);
if (cellData.getData() != null) {
cellData.getData().setEbitData(ebitDataDto1);
} else {
......@@ -1252,7 +1254,7 @@ public class ReportServiceImpl extends BaseService {
return cellData;
}
} else if (operationResultDto1.getData().getEbitData() == null && operationResultDto1.getData().getCellData() != null) {
EbitDataDto ebitDataDto1 = loadEbitData(orgId, period, specialConsideration, ebitRate);
EbitDataDto ebitDataDto1 = loadEbitData(orgId, period, specialConsideration, Constant.ebitRate);
operationResultDto1.getData().setEbitData(ebitDataDto1);
} else {
OperationResultDto<ReportDataDto> cellData = getCellData(reportId, getProjId(orgId, period));
......@@ -1293,7 +1295,7 @@ public class ReportServiceImpl extends BaseService {
case 40:
if (ebitCellData1.getData() == null)
break;
ebitDataDto.setEbitRate(Double.parseDouble(ebitCellData1.getData()));
ebitDataDto.setEbitRate(ebitCellData1.getData());
break;
case 41:
if (ebitCellData1.getData() == null)
......@@ -1303,7 +1305,7 @@ public class ReportServiceImpl extends BaseService {
case 42:
if (ebitCellData1.getData() == null)
break;
ebitDataDto.setSixAddTax(ebitCellData1.getData());
ebitDataDto.setSixAddTax(new BigDecimal(ebitCellData1.getData()));
break;
case 43:
if (ebitCellData1.getData() == null)
......@@ -1556,10 +1558,11 @@ public class ReportServiceImpl extends BaseService {
@Resource
private EbitCellDataMapper ebitCellDataMapper;
//加载Ebit数据
public EbitDataDto loadEbitData(String orgId, Integer period, Integer specialConsiderations, String ebitRate) {
double rate = 0.1;
BigDecimal spec = new BigDecimal(0);
double rate = 0.01; //ebitRate
if (!ebitRate.isEmpty()) {
int _index = ebitRate.indexOf("%");
spec = new BigDecimal(specialConsiderations);
......@@ -1583,12 +1586,12 @@ public class ReportServiceImpl extends BaseService {
BigDecimal yffy = new BigDecimal(0);//研发费用
BigDecimal zcjzss = new BigDecimal(0); //资产减值损失
for (ProfitLossStatement profitLossStatement : profitLossStatements) {
BigDecimal value = profitLossStatement.getPeriodAmt();
BigDecimal value = profitLossStatement.getYtdAmt();
switch (profitLossStatement.getItemName()) {
case "加:营业外收入":
case "一、营业收入":
yysr = value;
break;
case "减:营业外支出":
case "减:营业成本":
yycb = value;
case "营业税金及附加":
yysjfj = value;
......@@ -1604,26 +1607,14 @@ public class ReportServiceImpl extends BaseService {
zcjzss = value;
}
EbitDataDto ebitDataDto = new EbitDataDto();
BigDecimal subtract = yysr.subtract(yycb).subtract(yysjfj).subtract(xsfy).subtract(glfy).subtract(yffy).subtract(zcjzss);
BigDecimal subtract = yysr.subtract(yycb).add(yysjfj).add(xsfy).add(glfy).add(yffy).add(zcjzss);
ebitDataDto.setEbitSubtraction(subtract);
ebitDataDto.setSpecialFactors(subtract.add(spec));
ebitDataDto.setEbitRate(rate);
ebitDataDto.setEbitRate(String.valueOf(rate*100 + "%"));
ebitDataDto.setTransactionAmount(ebitDataDto.getSpecialFactors().multiply(new BigDecimal(ebitDataDto.getEbitRate())));
ebitDataDto.setTransactionAmount(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.06)));
ebitDataDto.setEbitRate(ebitRate);
ebitDataDto.setSixAddTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.06)));
ebitDataDto.setTotalAmountTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.16)));
/*//保存
for (int i = 37; i <= 43; i++) {
EbitCellData ebitCellData = new EbitCellData();
ebitCellData.setData(arr[i - 37]);
ebitCellData.setRow(i);
ebitCellData.setCol(3);
ebitCellData.setCreateTime(now);
ebitCellData.setOrganizationId(orgId);
ebitCellData.setPeriod(period);
ebitCellDataMapper.insert(ebitCellData);
}*/
return ebitDataDto;
}
return null;
......@@ -2324,7 +2315,7 @@ public class ReportServiceImpl extends BaseService {
ebitCellData1.setData(operationResultDto.getData().getEbitData().getTransactionAmount().toString());
ebitCellData1.setRow(i);
case 42:
ebitCellData1.setData(operationResultDto.getData().getEbitData().getSixAddTax());
ebitCellData1.setData(operationResultDto.getData().getEbitData().getSixAddTax().toString());
ebitCellData1.setRow(i);
case 43:
ebitCellData1.setData(operationResultDto.getData().getEbitData().getTotalAmountTax().toString());
......@@ -2341,8 +2332,9 @@ public class ReportServiceImpl extends BaseService {
@Resource
private EbitSpreadDataMapper ebitSpreadDataMapper;
public OperationResultDto spreadToDb(RequestParameterDto.EbitParam ebitParam) {
try {
@Transactional
public synchronized OperationResultDto spreadToDb(HttpServletRequest request, Integer period, String orgId) {
/* try {
EbitSpreadDataExample example = new EbitSpreadDataExample();
EbitSpreadDataExample.Criteria criteria = example.createCriteria();
EbitSpreadDataExample.Criteria criteria1 = criteria.andOrganizationIdEqualTo(ebitParam.getOrgId()).andPeriodEqualTo(ebitParam.getPeriod());
......@@ -2367,7 +2359,29 @@ public class ReportServiceImpl extends BaseService {
operationResultDto.error();
operationResultDto.setResultMsg("spread【json序列化字符串】保存失败");
return operationResultDto;
}*/
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String,MultipartFile> fileMap = multipartRequest.getFileMap();
MultipartFile file = fileMap.get("llb.xlsx");
String fileName = orgId + period + "利润表";
EbitSpreadDataExample example = new EbitSpreadDataExample();
example.createCriteria().andPeriodEqualTo(period).andOrganizationIdEqualTo(orgId);
List<EbitSpreadData> ebitSpreadData1 = ebitSpreadDataMapper.selectByExample(example);
if(ebitSpreadData1.size() != 0){
didiFileUploadService.delData(ebitSpreadData1.get(0).getFileKey());
ebitSpreadDataMapper.deleteByExample(example);
}
FileUpload fileUpload = didiFileUploadService.uploadFile(file, fileName, "ebit利润表");
EbitSpreadData ebitSpreadData = new EbitSpreadData();
ebitSpreadData.setPeriod(period);
ebitSpreadData.setOrganizationId(orgId);
ebitSpreadData.setFileKey(fileUpload.getUid());
ebitSpreadData.setFileName(fileName);
ebitSpreadData.setId(idService.nextId());
ebitSpreadDataMapper.insert(ebitSpreadData);
return operationResultDto.success();
}
......@@ -2389,8 +2403,11 @@ public class ReportServiceImpl extends BaseService {
*
* @param requestParameterDto
*/
public void manyExport(RequestParameterDto requestParameterDto, String zipFileName, HttpServletRequest request, HttpServletResponse response, String zipPath) throws Exception {
try {
public void manyExport(RequestParameterDto requestParameterDto, String zipFileName, HttpServletRequest request, HttpServletResponse response) throws Exception {
String zipPath = this.getClass().getResource("/").getPath().substring(1) + "zipDir";
String fileName = null;
FileExcelUtil.createFile(zipPath);
/* try {
FileOutputStream out = new FileOutputStream(zipFileName);//要输出的文件名字
} catch (FileNotFoundException e) {
e.printStackTrace();
......@@ -2447,12 +2464,14 @@ public class ReportServiceImpl extends BaseService {
}
}
inputStream = httpFileService.getUserTemplate(templatePath);
Workbook workbook = WorkbookFactory.create(inputStream);
Sheet sheet = workbook.getSheetAt(0);
try {
Cell cell = null;
List<Workbook> workbooksList = Lists.newArrayList();
for (List<EbitCellData> ebitCellDataList1 : dataList) {
Workbook workbook = WorkbookFactory.create(inputStream);
Sheet sheet = workbook.getSheetAt(0);
Workbook newworkbook = new XSSFWorkbook();
Sheet sheet1 = newworkbook.getSheetAt(0);
if (isSheetEmpty(sheet)) throw new Exception("模板异常");
for (EbitCellData ebitCellData : ebitCellDataList1) {
loop1:
......@@ -2467,28 +2486,51 @@ public class ReportServiceImpl extends BaseService {
}
}
}
sheet1.getRow(ebitCellData.getRow()).getCell(ebitCellData.getCol()).setCellValue(ebitCellData.getData());
}
POIUtil.cloneSheetAndStyle(workbook.getSheetAt(0), workbook.createSheet("利润表"),newworkbook);
workbooksList.add(workbook);
//将workbook生成file文件
String path = "\\\\zipDir\\\\" + requestParameterDto.getPeriod() + Math.random() + "利润表";
file = FileExcelUtil.generateExcelToPath(workbook, path);
if (file != null)
filesList.add(file);
}
FileExcelUtil.downloadZip(request, response, zipFileName, filesList, zipPath);
//将workbook转成流
/* ByteArrayOutputStream bos = new ByteArrayOutputStream();
workbook.write(bos);
byte[] barray = bos.toByteArray();
InputStream is = new ByteArrayInputStream(barray);*/
// FileOutputStream fileOut = new FileOutputStream(path);
} catch (IOException e) {
e.printStackTrace();
throw new Exception(ErrorMessage.SystemError);
}
}*/
EbitSpreadDataExample example = new EbitSpreadDataExample();
example.createCriteria().andPeriodEqualTo(requestParameterDto.getPeriod());
List<EbitSpreadData> ebitSpreadData = ebitSpreadDataMapper.selectByExample(example);
List<File> fileList = Lists.newArrayList();
if (ebitSpreadData.size() == 0)
throw new Exception("没有可导出的数据");
for (int i = 0; i < ebitSpreadData.size(); i++) {
DidiFileIUploadParam fileParam = new DidiFileIUploadParam();
fileParam.setUuids(Arrays.asList(ebitSpreadData.get(i).getFileKey()));
PageInfo<DidiFileUploadDetailResult> uploadDetail = didiFileUploadService.queryPage(fileParam);
String path = null;
if (CollectionUtils.isNotEmpty(uploadDetail.getList())) {
path = uploadDetail.getList().get(0).getViewHttpUrl();
}
InputStream inputStream = httpFileService.getUserTemplate(path);
Workbook workbook1 = WorkbookFactory.create(inputStream);
fileName = zipPath + "/" + requestParameterDto.getPeriod() + ".xlsx";
fileList.add(FileExcelUtil.generateExcelToPath(workbook1, fileName));
}
String zipPath1 = zipPath + "/sizegang.zip";
FileExcelUtil.downloadZip(request, response, zipFileName, fileList, zipPath1);
//将workbook转成流
/* ByteArrayOutputStream bos = new ByteArrayOutputStream();
workbook.write(bos);
byte[] barray = bos.toByteArray();6
InputStream is = new ByteArrayInputStream(barray);*/
// FileOutputStream fileOut = new FileOutputStream(path);
}
private String getCellStringValue(Cell cell) {
......
......@@ -40,15 +40,15 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="pwc.taxtech.atms.vat.dao" targetProject="../../src/main/java">
<property name="rootInterface" value="pwc.taxtech.atms.MyVatMapper" />
</javaClientGenerator>
<table tableName="pwc_report_attach" domainObjectName="PwcReportAttach">
<table tableName="ebit_spread_data" domainObjectName="EbitSpreadData">
<property name="useActualColumnNames" value="false"/>
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
<table tableName="invoice_record" domainObjectName="InvoiceRecord">
<!--<table tableName="invoice_record" domainObjectName="InvoiceRecord">
<property name="useActualColumnNames" value="false"/>
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
</table>-->
<!--
......
......@@ -50,22 +50,6 @@ public interface EbitSpreadDataMapper extends MyVatMapper {
*/
int insertSelective(EbitSpreadData record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table ebit_spread_data
*
* @mbg.generated
*/
List<EbitSpreadData> selectByExampleWithBLOBsWithRowbounds(EbitSpreadDataExample example, RowBounds rowBounds);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table ebit_spread_data
*
* @mbg.generated
*/
List<EbitSpreadData> selectByExampleWithBLOBs(EbitSpreadDataExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table ebit_spread_data
......@@ -98,14 +82,6 @@ public interface EbitSpreadDataMapper extends MyVatMapper {
*/
int updateByExampleSelective(@Param("record") EbitSpreadData record, @Param("example") EbitSpreadDataExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table ebit_spread_data
*
* @mbg.generated
*/
int updateByExampleWithBLOBs(@Param("record") EbitSpreadData record, @Param("example") EbitSpreadDataExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table ebit_spread_data
......@@ -122,14 +98,6 @@ public interface EbitSpreadDataMapper extends MyVatMapper {
*/
int updateByPrimaryKeySelective(EbitSpreadData record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table ebit_spread_data
*
* @mbg.generated
*/
int updateByPrimaryKeyWithBLOBs(EbitSpreadData record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table ebit_spread_data
......
......@@ -21,6 +21,17 @@ public class EbitSpreadData extends BaseEntity implements Serializable {
*/
private Long id;
/**
* Database Column Remarks:
* file下载地址
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column ebit_spread_data.file_key
*
* @mbg.generated
*/
private String fileKey;
/**
*
* This field was generated by MyBatis Generator.
......@@ -112,17 +123,6 @@ public class EbitSpreadData extends BaseEntity implements Serializable {
*/
private String fileName;
/**
* Database Column Remarks:
* spread json字符串(序列化之后)
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column ebit_spread_data.spread_json_string
*
* @mbg.generated
*/
private byte[] spreadJsonString;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table ebit_spread_data
......@@ -155,6 +155,30 @@ public class EbitSpreadData extends BaseEntity implements Serializable {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column ebit_spread_data.file_key
*
* @return the value of ebit_spread_data.file_key
*
* @mbg.generated
*/
public String getFileKey() {
return fileKey;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column ebit_spread_data.file_key
*
* @param fileKey the value for ebit_spread_data.file_key
*
* @mbg.generated
*/
public void setFileKey(String fileKey) {
this.fileKey = fileKey == null ? null : fileKey.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column ebit_spread_data.create_by
......@@ -371,30 +395,6 @@ public class EbitSpreadData extends BaseEntity implements Serializable {
this.fileName = fileName == null ? null : fileName.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column ebit_spread_data.spread_json_string
*
* @return the value of ebit_spread_data.spread_json_string
*
* @mbg.generated
*/
public byte[] getSpreadJsonString() {
return spreadJsonString;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column ebit_spread_data.spread_json_string
*
* @param spreadJsonString the value for ebit_spread_data.spread_json_string
*
* @mbg.generated
*/
public void setSpreadJsonString(byte[] spreadJsonString) {
this.spreadJsonString = spreadJsonString;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table ebit_spread_data
......@@ -408,6 +408,7 @@ public class EbitSpreadData extends BaseEntity implements Serializable {
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", fileKey=").append(fileKey);
sb.append(", createBy=").append(createBy);
sb.append(", createTime=").append(createTime);
sb.append(", updateBy=").append(updateBy);
......@@ -417,7 +418,6 @@ public class EbitSpreadData extends BaseEntity implements Serializable {
sb.append(", organizationId=").append(organizationId);
sb.append(", sheetName=").append(sheetName);
sb.append(", fileName=").append(fileName);
sb.append(", spreadJsonString=").append(spreadJsonString);
sb.append("]");
return sb.toString();
}
......
......@@ -255,6 +255,76 @@ public class EbitSpreadDataExample {
return (Criteria) this;
}
public Criteria andFileKeyIsNull() {
addCriterion("file_key is null");
return (Criteria) this;
}
public Criteria andFileKeyIsNotNull() {
addCriterion("file_key is not null");
return (Criteria) this;
}
public Criteria andFileKeyEqualTo(String value) {
addCriterion("file_key =", value, "fileKey");
return (Criteria) this;
}
public Criteria andFileKeyNotEqualTo(String value) {
addCriterion("file_key <>", value, "fileKey");
return (Criteria) this;
}
public Criteria andFileKeyGreaterThan(String value) {
addCriterion("file_key >", value, "fileKey");
return (Criteria) this;
}
public Criteria andFileKeyGreaterThanOrEqualTo(String value) {
addCriterion("file_key >=", value, "fileKey");
return (Criteria) this;
}
public Criteria andFileKeyLessThan(String value) {
addCriterion("file_key <", value, "fileKey");
return (Criteria) this;
}
public Criteria andFileKeyLessThanOrEqualTo(String value) {
addCriterion("file_key <=", value, "fileKey");
return (Criteria) this;
}
public Criteria andFileKeyLike(String value) {
addCriterion("file_key like", value, "fileKey");
return (Criteria) this;
}
public Criteria andFileKeyNotLike(String value) {
addCriterion("file_key not like", value, "fileKey");
return (Criteria) this;
}
public Criteria andFileKeyIn(List<String> values) {
addCriterion("file_key in", values, "fileKey");
return (Criteria) this;
}
public Criteria andFileKeyNotIn(List<String> values) {
addCriterion("file_key not in", values, "fileKey");
return (Criteria) this;
}
public Criteria andFileKeyBetween(String value1, String value2) {
addCriterion("file_key between", value1, value2, "fileKey");
return (Criteria) this;
}
public Criteria andFileKeyNotBetween(String value1, String value2) {
addCriterion("file_key not between", value1, value2, "fileKey");
return (Criteria) this;
}
public Criteria andCreateByIsNull() {
addCriterion("create_by is null");
return (Criteria) this;
......
......@@ -7,6 +7,7 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="file_key" jdbcType="VARCHAR" property="fileKey" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
......@@ -17,13 +18,6 @@
<result column="sheet_name" jdbcType="VARCHAR" property="sheetName" />
<result column="file_name" jdbcType="VARCHAR" property="fileName" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="pwc.taxtech.atms.vat.entity.EbitSpreadData">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<result column="spread_json_string" jdbcType="LONGVARBINARY" property="spreadJsonString" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
......@@ -95,36 +89,9 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, create_by, create_time, update_by, update_time, project_id, period, organization_id,
sheet_name, file_name
id, file_key, create_by, create_time, update_by, update_time, project_id, period,
organization_id, sheet_name, file_name
</sql>
<sql id="Blob_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
spread_json_string
</sql>
<select id="selectByExampleWithBLOBs" parameterType="pwc.taxtech.atms.vat.entity.EbitSpreadDataExample" resultMap="ResultMapWithBLOBs">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from ebit_spread_data
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="pwc.taxtech.atms.vat.entity.EbitSpreadDataExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
......@@ -143,15 +110,13 @@
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from ebit_spread_data
where id = #{id,jdbcType=BIGINT}
</select>
......@@ -178,14 +143,14 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into ebit_spread_data (id, create_by, create_time,
update_by, update_time, project_id,
period, organization_id, sheet_name,
file_name, spread_json_string)
values (#{id,jdbcType=BIGINT}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{projectId,jdbcType=VARCHAR},
#{period,jdbcType=INTEGER}, #{organizationId,jdbcType=VARCHAR}, #{sheetName,jdbcType=VARCHAR},
#{fileName,jdbcType=VARCHAR}, #{spreadJsonString,jdbcType=LONGVARBINARY})
insert into ebit_spread_data (id, file_key, create_by,
create_time, update_by, update_time,
project_id, period, organization_id,
sheet_name, file_name)
values (#{id,jdbcType=BIGINT}, #{fileKey,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{projectId,jdbcType=VARCHAR}, #{period,jdbcType=INTEGER}, #{organizationId,jdbcType=VARCHAR},
#{sheetName,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="pwc.taxtech.atms.vat.entity.EbitSpreadData">
<!--
......@@ -197,6 +162,9 @@
<if test="id != null">
id,
</if>
<if test="fileKey != null">
file_key,
</if>
<if test="createBy != null">
create_by,
</if>
......@@ -224,14 +192,14 @@
<if test="fileName != null">
file_name,
</if>
<if test="spreadJsonString != null">
spread_json_string,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="fileKey != null">
#{fileKey,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
......@@ -259,9 +227,6 @@
<if test="fileName != null">
#{fileName,jdbcType=VARCHAR},
</if>
<if test="spreadJsonString != null">
#{spreadJsonString,jdbcType=LONGVARBINARY},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="pwc.taxtech.atms.vat.entity.EbitSpreadDataExample" resultType="java.lang.Long">
......@@ -284,6 +249,9 @@
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.fileKey != null">
file_key = #{record.fileKey,jdbcType=VARCHAR},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
......@@ -311,35 +279,11 @@
<if test="record.fileName != null">
file_name = #{record.fileName,jdbcType=VARCHAR},
</if>
<if test="record.spreadJsonString != null">
spread_json_string = #{record.spreadJsonString,jdbcType=LONGVARBINARY},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update ebit_spread_data
set id = #{record.id,jdbcType=BIGINT},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_by = #{record.updateBy,jdbcType=VARCHAR},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
project_id = #{record.projectId,jdbcType=VARCHAR},
period = #{record.period,jdbcType=INTEGER},
organization_id = #{record.organizationId,jdbcType=VARCHAR},
sheet_name = #{record.sheetName,jdbcType=VARCHAR},
file_name = #{record.fileName,jdbcType=VARCHAR},
spread_json_string = #{record.spreadJsonString,jdbcType=LONGVARBINARY}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
......@@ -347,6 +291,7 @@
-->
update ebit_spread_data
set id = #{record.id,jdbcType=BIGINT},
file_key = #{record.fileKey,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_by = #{record.updateBy,jdbcType=VARCHAR},
......@@ -367,6 +312,9 @@
-->
update ebit_spread_data
<set>
<if test="fileKey != null">
file_key = #{fileKey,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
......@@ -394,37 +342,17 @@
<if test="fileName != null">
file_name = #{fileName,jdbcType=VARCHAR},
</if>
<if test="spreadJsonString != null">
spread_json_string = #{spreadJsonString,jdbcType=LONGVARBINARY},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="pwc.taxtech.atms.vat.entity.EbitSpreadData">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update ebit_spread_data
set create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
project_id = #{projectId,jdbcType=VARCHAR},
period = #{period,jdbcType=INTEGER},
organization_id = #{organizationId,jdbcType=VARCHAR},
sheet_name = #{sheetName,jdbcType=VARCHAR},
file_name = #{fileName,jdbcType=VARCHAR},
spread_json_string = #{spreadJsonString,jdbcType=LONGVARBINARY}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="pwc.taxtech.atms.vat.entity.EbitSpreadData">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update ebit_spread_data
set create_by = #{createBy,jdbcType=VARCHAR},
set file_key = #{fileKey,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
......@@ -435,26 +363,6 @@
file_name = #{fileName,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="selectByExampleWithBLOBsWithRowbounds" parameterType="pwc.taxtech.atms.vat.entity.EbitSpreadDataExample" resultMap="ResultMapWithBLOBs">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from ebit_spread_data
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExampleWithRowbounds" parameterType="pwc.taxtech.atms.vat.entity.EbitSpreadDataExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
......
......@@ -847,7 +847,7 @@
"Form":"Form",
"DomesticDataImport":"Domestic Data Import",
"InternationalDataImport":"International Data Import",
"TBEBITForm":"TB EBIT Form",
"TBEBITForm":"TP EBIT Form",
"ClickEnsureTip": "Click Ensure Button!",
"ApproveCommitted":"Committed",
......
analysisModule.controller('internationalDataImportController', ['$scope','$filter', '$log', '$translate', '$timeout', '$q', '$interval'
analysisModule.controller('internationalDataImportController', ['$scope', '$filter', '$log', '$translate', '$timeout', '$q', '$interval'
, 'apiInterceptor', 'Upload', 'vatImportService', 'SweetAlert', 'uiGridConstants', '$uibModal'
, 'vatSessionService', 'enums', 'vatOperationLogService'
, 'projectService', 'vatCommonService','templateService','orgService',
function ($scope,$filter, $log, $translate, $timeout, $q, $interval
, 'projectService', 'vatCommonService', 'templateService', 'orgService',
function ($scope, $filter, $log, $translate, $timeout, $q, $interval
, apiInterceptor, Upload, vatImportService, SweetAlert, uiGridConstants, $uibModal
, vatSessionService, enums, vatOperationLogService
, projectService, vatCommonService,templateService,orgService) {
, projectService, vatCommonService, templateService, orgService) {
'use strict';
var comment = vatSessionService.project.name + " " + vatSessionService.project.year + "年" + vatSessionService.month + "月";
......@@ -21,17 +21,17 @@
$scope.projectID = vatSessionService.project.id;
$scope.startRowNum = 2;
$scope.validationType = 0;
$scope.sheetData = { sheetNameList: [], dataList: [], selectedSheetIndex: 0 };
$scope.sheetInfo = { selectedSheetName: '', selectedSheetIndex: 0 };
$scope.sheetData = {sheetNameList: [], dataList: [], selectedSheetIndex: 0};
$scope.sheetInfo = {selectedSheetName: '', selectedSheetIndex: 0};
$scope.balanceInputList = [];
$scope.toInputList = [];
$scope.importEnum = { Import: 0, CoverImport: 1, AddImport: 2 }; //导入方式
$scope.importEnum = {Import: 0, CoverImport: 1, AddImport: 2}; //导入方式
$scope.selectedPeriod = null;
$scope.showTotalSecondRow = false;
$scope.importExcelFileUrlList = {
internationalBU : apiInterceptor.webApiHostUrl + '/Analysis/InternationalExcelFile',
internationalTax : apiInterceptor.webApiHostUrl + '/Analysis/InternationalExcelFile'
internationalBU: apiInterceptor.webApiHostUrl + '/Analysis/InternationalExcelFile',
internationalTax: apiInterceptor.webApiHostUrl + '/Analysis/InternationalExcelFile'
};
$scope.maxTitleLength = constant.maxButtonTitleLength;
......@@ -53,17 +53,17 @@
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth()+1;
$scope.selectedDate = new Date(year,date.getMonth(),1);
var month = date.getMonth() + 1;
$scope.selectedDate = new Date(year, date.getMonth(), 1);
$scope.startDate = new Date(year - 20, 1, 1);
$scope.endDate = new Date(year + 20, 1, 1);
$scope.viewMode = 1;
$scope.dateFormat = $translate.instant('dateFormat4YearMonth');
if(month.length<2){
$scope.UploadPeriodTime = year+" - 0"+month;
}else{
$scope.UploadPeriodTime = year+" - "+month;
if (month.length < 2) {
$scope.UploadPeriodTime = year + " - 0" + month;
} else {
$scope.UploadPeriodTime = year + " - " + month;
}
$scope.importExcelFile = null;
......@@ -87,10 +87,10 @@
};
var param = {
type : $scope.importType,
period : $scope.UploadPeriodTime,
country : $scope.selectCountry,
companyName : $scope.selectCountry
type: $scope.importType,
period: $scope.UploadPeriodTime,
country: $scope.selectCountry,
companyName: $scope.selectCountry
};
//初始化ack-pagination
......@@ -152,7 +152,7 @@
var url = urlCreator.createObjectURL(blob);
a.href = url;
a.target = '_blank';
a.download = fileName+".xlsx";
a.download = fileName + ".xlsx";
document.body.appendChild(a);
a.click();
}
......@@ -163,18 +163,18 @@
};
var doExport = function () {
var localDate=$filter('date')(new Date(), 'yyyyMMddHHmmss');
var localDate = $filter('date')(new Date(), 'yyyyMMddHHmmss');
var fileName = '';
constant.anlDownLoadFileNameList.forEach(function (m) {
if (m.code === $scope.importType) {
fileName = m.name + $scope.UploadPeriodTime+"_" +localDate;
fileName = m.name + $scope.UploadPeriodTime + "_" + localDate;
}
});
param.companyName = $scope.selectCompany;
param.country = $scope.selectCountry;
param.type = $scope.importType;
param.period = $scope.UploadPeriodTime;
vatImportService.downloadInternationalFile(param,fileName).then(function (data) {
vatImportService.downloadInternationalFile(param, fileName).then(function (data) {
if (data) {
ackMessageBox.success(translate('FileExportSuccess'));
}
......@@ -194,12 +194,12 @@
return;
}
if (!$scope.selectCountry||''===$scope.selectCountry){
if (!$scope.selectCountry || '' === $scope.selectCountry) {
SweetAlert.warning($translate.instant('PleaseSelectFileFirst'));
return;
}
if (!$scope.selectCompany||''===$scope.selectCompany){
if (!$scope.selectCompany || '' === $scope.selectCompany) {
SweetAlert.warning($translate.instant('PleaseSelectFileFirst'));
return;
}
......@@ -212,8 +212,8 @@
Upload.upload({
url: url,
data: {
companyName :$scope.selectCompany,
country : $scope.selectCountry,
companyName: $scope.selectCompany,
country: $scope.selectCountry,
period: period,
type: $scope.importType
},
......@@ -226,7 +226,7 @@
},
__RequestVerificationToken: token,
withCredentials: true
}).then(function(resp) {
}).then(function (resp) {
var ret = resp.data;
$('#busy-indicator-container').hide();
deferred.resolve();
......@@ -237,12 +237,12 @@
} else {
if (ret.resultMsg && ret.resultMsg.length > 0) {
SweetAlert.warning($translate.instant(ret.resultMsg));
}else{
} else {
SweetAlert.error($translate.instant('ImportFailed'));
}
}
refreshGrid();
}, function(resp) {
}, function (resp) {
deferred.resolve();
if (resp.statusText === 'HttpRequestValidationException') {
SweetAlert.warning($translate.instant('HttpRequestValidationException'));
......@@ -251,14 +251,14 @@
}
SweetAlert.error($translate.instant('ImportFail'));
console.log('Error status: ' + resp.status);
}, function(evt) {
}, function (evt) {
deferred.resolve();
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
$log.debug('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
});
};
var getUploadUrl = function(){
var getUploadUrl = function () {
var url = "";
switch ($scope.importType) {
case 100:
......@@ -292,10 +292,10 @@
var getGridHeight = function () {
if ($scope.isLoadComplete) {
return { height: ($('.balance-ouput-grid-wrapper').height()) + "px" };
return {height: ($('.balance-ouput-grid-wrapper').height()) + "px"};
}
else {
return { height: 0 + "px" };
return {height: 0 + "px"};
}
};
......@@ -354,7 +354,7 @@
autoExpandAll: false
},
allowColumnResizing: true,
allowColumnReordering:true,
allowColumnReordering: true,
columnAutoWidth: true,
showRowLines: true,
showColumnLines: true,
......@@ -386,7 +386,7 @@
vatImportService.displayAnalysisInternationalImportData(param).success(function (data) {
if (data.data) {
$scope.internationalBUDataGridSource = data.data;
}else {
} else {
SweetAlert.error($translate.instant('SystemError'));
}
});
......@@ -432,7 +432,7 @@
autoExpandAll: false
},
allowColumnResizing: true,
allowColumnReordering:true,
allowColumnReordering: true,
columnAutoWidth: true,
showRowLines: true,
showColumnLines: true,
......@@ -464,7 +464,7 @@
vatImportService.displayAnalysisInternationalImportData(param).success(function (data) {
if (data.data) {
$scope.internationalTaxDataGridSource = data.data;
}else {
} else {
SweetAlert.error($translate.instant('SystemError'));
}
});
......@@ -524,16 +524,16 @@
var setButtonWrapStyle = function () {
if ($scope.fileName) {
return { width: "100%" };
return {width: "100%"};
}
};
var setGridStyle = function () {
if ($scope.showTotalSecondRow) {
return { 'margin-top': '60px' }
return {'margin-top': '60px'}
}
else {
return { 'margin-top': '55px' }
return {'margin-top': '55px'}
}
};
......@@ -571,23 +571,23 @@
});
};
$scope.selectCompanyEvent = function(i){
$scope.selectCompany=i.name;
$scope.selectCompanyEvent = function (i) {
$scope.selectCompany = i.name;
refreshGrid();
};
$scope.selectCountryEvent = function(country){
$scope.selectCountry=country;
$scope.selectCountryEvent = function (country) {
$scope.selectCountry = country;
refreshGrid();
};
$scope.selectOne = function () {
$scope.checkedCompanyList = [];
angular.forEach($scope.companyList , function (i) {
angular.forEach($scope.companyList, function (i) {
var index = $scope.checkedCompanyList.indexOf(i.id);
if(i.checked && index === -1) {
if (i.checked && index === -1) {
$scope.checkedCompanyList.push(i);
} else if (!i.checked && index !== -1){
} else if (!i.checked && index !== -1) {
$scope.checkedCompanyList.splice(index, 1);
}
});
......@@ -596,22 +596,22 @@
$scope.checkedCompanyTypeList = "";
$scope.checkedCompanyCodeList = [];
angular.forEach($scope.checkedCompanyList,function (i) {
$scope.checkedCompanyTypeList += i.name+";";
angular.forEach($scope.checkedCompanyList, function (i) {
$scope.checkedCompanyTypeList += i.name + ";";
$scope.checkedCompanyCodeList.push(i.id);
});
console.log($scope.checkedCompanyList);
};
$scope.selectAll = function () {
if($scope.selectedAll) {
if ($scope.selectedAll) {
$scope.selectedOne = true;
$scope.checkedCompanyList = [];
angular.forEach($scope.companyList, function (i, index) {
$scope.checkedCompanyList.push(i);
i.checked = true;
})
}else {
} else {
$scope.selectedOne = false;
$scope.checkedCompanyList = [];
angular.forEach($scope.companyList, function (i, index) {
......@@ -620,14 +620,14 @@
}
$scope.checkedCompanyTypeList = "";
$scope.checkedCompanyCodeList = [];
angular.forEach($scope.checkedCompanyList,function (i) {
angular.forEach($scope.checkedCompanyList, function (i) {
$scope.checkedCompanyTypeList += i.name;
$scope.checkedCompanyCodeList.push(i.id);
});
console.log($scope.checkedCompanyList);
};
$scope.changeTab = function(i){
$scope.changeTab = function (i) {
$scope.importType = i.code;
$scope.selectType = i.type;
$scope.showInternationalBUDataGrid = false;
......@@ -636,20 +636,48 @@
case 100:
$scope.showInternationalBUDataGrid = true;
loadinternationalBUDatagrid();
$scope.selectCountry='';
$scope.selectCompany='';
$scope.selectCountry = '';
$scope.selectCompany = '';
break;
case 101:
$scope.showInternationalTaxDataGrid = true;
loadInternationalTaxDataGrid();
$scope.selectCountry='';
$scope.selectCompany='';
$scope.selectCountry = '';
$scope.selectCompany = '';
break;
default:
break;
}
};
/*------------------------------kevin insert ----------------------------------------------------------------*/
//机构下拉设置
$scope.selectOrgOptions = {
displayExpr: 'name',
valueExpr: 'id',
bindingOptions: {
value: 'relation._orgId',
dataSource: 'companyList'
},
height: '30px',
placeholder: $translate.instant('PleaseSelected'),
showClearButton: true,
searchEnabled: true,
noDataText: $translate.instant('RevenueNoOrgData'),
showSelectionControls: false,
onInitialized : function(e){
},
onItemClick: function (e) {
loadCellData($scope.relation.period, e.itemData.id,function(){
$scope.relation.orgId = e.itemData.id;
$scope.relation.orgName = e.itemData.name;
});
}
};
/*------------------------------------------------------------------------------------------------------------*/
//开始
(function initialize() {
$log.debug('internationalDataImportController.ctor()...');
......
......@@ -11,7 +11,8 @@
<div id="tab_total">
<form class="form-inline" id="navigationForm" name="navigationForm">
<div class="form-group" ng-style="setButtonWrapStyle()">
<div class="import-wrapper">
<div class="import-wrapper" style="margin-left: 17px;">
<div class="row">
<span class="text-bold" translate="SelectedImportType"></span>:
<div class="dropdown" style="margin-left:10px">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu2"
......@@ -28,15 +29,38 @@
</ul>
</div>
<span class="text-bold" translate="Period"></span>:
<div class="period-picker" style="margin-left:10px">
<input type="text" id="periodDatepicker" class="datepicker imp-subheader" style="width:80px;"
<div class="period-picker" style="margin-left:10px; width:141px;">
<input type="text" id="periodDatepicker" class="datepicker imp-subheader" style=" width: 111px;"
readonly="readonly" ng-model="UploadPeriodTime"/>
<i class="fa fa-calendar imp-subheader red-color" style="width:20px;"></i>
</div>
<button type="button"
ngf-select="" type="file" ng-model="importExcelFile" ngf-drag-over-class="'dragover'" accept=".xls,.xlsx" ngf-multiple="false"
ngf-allow-dir="false" class="btn btn-vat-third" >
{{fileName ? ((fileName)|limitString:5):'SelectFile' | translate}}
</button>
<button type="button"
class="btn btn-vat-primary" style=""
translate="TemplateBtn"
ng-click="downloadTemplate()"></button>
<button type="button"
class="btn btn-vat-primary" style=""
translate="ImportBtn"
ng-click="doUpload()"></button>
<button type="button"
class="btn btn-vat-primary" style="margin-right:0px;"
translate="ExportBtn"
ng-click="doExport()"></button>
</div>
<div class="row" style="margin-top: 10px;">
<span class="text-bold" translate="Country"></span>:
<div class="dropdown" style="margin-left:10px">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu3"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" style="width: 150px;">
data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" style="width: 150px;margin-left: 28px;">
{{selectCountry ? ((selectCountry)|translate):('PleaseSelect' | translate)}}
<span class="caret" style="float: right "></span>
</button>
......@@ -49,7 +73,7 @@
</ul>
</div>
<span class="text-bold" translate="Company"></span>:
<div class="dropdown" style="margin-left:10px">
<div class="dropdown" style="margin-left:38px">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu4"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" style="width: 320px;">
{{selectCompany ? ((selectCompany)|translate):('PleaseSelect' | translate)}}
......@@ -63,27 +87,7 @@
</li>
</ul>
</div>
<button type="button"
ngf-select="" type="file" ng-model="importExcelFile" ngf-drag-over-class="'dragover'" accept=".xls,.xlsx" ngf-multiple="false"
ngf-allow-dir="false" class="btn btn-vat-third" style="margin-right:10px;margin-left:10px;max-width: 30px;">
{{fileName ? ((fileName)|limitString:5):'SelectFile' | translate}}
</button>
<button type="button"
class="btn btn-vat-primary" style=""
translate="TemplateBtn"
ng-click="downloadTemplate()"></button>
<button type="button"
class="btn btn-vat-primary" style=""
translate="ImportBtn"
ng-click="doUpload()"></button>
<button type="button"
class="btn btn-vat-primary" style="margin-top: 8px;margin-right:0px;"
translate="ExportBtn"
ng-click="doExport()"></button>
</div>
</div>
</div>
</form>
......
......@@ -330,3 +330,8 @@
padding-left: 15px;
}
}
.dropdown-menu{
span{
white-space: nowrap;
}
}
\ No newline at end of file
......@@ -76,30 +76,42 @@
scope.$watchGroup(['relation.period', 'relation.orgId', 'relation.data'], function (newValue, oldValue) {
if (scope.relation.orgId != null && scope.relation.period != null) {
setTimeout(function () {
/* setTimeout(function () {
if ((scope.relation.broadcast && scope.relation.broadcast == true) || scope.spread != undefined) {
loadSheet(scope.templateId, false)
} else {
loadSheet(scope.templateId, true);
}
}, 200);
}, 200);*/
loadSheet(scope.templateId);
}
});
scope.$watch('relation.broadcast', function (newValue, oldValue) {
if (scope.relation.orgId != null && scope.relation.period != null) {
loadSheet(scope.templateId, false)
// loadSheet(scope.templateId, false)
loadSheet(scope.templateId)
}
});
var loadSheet = function (templateId, init) {
var loadSheet = function (templateId) {
//var prokjectId = vatSessionService.project.id;
//var period = vatSessionService.month;
if (!init) {
/* if (!init) {
addEbitRow();
setData(init)
return;
}*/
if(scope.relation.orgId == undefined){
scope.relation.orgId = null;
}
return templateService.getPeriodTemplateJsonByOrg(templateId, scope.relation.period, scope.relation.orgId).then(function (reportSpread) {
var spreadCtrl = getSpreadControl();
if (spreadCtrl) {
spreadCtrl.destroy();
}
spreadCtrl = null;
if (!_.isEmpty(reportSpread)) {
initSpreadExcel(reportSpread).then(function (spread) {
/* return locateCell(spread, true);*/
......@@ -111,21 +123,27 @@
};
//初始化spread
var _init = function(){
/* var _init = function(){
return templateService.getPeriodTemplateJsonByOrg(templateId, scope.relation.period, scope.relation.orgId).then(function (reportSpread) {
if (!_.isEmpty(reportSpread)) {
var spreadCtrl = getSpreadControl();
if (spreadCtrl) {
spreadCtrl.destroy();
}
spreadCtrl = null;
initSpreadExcel(reportSpread, true).then(function (spread) {
/* return locateCell(spread, true);*/
/!* return locateCell(spread, true);*!/
});
}
}, function (data) {
$log.info(data);
});
}
}*/
var initSpreadExcel = function (reportSpread, noCycle) {
var initSpreadExcel = function (reportSpread) {
var spread = getSpreadControl();
spread.suspendPaint();
spread.fromJSON(reportSpread);
spread.options.showVerticalScrollbar = true;
......@@ -164,14 +182,12 @@
sheet.clearSelection();
}
scope.spread = spread;
if(sheet.getRowCount() <= 38)
addEbitRow(sheet)
if (scope.templateId && scope.reportSource&& !noCycle) {
if (scope.templateId && scope.reportSource) {
setData(true);
}
spread.resumePaint();
return $q.when(spread);
};
......@@ -180,7 +196,7 @@
sheet = scope.spread.getActiveSheet();
sheet.setColumnWidth(0, 400)
//添加单元格
if (sheet.getRowCount > 43)
if (sheet.getRowCount() > 43)
return;
sheet.addRows(sheet.getRowCount(scope.relation.sheetArea.viewport), 1);
sheet.addRows(sheet.getRowCount(scope.relation.sheetArea.viewport), 1);
......@@ -189,9 +205,10 @@
sheet.addRows(sheet.getRowCount(scope.relation.sheetArea.viewport), 1);
sheet.setValue(i + 37, 0, profileList[i]);
}
lockCell(scope.spread);
}
var setEditable = function (spread) {
var lockCell = function (spread) {
//todo:注册之后这里去掉注释
var sheet;
if (constant.regesterInformation.active) {
......@@ -205,6 +222,9 @@
sheet.getCell(i, j).locked(true);
}
}
///解锁指定单元格
sheet.getCell(38, 2).locked(false);//特殊因素
sheet.getCell(40, 2).locked(false);//ebit比率
};
// 每个单元格大致由以下部分构成:_SumAll(_Inter(...)+_Manual(...)+C1)
......@@ -280,26 +300,26 @@
// 根据已有信息通过spreadJS计算各单元格的值
var setData = function (init) {
var sheet = scope.spread.sheets[0];
if (!init && scope.relation.broadcast == true) {
loadEbitCell(sheet);
/* if (!init && scope.relation.broadcast == true) {
scope.relation.loadEbitCell(sheet);
return;
}
}*/
if (angular.isArray(scope.reportSource)) {
//spreadJsTipService.initialize(sheet);
/*if (!scope.isReadOnly) {
setEditable(scope.spread, false, true);
lockCell(scope.spread, false, true);
}*/
scope.spread.suspendPaint();
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) {
_init(scope.templateId, true);///如果没有数据,需要重新加载
setEditable(scope.spread);
lockCell(scope.spread);
return;
}
*/
scope.reportSource.forEach(function (data) {
scope.relation.emptyData == true;
//fix bug11737 导出需要显示千分位
......@@ -323,14 +343,14 @@
}
}
}
setEditable(scope.spread);
lockCell(scope.spread);
scope.spread.resumePaint();
scope.relation.saveToDbFlag = Math.random();
}
};
(function initialize() {
loadSheet(scope.templateId, true);
loadSheet(scope.templateId);
})();
}
......
......@@ -2833,7 +2833,7 @@
//--------------------------------------kevin insert -------------------------------------
$scope.relation = {};
var loadIndustry = function () {
/* var loadIndustry = function () {
vatReportService.getOrgLists().success(function (industryData) {
var _data = industryData.data;
$scope.relation.orgId = _data[0].id;
......@@ -2860,7 +2860,7 @@
$('#dx-select-industry').dxSelectBox('instance').option('value', $scope.relation.id);
}
});
};
};*/
$scope.changeDate = function (e) {
if (e && e.date) {
......@@ -2901,10 +2901,34 @@
$scope.changeDate(e);
});
ele1.datepicker("setDate", $scope.selectedDate);
$scope.templateId ="100610523201314816";//这里先写死 todo 这里先写死利润表模板,后续会修改模板id
//初始化
$scope.relation.period = year.toString() + monthRevert(mon);
loadCellData($scope.relation.period, $scope.relation.orgId, function(){
loadCellData($scope.selectedDate, $scope.relation.orgId, function(){
});//初始化数据,默认是当前period
};
//机构下拉设置
$scope.selectOrgOptions = {
displayExpr: 'name',
valueExpr: 'id',
bindingOptions: {
value: 'relation._orgId',
dataSource: 'companyList'
},
height: '30px',
placeholder: $translate.instant('PleaseSelected'),
showClearButton: true,
searchEnabled: true,
noDataText: $translate.instant('RevenueNoOrgData'),
showSelectionControls: false,
onInitialized : function(e){
},
onItemClick: function (e) {
loadCellData($scope.relation.period, e.itemData.id,function(){
$scope.relation.orgId = e.itemData.id;
$scope.relation.orgName = e.itemData.name;
});
}
};
var monthRevert = function(mon){
......@@ -2916,14 +2940,21 @@
//保存并刷新,加载数据
$scope.saveAndRefresh = function(){
var sheet = $scope.spread.sheets[0];
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){
var specialConsiderations = (sheet.getCell(38,2).value() == null ? 0 : sheet.getCell(38,2).value()); //如果有值取值,没有则取默认值(EBIT考虑资产减值损失)
var ebitRate = (sheet.getCell(40,2).value() == null ? "1" : sheet.getCell(40,2).value()); //如果有值取值,没有则取默认值(EBIT rate)
if($scope.relation.period != undefined)
$scope.relation.period = Number($scope.relation.period);
if($scope.relation.orgId == undefined || $scope.relation.orgId == null){
SweetAlert.error("没有选择机构,无法保存刷新");
return;
}
vatReportService.saveAndRefresh($scope.relation.orgId, $scope.relation.period, specialConsiderations, ebitRate ).success(function(res){
if(res.result){
$scope.relation.data = res.data;
$timeout(function(){
spreadTODb();
}, 7000);
}, 3000);
}
}).error(function(error){
......@@ -2949,7 +2980,9 @@
});*/
var json = $scope.spread.toJSON({includeBindingSource: true});
var excelIo = new GC.Spread.Excel.IO();
var url = apiInterceptor.webApiHostUrl + '/Report/spreadToDb';
var url = apiInterceptor.webApiHostUrl + '/Report/spreadToDb?orgId='+ $scope.relation.orgId + "&period=" +$scope.relation.period;
//var apiTokenObj = JSON.parse(getCookie('AtmsApiToken'));
//xhr.setRequestHeader('Authorization', tokenType + ' ' + apiToken);
// here is excel IO API
excelIo.save(json, function (blob) {
var fd = new FormData(document.forms.namedItem("myform"));
......@@ -2960,6 +2993,10 @@
contentType:false,
processData: false,
data:fd,
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken()
},
success: function (data) {
if(data.result){
//alert("上传成功!");
......@@ -2971,6 +3008,7 @@
alert("上传失败:"+ex);
}
});
});
}
$scope.$watch('file', function (file) {
......@@ -2978,7 +3016,8 @@
});
//上传模板
$scope.upload = function (file) {
if(file.length == 0)
frontImport(file);//前端导入
/*if(file.length == 0)
return
file = file[0];
var token = $('input[name="__RequestVerificationToken"]').val();
......@@ -3015,7 +3054,7 @@
})
.error(function (data, status, headers, config) {
SweetAlert.error(status + "上传失败")
})
})*/
};
//加载Ebit数据
......@@ -3123,39 +3162,11 @@
$('#export').html('');
$log.debug(mainSpread);
}, 500);*/
vatReportService.manyExport(JSON.stringify(param)).success(function(res){
if(!res.result)
SweetAlert.error(res.resultMsg);
}).error(function(error){
SweetAlert.error("批量导出失败")
vatReportService.manyExport(JSON.stringify(param)).error(function(error){
SweetAlert.error(error);
});
};
$scope.relation._orgId = null;
//机构下拉设置
$scope.selectOrgOptions = {
displayExpr: 'name',
valueExpr: 'id',
bindingOptions: {
value: 'relation._orgId',
dataSource: 'companyList'
},
height: '30px',
placeholder: $translate.instant('PleaseSelected'),
showClearButton: true,
searchEnabled: true,
noDataText: $translate.instant('RevenueNoOrgData'),
showSelectionControls: false,
onInitialized : function(e){
},
onItemClick: function (e) {
loadCellData($scope.relation.period, e.itemData.id,function(){
$scope.relation.orgId = e.itemData.id;
$scope.relation.orgName = e.itemData.name;
});
}
};
$scope.$watch('relation._orgId', function(n, o){
if(n != undefined )
$scope.relation.orgId = n.pop();
......@@ -3256,9 +3267,9 @@
//load cell data
var date=new Date;
var month=date.getMonth()+1;
$scope.templateId ="100610523201314816";//这里先写死 todo 这里先写死利润表模板,后续会修改模板id
/* var date=new Date;
var month=date.getMonth()+1;*/
///loadCellData($scope.relation.period);//默认当前月
/***************************************************************************************************************/
......
<div class="vat-report-view">
<!--Report SpreadJS-->
<div class="row" style=" height: 71px; background: #ccc;">
<div class="col-sm-7" style=" margin-top: 20px;">
<div class="row" style=" height: 53px; background: #ccc;">
<div class="col-sm-7" style=" margin-top: 10px;">
<div class="col-sm-8">
<span class="text-bold" translate="SelectedOrganization" style=" top: -7px; display: inline!important; position: relative; ">:</span>
<!-- <div id="dx-select-industry" class="tab-content-select industry " style=" display: inline-block;"
......@@ -22,7 +22,7 @@
</div>
</div>
</div>
<div class="col-sm-5" class="bar-export" style=" margin-top: 20px;width: 39%; float: right;">
<div class="col-sm-5" class="bar-export navRight" style=" margin-top: 20px;width: 30%;; float: right;">
<span ngf-select="" ngf-change="upload($files)" accept=".xls,.xlsx" ngf-multiple="false"
ngf-allow-dir="false" class="" ><i class="fa fa-file">&nbsp;{{'uploadProfileTable' | translate}}</i></span>
<span ng-click="saveAndRefresh()"><i class="fa fa-refresh"></i>&nbsp;{{'saveAndRefresh' | translate}}</span>
......@@ -42,5 +42,6 @@
<form name="myform" style="disply:none;" id="myform" enctype="multipart/form-data" method="post">
    
   </form>
<a href="#" id = "a"></a>
</div>
</div>
\ No newline at end of file
......@@ -109,3 +109,10 @@
}
}
}
@media screen and (max-width:1400px) {
.navRight{
width: 40%!important;
}
}
\ No newline at end of file
webservices.factory('vatReportService', ['$q', '$log', '$http', '$translate', 'apiConfig', 'enums', 'SweetAlert', 'vatOperationLogService',
'vatSessionService',
function ($q, $log, $http, $translate, apiConfig, enums, SweetAlert, vatOperationLogService, vatSessionService) {
'vatSessionService','FileSaver',
function ($q, $log, $http, $translate, apiConfig, enums, SweetAlert, vatOperationLogService, vatSessionService, FileSaver) {
'use strict';
$log.debug('vatReportService.ctor()...');
return {
......@@ -70,11 +70,24 @@
return $http.post('/Report/reportEbitData',param, apiConfig.createVat({ contentType:"application/json"}));
} ,
manyExport : function(param){
return $http.post('/Report/manyExport', param, apiConfig.createVat());
return $http.post('/Report/manyExport', param, apiConfig.createVat({responseType: 'arraybuffer'})).then(function (response) {
var a = document.createElement('a');
var blob = new Blob([response.data], {'type':"application/octet-stream" });
//FileSaver.saveAs(data, '利润表.zip');
a.href = URL.createObjectURL(blob);
a.download = "利润表.zip";
a.click();
});
}
,
saveAndRefresh: function (orgId, period, specialConsiderations, ebitRate) {
return $http.get('/Report/specialConsiderations?=' + orgId + '&period=' + period + "&specialConsiderations=" + specialConsiderations + "&ebitRate=" + ebitRate, apiConfig.createVat());
var paramObj = {
orgId: orgId,
period : period,
specialConsiderations : specialConsiderations,
ebitRate : ebitRate
};
return $http.post('/Report/saveAndRefresh', paramObj , apiConfig.createVat());
},
calculateKeyValue: function (projectId, period) {
return $http.post('/Report/calculateKeyValue/' + projectId + '/' + period, {}, apiConfig.createVat({ignoreLoadingBar: true}));
......
......@@ -18,7 +18,7 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
};
var getPeriodTemplateJsonByOrg = function (templateId,period,orgId) {
return getJsonFromExcelForPeriod(templateId,period,orgId, true);
return getJsonFromExcelForPeriodOrg(templateId,period,orgId);
};
var getPeriodTemplateJsonByInit = function (templateId,period,orgId) {
......@@ -115,15 +115,10 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
};
var getJsonFromExcelForPeriod = function (templateID,period,projectIdOrOrgId, ebit) {
var getJsonFromExcelForPeriod = function (templateID,period,projectIdOrOrgId) {
var deferred = $q.defer();
var promise = deferred.promise;
var url = loginContext.apiHost + constant.webapi.prefix + '/template/getPeriodTemplateJson?templateId=' + templateID+"&period="+period;
if(ebit){
url += "&orgId="+projectIdOrOrgId
}else{
url += "&projectId=" +projectIdOrOrgId;
}
var url = loginContext.apiHost + constant.webapi.prefix + '/template/getPeriodTemplateJson?templateId=' + templateID+"&period="+period + "&projectId=" +projectIdOrOrgId;
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true); // 也可以使用POST方式,根据接口
xhr.responseType = "blob"; // 返回类型blob
......@@ -172,6 +167,7 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
var blob = this.response;
var excelIo = new GC.Spread.Excel.IO();
excelIo.open(blob, function (json) {
deferred.resolve(json);
}, function (e) {
// console.error(e.errorMessage);
......
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