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; ...@@ -8,10 +8,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.common.ApplicationException; import pwc.taxtech.atms.common.ApplicationException;
import pwc.taxtech.atms.dto.OperationResultDto; import pwc.taxtech.atms.common.ftp.FTPClientPool;
import pwc.taxtech.atms.dto.TemplateDto; import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.dto.TemplateUniqDto; import pwc.taxtech.atms.entitiy.Template;
import pwc.taxtech.atms.dto.UpateNameParam;
import pwc.taxtech.atms.service.TemplateService; import pwc.taxtech.atms.service.TemplateService;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -27,6 +26,9 @@ public class TemplateController { ...@@ -27,6 +26,9 @@ public class TemplateController {
@Autowired @Autowired
TemplateService templateService; TemplateService templateService;
@Autowired
FTPClientPool ftpClientPool;
//todo: //todo:
//[Route("getTemplateJson")] //[Route("getTemplateJson")]
// [HttpGet] // [HttpGet]
...@@ -56,21 +58,26 @@ public class TemplateController { ...@@ -56,21 +58,26 @@ public class TemplateController {
String filePath; String filePath;
File templateFile; File templateFile;
InputStream inputStream = null; InputStream inputStream = null;
String templatePath = templateService.getTemplatePath(templateID); Template template = templateService.getTemplateByID(templateID);
if (StringUtils.isEmpty(templateID)) { String templatePath = template.getPath();
if (StringUtils.isBlank(templateID)) {
return; return;
} }
if (templatePath == null || StringUtils.isEmpty(templatePath)) { if (StringUtils.isBlank(templatePath)) {
return; return;
} }
filePath = this.getClass().getResource("").toURI().getPath(); filePath = this.getClass().getResource("").toURI().getPath();
String tempPath = filePath.substring(0, filePath.indexOf("classes") + "\\classes".length()); String tempPath = filePath.substring(0, filePath.indexOf("classes") + "\\classes".length());
templateFile = new File(tempPath + templateService.getTemplatePath(templateID)); templateFile = new File(tempPath + templatePath);
try { 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"; String customFileName = "template_" + DateTime.now().toString("yyyyMMddHHmmss") + ".xlsx";
response.setHeader("Content-Disposition", String.format("inline; filename=\"" + customFileName + "\"")); response.setHeader("Content-Disposition", String.format("inline; filename=\"" + customFileName + "\""));
...@@ -108,9 +115,22 @@ public class TemplateController { ...@@ -108,9 +115,22 @@ public class TemplateController {
return templateService.getTemplateUniqList(serviceTypeID, payTaxType, reportType, industryIDs); return templateService.getTemplateUniqList(serviceTypeID, payTaxType, reportType, industryIDs);
} }
@RequestMapping(value = "updateTemplateName",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "updateTemplateName", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody public @ResponseBody
OperationResultDto<Object> updateTemplateName(@RequestBody UpateNameParam param){ OperationResultDto<Object> updateTemplateName(@RequestBody UpateNameParam param) {
return templateService.updateTemplateName(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 { ...@@ -58,9 +58,8 @@ public class TemplateGroupController {
List<String> pathList = (List<String>) result.getData(); List<String> pathList = (List<String>) result.getData();
if (pathList != null && pathList.size() > 0) { if (pathList != null && pathList.size() > 0) {
for(String path:pathList){ for(String path:pathList){
String pathAndName = path;
try { try {
ftpClientPool.delete(pathAndName); ftpClientPool.delete(path);
} }
catch(Exception e){ catch(Exception e){
} }
......
package pwc.taxtech.atms.service; package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.*; import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.entitiy.Template;
import java.util.List; import java.util.List;
...@@ -14,6 +15,8 @@ public interface TemplateService { ...@@ -14,6 +15,8 @@ public interface TemplateService {
String getTemplatePath(String templateID); String getTemplatePath(String templateID);
Template getTemplateByID(String templateID);
List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs); List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs);
OperationResultDto<Object> updateTemplateName(UpateNameParam param); OperationResultDto<Object> updateTemplateName(UpateNameParam param);
......
...@@ -58,6 +58,11 @@ public class TemplateServiceImpl extends AbstractService implements TemplateServ ...@@ -58,6 +58,11 @@ public class TemplateServiceImpl extends AbstractService implements TemplateServ
return result; return result;
} }
@Override
public Template getTemplateByID(String templateID) {
return templateMapper.selectByPrimaryKey(templateID);
}
@Override @Override
public List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs) { 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