Commit d9a72b6c authored by frank's avatar frank

Merge branch 'dev_frank' into 'dev'

add apis for report config

See merge request root/atms!12
parents 690ed87f 957b6bb2
......@@ -2,4 +2,5 @@ package pwc.taxtech.atms.constant;
public final class Constant {
public static final String Comma = ",";
public static final String Other = "其他";
}
package pwc.taxtech.atms.constant.enums;
public enum RegexMatchType {
CellNumber(1),
KeyValue (2),
Equal (3);
private Integer code;
RegexMatchType(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}
package pwc.taxtech.atms.constant.enums;
public enum RoleSource {
Unknown(0),
OrganizationLevel(1),
AreaLevel(2),
BusinessUnitLevel(3),
OriginalLevel(4),
DimensionLevel(5),
/**
* //维度的原始角色
*/
DimensionOriginalLevel(6),
/**
* //维度的附加角色
*/
DimensionExraLevel(7),
/**
* //机构的原始角色
*/
OrganizationOriginaLevel(8),
/**
* 机构的附加角色
*/
OrganizationExtraLevel(9);
private Integer code;
RoleSource(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}
......@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.dto.CellTemplateConfigDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.service.CellTemplateService;
import java.util.Collections;
......@@ -21,17 +22,35 @@ public class CellTemplateController {
@RequestMapping(value = "configList/{templateID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
List<CellTemplateConfigDto> GetConfigList(@PathVariable String templateID) {
if(StringUtils.isEmpty(templateID)){
return Collections.emptyList();
OperationResultDto<List<CellTemplateConfigDto>> GetConfigList(@PathVariable String templateID) {
OperationResultDto<List<CellTemplateConfigDto>> result = new OperationResultDto<>();
if (StringUtils.isEmpty(templateID)) {
result.setData(Collections.emptyList());
}
try {
return cellTemplateService.getCellConfigList(templateID);
} catch (Exception e) {
logger.error("CellTemplateController.GetCellConfigList", e);
}
return result;
}
@RequestMapping(value = "config/{cellTemplateID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto<CellTemplateConfigDto> GetConfig(@PathVariable String cellTemplateID) {
if (StringUtils.isEmpty(cellTemplateID)) {
return new OperationResultDto<>();
}
try {
return cellTemplateService.GetCellConfigList(templateID);
return cellTemplateService.getCellConfig(cellTemplateID);
} catch (Exception e) {
logger.error("GetCellConfigList",e);
logger.error("CellTemplateController.GetConfig", e);
}
return Collections.emptyList();
return new OperationResultDto<>();
}
}
......@@ -46,7 +46,7 @@ public class RuleEngineeConfigController {
@RequestMapping(value="taxRuleSetting/Save",method = RequestMethod.POST)
public void SaveTaxRuleSettings(@RequestBody BatchUpdateTaxRuleDto batchUpdateTaxRule) {
logger.debug("RuleEngineeConfigController SaveTaxRuleSettings");
ruleEngineeConfigService.SaveTaxRuleSettings(batchUpdateTaxRule);
ruleEngineeConfigService.savetaxrulesettings(batchUpdateTaxRule);
}
}
\ No newline at end of file
......@@ -6,10 +6,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.common.ApplicationException;
import pwc.taxtech.atms.dto.TemplateDto;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import pwc.taxtech.atms.service.TemplateService;
import javax.servlet.http.HttpServletResponse;
......@@ -21,7 +21,7 @@ import java.util.List;
@RestController
@RequestMapping(value = "api/v1/template")
public class TemplateController {
private static final Logger logger = LoggerFactory.getLogger(AccountController.class);
private static final Logger logger = LoggerFactory.getLogger(TemplateController.class);
@Autowired
TemplateService templateService;
......@@ -64,7 +64,7 @@ public class TemplateController {
}
filePath = this.getClass().getResource("").toURI().getPath();
String tempPath = filePath.substring(0,filePath.indexOf("classes")+"\\classes".length());
String tempPath = filePath.substring(0, filePath.indexOf("classes") + "\\classes".length());
templateFile = new File(tempPath + templateService.getTemplatePath(templateID));
try {
......@@ -73,11 +73,11 @@ public class TemplateController {
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;
int len = 0;
byte[] buffer = new byte[1024];
OutputStream out = response.getOutputStream();
while ((len=inputStream.read(buffer))>0){
out.write(buffer,0,len);
while ((len = inputStream.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
//FileCopyUtils.copy(inputStream, response.getOutputStream());
......@@ -98,6 +98,11 @@ public class TemplateController {
inputStream = null;
}
}
}
@RequestMapping(value = "getTemplateUniqList", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs) {
return templateService.getTemplateUniqList(serviceTypeID, payTaxType, reportType, industryIDs);
}
}
package pwc.taxtech.atms.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.service.TemplateFormulaService;
@RestController
@RequestMapping(value = "api/v1/templateFormula")
public class TemplateFormulaController {
@Autowired
TemplateFormulaService templateFormulaService;
private static final Logger logger = LoggerFactory.getLogger(TemplateFormulaController.class);
@RequestMapping(value = "validate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody OperationResultDto Validate(@RequestBody(required = false) String fromula) {
try {
return templateFormulaService.Validate(fromula);
} catch (Exception e) {
logger.error("TemplateFormulaController Valdate", e);
OperationResultDto result = new OperationResultDto();
result.setResult(false);
return result;
}
}
}
package pwc.taxtech.atms.dao;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import pwc.taxtech.atms.entitiy.Template;
import pwc.taxtech.atms.entitiy.TemplateExample;
......@@ -105,4 +108,14 @@ public interface TemplateMapper extends MyMapper {
* @mbg.generated
*/
int updateByPrimaryKey(Template record);
/**
* 获取TemplateUniqDto
* @param serviceTypeID
* @param payTaxType
* @param reportType
* @param indeustryIDs
* @return TemplateUniqDto List
*/
List<TemplateUniqDto> getTemplateUniqDtosByTemplateAndTemplateGroup(Map<String,Object> map);
}
\ No newline at end of file
package pwc.taxtech.atms.dto;
import pwc.taxtech.atms.constant.enums.RoleSource;
public class NameDto {
private String ID;
private String name;
private RoleSource RoleSource;
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package pwc.taxtech.atms.dto;
import org.apache.commons.lang3.StringUtils;
import pwc.taxtech.atms.constant.enums.RegexMatchType;
import java.util.AbstractMap;
public class RegexMatchObject {
/**
* GET(int columnIndex, int rowIndex);
*/
private String formularTemplate = "GET({0},{1})";
private String keyValueTemplate = "KeyValue(\"{0}\")";
private int index;
private int length;
private RegexMatchType matchType;
private AbstractMap.SimpleEntry<String, Integer> parameters;
private String expression;
private int fromNumberSystem26(String s) {
if (StringUtils.isEmpty(s)) {
return 0;
}
int n = 0;
for (int i = s.length() - 1, j = 1; i >= 0; i--, j *= 26) {
char c = Character.toUpperCase(s.charAt(i));
if (c < 'A' || c > 'Z') {
return 0;
}
n += ((int) c - 64) * j;
}
return n;
}
public String getFormularTemplate() {
return formularTemplate;
}
public void setFormularTemplate(String formularTemplate) {
this.formularTemplate = formularTemplate;
}
public String getKeyValueTemplate() {
return keyValueTemplate;
}
public void setKeyValueTemplate(String keyValueTemplate) {
this.keyValueTemplate = keyValueTemplate;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
public RegexMatchType getMatchType() {
return matchType;
}
public void setMatchType(RegexMatchType matchType) {
this.matchType = matchType;
}
public AbstractMap.SimpleEntry<String, Integer> getParameters() {
return parameters;
}
public void setParameters(AbstractMap.SimpleEntry<String, Integer> parameters) {
this.parameters = parameters;
}
public String getExpression() {
if (this.matchType.equals(RegexMatchType.CellNumber.getCode())) {
return String.format(formularTemplate, fromNumberSystem26(this.parameters.getKey()) - 1, parameters.getValue() - 1);
} else if (this.matchType.equals(RegexMatchType.KeyValue.getCode())) {
return String.format(keyValueTemplate, this.parameters.getKey().substring(1));
} else if (this.matchType.equals(RegexMatchType.Equal.getCode())) {
return "==";
}
return expression;
}
}
package pwc.taxtech.atms.dto;
public class TemplateUniqDto {
private String ID;
private String code;
private String name;
private Integer orderIndex;
private Integer reportType;
private String templateGroupID;
private String templateGroupName;
private String parentID;
private String parentName;
/**
* template type
*/
private Integer payTaxType;
private String industryIDs;
private String serviceTypeID;
private boolean isActiveAssociation;
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getOrderIndex() {
return orderIndex;
}
public void setOrderIndex(Integer orderIndex) {
this.orderIndex = orderIndex;
}
public Integer getReportType() {
return reportType;
}
public void setReportType(Integer reportType) {
this.reportType = reportType;
}
public String getTemplateGroupID() {
return templateGroupID;
}
public void setTemplateGroupID(String templateGroupID) {
this.templateGroupID = templateGroupID;
}
public String getTemplateGroupName() {
return templateGroupName;
}
public void setTemplateGroupName(String templateGroupName) {
this.templateGroupName = templateGroupName;
}
public String getParentID() {
return parentID;
}
public void setParentID(String parentID) {
this.parentID = parentID;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
public Integer getPayTaxType() {
return payTaxType;
}
public void setPayTaxType(Integer payTaxType) {
this.payTaxType = payTaxType;
}
public String getIndustryIDs() {
return industryIDs;
}
public void setIndustryIDs(String industryIDs) {
this.industryIDs = industryIDs;
}
public String getServiceTypeID() {
return serviceTypeID;
}
public void setServiceTypeID(String serviceTypeID) {
this.serviceTypeID = serviceTypeID;
}
public boolean getIsActiveAssociation() {
return isActiveAssociation;
}
public void setIsActiveAssociation(boolean isActiveAssociation) {
this.isActiveAssociation = isActiveAssociation;
}
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.CellTemplateConfigDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import java.util.List;
public interface CellTemplateService {
List<CellTemplateConfigDto> GetCellConfigList(String templateID);
OperationResultDto<List<CellTemplateConfigDto>> getCellConfigList(String templateID);
OperationResultDto<CellTemplateConfigDto> getCellConfig(String cellTemplateID);
}
......@@ -11,5 +11,5 @@ public interface RuleEngineeConfigService {
List<TaxRuleSettingDto> GetTaxRuleSetting();
void SaveTaxRuleSettings(BatchUpdateTaxRuleDto batchUpdateTaxRule);
void savetaxrulesettings(BatchUpdateTaxRuleDto batchUpdateTaxRule);
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.OperationResultDto;
public interface TemplateFormulaService {
OperationResultDto Validate(String formula);
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.TemplateDto;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import java.util.List;
......@@ -13,4 +14,6 @@ public interface TemplateService {
List<TemplateDto> get(String templateGroupID, Integer reportType);
String getTemplatePath(String templateID);
List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs);
}
......@@ -42,8 +42,8 @@ public final class CellConfigTranslater {
cellTemplateConfigDto.setIsReadOnly(isReadOnly);
cellTemplateConfigDto.setFormulaDescription(description);
Optional<CellTemplateConfig> formulaItem = configList.stream().filter(a -> a.getDataSourceType().equals(CellDataSourceType.valueOf("Formula"))).findFirst();
if (formulaItem != null) {
Optional<CellTemplateConfig> formulaItem = configList.stream().filter(a -> a.getDataSourceType().equals(CellDataSourceType.Formula.getCode())).findFirst();
if (formulaItem.isPresent()) {
cellTemplateConfigDto.setHasFormula(true);
cellTemplateConfigDto.setFormula(formulaItem.get().getFormula());
if (StringUtils.isEmpty(cellTemplateConfigDto.getFormulaDescription())
......@@ -54,8 +54,8 @@ public final class CellConfigTranslater {
cellTemplateConfigDto.setCellTemplateID(formulaItem.get().getCellTemplateID());
}
Optional<CellTemplateConfig> voucherItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("Voucher"))).findFirst();
if (voucherItem != null) {
Optional<CellTemplateConfig> voucherItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.Voucher.getCode())).findFirst();
if (voucherItem.isPresent()) {
cellTemplateConfigDto.setHasVoucher(true);
cellTemplateConfigDto.setVoucherKeyword(voucherItem.get().getVoucherKeyword() == null ? "" : voucherItem.get().getVoucherKeyword());
if (!StringUtils.isEmpty(voucherItem.get().getAccountCodes())) {
......@@ -63,8 +63,8 @@ public final class CellConfigTranslater {
}
}
Optional<CellTemplateConfig> invoiceItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("OutputInvoice")) || x.getDataSourceType().equals(CellDataSourceType.valueOf("InputInvoice")) || x.getDataSourceType().equals(CellDataSourceType.valueOf("CustomInvoice"))).findFirst();
if (invoiceItem != null) {
Optional<CellTemplateConfig> invoiceItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.OutputInvoice.getCode()) || x.getDataSourceType().equals(CellDataSourceType.InputInvoice.getCode()) || x.getDataSourceType().equals(CellDataSourceType.CustomInvoice.getCode())).findFirst();
if (invoiceItem.isPresent()) {
cellTemplateConfigDto.setHasInvoice(true);
cellTemplateConfigDto.setInvoiceType(invoiceItem.get().getInvoiceType());
cellTemplateConfigDto.setInvoiceAmountType(invoiceItem.get().getInvoiceAmountType());
......@@ -84,19 +84,19 @@ public final class CellConfigTranslater {
}
}
Optional<CellTemplateConfig> keyInItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("KeyIn"))).findFirst();
if (keyInItem != null) {
Optional<CellTemplateConfig> keyInItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.KeyIn.getCode())).findFirst();
if (keyInItem.isPresent()) {
cellTemplateConfigDto.setHasKeyIn(true);
}
Optional<CellTemplateConfig> modelItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("RelatedModel"))).findFirst();
if (modelItem != null) {
Optional<CellTemplateConfig> modelItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.RelatedModel.getCode())).findFirst();
if (modelItem.isPresent()) {
cellTemplateConfigDto.setHasModel(true);
cellTemplateConfigDto.setModelIDs(GetList(modelItem.get().getModelIDs()));
}
Optional<CellTemplateConfig> validationItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("Validation"))).findFirst();
if (validationItem != null) {
Optional<CellTemplateConfig> validationItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.Validation.getCode())).findFirst();
if (validationItem.isPresent()) {
cellTemplateConfigDto.setHasValidation(true);
cellTemplateConfigDto.setValidation(validationItem.get().getValidation());
cellTemplateConfigDto.setValidationDescription(validationItem.get().getValidationDescription());
......@@ -110,6 +110,6 @@ public final class CellConfigTranslater {
return null;
}
return Arrays.asList(joinString.split(Constant.Comma));
return new ArrayList<>(Arrays.asList(joinString.split(Constant.Comma)));
}
}
package pwc.taxtech.atms.service.impl;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dao.CellTemplateMapper;
import pwc.taxtech.atms.dto.CellTemplateConfigDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.entitiy.CellTemplate;
import pwc.taxtech.atms.entitiy.CellTemplateConfig;
import pwc.taxtech.atms.entitiy.CellTemplateConfigExample;
import pwc.taxtech.atms.entitiy.CellTemplateExample;
import pwc.taxtech.atms.service.CellTemplateService;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
......@@ -15,19 +19,56 @@ import java.util.stream.Collectors;
public class CellTemplateServiceImpl extends AbstractService implements CellTemplateService {
@Override
public List<CellTemplateConfigDto> GetCellConfigList(String templateID) {
List<CellTemplateConfigDto> result = new ArrayList<>();
public OperationResultDto<List<CellTemplateConfigDto>> getCellConfigList(String templateID) {
OperationResultDto<List<CellTemplateConfigDto>> result = new OperationResultDto<>();
CellTemplateExample example = new CellTemplateExample();
example.createCriteria().andReportTemplateIDEqualTo(templateID);
List<CellTemplate> cellTemplateList = cellTemplateMapper.selectByExample(example);
List<CellTemplateConfig> configList = cellTemplateConfigMapper.getCellTemplateConfigByTemplateID(templateID);
if (cellTemplateList.isEmpty()) {
result.setData(Collections.emptyList());
return result;
}
List<CellTemplateConfigDto> rData = new ArrayList<>();
for (CellTemplate x : cellTemplateList) {
result.add(GetConfigDto(x, configList.stream().filter(a -> a.getCellTemplateID().equalsIgnoreCase(x.getID())).collect(Collectors.toList())));
rData.add(GetConfigDto(x, configList.stream().filter(a -> a.getCellTemplateID().equalsIgnoreCase(x.getID())).collect(Collectors.toList())));
}
if (rData.size() > 0) {
result.setResult(true);
result.setData(rData);
} else {
result.setData(Collections.emptyList());
}
return result;
}
@Override
public OperationResultDto<CellTemplateConfigDto> getCellConfig(String cellTemplateID) {
OperationResultDto<CellTemplateConfigDto> result = new OperationResultDto<>();
CellTemplate config = cellTemplateMapper.selectByPrimaryKey(cellTemplateID);
if (config.equals(null)) {
result.setResultMsg("NoData");
return result;
}
CellTemplateConfigExample example = new CellTemplateConfigExample();
example.createCriteria().andCellTemplateIDEqualTo(cellTemplateID);
List<CellTemplateConfig> configList = cellTemplateConfigMapper.selectByExample(example);
result.setData(GetConfigDto(config, configList));
if (result.getData().equals(null)) {
result.setResultMsg("NoData");
return result;
}
result.setResult(true);
return result;
}
......
package pwc.taxtech.atms.service.impl;
import org.apache.commons.lang3.StringUtils;
import pwc.taxtech.atms.constant.enums.RegexMatchType;
import pwc.taxtech.atms.dto.RegexMatchObject;
import java.util.AbstractMap;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class FormulaHelper {
private Pattern regexPattern, equalPattern, keyValuePattern;
private String strPattern = "(?=\\+|-|\\*|/|,|\\(|$|)(?!\")(((?<columnNumber>[A-Z]{1,3})(?<rowNumber>[0-9]{1,7}))|(?<keyCode>@[a-zA-Z0-9.]{1,}))(?=\\+|-|\\*|/| |,|\\)|>|=|<|$|^)(?!\")";
private String strKeyValuePattern = "(?=\\+|-|\\*|/|,|\\(|$|)(?!\")(?<keyCode>@[a-zA-Z0-9.]{1,})(?=\\+|-|\\*|/| |,|\\)|>|=|<|$|^)(?!\")";
private String strEqualPattern = "(?<![<>])(?<equal>=)";
public FormulaHelper() {
regexPattern = Pattern.compile(strPattern);
equalPattern = Pattern.compile(strEqualPattern);
keyValuePattern = Pattern.compile(strKeyValuePattern);
}
public String FormatFormula(String formula) {
Matcher equalMatchResult = equalPattern.matcher(formula);
Stack<RegexMatchObject> equalMatchObjectStack = new Stack<>();
while (equalMatchResult.find()) {
if (StringUtils.isNotBlank(equalMatchResult.group("equal"))) {
RegexMatchObject object = new RegexMatchObject();
object.setIndex(equalMatchResult.start());
object.setLength(equalMatchResult.end() - equalMatchResult.start() + 1);
object.setMatchType(RegexMatchType.Equal);
object.setParameters(new AbstractMap.SimpleEntry<>(equalMatchResult.group("equal"), -1));
equalMatchObjectStack.push(object);
}
}
while (equalMatchObjectStack.size() > 0) {
RegexMatchObject obj = equalMatchObjectStack.pop();
formula = formula.substring(0, obj.getIndex()) + obj.getExpression() + formula.substring(obj.getIndex() + obj.getLength());
}
Matcher regexResult = regexPattern.matcher(formula);
Stack<RegexMatchObject> regexMatchObjectStack = new Stack<>();
while (regexResult.find()) {
if (StringUtils.isNotBlank(regexResult.group("columnNumber")) && StringUtils.isNotBlank(regexResult.group("rowNumber"))) {
RegexMatchObject object = new RegexMatchObject();
object.setIndex(regexResult.start());
object.setLength(regexResult.end() - regexResult.start() + 1);
object.setMatchType(RegexMatchType.CellNumber);
object.setParameters(new AbstractMap.SimpleEntry<>(regexResult.group("columnNumber"), Integer.parseInt(regexResult.group("rowNumber"))));
regexMatchObjectStack.push(object);
}
if (StringUtils.isNotBlank(regexResult.group("keyCode"))) {
RegexMatchObject object = new RegexMatchObject();
object.setIndex(regexResult.start());
object.setLength(regexResult.end() - regexResult.start() + 1);
object.setMatchType(RegexMatchType.CellNumber);
object.setParameters(new AbstractMap.SimpleEntry<>(regexResult.group("keyCode"), -1));
regexMatchObjectStack.push(object);
}
}
while (!regexMatchObjectStack.empty()) {
RegexMatchObject obj = regexMatchObjectStack.pop();
formula = formula.substring(0, obj.getIndex()) + obj.getExpression() + formula.substring(obj.getIndex(), obj.getLength());
}
return formula.trim();
}
}
......@@ -44,7 +44,7 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
List<String> orgIDs = organizationMapper.selectOnlyIDAndParentID().stream().map(OrganizationDto::getID)
.collect(Collectors.toList());
List<TaxPayerReportRule> rules = taxPayerReportRuleMapper.selectByExample(new TaxPayerReportRuleExample());
List<TaxPayerReportRule> filterRules = new ArrayList<TaxPayerReportRule>();
List<TaxPayerReportRule> filterRules = new ArrayList<>();
for (TaxPayerReportRule rule : rules) {
String[] selectedOrgIds = rule.getOrganizationID().split(",");
......@@ -61,7 +61,7 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
}
}
List<TaxPayerReportRuleDto> dtoList = new ArrayList<TaxPayerReportRuleDto>();
List<TaxPayerReportRuleDto> dtoList = new ArrayList<>();
for (TaxPayerReportRule rule : filterRules) {
TaxPayerReportRuleDto ruleDto = new TaxPayerReportRuleDto();
CommonUtils.copyProperties(rule, ruleDto);
......@@ -82,8 +82,8 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
}
@Override
@Transactional
public void SaveTaxRuleSettings(BatchUpdateTaxRuleDto batchUpdateTaxRule) {
@Transactional(readOnly = true)
public void savetaxrulesettings(BatchUpdateTaxRuleDto batchUpdateTaxRule) {
for (TaxRuleSettingOperation trso : batchUpdateTaxRule.getTaxRuleSettingOperations()) {
TaxRuleSetting taxRuleSetting = new TaxRuleSetting();
CommonUtils.copyProperties(trso.getTaxRuleSetting(), taxRuleSetting);
......@@ -126,12 +126,12 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
taxPayerReportRule.setCreateTime(new Date());
taxPayerReportRule.setUpdateTime(new Date());
SaveOrganizationServiceTemplateGroup(taxPayerReportRule,tprrdo.getAction());
if(tprrdo.getAction()=="Add") {
if(tprrdo.getAction().equals("Add")) {
taxPayerReportRuleMapper.insert(taxPayerReportRule);
operationService.AddDataAddLog(taxPayerReportRule, OperationModule.RuleEngineConfig, authUserHelper.getCurrentUserID(),
"AddRuleEngineConfiguration", "纳税类型", "纳税类型添加特殊机构", OperateLogType.OperationLogRuleEngine);
}
else if(tprrdo.getAction()=="Update") {
else if(tprrdo.getAction().equals("Update")) {
TaxPayerReportRule old = taxPayerReportRuleMapper.selectByPrimaryKey(reportDto.getID());
TaxPayerReportRule original = new TaxPayerReportRule();
CommonUtils.copyProperties(old, original);
......@@ -147,7 +147,7 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
"UpdateRuleEngineConfiguration", "纳税类型", taxPayerReportRule.getIsDefault() ? "默认纳税类型或默认纳税报表" : "纳税类型更新特殊机构", OperateLogType.OperationLogRuleEngine);
}
else if(tprrdo.getAction()=="Delete") {
else if(tprrdo.getAction().equals("Delete")) {
taxPayerReportRuleMapper.deleteByPrimaryKey(taxPayerReportRule.getID());
operationService.DeleteDataAddLog(reportDto, OperationModule.RuleEngineConfig, authUserHelper.getCurrentUserID(),
"DeleteRuleEngineConfiguration", "纳税类型", "纳税类型删除特殊机构", OperateLogType.OperationLogRuleEngine);
......@@ -184,7 +184,7 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
example.createCriteria().andOrganizationIDEqualTo(taxPayerReportRule.getOrganizationID()).andServiceTypeIDEqualTo("2");
Optional<OrganizationServiceTemplateGroup> thisOrgTemplate = organizationServiceTemplateGroupMapper.selectByExample(example).stream().findFirst();
if(action=="Delete") {
if(action.equals("Delete")) {
if(thisOrgTemplate.isPresent()) {
organizationServiceTemplateGroupMapper.deleteByPrimaryKey(thisOrgTemplate.get().getID());
}
......@@ -193,7 +193,7 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
{
if(thisOrgTemplate.isPresent()) {
OrganizationServiceTemplateGroup organizationServiceTemplateGroup = thisOrgTemplate.get();
if(organizationServiceTemplateGroup.getTemplateGroupID()==taxPayerReportRule.getTemplateGroupID()) {
if(organizationServiceTemplateGroup.getTemplateGroupID().equals(taxPayerReportRule.getTemplateGroupID())) {
//不用改
}
else
......
package pwc.taxtech.atms.service.impl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.service.TemplateFormulaService;
@Service
public class TemplateFormulaServiceImpl extends AbstractService implements TemplateFormulaService {
private FormulaHelper _formulaHelper = new FormulaHelper();
//private static ScriptEngine m_engine = Python.CreateEngine();
@Override
public OperationResultDto Validate(String formula) {
OperationResultDto result = new OperationResultDto();
if (StringUtils.isBlank(formula)) {
result.setResult(true);
return result;
}
try {
String tidyFormula = _formulaHelper.FormatFormula(formula);
/*todo: find the replace solution for here to check formual is correct or not
//var sourceCode = m_engine.CreateScriptSourceFromString(tidyFormula, SourceCodeKind.AutoDetect);
//var compileCode = sourceCode.Compile();
rtn.Result = compileCode != null;*/
result.setResult(true);
return result;
} catch (Exception e) {
result.setResult(false);
result.setResultMsg(e.getMessage());
}
return null;
}
}
......@@ -2,13 +2,18 @@ package pwc.taxtech.atms.service.impl;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.dto.NameDto;
import pwc.taxtech.atms.dto.TemplateDto;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import pwc.taxtech.atms.entitiy.Template;
import pwc.taxtech.atms.entitiy.TemplateExample;
import pwc.taxtech.atms.service.TemplateService;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.groupingBy;
@Service
public class TemplateServiceImpl extends AbstractService implements TemplateService {
......@@ -50,4 +55,63 @@ public class TemplateServiceImpl extends AbstractService implements TemplateServ
}
return result;
}
@Override
public List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs) {
Map<String, Object> map = new HashMap<>(4);
map.put("serviceTypeID", serviceTypeID);
map.put("payTaxType", payTaxType);
map.put("reportType", reportType);
map.put("industryIDs", industryIDs);
List<TemplateUniqDto> templatedbList = templateMapper.getTemplateUniqDtosByTemplateAndTemplateGroup(map);
Map<String, Map<String, List<TemplateUniqDto>>> groupList = templatedbList.stream().filter(sa -> sa.getIsActiveAssociation()).collect(groupingBy(TemplateUniqDto::getTemplateGroupID, Collectors.groupingBy(TemplateUniqDto::getTemplateGroupName)));
List<NameDto> groupListResult = new ArrayList<>();
groupList.forEach((key, value) -> {
NameDto temp = new NameDto();
temp.setID(key);
value.forEach((key2, value2) -> {
temp.setName(key2);
});
groupListResult.add(temp);
});
List<TemplateUniqDto> result = new ArrayList<>();
for (NameDto group : groupListResult) {
TemplateUniqDto parent = new TemplateUniqDto();
parent.setID(group.getID());
parent.setCode("");
parent.setName(group.getName());
result.add(parent);
List<TemplateUniqDto> subList = templatedbList.stream().filter(sa -> sa.getTemplateGroupID() == group.getID() && sa.getIsActiveAssociation()).collect(Collectors.toList());
subList.forEach(sa -> {
sa.setParentID(sa.getTemplateGroupID());
sa.setParentName(sa.getTemplateGroupName());
});
result.addAll(subList);
}
List<TemplateUniqDto> noGroupTemplateList = templatedbList.stream().filter(sa -> !sa.getIsActiveAssociation()).collect(Collectors.toList());
if (!noGroupTemplateList.isEmpty()) {
TemplateUniqDto parent = new TemplateUniqDto();
parent.setID(UUID.fromString("").toString());
parent.setCode("");
parent.setName(Constant.Other);
result.add(parent);
noGroupTemplateList.forEach(sa -> {
sa.setParentID(parent.getID());
sa.setParentName(parent.getName());
});
result.addAll(noGroupTemplateList);
}
return result;
}
}
......@@ -398,4 +398,37 @@
order by ${orderByClause}
</if>
</select>
<resultMap id="TemplateUniqDto" type="pwc.taxtech.atms.dto.TemplateUniqDto">
<id column="ID" jdbcType="VARCHAR" property="ID" />
<result column="Code" jdbcType="VARCHAR" property="Code" />
<result column="Name" jdbcType="VARCHAR" property="Name" />
<result column="OrderIndex" jdbcType="INTEGER" property="OrderIndex" />
<result column="ReportType" jdbcType="INTEGER" property="ReportType" />
<result column="TemplateGroupID" jdbcType="VARCHAR" property="TemplateGroupID" />
<result column="TemplateGroupName" jdbcType="VARCHAR" property="TemplateGroupName" />
<result column="ParentID" jdbcType="VARCHAR" property="ParentID" />
<result column="ParentName" jdbcType="VARCHAR" property="ParentName" />
<result column="PayTaxType" jdbcType="INTEGER" property="PayTaxType" />
<result column="IndustryIDs" jdbcType="VARCHAR" property="IndustryIDs" />
<result column="ServiceTypeID" jdbcType="VARCHAR" property="ServiceTypeID" />
<result column="IsActiveAssociation" jdbcType="INTEGER" property="IsActiveAssociation" />
</resultMap>
<select id="getTemplateUniqDtosByTemplateAndTemplateGroup" parameterType="map" resultMap="TemplateUniqDto" >
SELECT p.ID,p.Code,p.Name,p.ReportType,q.ID as TemplateGroupID,q.Name as TemplateGroupName,p.IsActiveAssociation FROM Template p join TemplateGroup q on p.templategroupID=q.ID
<if test="serviceTypeID">
WHERE q.ServiceTypeID=#{serviceTypeID,jdbcType=VARCHAR}
</if>
<if test="payTaxType!=null">
AND q.PayTaxType = #{payTaxType,jdbcType=INTEGER}
</if>
<if test="reportType!=null">
AND p.ReportType =#{reportType,jdbcType=INTEGER}
</if>
<if test="industryIDs">
AND q.IndustryIDs =#{industryID,jdbcType=VARCHAR}
</if>
ORDER BY p.TemplateGroupID, p.OrderIndex
</select>
</mapper>
\ No newline at end of file
......@@ -14,54 +14,54 @@ function ($rootScope, $log, $uibModal, $translate) {
var initialize = function (sheet) {
sheet.isPaintSuspended(true);
sheet.suspendPaint();
hasVoucherImg = new Image();
hasVoucherImg.src = '/app-resources/images/vat/hasVoucher.png';
hasVoucherImg.onload = function () {
sheet.repaint();
}
};
hasInvoiceImg = new Image();
hasInvoiceImg.src = '/app-resources/images/vat/hasInvoice.png';
hasInvoiceImg.onload = function () {
sheet.repaint();
}
};
hasKeyInImg = new Image();
hasKeyInImg.src = '/app-resources/images/vat/hasKeyIn.png';
hasKeyInImg.onload = function () {
sheet.repaint();
}
};
hasModelImg = new Image();
hasModelImg.src = '/app-resources/images/vat/hasModel.png';
hasModelImg.onload = function () {
sheet.repaint();
}
};
hasExceptionImg = new Image();
hasExceptionImg.src = '/app-resources/images/vat/hasException.png';
hasExceptionImg.onload = function () {
sheet.repaint();
}
};
hasValidationImg = new Image();
hasValidationImg.src = '/app-resources/images/vat/hasValidation.png';
hasValidationImg.onload = function () {
sheet.repaint();
}
};
};
var paintSheet = function (sheet) {
sheet.isPaintSuspended(false);
sheet.resumePaint();
};
var setCellTipString = function (cell, tip) {
//cell.cellType(new IconCellType(null, null, 0, null, tip));
cell.cellType(new IconsCellType([], [], tip));
}
};
var setCellTipByCellData = function (cell, cellData) {
var tips = null;
......@@ -100,7 +100,7 @@ function ($rootScope, $log, $uibModal, $translate) {
}
cell.cellType(new IconsCellType(icons, infos, tips));
}
};
var setCellTip = function (cell, config) {
var tips = null;
......@@ -201,7 +201,7 @@ function ($rootScope, $log, $uibModal, $translate) {
this.count = 0;
this.Formula = formula;
}
}
};
//var IconCellType = function (icon1, icon2, count, infos, formula) {
......@@ -217,7 +217,7 @@ function ($rootScope, $log, $uibModal, $translate) {
IconsCellType.prototype = new GC.Spread.Sheets.CellTypes.Base();
IconsCellType.prototype.paint = function (ctx, value, x, y, w, h, style, context) {
GC.Spread.Sheets.CellTypes.Base.prototype.paint.call(this, ctx, value, x, y, w, h, style, context);
GC.Spread.Sheets.CellTypes.Base.paint.call(this, ctx, value, x, y, w, h, style, context);
for (var i = 1; i <= this.count; i++) {
//距离当前单元格左侧距离,距离顶部距离 , ICON宽度,ICON高度
ctx.drawImage(this.Icons[i-1], x + w - (h - 3) * i + (h - 6 - 18) * i, y + 3 + (h / 2 - 3 - 9), 18, 18);
......@@ -232,7 +232,7 @@ function ($rootScope, $log, $uibModal, $translate) {
// ctx.drawImage(this.icon2, x + w - (h - 3) * i + (h - 6 - 18) * i, y + 3 + (h / 2 - 3 - 9), 18, 18);
//}
}
}
};
IconsCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
var index = x - (cellRect.x + cellRect.width - (cellRect.height - 3) * this.count) > 0 ?
Math.floor(this.count - (x - (cellRect.x + cellRect.width - (cellRect.height - 3) * this.count)) / (cellRect.height - 3)) :
......@@ -248,7 +248,7 @@ function ($rootScope, $log, $uibModal, $translate) {
sheetArea: context.sheetArea,
reservedLocationIndex: index
};
}
};
IconsCellType.prototype.processMouseMove = function (hitinfo) {
//console.log(hitinfo);
......
......@@ -93,7 +93,7 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
this.minArgs = minArgs;
};
customFunction.prototype = new GC.Spread.Sheets.Calc.Functions.Function();
customFunction.prototype = new GcSpread.Sheets.Calc.Functions.Function();
customFunction.prototype.evaluate = function (args) {
var formulaName = this.name + "(";
......@@ -128,7 +128,7 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
var deferred = $q.defer();
var promise = deferred.promise;
var spread = new GC.Spread.Sheets.Spread(document.getElementById(id));
var spread = new GcSpread.Sheets.Spread(document.getElementById(id));
var sheet = spread.getActiveSheet();
spread.showVerticalScrollbar(true);
......@@ -149,16 +149,16 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
sheet.setIsProtected(false);
}
spread.bind(GC.Spread.Sheets.Events.CellClick, function (sender, args) {
if (args.sheetArea === GC.Spread.Sheets.SheetArea.colHeader) {
spread.bind(GcSpread.Sheets.Events.CellClick, function (sender, args) {
if (args.sheetArea === GcSpread.Sheets.SheetArea.colHeader) {
$log.debug("The column header was clicked.");
}
if (args.sheetArea === GC.Spread.Sheets.SheetArea.rowHeader) {
if (args.sheetArea === GcSpread.Sheets.SheetArea.rowHeader) {
$log.debug("The row header was clicked.");
}
if (args.sheetArea === GC.Spread.Sheets.SheetArea.corner) {
if (args.sheetArea === GcSpread.Sheets.SheetArea.corner) {
$log.debug("The corner header was clicked.");
}
......@@ -167,7 +167,7 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
$log.debug(sheet.getTag(args.row, args.col));
});
spread.bind(GC.Spread.Sheets.Events.EditEnding, function (sender, args) {
spread.bind(GcSpread.Sheets.Events.EditEnding, function (sender, args) {
var sheet = spread.getActiveSheet();
......@@ -212,7 +212,7 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
var customfunctions;
//1. 获取自定义函数名及对应的计算值
//1. 获取自定义函数名及对应的计算值
getFormulaValueByDocumentCode(code).then(function (formuladata) {
formulaValues = JSON.parse(formuladata);
$log.debug(formulaValues);
......@@ -234,7 +234,7 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
initSpreadCustomFunction(sheet, func.name, 0, func.parameterCount);
}
//5. Get Document Cell
//5. Get Document Cell
getDocumentCellByDocumentId(documentObj.documentID).then(function (celldata) {
renderFormulaCell(sheet, celldata.data);
});
......@@ -281,14 +281,14 @@ webservices.factory('spreadJsService', ['$log', '$q', '$http', 'apiConfig', 'doc
};
var initSpreadCustomFunctionAsync = function (sheet, name) {
var asum = function () { }
//Define a class "ASUM" that extends AsyncFunction
asum.prototype = new GC.Spread.Sheets.Calc.Functions.AsyncFunction(name, 1, 255);
asum.prototype = new GcSpread.Sheets.Calc.Functions.AsyncFunction(name, 1, 255);
//Set default value to "Loading..."
asum.prototype.defaultValue = function () { return "Loading..."; };
//Override the evaluateAsync function
......
......@@ -13,78 +13,37 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
return "";
};
var getTemplateJson = function (templateID) {
//return $http.get('/template/getTemplateJson?templateID=' + templateID, apiConfig.create());
// var result = httpCacheService.get('/template/getTemplateJson?templateID=' + templateID);
// if (result.finishedCache) {
// return result;
// } else {
// var thisConfig = apiConfig.create();
// thisConfig.responseType = "blob";
// return $http.post('/template/getTemplateJson?templateID=' + templateID, {}, apiConfig.create());
// }
var deferred = $q.defer();
var promise = deferred.promise;
// var ajaxUrl = loginContext.apiHost + constant.webapi.prefix + '/template/getTemplateJson?templateID=' + templateID;
// var apiTokenObj = JSON.parse(getCookie('AtmsApiToken'));
// var apiToken = apiTokenObj.access_token;
// var tokenType = apiTokenObj.token_type;
// var ajaxSource = $.ajax({
// url: ajaxUrl,
// type: "POST",
// dataType:"blob",
// beforeSend: function (xhr) {
// xhr.setRequestHeader('Authorization', tokenType + ' ' + apiToken);
// //xhr.setRequestHeader('from', 'aabb@cn.pwc.com');
// //xhr.responseType = "blob";
// },
// success: function(data){
// deferred.resolve(data);
// },
// complete: function(data){
// deferred.resolve(data.responseText);
// }
// });
// ajaxSource.done(function (data) {
// deferred.resolve(data);
// });
return promise;
};
var initSpreadExcel = function (id, ssjsondata) {
var deferred = $q.defer();
var promise = deferred.promise;
var spread = new GC.Spread.Sheets.Workbook(document.getElementById(id));
spread.showVerticalScrollbar(true);
spread.showHorizontalScrollbar(true);
spread.scrollbarMaxAlign(true);
spread.scrollbarShowMax(true);
spread.tabNavigationVisible(true);
spread.newTabVisible(false);
spread.tabEditable(false);
spread.tabStripVisible(false);
spread.newTabVisible(false);
// spread.allowUndo(false);
// spread.allowUserResize(false);
// spread.canUserDragDrop(false);
// spread.canUserDragFill(false);
// spread.canUserEditFormula(false);
//
// spread.isPaintSuspended(true);
// spread.fromJSON(JSON.parse(ssjsondata));
// spread.isPaintSuspended(false);
spread.options.showVerticalScrollbar = true;
spread.options.showHorizontalScrollbar = true;
spread.options.scrollbarMaxAlign = true;
spread.options.scrollbarShowMax = true;
spread.options.tabNavigationVisible = true;
spread.options.newTabVisible = false;
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.suspendPaint();
spread.fromJSON(ssjsondata);
spread.resumePaint();
var sheet = spread.getActiveSheet();
if (sheet != null) {
// sheet.setRowHeaderVisible(true);
// sheet.setColumnHeaderVisible(true);
// sheet.setGridlineOptions({
// showVerticalGridline: false, showHorizontalGridline: false
// });
sheet.options.rowHeaderVisible = true;
sheet.options.colHeaderVisible = true;
sheet.options.gridline.showVerticalGridline = false;
sheet.options.gridline.showHorizontalGridline = false;
}
deferred.resolve(spread);
......@@ -96,7 +55,7 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
var promise = deferred.promise;
var spreadSheet;
var url = loginContext.apiHost + constant.webapi.prefix+'/template/getTemplateJson?templateID=' + templateID;
var url = loginContext.apiHost + constant.webapi.prefix + '/template/getTemplateJson?templateID=' + templateID;
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true); // 也可以使用POST方式,根据接口
xhr.responseType = "blob"; // 返回类型blob
......@@ -104,7 +63,6 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
var apiToken = apiTokenObj.access_token;
var tokenType = apiTokenObj.token_type;
xhr.setRequestHeader('Authorization', tokenType + ' ' + apiToken);
// xhr.setRequestHeader("Authorization","bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTUyNzMxNDA4NCwiaWF0IjoxNTI3MTQxMjg0LCJuYmYiOjE1MjcxNDA2ODQsImp0aSI6IjVGM0FGMTBDLTdFMEEtNDVDQy04RDVGLUREMTBFMDRCOUY4NCIsInVzZXJuYW1lIjoiYWRtaW4iLCJkYXRhYmFzZVVzZXJuYW1lIjoiQWRtaW4iLCJ1c2VyaWQiOiI2NjkzM0U3Qi1EQTc1LTRCMkUtQjdENi1BQjY1RENBMjBENTAifQ.M-dyU6W51LAPVQ66HIJZ-KAg6WjPSIt1GqpOc6etQ6XJfXp8KkUPA6A8qPZ8bhydWsKKMqpPlx-KRVhK2o5q0Q")
// 定义请求完成的处理函数,请求前也可以增加加载框/禁用下载按钮逻辑
xhr.onload = function () {
// 请求完成
......@@ -121,39 +79,10 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
// process error
alert(e.errorMessage);
}, {});
// var reader = new FileReader();
// reader.readAsDataURL(blob); // 转换为base64,可以直接放入a表情href
// reader.onload = function (e) {
// // 转换完成,创建一个a标签用于下载
// var a = document.createElement('a');
// a.download = 'data.xlsx';
// a.href = e.target.result;
// $("body").append(a); // 修复firefox中无法触发click
// a.click();
// $(a).remove();
// }
}
};
// 发送ajax请求
xhr.send();
// getTemplateJson(templateID).then(function (result) {
// //var data = new Blob(result, {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"});
// var excelIo = new GC.Spread.Excel.IO();
// excelIo.open(result, function (json) {
// //var workbookObj = json;
// //spread.fromJSON(workbookObj);
// spreadSheet = initSpreadExcel(id, json);
// deferred.resolve(spreadSheet);
// }, function (e) {
// // process error
// alert(e.errorMessage);
// }, {});
// spreadSheet = initSpreadExcel(id, result.data === undefined ? result : result.data);
//
// deferred.resolve(spreadSheet);
// });
return promise;
};
......@@ -162,7 +91,6 @@ webservices.factory('templateService', ['$log', '$http', '$q', 'apiConfig', 'htt
};
return {
getTemplateJson: getTemplateJson,
renderSpreadExcelSimple: renderSpreadExcelSimple,
initSpreadExcel: initSpreadExcel,
setRowColName: setRowColName
......
This diff is collapsed.
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