Commit 591f7a96 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 05887d75 e200f4c5
package pwc.taxtech.atms.common;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class CustomDateSerializer extends JsonSerializer<Date> {
@Override
public void serialize(Date value, JsonGenerator jgen, SerializerProvider arg2)
throws IOException, JsonProcessingException {
// TODO Auto-generated method stub
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String formattedDate = formatter.format(value);
jgen.writeString(formattedDate);
}
}
...@@ -135,6 +135,19 @@ public class DateUtils { ...@@ -135,6 +135,19 @@ public class DateUtils {
return period; return period;
} }
/**
* 将yyyymm 字符串转换为区间格式 yyyyMM
*
* @param dateStr
* @return
*/
public static Integer strToPeriod2(String dateStr) {
dateStr = dateStr.replace(" ","");
Integer period = Integer.valueOf(dateStr);
return period;
}
/** /**
* 将短时间格式字符串转换为时间 yyyy-MM-dd * 将短时间格式字符串转换为时间 yyyy-MM-dd
* *
...@@ -175,6 +188,19 @@ public class DateUtils { ...@@ -175,6 +188,19 @@ public class DateUtils {
return strtodate; return strtodate;
} }
/**
* 将短时间格式字符串转换为时间 yyyy-MM-dd
*
* @param strDate
* @return
*/
public static Date strToDate4(String strDate) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}
/** /**
* 得到现在时间 * 得到现在时间
* *
......
package pwc.taxtech.atms.common.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.config.FileServiceConfig;
import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.exception.ServiceException;
import java.io.IOException;
/**
* author kevin
* ver 1.0
*/
@Configuration
public class FileUploadUtil implements ApplicationContextAware {
protected static final Logger logger = LoggerFactory.getLogger(FileUploadUtil.class);
// Spring应用上下文环境
private static ApplicationContext applicationContext;
private static FileServiceConfig config;
private static final String USER_TEMPLATE_PATH = "pwc/userTemplate/";
private static final String HTTP_HEADER = "application/json;charset=UTF-8";
public static String upload(MultipartFile file) throws ServiceException{
return upload( file, false);
}
public static String serverPath(){
config = (FileServiceConfig)applicationContext.getBean("fileServiceConfig");
return config.getServerUrl() + config.getUploadUrl();
}
/**
* 上传模板
*
* @param file MultipartFile
* @param fullPath 是否返回全路径 默认false ,如果为true返回的路径直接可以用于下载
* @return Boolean
*/
public static String upload( MultipartFile file, boolean fullPath) throws ServiceException {
if (StringUtils.isBlank(file.getOriginalFilename()) || null == file) {
throw new IllegalArgumentException("上传参数为空");
}
CloseableHttpClient httpClient = null;
String filePath = USER_TEMPLATE_PATH + file.getOriginalFilename();
try {
String serverPath = serverPath();
httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(serverPath);
httpPost.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType());
JSONObject param = new JSONObject();
param.put("path", filePath);
param.put("file", file.getBytes());
HttpEntity httpEntity = new StringEntity(param.toJSONString(), ContentType.APPLICATION_JSON);
httpPost.setEntity(httpEntity);
HttpResponse httpResponse = httpClient.execute(httpPost);
ApiResultDto resultDto = JSON.parseObject(IOUtils.toString(httpResponse.getEntity().getContent(), "UTF-8"), ApiResultDto.class);
if (resultDto.getCode() == ApiResultDto.SUCCESS) {
if(fullPath){
return config.getServerUrl() + "/" + filePath;
}
return filePath;
}
} catch (Exception e) {
e.printStackTrace();
logger.error("uploadTemplate error.", e);
} finally {
if (null != httpClient) {
try {
httpClient.close();
} catch (IOException e) {
logger.error("close httpClient error.", e);
}
}
}
throw new ServiceException("uploadTemplate error.");
}
/**
* 实现ApplicationContextAware接口的回调方法。设置上下文环境
*
* @param applicationContext
*/
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
/**
* @return ApplicationContext
*/
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
}
...@@ -8,7 +8,9 @@ public enum EnumImportType { ...@@ -8,7 +8,9 @@ public enum EnumImportType {
AdjustmentTable(4), AdjustmentTable(4),
CashFlow(5), CashFlow(5),
CoupaPurchasingReport(6), CoupaPurchasingReport(6),
InvoiceData(7) InvoiceData(7),
CertifiedInvoicesList(8),
InvoiceRecord(9)
; ;
private Integer code; private Integer code;
......
...@@ -164,6 +164,39 @@ public class DataImportController extends BaseController { ...@@ -164,6 +164,39 @@ public class DataImportController extends BaseController {
} }
} }
@ResponseBody
@RequestMapping(value = "IRExcelFile", method = RequestMethod.POST)
public OperationResultDto importIRExcelFile(@RequestParam MultipartFile file,@RequestParam String orgIds,@RequestParam String periodDate,@RequestParam Integer importType) {
try {
if (null == file) {
return OperationResultDto.error(ErrorMessage.NoFile);
}
List<String> orgList = (List<String>)JSONArray.parse(orgIds);
return dataImportService.importIRExcelFile(file,orgList, periodDate,importType);
} catch (ServiceException e) {
return OperationResultDto.error(e.getMessage());
} catch (Exception e) {
logger.error("importIRExcelFile error.", e);
return OperationResultDto.error(ErrorMessage.SystemError);
}
}
@ResponseBody
@RequestMapping(value = "CILExcelFile", method = RequestMethod.POST)
public OperationResultDto importCILExcelFile(@RequestParam MultipartFile file,@RequestParam String periodDate,@RequestParam Integer importType) {
try {
if (null == file) {
return OperationResultDto.error(ErrorMessage.NoFile);
}
return dataImportService.importCILExcelFile(file, periodDate,importType);
} catch (ServiceException e) {
return OperationResultDto.error(e.getMessage());
} catch (Exception e) {
logger.error("importCILExcelFile error.", e);
return OperationResultDto.error(ErrorMessage.SystemError);
}
}
@ResponseBody @ResponseBody
@RequestMapping(value = "displayImportLog", method = RequestMethod.GET) @RequestMapping(value = "displayImportLog", method = RequestMethod.GET)
public List<DataImportLogDto> displayImportLog(@RequestParam Integer type) { public List<DataImportLogDto> displayImportLog(@RequestParam Integer type) {
......
...@@ -55,11 +55,35 @@ public class DataPreviewController extends BaseController { ...@@ -55,11 +55,35 @@ public class DataPreviewController extends BaseController {
return dataPreviewSerivceImpl.getBSDataForDisplay(param); return dataPreviewSerivceImpl.getBSDataForDisplay(param);
} }
@PostMapping("getIRDataForDisplay")
public PageInfo<InvoiceRecordDto> getIRDataForDisplay(@RequestBody InvoiceRecordParam param) {
logger.debug(String.format("发票记录表查询 Condition:%s", JSON.toJSONString(param)));
return dataPreviewSerivceImpl.getIRDataForDisplay(param);
}
@PostMapping("getRLITDataForDisplay")
public PageInfo<RedLetterInfoTableDto> getRLITDataForDisplay(@RequestBody RedLetterInfoTableParam param) {
logger.debug(String.format("红字信息表查询 Condition:%s", JSON.toJSONString(param)));
return dataPreviewSerivceImpl.getRLITDataForDisplay(param);
}
@PostMapping("getCPRDataForDisplay")
public PageInfo<CoupaPurchasingReportDto> getCPRDataForDisplay(@RequestBody CoupaPurchasingReportParam param) {
logger.debug(String.format("Coupa发票报告表查询 Condition:%s", JSON.toJSONString(param)));
return dataPreviewSerivceImpl.getCPRDataForDisplay(param);
}
@PostMapping("getCILDataForDisplay")
public PageInfo<CertifiedInvoicesListDto> getCILDataForDisplay(@RequestBody CertifiedInvoicesListParam param) {
logger.debug(String.format("已认证发票清单查询 Condition:%s", JSON.toJSONString(param)));
return dataPreviewSerivceImpl.getCILDataForDisplay(param);
}
@RequestMapping(value = "exportCFData/get", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "exportCFData/get", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void downloadCFQueryData(@RequestBody CashFlowParam param, HttpServletResponse response) { public void downloadCFQueryData(@RequestBody CashFlowParam param, HttpServletResponse response) {
logger.debug("enter downloadCFQueryData"); logger.debug("enter downloadCFQueryData");
String fileName="testFile"; String fileName="testFile";
// dataPreviewSerivceImpl.exportCashFlowList(response, param, fileName); dataPreviewSerivceImpl.exportCashFlowList(response, param, fileName);
} }
@RequestMapping(value = "exportTBData/get", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "exportTBData/get", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
......
...@@ -8,15 +8,21 @@ import org.springframework.http.ResponseEntity; ...@@ -8,15 +8,21 @@ import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; 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.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import pwc.taxtech.atms.common.CommonConstants; import pwc.taxtech.atms.common.CommonConstants;
import pwc.taxtech.atms.common.CommonUtils; import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.constant.enums.EnumModule; import pwc.taxtech.atms.constant.enums.EnumModule;
import pwc.taxtech.atms.dto.FileDto;
import pwc.taxtech.atms.dto.OperationResultDto; import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.service.impl.FileService; import pwc.taxtech.atms.service.impl.FileService;
import pwc.taxtech.atms.service.impl.HttpFileService;
import pwc.taxtech.atms.vat.service.impl.FileUploadAdapter; import pwc.taxtech.atms.vat.service.impl.FileUploadAdapter;
import javax.mail.Session;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.InputStream; import java.io.InputStream;
...@@ -33,6 +39,9 @@ public class FileUploadController { ...@@ -33,6 +39,9 @@ public class FileUploadController {
@Autowired @Autowired
private FileService fileService; private FileService fileService;
@Autowired
private HttpFileService httpFileService;
@RequestMapping(value = "NewFile", method = RequestMethod.POST, produces = MediaType.MULTIPART_FORM_DATA_VALUE) @RequestMapping(value = "NewFile", method = RequestMethod.POST, produces = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity getInputInvoiceTreeViewData(MultipartHttpServletRequest request) { public ResponseEntity getInputInvoiceTreeViewData(MultipartHttpServletRequest request) {
return fileUploadAdapter.upload(request); return fileUploadAdapter.upload(request);
......
package pwc.taxtech.atms.controller; package pwc.taxtech.atms.controller;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.constant.enums.EnumServiceType; import pwc.taxtech.atms.constant.enums.EnumServiceType;
import pwc.taxtech.atms.dpo.ReportDto; import pwc.taxtech.atms.dpo.ReportDto;
import pwc.taxtech.atms.dto.FileDto;
import pwc.taxtech.atms.dto.OperationResultDto; import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.*; import pwc.taxtech.atms.dto.vatdto.*;
import pwc.taxtech.atms.vat.entity.PeriodCellTemplateConfig; import pwc.taxtech.atms.vat.entity.PeriodCellTemplateConfig;
import pwc.taxtech.atms.vat.entity.PeriodJob; import pwc.taxtech.atms.vat.entity.PeriodJob;
import pwc.taxtech.atms.vat.entity.PwcReportAttach;
import pwc.taxtech.atms.vat.entity.VatEnterpriseAccount; import pwc.taxtech.atms.vat.entity.VatEnterpriseAccount;
import pwc.taxtech.atms.vat.service.impl.ReportServiceImpl; import pwc.taxtech.atms.vat.service.impl.ReportServiceImpl;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
@RestController @RestController
...@@ -149,4 +155,20 @@ public class ReportController { ...@@ -149,4 +155,20 @@ public class ReportController {
} }
@RequestMapping(value = "doUpload", method = RequestMethod.POST)
public OperationResultDto doUploadAttach(@RequestParam("fileName") String fileName, MultipartFile file, String remarks, @RequestParam("activeCol")Long activeCol, @RequestParam("activeRow")Long activeRow, @RequestParam("activeTemplateId")String activeTemplateId){
System.out.println(activeCol + "----" + activeRow + "-----" + activeTemplateId);
OperationResultDto operationResultDto = reportService.doUploadAttach(file, remarks);
if(!"error".equals(operationResultDto.getResultMsg())){//上传成功绑定
reportService.bindPwcAttach(activeCol, activeRow, activeTemplateId, (FileDto) operationResultDto.getData());
}
return operationResultDto;
}
@RequestMapping(value = "loadAttachList", method = RequestMethod.GET)
public List<PwcReportAttach> loadAttachList(Long col, Long row, String templateId){
return reportService.loadAttachList(col, row, templateId);
}
} }
\ No newline at end of file
...@@ -278,6 +278,10 @@ public class TemplateController extends BaseController implements ServletContext ...@@ -278,6 +278,10 @@ public class TemplateController extends BaseController implements ServletContext
return EnumImportType.CoupaPurchasingReport.name(); return EnumImportType.CoupaPurchasingReport.name();
}else if(EnumImportType.InvoiceData.getCode().equals(fileType)){ }else if(EnumImportType.InvoiceData.getCode().equals(fileType)){
return EnumImportType.InvoiceData.name(); return EnumImportType.InvoiceData.name();
}else if(EnumImportType.CertifiedInvoicesList.getCode().equals(fileType)){
return EnumImportType.CertifiedInvoicesList.name();
}else if(EnumImportType.InvoiceRecord.getCode().equals(fileType)){
return EnumImportType.InvoiceRecord.name();
}else if(EnumImportType.Undefined.getCode().equals(fileType)){ }else if(EnumImportType.Undefined.getCode().equals(fileType)){
return EnumImportType.Undefined.name(); return EnumImportType.Undefined.name();
} }
......
package pwc.taxtech.atms.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.format.annotation.DateTimeFormat;
import pwc.taxtech.atms.common.CustomDateSerializer;
import pwc.taxtech.atms.entity.BaseEntity;
import java.util.Date;
//统一返回文件对象
public class FileDto extends BaseEntity {
private String fileName;
private String size;
private String remarks;//备注信息
private String uploadUser;//上传用户
private Date createTime;
protected Date updateTime;
private String fileUrl;
public String getFileUrl() {
return fileUrl;
}
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getUploadUser() {
return uploadUser;
}
public void setUploadUser(String uploadUser) {
this.uploadUser = uploadUser;
}
@JsonSerialize(using = CustomDateSerializer.class)
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
@JsonSerialize(using = CustomDateSerializer.class)
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
@Override
public String toString() {
return "FileDto{" +
"fileName='" + fileName + '\'' +
", size='" + size + '\'' +
", remarks='" + remarks + '\'' +
", uploadUser='" + uploadUser + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
", fileUrl='" + fileUrl + '\'' +
'}';
}
}
...@@ -16,6 +16,7 @@ public class OperationResultDto<T> extends OperationResultBase { ...@@ -16,6 +16,7 @@ public class OperationResultDto<T> extends OperationResultBase {
private T data; private T data;
public OperationResultDto() { public OperationResultDto() {
} }
......
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.dpo.PagingDto;
public class CertifiedInvoicesListParam {
private PagingDto pageInfo;
private String orgId;
private Integer periodStart;
private Integer periodEnd;
public Integer getPeriodStart() {
return periodStart;
}
public void setPeriodStart(Integer periodStart) {
this.periodStart = periodStart;
}
public Integer getPeriodEnd() {
return periodEnd;
}
public void setPeriodEnd(Integer periodEnd) {
this.periodEnd = periodEnd;
}
public String getOrgId() {
return this.orgId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public PagingDto getPageInfo() {
return pageInfo;
}
public void setPageInfo(PagingDto pageInfo) {
this.pageInfo = pageInfo;
}
}
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.dpo.PagingDto;
public class CoupaPurchasingReportParam {
private PagingDto pageInfo;
private String orgId;
private Integer periodStart;
private Integer periodEnd;
public Integer getPeriodStart() {
return periodStart;
}
public void setPeriodStart(Integer periodStart) {
this.periodStart = periodStart;
}
public Integer getPeriodEnd() {
return periodEnd;
}
public void setPeriodEnd(Integer periodEnd) {
this.periodEnd = periodEnd;
}
public String getOrgId() {
return this.orgId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public PagingDto getPageInfo() {
return pageInfo;
}
public void setPageInfo(PagingDto pageInfo) {
this.pageInfo = pageInfo;
}
}
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.dpo.PagingDto;
public class InvoiceRecordParam {
private PagingDto pageInfo;
private String orgId;
private Integer periodStart;
private Integer periodEnd;
public Integer getPeriodStart() {
return periodStart;
}
public void setPeriodStart(Integer periodStart) {
this.periodStart = periodStart;
}
public Integer getPeriodEnd() {
return periodEnd;
}
public void setPeriodEnd(Integer periodEnd) {
this.periodEnd = periodEnd;
}
public String getOrgId() {
return this.orgId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public PagingDto getPageInfo() {
return pageInfo;
}
public void setPageInfo(PagingDto pageInfo) {
this.pageInfo = pageInfo;
}
}
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.dpo.PagingDto;
public class RedLetterInfoTableParam {
private PagingDto pageInfo;
private String orgId;
private Integer periodStart;
private Integer periodEnd;
public Integer getPeriodStart() {
return periodStart;
}
public void setPeriodStart(Integer periodStart) {
this.periodStart = periodStart;
}
public Integer getPeriodEnd() {
return periodEnd;
}
public void setPeriodEnd(Integer periodEnd) {
this.periodEnd = periodEnd;
}
public String getOrgId() {
return this.orgId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public PagingDto getPageInfo() {
return pageInfo;
}
public void setPageInfo(PagingDto pageInfo) {
this.pageInfo = pageInfo;
}
}
/*
package pwc.taxtech.atms.service.impl; package pwc.taxtech.atms.service.impl;
import org.jxls.common.Context; import org.jxls.common.Context;
import org.jxls.expression.JexlExpressionEvaluator; import org.jxls.expression.JexlExpressionEvaluator;
import org.jxls.transform.Transformer; import org.jxls.transform.Transformer;
...@@ -82,4 +80,4 @@ public class CommonDocumentHelper { ...@@ -82,4 +80,4 @@ public class CommonDocumentHelper {
} }
} }
*/
...@@ -198,4 +198,8 @@ public class FileService { ...@@ -198,4 +198,8 @@ public class FileService {
} }
} }
//上传文件
} }
...@@ -23,15 +23,22 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -23,15 +23,22 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.config.FileServiceConfig; import pwc.taxtech.atms.common.config.FileServiceConfig;
import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.dto.ApiResultDto; import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.dto.FileDto;
import pwc.taxtech.atms.exception.ServiceException; import pwc.taxtech.atms.exception.ServiceException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
/**
* version 2.0
* author kevin
*/
@Service @Service
public class HttpFileService extends BaseService { public class HttpFileService extends BaseService {
@Autowired @Autowired
...@@ -44,21 +51,23 @@ public class HttpFileService extends BaseService { ...@@ -44,21 +51,23 @@ public class HttpFileService extends BaseService {
* *
* @param fileName 文件名 * @param fileName 文件名
* @param file MultipartFile * @param file MultipartFile
* @param fullPath 是否返回全路径 默认false ,如果为true返回的路径直接可以用于下载
* @return Boolean * @return Boolean
*/ */
public String uploadTemplate(String fileName, MultipartFile file) throws ServiceException { public String uploadTemplate(String fileName, MultipartFile file, boolean fullPath) throws ServiceException {
if (StringUtils.isBlank(fileName) || null == file) { if (StringUtils.isBlank(fileName) || null == file) {
throw new IllegalArgumentException("上传参数为空"); throw new IllegalArgumentException("上传参数为空");
} }
CloseableHttpClient httpClient = null; CloseableHttpClient httpClient = null;
String fullPath = USER_TEMPLATE_PATH + fileName; String filePath = USER_TEMPLATE_PATH + fileName;
try { try {
String serverPath = config.getServerUrl() + config.getUploadUrl();
httpClient = HttpClients.createDefault(); httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(config.getServerUrl() + config.getUploadUrl()); HttpPost httpPost = new HttpPost(serverPath);
httpPost.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType()); httpPost.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType());
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("path", fullPath); param.put("path", filePath);
param.put("file", file.getBytes()); param.put("file", file.getBytes());
HttpEntity httpEntity = new StringEntity(param.toJSONString(), ContentType.APPLICATION_JSON); HttpEntity httpEntity = new StringEntity(param.toJSONString(), ContentType.APPLICATION_JSON);
...@@ -67,7 +76,10 @@ public class HttpFileService extends BaseService { ...@@ -67,7 +76,10 @@ public class HttpFileService extends BaseService {
HttpResponse httpResponse = httpClient.execute(httpPost); HttpResponse httpResponse = httpClient.execute(httpPost);
ApiResultDto resultDto = JSON.parseObject(IOUtils.toString(httpResponse.getEntity().getContent(), "UTF-8"), ApiResultDto.class); ApiResultDto resultDto = JSON.parseObject(IOUtils.toString(httpResponse.getEntity().getContent(), "UTF-8"), ApiResultDto.class);
if (resultDto.getCode() == ApiResultDto.SUCCESS) { if (resultDto.getCode() == ApiResultDto.SUCCESS) {
return fullPath; if(fullPath){
return config.getServerUrl() + "/" + filePath;
}
return filePath;
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("uploadTemplate error.", e); logger.error("uploadTemplate error.", e);
...@@ -83,6 +95,11 @@ public class HttpFileService extends BaseService { ...@@ -83,6 +95,11 @@ public class HttpFileService extends BaseService {
throw new ServiceException("uploadTemplate error."); throw new ServiceException("uploadTemplate error.");
} }
public String uploadTemplate(String fileName, MultipartFile file) throws ServiceException{
return uploadTemplate(fileName, file, false);
}
/** /**
* 下载模板 * 下载模板
* *
...@@ -117,4 +134,22 @@ public class HttpFileService extends BaseService { ...@@ -117,4 +134,22 @@ public class HttpFileService extends BaseService {
return null; return null;
} }
//上传
public FileDto upload(MultipartFile file, String remarks){
FileDto fileDto = new FileDto();
int i = file.getOriginalFilename().lastIndexOf(".");
fileDto.setFileName(file.getOriginalFilename());
if(remarks != null){
fileDto.setRemarks(remarks);
}
fileDto.setFileUrl(uploadTemplate(file.getOriginalFilename(), file, true));
//绑定
fileDto.setSize(String.valueOf(file.getSize()/1024));
fileDto.setUploadUser(authUserHelper.getCurrentAuditor().get());
fileDto.setCreateTime(DateUtils.getNowDate());
return fileDto;
}
} }
...@@ -41,7 +41,12 @@ ...@@ -41,7 +41,12 @@
<property name="rootInterface" value="pwc.taxtech.atms.MyVatMapper" /> <property name="rootInterface" value="pwc.taxtech.atms.MyVatMapper" />
</javaClientGenerator> </javaClientGenerator>
<table tableName="trial_balance_final" domainObjectName="TrialBalanceFinal"> <!-- <table tableName="trial_balance_final" domainObjectName="TrialBalanceFinal">
<property name="useActualColumnNames" value="false"/>
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>-->
<table tableName="pwc_report_attach" domainObjectName="PwcReportAttach">
<property name="useActualColumnNames" value="false"/> <property name="useActualColumnNames" value="false"/>
<property name="ignoreQualifiersAtRuntime" value="true"/> <property name="ignoreQualifiersAtRuntime" value="true"/>
</table> </table>
......
...@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper; import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.dpo.CoupaPurchasingReportCondition;
import pwc.taxtech.atms.vat.entity.CoupaPurchasingReport; import pwc.taxtech.atms.vat.entity.CoupaPurchasingReport;
import pwc.taxtech.atms.vat.entity.CoupaPurchasingReportExample; import pwc.taxtech.atms.vat.entity.CoupaPurchasingReportExample;
...@@ -107,4 +108,6 @@ public interface CoupaPurchasingReportMapper extends MyVatMapper { ...@@ -107,4 +108,6 @@ public interface CoupaPurchasingReportMapper extends MyVatMapper {
int updateByPrimaryKey(CoupaPurchasingReport record); int updateByPrimaryKey(CoupaPurchasingReport record);
int insertBatch(List<CoupaPurchasingReport> cprs); int insertBatch(List<CoupaPurchasingReport> cprs);
List<CoupaPurchasingReport> selectByCondition(@Param("cprCondition") CoupaPurchasingReportCondition condition);
} }
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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