1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package pwc.taxtech.atms.controller;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
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.PathVariable;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.common.ftp.FtpService;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.TemplateGroupDto;
import pwc.taxtech.atms.exception.ServiceException;
import pwc.taxtech.atms.service.impl.TemplateGroupServiceImpl;
import java.util.List;
@RestController
@RequestMapping("/api/v1/templateGroup/")
public class TemplateGroupController {
private static final Logger logger = LoggerFactory.getLogger(TemplateGroupController.class);
@Autowired
TemplateGroupServiceImpl templateGroupService;
@Autowired
FtpService ftpService;
@ApiOperation(value = "获取所有的模板分组")
@RequestMapping(value = "getall", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
List<TemplateGroupDto> get() {
logger.debug("TemplateGroupController Get");
return templateGroupService.get();
}
@ApiOperation(value = "根据服务类型和行业获取模板分组")
@RequestMapping(value = "getByIndustry/{serviceTypeId}/{industryId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
List<TemplateGroupDto> getTemplateGroupByIndustry(@PathVariable int serviceTypeId, @RequestParam Integer taxPayType, @PathVariable String industryId) {
return templateGroupService.get(serviceTypeId, taxPayType, industryId);
}
@RequestMapping(value = "updateTemplateGroupName", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto<Object> updateTemplateGroupName(@RequestBody TemplateGroupDto templateGroupDto) {
return templateGroupService.updateTemplateGroupName(templateGroupDto);
}
@RequestMapping(value = "deleteTemplateGroup", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto<Object> deleteTemplateGroup(@RequestBody TemplateGroupDto templateGroupDto) {
OperationResultDto<Object> result = templateGroupService.deleteTemplateGroup(templateGroupDto);
if (result.getResult()) {
List<String> pathList = (List<String>) result.getData();
if (pathList != null && pathList.size() > 0) {
for (String path : pathList) {
try {
//ftpService.delete(path);
} catch (Exception e) {
}
}
}
}
return result;
}
@ResponseBody
@ApiOperation(value = "获取Sheet名称")
@RequestMapping(value = "getSheetNameList", method = RequestMethod.POST)
public OperationResultDto getSheetNameList(@RequestParam MultipartFile file,
@RequestParam String filename,
@RequestParam String tempFileName) {
try {
if (null == file) {
return OperationResultDto.error(ErrorMessage.NoFile);
}
return OperationResultDto.success(templateGroupService.getSheetNameList(file));
} catch (Exception e) {
logger.error("getSheetNameList error.", e);
}
return OperationResultDto.error();
}
@ResponseBody
@ApiOperation(value = "导入模板")
@RequestMapping(value = "importTemplateGroupExcelFile", method = RequestMethod.POST)
public OperationResultDto importTemplateGroupExcelFile(@RequestParam MultipartFile file,
@RequestParam String filename,
@RequestParam String tempFileName,
@RequestParam String jsonModel) {
try {
if (null == file) {
return OperationResultDto.error(ErrorMessage.NoFile);
}
TemplateGroupDto templateGroupDto = JSON.parseObject(jsonModel, TemplateGroupDto.class);
if (CollectionUtils.isEmpty(templateGroupDto.getSheetNameList())) {
return OperationResultDto.error(ErrorMessage.NoSelectSheet);
}
templateGroupService.importTemplateGroupExcelFile(file, templateGroupDto);
return OperationResultDto.success();
} catch (ServiceException e) {
return OperationResultDto.error(e.getMessage());
} catch (Exception e) {
logger.error("importTemplateGroupExcelFile error.", e);
}
return OperationResultDto.error(ErrorMessage.SystemError);
}
@ResponseBody
@ApiOperation(value = "导入报表")
@RequestMapping(value = "importTemplateExcelFile", method = RequestMethod.POST)
public OperationResultDto importTemplateExcelFile(@RequestParam MultipartFile file,
@RequestParam Long templateGroupId,
@RequestParam String sheetList,
@RequestParam String tempFileName,
@RequestParam String reportType,
@RequestParam String filename) {
try {
templateGroupService.importTemplateExcelFile(file, templateGroupId, reportType, sheetList);
return OperationResultDto.success();
} catch (ServiceException e) {
return OperationResultDto.error(e.getMessage());
} catch (Exception e) {
logger.error("importTemplateExcelFile error.", e);
}
return OperationResultDto.error(ErrorMessage.SystemError);
}
@ResponseBody
@ApiOperation(value = "模板另存为")
@RequestMapping(value = "addTemplateGroup", method = RequestMethod.POST)
public OperationResultDto addTemplateGroup(@RequestBody TemplateGroupDto templateGroupDto) {
try {
templateGroupService.addTemplateGroup(templateGroupDto);
return OperationResultDto.success();
} catch (ServiceException e) {
return OperationResultDto.error(e.getMessage());
} catch (Exception e) {
logger.error("addTemplateGroup error.", e);
}
return OperationResultDto.error(ErrorMessage.SystemError);
}
}