Commit 3f550fd8 authored by kevin's avatar kevin

fix

parent ddc6e98b
......@@ -9,6 +9,16 @@ public class FileServiceConfig {
private String serverUrl;
@Value("${file.server.upload}")
private String uploadUrl;
@Value("${file_upload_post_url}")
private String upload_post_url;
public String getUpload_post_url() {
return upload_post_url;
}
public void setUpload_post_url(String upload_post_url) {
this.upload_post_url = upload_post_url;
}
public String getServerUrl() {
return serverUrl;
......
......@@ -17,5 +17,6 @@ public class ErrorMessageCN {
public static final String OrgStructureNameExist = "层级名称已存在!";
public static final String NoLedgerID = "该机构未同步主数据账套ID!";
public static final String NoCompanyCode = "该机构缺少机构代码字段!";
public static final String ErrorFileFormat="文件样式错误";
}
......@@ -41,10 +41,15 @@ public class FileUploadUtil implements ApplicationContextAware {
return upload( file, false);
}
public static String serverPath(){
public static String serverPath(boolean newUrl){
config = (FileServiceConfig)applicationContext.getBean("fileServiceConfig");
if(newUrl)
return config.getUpload_post_url();
return config.getServerUrl() + config.getUploadUrl();
}
public static String serverPath(){
return serverPath(true);
}
/**
* 上传模板
*
......
......@@ -5,6 +5,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.dao.ProjectMapper;
import pwc.taxtech.atms.dpo.PagingDto;
import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.dto.dataimport.DataImportAllParam;
......@@ -13,6 +14,8 @@ import pwc.taxtech.atms.dto.dataimport.DataProcessParam;
import pwc.taxtech.atms.dto.input.CamelPagingResultDto;
import pwc.taxtech.atms.dto.vatdto.TrialBalanceDto;
import pwc.taxtech.atms.dto.vatdto.TrialBalanceParam;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.entity.ProjectExample;
import pwc.taxtech.atms.exception.ServiceException;
import pwc.taxtech.atms.service.impl.DataImportService;
import pwc.taxtech.atms.service.impl.DidiFileUploadService;
......@@ -126,6 +129,7 @@ public class DataImportController extends BaseController {
}
}
@ResponseBody
@RequestMapping(value = "CFExcelFile", method = RequestMethod.POST)
public OperationResultDto importCFExcelFile(@RequestParam MultipartFile file,@RequestParam String orgIds,@RequestParam String periodDate,@RequestParam Integer importType) {
......
......@@ -7,15 +7,19 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.constant.enums.EnumServiceType;
import pwc.taxtech.atms.dao.OrganizationMapper;
import pwc.taxtech.atms.dao.ProjectMapper;
import pwc.taxtech.atms.dpo.ReportDto;
import pwc.taxtech.atms.dto.FileDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.PeriodReportDto;
import pwc.taxtech.atms.dto.ReportAttachDto;
import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.vat.entity.PeriodCellTemplateConfig;
import pwc.taxtech.atms.vat.entity.PeriodJob;
import pwc.taxtech.atms.vat.entity.PwcReportAttach;
import pwc.taxtech.atms.vat.entity.VatEnterpriseAccount;
import pwc.taxtech.atms.entity.OrganizationExample;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.entity.ProjectExample;
import pwc.taxtech.atms.service.impl.DataImportService;
import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.service.impl.ReportServiceImpl;
import java.util.List;
......@@ -82,6 +86,48 @@ public class ReportController {
return reportService.getCellData(reportId, from);
}
private static OperationResultDto<ReportDataDto> operationResultDto = null;
@RequestMapping(value = "reportEbitData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<ReportDataDto> reportEbitData(Long reportId, String orgId, Integer period) {
OperationResultDto resultDto = new OperationResultDto();
if (reportId == null || reportId == 0L) {
resultDto.setResult(false);
return resultDto;
}
operationResultDto = reportService.getCellData(reportId, orgId, period);
return operationResultDto;
}
@Autowired
private ProjectMapper projectMapper;
private String getProjId(String orgId, Integer tmsPeriod) {
ProjectExample pExample = new ProjectExample();
pExample.createCriteria().andOrganizationIdEqualTo(orgId).andYearEqualTo(tmsPeriod / 100);
List<Project> pList = projectMapper.selectByExample(pExample);
if (!pList.isEmpty()) {
return pList.get(0).getId();
}
return "";
}
public static void main(String[] args) {
System.out.println(201833 % 100);
}
private DataImportService dataImportService;
@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;
}
@RequestMapping(value = "report/{templateId}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<ReportDto> getReportByTemplate(@PathVariable Long templateId, @PathVariable Integer period, @RequestHeader String from) {
OperationResultDto resultDto = new OperationResultDto();
......@@ -93,6 +139,18 @@ public class ReportController {
return reportService.getReportByTemplate(templateId, period, from);
}
@RequestMapping(value = "getReportByTemplateEbit/{templateId}/{period}/{orgId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<PeriodReportDto> getReportByTemplateEbit(@PathVariable String templateId, @PathVariable Integer period, @PathVariable String orgId) {
OperationResultDto resultDto = new OperationResultDto();
if (templateId == null || period == null || period == 0) {
resultDto.setResult(false);
resultDto.setResultMsg("templateId or period is invalid");
return resultDto;
}
return reportService.getReportByTemplateEbit(Long.parseLong(templateId), period % 100, getProjId(orgId, period));
}
@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,
......@@ -157,25 +215,35 @@ public class ReportController {
@RequestMapping(value = "doUpload", method = RequestMethod.POST)
public OperationResultDto doUploadAttach(@RequestParam("fileName") String fileName, MultipartFile file, String remarks, @RequestParam("activeCol")Long activeCol, @RequestParam("activeRow")Long activeRow, @RequestParam("activeTemplateId")String activeTemplateId){
public OperationResultDto doUploadAttach(@RequestParam("fileName") String fileName, MultipartFile file, String remarks, @RequestParam("activeCol") Long activeCol, @RequestParam("activeRow") Long activeRow, @RequestParam("activeTemplateId") String activeTemplateId) {
System.out.println(activeCol + "----" + activeRow + "-----" + activeTemplateId);
OperationResultDto operationResultDto = reportService.doUploadAttach(file, remarks);
if(!"error".equals(operationResultDto.getResultMsg())){//上传成功绑定
if (!"error".equals(operationResultDto.getResultMsg())) {//上传成功绑定
reportService.bindPwcAttach(activeCol, activeRow, activeTemplateId, (FileDto) operationResultDto.getData());
}
return operationResultDto;
}
@RequestMapping("loadAttachList")
public List<PwcReportAttach> loadAttachList(@RequestBody ReportAttachDto reportAttachDto){
public List<PwcReportAttach> loadAttachList(@RequestBody ReportAttachDto reportAttachDto) {
System.out.println("sdsdfsd");
return reportService.loadAttachList(reportAttachDto);
}
@RequestMapping("deleteAttach")
public OperationResultDto deleteAttach(Long id){
public OperationResultDto deleteAttach(Long id) {
return reportService.deleteAttach(id);
}
@Autowired
private OrganizationMapper organizationMapper;
@RequestMapping("getOrgLists")
public OperationResultDto getOrgLists() {
OperationResultDto operationResultDto = new OperationResultDto();
OrganizationExample organizationExample = new OrganizationExample();
operationResultDto.setData(organizationMapper.selectByExample(organizationExample));
return operationResultDto;
}
}
\ No newline at end of file
......@@ -19,11 +19,14 @@ import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.constant.enums.EnumAnalysisImportType;
import pwc.taxtech.atms.constant.enums.EnumCitImportType;
import pwc.taxtech.atms.constant.enums.EnumImportType;
import pwc.taxtech.atms.dao.ProjectMapper;
import pwc.taxtech.atms.dpo.TemplateUniqDto;
import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.dto.didiFileUpload.DidiFileIUploadParam;
import pwc.taxtech.atms.dto.didiFileUpload.DidiFileUploadDetailResult;
import pwc.taxtech.atms.dto.vatdto.TemplateByGroupDto;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.entity.ProjectExample;
import pwc.taxtech.atms.entity.Template;
import pwc.taxtech.atms.exception.ApplicationException;
import pwc.taxtech.atms.exception.BadParameterException;
......@@ -184,16 +187,110 @@ 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);
List<Project> pList = projectMapper.selectByExample(pExample);
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,
@RequestParam(name = "period") Integer period,
@RequestParam(name = "projectId") String projectId,
@RequestParam(name = "period", required = false) Integer period,
@RequestParam(name = "projectId", required = false) String projectId,
HttpServletResponse response) throws URISyntaxException {
String filePath;
File templateFile;
InputStream inputStream = null;
List<PeriodTemplate> templates = null;
if(period == null || projectId == null){
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();
MyAsserts.assertNotEmpty(templatePath, new NotFoundException());
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()) {
inputStream = new BufferedInputStream(new FileInputStream(templateFile));
} else {
if (templatePath.indexOf("/") <= 0) {
DidiFileIUploadParam fileParam = new DidiFileIUploadParam();
fileParam.setUuids(Arrays.asList(templatePath));
PageInfo<DidiFileUploadDetailResult> uploadDetail = didiFileUploadService.queryPage(fileParam);
Map<String, String> urlMap = null;
if (CollectionUtils.isNotEmpty(uploadDetail.getList())) {
templatePath = uploadDetail.getList().get(0).getViewHttpUrl();
}
}
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) {
logger.error("Error downloading template file template.xlsx", e);
throw new ApplicationException("Error downloading template file template.xlsx", e);
} 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;
}
}
}
@RequestMapping(value = "getPeriodTemplateJsonOrg", method = RequestMethod.POST, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public @ResponseBody
void getPeriodTemplateJsonOrg(@RequestParam(name = "templateId") Long templateId,
@RequestParam(name = "period") Integer period,
@RequestParam(name = "orgId") String orgId,
HttpServletResponse response) throws URISyntaxException {
String projectId = 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);
MyAsserts.assertNotEmpty(templates, new NotFoundException());
PeriodTemplate template = templates.get(0);
......
......@@ -141,6 +141,24 @@ public class TemplateGroupController {
return OperationResultDto.error(ErrorMessage.SystemError);
}
@ResponseBody
@RequestMapping(value = "ebitTemplateImport", method = RequestMethod.POST)
public OperationResultDto ebitTemplateImport(@RequestParam MultipartFile file,
@RequestParam String orgId,
@RequestParam Integer period) {
try {
templateGroupService.ebitTemplateImport(file, orgId,period);
return OperationResultDto.success();
} catch (ServiceException e) {
return OperationResultDto.error(e.getMessage());
} catch (Exception e) {
logger.error("ebitTemplateImport error.", e);
}
return OperationResultDto.error(ErrorMessage.SystemError);
}
@ResponseBody
// @ApiOperation(value = "模板另存为")
@RequestMapping(value = "addTemplateGroup", method = RequestMethod.POST)
......
package pwc.taxtech.atms.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import pwc.taxtech.atms.common.util.PwCIdSerialize;
import pwc.taxtech.atms.vat.entity.EbitCellData;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
*
* This class was generated by MyBatis Generator.
* This class corresponds to the database table TAX_ADMIN.PERIOD_REPORT
*
* @mbg.generated do_not_delete_during_merge
*/
public class PeriodReportDto implements Serializable {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_ADMIN.PERIOD_REPORT.ID
*
* @mbg.generated
*/
@JsonSerialize(using = PwCIdSerialize.class)
private Long id;
private List<EbitCellData> cellDataList;
public List<EbitCellData> getCellDataList() {
return cellDataList;
}
public void setCellDataList(List<EbitCellData> cellDataList) {
this.cellDataList = cellDataList;
}
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_ADMIN.PERIOD_REPORT.TEMPLATE_ID
*
* @mbg.generated
*/
private Long templateId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_ADMIN.PERIOD_REPORT.PERIOD
*
* @mbg.generated
*/
private Integer period;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_ADMIN.PERIOD_REPORT.PROJECT_ID
*
* @mbg.generated
*/
private String projectId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_ADMIN.PERIOD_REPORT.CREATE_BY
*
* @mbg.generated
*/
private String createBy;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_ADMIN.PERIOD_REPORT.CREATE_TIME
*
* @mbg.generated
*/
private Date createTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_ADMIN.PERIOD_REPORT.UPDATE_BY
*
* @mbg.generated
*/
private String updateBy;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column TAX_ADMIN.PERIOD_REPORT.UPDATE_TIME
*
* @mbg.generated
*/
private Date updateTime;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table TAX_ADMIN.PERIOD_REPORT
*
* @mbg.generated
*/
private static final long serialVersionUID = 1L;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_ADMIN.PERIOD_REPORT.ID
*
* @return the value of TAX_ADMIN.PERIOD_REPORT.ID
*
* @mbg.generated
*/
public Long getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_ADMIN.PERIOD_REPORT.ID
*
* @param id the value for TAX_ADMIN.PERIOD_REPORT.ID
*
* @mbg.generated
*/
public void setId(Long id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_ADMIN.PERIOD_REPORT.TEMPLATE_ID
*
* @return the value of TAX_ADMIN.PERIOD_REPORT.TEMPLATE_ID
*
* @mbg.generated
*/
public Long getTemplateId() {
return templateId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_ADMIN.PERIOD_REPORT.TEMPLATE_ID
*
* @param templateId the value for TAX_ADMIN.PERIOD_REPORT.TEMPLATE_ID
*
* @mbg.generated
*/
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_ADMIN.PERIOD_REPORT.PERIOD
*
* @return the value of TAX_ADMIN.PERIOD_REPORT.PERIOD
*
* @mbg.generated
*/
public Integer getPeriod() {
return period;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_ADMIN.PERIOD_REPORT.PERIOD
*
* @param period the value for TAX_ADMIN.PERIOD_REPORT.PERIOD
*
* @mbg.generated
*/
public void setPeriod(Integer period) {
this.period = period;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_ADMIN.PERIOD_REPORT.PROJECT_ID
*
* @return the value of TAX_ADMIN.PERIOD_REPORT.PROJECT_ID
*
* @mbg.generated
*/
public String getProjectId() {
return projectId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_ADMIN.PERIOD_REPORT.PROJECT_ID
*
* @param projectId the value for TAX_ADMIN.PERIOD_REPORT.PROJECT_ID
*
* @mbg.generated
*/
public void setProjectId(String projectId) {
this.projectId = projectId == null ? null : projectId.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_ADMIN.PERIOD_REPORT.CREATE_BY
*
* @return the value of TAX_ADMIN.PERIOD_REPORT.CREATE_BY
*
* @mbg.generated
*/
public String getCreateBy() {
return createBy;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_ADMIN.PERIOD_REPORT.CREATE_BY
*
* @param createBy the value for TAX_ADMIN.PERIOD_REPORT.CREATE_BY
*
* @mbg.generated
*/
public void setCreateBy(String createBy) {
this.createBy = createBy == null ? null : createBy.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_ADMIN.PERIOD_REPORT.CREATE_TIME
*
* @return the value of TAX_ADMIN.PERIOD_REPORT.CREATE_TIME
*
* @mbg.generated
*/
public Date getCreateTime() {
return createTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_ADMIN.PERIOD_REPORT.CREATE_TIME
*
* @param createTime the value for TAX_ADMIN.PERIOD_REPORT.CREATE_TIME
*
* @mbg.generated
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_ADMIN.PERIOD_REPORT.UPDATE_BY
*
* @return the value of TAX_ADMIN.PERIOD_REPORT.UPDATE_BY
*
* @mbg.generated
*/
public String getUpdateBy() {
return updateBy;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_ADMIN.PERIOD_REPORT.UPDATE_BY
*
* @param updateBy the value for TAX_ADMIN.PERIOD_REPORT.UPDATE_BY
*
* @mbg.generated
*/
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy == null ? null : updateBy.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column TAX_ADMIN.PERIOD_REPORT.UPDATE_TIME
*
* @return the value of TAX_ADMIN.PERIOD_REPORT.UPDATE_TIME
*
* @mbg.generated
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column TAX_ADMIN.PERIOD_REPORT.UPDATE_TIME
*
* @param updateTime the value for TAX_ADMIN.PERIOD_REPORT.UPDATE_TIME
*
* @mbg.generated
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table TAX_ADMIN.PERIOD_REPORT
*
* @mbg.generated
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", templateId=").append(templateId);
sb.append(", period=").append(period);
sb.append(", projectId=").append(projectId);
sb.append(", createBy=").append(createBy);
sb.append(", createTime=").append(createTime);
sb.append(", updateBy=").append(updateBy);
sb.append(", updateTime=").append(updateTime);
sb.append("]");
return sb.toString();
}
}
\ No newline at end of file
package pwc.taxtech.atms.dto.vatdto;
import java.math.BigDecimal;
/**
* @ClassName EbitDataDto
* Description TODO
* @Author pwc kevin
* @Date 3/26/2019 11:00 AM
* Version 1.0
**/
public class EbitDataDto {
private BigDecimal ebitSubtraction; // 1. EBIT(考虑资产减值损失)
private BigDecimal specialFactors; //考虑特殊因素
private double ebitRate;// ebit比率 默认1%(可更改)
private BigDecimal transactionAmount; //关联交易金额
private String sixAddTax; //6%增值税
private BigDecimal totalAmountTax;// 价税合计金额
private String specialConsiderations;//特殊因素考虑
public String getSpecialConsiderations() {
return specialConsiderations;
}
public void setSpecialConsiderations(String specialConsiderations) {
this.specialConsiderations = specialConsiderations;
}
public BigDecimal getEbitSubtraction() {
return ebitSubtraction;
}
public void setEbitSubtraction(BigDecimal ebitSubtraction) {
this.ebitSubtraction = ebitSubtraction;
}
public BigDecimal getSpecialFactors() {
return specialFactors;
}
public void setSpecialFactors(BigDecimal specialFactors) {
this.specialFactors = specialFactors;
}
public double getEbitRate() {
return ebitRate;
}
public void setEbitRate(double ebitRate) {
this.ebitRate = ebitRate;
}
public BigDecimal getTransactionAmount() {
return transactionAmount;
}
public void setTransactionAmount(BigDecimal transactionAmount) {
this.transactionAmount = transactionAmount;
}
public String getSixAddTax() {
return sixAddTax;
}
public void setSixAddTax(String sixAddTax) {
this.sixAddTax = sixAddTax;
}
public BigDecimal getTotalAmountTax() {
return totalAmountTax;
}
public void setTotalAmountTax(BigDecimal totalAmountTax) {
this.totalAmountTax = totalAmountTax;
}
@Override
public String toString() {
return "EbitDataDto{" +
"ebitSubtraction=" + ebitSubtraction +
", specialFactors=" + specialFactors +
", ebitRate='" + ebitRate + '\'' +
", transactionAmount=" + transactionAmount +
", sixAddTax='" + sixAddTax + '\'' +
", totalAmountTax=" + totalAmountTax +
'}';
}
}
......@@ -8,6 +8,15 @@ public class ReportDataDto {
private List<CellDataDto> cellData;
private List<PeriodFormulaBlock> formulaBlocks;
private List<DataSourceDtoExtend> manualDataSources;
private EbitDataDto ebitData;
public EbitDataDto getEbitData() {
return ebitData;
}
public void setEbitData(EbitDataDto ebitData) {
this.ebitData = ebitData;
}
public List<CellDataDto> getCellData() {
return this.cellData;
......
......@@ -748,7 +748,8 @@ public class AnalysisServiceImpl extends BaseService {
private BigDecimal getCellBigDecimalValue(Cell cell) {
if (cell.getCellTypeEnum().equals(CellType.STRING)) {
return new BigDecimal(cell.getStringCellValue());
String replace = cell.getStringCellValue().replace("%", "");
return new BigDecimal(Double.parseDouble(replace)/100);
} else if(cell.getCellTypeEnum().equals(CellType.NUMERIC)) {
return new BigDecimal(cell.getNumericCellValue());
}
......
......@@ -5,6 +5,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -15,35 +16,23 @@ import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.POIUtil;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.common.message.ErrorMessageCN;
import pwc.taxtech.atms.common.message.TemplateMessage;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.CellDataSourceType;
import pwc.taxtech.atms.constant.enums.FileUploadEnum;
import pwc.taxtech.atms.constant.enums.TemplateGroupType;
import pwc.taxtech.atms.dao.CellTemplateConfigDao;
import pwc.taxtech.atms.dao.CellTemplateConfigMapper;
import pwc.taxtech.atms.dao.CellTemplateDao;
import pwc.taxtech.atms.dao.CellTemplateMapper;
import pwc.taxtech.atms.dao.TemplateDao;
import pwc.taxtech.atms.dao.TemplateGroupDao;
import pwc.taxtech.atms.dao.TemplateGroupMapper;
import pwc.taxtech.atms.dao.TemplateMapper;
import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.TemplateGroupDto;
import pwc.taxtech.atms.entity.CellTemplate;
import pwc.taxtech.atms.entity.CellTemplateConfig;
import pwc.taxtech.atms.entity.CellTemplateConfigExample;
import pwc.taxtech.atms.entity.CellTemplateExample;
import pwc.taxtech.atms.entity.Template;
import pwc.taxtech.atms.entity.TemplateExample;
import pwc.taxtech.atms.entity.TemplateGroup;
import pwc.taxtech.atms.entity.TemplateGroupExample;
import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.exception.ServiceException;
import pwc.taxtech.atms.vat.dao.PeriodDataSourceMapper;
import pwc.taxtech.atms.vat.entity.FileUpload;
import pwc.taxtech.atms.vat.entity.PeriodDataSource;
import pwc.taxtech.atms.vat.entity.*;
import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.*;
......@@ -73,6 +62,7 @@ public class TemplateGroupServiceImpl extends AbstractService {
private PeriodDataSourceMapper periodDataSourceMapper;
@Autowired
private DidiFileUploadService didiFileUploadService;
public List<TemplateGroupDto> get() {
List<TemplateGroup> templateGroups = templateGroupMapper.selectByExample(new TemplateGroupExample());
List<TemplateGroupDto> templateGroupDtos = new ArrayList<>();
......@@ -167,6 +157,90 @@ public class TemplateGroupServiceImpl extends AbstractService {
cellTemplateMapper.deleteByExample(example);
}
private boolean isSheetEmpty(Sheet sheet) {
if (sheet.getLastRowNum() > 0 &&
(null == sheet.getRow(0).getCell(0) || "Version".equals(getCellStringValue(sheet.getRow(0).getCell(0)))) &&
null == sheet.getRow(0).getCell(2)) {
return true;
}
return false;
}
private String getCellStringValue(Cell cell) {
if (null == cell) {
return "";
}
if (cell.getCellTypeEnum().equals(CellType.STRING)) {
return cell.getStringCellValue().trim();
} else if (cell.getCellTypeEnum().equals(CellType.NUMERIC)) {
// 取整
return String.valueOf((int) cell.getNumericCellValue()).trim();
}
logger.warn("获取单元格数据类型未匹配");
return null;
}
@Resource
private ProjectMapper projectMapper;
private String getProjId(String orgId, Integer tmsPeriod) {
ProjectExample pExample = new ProjectExample();
pExample.createCriteria().andOrganizationIdEqualTo(orgId).andYearEqualTo(tmsPeriod / 100);
List<Project> pList = projectMapper.selectByExample(pExample);
if (!pList.isEmpty()) {
return pList.get(0).getId();
}
return "";
}
public static final String PROTABLEID = "100610523201314816";
public void ebitTemplateImport(MultipartFile file, String orgId, Integer period) {
InputStream inputStream = null;
Date now = new Date();
String projectId = getProjId(orgId, period);
try {
inputStream = file.getInputStream();
Workbook workbook = WorkbookFactory.create(inputStream);
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
List<EbitCellData> list = Lists.newArrayList();
Sheet sheet = workbook.getSheetAt(i);
if (isSheetEmpty(sheet)) continue;
List<InvoiceData> cfs = Lists.newArrayList();
String[] sheetName = sheet.getSheetName().split("-");
String taypayerNum = sheetName[0];
String titleValue = sheet.getRow(0).getCell(3).getStringCellValue();
if ("".equals(titleValue) || !"".equals("利润表(单家PRC)"))
throw new ServiceException(ErrorMessageCN.ErrorFileFormat);
if (period == null) {
throw new ServiceException(ErrorMessageCN.DoNotSelectPeriod);
}
for (int j = 1; j <= sheet.getRow(0).getLastCellNum(); j++) {
for (int m = 1; j < sheet.getLastRowNum(); j++) {
if (j == 2 || j == 3) {
EbitCellData ebitCellData = new EbitCellData();
ebitCellData.setCol(j);
ebitCellData.setRow(m);
ebitCellData.setCreateTime(now);
ebitCellData.setData(sheet.getRow(m).getCell(j).getStringCellValue());
ebitCellData.setTemplateId(PROTABLEID);
ebitCellData.setProjectId(projectId);
list.add(ebitCellData);
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidFormatException e) {
e.printStackTrace();
}
}
public class TemplateGroupMessage {
static final String TEMPLATE_GROUP_NAME_EXIST = "TemplateGroupNameExist";
static final String SYSTEM_TYPE_CANNOT_DELETE = "SystemTypeCannotDelete";
......@@ -214,7 +288,7 @@ public class TemplateGroupServiceImpl extends AbstractService {
templateGroupMapper.insertSelective(templateGroup);
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
String sheetName = workbook.getSheetName(i);
if(!sheetNameList.contains(sheetName)){
if (!sheetNameList.contains(sheetName)) {
continue;
}
String newName = sheetName + CommonUtils.getUUID() + POIUtil.getFileSuffix(fileName).get();
......@@ -226,7 +300,7 @@ public class TemplateGroupServiceImpl extends AbstractService {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
optional.get().write(bos);
//上传didi服务器文件
FileUpload fileUpload = didiFileUploadService.uploadFile(file,file.getOriginalFilename(), FileUploadEnum.BizSource.REPORT_TEMPLATE_UPLOAD.name());
FileUpload fileUpload = didiFileUploadService.uploadFile(file, file.getOriginalFilename(), FileUploadEnum.BizSource.REPORT_TEMPLATE_UPLOAD.name());
// String tmpPath = httpFileService.uploadTemplate(newName, file);
String[] arr = sheetName.split("_");
String name = arr.length >= 2 ? arr[1] : arr[0];
......@@ -259,9 +333,9 @@ public class TemplateGroupServiceImpl extends AbstractService {
cellTemplate.setUpdateTime(now);
cellTemplate.setRowIndex(r);
//税金计算表单独处理
if("VAT020".equals(template.getCode())){
if ("VAT020".equals(template.getCode())) {
cellTemplate.setRowName(POIUtil.getCellFormulaString(cell));
}else{
} else {
cellTemplate.setRowName(StringUtils.EMPTY);
}
cellTemplate.setColumnName(StringUtils.EMPTY);
......@@ -280,11 +354,11 @@ public class TemplateGroupServiceImpl extends AbstractService {
//todo: 这里没有Config数据只有在上传模板以后,在界面里面可以配置公式
if (!cell.getCellStyle().getLocked() && hasKeyIn(cell)) {
cell.setCellValue(StringUtils.EMPTY);
if(allowManual){
if (allowManual) {
addManualConfig(cellTemplate, template, cell, now, cellTemplateConfigList);
}
}
if(!cell.getCellStyle().getLocked() && StringUtils.isNotBlank(POIUtil.getCellFormulaString(cell))) {
if (!cell.getCellStyle().getLocked() && StringUtils.isNotBlank(POIUtil.getCellFormulaString(cell))) {
CellTemplateConfig config = new CellTemplateConfig();
config.setId(distributedIdService.nextId());
config.setCellTemplateId(cellTemplate.getId());
......@@ -356,7 +430,7 @@ public class TemplateGroupServiceImpl extends AbstractService {
int length = templateMapper.selectByExample(t).size();
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
String sheetName = workbook.getSheetName(i);
if(!sheetNameList.contains(sheetName)){
if (!sheetNameList.contains(sheetName)) {
continue;
}
String newName = sheetName + CommonUtils.getUUID() + POIUtil.getFileSuffix(fileName).get();
......@@ -368,25 +442,25 @@ public class TemplateGroupServiceImpl extends AbstractService {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Workbook wtemp = optional.get();
Sheet temp = wtemp.getSheetAt(0);
for(int j = temp.getFirstRowNum(); j < temp.getLastRowNum(); j ++){
for (int j = temp.getFirstRowNum(); j < temp.getLastRowNum(); j++) {
Row row = temp.getRow(j);
if(row == null){
if (row == null) {
continue;
}
for(int k = row.getFirstCellNum(); k < row.getLastCellNum(); k++){
for (int k = row.getFirstCellNum(); k < row.getLastCellNum(); k++) {
Cell cell = row.getCell(k);
if (cell == null) {
continue;//todo cell == null 如何处理
}
cell.setCellType(CellType.STRING);
if(!cell.getCellStyle().getLocked() && "${KeyIn}".equalsIgnoreCase(cell.getStringCellValue())){
if (!cell.getCellStyle().getLocked() && "${KeyIn}".equalsIgnoreCase(cell.getStringCellValue())) {
cell.setCellValue("");
}
}
}
wtemp.write(bos);
//上传didi服务器文件
FileUpload fileUpload = didiFileUploadService.uploadFile(file,file.getOriginalFilename(), FileUploadEnum.BizSource.REPORT_TEMPLATE_UPLOAD.name());
FileUpload fileUpload = didiFileUploadService.uploadFile(file, file.getOriginalFilename(), FileUploadEnum.BizSource.REPORT_TEMPLATE_UPLOAD.name());
// String tmpPath = httpFileService.uploadTemplate(newName, file);
String[] arr = sheetName.split("_");
String name = arr.length >= 2 ? arr[1] : arr[0];
......@@ -408,11 +482,11 @@ public class TemplateGroupServiceImpl extends AbstractService {
List<PeriodDataSource> periodDataSourceList = Lists.newArrayList();
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);
......@@ -421,7 +495,7 @@ public class TemplateGroupServiceImpl extends AbstractService {
}
CellTemplate cellTemplate = new CellTemplate();
//税金计算表单独处理
if("VAT020".equals(template.getCode())){
if ("VAT020".equals(template.getCode())) {
cellTemplate.setRowName(POIUtil.getCellFormulaString(cell));
}
cellTemplate.setColumnIndex(c);
......@@ -438,11 +512,11 @@ public class TemplateGroupServiceImpl extends AbstractService {
//todo: 这里没有Config数据只有在上传模板以后,在界面里面可以配置公式
if (!cell.getCellStyle().getLocked() && hasKeyIn(cell)) {
cell.setCellValue(StringUtils.EMPTY);
if(allowManual){
if (allowManual) {
addManualConfig(cellTemplate, template, cell, now, cellTemplateConfigList);
}
}
if(!cell.getCellStyle().getLocked() && StringUtils.isNotBlank(POIUtil.getCellFormulaString(cell))) {
if (!cell.getCellStyle().getLocked() && StringUtils.isNotBlank(POIUtil.getCellFormulaString(cell))) {
CellTemplateConfig config = new CellTemplateConfig();
config.setId(distributedIdService.nextId());
config.setCellTemplateId(cellTemplate.getId());
......@@ -561,8 +635,8 @@ public class TemplateGroupServiceImpl extends AbstractService {
throw new ServiceException(TemplateMessage.TemplateGroupNameExist);
}
try {
TemplateGroup templateGroup=new TemplateGroup();
CommonUtils.copyProperties(templateGroupDto,templateGroup);
TemplateGroup templateGroup = new TemplateGroup();
CommonUtils.copyProperties(templateGroupDto, templateGroup);
Long newGroupId = distributedIdService.nextId();
Date now = new Date();
templateGroup.setId(newGroupId);
......@@ -585,6 +659,7 @@ public class TemplateGroupServiceImpl extends AbstractService {
/**
* 替换占位符
*
* @param cell cell
* @return Boolean
*/
......
......@@ -123,6 +123,12 @@ public class TemplateServiceImpl extends AbstractService {
example.createCriteria().andProjectIdEqualTo(projectId).andTemplateIdEqualTo(templateId).andPeriodEqualTo(period);
return periodTemplateMapper.selectByExample(example);
}
public List<PeriodTemplate> getTemplates(Long templateId){
PeriodTemplateExample example = new PeriodTemplateExample();
example.createCriteria().andTemplateIdEqualTo(templateId);
return periodTemplateMapper.selectByExample(example);
}
public String getTemplatePath(Long templateId) {
String result = "";
......
......@@ -24,6 +24,7 @@ import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -151,7 +152,6 @@ public class FormulaAgent {
}
public static String buildSql(String tableName, String getField, String filter, String filterValue, Integer period, Integer year, FormulaContext formulaContext) {
/*
......@@ -184,11 +184,11 @@ public class FormulaAgent {
String sql = "";
//统一判断年度
year = formulaContext.getYear() + year;
if(getSql){
if (getSql) {
tableName = tableName.toLowerCase();
sql = "select * from " + tableName + " where 1=1 and " + filter + filterValue;
return sql + " and project_id = '" + formulaContext.getProjectId() + "'";
}else{
} else {
sql = "select sum(" + getField + ") as " + getField + " from " + tableName + " where 1=1 and " + filter + filterValue;
}
String _p = insertZero(formulaContext.getPeriod() - Math.abs(period));
......@@ -237,8 +237,16 @@ public class FormulaAgent {
public BigDecimal getTableDataByName(String tableName, String getField, String filter, String filterValue, Integer period, Integer year, FormulaContext formulaContext) {
Map<String, Object> stringObjectMap = jdbcTemplate.queryForMap(buildSql(TableRule.map.get(tableName), getField, filter, filterValue, period, year, formulaContext));
Map<String, Object> stringObjectMap = new HashMap<>();
try {
stringObjectMap = jdbcTemplate.queryForMap(buildSql(TableRule.map.get(tableName), getField, filter, filterValue, period, year, formulaContext));
if (stringObjectMap.get(getField) != null) {
return new BigDecimal(stringObjectMap.get(getField).toString());
}
} catch (Exception e) {
e.printStackTrace();
return new BigDecimal(0);
}
/* for (int i = 0, j = stringObjectMap.size(); i < j; i++) {
if (i == 1) {
if(stringObjectMap.get(i).get(StringUtil.underline2Camel(getField)) == null){
......@@ -256,28 +264,26 @@ public class FormulaAgent {
}
}
*/
if(stringObjectMap.get(getField) != null ){
return new BigDecimal(stringObjectMap.get(getField).toString());
}
return new BigDecimal(0);
}
/**
* 获取期末余额
* @author zhikai.z.wei
*
* @param subjectType
* @param subjectCode
* @param year
* @param period
* @param formulaContext
* @return
* @author zhikai.z.wei
*/
public BigDecimal getQMYE(Integer subjectType, String subjectCode, Integer year, Integer period, FormulaContext formulaContext){
public BigDecimal getQMYE(Integer subjectType, String subjectCode, Integer year, Integer period, FormulaContext formulaContext) {
Project project = projectMapper.selectByPrimaryKey(formulaContext.getProjectId());
CitTbamExample citTbamExample = new CitTbamExample();
citTbamExample.createCriteria().andAccountCodeEqualTo(subjectCode).andPeriodEqualTo(year+ project.getYear());
citTbamExample.createCriteria().andAccountCodeEqualTo(subjectCode).andPeriodEqualTo(year + project.getYear());
List<CitTbam> citTbams = citTbamMapper.selectByExample(citTbamExample);
if(citTbams == null || citTbams.isEmpty()){
if (citTbams == null || citTbams.isEmpty()) {
return new BigDecimal(0.0);
}
return citTbams.get(0).getEndingBalance();
......
......@@ -12,9 +12,11 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.POIUtil;
......@@ -29,10 +31,12 @@ import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.dpo.ReportDto;
import pwc.taxtech.atms.dto.FileDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.PeriodReportDto;
import pwc.taxtech.atms.dto.ReportAttachDto;
import pwc.taxtech.atms.dto.didiFileUpload.DidiFileIUploadParam;
import pwc.taxtech.atms.dto.didiFileUpload.DidiFileUploadDetailResult;
import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.dto.vatdto.dd.ProfitLossStatementExportDto;
import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.exception.NotFoundException;
......@@ -296,42 +300,42 @@ 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);
assembleInvoiceRecord(projectId, period);
clearPeriodData(projectId, period, exceptTemplateIds, isMergeManualData);
copyTemplateAndConfigFromAdmin(projectId, templates, period);
setStatus(job, STATUS_END);
periodJobMapper.updateByPrimaryKey(job);
}
public void assembleInvoiceRecord(String projectId,Integer period){
public void assembleInvoiceRecord(String projectId, Integer period) {
Project project = projectMapper.selectByPrimaryKey(projectId);
MyAsserts.assertNotNull(project, Exceptions.NOT_FOUND_REPORT_EXCEPTION);
String queryDate = project.getYear()+"-"+(period<10?("0"+period):(period+""));
String queryDate = project.getYear() + "-" + (period < 10 ? ("0" + period) : (period + ""));
RevenueTypeMappingExample mappingExample = new RevenueTypeMappingExample();
mappingExample.createCriteria().andOrgIdEqualTo(project.getOrganizationId()).
andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate).
andStatusEqualTo(0);
List<RevenueTypeMapping> mappingList = revenueTypeMappingMapper.selectByExample(mappingExample);
Map<String,Long> map = new HashMap<>();
for(RevenueTypeMapping mapping:mappingList){
if(!map.containsKey(mapping.getContent())){
Map<String, Long> map = new HashMap<>();
for (RevenueTypeMapping mapping : mappingList) {
if (!map.containsKey(mapping.getContent())) {
RevenueConfigExample configExample = new RevenueConfigExample();
configExample.createCriteria().andNameEqualTo(mapping.getRevenueTypeName()).
andStatusEqualTo(0).andOrgIdEqualTo(mapping.getOrgId()).
andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate);
List<RevenueConfig> configs = revenueConfigMapper.selectByExample(configExample);
if(CollectionUtils.isNotEmpty(configs)){
map.put(mapping.getContent(),configs.get(0).getId());
if (CollectionUtils.isNotEmpty(configs)) {
map.put(mapping.getContent(), configs.get(0).getId());
}
}
if(map.containsKey(mapping.getContent())){
if (map.containsKey(mapping.getContent())) {
InvoiceRecord destRecord = new InvoiceRecord();
destRecord.setRevenueCofId(map.get(mapping.getContent()));
InvoiceRecordExample recordExample = new InvoiceRecordExample();
recordExample.createCriteria().andProjectIdEqualTo(projectId)
.andOrganizationIdEqualTo(mapping.getOrgId()).andBillingContentEqualTo(mapping.getContent()).
andPeriodEqualTo(Integer.valueOf(queryDate.replace("-","")));
invoiceRecordMapper.updateByExampleSelective(destRecord,recordExample);
andPeriodEqualTo(Integer.valueOf(queryDate.replace("-", "")));
invoiceRecordMapper.updateByExampleSelective(destRecord, recordExample);
}
}
}
......@@ -436,13 +440,13 @@ public class ReportServiceImpl extends BaseService {
if (cell == null) {
continue;//todo cell == null 如何处理
}
if (r <= addRowIndex+1) {
String cellId = projectId+template.getId()+period+r+c;
if((r-1)>=0&&(r-1)<configIds.size()){
cellId += configIds.get(configIds.size()-r);
if (r <= addRowIndex + 1) {
String cellId = projectId + template.getId() + period + r + c;
if ((r - 1) >= 0 && (r - 1) < configIds.size()) {
cellId += configIds.get(configIds.size() - r);
}
Long cellTemplateId = Long.valueOf(cellId.hashCode());
cellTemplateId = cellTemplateId<0?cellTemplateId:(cellTemplateId*-1);
cellTemplateId = cellTemplateId < 0 ? cellTemplateId : (cellTemplateId * -1);
//更新手工数据源
PeriodDataSourceExample delExample = new PeriodDataSourceExample();
delExample.createCriteria().andProjectIdEqualTo(projectId)
......@@ -458,7 +462,7 @@ public class ReportServiceImpl extends BaseService {
dataSource = new DataSourceExtendDto();
dataSource.setColumnIndex(c);
dataSource.setRowIndex(r);
periodDataSourceMapper.updateByExampleSelective(dataSource,updateExample);
periodDataSourceMapper.updateByExampleSelective(dataSource, updateExample);
PeriodCellTemplate cellTemplate = new PeriodCellTemplate();
cellTemplate.setPeriod(period);
cellTemplate.setRowName(POIUtil.getCellFormulaString(cell));
......@@ -475,7 +479,7 @@ public class ReportServiceImpl extends BaseService {
}
cellTemplate.setIsReadOnly(hasHandDatas.contains(c) ? 0 : 1);
cellTemplateList.add(cellTemplate);
if (r>0&&hasFormulaDatas.contains(c) && StringUtils.isNotBlank(POIUtil.getCellFormulaString(cell))) {
if (r > 0 && hasFormulaDatas.contains(c) && StringUtils.isNotBlank(POIUtil.getCellFormulaString(cell))) {
PeriodCellTemplateConfig periodCellTemplateConfig = new PeriodCellTemplateConfig();
periodCellTemplateConfig.setId(distributedIdService.nextId());
periodCellTemplateConfig.setPeriod(period);
......@@ -495,7 +499,7 @@ public class ReportServiceImpl extends BaseService {
fixedAccountCode(periodCellTemplateConfig);
cellTemplateConfigList.add(periodCellTemplateConfig);
}
if (r>0&&r<=addRowIndex&&hasHandDatas.contains(c)) {
if (r > 0 && r <= addRowIndex && hasHandDatas.contains(c)) {
addManualConfig(cellTemplate, cell, now, cellTemplateConfigList);
}
} else {
......@@ -770,39 +774,40 @@ public class ReportServiceImpl extends BaseService {
periodTemplateMapper.batchInsert(periodTemplateList);
}
private String transNumber(int num,String result){
private String transNumber(int num, String result) {
if(num==0){
if (num == 0) {
return result;
}
int pre = num/26;// 取商
int res = num%26;// 取余数
if(res!=0){
result =(char)(res+'A'-1)+result;
}else{
result+='Z';
pre = pre -1;
int pre = num / 26;// 取商
int res = num % 26;// 取余数
if (res != 0) {
result = (char) (res + 'A' - 1) + result;
} else {
result += 'Z';
pre = pre - 1;
}
return transNumber(pre,result);
return transNumber(pre, result);
}
public Workbook assembleTaxWorkBook(Template template, Workbook tWorkbook, String projectId, Integer period) {
Sheet sheet = tWorkbook.getSheetAt(0);
Project project = projectMapper.selectByPrimaryKey(projectId);
RevenueConfigExample example = new RevenueConfigExample();
String queryDate = project.getYear()+"-"+(period>=10?period:("0"+period));
String queryDate = project.getYear() + "-" + (period >= 10 ? period : ("0" + period));
example.createCriteria().andOrgIdEqualTo(project.getOrganizationId()).
andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate).andStatusEqualTo(0);
example.setOrderByClause(" create_time ");
List<RevenueConfig> dataList = revenueConfigMapper.selectByExample(example);
//合计项map
Map<Integer,List<String>> sumMap = new HashMap<>();
sumMap.put(TaxesCalculateReportEnum.Column.Column_4.getIndex(),new ArrayList<>());
sumMap.put(TaxesCalculateReportEnum.Column.Column_5.getIndex(),new ArrayList<>());
sumMap.put(TaxesCalculateReportEnum.Column.Column_6.getIndex(),new ArrayList<>());
sumMap.put(TaxesCalculateReportEnum.Column.Column_7.getIndex(),new ArrayList<>());
sumMap.put(TaxesCalculateReportEnum.Column.Column_8.getIndex(),new ArrayList<>());
sumMap.put(TaxesCalculateReportEnum.Column.Column_9.getIndex(),new ArrayList<>());
sumMap.put(TaxesCalculateReportEnum.Column.Column_11.getIndex(),new ArrayList<>());
Map<Integer, List<String>> sumMap = new HashMap<>();
sumMap.put(TaxesCalculateReportEnum.Column.Column_4.getIndex(), new ArrayList<>());
sumMap.put(TaxesCalculateReportEnum.Column.Column_5.getIndex(), new ArrayList<>());
sumMap.put(TaxesCalculateReportEnum.Column.Column_6.getIndex(), new ArrayList<>());
sumMap.put(TaxesCalculateReportEnum.Column.Column_7.getIndex(), new ArrayList<>());
sumMap.put(TaxesCalculateReportEnum.Column.Column_8.getIndex(), new ArrayList<>());
sumMap.put(TaxesCalculateReportEnum.Column.Column_9.getIndex(), new ArrayList<>());
sumMap.put(TaxesCalculateReportEnum.Column.Column_11.getIndex(), new ArrayList<>());
List<Long> configIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(dataList)) {
......@@ -813,7 +818,7 @@ public class ReportServiceImpl extends BaseService {
configIds.add(config.getId());
Row row = POIUtil.createAndCloneRow(tWorkbook, sheet, 1, sourceRow);
row.getCell(TaxesCalculateReportEnum.Column.Column_1.getIndex()).setCellValue("1-" + (dataList.size()+1-rowIndex));
row.getCell(TaxesCalculateReportEnum.Column.Column_1.getIndex()).setCellValue("1-" + (dataList.size() + 1 - rowIndex));
row.getCell(TaxesCalculateReportEnum.Column.Column_2.getIndex()).setCellValue(config.getName());
row.getCell(TaxesCalculateReportEnum.Column.Column_3.getIndex()).setCellValue("PC(\"FilterDate1\",2)");
//判断帐载收入明细
......@@ -828,57 +833,57 @@ public class ReportServiceImpl extends BaseService {
} else {
row.getCell(TaxesCalculateReportEnum.Column.Column_4.getIndex()).setCellValue("");
}
row.getCell(TaxesCalculateReportEnum.Column.Column_5.getIndex()).setCellValue("KPSR(\""+config.getName()+"\",2,1)");
row.getCell(TaxesCalculateReportEnum.Column.Column_6.getIndex()).setCellValue("KPSR(\""+config.getName()+"\",2,2)");
row.getCell(TaxesCalculateReportEnum.Column.Column_7.getIndex()).setCellValue("KPSR(\""+config.getName()+"\",1,1)");
row.getCell(TaxesCalculateReportEnum.Column.Column_8.getIndex()).setCellValue("KPSR(\""+config.getName()+"\",1,2)");
row.getCell(TaxesCalculateReportEnum.Column.Column_5.getIndex()).setCellValue("KPSR(\"" + config.getName() + "\",2,1)");
row.getCell(TaxesCalculateReportEnum.Column.Column_6.getIndex()).setCellValue("KPSR(\"" + config.getName() + "\",2,2)");
row.getCell(TaxesCalculateReportEnum.Column.Column_7.getIndex()).setCellValue("KPSR(\"" + config.getName() + "\",1,1)");
row.getCell(TaxesCalculateReportEnum.Column.Column_8.getIndex()).setCellValue("KPSR(\"" + config.getName() + "\",1,2)");
if (1 == config.getTaxBase()) {//账载
row.getCell(TaxesCalculateReportEnum.Column.Column_9.getIndex()).setCellValue("WPNAME(\"VAT020\",\"B\",\""+config.getName()+"\",\"D\")");
row.getCell(TaxesCalculateReportEnum.Column.Column_9.getIndex()).setCellValue("WPNAME(\"VAT020\",\"B\",\"" + config.getName() + "\",\"D\")");
} else if (2 == config.getTaxBase()) {//开票收入
row.getCell(TaxesCalculateReportEnum.Column.Column_9.getIndex()).setCellValue("WPNAME(\"VAT020\",\"B\",\""+config.getName()+"\",\"E\")+"
+"WPNAME(\"VAT020\",\"B\",\""+config.getName()+"\",\"G\")");
row.getCell(TaxesCalculateReportEnum.Column.Column_9.getIndex()).setCellValue("WPNAME(\"VAT020\",\"B\",\"" + config.getName() + "\",\"E\")+"
+ "WPNAME(\"VAT020\",\"B\",\"" + config.getName() + "\",\"G\")");
} else if (3 == config.getTaxBase()) {//手工录入
} else if (4 == config.getTaxBase()) {//借方发生额
row.getCell(TaxesCalculateReportEnum.Column.Column_9.getIndex()).setCellValue("JFFS(\"" + config.getTbSegment3() + "\"," + project.getYear() + "," + period + ",1,,)");
} else if (5 == config.getTaxBase()) {//贷方发生额
row.getCell(TaxesCalculateReportEnum.Column.Column_9.getIndex()).setCellValue("DFFS(\"" + config.getTbSegment3() + "\"," + project.getYear() + "," + period + ",1,,)");
}else{
} else {
row.getCell(TaxesCalculateReportEnum.Column.Column_9.getIndex()).setCellValue("");
}
row.getCell(TaxesCalculateReportEnum.Column.Column_10.getIndex()).setCellValue(config.getTaxRate().multiply(new BigDecimal(100)).intValue() + "%");
row.getCell(TaxesCalculateReportEnum.Column.Column_11.getIndex()).setCellValue("WPNAME(\"VAT020\",\"B\",\""+config.getName()+"\",\"I\")*"
+"WPNAME(\"VAT020\",\"B\",\""+config.getName()+"\",\"J\")");
row.getCell(TaxesCalculateReportEnum.Column.Column_11.getIndex()).setCellValue("WPNAME(\"VAT020\",\"B\",\"" + config.getName() + "\",\"I\")*"
+ "WPNAME(\"VAT020\",\"B\",\"" + config.getName() + "\",\"J\")");
row.getCell(TaxesCalculateReportEnum.Column.Column_12.getIndex()).setCellValue(RevenueConfEnum.RevenueType.MAPPING.get(config.getRevenueType()));
row.getCell(TaxesCalculateReportEnum.Column.Column_13.getIndex()).setCellValue(RevenueConfEnum.TaxType.MAPPING.get(config.getTaxType()));
rowIndex++;
//组装合计项
sumMap.get(TaxesCalculateReportEnum.Column.Column_4.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_4.getIndex()+1,"")+rowIndex);
sumMap.get(TaxesCalculateReportEnum.Column.Column_5.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_5.getIndex()+1,"")+rowIndex);
sumMap.get(TaxesCalculateReportEnum.Column.Column_6.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_6.getIndex()+1,"")+rowIndex);
sumMap.get(TaxesCalculateReportEnum.Column.Column_7.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_7.getIndex()+1,"")+rowIndex);
sumMap.get(TaxesCalculateReportEnum.Column.Column_8.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_8.getIndex()+1,"")+rowIndex);
sumMap.get(TaxesCalculateReportEnum.Column.Column_9.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_9.getIndex()+1,"")+rowIndex);
sumMap.get(TaxesCalculateReportEnum.Column.Column_11.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_11.getIndex()+1,"")+rowIndex);
sumMap.get(TaxesCalculateReportEnum.Column.Column_4.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_4.getIndex() + 1, "") + rowIndex);
sumMap.get(TaxesCalculateReportEnum.Column.Column_5.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_5.getIndex() + 1, "") + rowIndex);
sumMap.get(TaxesCalculateReportEnum.Column.Column_6.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_6.getIndex() + 1, "") + rowIndex);
sumMap.get(TaxesCalculateReportEnum.Column.Column_7.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_7.getIndex() + 1, "") + rowIndex);
sumMap.get(TaxesCalculateReportEnum.Column.Column_8.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_8.getIndex() + 1, "") + rowIndex);
sumMap.get(TaxesCalculateReportEnum.Column.Column_9.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_9.getIndex() + 1, "") + rowIndex);
sumMap.get(TaxesCalculateReportEnum.Column.Column_11.getIndex()).add(transNumber(TaxesCalculateReportEnum.Column.Column_11.getIndex() + 1, "") + rowIndex);
}
//组装合计项数据
assembleSumRow(sheet.getRow(rowIndex),sumMap);
assembleSumRow(sheet.getRow(rowIndex), sumMap);
}
assemblePeriodTemplate(template, tWorkbook, projectId, period, configIds);
return tWorkbook;
}
public void assembleSumRow(Row sumRow,Map<Integer,List<String>> sumMap){
Iterator<Map.Entry<Integer,List<String>>> iterator = sumMap.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry<Integer,List<String>> entry = iterator.next();
public void assembleSumRow(Row sumRow, Map<Integer, List<String>> sumMap) {
Iterator<Map.Entry<Integer, List<String>>> iterator = sumMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Integer, List<String>> entry = iterator.next();
String sumStr = "Sum(";
for(String cellNum : entry.getValue()){
sumStr+=cellNum+",";
for (String cellNum : entry.getValue()) {
sumStr += cellNum + ",";
}
sumStr+=")";
sumStr = sumStr.replace(",)",")");
sumStr += ")";
sumStr = sumStr.replace(",)", ")");
sumRow.getCell(entry.getKey()).setCellValue(sumStr);
}
......@@ -1005,14 +1010,13 @@ public class ReportServiceImpl extends BaseService {
for (int j = 0; j < journalEntries.size(); j++) {
JournalEntry journalEntry = journalEntries.get(j);
AdjustmentTable adjustmentTable = adjustmentTables.get(j);
boolean boo = ("".equals(journalEntry.getSegment3()) && "".equals(adjustmentTable.getSegment3()) && "".equals(journalEntry.getSegment5()) && "".equals(adjustmentTable.getSegment5()) && "".equals(journalEntry.getSegment6()) && "".equals(adjustmentTable.getSegment6()));
if (journalEntry.getSegment3().equals(adjustmentTable.getSegment3()) &&
journalEntry.getSegment5().equals(adjustmentTable.getSegment5()) &&
journalEntry.getSegment6().equals(adjustmentTable.getSegment6()) && journalEntry.getPeriodJrMinDr() != adjustmentTable.getPeriodDrMixCr()) {
journalEntry.getSegment6().equals(adjustmentTable.getSegment6()) && journalEntry.getPeriodJrMinDr() != adjustmentTable.getPeriodDrMixCr() && !boo) {
setStatus(genJob, STATUS_ERROR);
Constant.ReportDataValidateLog reportDataValidateLog = new Constant.ReportDataValidateLog(journalEntries.get(j).getSegment3(), journalEntries.get(j).getSegment5(), journalEntries.get(j).getSegment6());
//记录校验结果
//
map.put("result", reportDataValidateLog.getResult(false));
map.put("validateResult", "error");
map.put("tmsPeriod", journalEntry.getTmsPeriod());
......@@ -1039,6 +1043,7 @@ public class ReportServiceImpl extends BaseService {
periodJobMapper.updateByPrimaryKey(genJob);
}
@Resource
private DataValidateLogMapper dataValidateLogMapper;
......@@ -1057,10 +1062,62 @@ public class ReportServiceImpl extends BaseService {
}
private String getProjId(String orgId, Integer tmsPeriod) {
ProjectExample pExample = new ProjectExample();
pExample.createCriteria().andOrganizationIdEqualTo(orgId).andYearEqualTo(tmsPeriod / 100);
List<Project> pList = projectMapper.selectByExample(pExample);
if (!pList.isEmpty()) {
return pList.get(0).getId();
}
return "";
}
public List<CellTemplateReferenceDto> getTemplateReferences(int period) {
return new ArrayList<>();
}
public OperationResultDto<ReportDataDto> getCellData(Long reportId, String orgId, Integer period) {
OperationResultDto<ReportDataDto> cellData = getCellData(reportId, getProjId(orgId, period));
cellData.getData().setEbitData(loadEbitDataFirst(orgId, period));//特殊因素考虑 默认为0 rate 默认为1%
return cellData;
}
public EbitDataDto loadEbitDataFirst(String orgId, Integer period){
EbitDataDto ebitDataDto = new EbitDataDto();
EbitCellDataExample example = new EbitCellDataExample();
EbitCellDataExample.Criteria criteria = example.createCriteria();
criteria.andOrganizationIdEqualTo(orgId);
criteria.andPeriodEqualTo(period);
List<EbitCellData> ebitCellData = ebitCellDataMapper.selectByExample(example);
for(EbitCellData ebitCellData1 : ebitCellData){
switch (ebitCellData1.getRow()){
case 37:
ebitDataDto.setSpecialConsiderations(ebitCellData1.getData());
break;
case 38:
ebitDataDto.setSpecialConsiderations(ebitCellData1.getData());
break;
case 39:
ebitDataDto.setSpecialFactors(new BigDecimal(ebitCellData1.getData()));
break;
case 40:
ebitDataDto.setEbitRate(Double.parseDouble(ebitCellData1.getData()));
break;
case 41:
ebitDataDto.setTransactionAmount(new BigDecimal(ebitCellData1.getData()));
break;
case 42:
ebitDataDto.setSixAddTax(ebitCellData1.getData());
break;
case 43:
ebitDataDto.setTotalAmountTax(new BigDecimal(ebitCellData1.getData()));
break;
}
}
return ebitDataDto;
}
public OperationResultDto<ReportDataDto> getCellData(Long reportId, String projectId) {
OperationResultDto resultDto = new OperationResultDto();
ReportDataDto dataDto = new ReportDataDto();
......@@ -1273,6 +1330,85 @@ public class ReportServiceImpl extends BaseService {
return resultDto;
}
@Autowired
private ProfitLossStatementFinalMapper profitLossStatementFinalMapper;
@Autowired
private EbitCellDataMapper ebitCellDataMapper;
//加载Ebit数据
public EbitDataDto loadEbitData(String orgId, Integer period, Integer specialConsiderations, String ebitRate) {
double rate = 0.1;
BigDecimal spec = new BigDecimal(0);
if (!ebitRate.isEmpty()) {
int _index = ebitRate.indexOf("%");
spec = new BigDecimal(specialConsiderations);
if (_index != -1) {
rate = Double.parseDouble(ebitRate.substring(0, _index - 1)) / 100;
} else {
rate = Double.parseDouble(ebitRate) / 100;
}
}
ProfitLossStatementExample example = new ProfitLossStatementExample();
ProfitLossStatementExample.Criteria criteria = example.createCriteria();
criteria.andOrganizationIdEqualTo(orgId);
criteria.andPeriodEqualTo(period);
List<ProfitLossStatement> profitLossStatements = profitLossStatementFinalMapper.selectByCondition(example);
BigDecimal yysr = new BigDecimal(0);//营业收入
BigDecimal yycb = new BigDecimal(0);//营业成本
BigDecimal yysjfj = new BigDecimal(0);//营业税金附加
BigDecimal xsfy = new BigDecimal(0);//销售费用
BigDecimal glfy = new BigDecimal(0);//管理费用
BigDecimal yffy = new BigDecimal(0);//研发费用
BigDecimal zcjzss = new BigDecimal(0); //资产减值损失
for (ProfitLossStatement profitLossStatement : profitLossStatements) {
BigDecimal value = profitLossStatement.getPeriodAmt();
switch (profitLossStatement.getItemName()) {
case "加:营业外收入":
yysr = value;
break;
case "减:营业外支出":
yycb = value;
case "营业税金及附加":
yysjfj = value;
break;
case "销售费用":
xsfy = value;
case "管理费用":
glfy = value;
break;
case "研发费用 ":
yffy = value;
case "资产减值损失":
zcjzss = value;
}
EbitDataDto ebitDataDto = new EbitDataDto();
BigDecimal subtract = yysr.subtract(yycb).subtract(yysjfj).subtract(xsfy).subtract(glfy).subtract(yffy).subtract(zcjzss);
ebitDataDto.setEbitSubtraction(subtract);
ebitDataDto.setSpecialFactors(subtract.add(spec));
ebitDataDto.setEbitRate(rate);
ebitDataDto.setTransactionAmount(ebitDataDto.getSpecialFactors().multiply(new BigDecimal(ebitDataDto.getEbitRate())));
ebitDataDto.setTransactionAmount(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.06)));
ebitDataDto.setTotalAmountTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.16)));
Date now = new Date();
/*//保存
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;
}
private Integer convertType(Integer dataSourceType) {
if (dataSourceType.equals(FormulaDataSourceDetailType.InputInvoiceDataSourceDto.getCode())) {
return CellDataSourceType.InputInvoice.getCode();
......@@ -1316,6 +1452,42 @@ public class ReportServiceImpl extends BaseService {
return resultDto;
}
/*
*
* EbitCellDataExample example1 = new EbitCellDataExample();
EbitCellDataExample.Criteria criteria = example1.createCriteria();
criteria.andPeriodEqualTo(period);
criteria.andProjectIdEqualTo(projectId);
criteria.andTemplateIdEqualTo(templateId.toString());
List<EbitCellData> ebitCellData = ebitCellDataMapper.selectByExample(example1);
if (!(ebitCellData.size() == 0)) {
report.get().setCellDataList(ebitCellData);
}
*/
public OperationResultDto<PeriodReportDto> getReportByTemplateEbit(Long templateId, Integer period, String projectId) {
projectId = "1942295d-6fe6-4aa7-b2e7-b66a5772697c";
period = 0;
OperationResultDto resultDto = new OperationResultDto();
try {
PeriodReportExample example = new PeriodReportExample();
example.createCriteria().andProjectIdEqualTo(projectId).andTemplateIdEqualTo(templateId).andPeriodEqualTo(period);
Optional<PeriodReport> report = periodReportMapper.selectByExample(example).stream().findFirst();
if (report.isPresent()) {
PeriodReportDto periodReportDto = new PeriodReportDto();
BeanUtils.copyProperties(report, periodReportDto);
resultDto.setResult(true);
resultDto.setData(periodReportDto);
} else {
resultDto.setResult(true);
resultDto.setResultMsg("can not find report");
}
} catch (Exception ex) {
logger.error(ex.getMessage());
resultDto.setResult(false);
}
return resultDto;
}
public OperationResultDto<PeriodCellTemplateConfig> getCellTemplateConfig(Long reportTemplateId, Integer periodParam,
int rowIndex, int columnIndex, String projectId) {
OperationResultDto resultDto = new OperationResultDto();
......@@ -1427,12 +1599,12 @@ public class ReportServiceImpl extends BaseService {
data.setCellId(cellData.getId());
} else {
PeriodCellData cellData = periodCellDataMapper.selectByPrimaryKey(data.getCellId());
if(StringUtils.isNotBlank(data.getKeyinData())){
if (StringUtils.isNotBlank(data.getKeyinData())) {
cellData.setKeyinData(data.getKeyinData());
if (StringUtils.isEmpty(cellData.getFormulaExp()))
cellData.setFormulaExp(data.getKeyinData());
periodCellDataMapper.updateByPrimaryKeySelective(cellData);
}else if (data.getAmount() != null && cellData.getData() != data.getAmount().toString()) {
} else if (data.getAmount() != null && cellData.getData() != data.getAmount().toString()) {
cellData.setData(data.getAmount().toString());
if (StringUtils.isEmpty(cellData.getFormulaExp()))
cellData.setFormulaExp(data.getAmount().toString());
......@@ -1453,7 +1625,7 @@ public class ReportServiceImpl extends BaseService {
PeriodDataSource dataSourceModel = null;
if (dataSourceExtendDtos.size() > 0) {
dataSourceModel = dataSourceExtendDtos.get(0).getDataSource();
if(StringUtils.isBlank(data.getKeyinData()))
if (StringUtils.isBlank(data.getKeyinData()))
updateCellValueForDataSourceChange(dataSourceModel, data.getAmount());
originalAmount = dataSourceModel.getAmount() != null ? dataSourceModel.getAmount() : new BigDecimal("0");
dataSourceModel.setName(data.getName());
......@@ -1535,7 +1707,7 @@ public class ReportServiceImpl extends BaseService {
dataSource.setUpdateTime(new Date());
periodDataSourceMapper.updateByPrimaryKeySelective(dataSource);
if (!cellData.getData().equals("#VALUE!")) {
if(StringUtils.isBlank(cellData.getData())) cellData.setData("0");
if (StringUtils.isBlank(cellData.getData())) cellData.setData("0");
cellData.setData(new BigDecimal(cellData.getData()).add(changeValue).toString());
} else {
cellData.setData(new BigDecimal("0.0").add(changeValue).toString());
......@@ -1543,7 +1715,7 @@ public class ReportServiceImpl extends BaseService {
//cellData.setFormulaExp(cellData.getData());
cellData.setUpdateTime(new Date());
periodCellDataMapper.updateByPrimaryKeySelective(cellData);
} else if(dataSource.getDescription().equals(cellName) && StringUtils.isNotBlank(data.getKeyinData())){
} else if (dataSource.getDescription().equals(cellName) && StringUtils.isNotBlank(data.getKeyinData())) {
dataSource.setKeyinData(data.getKeyinData());
dataSource.setUpdateBy("admin");
dataSource.setUpdateTime(new Date());
......@@ -1902,4 +2074,52 @@ public class ReportServiceImpl extends BaseService {
}
return objectOperationResultDto;
}
public void saveDatasource(String orgId, Integer period, Integer specialConsiderations, String ebitRate, OperationResultDto<ReportDataDto> operationResultDto) {
for (int i = 37; i <= 43; i++) {
EbitCellDataExample example = new EbitCellDataExample();
EbitCellDataExample.Criteria criteria = example.createCriteria();
criteria.andOrganizationIdEqualTo(orgId);
criteria.andPeriodEqualTo(period);
criteria.andColEqualTo(3);
criteria.andRowEqualTo(i);
List<EbitCellData> ebitCellData = ebitCellDataMapper.selectByExample(example);
if (ebitCellData.size() == 0) {
ebitCellDataMapper.insert(switchMeth(i, new EbitCellData(), operationResultDto, specialConsiderations, ebitRate, orgId,period));
} else {
ebitCellDataMapper.updateByExampleSelective(switchMeth(i, new EbitCellData(), operationResultDto, specialConsiderations, ebitRate, orgId, period), example);
}
}
}
private EbitCellData switchMeth(Integer i, EbitCellData ebitCellData1, OperationResultDto<ReportDataDto> operationResultDto, Integer specialConsiderations, String ebitRate, String orgId, Integer period) {
switch (i) {
case 37:
ebitCellData1.setData(operationResultDto.getData().getEbitData().getEbitSubtraction().toString());
ebitCellData1.setRow(i);
case 38:
ebitCellData1.setData(specialConsiderations.toString());
ebitCellData1.setRow(i);
case 39:
ebitCellData1.setData(operationResultDto.getData().getEbitData().getSpecialFactors().toString());
ebitCellData1.setRow(i);
case 40:
ebitCellData1.setData(ebitRate);
case 41:
ebitCellData1.setData(operationResultDto.getData().getEbitData().getTransactionAmount().toString());
ebitCellData1.setRow(i);
case 42:
ebitCellData1.setData(operationResultDto.getData().getEbitData().getSixAddTax());
ebitCellData1.setRow(i);
case 43:
ebitCellData1.setData(operationResultDto.getData().getEbitData().getTotalAmountTax().toString());
ebitCellData1.setRow(i);
}
ebitCellData1.setCol(3);
ebitCellData1.setCreateTime(new Date());
ebitCellData1.setOrganizationId(orgId);
ebitCellData1.setPeriod(period);
return ebitCellData1;
}
}
......@@ -61,16 +61,17 @@ public class RSUMIF extends FunctionBase implements FreeRefFunction {
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
parameterCheck(args, ec);
BigDecimal cellValue = BigDecimal.ZERO;
List<Object> dataSource = new ArrayList<>();
BigDecimal cellValue = BigDecimal.ZERO;
String filter = null;
String filterValue = null;
try {
parameterCheck(args, ec);
Map map = new HashMap<String, String>();
ReportCellTableSUMIFDataSourceDto reportCellTableSUMIFDataSourceDto = new ReportCellTableSUMIFDataSourceDto();
reportCellTableSUMIFDataSourceDto.insertData(ec, formulaContext);
String filter = null;
String filterValue = null;
dataSource.add(reportCellTableSUMIFDataSourceDto);
try {
tableName = resolverString(args, ec, 0);
getField = resolverString(args, ec, 1);
filter= resolverString(args, ec, 2);
......@@ -95,13 +96,9 @@ public class RSUMIF extends FunctionBase implements FreeRefFunction {
cellValue, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupId(), ec.getColumnIndex(), ec.getRowIndex(),
formulaContext.getProjectId(), selectShow(tableName), FormulaAgent._buildSql(getField,tableName,filter,filterValue,period,formulaContext,year, boo, true));
} catch (Exception e) {
e.printStackTrace();
}
try {
saveFormulaBlock(formulaContext.getPeriod(), ec,
new RSUMIFParasBo().getExpression(args, ec), cellValue, dataSourceId, formulaContext.getProjectId());
} catch (EvaluationException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
......
......@@ -40,7 +40,7 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="pwc.taxtech.atms.vat.dao" targetProject="../../src/main/java">
<property name="rootInterface" value="pwc.taxtech.atms.MyVatMapper" />
</javaClientGenerator>
<table tableName="invoice_record" domainObjectName="InvoiceRecord">
<table tableName="ebit_cell_data" domainObjectName="EbitCellData">
<property name="useActualColumnNames" value="false"/>
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
......
package pwc.taxtech.atms.dpo;
import pwc.taxtech.atms.vat.entity.EbitCellData;
import java.util.Date;
import java.util.List;
public class ReportDto {
private String id;
......@@ -14,6 +17,15 @@ public class ReportDto {
private String updater;
private Date updateTime;
private Integer reportType;
private List<EbitCellData> cellDataList;
public List<EbitCellData> getCellDataList() {
return cellDataList;
}
public void setCellDataList(List<EbitCellData> cellDataList) {
this.cellDataList = cellDataList;
}
public Integer getReportType() {
return reportType;
......
......@@ -107,7 +107,7 @@ public interface ProfitLossStatementFinalMapper extends MyVatMapper {
*/
int updateByPrimaryKey(ProfitLossStatement record);
List<ProfitLossStatement> selectByCondition(@Param("plCondition") ProfitLossStatementCondition condition);
List<ProfitLossStatement> selectByCondition(@Param("plCondition") ProfitLossStatementExample condition);
int insertBatch(List<ProfitLossStatement> pls);
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package pwc.taxtech.atms.vat.entity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
*
......@@ -18,7 +19,17 @@ public class PeriodReport implements Serializable {
*
* @mbg.generated
*/
private Long id;
private List<EbitCellData> cellDataList;
public List<EbitCellData> getCellDataList() {
return cellDataList;
}
public void setCellDataList(List<EbitCellData> cellDataList) {
this.cellDataList = cellDataList;
}
/**
*
......
......@@ -1679,6 +1679,7 @@ var analysisModule = angular.module('app.analysis', ['ui.grid', 'ui.router','ui.
}
},
resolve: scriptDependencyProvider.createDependenciesMap(scriptDependencyProvider.analysis),
deepStateRedirect: false,
sticky: true
});
......
......@@ -6,7 +6,7 @@
<!DOCTYPE html>
<html ng-app="app">
<head>
<base href="/" />
<base href="/"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8" http-equiv="X-UA-Compatible" content="chrome=1; IE=11; IE=10; IE=9; IE=EDGE">
<title>Apex+ ATMS</title>
......@@ -16,7 +16,7 @@
}
body {
font-family: "Microsoft YaHei",Arial,Helvetica,sans-serif,"宋体";
font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif, "宋体";
}
a.back-to-top {
......@@ -50,14 +50,14 @@
<!--@Styles.Render("~/bundles/framework.less")-->
<!--@Styles.Render("~/bundles/taxDocumentManage.less")-->
<link href="Content/bundle_content.css" rel="stylesheet" type="text/css" />
<link href="bundles/appresources.css" rel="stylesheet" type="text/css" />
<link href="bundles/appresources.less" rel="stylesheet" type="text/css" />
<link href="bundles/common.css" rel="stylesheet" type="text/css" />
<link href="bundles/common.less" rel="stylesheet" type="text/css" />
<link href="bundles/less/framework.less" rel="stylesheet" type="text/css" />
<link href="bundles/less/taxDocumentManage.less" rel="stylesheet" type="text/css" />
<link href="bundles/less/cit.less" rel="stylesheet" type="text/css" />
<link href="Content/bundle_content.css" rel="stylesheet" type="text/css"/>
<link href="bundles/appresources.css" rel="stylesheet" type="text/css"/>
<link href="bundles/appresources.less" rel="stylesheet" type="text/css"/>
<link href="bundles/common.css" rel="stylesheet" type="text/css"/>
<link href="bundles/common.less" rel="stylesheet" type="text/css"/>
<link href="bundles/less/framework.less" rel="stylesheet" type="text/css"/>
<link href="bundles/less/taxDocumentManage.less" rel="stylesheet" type="text/css"/>
<link href="bundles/less/cit.less" rel="stylesheet" type="text/css"/>
</head>
<body ng-controller="AppController">
<!--@Html.AntiForgeryToken()-->
......@@ -65,7 +65,7 @@
<app-nav></app-nav>
<div class="page-wrapper" style="position:relative;overflow-x:hidden;overflow-y:auto;margin-top:55px">
<div class="main-contents" ui-view></div>
<div class="data-import-contents" style="display: none" ui-view="importContent"></div>
<div class="data-import-contents" ui-view="importContent"></div><!--style="display: none"-->
</div>
<div class="clear"></div>
<atms-busy-indicator></atms-busy-indicator>
......@@ -130,12 +130,17 @@
}
});
// <!--if (JSON.parse(user_name.split('=')[1]).user_name.toLowerCase() === 'simon') {-->
// <!--window.location.href = '/#/overview/assetsManage';-->
// <!--}-->
// <!--else {-->
//
<!--if (JSON.parse(user_name.split('=')[1]).user_name.toLowerCase() === 'simon') {-->
//
<!--window.location.href = '/#/overview/assetsManage';-->
//
<!--}-->
//
<!--else {-->
window.location.href = '/#/overview/vat';
// <!--}-->
//
<!--}-->
// create the back to top button
$('body').prepend('<a href="#" class="back-to-top">Back to Top</a>');
......@@ -162,7 +167,7 @@
//$('.nav-element-left a').removeClass('active');
//$('#overview').addClass('active');
};
</script>
</script>
</body>
</html>
......@@ -2288,6 +2288,9 @@
"DriverType": "司机类型",
"FileExportSuccess": "文件下载成功!",
"FileExportFailed": "文件下载失败!",
"singleExport": "单体导出",
"manyExport":"批量导出",
"saveAndRefresh" : "保存并刷新",
"uploadProfileTable": "上传利润表",
"~MustBeEndOneApp": "我必须是最后一个!"
}
\ No newline at end of file
analysisModule.directive('tableReportSheet', ['$rootScope', '$log', '$timeout', '$q', 'templateService', 'enums', 'keyValueDataService', 'spreadJsTipService',
'$interval', 'vatSessionService',
function ($rootScope, $log, $timeout, $q, templateService, enums, keyValueDataService, spreadJsTipService, $interval, vatSessionService) {
'use strict';
$log.debug('tableReportSheet.ctor()...');
return {
restrict: 'E',
template: '<div class="report" style="height: 100%;"></div>',
replace: true,
scope: {
templateId: '=',
spread: '=',
reportSource: '=',
formulaBlocks: '=',
manualDataSources: '=',
isReadOnly: '=',
serviceType: '=',
initRow: '=?',
initCol: '=?',
reportApi: '=?', // In: onCellClick, onCellDoubleClick; Out: refreshReport,
relation : '='
},
link: function (scope, element) {
$log.debug('vatReportSheet.link()...');
// Register api functions in internalApi
// If selectorApi passed is not undefined, we will use it as internalApi
scope.internalApi = scope.reportApi || {};
scope.projectYear = vatSessionService.year;
scope.projectPeriod = scope.serviceType === enums.serviceType.VAT ? vatSessionService.month : 0;
scope.$watch('templateId', function (newVal, oldValue) {
if (newVal !== oldValue) {
loadSheet(newVal);
}
});
scope.$watchGroup(['reportSource', 'formulaBlocks', 'manualDataSources', 'templateId'], function (newVal, oldValue) {
if (scope.templateId && scope.reportSource && scope.hasLoadSpread) {
setData();
}
});
var profileList = ["EBIT考虑资产减值损失", "加:特殊因素考虑", "EBIT(考虑特殊因素)", "EBIT rate", "关联交易金额", "6%增值税", "价税合计金额"];
// 首次进入页面时,通过promise模式保证在加载完成后再调用locateCell以focus在特定单元格
// 如果是在当前页面要focus在特定单元格,通过watch行列号来完成
scope.$watchGroup(['initRow', 'initCol'], function (newVal, oldVal) {
if (_.isNumber(scope.initRow) && _.isNumber(scope.initCol)) {
var spreadCtrl = getSpreadControl();
if (spreadCtrl) {
locateCell(spreadCtrl);
}
spreadCtrl = null;
}
});
var locateCell = function (spread, forceCloseModal) {
if (_.isNumber(scope.initRow) && _.isNumber(scope.initCol)) {
var sheet;
if (constant.regesterInformation.active) {
sheet = spread.getActiveSheet();
}
else {
sheet = spread.getSheet(1);
}
//var sheet = spread.getActiveSheet();
//var sheet = spread.getSheet(1);
sheet.setSelection(scope.initRow, scope.initCol, 1, 1);
if (_.isFunction(scope.internalApi.onCellClick) && !forceCloseModal) {
scope.internalApi.onCellClick({
'args': {row: scope.initRow, col: scope.initCol},
'data': JSON.parse(sheet.getTag(scope.initRow, scope.initCol))
});
}
$log.debug(sheet.getTag(scope.initRow, scope.initCol));
scope.initRow = null;
scope.initCol = null;
sheet = null;
return $q.when();
}
};
scope.$watchGroup(['relation.period', 'relation.orgId', 'relation.data'], function(newValue, oldValue){
if(scope.relation.orgId != null && scope.relation.period != null && scope.spread != undefined){
setData("true")
}
});
var loadSheet = function (templateId, init) {
//var prokjectId = vatSessionService.project.id;
//var period = vatSessionService.month;
if(scope.relation.orgId == undefined){
scope.relation.orgId = "-1";
}
if(!init){
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);
});
}
}, function (data) {
$log.info(data);
});
}else{
return templateService.getPeriodTemplateJsonByInit(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);
});
}
}, function (data) {
$log.info(data);
});
}
};
var initSpreadExcel = function (reportSpread) {
var spread = getSpreadControl();
spread.suspendPaint();
spread.fromJSON(reportSpread);
spread.options.showVerticalScrollbar = true;
spread.options.showHorizontalScrollbar = true;
spread.options.scrollbarMaxAlign = true;
spread.options.scrollbarShowMax = true;
spread.options.tabNavigationVisible = true;
if (constant.regesterInformation.active) {
spread.options.tabEditable = false;
spread.options.tabStripVisible = false;
spread.options.newTabVisible = false;
}
spread.options.allowUndo = false;
spread.options.allowUserResize = false;
spread.options.allowUserDragDrop = false;
spread.options.allowUserDragFill = false;
spread.options.allowUserEditFormula = false;
spread.options.allowContextMenu = false;
initInterFunction(spread);
//todo:注册之后这里去掉注释
//var sheet = spread.getActiveSheet();
var sheet;
if (constant.regesterInformation.active) {
sheet = spread.getActiveSheet();
}
else {
sheet = spread.getSheet(1);
}
if (sheet != null) {
sheet.options.rowHeaderVisible = true;
sheet.options.colHeaderVisible = true;
sheet.options.gridline.showVerticalGridline = false;
sheet.options.gridline.showHorizontalGridline = false;
sheet.options.isProtected = true;
if (scope.isReadOnly) {
setEditable(spread, true, false);
}
sheet.clearSelection();
}
spread.resumePaint();
scope.spread = spread;
if (scope.templateId && scope.reportSource && scope.hasLoadSpread) {
setData("false");
}
return $q.when(spread);
};
var setEditable = function (spread, isReadOnly, ifSuspend) {
//todo:注册之后这里去掉注释
var sheet;
if (constant.regesterInformation.active) {
sheet = spread.getActiveSheet();
}
else {
sheet = spread.getSheet(1);
}
if (sheet != null) {
if (ifSuspend) {
spread.suspendPaint();
}
}
// isReadOnly为true时,设置整个sheet不可编辑
if (isReadOnly) {
for (var row = 0; row < sheet.getRowCount(); row++) {
for (var column = 0; column < sheet.getColumnCount(); column++) {
try {
sheet.getCell(row, column).locked(true);
}
catch (e) {
}
}
}
}
else {
// isReadOnly为false时,设置无配置单元格不可编辑,有配置单元格可编辑
for (var i = 0; i < scope.reportSource.length; i++) {
var cell = scope.reportSource[i];
sheet.getCell(cell.rowIndex, cell.columnIndex).locked(false);
}
for (var x = 0; x < sheet.getRowCount(); x++) {
for (var y = 0; y < sheet.getColumnCount(); y++) {
var idx = _.findIndex(scope.reportSource, {rowIndex: x, columnIndex: y});
if (idx < 0) {
sheet.getCell(x, y).locked(true);
}
}
}
}
sheet.options.isProtected = true;
sheet.options.protectionOptions = {
allowEditObjects: false
};
if (sheet != null) {
if (ifSuspend) {
spread.resumePaint();
}
}
};
// 每个单元格大致由以下部分构成:_SumAll(_Inter(...)+_Manual(...)+C1)
// _Inter: IronPython公式计算结果
// _Manual: 手工数据源值
// C1: 类似的Excel公式,通过SpreadJS公式引擎计算
var initInterFunction = function (spread) {
var activeSheet;
if (constant.regesterInformation.active) {
activeSheet = spread.getActiveSheet();
}
else {
activeSheet = spread.getSheet(1);
}
var manualFunc = function () {
};
manualFunc.prototype = new GC.Spread.CalcEngine.Functions.Function("_Manual", 1, 1);
manualFunc.prototype.evaluate = function (args) {
if (!_.isString(args)) {
return "#VALUE!";
}
//var cellTemplateID = Number(args);
var ds = _.where(scope.manualDataSources, {item1: args});
if (!_.isEmpty(ds)) {
return _.reduce(ds, function (memo, x) {
if (x.item2.dataSourceType === 6) {
var rtn = x.item2.amount;
rtn = PWC.tryParseStringToNum(rtn);
// 如果是数值数据源,只有OperationType为2时,该数据源的数值应被减去;其他情况下应被加上
if (_.isNumber(rtn) && !isNaN(rtn)) {
var operationType = x.item2.operationType;
rtn = operationType === 2 ? (-rtn) : rtn;
}
return memo + rtn;
}
else {
return memo;
}
}, 0);
}
return 0;
};
//var sumAllFunc = function () { };
//sumAllFunc.prototype = new GcSpread.Sheets.Calc.Functions.Function("_SumAll", 1, 255);
//sumAllFunc.prototype.evaluate = function (args) {
// if (args.length < 1) {
// return "";
// }
// var rtn = args[0];
// if (args.length === 1 && (_.isNull(rtn) || _.isUndefined(rtn))) {
// rtn = "";
// }
// else {
// // 下面这种奇怪的写法是为了保证在reduce过程中累计值的类型正确
// rtn = _.reduce(args.slice(1), function (memo, x) {
// return memo + x;
// }, rtn);
// }
// return rtn;
//};
spread.clearCustomFunctions();
//spread.addCustomFunction(new interFunc());
activeSheet.addCustomFunction(new manualFunc());
//spread.addCustomFunction(new sumAllFunc());
};
var layoutChangedFunc = scope.$on(enums.vatEvent.layoutChanged, function () {
repaintSpread();
});
// TODO: 手工修改单元格值之后,更新单元格状态
var cellValueModifiedFunc = $rootScope.$on('cellValueModified', function (event, args) {
var modifiedReportCell = args.modifiedReportCell;
var cell = scope.reportSource.filter(function (data) {
return data.rowIndex === modifiedReportCell.row && data.columnIndex === modifiedReportCell.col;
})[0];
cell.value = modifiedReportCell.value;
cell.isModified = true;
cell.modifiedReportCell = modifiedReportCell;
setData();
});
var cellValueResetFunc = $rootScope.$on('cellValueReset', function (event, args) {
var cell = scope.reportSource.filter(function (data) {
return data.rowIndex === args.row && data.columnIndex === args.col;
})[0];
cell.value = cell.modifiedReportCell ? cell.modifiedReportCell.originalValue : cell.value;
cell.isModified = false;
cell.modifiedReportCell = null;
setData();
});
scope.$on('$destroy', function () {
layoutChangedFunc();
cellValueModifiedFunc();
cellValueResetFunc();
});
// Get spreadJS control.
var getSpreadControl = function () {
return new GC.Spread.Sheets.Workbook(getSpreadControlElement());
};
// Get spreadJS control element
var getSpreadControlElement = function () {
//var elem = document.getElementsByClassName('report-view');
var elem = document.getElementById('r_' + scope.templateId);
if (!elem) {
var elems = document.getElementsByClassName('report');
if (!elems || elems.length === 0) {
return undefined;
}
return elems[0];
}
return elem;
};
var repaintSpread = function () {
return $timeout(function () {
var spread = getSpreadControl();
if (spread && spread.refresh) {
spread.refresh();
}
}, 50);
};
// 根据已有信息通过spreadJS计算各单元格的值
var setData = function (saveAndRefresh) {
var sheet = scope.spread.sheets[0];
var isExportData = false;
if (angular.isArray(scope.reportSource)) {
spreadJsTipService.initialize(sheet);
if (!scope.isReadOnly) {
setEditable(scope.spread, false, true);
}
scope.reportSource.forEach(function (data) {
//fix bug11737 导出需要显示千分位
// 避免直接使用data.value = parseFloat(data.value)导致非数字型value无法显示
data.value = PWC.tryParseStringToNum(data.value);
if (data.isExportData) {//导出报表时,设置单元格的公式信息
isExportData = true;
if (data.isFormula) {
//获取单元格除公式值之外的剩余值
var subValue = 0;
if (data.dataSourceList && data.dataSourceList.length > 0) {
data.dataSourceList.forEach(function (dataSource) {
var cellName = PWC.numToExcelChar(dataSource.rowIndex, dataSource.columnIndex);
if (dataSource.type != enums.formulaDataSourceType.Report && dataSource.amount) {
subValue += parseFloat(dataSource.amount + '');
}
});
}
sheet.setFormula(data.rowIndex, data.columnIndex, '=' + data.formula + (subValue ? ('+' + subValue) : ''));
} else {
sheet.setValue(data.rowIndex, data.columnIndex, data.value);
}
} else { // 显示报表时,设置单元格的值或公式
var cell = sheet.getCell(data.rowIndex, data.columnIndex);
if (data.isModified
|| (data.dataVoucherList && data.dataVoucherList.length)
|| (data.dataInvoiceList && data.dataInvoiceList.length)
|| (data.dataSourceList && data.dataSourceList.length
&& _.some(data.dataSourceList, function (dataSource) {
return dataSource.dataSourceType === 6 && dataSource.amount
}))
) { // 存在用户手工输入值,需要改变底色
cell.backColor('#fbe8cc');
}
if (!_.isEmpty(data.dataSourceList)) {
var reports = _.chain(data.dataSourceList)
.where({type: enums.formulaDataSourceType.Report})
.map(function (x) {
return {
reportCode: x.reportCode,
year: x.year,
period: x.period
};
}).uniq(function (x) {
return x.reportCode + ',' + x.year + ',' + x.period;
}).value();
if (reports.length === 1) {
var drillDownArgs = _.findWhere(data.dataSourceList, {type: enums.formulaDataSourceType.Report});
if (drillDownArgs.period === scope.projectPeriod && drillDownArgs.year === scope.projectYear) {
// cell.textDecoration(GcSpread.Sheets.TextDecorationType.Underline);
cell.foreColor('blue');
}
}
}
// 设置顺序: 非数值字符串 -> 单元格值覆盖修改 -> 公式或手工数据源 -> 数值
var ifShowParseFloat = true; // 用于标识单元格是否设置成数值
if(data.dataSourceList && data.dataSourceList.length > 0 && data.dataSourceList[0].keyinData){
// sheet.getCell(data.rowIndex, data.columnIndex).cellType(new GC.Spread.Sheets.CellTypes.Text());
sheet.setValue(data.rowIndex, data.columnIndex, data.dataSourceList[0].keyinData+" ");
ifShowParseFloat = false; // 非数值字符串,单元格设置为字符串
// data.value = data.dataSourceList[0].keyinData;
}
// else if(_.isString(data.keyinData) && data.keyinData.length > 0 && isNaN(Number(data.keyinData))){
// sheet.setValue(data.rowIndex, data.columnIndex, data.keyinData);
// ifShowParseFloat = false; // 非数值字符串,单元格设置为字符串
// data.value = data.keyinData;
// }
else if (_.isString(data.value) && data.value.length > 0 && isNaN(Number(data.value))) {
sheet.setValue(data.rowIndex, data.columnIndex, data.value);
ifShowParseFloat = false; // 非数值字符串,单元格设置为字符串
}
else if (data.isModified) { // 覆盖修改,且新值是数字
if (_.isNumber(data.value) && !isNaN(data.value)) {
data.value = data.value.toFixed(4);
}
sheet.setValue(data.rowIndex, data.columnIndex, data.value);
ifShowParseFloat = false; // 单元格值覆盖修改
}
else if (!data.isReadOnly && !scope.isReadOnly) { // 非只读report(资料清单)且非只读单元格
ifShowParseFloat = true;
}
else if (data.cellTemplateConfig) {
var parsedFormula = data.cellTemplateConfig.parsedFormula;
if (data.cellTemplateConfig.hasInvoice || data.cellTemplateConfig.hasKeyIn
|| data.cellTemplateConfig.hasModel || data.cellTemplateConfig.hasVoucher) {
if (!_.isEmpty(parsedFormula)) {
parsedFormula = parsedFormula + '+_Manual("' + data.cellTemplateID + '")';
}
else {
parsedFormula = '_Manual("' + data.cellTemplateID + '")';
}
}
if (!_.isEmpty(parsedFormula)) {
parsedFormula = 'IFERROR(' + parsedFormula + ', "")';
sheet.setFormula(data.rowIndex, data.columnIndex, '=' + parsedFormula);
ifShowParseFloat = false; // 有公式或手工数据源,单元格设置为公式
}
}
if (ifShowParseFloat) {
if (_.isNumber(data.value) && !isNaN(data.value)) {
data.value = data.value.toFixed(4);
}
sheet.setValue(data.rowIndex, data.columnIndex, data.value); // 只有数值,设置为数值
}
}
sheet.setTag(data.rowIndex, data.columnIndex, JSON.stringify(data));
//设置 tooltip 和 图标信息
spreadJsTipService.setCellTipByCellData(sheet.getCell(data.rowIndex, data.columnIndex), data);
});
// 设置破折号单元格的值和显示格式,将其替换为带破折号格式的0值,这样引用到的其他单元格才能正常计算
var rowCount = sheet.getRowCount();
var columnCount = sheet.getColumnCount();
for (var r = 0; r < rowCount; r++) {
for (var c = 0; c < columnCount; c++) {
var cell = sheet.getCell(r, c);
if (cell.value() === '——') {
cell.value(0);
cell.formatter("[=0]——;0.00");
}
}
}
if(saveAndRefresh && saveAndRefresh == "false"){
loadEbitCell(sheet, false);
}else if ( saveAndRefresh && saveAndRefresh == "true"){
loadEbitCell(sheet, true);
}
spreadJsTipService.paintSheet(sheet);
}
};
//加载Ebit数据
var loadEbitCell = function(sheet, type){
for( var r = 37; r<= 43; r++ ){
for(var c = 1; c<=3; c++){
if( c == 1){
sheet.setValue(r,c, profileList[r-37]);
}
if(c == 3 && type){
if(r == 37){
sheet.setValue(r, c,scope.relation.data.ebitSubtraction);
}
if(r == 38){
sheet.setValue(r, c,scope.relation.data.specialConsiderations );
}
if(r == 39){
sheet.setValue(r, c,scope.relation.data.specialFactors);
}
if(r == 40){
sheet.setValue(r, c,scope.relation.data.ebitRate);
}
if(r == 41){
sheet.setValue(r, c,scope.relation.data.transactionAmount);
}
if(r == 42){
sheet.setValue(r, c,scope.relation.data.sixAddTax);
}
if(r ==43){
sheet.setValue(r, c,scope.relation.data.totalAmountTax);
}
}
}
}
}
// 更新数据源后,通过调用该方法计算所有当前sheet单元格,并通过比较原数据列表与spreadJS计算的新值列表,获取保存时需要修改库中Value的单元格信息列表
var updateCells = function () {
var sheet = getSpreadControl().sheets[0];
var cells = [];
var reportDataSources = _.chain(scope.reportSource)
.pluck('dataSourceList')
.flatten(true).value();
angular.forEach(scope.reportSource, function (x) {
// 比较刷新前后报表中的值的变化
// 优先将单元格转换成数值比较,如果不能则转换为字符串比较
var cell = sheet.getCell(x.rowIndex, x.columnIndex);
var newVal = cell.value();
newVal = PWC.tryParseStringToNum(newVal);
if (_.isBoolean(newVal)) {
newVal = newVal.toString();
}
else if (_.isNumber(newVal) && !isNaN(newVal)) {
newVal = newVal.toFixed(4);
}
if(x.keyinData){
sheet.setValue(x.rowIndex, x.columnIndex, x.keyinData);
}
var oldVal = x.value;
oldVal = PWC.tryParseStringToNum(oldVal);
if (_.isBoolean(oldVal)) {
oldVal = oldVal.toString();
}
else if (_.isNumber(oldVal) && !isNaN(oldVal)) {
oldVal = oldVal.toFixed(4);
}
if (newVal !== oldVal) {
cells.push({id: x.cellID, oldVal: oldVal, newVal: newVal});
x.value = newVal;
x.isDirty = true;
var dirtyDataSources = _.filter(reportDataSources, {
cellDataID: x.cellID,
name: 'ReportDataSource'
});
angular.forEach(dirtyDataSources, function (ds) {
newVal = PWC.tryParseStringToNum(newVal);
ds.amount = newVal;
});
sheet.setTag(x.rowIndex, x.columnIndex, JSON.stringify(x));
}
});
loadSheet(scope.templateId);
return cells;
};
(function initialize() {
loadSheet(scope.templateId, true);
if (scope.internalApi) {
scope.internalApi.refreshReport = updateCells;
}
})();
}
};
}
]);
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
<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="col-sm-6">
<span class="text-bold" translate="SelectedOrganization" style=" top: -11px; position: relative;">:</span>
<div id="dx-select-industry" class="tab-content-select industry " style=" display: inline-block;"
dx-select-box="dataSourceIndustryList" dx-item-alias="itemObj">
<div data-options="dxTemplate: { name: 'orgList' }" class="dx-item-content dx-list-item-content"
title="{{itemObj.name}}-{{itemObj.name}}">
{{itemObj.code}}-{{itemObj.name}}
</div>
</div>
</div>
<div class="col-sm-6" class="dateClass">
<span class="text-bold" translate="InvoiceQJ">:</span>
<div style=" display: inline-block;">
<input type="text" id="ebitDatepacker" class="datepicker" style="width:120px;height: 34px;"
readonly="readonly"/>
<i class="fa fa-calendar vat-subheader red-color" style="width:20px;"></i>
</div>
</div>
</div>
<div class="col-sm-5" class="bar-export" style=" margin-top: 20px;width: 39%; float: right;">
<span ng-click="uploadProfileTable()" ngf-select ngf-change="upload($files)" ngf-multiple="true"
ngf-validate="{size: {min:'10KB', max:'20MB'}}"><i class="fa fa-file">&nbsp;{{'uploadProfileTable' | translate}}</i></span>
<span ng-click="saveAndRefresh()"><i class="fa fa-refresh"></i>&nbsp;{{'saveAndRefresh' | translate}}</span>
<span ng-click="singleExport();"><i
class="fa fa-upload"></i>&nbsp;{{'singleExport' | translate}}</span>
<span ng-click="manyExport()"><i
class="fa fa-cloud-upload"></i>&nbsp;{{'manyExport' | translate}}</span>
</div>
</div>
<div class='report-container' id="reportContainer">
<input type="file" id="fileDemo" style="display: none" class="input">
<table-report-sheet report-source="reportData" spread='spread' template-id='templateId'
relation="relation">
</table-report-sheet>
</div>
</div>
\ No newline at end of file
analysisModule.directive('tbEbitForm', ['$log', 'enums',
function ($log, enums) {
'use strict';
$log.debug('tbEbitForm.ctor()...');
return {
restrict: 'E',
templateUrl: '/app/analysis/table/tb-ebit-form.html' + '?_=' + Math.random(),
scope: {
},
controller: 'tableReportSheetController',
link: function ($scope, $ele, $attr) {
}
};
}
]);
\ No newline at end of file
@import "~/app-resources/less/theme.less";
@color-red:#e20;
@color-gray:#939598-#222;
.bar-export{
span{
cursor: pointer;
}
}
.dxLeft{
width: 40%;
}
.dateClass{
position: relative;
left: -190px;
}
.vat-report-view {
height: calc(~"100% - 20px");
min-height: 500px;
margin-left: 0px;
margin-top: 0px;
.report-container {
border: @thin-border solid @color-border;
//height: calc(~"100% - 36px");
margin: 0;
width: 100%;
white-space: normal;
display: inline-block;
margin-top: -9px;
}
.row {
margin-left: 0px;
margin-bottom:10px;
&>span {
float: right;
margin-right: 15px;
cursor: pointer;
}
}
#addCertificatePop {
.modal-dialog {
width: 700px;
.add-certificate-pop-body {
height: 240px;
#add-certificate-grid {
height: 210px;
}
}
.modal-footer {
.template-1-button {
background-color: @color-red;
color: white;
margin-right:30px;
}
.template-2-button {
background-color: @color-gray;
color: white;
margin-right: 30px;
}
}
}
}
}
.model-report-approve-popup {
width: 400px;
height:500px;
position:fixed;
top:25%;
left:40%;
.modal-dialog {
width: 100%;
height: 90%;
margin: 20px auto;
.modal-content {
width: 100%;
.modal-body {
height: 90%;
}
}
}
}
.model-report-remarks-popup {
width: 400px;
height:500px;
position:fixed;
top:25%;
left:40%;
.modal-dialog {
width: 100%;
height: 90%;
margin: 20px auto;
.modal-content {
width: 100%;
.modal-body {
height: 90%;
}
}
}
}
......@@ -10,8 +10,6 @@
class="fa fa-floppy-o"></i>&nbsp;{{'上传手工数据'}}
</span>
<span ng-if="!isBSPL" ng-click="openExportPop('upload');"><i class="fa fa-upload"></i>&nbsp;{{'UploadExcel' | translate}}</span>
<!--<span ng-if="!isBSPL" ng-click="saveReportCache();"><i-->
<!--class="fa fa-floppy-o"></i>&nbsp;{{'Save' | translate}}</span>-->
</div>
......@@ -97,10 +95,6 @@
</script>
</div>
<!-- File Vouchers Upload Popup -->
<div class="modal fade" id="showVoucherUploadPortal" tabindex="-1" role="dialog" aria-labelledby="myModal"
data-backdrop="static" data-keyboard="false">
......
......@@ -52,7 +52,7 @@
if (!Number.prototype.formatAmount) {
Number.prototype.formatAmount = function (decPlaces, type) {
if(type){
return Number(decPlaces.toString().toFixed(2));
return Number(decPlaces.toFixed(2));
}
decPlaces = isNaN(decPlaces = Math.abs(decPlaces)) ? 2 : decPlaces;
var n = this.toFixed(decPlaces);
......
......@@ -43,23 +43,29 @@
// citGetTemplate: function (projectId, period?)
updateConfig: function (projectId, ifDeleteManualDataSource, period, generator, isMergeManualDataSource) {
return $http.post('/Report/updateConfig/' + projectId + '/' + ifDeleteManualDataSource + '/' + period + '?generator=' + generator+ '&mergeManual='+isMergeManualDataSource, {}, apiConfig.createVat({ignoreLoadingBar: true}));
return $http.post('/Report/updateConfig/' + projectId + '/' + ifDeleteManualDataSource + '/' + period + '?generator=' + generator + '&mergeManual=' + isMergeManualDataSource, {}, apiConfig.createVat({ignoreLoadingBar: true}));
},
generate: function (projectId, templateId, ifDeleteManualDataSource, period, generator) {
return $http.post('/Report/generate/' + projectId + '/' + templateId + '/' + ifDeleteManualDataSource + '/' + period + '?generator=' + generator, {}, apiConfig.createVat({ignoreLoadingBar: true}));
},
generateAll: function (projectId, isMergeManualDataSource, period, generator) {
return $http.post('/Report/generateByTotal/' + projectId + '/' + isMergeManualDataSource + '/' + period + '?generator=' + generator , {}, apiConfig.createVat({ignoreLoadingBar: true}));
return $http.post('/Report/generateByTotal/' + projectId + '/' + isMergeManualDataSource + '/' + period + '?generator=' + generator, {}, apiConfig.createVat({ignoreLoadingBar: true}));
},
getRunningJob: function (projectId, period) {
return $http.get('/Report/getRunningJob/' + projectId+'/'+period, apiConfig.createVat());
return $http.get('/Report/getRunningJob/' + projectId + '/' + period, apiConfig.createVat());
},
getJobStatus: function (projectId, period, jobId) {
return $http.get('/Report/getJobStatus/' + projectId+'/'+period+'/'+jobId, apiConfig.createVat({ignoreLoadingBar: true}));
return $http.get('/Report/getJobStatus/' + projectId + '/' + period + '/' + jobId, apiConfig.createVat({ignoreLoadingBar: true}));
},
getReportData: function (reportId) {
return $http.get('/Report/reportData/' + reportId, apiConfig.createVat());
},
getReportEbitData: function (reportId, orgId, period) {
return $http.get('/Report/reportEbitData?reportId=' + reportId + '&orgId=' + orgId, +'&period=' + period, apiConfig.createVat());
} ,
saveAndRefresh: function (orgId, period, specialConsiderations, ebitRate) {
return $http.get('/Report/specialConsiderations?=' + orgId + '&period=' + period + "&specialConsiderations=" + specialConsiderations + "&ebitRate=" + ebitRate, apiConfig.createVat());
},
calculateKeyValue: function (projectId, period) {
return $http.post('/Report/calculateKeyValue/' + projectId + '/' + period, {}, apiConfig.createVat({ignoreLoadingBar: true}));
},
......@@ -95,7 +101,7 @@
vatOperationLogService.addOperationLog(logInfo);
data.dataSourceType = enums.cellDataSourceType.KeyIn;
return $q.when(data);
},function (data) {
}, function (data) {
logInfo.UpdateState = $translate.instant('ManualInputFail');
SweetAlert.error($translate.instant('PleaseContactAdministrator'));
return vatOperationLogService.addOperationLog(logInfo);
......@@ -163,7 +169,7 @@
return $http.post('/Report/citGenerate/byTotal/' + projectId + '/' + ifDeleteManualDataSource + '/' + 0
// 暂时将生成预缴表的period设置为0,等待完成新的预缴表生成逻辑 + period
+ '/' + enums.reportType.prepay
+ '?generator=' + generator, {}, apiConfig.createVat({ ignoreLoadingBar: true }));
+ '?generator=' + generator, {}, apiConfig.createVat({ignoreLoadingBar: true}));
},
citGenerateByType: function (projectId, ifDeleteManualDataSource, reportType, generator) {
var paramStr = '';
......@@ -171,7 +177,7 @@
paramStr = '/' + reportType;
}
return $http.post('/Report/citGenerate/byTotal/' + projectId + '/' + ifDeleteManualDataSource + '/0' + paramStr + '?generator=' + generator, {}, apiConfig.createVat({ ignoreLoadingBar: true }));
return $http.post('/Report/citGenerate/byTotal/' + projectId + '/' + ifDeleteManualDataSource + '/0' + paramStr + '?generator=' + generator, {}, apiConfig.createVat({ignoreLoadingBar: true}));
},
citGetTemplate: function (projectId, period) {
if (!_.isNumber(period)) {
......@@ -192,7 +198,7 @@
reportTypeParam = '/' + reportType;
}
return $http.post('/Report/citCalculateKeyValue/' + projectId + '/0' + reportTypeParam, {}, apiConfig.createVat({ ignoreLoadingBar: true }));
return $http.post('/Report/citCalculateKeyValue/' + projectId + '/0' + reportTypeParam, {}, apiConfig.createVat({ignoreLoadingBar: true}));
},
getReportByTemplateId: function (templateId, period) {
if (!_.isNumber(period)) {
......@@ -200,19 +206,32 @@
}
return $http.get('/Report/report/' + templateId + '/' + period, apiConfig.createVat());
},
getReportByTemplateIdEbit: function (templateId, period, orgId) {
if (!_.isNumber(period)) {
period = 0;
}
return $http.get('/Report/getReportByTemplateEbit/' + templateId + '/' + period + '/' + orgId, apiConfig.createVat());
},
getDataSourceDetailList: function (dataSourceId) {
return $http.get('/Report/getDataSourceDetailList/' + dataSourceId, apiConfig.createVat());
},
hasManualDataSource: function (projectId, period) {
return $http.get('/Report/hasManualDataSource/' + projectId+ '/' +period, apiConfig.createVat());
return $http.get('/Report/hasManualDataSource/' + projectId + '/' + period, apiConfig.createVat());
},
loadAttachList : function(activeSheet){
return $http.post('/Report/loadAttachList' , activeSheet, apiConfig.createVat());
loadAttachList: function (activeSheet) {
return $http.post('/Report/loadAttachList', activeSheet, apiConfig.createVat());
},
deleteAttach : function(id){
var config = { isBusyRequest: true };
deleteAttach: function (id) {
var config = {isBusyRequest: true};
return $http.get('/Report/deleteAttach?id=' + id, apiConfig.create(config));
},
getOrgLists: function () {
return $http.get('/Report/getOrgLists', apiConfig.createVat());
},
saveEbitModule: function () {
}
};
......
......@@ -14,16 +14,16 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
//}
};
var getPeriodTemplateJson = function (templateId,period,projectId) {
//return $http.get('/template/getTemplateJson?templateID=' + templateID, apiConfig.create());
//var url = '/template/getTemplateJson?templateID=' + templateID;
//var result = httpCacheService.get(url);
// if (result.finishedCache) {
// return result;
// } else {
return getJsonFromExcelForPeriod(templateId,period,projectId);
//}
};
var getPeriodTemplateJsonByOrg = function (templateId,period,orgId) {
return getJsonFromExcelForPeriod(templateId,period,orgId);
};
var getPeriodTemplateJsonByInit = function (templateId,period,orgId) {
return getJsonFromExcelForPeriod(templateId,period,orgId , true);
};
var getCookie = function (cname) {
var name = cname + "=";
......@@ -115,10 +115,49 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
};
var getJsonFromExcelForPeriod = function (templateID,period,projectId) {
var getJsonFromExcelForPeriod = function (templateID,period,projectId, init) {
var deferred = $q.defer();
var promise = deferred.promise;
var url = null;
if(!init){
url = loginContext.apiHost + constant.webapi.prefix + '/template/getPeriodTemplateJson?templateId=' + templateID+"&period="+period+"&projectId="+projectId;
}else{
url = loginContext.apiHost + constant.webapi.prefix + '/template/getPeriodTemplateJson?templateId=' + templateID;
}
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true); // 也可以使用POST方式,根据接口
xhr.responseType = "blob"; // 返回类型blob
var apiTokenObj = JSON.parse(getCookie('AtmsApiToken'));
var apiToken = apiTokenObj.access_token;
var tokenType = apiTokenObj.token_type;
xhr.setRequestHeader('Authorization', tokenType + ' ' + apiToken);
// 定义请求完成的处理函数,请求前也可以增加加载框/禁用下载按钮逻辑
xhr.onload = function () {
// 请求完成
if (this.status === 200) {
// 返回200
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);
//alert(e.errorMessage);
deferred.reject(e.errorMessage);
}, {});
}
};
// 发送ajax请求
xhr.send();
return promise;
};
var getJsonFromExcelForPeriodOrg = function (templateID,period,orgId) {
var deferred = $q.defer();
var promise = deferred.promise;
var url = loginContext.apiHost + constant.webapi.prefix + '/template/getPeriodTemplateJson?templateId=' + templateID+"&period="+period+"&projectId="+projectId;
var url = loginContext.apiHost + constant.webapi.prefix + '/template/getPeriodTemplateJsonOrg?templateId=' + templateID+"&period="+period+"&orgId="+orgId;
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true); // 也可以使用POST方式,根据接口
xhr.responseType = "blob"; // 返回类型blob
......@@ -169,6 +208,8 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
setRowColName: setRowColName,
getTemplateJson: getTemplateJson,
getPeriodTemplateJson:getPeriodTemplateJson,
getPeriodTemplateJsonByOrg :getPeriodTemplateJsonByOrg,
getPeriodTemplateJsonByInit : getPeriodTemplateJsonByInit,
downloadTemplate: function (fileType) {
return $http.get('/template/file/downloadTemplate?fileType=' + fileType , apiConfig.create({ responseType: 'arraybuffer' }));
},
......
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