|
|
@@ -68,26 +68,27 @@ public class FileServiceImpl implements FileService {
|
|
|
};
|
|
|
|
|
|
@Override
|
|
|
- public String autoDeploy(String userNames) {
|
|
|
- logger.info("request... " + userNames);
|
|
|
- if (StringUtils.isEmpty(userNames)) {
|
|
|
- throw new ReportException("参数不能为空:userNames");
|
|
|
+ public String autoDeploy(String sourceUserName, String destinationUserNames) {
|
|
|
+ logger.info("request... " + destinationUserNames);
|
|
|
+ if (StringUtils.isEmpty(sourceUserName) || StringUtils.isEmpty(destinationUserNames)) {
|
|
|
+ throw new ReportException("参数不能为空:sourceUserName,destinationUserNames");
|
|
|
}
|
|
|
try {
|
|
|
- logger.info("get standardJrxmls from " + sysConf.getStandardJrxmlsUrl() + "...");
|
|
|
+ String stantardJrxmlsUrl = String.format(sysConf.getStandardJrxmlsUrl(), sourceUserName);
|
|
|
+ logger.info("get standardJrxmls from " + stantardJrxmlsUrl + "...");
|
|
|
// 获取标准模板数据
|
|
|
JSONObject jsonObject = JSONObject.parseObject(IOUtils.toString(HttpClients.createDefault()
|
|
|
- .execute(new HttpGet(URI.create(sysConf.getStandardJrxmlsUrl()))).getEntity().getContent()));
|
|
|
+ .execute(new HttpGet(URI.create(stantardJrxmlsUrl))).getEntity().getContent()));
|
|
|
byte[] data = jsonObject.getBytes("data");
|
|
|
if (ArrayUtils.isEmpty(data)) {
|
|
|
throw new ReportException("标准模板不存在");
|
|
|
}
|
|
|
- String[] userNameArray = userNames.split(",");
|
|
|
+ String[] userNameArray = destinationUserNames.split(",");
|
|
|
// 创建账套路径并解压模板zip包
|
|
|
for (String userName : userNameArray) {
|
|
|
ZipUtils.unzip(data, getMasterPath(userName));
|
|
|
}
|
|
|
- return "已自动部署:" + userNames;
|
|
|
+ return "已自动部署:" + destinationUserNames;
|
|
|
} catch (UnsupportedOperationException | IOException e) {
|
|
|
throw new ReportException(e).setDetailedMessage(e);
|
|
|
}
|
|
|
@@ -97,7 +98,7 @@ public class FileServiceImpl implements FileService {
|
|
|
public String upload(final String userName, String fileType, final MultipartFile file) {
|
|
|
String message = "";
|
|
|
if (StringUtils.isEmpty(userName)) {
|
|
|
- message = "未传入当前账套用户名!";
|
|
|
+ message = "未传入当前账套名称!";
|
|
|
logger.error(message);
|
|
|
return message;
|
|
|
}
|
|
|
@@ -204,14 +205,30 @@ public class FileServiceImpl implements FileService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void downloadStandardJrxmls(HttpServletResponse response) {
|
|
|
- downloadZip(sysConf.getStandardMaster(), response);
|
|
|
+ public byte[] getStandardJrxmls(String userName) {
|
|
|
+ if (StringUtils.isEmpty(userName)) {
|
|
|
+ throw new ReportException("未传入当前账套名称!");
|
|
|
+ }
|
|
|
+ byte[] data = ZipUtils.zipFolder(getMasterPath(sysConf.getStandardMaster()) + "/" + userName,
|
|
|
+ FileServiceImpl.fileFilter);
|
|
|
+ if (ArrayUtils.isEmpty(data)) {
|
|
|
+ throw new ReportException("压缩失败");
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void downloadStandardJrxmls(String userName, HttpServletResponse response) {
|
|
|
+ if (StringUtils.isEmpty(userName)) {
|
|
|
+ throw new ReportException("未传入当前账套名称!");
|
|
|
+ }
|
|
|
+ downloadZip(sysConf.getStandardMaster() + "/" + userName, response);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void downloadZip(String userName, HttpServletResponse response) {
|
|
|
if (StringUtils.isEmpty(userName)) {
|
|
|
- throw new ReportException("未传入当前账套用户名!");
|
|
|
+ throw new ReportException("未传入当前账套名称!");
|
|
|
}
|
|
|
String masterPath = getMasterPath(userName);
|
|
|
byte[] data = ZipUtils.zipFolder(masterPath, FileServiceImpl.fileFilter);
|