Commit a2ed84ef authored by eddie.woo's avatar eddie.woo

Merge branch 'dev_mysql' of http://code.tech.tax.asia.pwcinternal.com/root/atms into dev_mysql

parents cb9a4f47 7af95349
......@@ -16,9 +16,9 @@
<dependencies>
<!-- https://mvnrepository.com/artifact/com.oracle/ojdbc6 -->
<!--<dependency>-->
<!--<groupId>com.oracle</groupId>-->
<!--<artifactId>ojdbc</artifactId>-->
<!--<version>0.0.1</version>-->
<!--<groupId>com.oracle</groupId>-->
<!--<artifactId>ojdbc</artifactId>-->
<!--<version>0.0.1</version>-->
<!--</dependency>-->
<!--<dependency>
<groupId>com.oracle</groupId>
......@@ -74,17 +74,18 @@
<version>4.2.3.RELEASE</version>
</dependency>
<!--去除swagger-->
<!-- <dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>-->
<!-- <dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
......@@ -442,7 +443,7 @@
<profiles>
<profile>
<id>dev</id>
<activation>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
......@@ -454,8 +455,8 @@
<env>dev</env>
</properties>
</profile>
<profile>
<id>staging</id>
<build>
......@@ -522,13 +523,13 @@
<targetPath>${basedir}/target/classes/userTemplate</targetPath>
</resource>
<resource>
<directory>src/main/resources/vat_excel_template</directory>
<includes>
<include>**/*.xls</include>
<include>**/*.xlsx</include>
</includes>
<targetPath>${basedir}/target/classes/vat_excel_template</targetPath>
</resource>
<directory>src/main/resources/vat_excel_template</directory>
<includes>
<include>**/*.xls</include>
<include>**/*.xlsx</include>
</includes>
<targetPath>${basedir}/target/classes/vat_excel_template</targetPath>
</resource>
<resource>
<directory>src/main/resources/cit_excel_template</directory>
<includes>
......@@ -553,6 +554,14 @@
</includes>
<targetPath>${basedir}/target/classes/user_excel_template</targetPath>
</resource>
<resource>
<directory>src/main/resources/analysis_excel_init</directory>
<includes>
<include>**/*.xls</include>
<include>**/*.xlsx</include>
</includes>
<targetPath>${basedir}/target/classes/analysis_excel_init</targetPath>
</resource>
</resources>
<plugins>
<plugin>
......
......@@ -13,7 +13,8 @@ public enum EnumImportType {
InvoiceRecord(9),
ExtractFinancialData(10),
ExtractInvoiceData(11),
RevenueMapping(12)
RevenueMapping(12),
RevenueConfig(13)
;
private Integer code;
......
......@@ -15,7 +15,7 @@ public class RevenueConfEnum {
private Integer code;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
public static final Map<String, Integer> REVERSAL_MAPPING = new HashMap<>();
AccountType(Integer code, String name) {
this.code = code;
this.name = name;
......@@ -32,6 +32,7 @@ public class RevenueConfEnum {
static {
for (RevenueConfEnum.AccountType accountType : RevenueConfEnum.AccountType.values()) {
MAPPING.put(accountType.getCode(), accountType.getName());
REVERSAL_MAPPING.put(accountType.getName(),accountType.getCode());
}
}
}
......@@ -48,7 +49,7 @@ public class RevenueConfEnum {
private Integer code;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
public static final Map<String, Integer> REVERSAL_MAPPING = new HashMap<>();
TaxBase(Integer code, String name) {
this.code = code;
this.name = name;
......@@ -65,6 +66,7 @@ public class RevenueConfEnum {
static {
for (RevenueConfEnum.TaxBase taxBase : RevenueConfEnum.TaxBase.values()) {
MAPPING.put(taxBase.getCode(), taxBase.getName());
REVERSAL_MAPPING.put(taxBase.getName(),taxBase.getCode());
}
}
}
......@@ -80,7 +82,7 @@ public class RevenueConfEnum {
private Integer code;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
public static final Map<String, Integer> REVERSAL_MAPPING = new HashMap<>();
TaxType(Integer code, String name) {
this.code = code;
this.name = name;
......@@ -97,6 +99,7 @@ public class RevenueConfEnum {
static {
for (RevenueConfEnum.TaxType taxType : RevenueConfEnum.TaxType.values()) {
MAPPING.put(taxType.getCode(), taxType.getName());
REVERSAL_MAPPING.put(taxType.getName(),taxType.getCode());
}
}
}
......@@ -110,7 +113,7 @@ public class RevenueConfEnum {
private Integer code;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
public static final Map<String, Integer> REVERSAL_MAPPING = new HashMap<>();
RevenueType(Integer code, String name) {
this.code = code;
this.name = name;
......@@ -127,6 +130,7 @@ public class RevenueConfEnum {
static {
for (RevenueConfEnum.RevenueType revenueType : RevenueConfEnum.RevenueType.values()) {
MAPPING.put(revenueType.getCode(), revenueType.getName());
REVERSAL_MAPPING.put(revenueType.getName(),revenueType.getCode());
}
}
}
......@@ -140,7 +144,7 @@ public class RevenueConfEnum {
private Integer code;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
public static final Map<String, Integer> REVERSAL_MAPPING = new HashMap<>();
Status(Integer code, String name) {
this.code = code;
this.name = name;
......@@ -157,8 +161,48 @@ public class RevenueConfEnum {
static {
for (RevenueConfEnum.Status status : RevenueConfEnum.Status.values()) {
MAPPING.put(status.getCode(), status.getName());
REVERSAL_MAPPING.put(status.getName(),status.getCode());
}
}
}
public enum EXECLColumn {
Column_1(0, "收入类型名称"),
Column_2(1, "适用公司"),
Column_3(2, "账载收入"),
Column_4(3, "科目代码"),
Column_5(4, "利润中心代码"),
Column_6(5, "产品代码"),
Column_7(6, "税率"),
Column_8(7, "计税收入"),
Column_9(8, "计税收入科目代码"),
Column_10(9, "收入类型"),
Column_11(10, "计税方法"),
Column_12(11, "状态"),
Column_13(12, "起始日期"),
Column_14(13, "终止日期")
;
private Integer index;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
EXECLColumn(Integer index, String name) {
this.index = index;
this.name = name;
}
public Integer getIndex() {
return index;
}
public String getName() {
return name;
}
static {
for (TaxesCalculateReportEnum.Column accountType : TaxesCalculateReportEnum.Column.values()) {
MAPPING.put(accountType.getIndex(), accountType.getName());
}
}
}
}
package pwc.taxtech.atms.controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.constant.enums.EnumImportType;
import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.dto.input.CamelPagingResultDto;
import pwc.taxtech.atms.dto.revenuconf.RevConfAddDto;
......@@ -13,6 +13,9 @@ import pwc.taxtech.atms.service.impl.RevenueConfService;
import pwc.taxtech.atms.vat.entity.RevenueConfig;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
@RestController
......@@ -48,4 +51,33 @@ public class RevenueConfController extends BaseController {
revenueConfService.delConfig(idList);
return ApiResultDto.success();
}
@PostMapping("upload")
public ApiResultDto upload(@RequestParam MultipartFile file, @RequestParam Integer type) throws Exception {
List<String> unSuccessList = revenueConfService.upload(file, type);
return ApiResultDto.success(unSuccessList);
}
@GetMapping("export")
public void export(HttpServletResponse response) throws Exception {
OutputStream ouputStream = null;
try {
InputStream inputStream = this.getClass().getResourceAsStream("/document/DataImport/" + EnumImportType.RevenueConfig.name() + ".xlsx");
Workbook tWorkbook = revenueConfService.export(inputStream);
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", "attachment;fileName=" + EnumImportType.RevenueConfig.name() + ".xlsx");
ouputStream = response.getOutputStream();
tWorkbook.write(ouputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (ouputStream != null) {
ouputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
......@@ -5,19 +5,30 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.POIUtil;
import pwc.taxtech.atms.constant.enums.RevenueConfEnum;
import pwc.taxtech.atms.dpo.OrgSelectDto;
import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.dto.revenuconf.RevConfAddDto;
import pwc.taxtech.atms.dto.revenuconf.RevenueConfParam;
import pwc.taxtech.atms.dto.revenuconf.RevenueConfResult;
import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.vat.dao.RevenueConfigMapper;
import pwc.taxtech.atms.vat.entity.RevenueConfig;
import pwc.taxtech.atms.vat.entity.RevenueConfigExample;
import javax.annotation.Resource;
import java.util.List;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Service
......@@ -127,4 +138,182 @@ public class RevenueConfService extends BaseService {
return config;
}
public List<String> upload(MultipartFile file, Integer type) throws Exception {
List<String> unSuccessList = new ArrayList<>();
List<RevenueConfig> dataList = new ArrayList<>();
InputStream inputStream = file.getInputStream();
Workbook workbook = WorkbookFactory.create(inputStream);
Sheet sheet = workbook.getSheetAt(0);
List<OrgSelectDto> orgDtoList = organizationService.getMyOrgList();
List<String> orgIds = new ArrayList<>();
String unSuccessMsg;
for (int r = sheet.getFirstRowNum()+1; r <= sheet.getLastRowNum(); r++) {
Row row = sheet.getRow(r);
unSuccessMsg = "第"+(r+1)+"行:";
String orgName = POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_2.getIndex()));
Optional<OrgSelectDto> optional = orgDtoList.stream().filter(o -> StringUtils.equals(o.getName(), orgName)).findFirst();
if (!optional.isPresent()) {
unSuccessMsg +="|公司不存在|";
unSuccessList.add(unSuccessMsg);
continue;
}
String msg = verifyColumn(row);
if(StringUtils.isNotBlank(msg)){
unSuccessMsg+=msg;
unSuccessList.add(unSuccessMsg);
continue;
}
RevenueConfig revenueConfig = new RevenueConfig();
revenueConfig.setId(idService.nextId());
revenueConfig.setSerialNo("");
revenueConfig.setAccountName("");
revenueConfig.setOrgId(optional.get().getId());
orgIds.add(optional.get().getId());
revenueConfig.setName(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_1.getIndex())));
revenueConfig.setAccountType(RevenueConfEnum.AccountType.REVERSAL_MAPPING.get(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_3.getIndex()))));
revenueConfig.setTbSegment3(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_4.getIndex())));
if(StringUtils.isBlank(revenueConfig.getTbSegment3())){
revenueConfig.setTbSegment3("");
}
revenueConfig.setTbSegment5(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_5.getIndex())));
if(StringUtils.isBlank(revenueConfig.getTbSegment5())){
revenueConfig.setTbSegment5("");
}
revenueConfig.setTbSegment6(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_6.getIndex())));
if(StringUtils.isBlank(revenueConfig.getTbSegment6())){
revenueConfig.setTbSegment6("");
}
String taxRat = POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_7.getIndex()));
// taxRat = taxRat.replaceAll("%","");
revenueConfig.setTaxRate(new BigDecimal(taxRat));
revenueConfig.setTaxBase(RevenueConfEnum.TaxBase.REVERSAL_MAPPING.get(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_8.getIndex()))));
if(revenueConfig.getTaxBase().intValue() == 4){
revenueConfig.setBaseDrCode(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_9.getIndex())));
revenueConfig.setBaseCrCode("");
}else if(revenueConfig.getTaxBase().intValue() == 5){
revenueConfig.setBaseCrCode(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_9.getIndex())));
revenueConfig.setBaseDrCode("");
}else{
revenueConfig.setBaseDrCode("");
revenueConfig.setBaseCrCode("");
}
revenueConfig.setRevenueType(RevenueConfEnum.RevenueType.REVERSAL_MAPPING.get(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_10.getIndex()))));
revenueConfig.setTaxType(RevenueConfEnum.TaxType.REVERSAL_MAPPING.get(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_11.getIndex()))));
revenueConfig.setStatus(RevenueConfEnum.Status.REVERSAL_MAPPING.get(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_12.getIndex()))));
revenueConfig.setStartDate(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_13.getIndex())));
revenueConfig.setEndDate(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_14.getIndex())));
revenueConfig.setCreateBy("Admin");
revenueConfig.setUpdateBy("Admin");
revenueConfig.setUpdateTime(new Date());
revenueConfig.setCreateTime(new Date());
dataList.add(revenueConfig);
}
if (1 == type) {
if(CollectionUtils.isNotEmpty(orgIds)){
RevenueConfigExample delExample = new RevenueConfigExample();
delExample.createCriteria().andOrgIdIn(orgIds);
revenueConfigMapper.deleteByExample(delExample);
}
}
if (!CollectionUtils.isEmpty(dataList)) {
List<List<RevenueConfig>> batchList = CommonUtils.subListWithLen(dataList, CommonUtils.BATCH_NUM_2000);
batchList.forEach(l -> revenueConfigMapper.batchInsert(l));
}
return unSuccessList;
}
public String verifyColumn(Row row){
String msg = "";
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_1.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_1.getName()+"值有错误|";
}
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_7.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_7.getName()+"值有错误|";
}
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_13.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_13.getName()+"值有错误|";
}
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_14.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_14.getName()+"值有错误|";
}
if(!RevenueConfEnum.AccountType.REVERSAL_MAPPING.containsKey(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_3.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_3.getName()+"值有错误|";
}else{
if(RevenueConfEnum.AccountType.REVERSAL_MAPPING.get(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_3.getIndex()))).intValue()==1){
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_4.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_4.getName()+"值有错误|";
}
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_5.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_5.getName()+"值有错误|";
}
if(StringUtils.isBlank(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_6.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_6.getName()+"值有错误|";
}
}
}
if(!RevenueConfEnum.TaxBase.REVERSAL_MAPPING.containsKey(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_8.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_8.getName()+"值有错误|";
}
if(!RevenueConfEnum.RevenueType.REVERSAL_MAPPING.containsKey(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_10.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_10.getName()+"值有错误|";
}
if(!RevenueConfEnum.TaxType.REVERSAL_MAPPING.containsKey(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_11.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_11.getName()+"值有错误|";
}
if(!RevenueConfEnum.Status.REVERSAL_MAPPING.containsKey(POIUtil.getCellFormulaString(row.getCell(RevenueConfEnum.EXECLColumn.Column_12.getIndex())))){
msg +="|"+RevenueConfEnum.EXECLColumn.Column_12.getName()+"值有错误|";
}
return msg;
}
public Workbook export(InputStream is){
Workbook tWorkbook = new XSSFWorkbook();
try {
tWorkbook = WorkbookFactory.create(is);
Sheet sheet = tWorkbook.getSheetAt(0);
Row sourceRow = sheet.getRow(1);
//查询公司map
List<OrgSelectDto> orgDtoList = organizationService.getMyOrgList();
Map<String, String> orgMap = orgDtoList.stream().collect(Collectors.toMap(OrgSelectDto::getId, OrgSelectDto::getName, (value1, value2) -> {
return value2;
}));
if(CollectionUtils.isNotEmpty(orgDtoList)){
RevenueConfigExample example = new RevenueConfigExample();
example.createCriteria().andOrgIdIn(orgDtoList.stream().map(OrgSelectDto::getId).collect(Collectors.toList()));
example.setOrderByClause("org_id");
List<RevenueConfig> dataList = revenueConfigMapper.selectByExample(example);
if(CollectionUtils.isNotEmpty(dataList)){
for(int i = dataList.size()-1;i>=0;i--){
RevenueConfig revenueConfig = dataList.get(i);
Row row = POIUtil.createAndCloneRow(tWorkbook, sheet, 1, sourceRow);
row.getCell(RevenueConfEnum.EXECLColumn.Column_1.getIndex()).setCellValue(revenueConfig.getName());
row.getCell(RevenueConfEnum.EXECLColumn.Column_2.getIndex()).setCellValue(orgMap.get(revenueConfig.getOrgId()));
row.getCell(RevenueConfEnum.EXECLColumn.Column_3.getIndex()).setCellValue(RevenueConfEnum.AccountType.MAPPING.get(revenueConfig.getAccountType()));
row.getCell(RevenueConfEnum.EXECLColumn.Column_4.getIndex()).setCellValue(revenueConfig.getTbSegment3());
row.getCell(RevenueConfEnum.EXECLColumn.Column_5.getIndex()).setCellValue(revenueConfig.getTbSegment5());
row.getCell(RevenueConfEnum.EXECLColumn.Column_6.getIndex()).setCellValue(revenueConfig.getTbSegment6());
row.getCell(RevenueConfEnum.EXECLColumn.Column_7.getIndex()).setCellValue(String.valueOf(revenueConfig.getTaxRate().multiply(new BigDecimal(100)).intValue())+"%");
row.getCell(RevenueConfEnum.EXECLColumn.Column_8.getIndex()).setCellValue(RevenueConfEnum.TaxBase.MAPPING.get(revenueConfig.getTaxBase()));
if(revenueConfig.getTaxBase().intValue() == 4){
row.getCell(RevenueConfEnum.EXECLColumn.Column_9.getIndex()).setCellValue(revenueConfig.getBaseDrCode());
}else if(revenueConfig.getTaxBase().intValue() == 5){
row.getCell(RevenueConfEnum.EXECLColumn.Column_9.getIndex()).setCellValue(revenueConfig.getBaseCrCode());
}else{
row.getCell(RevenueConfEnum.EXECLColumn.Column_9.getIndex()).setCellValue("");
}
row.getCell(RevenueConfEnum.EXECLColumn.Column_10.getIndex()).setCellValue(RevenueConfEnum.RevenueType.MAPPING.get(revenueConfig.getRevenueType()));
row.getCell(RevenueConfEnum.EXECLColumn.Column_11.getIndex()).setCellValue(RevenueConfEnum.TaxType.MAPPING.get(revenueConfig.getTaxType()));
row.getCell(RevenueConfEnum.EXECLColumn.Column_12.getIndex()).setCellValue(RevenueConfEnum.Status.MAPPING.get(revenueConfig.getStatus()));
row.getCell(RevenueConfEnum.EXECLColumn.Column_13.getIndex()).setCellValue(revenueConfig.getStartDate());
row.getCell(RevenueConfEnum.EXECLColumn.Column_14.getIndex()).setCellValue(revenueConfig.getEndDate());
}
}
}
sheet.removeRow(sourceRow);
return tWorkbook;
} catch (Exception e) {
logger.error("export error.", e);
throw Exceptions.SERVER_ERROR_EXCEPTION;
}
}
}
......@@ -6,12 +6,16 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.grapecity.documents.excel.V;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -1732,6 +1736,40 @@ public class ReportServiceImpl extends BaseService {
return ebitDataDto;
}
public EbitDataDto ebitCellDataToEbitDataDto(List<EbitCellData> ebitCellData) {
EbitDataDto ebitDataDto = new EbitDataDto();
for (EbitCellData ebitCellData1 : ebitCellData) {
if (ebitCellData1.getCol() == 1)
continue;
switch (ebitCellData1.getRow()) {
case 37:
ebitDataDto.setEbitSubtraction(new BigDecimal(ebitCellData1.getData()).setScale(2, BigDecimal.ROUND_HALF_UP));
if ((new BigDecimal(ebitCellData1.getData()).setScale(2, BigDecimal.ROUND_HALF_UP)).compareTo(new BigDecimal("0.0000")) == -1) {
return null;
}
break;
case 38:
ebitDataDto.setSpecialConsiderations(ebitCellData1.getData());
break;
case 39:
ebitDataDto.setSpecialFactors(new BigDecimal(ebitCellData1.getData()).setScale(2, BigDecimal.ROUND_HALF_UP));
break;
case 40:
ebitDataDto.setEbitRate(ebitCellData1.getData());
break;
case 41:
ebitDataDto.setTransactionAmount(new BigDecimal(ebitCellData1.getData()).setScale(2, BigDecimal.ROUND_HALF_UP));
break;
case 42:
ebitDataDto.setSixAddTax(new BigDecimal(ebitCellData1.getData()).setScale(2, BigDecimal.ROUND_HALF_UP));
break;
case 43:
ebitDataDto.setTotalAmountTax(new BigDecimal(ebitCellData1.getData()).setScale(2, BigDecimal.ROUND_HALF_UP));
break;
}
}
return ebitDataDto;
}
public EbitDataDto calculateEbitDataByEbit(List<EbitCellData> ebitCellData, String specialConsiderations, String ebitRate) {
EbitDataDto ebitDataDto = new EbitDataDto();
......@@ -1759,46 +1797,48 @@ public class ReportServiceImpl extends BaseService {
BigDecimal zcjzss = new BigDecimal(0); //资产减值损失
for (EbitCellData ebitCellData1 : ebitCellData) {
if (ebitCellData1.getCol() == 2 && ebitCellData1.getRow() == 11) { //一、营业收入
if(StringUtils.isNotEmpty(ebitCellData1.getData())) yysr = new BigDecimal(ebitCellData1.getData());
if (StringUtils.isNotEmpty(ebitCellData1.getData())) yysr = new BigDecimal(ebitCellData1.getData());
continue;
}
if (ebitCellData1.getCol() == 2 && ebitCellData1.getRow() == 12) {//减:营业成本
if(StringUtils.isNotEmpty(ebitCellData1.getData()))yycb = new BigDecimal(ebitCellData1.getData());
if (StringUtils.isNotEmpty(ebitCellData1.getData())) yycb = new BigDecimal(ebitCellData1.getData());
continue;
}
if (ebitCellData1.getCol() == 2 && ebitCellData1.getRow() == 13) {//营业税金及附加
if(StringUtils.isNotEmpty(ebitCellData1.getData())) yysjfj = new BigDecimal(ebitCellData1.getData());
if (StringUtils.isNotEmpty(ebitCellData1.getData()))
yysjfj = new BigDecimal(ebitCellData1.getData());
continue;
}
if (ebitCellData1.getCol() == 2 && ebitCellData1.getRow() == 14) {//销售费用
if(StringUtils.isNotEmpty(ebitCellData1.getData())) xsfy = new BigDecimal(ebitCellData1.getData());
if (StringUtils.isNotEmpty(ebitCellData1.getData())) xsfy = new BigDecimal(ebitCellData1.getData());
continue;
}
if (ebitCellData1.getCol() == 2 && ebitCellData1.getRow() == 15) {//管理费用
if(StringUtils.isNotEmpty(ebitCellData1.getData())) glfy = new BigDecimal(ebitCellData1.getData());
if (StringUtils.isNotEmpty(ebitCellData1.getData())) glfy = new BigDecimal(ebitCellData1.getData());
continue;
}
if (ebitCellData1.getCol() == 2 && ebitCellData1.getRow() == 16) {//研发费用
if(StringUtils.isNotEmpty(ebitCellData1.getData()))yffy = new BigDecimal(ebitCellData1.getData());
if (StringUtils.isNotEmpty(ebitCellData1.getData())) yffy = new BigDecimal(ebitCellData1.getData());
continue;
}
if (ebitCellData1.getCol() == 2 && ebitCellData1.getRow() == 18) {//资产减值损失
if(StringUtils.isNotEmpty(ebitCellData1.getData()))zcjzss = new BigDecimal(ebitCellData1.getData());
if (StringUtils.isNotEmpty(ebitCellData1.getData()))
zcjzss = new BigDecimal(ebitCellData1.getData());
continue;
}
}
BigDecimal subtract = yysr.subtract(yycb).add(yysjfj).add(xsfy).add(glfy).add(yffy).add(zcjzss);
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(String.valueOf(rate));
ebitDataDto.setTransactionAmount(ebitDataDto.getSpecialFactors().multiply(new BigDecimal(ebitDataDto.getEbitRate())));
ebitDataDto.setTransactionAmount(ebitDataDto.getSpecialFactors().multiply(new BigDecimal(ebitDataDto.getEbitRate())).setScale(2, BigDecimal.ROUND_HALF_UP));
if (ebitRate.indexOf("%") != -1) {
ebitDataDto.setEbitRate(ebitRate);
} else {
ebitDataDto.setEbitRate(ebitRate + "%");
}
ebitDataDto.setSixAddTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.06).setScale(2, BigDecimal.ROUND_UP)));
ebitDataDto.setTotalAmountTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(1.06).setScale(2, BigDecimal.ROUND_UP)));
ebitDataDto.setSixAddTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(0.06)).setScale(2, BigDecimal.ROUND_HALF_UP));
ebitDataDto.setTotalAmountTax(ebitDataDto.getTransactionAmount().multiply(new BigDecimal(1.06)).setScale(2, BigDecimal.ROUND_HALF_UP));
ebitDataDto.setSpecialConsiderations(specialConsiderations);
} catch (Exception e) {
e.printStackTrace();
......@@ -2532,7 +2572,6 @@ public class ReportServiceImpl extends BaseService {
didiFileUploadService.delData(ebitSpreadData1.get(0).getFileKey());
ebitSpreadDataMapper.deleteByExample(example);
}*/
EbitCellDataExample exampleCellData = new EbitCellDataExample();
exampleCellData.createCriteria().andPeriodEqualTo(period).andOrganizationIdEqualTo(orgId);
if (ebitCellDataMapper.selectByExample(exampleCellData).size() != 0) {
......@@ -2553,7 +2592,7 @@ public class ReportServiceImpl extends BaseService {
/* if (j <= 36)
continue;*/
for (int k = 1; k < sheet.getRow(0).getLastCellNum(); k++) {
if (k ==1 || k == 2){
if (k == 1 || k == 2) {
EbitCellData ebitCellData1 = new EbitCellData();
ebitCellData1.setId(idService.nextId());
ebitCellData1.setOrganizationId(orgId);
......@@ -2603,6 +2642,7 @@ public class ReportServiceImpl extends BaseService {
@Autowired
private JdbcTemplate jdbcTemplate;
private static CellStyle cellStyle1 = null;
/**
* 批量导出Excel ebit利润表
......@@ -2678,20 +2718,34 @@ public class ReportServiceImpl extends BaseService {
List<Integer> cols = Lists.newArrayList();
FileExcelUtil.deleteColumn(sheetAt, 1, cols);
//var profileList = ["EBIT考虑资产减值损失", "", "", "", "", "", ""];
List<String> ebitTitle = Lists.newArrayList("EBIT考虑资产减值损失", "加:特殊因素考虑", "EBIT(考虑特殊因素)", "EBIT rate", "关联交易金额", "6%增值税", "价税合计金额");
//设置单元格居右
cellStyle1 = workbook1.createCellStyle();//创建样式
cellStyle1.setAlignment(HorizontalAlignment.RIGHT);
CellStyle headerCellType = workbook1.createCellStyle();
//给第一个sheet创建ebit 行
for (int i = 37; i <= 43; i++) {
sheetAt.createRow(i).createCell(0).setCellValue(ebitTitle.get(i - 37));
}
List<EbitDataDto> ebitCellDataList = new ArrayList<>();
if (finalMap.size() == 0)
throw new Exception("没有利润表模板,无法批量导出,请上传模板");
for (Map.Entry<String, List<EbitCellData>> entry : finalMap.entrySet()) {
EbitCellDataExample example = new EbitCellDataExample();
example.createCriteria().andPeriodEqualTo(requestParameterDto.getPeriod()).andOrganizationIdEqualTo(entry.getKey());
List<EbitCellData> ebitCellDataList1 = ebitCellDataMapper.selectByExample(example);
if (ebitCellDataList1.size() != 0) {
EbitDataDto ebitDataDto = ebitCellDataToEbitDataDto(entry.getValue());
if (ebitDataDto == null) {
continue;
} else {
ebitCellDataList.add(ebitDataDto);
}
} else {
ebitCellDataList.add(calculateEbitDataByEbit(entry.getValue(), specialConsideration, ebitRate));
}
//加载计算ebit数据
ebitCellDataList.add(calculateEbitDataByEbit(entry.getValue(), specialConsideration, ebitRate));
for (int m = 0; m <= sheetAt.getLastRowNum(); m++) {
switch (m) {
case 7:
......@@ -2719,45 +2773,53 @@ public class ReportServiceImpl extends BaseService {
for (EbitCellData ebitCellData : entry.getValue()) {
if (m == ebitCellData.getRow()) {
try {
sheetAt.getRow(m).getCell(_index + 1).setCellValue(ebitCellData.getData());
sheetAt.getRow(m).getCell(_index + 1).setCellValue(ebitCellData.getData().equals("")== true ? "0" : ebitCellData.getData() );
} catch (Exception e) {
sheetAt.getRow(m).createCell(_index + 1).setCellValue(ebitCellData.getData());
sheetAt.getRow(m).createCell(_index + 1).setCellValue(ebitCellData.getData().equals("")== true ? "0" : ebitCellData.getData());
}
System.out.println(ebitCellData.getData());
}
}
}
//cell.setCellType(cellStyle.getAlignment());
}
for (EbitDataDto ebitCellData : ebitCellDataList) {
switch (m){
case 37:
cellAndOrCreate(m, _index+1, ebitCellData.getEbitSubtraction().toString(), sheetAt);
break;
case 38:
cellAndOrCreate(m, _index+1, ebitCellData.getSpecialConsiderations(), sheetAt);
break;
case 39:
cellAndOrCreate(m, _index+1, ebitCellData.getSpecialFactors().toString(), sheetAt);
break;
case 40:
cellAndOrCreate(m, _index+1, ebitCellData.getEbitRate(), sheetAt);
break;
case 41:
cellAndOrCreate(m, _index+1, ebitCellData.getTransactionAmount().toString(), sheetAt);
break;
case 42:
cellAndOrCreate(m, _index+1, ebitCellData.getSixAddTax().toString(), sheetAt);
break;
case 43:
cellAndOrCreate(m, _index+1, ebitCellData.getTotalAmountTax().toString(), sheetAt);
break;
if (m >= 37) {//加载ebit数据
for (EbitDataDto ebitCellData : ebitCellDataList) {
switch (m) {
case 37:
addFormula(cellAndOrCreate(m, _index + 1,
ebitCellData.getEbitSubtraction().toString(),
sheetAt), Lists.newArrayList("12- ", "13- ", "14- ", "15- ", "16- ", "18"), _index + 1);
break;
case 38:
cellAndOrCreate(m, _index + 1, ebitCellData.getSpecialConsiderations(), sheetAt);
break;
case 39:
addFormula(cellAndOrCreate(m, _index + 1, ebitCellData.getSpecialFactors().toString(), sheetAt),
Lists.newArrayList("38+ ", "39"), _index + 1);
break;
case 40:
cellAndOrCreate(m, _index + 1, ebitCellData.getEbitRate(), sheetAt);
break;
case 41:
addFormula(cellAndOrCreate(m, _index + 1, ebitCellData.getTransactionAmount().toString(), sheetAt),
Lists.newArrayList("40 * ", "41"), _index + 1);
break;
case 42:
addFormula(cellAndOrCreate(m, _index + 1, ebitCellData.getSixAddTax().toString(), sheetAt), Lists.newArrayList("42 * 0.06"), _index + 1);
break;
case 43:
addFormula(cellAndOrCreate(m, _index + 1, ebitCellData.getTotalAmountTax().toString(), sheetAt), Lists.newArrayList("42 * 1.06"), _index + 1);
break;
}
}
}
}
_index++;
}
///合并单元格
insertExcelOne(headerCellType, workbook1, sheetAt, _index, requestParameterDto);
/* for (int i = 0; i < ebitSpreadData.size(); i++) {
DidiFileIUploadParam fileParam = new DidiFileIUploadParam();
fileParam.setUuids(Arrays.asList(ebitSpreadData.get(i).getFileKey()));
......@@ -2796,17 +2858,24 @@ public class ReportServiceImpl extends BaseService {
FileExcelUtil.downloadExcel(request, response, requestParameterDto.getPeriod() + "-汇总利润表.xlsx", workbook1);
}
public void cellAndOrCreate(Integer row, Integer col,String data, Sheet sheetAt){
public void addFormula(Cell cell, List<String> mulaList, Integer col) {
StringBuilder stringBuilder = new StringBuilder();
mulaList.forEach(x -> {
stringBuilder.append(LetterExcelUtil.NumToExcel(col)+ x);
});
cell.setCellFormula(stringBuilder.toString());
}
public Cell cellAndOrCreate(Integer row, Integer col, String data, Sheet sheetAt) {
if (sheetAt.getRow(row).getCell(col) == null) {
sheetAt.getRow(row).createCell(col).setCellValue(data);
} else {
sheetAt.getRow(row).getCell(col).setCellValue(data);
}
sheetAt.getRow(row).getCell(col).setCellStyle(cellStyle1);
return sheetAt.getRow(row).getCell(col);
}
/* public void insertData(String templateId, Integer period, Sheet sheet, int beginCell) {
List<Project> projects = projectMapper.selectByExample(example1);
for (EbitCell project : ebitCellData) {
String projectId = getProjId(project.getOrganizationId(), period);
......@@ -2866,56 +2935,49 @@ public class ReportServiceImpl extends BaseService {
}*/
public void insertExcelOne(Sheet sheetAt, List<EbitSpreadData> spreadData, XSSFWorkbook workbook, Integer period) {
XSSFCellStyle cellStyle = workbook.createCellStyle();
XSSFFont font = workbook.createFont();
font.setFontHeight(20);
public void insertExcelOne(CellStyle headerCellType, XSSFWorkbook workbook1, Sheet sheetAt, Integer _index, RequestParameterDto requestParameterDto) {
headerCellType.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直
headerCellType.setAlignment(HorizontalAlignment.CENTER);// 水平
XSSFFont font = workbook1.createFont();
font.setBold(true);
cellStyle.setAlignment(HorizontalAlignment.CENTER);// 设置居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyle.setFont(font);
if (spreadData.size() != 0) {
sheetAt.getRow(6).getCell(1).setCellValue(getOrgName(spreadData.get(0).getOrganizationId()));
}
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
sheetAt.getRow(8).getCell(1).setCellValue("本年累计");
sheetAt.getRow(0).createCell(4).setCellValue("日期:" + format.format(new Date()));
for (int m = 0; m < 3; m++) {
if (sheetAt.getRow(m) == null)
continue;
}
sheetAt.createRow(2).createCell(3).setCellValue("本期" + period);
POIStyleUtil.setCellBackgroundColor(workbook, sheetAt.createRow(2).createCell(3), new XSSFColor(java.awt.Color.YELLOW));//设置背景颜色
sheetAt.getRow(0).getCell(1).setCellValue("");
sheetAt.getRow(0).createCell(3).setCellValue("利润表汇总");
sheetAt.getRow(0).getCell(3).setCellStyle(cellStyle);
font.setFontHeight(30);
headerCellType.setFont(font);
sheetAt.addMergedRegion(new CellRangeAddress(0, 0, 1, _index + 4));
sheetAt.getRow(0).getCell(1).setCellStyle(headerCellType);
POIStyleUtil.setCellBackgroundColor(workbook1, sheetAt.getRow(2).createCell(_index + 1), new XSSFColor(java.awt.Color.YELLOW));
sheetAt.getRow(2).getCell(_index + 1).setCellValue("本期:" + requestParameterDto.getPeriod());
}
public String getCellStringValue(Cell cell) {
String cellValue = null;
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_STRING://字符串类型
cellValue = cell.getStringCellValue();
if (cellValue.trim().equals("") || cellValue.trim().length() <= 0)
cellValue = "";
break;
case HSSFCell.CELL_TYPE_NUMERIC: //数值类型
cellValue = String.valueOf(cell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_FORMULA: //公式
cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
cellValue = String.valueOf(cell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_BLANK:
cellValue = " ";
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
break;
case HSSFCell.CELL_TYPE_ERROR:
break;
default:
break;
String cellValue = "";
try {
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_STRING://字符串类型
cellValue = cell.getStringCellValue();
if (cellValue.trim().equals("") || cellValue.trim().length() <= 0)
cellValue = "";
break;
case HSSFCell.CELL_TYPE_NUMERIC: //数值类型
cellValue = String.valueOf(cell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_FORMULA: //公式
cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
cellValue = String.valueOf(cell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_BLANK:
cellValue = " ";
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
break;
case HSSFCell.CELL_TYPE_ERROR:
break;
default:
break;
}
} catch (Exception e) {
//e.printStackTrace();
logger.warn("单元格取值失败");
return "";
}
return cellValue;
}
......
package pwc.taxtech.atms.vat.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
......@@ -8,6 +7,8 @@ import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.entity.RevenueConfig;
import pwc.taxtech.atms.vat.entity.RevenueConfigExample;
import java.util.List;
@Mapper
public interface RevenueConfigMapper extends MyVatMapper {
/**
......@@ -105,4 +106,6 @@ public interface RevenueConfigMapper extends MyVatMapper {
* @mbg.generated
*/
int updateByPrimaryKey(RevenueConfig record);
int batchInsert(List<RevenueConfig> list);
}
\ No newline at end of file
......@@ -414,24 +414,4 @@
</if>
</select>
<insert id="batchInsert">
insert into revenue_type_mapping
(id, org_id, ou_name, content, tax_rate, revenue_type_name, start_date, end_date, status, create_by, update_by, create_time, update_time) values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id},
#{item.orgId},
#{item.ouName},
#{item.content},
#{item.taxRate},
#{item.revenueTypeName},
#{item.startDate},
#{item.endDate},
#{item.status,jdbcType=TINYINT},
#{item.createBy},
#{item.updateBy},
#{item.createTime},
#{item.updateTime})
</foreach>
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pwc.taxtech.atms.vat.dao.RevenueConfigMapper">
<insert id="batchInsert">
insert into revenue_config
(id, serial_no, name, org_id, account_type, account_name, tax_rate, tax_base, revenue_type, tax_type, status, start_date, end_date, tb_segment3, tb_segment5, tb_segment6, update_time, create_time, update_by, create_by, base_cr_code, base_dr_code) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.id,jdbcType=BIGINT},
#{item.serialNo,jdbcType=VARCHAR},
#{item.name,jdbcType=VARCHAR},
#{item.orgId,jdbcType=VARCHAR},
#{item.accountType,jdbcType=TINYINT},
#{item.accountName,jdbcType=VARCHAR},
#{item.taxRate,jdbcType=DECIMAL},
#{item.taxBase,jdbcType=TINYINT},
#{item.revenueType,jdbcType=TINYINT},
#{item.taxType,jdbcType=TINYINT},
#{item.status,jdbcType=TINYINT},
#{item.startDate,jdbcType=VARCHAR},
#{item.endDate,jdbcType=VARCHAR},
#{item.tbSegment3,jdbcType=VARCHAR},
#{item.tbSegment5,jdbcType=VARCHAR},
#{item.tbSegment6,jdbcType=VARCHAR},
#{item.updateTime,jdbcType=TIMESTAMP},
#{item.createTime,jdbcType=TIMESTAMP},
#{item.updateBy,jdbcType=VARCHAR},
#{item.createBy,jdbcType=VARCHAR},
#{item.baseCrCode,jdbcType=VARCHAR},
#{item.baseDrCode,jdbcType=VARCHAR})
</foreach>
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pwc.taxtech.atms.vat.dao.RevenueTypeMappingMapper">
<insert id="batchInsert">
insert into revenue_type_mapping
(id, org_id, ou_name, content, tax_rate, revenue_type_name, start_date, end_date, status, create_by, update_by, create_time, update_time) values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id},
#{item.orgId},
#{item.ouName},
#{item.content},
#{item.taxRate},
#{item.revenueTypeName},
#{item.startDate},
#{item.endDate},
#{item.status,jdbcType=TINYINT},
#{item.createBy},
#{item.updateBy},
#{item.createTime},
#{item.updateTime})
</foreach>
</insert>
</mapper>
\ No newline at end of file
......@@ -4,6 +4,59 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<script>
//获取地址栏参数,name:参数名称
window.str="";
var z =function getUrlParms(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)
return unescape(r[2]);
return null;
}
var ddTicket = z("ticketStr");
//設置cookie
var sc= function setCookie(name,value) {
var Days = 30;
var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=./";
}
sc("ddTicket",ddTicket);
var ReUrl="https://me.xiaojukeji.com/project/stargate-auth/html/login.html?redirect_uri=http%3A%2F%2Fmis.diditaxi.com.cn%2Fauth%3Fapp_id%3D2500%26version%3D1.0%26jumpto%3Dhttp://dts-test.erp.didichuxing.com/orangeweb/index.html%26callback_index%3D0"
if(ddTicket==undefined || ddTicket=="" || ddTicket == null){
document.location=ReUrl;
}
/* else {
//创建核心对象
xmlhttp = null;
if (window.XMLHttpRequest) {// code for Firefox, Opera, IE7, etc.
xmlhttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
//编写回调函数
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
//
}
}
//這個 url 測試的
var getUserUrl="http://dts-test.erp.didichuxing.com/sso/getUser?ticket=";
//open设置请求方式和请求路径
xmlhttp.open("get", getUserUrl+ddTicket);
//send 发送
xmlhttp.send();
}*/
</script>
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>didi2</title>
<link rel="stylesheet" href="font_roboto.css">
......
......@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import pwc.taxtech.atms.common.DDUserInfoRes;
import pwc.taxtech.atms.common.HttpUtil;
import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.dto.AtmsTokenDto;
import pwc.taxtech.atms.web.AtmsWebSettings;
import pwc.taxtech.atms.web.service.OrangeHeapService;
......@@ -196,7 +197,7 @@ public class IndexController {
*/
@RequestMapping(value = {"/sso/getUser"}, method = RequestMethod.GET)
@ResponseBody
public String accept(@RequestParam(value = "ticket") String ticket, HttpServletRequest request,
public ApiResultDto accept(@RequestParam(value = "ticket") String ticket, HttpServletRequest request,
HttpServletResponse response) {
DDUserInfoRes ddUserInfoRes = null;
try {
......@@ -207,7 +208,7 @@ public class IndexController {
} catch (Exception e) {
logger.info(String.format("调用DDSSO获取用户信息失败:[%s]", e.getMessage()), e);
}
return JSON.toJSONString(ddUserInfoRes);
return ApiResultDto.success(ddUserInfoRes);
}
......
......@@ -3140,7 +3140,7 @@
sheet.setValue(40, 2, $scope._ebitResult.rate + "%");
sheet.setValue(41, 2, $scope._ebitResult.gljyye);
sheet.setValue(42, 2, $scope._ebitResult.sixAddtax);
sheet.setValue(43, 2, $scope._ebitResult.klzcjsz);
sheet.setValue(43, 2, $scope._ebitResult.tsklys);
}
setTimeout(function(){spreadTODb();}, 1000)
}
......
......@@ -1563,7 +1563,8 @@ constant.importFileType = {
invoiceRecord: 9,
ExtractFinancialData: 10,
ExtractInvoiceData: 11,
RevenueMapping: 12
RevenueMapping: 12,
RevenueConfig: 13
};
constant.citImportFileType = {
......
vatModule.controller('VatRevenueConfigController', ['$scope', '$log', '$translate', '$timeout', 'SweetAlert', '$q',
'$interval', 'dxDataGridService', '$http', 'apiConfig',
function ($scope, $log, $translate, $timeout, SweetAlert, $q, $interval, dxDataGridService, $http, apiConfig) {
'$interval', 'dxDataGridService', '$http', 'apiConfig','Upload','apiInterceptor','templateService',
function ($scope, $log, $translate, $timeout, SweetAlert, $q, $interval, dxDataGridService, $http, apiConfig,Upload,apiInterceptor,templateService) {
'use strict';
$scope.upload = function(uploadType) {
if (!$scope.uploadFile || !$scope.uploadFile.file.name) {
SweetAlert.warning($translate.instant('SelectUploadFileRequired'));
return;
}
$('#busy-indicator-container').show();
var deferred = $q.defer();
Upload.upload({
url: apiInterceptor.webApiHostUrl + '/revenueConf/upload',
data: {
type: uploadType,
},
file: $scope.uploadFile.file,
// resumeChunkSize: resumable ? $scope.chunkSize : null,
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: apiInterceptor.tokenType + ' ' + apiInterceptor.apiToken(),
withCredentials: true
},
withCredentials: true
}).then(function(res) {
$('#busy-indicator-container').hide();
deferred.resolve();
if (res && res.data && 0 === res.data.code) {
if(res.data.data.length==0){
SweetAlert.success($translate.instant('ImportSuccess'));
}else{
var msg = '';
angular.forEach(res.data.data,function (item) {
msg += item +" \n ";
});
SweetAlert.success(msg);
}
$scope.refreshConfigGrid();
} else {
SweetAlert.error($translate.instant('SystemError'));
}
}, function(resp) {
deferred.resolve();
if (resp.statusText === 'HttpRequestValidationException') {
SweetAlert.warning($translate.instant('HttpRequestValidationException'));
} else {
SweetAlert.warning($translate.instant('SaveFail'));
}
$('#busy-indicator-container').hide();
}, function(evt) {
deferred.resolve();
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
$log.debug('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
});
};
$scope.downloadTemplate = function () {
templateService.downloadTemplate(constant.importFileType.RevenueConfig).success(function (data, status, headers) {
var octetStreamMime = 'application/octet-stream';
var contentType = headers('content-type') || octetStreamMime;
if (window.navigator.msSaveBlob) {
var blob = new Blob([data], {
type: contentType
});
navigator.msSaveBlob(blob, "收入类型配置导入模板");
} else {
var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
if (urlCreator) {
var a = document.createElement('a');
var blob = new Blob([data], {
type: contentType
});
var url = urlCreator.createObjectURL(blob);
a.href = url;
a.target = '_blank';
a.download = "收入类型配置导入模板.xlsx";
document.body.appendChild(a);
a.click();
}
}
}).error(function () {
SweetAlert.error($translate.instant('PleaseContactAdministrator'));
});
};
$scope.exportRevenueConf = function () {
$http.get('/revenueConf/export', apiConfig.create({ responseType: 'arraybuffer' })).success(function (data, status, headers) {
var octetStreamMime = 'application/octet-stream';
var contentType = headers('content-type') || octetStreamMime;
if (window.navigator.msSaveBlob) {
var blob = new Blob([data], {
type: contentType
});
navigator.msSaveBlob(blob, "收入类型配置报表");
} else {
var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
if (urlCreator) {
var a = document.createElement('a');
var blob = new Blob([data], {
type: contentType
});
var url = urlCreator.createObjectURL(blob);
a.href = url;
a.target = '_blank';
a.download = "收入类型配置报表.xlsx";
document.body.appendChild(a);
a.click();
}
}
}).error(function () {
SweetAlert.error($translate.instant('PleaseContactAdministrator'));
});
};
//表格配置
$scope.revenueGridOptions = $.extend(true, {}, dxDataGridService.BASIC_GRID_OPTIONS, {
columns: [
......
......@@ -5,10 +5,22 @@
</div>
<div id="tab_total">
<form class="form-inline">
<div class="form-group" style="margin-top: 5px;"><div class="import-wrapper">
<button type="button" class="btn btn-primary" ng-click="addConfig()">{{'RevenueAddBtn' | translate }}</button>&nbsp;&nbsp;&nbsp;
<div class="form-group" style="margin-top: 5px;">
<button type="button" class="btn btn-secondary" ng-click="addConfig()">{{'RevenueAddBtn' | translate }}</button>&nbsp;&nbsp;&nbsp;
<button type="button" class="btn btn-third" ng-click="batchDelConfig()">{{'RevenueDelBtn' | translate }}</button>
</div></div>
<label class="control-label">文件:</label>
<input class="form-control" type="text" name="fileName" ng-model="uploadFile.file.name" readonly placeholder=""/>
<button type="button" type="file" ngf-select ng-model="uploadFile.file" accept=".xls,.xlsx" class="btn btn-secondary browse">{{'SelectFile' | translate }}</button>
<button type="button" class="btn btn-secondary" translate="CoverImportBtn" ng-click="upload(1)"></button>
<button type="button" class="btn btn-secondary" translate="AddImportBtn" ng-click="upload(2)"></button>
<button type="button" class="btn btn-in-grid inline-div" ng-click="downloadTemplate()"><i
class="fa fa-download" aria-hidden="true"></i>下载模板
</button>
<button type="button" class="btn btn-in-grid inline-div" ng-click="exportRevenueConf()"><i
class="fa fa-download" aria-hidden="true"></i>导出报表
</button>
</div>
</form>
<div class="dt-init-wrapper">
......
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