Commit 96eece88 authored by eddie.woo's avatar eddie.woo

Merge branches 'dev' and 'dev_eddie' of…

Merge branches 'dev' and 'dev_eddie' of http://code.tech.tax.asia.pwcinternal.com/root/atms into dev_eddie
parents 2e8a535c 961dacb1
......@@ -8,10 +8,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.common.ApplicationException;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.TemplateDto;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import pwc.taxtech.atms.dto.UpateNameParam;
import pwc.taxtech.atms.common.ftp.FTPClientPool;
import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.entitiy.Template;
import pwc.taxtech.atms.service.TemplateService;
import javax.servlet.http.HttpServletResponse;
......@@ -27,6 +26,9 @@ public class TemplateController {
@Autowired
TemplateService templateService;
@Autowired
FTPClientPool ftpClientPool;
//todo:
//[Route("getTemplateJson")]
// [HttpGet]
......@@ -56,21 +58,26 @@ public class TemplateController {
String filePath;
File templateFile;
InputStream inputStream = null;
String templatePath = templateService.getTemplatePath(templateID);
if (StringUtils.isEmpty(templateID)) {
Template template = templateService.getTemplateByID(templateID);
String templatePath = template.getPath();
if (StringUtils.isBlank(templateID)) {
return;
}
if (templatePath == null || StringUtils.isEmpty(templatePath)) {
if (StringUtils.isBlank(templatePath)) {
return;
}
filePath = this.getClass().getResource("").toURI().getPath();
String tempPath = filePath.substring(0, filePath.indexOf("classes") + "\\classes".length());
templateFile = new File(tempPath + templateService.getTemplatePath(templateID));
templateFile = new File(tempPath + templatePath);
try {
inputStream = new BufferedInputStream(new FileInputStream(templateFile));
//如果是系统报表就取本地文件夹,如果不是就取FTP
if (template.getIsSystemType()) {
inputStream = new BufferedInputStream(new FileInputStream(templateFile));
} else {
inputStream = ftpClientPool.download(templatePath);
}
//客户端保存的文件名
String customFileName = "template_" + DateTime.now().toString("yyyyMMddHHmmss") + ".xlsx";
response.setHeader("Content-Disposition", String.format("inline; filename=\"" + customFileName + "\""));
......@@ -108,9 +115,22 @@ public class TemplateController {
return templateService.getTemplateUniqList(serviceTypeID, payTaxType, reportType, industryIDs);
}
@RequestMapping(value = "updateTemplateName",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto<Object> updateTemplateName(@RequestBody UpateNameParam param){
@RequestMapping(value = "updateTemplateName", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto<Object> updateTemplateName(@RequestBody UpateNameParam param) {
return templateService.updateTemplateName(param);
}
@RequestMapping(value = "deleteTemplate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto<String> deleteTemplate(@RequestBody DeleteTemplateParam param) {
OperationResultDto<String> result = templateService.deleteTemplate(param);
if (result.getResult() && StringUtils.isNotBlank(result.getData())) {
try {
ftpClientPool.delete(result.getData());
} catch (Exception e) {
}
}
return result;
}
}
......@@ -58,9 +58,8 @@ public class TemplateGroupController {
List<String> pathList = (List<String>) result.getData();
if (pathList != null && pathList.size() > 0) {
for(String path:pathList){
String pathAndName = path;
try {
ftpClientPool.delete(pathAndName);
ftpClientPool.delete(path);
}
catch(Exception e){
}
......
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.entitiy.Template;
import java.util.List;
......@@ -14,6 +15,8 @@ public interface TemplateService {
String getTemplatePath(String templateID);
Template getTemplateByID(String templateID);
List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs);
OperationResultDto<Object> updateTemplateName(UpateNameParam param);
......
......@@ -58,6 +58,11 @@ public class TemplateServiceImpl extends AbstractService implements TemplateServ
return result;
}
@Override
public Template getTemplateByID(String templateID) {
return templateMapper.selectByPrimaryKey(templateID);
}
@Override
public List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs) {
......
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