人员列表修改
parent
c998088bec
commit
8313cdd88b
|
@ -3,6 +3,7 @@ package cn.palmte.work.controller.backend;
|
|||
import cn.palmte.work.bean.ResponseMsg;
|
||||
import cn.palmte.work.config.Constant;
|
||||
import cn.palmte.work.model.Admin;
|
||||
import cn.palmte.work.model.Dept;
|
||||
import cn.palmte.work.model.DeptRepository;
|
||||
import cn.palmte.work.model.UserPositionRepository;
|
||||
import cn.palmte.work.pojo.ModifyPasswordRequest;
|
||||
|
@ -28,12 +29,15 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import top.jfunc.common.crypto.symmetric.DESAS;
|
||||
import top.jfunc.common.db.bean.Page;
|
||||
import top.jfunc.common.utils.CollectionUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
@ -83,9 +87,18 @@ public class AccountController extends BaseController {
|
|||
setModel(keywords, model);
|
||||
ConcurrentHashMap<String, String> searchInfo = getSearchInfo(keywords, model);
|
||||
model.put("roleList", sysRoleService.getAllEnableSysRole());
|
||||
model.put("deptList", deptRepository.findAll());
|
||||
model.put("deptList", deptRepository.findFirstLevelDept());
|
||||
model.put("positionList", userPositionRepository.findAll());
|
||||
model.put("pager", accountService.list(searchInfo, pageNumber, pageSize));
|
||||
Page<Admin> page = accountService.list(searchInfo, pageNumber, pageSize);
|
||||
List<Admin> list = page.getList();
|
||||
if(CollectionUtil.isNotEmpty(list)){
|
||||
|
||||
int offset = (pageNumber - 1) * pageSize;
|
||||
for (int i = 0 , size = list.size(); i < size; i++) {
|
||||
list.get(i).setTempId(i+1 + offset);
|
||||
}
|
||||
}
|
||||
model.put("pager", page);
|
||||
return "/admin/account_list";
|
||||
}
|
||||
|
||||
|
@ -223,8 +236,8 @@ public class AccountController extends BaseController {
|
|||
public void export(@RequestParam(value = "keywords", required = false) String keywords, HttpServletResponse httpServletResponse) throws IOException {
|
||||
Map<String, String> searchInfo = getSearchInfo(keywords);
|
||||
downloadHeader(httpServletResponse, Utils.generateExcelName("人员信息"), "application/octet-stream");
|
||||
String[] headers = {"工号", "手机号码", "姓名", "常驻地", "一级部门", "直接主管", "职位", "角色名称", "公司邮件地址"};
|
||||
String[] exportColumns = {"userName", "telephone", "realName", "workLocation", "deptName", "directManager", "positionName", "roleName", "companyEmail"};
|
||||
String[] headers = {"四算系统登录账号", "手机号码", "姓名", "常驻地", "一级部门", "二级部门", "三级部门", "直接主管", "职位", "角色名称", "公司邮件地址"};
|
||||
String[] exportColumns = {"userName", "telephone", "realName", "workLocation", "deptFirstName", "deptSecondName", "deptThirdName", "directManager", "positionName", "roleName", "companyEmail"};
|
||||
ExportUtils.exportToExcel(headers, exportColumns, 1, 10000,
|
||||
httpServletResponse.getOutputStream(), (pN, pS) -> accountService.list(searchInfo, pN, pS).getList());
|
||||
}
|
||||
|
@ -235,7 +248,7 @@ public class AccountController extends BaseController {
|
|||
@RequestMapping("/template")
|
||||
public void template(HttpServletResponse response) throws Exception {
|
||||
|
||||
String[] headers = new String[]{"工号", "手机号码", "姓名", "常驻地", "一级部门", "直接主管", "职位", "角色名称", "公司邮件地址"};
|
||||
String[] headers = new String[]{"四算系统登录账号", "手机号码", "姓名", "常驻地", "所属部门", "直接主管", "职位", "角色名称", "公司邮件地址"};
|
||||
downloadHeader(response, Utils.generateExcelName("人员信息批量导入模板"));
|
||||
ExportUtils exportUtils = new ExportUtils(headers);
|
||||
exportUtils.write(response.getOutputStream());
|
||||
|
|
|
@ -90,6 +90,18 @@ public class Admin{
|
|||
@Column(name = "company_email")
|
||||
private String companyEmail;
|
||||
|
||||
@Transient
|
||||
private Integer tempId;
|
||||
|
||||
@Transient
|
||||
private String deptFirstName;
|
||||
|
||||
@Transient
|
||||
private String deptSecondName;
|
||||
|
||||
@Transient
|
||||
private String deptThirdName;
|
||||
|
||||
public String getEmpCode() {
|
||||
return empCode;
|
||||
}
|
||||
|
@ -346,6 +358,35 @@ public class Admin{
|
|||
}
|
||||
|
||||
|
||||
public Integer getTempId() {
|
||||
return tempId;
|
||||
}
|
||||
|
||||
public void setTempId(Integer tempId) {
|
||||
this.tempId = tempId;
|
||||
}
|
||||
|
||||
public String getDeptFirstName() {
|
||||
return deptFirstName;
|
||||
}
|
||||
|
||||
public void setDeptFirstName(String deptFirstName) {
|
||||
this.deptFirstName = deptFirstName;
|
||||
}
|
||||
|
||||
public String getDeptSecondName() {
|
||||
return deptSecondName;
|
||||
}
|
||||
|
||||
public void setDeptSecondName(String deptSecondName) {
|
||||
this.deptSecondName = deptSecondName;
|
||||
}
|
||||
|
||||
public String getDeptThirdName() {
|
||||
return deptThirdName;
|
||||
}
|
||||
|
||||
public void setDeptThirdName(String deptThirdName) {
|
||||
this.deptThirdName = deptThirdName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@ public interface DeptRepository extends JpaRepository<Dept,Integer> {
|
|||
|
||||
Dept findByNameEquals(String name);
|
||||
|
||||
@Query(value = "select * from dept where level = 1", nativeQuery = true)
|
||||
List<Dept> findFirstLevelDept();
|
||||
|
||||
@Query(value = "select * from dept where enabled = 1", nativeQuery = true)
|
||||
List<Dept> findEnable();
|
||||
|
||||
|
|
|
@ -56,7 +56,10 @@ public class AccountService {
|
|||
}
|
||||
|
||||
public Page<Admin> list(Map<String, String> searchInfo, int pageNumber, int pageSize) {
|
||||
QueryHelper queryHelper = new QueryHelper("*", "sys_user u");
|
||||
QueryHelper queryHelper = new QueryHelper("u.*, (CASE d.level WHEN 1 THEN d.name WHEN 2 THEN d2.name ELSE d3.name END) AS deptFirstName, (CASE d.level WHEN 1 THEN '' WHEN 2 THEN d.name WHEN 3 THEN d2.name END) AS deptSecondName, (CASE d.level WHEN 3 THEN d.name ELSE '' END) AS deptThirdName", "sys_user u");
|
||||
queryHelper.leftJoin("dept d", "u.dept_id = d.id");
|
||||
queryHelper.leftJoin("dept d2", "d.parent_id = d2.id");
|
||||
queryHelper.leftJoin("dept d3", "d2.parent_id = d3.id");
|
||||
queryHelper.addCondition("u.is_deleted = 0");
|
||||
queryHelper.addCondition("u.id > 1");
|
||||
queryHelper.addCondition(searchInfo.containsKey("realName"), "u.real_name like ?", "%" +
|
||||
|
@ -198,18 +201,18 @@ public class AccountService {
|
|||
}
|
||||
|
||||
if (StringUtils.isEmpty(admin.getUserName())) {
|
||||
message = "工号不能为空!";
|
||||
message = "四算系统登录账号不能为空!";
|
||||
return message;
|
||||
}
|
||||
Admin existAdmin = adminRepository.getAdminByUsername(admin.getUserName());
|
||||
if (userId == -1) {
|
||||
if (existAdmin != null) {
|
||||
message = "该工号已存在!";
|
||||
message = "该四算系统登录账号已存在!";
|
||||
return message;
|
||||
}
|
||||
} else {
|
||||
if (existAdmin != null && existAdmin.getId() != userId) {
|
||||
message = "该工号已存在!";
|
||||
message = "该四算系统登录账号已存在!";
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
@ -295,15 +298,15 @@ public class AccountService {
|
|||
for (Map m : excelMap) {
|
||||
|
||||
try {
|
||||
Object empCode = m.get("工号");
|
||||
Object empCode = m.get("四算系统登录账号");
|
||||
if (empCode == null || StrKit.isBlank(empCode.toString())) {
|
||||
throw new Exception("工号不能为空");
|
||||
throw new Exception("四算系统登录账号不能为空");
|
||||
}
|
||||
|
||||
Admin byEmpCode = adminRepository.getAdminByUsername(empCode.toString());
|
||||
|
||||
if (null != byEmpCode) {
|
||||
throw new Exception("工号" + empCode.toString() + "已存在");
|
||||
throw new Exception("四算系统登录账号" + empCode.toString() + "已存在");
|
||||
}
|
||||
|
||||
Object telephone = m.get("手机号码");
|
||||
|
@ -341,15 +344,15 @@ public class AccountService {
|
|||
throw new Exception("常驻地不能为空");
|
||||
}
|
||||
|
||||
Object deptName = m.get("一级部门");
|
||||
Object deptName = m.get("所属部门");
|
||||
if (deptName == null || StrKit.isBlank(deptName.toString())) {
|
||||
throw new Exception("一级部门不能为空");
|
||||
throw new Exception("所属部门不能为空");
|
||||
}
|
||||
|
||||
Dept dept = deptRepository.findByNameEquals(deptName.toString());
|
||||
|
||||
if (null == dept) {
|
||||
throw new Exception("一级部门" + deptName.toString() + "不存在");
|
||||
throw new Exception("所属部门" + deptName.toString() + "不存在");
|
||||
}
|
||||
|
||||
Object directManager = m.get("直接主管");
|
||||
|
|
|
@ -25,15 +25,15 @@
|
|||
<div class="am-g am-form-group am-margin-top">
|
||||
<div class="am-u-sm-4 am-u-md-2 am-text-right">
|
||||
<span style="color: red;">*</span>
|
||||
工号
|
||||
四算系统登录账号
|
||||
</div>
|
||||
<div class="am-u-sm-6 am-u-md-6">
|
||||
<input name="userName" class="js-ajax-validate"
|
||||
data-validate-async data-validation-message="请输入工号"
|
||||
data-validate-async data-validation-message="请输入四算系统登录账号"
|
||||
type="text" id="userName" value="${account.userName!}" minlength="1"
|
||||
maxlength="20"
|
||||
required <#if userId!=-1>readonly</#if>
|
||||
placeholder="请输入工号"/>
|
||||
placeholder="请输入四算系统登录账号"/>
|
||||
</div>
|
||||
<div class="am-u-sm-2 am-u-md-4 input-msg"></div>
|
||||
</div>
|
||||
|
@ -105,7 +105,7 @@
|
|||
<div class="am-g am-form-group am-margin-top">
|
||||
<div class="am-u-sm-4 am-u-md-2 am-text-right">
|
||||
<span style="color: red;">*</span>
|
||||
一级部门
|
||||
所属部门
|
||||
</div>
|
||||
<div class="am-u-sm-8 am-u-md-10">
|
||||
<select id="deptId" name="deptId"
|
||||
|
|
|
@ -142,11 +142,14 @@
|
|||
<table class="am-table am-table-striped am-table-hover table-main">
|
||||
<thead>
|
||||
<tr class="am-text-nowrap">
|
||||
<th class="table-title">工号</th>
|
||||
<th class="table-title">序号</th>
|
||||
<th class="table-title">四算系统登录账号</th>
|
||||
<th class="table-title">手机号码</th>
|
||||
<th class="table-title">姓名</th>
|
||||
<th class="table-title">常驻地</th>
|
||||
<th class="table-title">一级部门</th>
|
||||
<th class="table-title">二级部门</th>
|
||||
<th class="table-title">三级部门</th>
|
||||
<th class="table-title">直接主管</th>
|
||||
<th class="table-title">职位</th>
|
||||
<th class="table-title">角色名称</th>
|
||||
|
@ -157,11 +160,14 @@
|
|||
<tbody>
|
||||
<#list pager.list as list>
|
||||
<tr>
|
||||
<td>${list.tempId!}</td>
|
||||
<td>${list.userName!}</td>
|
||||
<td>${list.telephone!}</td>
|
||||
<td>${list.realName!}</td>
|
||||
<td>${list.workLocation!}</td>
|
||||
<td>${list.deptName!}</td>
|
||||
<td>${list.deptFirstName!}</td>
|
||||
<td>${list.deptSecondName!}</td>
|
||||
<td>${list.deptThirdName!}</td>
|
||||
<td>${list.directManager!}</td>
|
||||
<td>${list.positionName!}</td>
|
||||
<td>${list.roleName!}</td>
|
||||
|
|
Loading…
Reference in New Issue