|
|
@ -21,6 +21,8 @@ import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.model.platform.AccountExportModel;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.model.platform.UserExportModel;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysMessage;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysMessage;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserDepartment;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserDepartment;
|
|
|
@ -61,6 +63,9 @@ import java.io.OutputStream;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @Description : 系统用户操作服务
|
|
|
|
* @Description : 系统用户操作服务
|
|
|
@ -736,4 +741,65 @@ public class SysUserController extends CoreBaseController {
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/export")
|
|
|
|
|
|
|
|
@ApiOperation(value = "导出账号信息", notes = "导出账号信息")
|
|
|
|
|
|
|
|
public void exportSysUserInfo(SysUser sysUser, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
|
|
File file = null;
|
|
|
|
|
|
|
|
if (sysUser == null) {
|
|
|
|
|
|
|
|
sysUser = new SysUser();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置默认值
|
|
|
|
|
|
|
|
sysUser.setOrganizeCode(AuthUtil.getOrganize().getOrganizeCode());
|
|
|
|
|
|
|
|
sysUser.setIsValid(CommonEnumUtil.IS_VAILD.VAILD.getValue());
|
|
|
|
|
|
|
|
sysUser.setIsDeleted(CommonEnumUtil.IS_DEAL.NO.getValue());
|
|
|
|
|
|
|
|
List<SysUser> list = sysUserService.querySysUser(sysUser);
|
|
|
|
|
|
|
|
List<AccountExportModel> exportModelList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SysRefUserRole> sysRefUserRoleList;
|
|
|
|
|
|
|
|
StringBuilder roleName;
|
|
|
|
|
|
|
|
for (SysUser user : list) {
|
|
|
|
|
|
|
|
exportModelList.add(new AccountExportModel(
|
|
|
|
|
|
|
|
user.getUserName(),
|
|
|
|
|
|
|
|
user.getUserLoginName(),
|
|
|
|
|
|
|
|
user.getUserEmail(),
|
|
|
|
|
|
|
|
user.getUserPhone(),
|
|
|
|
|
|
|
|
user.getDepartmentNameRdd(),
|
|
|
|
|
|
|
|
user.getUserLoginNum(),
|
|
|
|
|
|
|
|
user.getUserLoginLastDateTime(),
|
|
|
|
|
|
|
|
user.getUserStatus()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ExcelTool excelTool = new ExcelTool(entityManager, redisRes);
|
|
|
|
|
|
|
|
String fileName = "user-" + System.currentTimeMillis() + ".xls";
|
|
|
|
|
|
|
|
file = new File(fileName);
|
|
|
|
|
|
|
|
file.createNewFile();
|
|
|
|
|
|
|
|
File excle = excelTool.exportData(file, exportModelList, AccountExportModel.class
|
|
|
|
|
|
|
|
, (LinkedHashMap<String, String>) ExcelTool.getColName(AccountExportModel.class));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
response.setContentType("application/force-download"); // 设置强制下载不打开
|
|
|
|
|
|
|
|
response.addHeader("Content-Disposition", "attachment;fileName=" + fileName); // 设置文件名
|
|
|
|
|
|
|
|
response.addHeader("Content-type", FileContentTypeTool.getContentType(StringTool.getStringFileSuffix(fileName, true)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置文件名
|
|
|
|
|
|
|
|
try (BufferedInputStream bis = new BufferedInputStream(new DataInputStream(new FileInputStream(excle)))) {
|
|
|
|
|
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
|
|
|
int i = bis.read(buffer);
|
|
|
|
|
|
|
|
while (i != -1) {
|
|
|
|
|
|
|
|
os.write(buffer, 0, i);
|
|
|
|
|
|
|
|
i = bis.read(buffer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
LOGGER.error("用户日志导出异常", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
FileUtils.deleteQuietly(file);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|