Commit 4ef494ac authored by gary's avatar gary

Merge remote-tracking branch 'origin/dev_mysql' into dev_mysql

parents f7c56fc2 4da82e2b
......@@ -10,6 +10,10 @@ import pwc.taxtech.atms.invoice.OutputInvoiceDetailMapper;
import pwc.taxtech.atms.invoice.OutputInvoiceMapper;
import pwc.taxtech.atms.service.impl.DistributedIdService;
import pwc.taxtech.atms.vat.dao.*;
import pwc.taxtech.atms.vat.entity.BalanceSheet;
import java.util.HashMap;
import java.util.Map;
//用来获取spring托管的bean
@Component
......@@ -55,6 +59,23 @@ public class SpringContextUtil implements ApplicationContextAware {
public static TrialBalanceMapper trialBalanceMapper;
public static AdjustmentTableMapper adjustmentTableMapper;
public static TrialBalanceFinalMapper trialBalanceFinalMapper;
public static ProfitLossStatementMapper profitLossStatementMapper;
public static CashFlowMapper cashFlowMapper;
public static BalanceSheetManualMapper balanceSheetManualMapper;
public static ProfitLossStatementManualMapper profitLossStatementManualMapper;
public static CashFlowManualMapper cashFlowManualMapper;
public static BalanceSheetFinalMapper balanceSheetFinalMapper;
public static CashFlowFinalMapper cashFlowFinalMapper;
public static CitBalanceSheetPrcAdjustMapper citBalanceSheetPrcAdjustMapper;
public static CitProfitPrcAdjustMapper citProfitPrcAdjustMapper;
public static BalanceSheetMapper balanceSheetMapper;
public static Map map = new HashMap<String, Object>();
/**
* 获取bean
......@@ -111,5 +132,34 @@ public class SpringContextUtil implements ApplicationContextAware {
trialBalanceMapper = webApplicationContext.getBean(TrialBalanceMapper.class);
adjustmentTableMapper = webApplicationContext.getBean(AdjustmentTableMapper.class);
trialBalanceFinalMapper = webApplicationContext.getBean(TrialBalanceFinalMapper.class);
profitLossStatementMapper = webApplicationContext.getBean(ProfitLossStatementMapper.class);
cashFlowMapper = webApplicationContext.getBean(CashFlowMapper.class);
balanceSheetManualMapper = webApplicationContext.getBean(BalanceSheetManualMapper.class);
profitLossStatementManualMapper = webApplicationContext.getBean(ProfitLossStatementManualMapper.class);
cashFlowManualMapper = webApplicationContext.getBean(CashFlowManualMapper.class);
balanceSheetFinalMapper = webApplicationContext.getBean(BalanceSheetFinalMapper.class);
cashFlowFinalMapper = webApplicationContext.getBean(CashFlowFinalMapper.class);
citBalanceSheetPrcAdjustMapper = webApplicationContext.getBean(CitBalanceSheetPrcAdjustMapper.class);
citProfitPrcAdjustMapper = webApplicationContext.getBean(CitProfitPrcAdjustMapper.class);
balanceSheetMapper = webApplicationContext.getBean(BalanceSheetMapper.class);
/* map.put("balance_sheet", balanceMapper);
map.put("profit_loss_statement",profitLossStatementMapper);
map.put("cash_flow", cashFlowMapper);
map.put("balance_sheet_manual", balanceSheetManualMapper);
map.put("profit_loss_statement_manual", profitLossStatementManualMapper);
map.put("cash_flow_manual", cashFlowManualMapper);
map.put("balance_sheet_final", balanceSheetFinalMapper);
map.put("profit_loss_statement_final", profitLossStatementManualMapper);
map.put("cash_flow_final", cashFlowFinalMapper);
map.put("cit_balance_sheet_prc_adjust", citBalanceSheetPrcAdjustMapper);
map.put("cit_profit_prc_adjust", citProfitPrcAdjustMapper);*/
}
}
package pwc.taxtech.atms.common.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @ClassName StringUtil
* Description TODO
* @Author pwc kevin
* @Date 3/11/2019 5:29 PM
* Version 1.0
**/
public class StringUtil {
/**
* 下划线转驼峰法(默认小驼峰)
*
* @param line
* 源字符串
* @param smallCamel
* 大小驼峰,是否为小驼峰(驼峰,第一个字符是大写还是小写)
* @return 转换后的字符串
*/
public static String underline2Camel(String line, boolean ... smallCamel) {
if (line == null || "".equals(line)) {
return "";
}
StringBuffer sb = new StringBuffer();
Pattern pattern = Pattern.compile("([A-Za-z\\d]+)(_)?");
Matcher matcher = pattern.matcher(line);
//匹配正则表达式
while (matcher.find()) {
String word = matcher.group();
//当是true 或则是空的情况
if((smallCamel.length ==0 || smallCamel[0] ) && matcher.start()==0){
sb.append(Character.toLowerCase(word.charAt(0)));
}else{
sb.append(Character.toUpperCase(word.charAt(0)));
}
int index = word.lastIndexOf('_');
if (index > 0) {
sb.append(word.substring(1, index).toLowerCase());
} else {
sb.append(word.substring(1).toLowerCase());
}
}
return sb.toString();
}
/**
* 驼峰法转下划线
*
* @param line
* 源字符串
* @return 转换后的字符串
*/
public static String camel2Underline(String line) {
if (line == null || "".equals(line)) {
return "";
}
line = String.valueOf(line.charAt(0)).toUpperCase()
.concat(line.substring(1));
StringBuffer sb = new StringBuffer();
Pattern pattern = Pattern.compile("[A-Z]([a-z\\d]+)?");
Matcher matcher = pattern.matcher(line);
while (matcher.find()) {
String word = matcher.group();
sb.append(word.toUpperCase());
sb.append(matcher.end() == line.length() ? "" : "_");
}
return sb.toString();
}
/* public static void main(String[] args) {
String line = "are_you_dou_bi_yellowcong";
//下划线转驼峰(大驼峰)
//AreYouDouBiYellowcong
String camel = underline2Camel(line, true);
System.out.println(camel);
//下划线转驼峰(小驼峰)
//areYouDouBiYellowcong
camel = underline2Camel(line);
System.out.println(camel);
//驼峰转下划线
//ARE_YOU_DOU_BI_YELLOWCONG
System.out.println(camel2Underline(camel));
}*/
}
......@@ -4,15 +4,12 @@ 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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.dto.LoginOutputDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.user.UserPasswordDto;
import pwc.taxtech.atms.service.impl.UserAccountServiceImpl;
import pwc.taxtech.atms.vat.service.impl.FormulaAgent;
@RestController
@RequestMapping("/api/v1/Account/")
......@@ -37,4 +34,5 @@ public class AccountController {
logger.debug("enter forgetPassword");
return userAccountService.forgetPassword(mail);
}
}
......@@ -50,8 +50,7 @@ public class TaxDocumentController {
@PostMapping("add")
@ResponseBody
public boolean addTaxDocument(@RequestBody TaxDocument taxDocument,
@RequestPart("file") MultipartFile file,
@RequestParam(required = false) String modual) {
@RequestParam MultipartFile file) {
return taxDocumentService.addTaxDocumentList(file,taxDocument);
}
......
package pwc.taxtech.atms.dto;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName DataTablesEnum
* Description TODO
* @Author pwc kevin
* @Date 3/11/2019 2:30 PM
* Version 1.0
**/
public class TableRule {
public static Map<String, String> map = new HashMap<String, String>();
static {
map.put("EBSZCFZB", "balance_sheet");
map.put("EBSLRB", "profit_loss_statement");
map.put("EBSXJLLB", "cash_flow");
map.put("RGDRZCFZB", "balance_sheet_manual");
map.put("RGDRLRB", "profit_loss_statement_manual");
map.put("RGDRXJLLB", "cash_flow_manual");
map.put("ZXZCFZB", "balance_sheet_final");
map.put("ZXLLB", "profit_loss_statement_final");
map.put("ZXXJLLB", "cash_flow_final");
map.put("CITZCFZB", "cit_balance_sheet_prc_adjust");
map.put("CITLRB", "cit_profit_prc_adjust");
}
}
......@@ -58,7 +58,7 @@ public class CitReportServiceImpl extends BaseService {
private final static Logger logger = LoggerFactory.getLogger(CitReportServiceImpl.class);
private final static String[] functions = {"SGSR", "FSJZ", "ND", "BB", "XXFP", "GZSD", "PC", "JXFPMX",
"JXFP", "PSUM", "DFFS", "JFFS", "WPSR","WPNAME","WPTYPE"};
"JXFP", "PSUM", "DFFS", "JFFS", "WPSR","WPNAME","WPTYPE", "SUM2", "SUM", "RSUMIF", "TABLESUM2"};
@Autowired
private OrganizationServiceTemplateGroupMapper orgServiceTemplateGroupMapper;
......
......@@ -53,9 +53,13 @@ public class TaxDocumentServiceImpl {
if(CollectionUtils.isNotEmpty(uploadDetail.getList())){
urlMap = uploadDetail.getList().stream().collect(Collectors.toMap(DidiFileUploadDetailResult::getUid, didiFileUploadDetailResult -> didiFileUploadDetailResult.getViewHttpUrl()));
}
for(TaxDocument data:dataList){
data.setFilePositionUrl(urlMap.get(data.getFileUploadId()));
if(urlMap!=null){
for(TaxDocument data:dataList){
data.setFilePositionUrl(urlMap.get(data.getFileUploadId()));
}
}
return dataList;
}
......@@ -87,7 +91,7 @@ public class TaxDocumentServiceImpl {
}
//档案名称 fileName
if (StringUtils.isNotBlank(taxDocumentDto.getFileName())) {
criteria.andFileNameEqualTo(taxDocumentDto.getFileName());
criteria.andFileNameLike(taxDocumentDto.getFileName());
}
//业务线 businessLine
if (StringUtils.isNotBlank(taxDocumentDto.getBusinessLine())) {
......
package pwc.taxtech.atms.vat.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.common.util.StringUtil;
import pwc.taxtech.atms.constant.enums.EnumServiceType;
import pwc.taxtech.atms.dao.FormulaAdminMapper;
import pwc.taxtech.atms.dao.ProjectServiceTypeMapper;
import pwc.taxtech.atms.dpo.CellTemplatePerGroupDto;
import pwc.taxtech.atms.dpo.GroupId;
import pwc.taxtech.atms.dto.TableRule;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.entity.ProjectServiceType;
import pwc.taxtech.atms.entity.ProjectServiceTypeExample;
import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.vat.dao.CellDataMapper;
import pwc.taxtech.atms.vat.dao.PeriodCellDataMapper;
import pwc.taxtech.atms.vat.dao.PeriodDataSourceMapper;
import pwc.taxtech.atms.vat.dao.PeriodReportMapper;
import pwc.taxtech.atms.vat.dao.*;
import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import static pwc.taxtech.atms.constant.Constant.FIRST_OR_DEFAULT;
......@@ -59,6 +63,7 @@ public class FormulaAgent {
/**
* 根据收入类型配置及列index查询报表模板
*
* @param templateGroupId
* @param code
* @param rowColumnIndex
......@@ -85,7 +90,7 @@ public class FormulaAgent {
String orgId,
String startDate,
String endDate) {
return adminMp.getCellTemplateByTypeAndIndex(templateGroupId, projectId,code, rowColumnIndex, taxRate, revenueType, taxType, columnIndex, period, orgId, startDate, endDate);
return adminMp.getCellTemplateByTypeAndIndex(templateGroupId, projectId, code, rowColumnIndex, taxRate, revenueType, taxType, columnIndex, period, orgId, startDate, endDate);
}
public Project getFixedProject(String projectId, Integer year) {
......@@ -132,11 +137,75 @@ public class FormulaAgent {
return cellData;
}
public List<CellTemplatePerGroupDto> getCellDataByPos(Long templateId, Integer period, String cellRow, String cellCol, String projectId){
return adminMp.getCellDataByPos(templateId, period, cellRow, cellCol, projectId);
public List<CellTemplatePerGroupDto> getCellDataByPos(Long templateId, Integer period, String cellRow, String cellCol, String projectId) {
return adminMp.getCellDataByPos(templateId, period, cellRow, cellCol, projectId);
}
public List<CellTemplatePerGroupDto> getTableData(String tableName, String getField, String selectFilter, String year, String selectPeriod) {
return adminMp.getTableData(tableName, getField, selectFilter, year, selectPeriod);
}
public static String buildSql(String tableName, String getField, String filter, String filterValue, Integer period, String year, FormulaContext formulaContext) {
String sql = "";
String[] split = filterValue.split(" ");
String para3 = null;
if (split[0].indexOf(">=") != -1) {
filterValue = "> " + split[1] + "and" + filter + " =" + split[1];
}
if (split[0].indexOf("<=") != -1) {
filterValue = "< " + split[1] + "and" + filter + " =" + split[1];
}
if ("CITZCFZB".equals(tableName) || ("CITLRB".equals(tableName))) {
return _buildSql(getField, tableName, filter, filterValue, period, formulaContext, year, false);
}
return _buildSql(getField, tableName, filter, filterValue, period, formulaContext, year, true);
}
public static String _buildSql(String getField, String tableName, String filter, String filterValue, Integer period, FormulaContext formulaContext, String year, boolean bool) {
String sql = "select " + getField + " from " + tableName + " where 1=1 and " + filter + filterValue;
String _p = "";
if (formulaContext.getPeriod() - period < 10) {
_p = year + "'0" + (formulaContext.getPeriod() - period) + "'";
} else {
_p = year + (formulaContext.getPeriod() - period);
}
if (period == 0) {
sql += " and tms-period = " + formulaContext.getPeriod();
} else if (period == -99) {
sql += "and tms-period between '" + year + "01' and " + (formulaContext.getPeriod() - 1);
} else if (period == 99) {
sql += "and tms-period between '" + year + "01' and " + (formulaContext.getPeriod());
} else {
sql += "and tms-period between " + _p + "and " + (formulaContext.getPeriod() - 1);
}
if (bool) {
sql += " and period = '" + year + period + "'";
}
return sql;
}
@Autowired
JdbcTemplate jdbcTemplate;
public static void main(String[] args) {
System.out.println(buildSql("balance_sheet", "end_bal", "beg_bal", "> 0.00", 201810, "2", null));
;
}
public Long getTableDataByName(String tableName, String getField, String filter, String filterValue, Integer period, String year, FormulaContext formulaContext) {
List<Map<String, Object>> stringObjectMap = jdbcTemplate.queryForList(buildSql(TableRule.map.get(tableName), getField, filter, filterValue, period, year, formulaContext));
Long rev = 0L;
for (int i = 0, j = stringObjectMap.size(); i < j; i++) {
if (i == 1) {
rev = Long.parseLong(String.valueOf(stringObjectMap.get(i).get(StringUtil.underline2Camel(getField))));
} else {
rev = rev + Long.parseLong(String.valueOf(stringObjectMap.get(i).get(StringUtil.underline2Camel(getField))));
}
}
return rev;
}
}
......@@ -512,7 +512,8 @@ public class ReportGeneratorImpl {
FreeRefFunction[] functionImpls = {new SGSR(formulaContext), new FSJZ(formulaContext), new ND(formulaContext),
new BB(formulaContext), new XXFP(formulaContext), new GZSD(formulaContext), new PC(formulaContext)
, new JXFPMX(formulaContext), new JXFP(formulaContext), new PSUM(formulaContext), new DFFS(formulaContext),
new JFFS(formulaContext), new WPSR(formulaContext),new WPNAME(formulaContext),new WPTYPE(formulaContext)};
new JFFS(formulaContext), new WPSR(formulaContext),new WPNAME(formulaContext),new WPTYPE(formulaContext), new SUM2(formulaContext),
new SUM(formulaContext), new RSUMIF(formulaContext), new TABLESUMIF(formulaContext)};
UDFFinder udfs = new DefaultUDFFinder(functions, functionImpls);
UDFFinder udfToolpack = new AggregatingUDFFinder(udfs);
workbook.addToolPack(udfToolpack);
......
......@@ -30,7 +30,7 @@ import static pwc.taxtech.atms.common.util.FormulaUtil.resolverString;
public class RSUMIF extends FunctionBase implements FreeRefFunction {
final static ValueEval defaultEval = new StringEval("0");
static final Logger LOGGER = LoggerFactory.getLogger(BB.class);
static final Logger LOGGER = LoggerFactory.getLogger(RSUMIF.class);
String tableName;
String getField;//取值列字段
Map<String, String> fileterMap = new HashMap<String, String>();
......@@ -53,7 +53,6 @@ public class RSUMIF extends FunctionBase implements FreeRefFunction {
} catch (Exception e) {
if (e instanceof FormulaException)
LOGGER.warn("Formula Exception || {}", e.getMessage());
e.printStackTrace();
return defaultEval;
}
......@@ -99,7 +98,6 @@ public class RSUMIF extends FunctionBase implements FreeRefFunction {
fileterMap.put(resolverString(args, ec, i), resolverString(args, ec, i + 1));
}
}
if (period == 0) {
selectPeriod = "t.period = " + formulaContext.getPeriod();
} else if (period == -99) {
......
package pwc.taxtech.atms.vat.service.impl.report.functions;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.TableRule;
import pwc.taxtech.atms.exception.Exceptions;
import java.util.HashMap;
import java.util.Map;
import static pwc.taxtech.atms.common.util.FormulaUtil.resolverInteger;
import static pwc.taxtech.atms.common.util.FormulaUtil.resolverString;
/**
* @ClassName TABLESUMIF
* Description TODO
* @Author pwc kevin
* @Date 3/11/2019 2:52 PM
* Version 1.0
**/
public class TABLESUMIF extends FunctionBase implements FreeRefFunction {
private String tableName;
public TABLESUMIF(FormulaContext formulaContext) {
super(formulaContext);
}
//进行参数验证
public void parameterCheck(ValueEval[] args, OperationEvaluationContext ec) {
argsLength = args.length;
if (argsLength != 6) //参数小于当做异常处理, 最后俩参数可以取默认值
throw Exceptions.parameterError;
try {
tableName = resolverString(args, ec, 0);
Map<String, String> map = TableRule.map;
if (!map.containsKey(tableName))
throw Exceptions.parameterError;
} catch (EvaluationException e) {
e.printStackTrace();
}
}
Integer argsLength;
String getField;
Integer period;
String year;
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
parameterCheck(args, ec);
try {
tableName = resolverString(args, ec, 0);
getField = resolverString(args, ec, 1);
String filter = resolverString(args, ec, 2);
String filterValue =resolverString(args, ec, 3);
period = resolverInteger(args, ec, 4);//会计期间
year = resolverString(args, ec, 5);//会计年度
new NumberEval(agent.getTableDataByName(tableName, getField,filter,filterValue, period, year, formulaContext));
} catch (EvaluationException e) {
e.printStackTrace();
return new NumberEval(0.00);
}
return new NumberEval(0.00);
}
}
......@@ -2,8 +2,8 @@
* Created by Administrator on 2019/3/1 0001.
*/
taxDocumentManageModule.controller('taxDocumentListController',
['$log', '$http', '$q', '$scope', '$translate', '$timeout', 'SweetAlert', '$compile', 'taxDocumentListService', '$filter',
function ($log, $http, $q, $scope, $translate, $timeout, SweetAlert, $compile, taxDocumentListService, $filter) {
['$log', '$http', '$q', '$scope', '$translate', '$timeout', 'SweetAlert', '$compile', 'taxDocumentListService', '$filter','apiInterceptor',
function ($log, $http, $q, $scope, $translate, $timeout, SweetAlert, $compile, taxDocumentListService, $filter,apiInterceptor) {
$scope.queryFieldModel = {};
$scope.editFieldModel = {
......@@ -267,13 +267,25 @@ taxDocumentManageModule.controller('taxDocumentListController',
var uploadItem = $scope.uploader.queue[0];
var fileName = uploadItem._file ? uploadItem._file.name : uploadItem.name;
uploadItem.formData = [
{originFileName:fileName}
{originFileName:fileName},
];
Object.keys($scope.editFieldModel).forEach(function(key){
var fields = {};
if(/(ownTime|fileTime|effectiveTime)/.test(key)){
fields[key] = $scope.editFieldModel[key].split("-").join("/");
}else{
fields[key] = $scope.editFieldModel[key];
}
uploadItem.formData.push(fields);
});
// data == true,代表可以直接上传,否则属于覆盖行为
if (data === true) {
$scope.uploader.url = apiInterceptor.webApiHostUrl + "/taxDoc/add";
$scope.uploader.uploadItem(0);
$scope.isCoverOperation = false;
$('#busy-indicator-container').show();
// addLogicAfterUploadFile($scope.editFieldModel,'simple');
} else {
SweetAlert.swal({
......@@ -289,7 +301,11 @@ taxDocumentManageModule.controller('taxDocumentListController',
},
function (isConfirm) {
if (isConfirm) {
$scope.uploader.url = apiInterceptor.webApiHostUrl + "/taxDoc/edit";
$scope.uploader.uploadItem(0);
// editDocFileRecord($scope.editFieldModel, 'simple');
$('#busy-indicator-container').show();
$scope.isCoverOperation = true;
}
})
......@@ -439,13 +455,11 @@ taxDocumentManageModule.controller('taxDocumentListController',
}
});
taxDocumentListService.getCompanyNameOptions().then(function(res){
if (res && 0 === res.code) {
angular.forEach(res.data, function (item) {
$scope.companyNameOptionsMap[item.id]=item.name;
});
console.log($scope.companyNameOptionsMap)
} else {
SweetAlert.error($translate.instant('RevenueGetOrgError'));
}
......@@ -475,7 +489,7 @@ taxDocumentManageModule.controller('taxDocumentListController',
$scope.cancelDocFileType = cancelDocFileType;
})();
}])
}]);
taxDocumentManageModule.directive("multiDatePicker", function () {
return {
restrict: "EA",
......@@ -624,7 +638,7 @@ taxDocumentManageModule.directive('fileUploader',function () {
$("#uploadFilePlugin").click();
};
$scope.uploader = new FileUploader({
url: "http://etms.longi-silicon.com:8180/api/v1/taxDoc/upload",
url: apiInterceptor.webApiHostUrl + "/taxDoc/add",
// autoUpload: true,//添加后,自动上传
headers:{"Authorization":apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken()},
removeAfterUpload:true,
......@@ -632,20 +646,14 @@ taxDocumentManageModule.directive('fileUploader',function () {
$scope.uploader.filters.push({//xls限制
name: 'fileTypeFilter',
fn: function (item, options) {
// var type = item.name.split(".").pop();
// var matchResult = /xlsx|xls|pdf/i.test(type);
var fileNativePath = $("#uploadFilePlugin")[0].value;
var splitMark = /\//.test(fileNativePath) ? "/" : "\\";
var prevPath = fileNativePath.split(splitMark);
prevPath.pop();
fileNativePath = prevPath.join(splitMark) + splitMark;
// if(matchResult){
$scope.uploader.clearQueue();
$scope.editFieldModel.fileNativePath = fileNativePath;
$scope.editFieldModel.fileName = item.name;
// $scope.uploader.addToQueue($("#uploadFilePlugin")[0].files[0]);
// $scope.uploader.queue[0] = $("#uploadFilePlugin")[0].files[0];
// }
return true;
}
});
......@@ -654,23 +662,39 @@ taxDocumentManageModule.directive('fileUploader',function () {
});
$scope.uploader.onErrorItem = function(fileItem, response, status, headers) {
SweetAlert.warning($translate.instant('FailUpload'));
$scope.uploader.clearQueue();
// $scope.uploader.cancelItem();
// $scope.uploader.clearQueue();
$scope.editFieldModel = {};
// console.info('onErrorItem', fileItem, response, status, headers);
$('#busy-indicator-container').hide();
};
// $scope.uploader.onCancelItem = function(fileItem, response, status, headers) {
// console.info('onCancelItem', fileItem, response, status, headers);
// };
$scope.uploader.onSuccessItem = function(fileItem, response, status, headers) {
fileItem.filePositionUrl = response;
$scope.editFieldModel.filePositionUrl = response;
// fileItem.filePositionUrl = response;
// $scope.editFieldModel.filePositionUrl = response;
var title = $translate.instant("Uploaded");
if($scope.isCoverOperation) {
$scope.coverDocFileRecord($scope.editFieldModel, 'simple');
title = $translate.instant("Edited");
// $scope.coverDocFileRecord($scope.editFieldModel, 'simple');
} else {
$scope.addLogicAfterUploadFile($scope.editFieldModel, 'simple');
title = $translate.instant("Uploaded");
// $scope.addLogicAfterUploadFile($scope.editFieldModel, 'simple');
}
// console.info('onSuccessItem', arguments);
SweetAlert.swal({
title:title,
type: "success",
confirmButtonText: $translate.instant('Confirm'),
closeOnConfirm: true
},
function (isConfirm) {
if(isConfirm) $scope.loadMainData();
});
$('#simpleUploadPopDialog').modal('hide');
};
}]
}
......@@ -709,7 +733,6 @@ taxDocumentManageModule.directive('multiFileUploader',function () {
},500);
$scope.multiUploader = new FileUploader({
url: "http://etms.longi-silicon.com:8180/api/v1/taxDoc/upload",
// autoUpload: true,//添加后,自动上传
headers:{"Authorization":apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken()},
removeAfterUpload:true,
......@@ -717,9 +740,6 @@ taxDocumentManageModule.directive('multiFileUploader',function () {
$scope.multiUploader.filters.push({//xls限制
name: 'fileTypeFilter',
fn: function (item, options) {
// var type = item.name.split(".").pop();
// var matchResult = /xlsx|xls|pdf/i.test(type);
// if(matchResult){
var fileNativePath = $("#multiUploadFilePlugin")[0].value;
var splitMark = /\//.test(fileNativePath) ? "/" : "\\";
var prevPath = fileNativePath.split(splitMark);
......@@ -730,8 +750,6 @@ taxDocumentManageModule.directive('multiFileUploader',function () {
fileName:item.name,
iShow:$scope.editFieldModel_multi.length === 0
});
// }
// 根据需求,改为不做类型限制
return true;
}
......@@ -751,55 +769,59 @@ taxDocumentManageModule.directive('multiFileUploader',function () {
$scope.multiUploadSuccessItems = [];
$scope.multiUploader.onCompleteAll = function () {
if($scope.multiUploadErrorItems.length >=5){
//如果上传错误大于5个,直接取消上传行为
console.info("失败数量:",$scope.multiUploadErrorItems);
SweetAlert.warning($translate.instant('UploadLimit'));
}else{
console.info("成功数量:",$scope.multiUploadSuccessItems);
//先探测有没有覆盖的情况
$scope.editFieldModel_multi.forEach(function(fieldItem){
taxDocumentListService.verifyDuplicate(fieldItem).then(function(data){
//$scope.multiUploadSuccessItems的长度可以用作判断上传是否已经完成
$scope.multiUploadSuccessItems.shift();
if (data === true) {
$scope.addLogicAfterUploadFile(fieldItem,'multi');
} else {
$scope.coverDocFileRecord(fieldItem,'multi');
}
});
});
}
$scope.multiUploader.clearQueue();
$("#uploadResultPop").modal("show");
$('#multiUploadPopDialog').modal('hide');
// $scope.multiUploader.clearQueue();
};
$scope.multiUploader.onSuccessItem = function(fileItem,response) {
fileItem.filePositionUrl = response;
// fileItem.filePositionUrl = response;
$scope.multiUploadSuccessItems.push(fileItem);
// 存储返回的URL
$scope.editFieldModel_multi.forEach(function(modelItem){
if(modelItem.fileName === fileItem._file.name){
modelItem.filePositionUrl = response;
}
});
};
$scope.multiUploadSubmit = function(){
$scope.multiUploadErrorItems = [];
$scope.multiUploadSuccessItems = [];
for(var i = 0; i < $scope.multiUploader.queue.length;i++){
// 先设置uploader队列里每个文件的请求参数:fileOriginalName
var fileItem = $scope.multiUploader.queue[i];
fileItem.formData = [{
fileOriginName:fileItem._file.name
fileOriginName:fileItem.name ? fileItem.name : fileItem._file.name
}];
var editFieldModel = $scope.editFieldModel_multi[i];
Object.keys(editFieldModel).forEach(function(key){
var fields = {};
if(/(ownTime|fileTime|effectiveTime)/.test(key)){
fields[key] = editFieldModel[key].split("-").join("/");
}else{
fields[key] = editFieldModel[key];
}
fileItem.formData.push(fields);
});
(function(_i,_fileItem,_editFieldModel,_taxDocumentListService,_multiUploader){
_taxDocumentListService.verifyDuplicate(_editFieldModel).then(function(data){
if (data === true) {
_fileItem.url = apiInterceptor.webApiHostUrl + "/taxDoc/add";
} else {
_fileItem.url = apiInterceptor.webApiHostUrl + "/taxDoc/edit";
}
_multiUploader.uploadItem(_i);
});
})(i,fileItem,editFieldModel,taxDocumentListService,$scope.multiUploader);
$scope.multiUploader.uploadItem(i);
}
}
};
$scope.confirmUploadResult = function(){
$('#uploadResultPop').modal('hide');
$scope.loadMainData();
};
}]
}
});
......@@ -839,7 +861,45 @@ taxDocumentManageModule.directive('filePreview',function(){
SweetAlert.warning($translate.instant('UnFile'));
}
};*/
$scope.currentSheetName = '';
var sheetCurPageIndex = 0;
var sheetSumPages = 1;
var sheetPromise = null;
var cacheUrl = null;
$scope.prevPaging_xls = function(){
if(sheetCurPageIndex <= 0) return sheetCurPageIndex = 0;
sheetCurPageIndex --;
sheetPromise.then(function(resData){renderXLS(resData)})
};
$scope.nextPaging_xls = function(){
if(sheetCurPageIndex >= (sheetSumPages - 1)) return sheetCurPageIndex = sheetSumPages - 1;
sheetCurPageIndex ++;
sheetPromise.then(function(resData){renderXLS(resData)})
};
function getXLS(url){
// return taxDocumentListService.getBinaryData('./bundles/MS Function list - Phase 1.xlsx');
return taxDocumentListService.getBinaryData(url);
}
function renderXLS(resData){
try{
var wb = window.XLSX.read(resData, {type:"array"});
sheetSumPages = wb.SheetNames.length;
$scope.currentSheetName = wb.SheetNames[sheetCurPageIndex];
var data = window.XLSX.utils.sheet_to_json(wb.Sheets[$scope.currentSheetName]);
// console.log(data);
if(data && data.length){
$scope.filePreview_dataGridUpdate(data);
$("#filePreviewPop").modal("show");
}
}catch(e){
SweetAlert.warning(e.message);
}
}
$scope.viewRemoteFile = function (fileName, filePositionUrl) {
if(typeof filePositionUrl !== 'string'
|| filePositionUrl === 'null'
......@@ -849,19 +909,12 @@ taxDocumentManageModule.directive('filePreview',function(){
//区分文件类型
var fileType = fileName.split(".").pop();
if(/xlsx|xls/i.test(fileType)){
taxDocumentListService.getBinaryData(filePositionUrl).then(function(resData){
try{
var wb = window.XLSX.read(resData, {type:"array"});
var data = window.XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
// console.log(data);
if(data && data.length){
$scope.filePreview_dataGridUpdate(data);
$("#filePreviewPop").modal("show");
}
}catch(e){
SweetAlert.warning(e.message);
}
});
if(cacheUrl !== filePositionUrl){
cacheUrl = filePositionUrl;
sheetPromise = getXLS(filePositionUrl);
}
sheetPromise.then(function(resData){renderXLS(resData)})
}
else if(/pdf/i.test(fileType)){
// return SweetAlert.warning('暂时不支持PDF预览');
......@@ -936,7 +989,7 @@ taxDocumentManageModule.directive('filePreview',function(){
rowAlternationEnabled: true, //单双行颜色
};
var dataGrid = $('<div dx-data-grid="filePreview_dataGridOptions">');
$("#preview_dataGrid").append(dataGrid);
$("#preview_dataGrid").html("").append(dataGrid);
$compile(dataGrid)($scope);
};
......@@ -981,12 +1034,12 @@ taxDocumentManageModule.directive('pdfPreview',function(){
container.style.display = "none";
};
$scope.prevPaging = function(){
if(pdfCurPageIndex === 1) return;
if(pdfCurPageIndex <= 1) return pdfCurPageIndex = 1;
pdfCurPageIndex --;
pdfPromise.then(function(pdf){renderPdf(pdf)})
};
$scope.nextPaging = function(){
if(pdfCurPageIndex === pdfSumPages) return;
if(pdfCurPageIndex >= pdfSumPages) return pdfCurPageIndex = pdfSumPages;
pdfCurPageIndex ++;
pdfPromise.then(function(pdf){renderPdf(pdf)})
};
......
......@@ -355,6 +355,7 @@
<div class="TDL-query-val">
<select ng-model="queryFieldModel.companyName" class="form-control radius3"
title="{{queryFieldModel.companyName}}" required placeholder="{{'PleaseSelected' | translate}}">
<option selected></option>
<option ng-repeat="(key,companyName) in companyNameOptionsMap"
ng-click="queryFieldModel.companyId = key"
value="{{companyName}}">{{companyName}}</option>
......@@ -614,7 +615,7 @@
{{'Duration' | translate}}
</label>
<div class="col-sm-11" style="width:61.67%">
<input type='text' placeholder="{{'PleaseSelected' | translate}}" date-time-picker data-date-format="yyyy-mm-dd" style="width:320px;"
<input type='text' placeholder="{{'PleaseSelected' | translate}}" date-time-picker data-date-format="yyyy/mm/dd" style="width:320px;"
class="form-control" ng-model="editFieldModel.ownTime" required
data-min-view="2"/>
</div>
......@@ -624,7 +625,7 @@
{{'AvailabilityDate' | translate}}
</label>
<div class="col-sm-11" style="width:61.67%">
<input type='text' placeholder="{{'PleaseSelected' | translate}}" date-time-picker data-date-format="yyyy-mm-dd" style="width:320px;"
<input type='text' placeholder="{{'PleaseSelected' | translate}}" date-time-picker data-date-format="yyyy/mm/dd" style="width:320px;"
class="form-control" ng-model="editFieldModel.fileTime"
data-min-view="2"/>
</div>
......@@ -632,7 +633,7 @@
<div class="col-sm-6 form-group">
<label class="col-sm-3 control-label" translate="DueDate"></label>
<div class="col-sm-11" style="width:61.67%">
<input type='text' placeholder="{{'PleaseSelected' | translate}}" date-time-picker data-date-format="yyyy-mm-dd" style="width:320px;"
<input type='text' placeholder="{{'PleaseSelected' | translate}}" date-time-picker data-date-format="yyyy/mm/dd" style="width:320px;"
class="form-control" ng-model="editFieldModel.effectiveTime"
data-min-view="2"/>
</div>
......@@ -821,7 +822,7 @@
{{'Duration' | translate}}
</label>
<div class="col-sm-11" style="width:61.67%">
<input type='text' placeholder="{{'PleaseSelected' | translate}}" date-time-picker data-date-format="yyyy-mm-dd" style="width:280px;"
<input type='text' placeholder="{{'PleaseSelected' | translate}}" date-time-picker data-date-format="yyyy/mm/dd" style="width:280px;"
class="form-control" ng-model="editFieldItem.ownTime" required
data-min-view="2"/>
</div>
......@@ -831,7 +832,7 @@
{{'AvailabilityDate' | translate}}
</label>
<div class="col-sm-11" style="width:61.67%">
<input type='text' placeholder="{{'PleaseSelected' | translate}}" date-time-picker data-date-format="yyyy-mm-dd" style="width:280px;"
<input type='text' placeholder="{{'PleaseSelected' | translate}}" date-time-picker data-date-format="yyyy/mm/dd" style="width:280px;"
class="form-control" ng-model="editFieldItem.fileTime"
data-min-view="2"/>
</div>
......@@ -839,7 +840,7 @@
<div class="col-sm-6 form-group">
<label class="col-sm-3 control-label" translate="DueDate"></label>
<div class="col-sm-11" style="width:61.67%">
<input type='text' placeholder="{{'PleaseSelected' | translate}}" date-time-picker data-date-format="yyyy-mm-dd" style="width:280px;"
<input type='text' placeholder="{{'PleaseSelected' | translate}}" date-time-picker data-date-format="yyyy/mm/dd" style="width:280px;"
class="form-control" ng-model="editFieldItem.effectiveTime"
data-min-view="2"/>
</div>
......@@ -903,7 +904,7 @@
<div class="modal-content">
<div class="modal-header">
<span class="close" data-dismiss="modal" aria-hidden="true" ng-click="hideFilePreviewPop()">×</span>
<div class="modal-title">{{fileName}}</div>
<div class="modal-title">{{currentSheetName}}</div>
</div>
<div class="modal-body">
<div class="dx-viewport demo-container" id="preview_dataGrid">
......@@ -911,6 +912,37 @@
</div>
</div>
<button class="TDL-pdf-paging-btn TDL-pdf-paging-btn-prev" ng-click="prevPaging_xls()" title="上一页">&lt;</button>
<button class="TDL-pdf-paging-btn TDL-pdf-paging-btn-next" ng-click="nextPaging_xls()" title="下一页">&gt;</button>
</div>
</div>
<div class="modal fade" id="uploadResultPop" tabindex="-1" role="dialog" aria-labelledby="myModal" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog" style="width:80%;" role="document">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title">提示讯息</div>
</div>
<div class="modal-body">
<p ng-if="multiUploadSuccessItems.length">{{multiUploadSuccessItems.length}}个档案上传成功</p>
<ul>
<li ng-repeat="item in multiUploadSuccessItems">
<span>{{item._file.name}}</span>
</li>
</ul>
<p ng-if="multiUploadErrorItems.length">{{multiUploadErrorItems.length}}个档案上传失败</p>
<ul>
<li ng-repeat="item in multiUploadErrorItems">
<span>{{item._file.name}}</span>
</li>
</ul>
</div>
<div class="modal-footer">
<button class="btn btn-primary" translate="Confirm" ng-click="confirmUploadResult()"></button>
<!--<button type="button" class="btn btn-third" data-dismiss="modal" translate="Cancel"></button>-->
</div>
</div>
</div>
</div>
......
......@@ -2,8 +2,8 @@
* Created by Administrator on 2019/3/1 0001.
*/
taxDocumentManageModule.factory('taxDocumentListService',
['$q', 'apiConfig', 'jqFetch','apiInterceptor',
function ($q, apiConfig, jqFetch,apiInterceptor) {
['$q', 'apiConfig', 'jqFetch', 'apiInterceptor',
function ($q, apiConfig, jqFetch, apiInterceptor) {
'use strict';
return {
fetchMainList: function (params) {
......@@ -15,33 +15,35 @@ taxDocumentManageModule.factory('taxDocumentListService',
editRecord: function (params) {
return jqFetch.post(apiInterceptor.webApiHostUrl + '/taxDoc/edit', params);
},
verifyDuplicate:function(params){
verifyDuplicate: function (params) {
return jqFetch.post(apiInterceptor.webApiHostUrl + '/taxDoc/queryWhetherData', params);
},
getFileInfoOptions:function(params){
getFileInfoOptions: function (params) {
return jqFetch.post(apiInterceptor.webApiHostUrl + '/fileTypes/query4SelectionBox', params);
},
getCompanyNameOptions:function(params){
getCompanyNameOptions: function (params) {
return jqFetch.get(apiInterceptor.webApiHostUrl + '/org/getMyOrgList', params);
},
delFileRecordItems:function(params){
delFileRecordItems: function (params) {
return jqFetch.post(apiInterceptor.webApiHostUrl + '/taxDoc/batchDelete', params);
},
getBinaryData:function(url){
getBinaryData: function (url) {
var defer = $q.defer();
var oReq = new XMLHttpRequest();
oReq.onload = function(e) {
oReq.onload = function (e) {
var arraybuffer = oReq.response;
console.info("arraybuffer:",arraybuffer);
console.info("arraybuffer:", arraybuffer);
defer.resolve(arraybuffer);
};
// oReq.open("GET", 'http://47.94.233.173:11007/static/erp_tax_system/3221D133-85B8-4E22-AE9B-DBEBD942D217?expire=1552361736&signiture=_Wz1_8Z6T8h5qnZAGpoRa8kNZeqmE7KoztKeehzYK4U=', true);
oReq.open("GET", url, true);
oReq.responseType = "arraybuffer";
oReq.send();
// return jqFetch.get(url,{},'arraybuffer');
return defer.promise;
}
};
}]);
\ No newline at end of file
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