Compare commits
4 Commits
5bf26c76d5
...
2823430d31
| Author | SHA1 | Date |
|---|---|---|
|
|
2823430d31 | |
|
|
6f845e50ae | |
|
|
392956408e | |
|
|
81d10ba5d1 |
|
|
@ -17,6 +17,7 @@ import com.nflg.mobilebroken.common.pojo.vo.TitleSimpleVO;
|
|||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.VUtils;
|
||||
import com.nflg.mobilebroken.repository.entity.AdminUser;
|
||||
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||
import com.nflg.mobilebroken.repository.service.IAdminUserService;
|
||||
import com.nflg.mobilebroken.repository.service.IDictionaryItemTranslateService;
|
||||
import com.nflg.mobilebroken.repository.service.ITBaseDepartmentService;
|
||||
|
|
@ -134,8 +135,16 @@ public class AdminUserController extends ControllerBase {
|
|||
@PostMapping("updateAccount")
|
||||
@MethodInfoMark(value = "更新账号", menuName = "账号管理")
|
||||
@ApiMark(moduleName = "账号管理", apiName = "更新账号")
|
||||
public ApiResult<Void> updateAccount(@Valid @RequestBody AccountUpdateRequest request) throws MessagingException {
|
||||
public ApiResult<Void> updateAccount(@Valid @RequestBody AccountUpdateRequest request) {
|
||||
AdminUser user=adminUserService.getById(request.getId());
|
||||
if (!Objects.equals(user.getDepartmentId(), request.getDepartmentId())) {
|
||||
departmentService.updateHasManager(user.getDepartmentId());
|
||||
departmentService.lambdaUpdate()
|
||||
.set(TBaseDepartment::isHasManager, true)
|
||||
.eq(TBaseDepartment::isHasManager, false)
|
||||
.eq(TBaseDepartment::getId, request.getDepartmentId())
|
||||
.update();
|
||||
}
|
||||
user.setUserCode(request.getUserCode())
|
||||
.setUserName(request.getUserName())
|
||||
.setAvatar(request.getAvatar())
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.nflg.mobilebroken.common.util.VUtils;
|
|||
import com.nflg.mobilebroken.repository.entity.AppUser;
|
||||
import com.nflg.mobilebroken.repository.entity.AppUserApplyfor;
|
||||
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
|
||||
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||
import com.nflg.mobilebroken.repository.service.*;
|
||||
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
|
||||
import com.nflg.mobilebroken.starter.service.EmailService;
|
||||
|
|
@ -78,6 +79,9 @@ public class AppUserController extends ControllerBase {
|
|||
@Resource
|
||||
private IAdminMessageService adminMessageService;
|
||||
|
||||
@Resource
|
||||
private ITBaseDepartmentService departmentService;
|
||||
|
||||
/**
|
||||
* 获取公司列表
|
||||
* @param userId 用户id
|
||||
|
|
@ -206,6 +210,16 @@ public class AppUserController extends ControllerBase {
|
|||
@ApiMark(moduleName = "代理商管理", apiName = "更新代理商账号")
|
||||
public ApiResult<Void> updateAppUser(@Valid @RequestBody AppUserUpdateRequest request) {
|
||||
AppUser user=appUserService.getById(request.getId());
|
||||
if (!Objects.equals(user.getDepartmentId(), request.getDepartmentId())) {
|
||||
if (Objects.nonNull(user.getDepartmentId())) {
|
||||
departmentService.updateHasManager(user.getDepartmentId());
|
||||
}
|
||||
departmentService.lambdaUpdate()
|
||||
.set(TBaseDepartment::isHasManager, true)
|
||||
.eq(TBaseDepartment::isHasManager, false)
|
||||
.eq(TBaseDepartment::getId, request.getDepartmentId())
|
||||
.update();
|
||||
}
|
||||
user.setExpireTime(user.getExpireTime().plusDays(1));
|
||||
if (user.getIsPrimary()){
|
||||
updatePrimaryAppUser(user,request);
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
package com.nflg.mobilebroken.admin.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.mobilebroken.admin.annotation.ApiMark;
|
||||
import com.nflg.mobilebroken.admin.constant.Constant;
|
||||
import com.nflg.mobilebroken.admin.pojo.dto.DepartmentDTO;
|
||||
import com.nflg.mobilebroken.admin.pojo.query.DepartmentQuery;
|
||||
import com.nflg.mobilebroken.admin.pojo.vo.BaseDepartmentVO;
|
||||
import com.nflg.mobilebroken.admin.service.AdminDepartmentService;
|
||||
import com.nflg.mobilebroken.common.constant.STATE;
|
||||
import com.nflg.mobilebroken.common.exception.NflgException;
|
||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.DepartmentChildItemVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.DepartmentChildVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.DepartmentSimpleVO;
|
||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.UniqueSequenceGenerator;
|
||||
import com.nflg.mobilebroken.common.util.VUtils;
|
||||
|
|
@ -26,6 +27,8 @@ import javax.validation.Valid;
|
|||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 部门管理
|
||||
|
|
@ -47,9 +50,9 @@ public class DepartmentController extends ControllerBase {
|
|||
*/
|
||||
@PostMapping("getList")
|
||||
@ApiMark(moduleName = "部门管理", apiName = "获取部门列表")
|
||||
public ApiResult<PageData<BaseDepartmentVO>> getList(@RequestBody DepartmentQuery query){
|
||||
public ApiResult<PageData<BaseDepartmentVO>> getList(@RequestBody DepartmentQuery query) {
|
||||
|
||||
return adminDepartmentService.getList(query);
|
||||
return adminDepartmentService.getList(query);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -61,7 +64,7 @@ public class DepartmentController extends ControllerBase {
|
|||
*/
|
||||
@GetMapping("getChild")
|
||||
@ApiMark(moduleName = "部门管理", apiName = "获取子级")
|
||||
public ApiResult<List<TBaseDepartment>> getChild(@RequestParam("parentId") Long parentId ){
|
||||
public ApiResult<List<TBaseDepartment>> getChild(@RequestParam("parentId") Long parentId) {
|
||||
|
||||
return ApiResult.success(departmentService.getChildByParentId(parentId));
|
||||
}
|
||||
|
|
@ -72,20 +75,19 @@ public class DepartmentController extends ControllerBase {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping("add")
|
||||
@MethodInfoMark(value = "新增" ,menuName = "部门管理")
|
||||
@MethodInfoMark(value = "新增", menuName = "部门管理")
|
||||
@ApiMark(moduleName = "部门管理", apiName = "新增")
|
||||
public ApiResult<Boolean> add(@Valid @RequestBody DepartmentDTO departmentDTO){
|
||||
public ApiResult<Boolean> add(@Valid @RequestBody DepartmentDTO departmentDTO) {
|
||||
|
||||
// List<TBaseDepartment> checkCode = departmentService.lambdaQuery().eq(TBaseDepartment::getDeptCode, departmentDTO.getDeptCode()).list();
|
||||
//新增
|
||||
TBaseDepartment dept = Convert.convert(TBaseDepartment.class, departmentDTO);
|
||||
if(null==departmentDTO.getId() || departmentDTO.getId()==0){
|
||||
if (null == departmentDTO.getId() || departmentDTO.getId() == 0) {
|
||||
dept.setDeptCode(UniqueSequenceGenerator.generateCode(Constant.DeptCodePrefix));
|
||||
dept.setDataCreateUserNo(AdminUserUtil.getUserNo());
|
||||
dept.setDataCreateUserName(AdminUserUtil.getUserName());
|
||||
dept.setDataCreateTime(LocalDateTime.now());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dept.setDataModifyUserNo(AdminUserUtil.getUserNo());
|
||||
dept.setDataModifyUserName(AdminUserUtil.getUserName());
|
||||
dept.setDataModifyTime(LocalDateTime.now());
|
||||
|
|
@ -101,23 +103,33 @@ public class DepartmentController extends ControllerBase {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping("del")
|
||||
@MethodInfoMark(value = "删除",menuName = "部门管理")
|
||||
@MethodInfoMark(value = "删除", menuName = "部门管理")
|
||||
@ApiMark(moduleName = "部门管理", apiName = "删除")
|
||||
public ApiResult<Boolean> add(@RequestBody List<Long> ids ){
|
||||
public ApiResult<Boolean> del(@RequestBody List<Long> ids) {
|
||||
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要删除的数据");
|
||||
List<TBaseDepartment> delDepartments = departmentService.getBaseMapper().selectByIds(ids);
|
||||
List<String> hasChildDeptNames=new ArrayList<>();
|
||||
List<Long> childIds=new ArrayList<>();
|
||||
for (TBaseDepartment dept :delDepartments) {
|
||||
childIds.clear();
|
||||
adminDepartmentService.getAllChildIds(dept,childIds);
|
||||
if(CollUtil.isNotEmpty(childIds)){
|
||||
hasChildDeptNames.add(dept.getDeptName());
|
||||
}
|
||||
}
|
||||
if(CollUtil.isNotEmpty(hasChildDeptNames)){
|
||||
throw new NflgException(STATE.ParamErr, StrUtil.join(",", hasChildDeptNames)+" 存在子集,请先删除子级");
|
||||
}
|
||||
// List<String> hasChildDeptNames=new ArrayList<>();
|
||||
// List<Long> childIds=new ArrayList<>();
|
||||
// for (TBaseDepartment dept :delDepartments) {
|
||||
// childIds.clear();
|
||||
// adminDepartmentService.getAllChildIds(dept,childIds);
|
||||
// if(CollUtil.isNotEmpty(childIds)){
|
||||
// hasChildDeptNames.add(dept.getDeptName());
|
||||
// }
|
||||
// }
|
||||
// if(CollUtil.isNotEmpty(hasChildDeptNames)){
|
||||
// throw new NflgException(STATE.ParamErr, StrUtil.join(",", hasChildDeptNames)+" 存在子集,请先删除子级");
|
||||
// }
|
||||
List<TBaseDepartment> errors = delDepartments.stream()
|
||||
.filter(TBaseDepartment::isHasChild)
|
||||
.collect(Collectors.toList());
|
||||
VUtils.trueThrowBusinessError(CollectionUtil.isNotEmpty(errors))
|
||||
.throwMessage("以下部门存在下级,不能删除:" + errors.stream().map(TBaseDepartment::getDeptName).collect(Collectors.joining(",")));
|
||||
errors = delDepartments.stream()
|
||||
.filter(TBaseDepartment::isHasManager)
|
||||
.collect(Collectors.toList());
|
||||
VUtils.trueThrowBusinessError(CollectionUtil.isNotEmpty(errors))
|
||||
.throwMessage("以下部门存在用户,不能删除:" + errors.stream().map(TBaseDepartment::getDeptName).collect(Collectors.joining(",")));
|
||||
departmentService.del(ids);
|
||||
return ApiResult.success(true);
|
||||
}
|
||||
|
|
@ -129,18 +141,18 @@ public class DepartmentController extends ControllerBase {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping("enable")
|
||||
@MethodInfoMark(value = "启用",menuName = "部门管理")
|
||||
@MethodInfoMark(value = "启用", menuName = "部门管理")
|
||||
@ApiMark(moduleName = "部门管理", apiName = "启用")
|
||||
public ApiResult<Boolean> enable(@RequestBody List<Long> ids ){
|
||||
public ApiResult<Boolean> enable(@RequestBody List<Long> ids) {
|
||||
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要启用的数据");
|
||||
List<TBaseDepartment> tBaseDepartments = departmentService.getBaseMapper().selectByIds(ids);
|
||||
tBaseDepartments.forEach(u->{
|
||||
tBaseDepartments.forEach(u -> {
|
||||
u.setDeptStatus(1);
|
||||
u.setDataModifyUserNo(AdminUserUtil.getUserNo());
|
||||
u.setDataModifyUserName(AdminUserUtil.getUserName());
|
||||
u.setDataModifyTime(LocalDateTime.now());
|
||||
});
|
||||
if(CollUtil.isNotEmpty(tBaseDepartments)){
|
||||
});
|
||||
if (CollUtil.isNotEmpty(tBaseDepartments)) {
|
||||
departmentService.updateBatchById(tBaseDepartments);
|
||||
}
|
||||
|
||||
|
|
@ -154,37 +166,86 @@ public class DepartmentController extends ControllerBase {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping("disable")
|
||||
@MethodInfoMark(value = "禁用",menuName = "部门管理")
|
||||
@MethodInfoMark(value = "禁用", menuName = "部门管理")
|
||||
@ApiMark(moduleName = "部门管理", apiName = "禁用")
|
||||
public ApiResult<Boolean> disable(@RequestBody List<Long> ids ){
|
||||
public ApiResult<Boolean> disable(@RequestBody List<Long> ids) {
|
||||
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要启用的数据");
|
||||
|
||||
List<TBaseDepartment> tBaseDepartments = departmentService.getBaseMapper().selectByIds(ids);
|
||||
List<Long> childIds=new ArrayList<>();
|
||||
List<Long> childIds = new ArrayList<>();
|
||||
childIds.addAll(ids);
|
||||
for (TBaseDepartment tBaseDepartment : tBaseDepartments) {
|
||||
adminDepartmentService.getAllChildIds(tBaseDepartment, childIds);
|
||||
}
|
||||
tBaseDepartments = departmentService.getBaseMapper().selectByIds(childIds);
|
||||
tBaseDepartments.forEach(u->{
|
||||
tBaseDepartments.forEach(u -> {
|
||||
u.setDeptStatus(0);
|
||||
u.setDataModifyUserNo(AdminUserUtil.getUserNo());
|
||||
u.setDataModifyUserName(AdminUserUtil.getUserName());
|
||||
u.setDataModifyTime(LocalDateTime.now());
|
||||
});
|
||||
if(CollUtil.isNotEmpty(tBaseDepartments)){
|
||||
if (CollUtil.isNotEmpty(tBaseDepartments)) {
|
||||
departmentService.updateBatchById(tBaseDepartments);
|
||||
}
|
||||
|
||||
return ApiResult.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取绑定的用户和子级部门
|
||||
* @param id 部门id
|
||||
*/
|
||||
@GetMapping("getChildren")
|
||||
public ApiResult<DepartmentChildVO> getChildren(@RequestParam Long id) {
|
||||
List<TBaseDepartment> departments = departmentService.lambdaQuery().eq(TBaseDepartment::getDataValidStatus, 1).list();
|
||||
TBaseDepartment department = departments.stream().filter(u -> u.getId().equals(id)).findFirst().orElse(null);
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(department)).throwMessage("部门不存在");
|
||||
List<DepartmentChildItemVO> itemVOS = new ArrayList<>();
|
||||
List<DepartmentChildItemVO> users = departmentService.getUsers(id);
|
||||
if (CollUtil.isNotEmpty(users)) {
|
||||
itemVOS.addAll(users);
|
||||
}
|
||||
List<TBaseDepartment> childs = departments.stream()
|
||||
.filter(di -> Objects.equals(di.getDeptParentId(), id))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(childs)) {
|
||||
itemVOS.addAll(
|
||||
childs.stream().map(c -> new DepartmentChildItemVO()
|
||||
.setId(c.getId())
|
||||
.setName(c.getDeptName())
|
||||
.setType(0)
|
||||
.setState(c.getDeptStatus())
|
||||
.setCreateBy(c.getDataCreateUserName())
|
||||
.setCreateTime(c.getDataCreateTime())
|
||||
.setUpdateBy(c.getDataModifyUserName())
|
||||
.setUpdateTime(c.getDataModifyTime())
|
||||
)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
List<DepartmentSimpleVO> paths = new ArrayList<>();
|
||||
paths.add(new DepartmentSimpleVO()
|
||||
.setId(department.getId())
|
||||
.setName(department.getDeptName())
|
||||
);
|
||||
bindParent(paths, department, departments);
|
||||
return ApiResult.success(new DepartmentChildVO()
|
||||
.setPaths(paths)
|
||||
.setItems(itemVOS)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void bindParent(List<DepartmentSimpleVO> paths, TBaseDepartment department, List<TBaseDepartment> departments) {
|
||||
TBaseDepartment parent = departments.stream()
|
||||
.filter(di -> Objects.equals(di.getId(), department.getDeptParentId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (Objects.nonNull(parent)) {
|
||||
paths.add(0, new DepartmentSimpleVO()
|
||||
.setId(parent.getId())
|
||||
.setName(parent.getDeptName())
|
||||
);
|
||||
bindParent(paths, parent, departments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -538,7 +538,6 @@ public class TicketController extends ControllerBase {
|
|||
@GetMapping("exportPdf")
|
||||
@ApiMark(moduleName = "工单管理", apiName = "导出工单为pdf")
|
||||
public void exportPdf(HttpServletResponse response, @Valid @RequestParam @NotNull(message = "工单编号不能为空") Integer id) {
|
||||
|
||||
Ticket ticket = ticketService.getById(id);
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(ticket)).throwMessage("工单不存在");
|
||||
DeviceInfoVO device = deviceService.getByDeviceNo(ticket.getDeviceNo());
|
||||
|
|
|
|||
|
|
@ -63,8 +63,11 @@
|
|||
<td colspan="2" th:text="${ticket.useTime}+'小时'"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="desc1">主要负责人</td>
|
||||
<td colspan="2"
|
||||
th:text="${#strings.arraySplit(ticket.handleUserName, ',').length > 0 ? #strings.arraySplit(ticket.handleUserName, ',')[0] : ''}"></td>
|
||||
<td class="desc1">处理人</td>
|
||||
<td colspan="11" th:text="${ticket.handleUserName}"></td>
|
||||
<td colspan="8" th:text="${ticket.handleUserName}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="desc1">问题描述</td>
|
||||
|
|
|
|||
|
|
@ -123,6 +123,11 @@ public class AppUserForAdminVO {
|
|||
*/
|
||||
private Long departmentId;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String departmentName;
|
||||
|
||||
/**
|
||||
* 地域类型,字典id
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -106,4 +106,14 @@ public class AppUserVO {
|
|||
|
||||
//平台,app或者admin
|
||||
private String platform="app";
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
private Long departmentId;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String departmentName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
package com.nflg.mobilebroken.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class DepartmentChildItemVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 0:部门 1:用户
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 0:代理商,1:终端用户;2:内部用户
|
||||
*/
|
||||
private Integer userType;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.nflg.mobilebroken.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class DepartmentChildVO {
|
||||
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
private List<DepartmentSimpleVO> paths;
|
||||
|
||||
/**
|
||||
* 子级
|
||||
*/
|
||||
private List<DepartmentChildItemVO> items;
|
||||
}
|
||||
|
|
@ -15,6 +15,16 @@ public class DepartmentSimpleVO {
|
|||
//部门名称
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 是否有下级
|
||||
*/
|
||||
private boolean hasChild;
|
||||
|
||||
/**
|
||||
* 是否已设置管理者
|
||||
*/
|
||||
private boolean hasManager;
|
||||
|
||||
//下级
|
||||
private List<DepartmentSimpleVO> children;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,8 +67,11 @@
|
|||
<td colspan="2" th:text="${base.v1}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="desc1">主要负责人</td>
|
||||
<td colspan="2"
|
||||
th:text="${#strings.arraySplit(ticket.handleUserName, ',').length > 0 ? #strings.arraySplit(ticket.handleUserName, ',')[0] : ''}"></td>
|
||||
<td class="desc1">处理人</td>
|
||||
<td colspan="11" th:text="${ticket.handleUserName}"></td>
|
||||
<td colspan="8" th:text="${ticket.handleUserName}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="desc1">问题描述</td>
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@ package com.nflg.mobilebroken.repository.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门表
|
||||
|
|
@ -85,4 +86,14 @@ public class TBaseDepartment implements Serializable {
|
|||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime dataModifyTime;
|
||||
|
||||
/**
|
||||
* 是否有下级
|
||||
*/
|
||||
private boolean hasChild;
|
||||
|
||||
/**
|
||||
* 是否已设置管理者
|
||||
*/
|
||||
private boolean hasManager;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
package com.nflg.mobilebroken.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.DepartmentChildItemVO;
|
||||
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -21,4 +22,8 @@ public interface TBaseDepartmentMapper extends BaseMapper<TBaseDepartment> {
|
|||
Page<TBaseDepartment> selectListByPage(@Param("page") Page<PageBaseQuery> page,@Param("query") PageBaseQuery query );
|
||||
|
||||
void del(@Param("ids") List<Long> ids);
|
||||
|
||||
void updateHasManager(Long departmentId);
|
||||
|
||||
List<DepartmentChildItemVO> getUsers(Long id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.nflg.mobilebroken.repository.service;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.DepartmentChildItemVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.DepartmentSimpleVO;
|
||||
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -34,4 +35,8 @@ public interface ITBaseDepartmentService extends IService<TBaseDepartment> {
|
|||
|
||||
|
||||
Set<Long> getAllChildrenIds(Long departmentId);
|
||||
|
||||
void updateHasManager(Long departmentId);
|
||||
|
||||
List<DepartmentChildItemVO> getUsers(Long id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,6 +120,11 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
|||
.setCreateTime(LocalDateTime.now());
|
||||
save(user);
|
||||
}
|
||||
departmentService.lambdaUpdate()
|
||||
.set(TBaseDepartment::isHasManager, true)
|
||||
.eq(TBaseDepartment::isHasManager, false)
|
||||
.eq(TBaseDepartment::getId, user.getDepartmentId())
|
||||
.update();
|
||||
return user;
|
||||
}
|
||||
|
||||
|
|
@ -465,7 +470,8 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
|||
Set<TBaseDepartment> searchDepartments = departments.stream()
|
||||
.filter(d -> searchUsers.stream().map(AdminUser::getDepartmentId).anyMatch(dt -> Objects.equals(d.getId(), dt)))
|
||||
.collect(Collectors.toSet());
|
||||
searchDepartments.forEach(d -> bindParent(d, searchDepartments, departments));
|
||||
Set<TBaseDepartment> treeDepartments = new HashSet<>(searchDepartments);
|
||||
searchDepartments.forEach(d -> bindParent(d, treeDepartments, departments));
|
||||
List<TBaseDepartment> rootDepartments = searchDepartments.stream()
|
||||
.filter(d -> d.getDeptParentId() == 0)
|
||||
.collect(Collectors.toList());
|
||||
|
|
@ -506,13 +512,14 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
|||
}
|
||||
}
|
||||
|
||||
private void bindParent(TBaseDepartment department, Set<TBaseDepartment> vos, List<TBaseDepartment> departments) {
|
||||
private void bindParent(TBaseDepartment department, Set<TBaseDepartment> treeDepartments, List<TBaseDepartment> departments) {
|
||||
Set<TBaseDepartment> parents = departments.stream()
|
||||
.filter(d -> Objects.equals(d.getId(), department.getDeptParentId()))
|
||||
.collect(Collectors.toSet());
|
||||
parents.removeIf(p -> treeDepartments.stream().anyMatch(v -> Objects.equals(p.getId(), v.getId())));
|
||||
if (CollectionUtil.isNotEmpty(parents)) {
|
||||
vos.addAll(parents);
|
||||
parents.forEach(p -> bindParent(p, vos, departments));
|
||||
treeDepartments.addAll(parents);
|
||||
parents.forEach(p -> bindParent(p, treeDepartments, departments));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,9 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
|||
@Resource
|
||||
private ITBaseAreaService baseAreaService;
|
||||
|
||||
@Resource
|
||||
private ITBaseDepartmentService departmentService;
|
||||
|
||||
@Override
|
||||
public AppUserApplyfor add(AddUserRequest request) {
|
||||
VUtils.trueThrowBusinessError(appUserService.lambdaQuery().eq(AppUser::getEmail, request.getEmail()).exists())
|
||||
|
|
@ -223,6 +226,11 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
|||
.setExpireTime(appUser.getExpireTime())
|
||||
.setSalesUserName(appUser.getSalesUserName());
|
||||
appUserService.save(user);
|
||||
departmentService.lambdaUpdate()
|
||||
.set(TBaseDepartment::isHasManager, true)
|
||||
.eq(TBaseDepartment::isHasManager, false)
|
||||
.eq(TBaseDepartment::getId, user.getDepartmentId())
|
||||
.update();
|
||||
} else if (applyfor.getType() == AppUserApplyforType.ENABLE.getState().byteValue()) {
|
||||
//账号启用
|
||||
AppUser appUser = appUserService.getById(applyfor.getUserId());
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
@Resource
|
||||
private ITBaseAreaService baseAreaService;
|
||||
|
||||
@Resource
|
||||
private ITBaseDepartmentService departmentService;
|
||||
|
||||
@Override
|
||||
public AppUser getUser(String userName, String password) {
|
||||
AppUser user = lambdaQuery()
|
||||
|
|
@ -198,6 +201,11 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
.setExpireTime(LocalDate.of(LocalDateTime.now().getYear() + 1, 1, 1));
|
||||
save(user);
|
||||
}
|
||||
departmentService.lambdaUpdate()
|
||||
.set(TBaseDepartment::isHasManager, true)
|
||||
.eq(TBaseDepartment::isHasManager, false)
|
||||
.eq(TBaseDepartment::getId, user.getDepartmentId())
|
||||
.update();
|
||||
return user;
|
||||
}
|
||||
|
||||
|
|
@ -239,12 +247,13 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
AppUser primaryUser = getById(id);
|
||||
List<Integer> companyIds = Arrays.stream(primaryUser.getCompanyId().split(",")).map(Integer::parseInt).collect(Collectors.toList());
|
||||
List<CompanyVO> datas = new ArrayList<>();
|
||||
List<TBaseDepartment> departments = departmentService.list();
|
||||
for (Integer companyId : companyIds) {
|
||||
TBaseCustomer customer = customerService.getById(companyId);
|
||||
CompanyVO companyVO = new CompanyVO()
|
||||
.setId(customer.getId())
|
||||
.setName(customer.getAgencyCompanyName())
|
||||
.setUsers(getByCompanyId(companyId));
|
||||
.setUsers(getByCompanyId(companyId, departments));
|
||||
datas.add(companyVO);
|
||||
}
|
||||
return datas;
|
||||
|
|
@ -423,6 +432,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
List<AppUserForAdminVO> subs = datas.stream()
|
||||
.filter(d -> Objects.nonNull(d.getIsPrimary()) && !d.getIsPrimary())
|
||||
.collect(Collectors.toList());
|
||||
List<TBaseDepartment> departments = departmentService.list();
|
||||
subs.forEach(d -> {
|
||||
AppUserForAdminVO primary = primarys.stream()
|
||||
.filter(p -> Objects.nonNull(p.getIsPrimary()) && Arrays.stream(p.getCompanyId().split(",")).anyMatch(c -> c.equals(d.getCompanyId())))
|
||||
|
|
@ -457,7 +467,14 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
.setSalesUserName(appUser.getSalesUserName())
|
||||
.setTitleId(appUser.getTitleId())
|
||||
.setTitle(positionService.getById(appUser.getTitleId()).getPositionName())
|
||||
.setState(appUser.getExpireTime().isAfter(LocalDate.now()) ? 1 : 2);
|
||||
.setState(appUser.getExpireTime().isAfter(LocalDate.now()) ? 1 : 2)
|
||||
.setDepartmentId(appUser.getDepartmentId())
|
||||
.setDepartmentName(departments.stream()
|
||||
.filter(dept -> dept.getId().equals(appUser.getDepartmentId()))
|
||||
.findFirst()
|
||||
.map(TBaseDepartment::getDeptName)
|
||||
.orElse("")
|
||||
);
|
||||
AppUserApplyfor applyFor = appUserApplyforService.lambdaQuery()
|
||||
.eq(AppUserApplyfor::getUserId, appUser.getId())
|
||||
.eq(AppUserApplyfor::getState, AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue())
|
||||
|
|
@ -748,12 +765,13 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
.collect(Collectors.toSet());
|
||||
companyIds.addAll(userCompanyIds);
|
||||
}
|
||||
List<TBaseDepartment> departments = departmentService.list();
|
||||
companyIds.forEach(id -> {
|
||||
TBaseCustomer customer = customerService.getById(id);
|
||||
CompanyVO companyVO = new CompanyVO()
|
||||
.setId(customer.getId())
|
||||
.setName(customer.getAgencyCompanyName())
|
||||
.setUsers(getByCompanyId(id));
|
||||
.setUsers(getByCompanyId(id, departments));
|
||||
datas.add(companyVO);
|
||||
});
|
||||
return datas;
|
||||
|
|
@ -834,7 +852,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
return getBaseMapper().selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
private List<AppUserVO> getByCompanyId(Integer companyId) {
|
||||
private List<AppUserVO> getByCompanyId(Integer companyId, List<TBaseDepartment> departments) {
|
||||
return lambdaQuery()
|
||||
.eq(AppUser::getIsDel, false)
|
||||
.eq(AppUser::getCompanyId, companyId.toString())
|
||||
|
|
@ -842,7 +860,18 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
.eq(AppUser::getIsPrimary, false)
|
||||
.list()
|
||||
.stream()
|
||||
.map(u -> new AppUserVO().setId(u.getId()).setName(u.getName()))
|
||||
.map(u -> new AppUserVO()
|
||||
.setId(u.getId())
|
||||
.setName(u.getName())
|
||||
.setDepartmentId(u.getDepartmentId())
|
||||
.setDepartmentName(
|
||||
departments.stream()
|
||||
.filter(d -> Objects.equals(d.getId(), u.getDepartmentId()))
|
||||
.findFirst()
|
||||
.map(TBaseDepartment::getDeptName)
|
||||
.orElse("")
|
||||
)
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.DepartmentChildItemVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.DepartmentSimpleVO;
|
||||
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||
import com.nflg.mobilebroken.repository.mapper.TBaseDepartmentMapper;
|
||||
|
|
@ -72,6 +73,16 @@ public class TBaseDepartmentServiceImpl extends ServiceImpl<TBaseDepartmentMappe
|
|||
return ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHasManager(Long departmentId) {
|
||||
baseMapper.updateHasManager(departmentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentChildItemVO> getUsers(Long id) {
|
||||
return baseMapper.getUsers(id);
|
||||
}
|
||||
|
||||
private void getChildrenIds(Set<Long> ids, List<TBaseDepartment> departments, Long departmentId) {
|
||||
Set<Long> cids = departments.stream()
|
||||
.filter(d -> Objects.equals(d.getDeptParentId(), departmentId))
|
||||
|
|
@ -96,7 +107,12 @@ public class TBaseDepartmentServiceImpl extends ServiceImpl<TBaseDepartmentMappe
|
|||
|
||||
private List<DepartmentSimpleVO> convert(List<TBaseDepartment> datas) {
|
||||
return datas.stream()
|
||||
.map(d -> new DepartmentSimpleVO().setId(d.getId()).setName(d.getDeptName()))
|
||||
.map(d -> new DepartmentSimpleVO()
|
||||
.setId(d.getId())
|
||||
.setName(d.getDeptName())
|
||||
.setHasChild(d.isHasChild())
|
||||
.setHasManager(d.isHasManager())
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,12 +123,14 @@
|
|||
,au.expire_time,IF(aua.id IS NOT NULL,0
|
||||
,IF(CONVERT_TZ(NOW(), @@session.time_zone, '+00:00') < au.expire_time,1,2)) AS 'state',au.create_by
|
||||
,au.create_time,au.update_by,au.update_time,au.last_login_time,au.is_primary,au.company_id,au.phone,au.area_id
|
||||
,au.language_code,p.position_name AS
|
||||
'title',au.title_id,au.type,au.customer_name,au.department_id,au.region_type_id
|
||||
,au.language_code,p.position_name AS 'title',au.title_id,au.type,au.customer_name,au.department_id,d.dept_name
|
||||
as 'departmentName'
|
||||
,au.region_type_id
|
||||
FROM app_user au
|
||||
LEFT JOIN app_area aa ON au.area_id=aa.id
|
||||
LEFT JOIN app_user_applyfor aua ON aua.user_id=au.id AND aua.state=0
|
||||
LEFT JOIN t_base_position p ON au.title_id=p.id
|
||||
LEFT JOIN t_base_department d ON au.department_id=d.id
|
||||
WHERE au.is_del=0
|
||||
<if test="loginName!=null and loginName!=''">
|
||||
AND au.login_name LIKE concat('%', #{loginName}, '%')
|
||||
|
|
@ -158,12 +160,14 @@
|
|||
,IF(aua.is_primary,fun_getPrimaryUserArea(aua.company_id),aa.`name`) AS 'areaName'
|
||||
,null AS 'userState',null AS 'expireTime',0 AS 'state',au.name AS 'createBy',aua.create_time,null AS 'updateBy'
|
||||
,null AS 'updateTime',null AS 'lastLoginTime',aua.is_primary,aua.company_id,aua.user_phone AS 'phone',aua.area_id
|
||||
,aua.language_code,p.position_name AS
|
||||
'title',aua.title_id,au.type,au.customer_name,au.department_id,au.region_type_id
|
||||
,aua.language_code,p.position_name AS 'title',aua.title_id,au.type,au.customer_name,au.department_id,d.dept_name
|
||||
as 'departmentName'
|
||||
,au.region_type_id
|
||||
FROM app_user_applyfor aua
|
||||
LEFT JOIN app_user au ON au.id=aua.create_by
|
||||
LEFT JOIN app_area aa ON aua.area_id=aa.id
|
||||
LEFT JOIN t_base_position p ON aua.title_id=p.id
|
||||
LEFT JOIN t_base_department d ON au.department_id=d.id
|
||||
WHERE aua.type=0 AND aua.state=0
|
||||
<if test="loginName!=null and loginName!=''">
|
||||
AND aua.user_email LIKE concat('%', #{loginName}, '%')
|
||||
|
|
|
|||
|
|
@ -18,6 +18,19 @@
|
|||
</if>
|
||||
<include refid="whr"/>
|
||||
</select>
|
||||
<select id="getUsers" resultType="com.nflg.mobilebroken.common.pojo.vo.DepartmentChildItemVO">
|
||||
SELECT id,
|
||||
user_name as 'name',
|
||||
1 as 'type',
|
||||
type as 'userType',
|
||||
state,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time
|
||||
FROM v_all_user
|
||||
WHERE department_id = #{id}
|
||||
</select>
|
||||
|
||||
<delete id="del">
|
||||
delete from t_base_department where id in
|
||||
|
|
@ -25,4 +38,9 @@
|
|||
#{item}
|
||||
</foreach>
|
||||
</delete>
|
||||
<update id="updateHasManager">
|
||||
UPDATE t_base_department p
|
||||
SET has_manager=EXISTS(SELECT * FROM v_all_user WHERE department_id = p.id)
|
||||
WHERE id = #{departmentId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue