Compare commits

..

No commits in common. "2823430d31b744c2060bd88f4f801bd7f35f1145" and "5bf26c76d5aacfa487c15d110dcb9014ef981547" have entirely different histories.

20 changed files with 63 additions and 351 deletions

View File

@ -17,7 +17,6 @@ import com.nflg.mobilebroken.common.pojo.vo.TitleSimpleVO;
import com.nflg.mobilebroken.common.util.AdminUserUtil; import com.nflg.mobilebroken.common.util.AdminUserUtil;
import com.nflg.mobilebroken.common.util.VUtils; import com.nflg.mobilebroken.common.util.VUtils;
import com.nflg.mobilebroken.repository.entity.AdminUser; 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.IAdminUserService;
import com.nflg.mobilebroken.repository.service.IDictionaryItemTranslateService; import com.nflg.mobilebroken.repository.service.IDictionaryItemTranslateService;
import com.nflg.mobilebroken.repository.service.ITBaseDepartmentService; import com.nflg.mobilebroken.repository.service.ITBaseDepartmentService;
@ -135,16 +134,8 @@ public class AdminUserController extends ControllerBase {
@PostMapping("updateAccount") @PostMapping("updateAccount")
@MethodInfoMark(value = "更新账号", menuName = "账号管理") @MethodInfoMark(value = "更新账号", menuName = "账号管理")
@ApiMark(moduleName = "账号管理", apiName = "更新账号") @ApiMark(moduleName = "账号管理", apiName = "更新账号")
public ApiResult<Void> updateAccount(@Valid @RequestBody AccountUpdateRequest request) { public ApiResult<Void> updateAccount(@Valid @RequestBody AccountUpdateRequest request) throws MessagingException {
AdminUser user=adminUserService.getById(request.getId()); 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()) user.setUserCode(request.getUserCode())
.setUserName(request.getUserName()) .setUserName(request.getUserName())
.setAvatar(request.getAvatar()) .setAvatar(request.getAvatar())

View File

@ -15,7 +15,6 @@ import com.nflg.mobilebroken.common.util.VUtils;
import com.nflg.mobilebroken.repository.entity.AppUser; import com.nflg.mobilebroken.repository.entity.AppUser;
import com.nflg.mobilebroken.repository.entity.AppUserApplyfor; import com.nflg.mobilebroken.repository.entity.AppUserApplyfor;
import com.nflg.mobilebroken.repository.entity.TBaseCustomer; import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
import com.nflg.mobilebroken.repository.service.*; import com.nflg.mobilebroken.repository.service.*;
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark; import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
import com.nflg.mobilebroken.starter.service.EmailService; import com.nflg.mobilebroken.starter.service.EmailService;
@ -79,9 +78,6 @@ public class AppUserController extends ControllerBase {
@Resource @Resource
private IAdminMessageService adminMessageService; private IAdminMessageService adminMessageService;
@Resource
private ITBaseDepartmentService departmentService;
/** /**
* 获取公司列表 * 获取公司列表
* @param userId 用户id * @param userId 用户id
@ -210,16 +206,6 @@ public class AppUserController extends ControllerBase {
@ApiMark(moduleName = "代理商管理", apiName = "更新代理商账号") @ApiMark(moduleName = "代理商管理", apiName = "更新代理商账号")
public ApiResult<Void> updateAppUser(@Valid @RequestBody AppUserUpdateRequest request) { public ApiResult<Void> updateAppUser(@Valid @RequestBody AppUserUpdateRequest request) {
AppUser user=appUserService.getById(request.getId()); 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)); user.setExpireTime(user.getExpireTime().plusDays(1));
if (user.getIsPrimary()){ if (user.getIsPrimary()){
updatePrimaryAppUser(user,request); updatePrimaryAppUser(user,request);

View File

@ -1,19 +1,18 @@
package com.nflg.mobilebroken.admin.controller; package com.nflg.mobilebroken.admin.controller;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import com.nflg.mobilebroken.admin.annotation.ApiMark; import com.nflg.mobilebroken.admin.annotation.ApiMark;
import com.nflg.mobilebroken.admin.constant.Constant; import com.nflg.mobilebroken.admin.constant.Constant;
import com.nflg.mobilebroken.admin.pojo.dto.DepartmentDTO; import com.nflg.mobilebroken.admin.pojo.dto.DepartmentDTO;
import com.nflg.mobilebroken.admin.pojo.query.DepartmentQuery; import com.nflg.mobilebroken.admin.pojo.query.DepartmentQuery;
import com.nflg.mobilebroken.admin.pojo.vo.BaseDepartmentVO; import com.nflg.mobilebroken.admin.pojo.vo.BaseDepartmentVO;
import com.nflg.mobilebroken.admin.service.AdminDepartmentService; 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.ApiResult;
import com.nflg.mobilebroken.common.pojo.PageData; 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.AdminUserUtil;
import com.nflg.mobilebroken.common.util.UniqueSequenceGenerator; import com.nflg.mobilebroken.common.util.UniqueSequenceGenerator;
import com.nflg.mobilebroken.common.util.VUtils; import com.nflg.mobilebroken.common.util.VUtils;
@ -27,8 +26,6 @@ import javax.validation.Valid;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* 部门管理 * 部门管理
@ -50,9 +47,9 @@ public class DepartmentController extends ControllerBase {
*/ */
@PostMapping("getList") @PostMapping("getList")
@ApiMark(moduleName = "部门管理", apiName = "获取部门列表") @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);
} }
@ -64,7 +61,7 @@ public class DepartmentController extends ControllerBase {
*/ */
@GetMapping("getChild") @GetMapping("getChild")
@ApiMark(moduleName = "部门管理", apiName = "获取子级") @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)); return ApiResult.success(departmentService.getChildByParentId(parentId));
} }
@ -75,19 +72,20 @@ public class DepartmentController extends ControllerBase {
* @return * @return
*/ */
@PostMapping("add") @PostMapping("add")
@MethodInfoMark(value = "新增", menuName = "部门管理") @MethodInfoMark(value = "新增" ,menuName = "部门管理")
@ApiMark(moduleName = "部门管理", apiName = "新增") @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(); // List<TBaseDepartment> checkCode = departmentService.lambdaQuery().eq(TBaseDepartment::getDeptCode, departmentDTO.getDeptCode()).list();
//新增 //新增
TBaseDepartment dept = Convert.convert(TBaseDepartment.class, departmentDTO); 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.setDeptCode(UniqueSequenceGenerator.generateCode(Constant.DeptCodePrefix));
dept.setDataCreateUserNo(AdminUserUtil.getUserNo()); dept.setDataCreateUserNo(AdminUserUtil.getUserNo());
dept.setDataCreateUserName(AdminUserUtil.getUserName()); dept.setDataCreateUserName(AdminUserUtil.getUserName());
dept.setDataCreateTime(LocalDateTime.now()); dept.setDataCreateTime(LocalDateTime.now());
} else { }
else {
dept.setDataModifyUserNo(AdminUserUtil.getUserNo()); dept.setDataModifyUserNo(AdminUserUtil.getUserNo());
dept.setDataModifyUserName(AdminUserUtil.getUserName()); dept.setDataModifyUserName(AdminUserUtil.getUserName());
dept.setDataModifyTime(LocalDateTime.now()); dept.setDataModifyTime(LocalDateTime.now());
@ -103,33 +101,23 @@ public class DepartmentController extends ControllerBase {
* @return * @return
*/ */
@PostMapping("del") @PostMapping("del")
@MethodInfoMark(value = "删除", menuName = "部门管理") @MethodInfoMark(value = "删除",menuName = "部门管理")
@ApiMark(moduleName = "部门管理", apiName = "删除") @ApiMark(moduleName = "部门管理", apiName = "删除")
public ApiResult<Boolean> del(@RequestBody List<Long> ids) { public ApiResult<Boolean> add(@RequestBody List<Long> ids ){
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要删除的数据"); VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要删除的数据");
List<TBaseDepartment> delDepartments = departmentService.getBaseMapper().selectByIds(ids); List<TBaseDepartment> delDepartments = departmentService.getBaseMapper().selectByIds(ids);
// List<String> hasChildDeptNames=new ArrayList<>(); List<String> hasChildDeptNames=new ArrayList<>();
// List<Long> childIds=new ArrayList<>(); List<Long> childIds=new ArrayList<>();
// for (TBaseDepartment dept :delDepartments) { for (TBaseDepartment dept :delDepartments) {
// childIds.clear(); childIds.clear();
// adminDepartmentService.getAllChildIds(dept,childIds); adminDepartmentService.getAllChildIds(dept,childIds);
// if(CollUtil.isNotEmpty(childIds)){ if(CollUtil.isNotEmpty(childIds)){
// hasChildDeptNames.add(dept.getDeptName()); hasChildDeptNames.add(dept.getDeptName());
// } }
// } }
// if(CollUtil.isNotEmpty(hasChildDeptNames)){ if(CollUtil.isNotEmpty(hasChildDeptNames)){
// throw new NflgException(STATE.ParamErr, StrUtil.join(",", 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); departmentService.del(ids);
return ApiResult.success(true); return ApiResult.success(true);
} }
@ -141,18 +129,18 @@ public class DepartmentController extends ControllerBase {
* @return * @return
*/ */
@PostMapping("enable") @PostMapping("enable")
@MethodInfoMark(value = "启用", menuName = "部门管理") @MethodInfoMark(value = "启用",menuName = "部门管理")
@ApiMark(moduleName = "部门管理", apiName = "启用") @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("请选择要启用的数据"); VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要启用的数据");
List<TBaseDepartment> tBaseDepartments = departmentService.getBaseMapper().selectByIds(ids); List<TBaseDepartment> tBaseDepartments = departmentService.getBaseMapper().selectByIds(ids);
tBaseDepartments.forEach(u -> { tBaseDepartments.forEach(u->{
u.setDeptStatus(1); u.setDeptStatus(1);
u.setDataModifyUserNo(AdminUserUtil.getUserNo()); u.setDataModifyUserNo(AdminUserUtil.getUserNo());
u.setDataModifyUserName(AdminUserUtil.getUserName()); u.setDataModifyUserName(AdminUserUtil.getUserName());
u.setDataModifyTime(LocalDateTime.now()); u.setDataModifyTime(LocalDateTime.now());
}); });
if (CollUtil.isNotEmpty(tBaseDepartments)) { if(CollUtil.isNotEmpty(tBaseDepartments)){
departmentService.updateBatchById(tBaseDepartments); departmentService.updateBatchById(tBaseDepartments);
} }
@ -166,86 +154,37 @@ public class DepartmentController extends ControllerBase {
* @return * @return
*/ */
@PostMapping("disable") @PostMapping("disable")
@MethodInfoMark(value = "禁用", menuName = "部门管理") @MethodInfoMark(value = "禁用",menuName = "部门管理")
@ApiMark(moduleName = "部门管理", apiName = "禁用") @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("请选择要启用的数据"); VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要启用的数据");
List<TBaseDepartment> tBaseDepartments = departmentService.getBaseMapper().selectByIds(ids); List<TBaseDepartment> tBaseDepartments = departmentService.getBaseMapper().selectByIds(ids);
List<Long> childIds = new ArrayList<>(); List<Long> childIds=new ArrayList<>();
childIds.addAll(ids); childIds.addAll(ids);
for (TBaseDepartment tBaseDepartment : tBaseDepartments) { for (TBaseDepartment tBaseDepartment : tBaseDepartments) {
adminDepartmentService.getAllChildIds(tBaseDepartment, childIds); adminDepartmentService.getAllChildIds(tBaseDepartment, childIds);
} }
tBaseDepartments = departmentService.getBaseMapper().selectByIds(childIds); tBaseDepartments = departmentService.getBaseMapper().selectByIds(childIds);
tBaseDepartments.forEach(u -> { tBaseDepartments.forEach(u->{
u.setDeptStatus(0); u.setDeptStatus(0);
u.setDataModifyUserNo(AdminUserUtil.getUserNo()); u.setDataModifyUserNo(AdminUserUtil.getUserNo());
u.setDataModifyUserName(AdminUserUtil.getUserName()); u.setDataModifyUserName(AdminUserUtil.getUserName());
u.setDataModifyTime(LocalDateTime.now()); u.setDataModifyTime(LocalDateTime.now());
}); });
if (CollUtil.isNotEmpty(tBaseDepartments)) { if(CollUtil.isNotEmpty(tBaseDepartments)){
departmentService.updateBatchById(tBaseDepartments); departmentService.updateBatchById(tBaseDepartments);
} }
return ApiResult.success(true); 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);
}
}
} }

View File

@ -538,6 +538,7 @@ public class TicketController extends ControllerBase {
@GetMapping("exportPdf") @GetMapping("exportPdf")
@ApiMark(moduleName = "工单管理", apiName = "导出工单为pdf") @ApiMark(moduleName = "工单管理", apiName = "导出工单为pdf")
public void exportPdf(HttpServletResponse response, @Valid @RequestParam @NotNull(message = "工单编号不能为空") Integer id) { public void exportPdf(HttpServletResponse response, @Valid @RequestParam @NotNull(message = "工单编号不能为空") Integer id) {
Ticket ticket = ticketService.getById(id); Ticket ticket = ticketService.getById(id);
VUtils.trueThrowBusinessError(Objects.isNull(ticket)).throwMessage("工单不存在"); VUtils.trueThrowBusinessError(Objects.isNull(ticket)).throwMessage("工单不存在");
DeviceInfoVO device = deviceService.getByDeviceNo(ticket.getDeviceNo()); DeviceInfoVO device = deviceService.getByDeviceNo(ticket.getDeviceNo());

View File

@ -63,11 +63,8 @@
<td colspan="2" th:text="${ticket.useTime}+'小时'"></td> <td colspan="2" th:text="${ticket.useTime}+'小时'"></td>
</tr> </tr>
<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 class="desc1">处理人</td>
<td colspan="8" th:text="${ticket.handleUserName}"></td> <td colspan="11" th:text="${ticket.handleUserName}"></td>
</tr> </tr>
<tr> <tr>
<td class="desc1">问题描述</td> <td class="desc1">问题描述</td>

View File

@ -123,11 +123,6 @@ public class AppUserForAdminVO {
*/ */
private Long departmentId; private Long departmentId;
/**
* 部门名称
*/
private String departmentName;
/** /**
* 地域类型字典id * 地域类型字典id
*/ */

View File

@ -106,14 +106,4 @@ public class AppUserVO {
//平台app或者admin //平台app或者admin
private String platform="app"; private String platform="app";
/**
* 部门id
*/
private Long departmentId;
/**
* 部门名称
*/
private String departmentName;
} }

View File

@ -1,50 +0,0 @@
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;
}

View File

@ -1,21 +0,0 @@
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;
}

View File

@ -15,16 +15,6 @@ public class DepartmentSimpleVO {
//部门名称 //部门名称
private String name; private String name;
/**
* 是否有下级
*/
private boolean hasChild;
/**
* 是否已设置管理者
*/
private boolean hasManager;
//下级 //下级
private List<DepartmentSimpleVO> children; private List<DepartmentSimpleVO> children;
} }

View File

@ -67,11 +67,8 @@
<td colspan="2" th:text="${base.v1}"></td> <td colspan="2" th:text="${base.v1}"></td>
</tr> </tr>
<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 class="desc1">处理人</td>
<td colspan="8" th:text="${ticket.handleUserName}"></td> <td colspan="11" th:text="${ticket.handleUserName}"></td>
</tr> </tr>
<tr> <tr>
<td class="desc1">问题描述</td> <td class="desc1">问题描述</td>

View File

@ -3,13 +3,12 @@ package com.nflg.mobilebroken.repository.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
/** /**
* <p> * <p>
* 部门表 * 部门表
@ -86,14 +85,4 @@ public class TBaseDepartment implements Serializable {
* 更新时间 * 更新时间
*/ */
private LocalDateTime dataModifyTime; private LocalDateTime dataModifyTime;
/**
* 是否有下级
*/
private boolean hasChild;
/**
* 是否已设置管理者
*/
private boolean hasManager;
} }

View File

@ -1,10 +1,9 @@
package com.nflg.mobilebroken.repository.mapper; package com.nflg.mobilebroken.repository.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery; 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.nflg.mobilebroken.repository.entity.TBaseDepartment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -22,8 +21,4 @@ public interface TBaseDepartmentMapper extends BaseMapper<TBaseDepartment> {
Page<TBaseDepartment> selectListByPage(@Param("page") Page<PageBaseQuery> page,@Param("query") PageBaseQuery query ); Page<TBaseDepartment> selectListByPage(@Param("page") Page<PageBaseQuery> page,@Param("query") PageBaseQuery query );
void del(@Param("ids") List<Long> ids); void del(@Param("ids") List<Long> ids);
void updateHasManager(Long departmentId);
List<DepartmentChildItemVO> getUsers(Long id);
} }

View File

@ -3,7 +3,6 @@ package com.nflg.mobilebroken.repository.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery; 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.common.pojo.vo.DepartmentSimpleVO;
import com.nflg.mobilebroken.repository.entity.TBaseDepartment; import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -35,8 +34,4 @@ public interface ITBaseDepartmentService extends IService<TBaseDepartment> {
Set<Long> getAllChildrenIds(Long departmentId); Set<Long> getAllChildrenIds(Long departmentId);
void updateHasManager(Long departmentId);
List<DepartmentChildItemVO> getUsers(Long id);
} }

View File

@ -120,11 +120,6 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
.setCreateTime(LocalDateTime.now()); .setCreateTime(LocalDateTime.now());
save(user); save(user);
} }
departmentService.lambdaUpdate()
.set(TBaseDepartment::isHasManager, true)
.eq(TBaseDepartment::isHasManager, false)
.eq(TBaseDepartment::getId, user.getDepartmentId())
.update();
return user; return user;
} }
@ -470,8 +465,7 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
Set<TBaseDepartment> searchDepartments = departments.stream() Set<TBaseDepartment> searchDepartments = departments.stream()
.filter(d -> searchUsers.stream().map(AdminUser::getDepartmentId).anyMatch(dt -> Objects.equals(d.getId(), dt))) .filter(d -> searchUsers.stream().map(AdminUser::getDepartmentId).anyMatch(dt -> Objects.equals(d.getId(), dt)))
.collect(Collectors.toSet()); .collect(Collectors.toSet());
Set<TBaseDepartment> treeDepartments = new HashSet<>(searchDepartments); searchDepartments.forEach(d -> bindParent(d, searchDepartments, departments));
searchDepartments.forEach(d -> bindParent(d, treeDepartments, departments));
List<TBaseDepartment> rootDepartments = searchDepartments.stream() List<TBaseDepartment> rootDepartments = searchDepartments.stream()
.filter(d -> d.getDeptParentId() == 0) .filter(d -> d.getDeptParentId() == 0)
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -512,14 +506,13 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
} }
} }
private void bindParent(TBaseDepartment department, Set<TBaseDepartment> treeDepartments, List<TBaseDepartment> departments) { private void bindParent(TBaseDepartment department, Set<TBaseDepartment> vos, List<TBaseDepartment> departments) {
Set<TBaseDepartment> parents = departments.stream() Set<TBaseDepartment> parents = departments.stream()
.filter(d -> Objects.equals(d.getId(), department.getDeptParentId())) .filter(d -> Objects.equals(d.getId(), department.getDeptParentId()))
.collect(Collectors.toSet()); .collect(Collectors.toSet());
parents.removeIf(p -> treeDepartments.stream().anyMatch(v -> Objects.equals(p.getId(), v.getId())));
if (CollectionUtil.isNotEmpty(parents)) { if (CollectionUtil.isNotEmpty(parents)) {
treeDepartments.addAll(parents); vos.addAll(parents);
parents.forEach(p -> bindParent(p, treeDepartments, departments)); parents.forEach(p -> bindParent(p, vos, departments));
} }
} }

View File

@ -59,9 +59,6 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
@Resource @Resource
private ITBaseAreaService baseAreaService; private ITBaseAreaService baseAreaService;
@Resource
private ITBaseDepartmentService departmentService;
@Override @Override
public AppUserApplyfor add(AddUserRequest request) { public AppUserApplyfor add(AddUserRequest request) {
VUtils.trueThrowBusinessError(appUserService.lambdaQuery().eq(AppUser::getEmail, request.getEmail()).exists()) VUtils.trueThrowBusinessError(appUserService.lambdaQuery().eq(AppUser::getEmail, request.getEmail()).exists())
@ -226,11 +223,6 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
.setExpireTime(appUser.getExpireTime()) .setExpireTime(appUser.getExpireTime())
.setSalesUserName(appUser.getSalesUserName()); .setSalesUserName(appUser.getSalesUserName());
appUserService.save(user); 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()) { } else if (applyfor.getType() == AppUserApplyforType.ENABLE.getState().byteValue()) {
//账号启用 //账号启用
AppUser appUser = appUserService.getById(applyfor.getUserId()); AppUser appUser = appUserService.getById(applyfor.getUserId());

View File

@ -71,9 +71,6 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
@Resource @Resource
private ITBaseAreaService baseAreaService; private ITBaseAreaService baseAreaService;
@Resource
private ITBaseDepartmentService departmentService;
@Override @Override
public AppUser getUser(String userName, String password) { public AppUser getUser(String userName, String password) {
AppUser user = lambdaQuery() AppUser user = lambdaQuery()
@ -201,11 +198,6 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
.setExpireTime(LocalDate.of(LocalDateTime.now().getYear() + 1, 1, 1)); .setExpireTime(LocalDate.of(LocalDateTime.now().getYear() + 1, 1, 1));
save(user); save(user);
} }
departmentService.lambdaUpdate()
.set(TBaseDepartment::isHasManager, true)
.eq(TBaseDepartment::isHasManager, false)
.eq(TBaseDepartment::getId, user.getDepartmentId())
.update();
return user; return user;
} }
@ -247,13 +239,12 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
AppUser primaryUser = getById(id); AppUser primaryUser = getById(id);
List<Integer> companyIds = Arrays.stream(primaryUser.getCompanyId().split(",")).map(Integer::parseInt).collect(Collectors.toList()); List<Integer> companyIds = Arrays.stream(primaryUser.getCompanyId().split(",")).map(Integer::parseInt).collect(Collectors.toList());
List<CompanyVO> datas = new ArrayList<>(); List<CompanyVO> datas = new ArrayList<>();
List<TBaseDepartment> departments = departmentService.list();
for (Integer companyId : companyIds) { for (Integer companyId : companyIds) {
TBaseCustomer customer = customerService.getById(companyId); TBaseCustomer customer = customerService.getById(companyId);
CompanyVO companyVO = new CompanyVO() CompanyVO companyVO = new CompanyVO()
.setId(customer.getId()) .setId(customer.getId())
.setName(customer.getAgencyCompanyName()) .setName(customer.getAgencyCompanyName())
.setUsers(getByCompanyId(companyId, departments)); .setUsers(getByCompanyId(companyId));
datas.add(companyVO); datas.add(companyVO);
} }
return datas; return datas;
@ -432,7 +423,6 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
List<AppUserForAdminVO> subs = datas.stream() List<AppUserForAdminVO> subs = datas.stream()
.filter(d -> Objects.nonNull(d.getIsPrimary()) && !d.getIsPrimary()) .filter(d -> Objects.nonNull(d.getIsPrimary()) && !d.getIsPrimary())
.collect(Collectors.toList()); .collect(Collectors.toList());
List<TBaseDepartment> departments = departmentService.list();
subs.forEach(d -> { subs.forEach(d -> {
AppUserForAdminVO primary = primarys.stream() AppUserForAdminVO primary = primarys.stream()
.filter(p -> Objects.nonNull(p.getIsPrimary()) && Arrays.stream(p.getCompanyId().split(",")).anyMatch(c -> c.equals(d.getCompanyId()))) .filter(p -> Objects.nonNull(p.getIsPrimary()) && Arrays.stream(p.getCompanyId().split(",")).anyMatch(c -> c.equals(d.getCompanyId())))
@ -467,14 +457,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
.setSalesUserName(appUser.getSalesUserName()) .setSalesUserName(appUser.getSalesUserName())
.setTitleId(appUser.getTitleId()) .setTitleId(appUser.getTitleId())
.setTitle(positionService.getById(appUser.getTitleId()).getPositionName()) .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() AppUserApplyfor applyFor = appUserApplyforService.lambdaQuery()
.eq(AppUserApplyfor::getUserId, appUser.getId()) .eq(AppUserApplyfor::getUserId, appUser.getId())
.eq(AppUserApplyfor::getState, AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue()) .eq(AppUserApplyfor::getState, AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue())
@ -765,13 +748,12 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
.collect(Collectors.toSet()); .collect(Collectors.toSet());
companyIds.addAll(userCompanyIds); companyIds.addAll(userCompanyIds);
} }
List<TBaseDepartment> departments = departmentService.list();
companyIds.forEach(id -> { companyIds.forEach(id -> {
TBaseCustomer customer = customerService.getById(id); TBaseCustomer customer = customerService.getById(id);
CompanyVO companyVO = new CompanyVO() CompanyVO companyVO = new CompanyVO()
.setId(customer.getId()) .setId(customer.getId())
.setName(customer.getAgencyCompanyName()) .setName(customer.getAgencyCompanyName())
.setUsers(getByCompanyId(id, departments)); .setUsers(getByCompanyId(id));
datas.add(companyVO); datas.add(companyVO);
}); });
return datas; return datas;
@ -852,7 +834,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
return getBaseMapper().selectOne(queryWrapper); return getBaseMapper().selectOne(queryWrapper);
} }
private List<AppUserVO> getByCompanyId(Integer companyId, List<TBaseDepartment> departments) { private List<AppUserVO> getByCompanyId(Integer companyId) {
return lambdaQuery() return lambdaQuery()
.eq(AppUser::getIsDel, false) .eq(AppUser::getIsDel, false)
.eq(AppUser::getCompanyId, companyId.toString()) .eq(AppUser::getCompanyId, companyId.toString())
@ -860,18 +842,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
.eq(AppUser::getIsPrimary, false) .eq(AppUser::getIsPrimary, false)
.list() .list()
.stream() .stream()
.map(u -> new AppUserVO() .map(u -> new AppUserVO().setId(u.getId()).setName(u.getName()))
.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()); .collect(Collectors.toList());
} }
} }

View File

@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery; 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.common.pojo.vo.DepartmentSimpleVO;
import com.nflg.mobilebroken.repository.entity.TBaseDepartment; import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
import com.nflg.mobilebroken.repository.mapper.TBaseDepartmentMapper; import com.nflg.mobilebroken.repository.mapper.TBaseDepartmentMapper;
@ -73,16 +72,6 @@ public class TBaseDepartmentServiceImpl extends ServiceImpl<TBaseDepartmentMappe
return ids; 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) { private void getChildrenIds(Set<Long> ids, List<TBaseDepartment> departments, Long departmentId) {
Set<Long> cids = departments.stream() Set<Long> cids = departments.stream()
.filter(d -> Objects.equals(d.getDeptParentId(), departmentId)) .filter(d -> Objects.equals(d.getDeptParentId(), departmentId))
@ -107,12 +96,7 @@ public class TBaseDepartmentServiceImpl extends ServiceImpl<TBaseDepartmentMappe
private List<DepartmentSimpleVO> convert(List<TBaseDepartment> datas) { private List<DepartmentSimpleVO> convert(List<TBaseDepartment> datas) {
return datas.stream() return datas.stream()
.map(d -> new DepartmentSimpleVO() .map(d -> new DepartmentSimpleVO().setId(d.getId()).setName(d.getDeptName()))
.setId(d.getId())
.setName(d.getDeptName())
.setHasChild(d.isHasChild())
.setHasManager(d.isHasManager())
)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} }

View File

@ -123,14 +123,12 @@
,au.expire_time,IF(aua.id IS NOT NULL,0 ,au.expire_time,IF(aua.id IS NOT NULL,0
,IF(CONVERT_TZ(NOW(), @@session.time_zone, '+00:00') &lt; au.expire_time,1,2)) AS 'state',au.create_by ,IF(CONVERT_TZ(NOW(), @@session.time_zone, '+00:00') &lt; 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.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,d.dept_name ,au.language_code,p.position_name AS
as 'departmentName' 'title',au.title_id,au.type,au.customer_name,au.department_id,au.region_type_id
,au.region_type_id
FROM app_user au FROM app_user au
LEFT JOIN app_area aa ON au.area_id=aa.id 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 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_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 WHERE au.is_del=0
<if test="loginName!=null and loginName!=''"> <if test="loginName!=null and loginName!=''">
AND au.login_name LIKE concat('%', #{loginName}, '%') AND au.login_name LIKE concat('%', #{loginName}, '%')
@ -160,14 +158,12 @@
,IF(aua.is_primary,fun_getPrimaryUserArea(aua.company_id),aa.`name`) AS 'areaName' ,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 '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 ,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,d.dept_name ,aua.language_code,p.position_name AS
as 'departmentName' 'title',aua.title_id,au.type,au.customer_name,au.department_id,au.region_type_id
,au.region_type_id
FROM app_user_applyfor aua FROM app_user_applyfor aua
LEFT JOIN app_user au ON au.id=aua.create_by LEFT JOIN app_user au ON au.id=aua.create_by
LEFT JOIN app_area aa ON aua.area_id=aa.id 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_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 WHERE aua.type=0 AND aua.state=0
<if test="loginName!=null and loginName!=''"> <if test="loginName!=null and loginName!=''">
AND aua.user_email LIKE concat('%', #{loginName}, '%') AND aua.user_email LIKE concat('%', #{loginName}, '%')

View File

@ -18,19 +18,6 @@
</if> </if>
<include refid="whr"/> <include refid="whr"/>
</select> </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 id="del">
delete from t_base_department where id in delete from t_base_department where id in
@ -38,9 +25,4 @@
#{item} #{item}
</foreach> </foreach>
</delete> </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> </mapper>