Compare commits

...

13 Commits

Author SHA1 Message Date
曹鹏飞 a85a236994 Merge branch 'feature/data-permission' into feature/quotation 2026-01-20 09:24:55 +08:00
曹鹏飞 e0579c4c5c Merge branch 'feature/gongfu' into feature/data-permission 2026-01-20 09:24:20 +08:00
曹鹏飞 3c77153dfc Merge branch 'prod/20260119' into feature/gongfu 2026-01-19 15:30:18 +08:00
曹鹏飞 1d0e85f6f0 移除代理商过期处理定时任务 2026-01-19 15:29:55 +08:00
曹鹏飞 8a6bbcc7a1 Merge branch 'feature/gongfu' into feature/data-permission 2026-01-19 10:46:54 +08:00
曹鹏飞 2c9047d1a5 服务报告添加对服务月报的上传支持 2026-01-19 10:46:21 +08:00
曹鹏飞 2823430d31 feat(department): 完善部门管理功能并优化用户关联逻辑
- 新增部门子级数据结构定义,包括DepartmentChildItemVO和DepartmentChildVO
- 在AppUserForAdminVO和AppUserVO中添加部门名称字段用于显示
- 实现部门与用户的关联查询,在多处服务层添加部门名称映射
- 重构部门控制器中的删除验证逻辑,改为检查子级和管理员用户
- 添加获取部门绑定用户和子级部门的接口方法
- 优化部门启用禁用功能,支持批量操作和状态更新
- 修复用户更新时的部门变更处理逻辑,确保部门管理员状态正确更新
- 重构部门服务层的hasManager字段更新逻辑,提高数据一致性
2026-01-19 09:50:09 +08:00
曹鹏飞 6f845e50ae Merge branch 'feature/gongfu' into feature/data-permission 2026-01-16 16:23:28 +08:00
曹鹏飞 392956408e feat(ticket): 添加主要负责人字段到工单PDF导出功能
- 在PDF模板中新增主要负责人显示字段
- 实现主要负责人从处理人列表中提取第一个的功能
- 调整表格列宽布局以适应新字段
- 优化工单PDF导出的数据展示结构
2026-01-16 16:19:13 +08:00
曹鹏飞 81d10ba5d1 refactor(department): 优化部门层级绑定逻辑并添加部门属性
- 修改bindParent方法参数名以提高代码可读性
- 在bindParent方法中添加重复检查避免循环引用
- 创建treeDepartments副本确保数据完整性
- 调整TBaseDepartment类中导入语句顺序
- 添加hasChild和hasManager两个新字段用于标识部门状态
2026-01-16 15:57:44 +08:00
曹鹏飞 5bf26c76d5 Merge branch 'feature/gongfu' into feature/data-permission
# Conflicts:
#	nflg-mobilebroken-admin/src/test/java/TTest.java
2026-01-16 15:16:49 +08:00
曹鹏飞 142b47f91f refactor(customer): 优化代理商公司同步逻辑,按公司名称和编码排重,任一个相同责认为是相同的记录,会覆盖旧记录 2026-01-16 15:15:29 +08:00
曹鹏飞 5ea168155f feat(admin): 实现管理员账号搜索功能优化
- 搜索账号接口添加新版本标识
- 重构搜索逻辑,使用流式过滤替代模糊查询
- 优化部门层级绑定逻辑,支持更精确的树形结构构建
- 添加子节点递归处理功能,完善用户组织架构展示
- 修复部门与用户关联关系的数据转换问题
- 优化集合操作提高搜索性能
2026-01-16 13:54:05 +08:00
27 changed files with 557 additions and 148 deletions

View File

@ -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())
@ -373,7 +382,7 @@ public class AdminUserController extends ControllerBase {
}
/**
* 搜索账号
* 搜索账号
* @param request 请求参数
*/
@PostMapping("searchAccountNew")

View File

@ -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);

View File

@ -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;
/**
* 部门管理
@ -84,8 +87,7 @@ public class DepartmentController extends ControllerBase {
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());
@ -103,21 +105,31 @@ public class DepartmentController extends ControllerBase {
@PostMapping("del")
@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);
}
@ -179,12 +191,61 @@ public class DepartmentController extends ControllerBase {
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,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());

View File

@ -22,7 +22,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -99,10 +98,10 @@ public class AdminCustomerService {
*/
public void syncFromCrm(SyncFromCrmDTO dateParam) {
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 循环从起始日期到结束日期每次增加一天
List<TBaseCustomer> result = new ArrayList<>();
// List<TBaseCustomer> result = new ArrayList<>();
// for (LocalDate date = stDate; !date.isAfter(edDate); date = date.plusDays(1)) {
@ -110,12 +109,19 @@ public class AdminCustomerService {
if (CollUtil.isEmpty(agentList)) {
return;
}
Set<String> crmComanyCodes = agentList.stream().map(u -> u.getId()).collect(Collectors.toSet());
List<TBaseCustomer> crmCompanyList = baseCustomerService.lambdaQuery().in(TBaseCustomer::getAgencyCompanyCode, crmComanyCodes).list();
Map<String, TBaseCustomer> crmCompanyMap = crmCompanyList.stream().collect(Collectors.toMap(TBaseCustomer::getAgencyCompanyCode, cm -> cm));
List<TBaseCustomer> result = new ArrayList<>();
// Set<String> crmComanyCodes = agentList.stream().map(u -> u.getId()).collect(Collectors.toSet());
// List<TBaseCustomer> crmCompanyList = baseCustomerService.lambdaQuery().in(TBaseCustomer::getAgencyCompanyCode, crmComanyCodes).list();
// Map<String, TBaseCustomer> crmCompanyMap = crmCompanyList.stream().collect(Collectors.toMap(TBaseCustomer::getAgencyCompanyCode, cm -> cm));
List<TBaseCustomer> customers = baseCustomerService.list();
agentList.forEach(u -> {
TBaseCustomer ent = crmCompanyMap.get(u.getId());
// TBaseCustomer ent = crmCompanyMap.get(u.getId());
TBaseCustomer ent = customers.stream()
.filter(c -> Objects.equals(c.getAgencyCompanyCode(), u.getId())
|| StrUtil.equals(convertName(c.getAgencyCompanyName()), convertName(u.getName())))
.findFirst()
.orElse(null);
if (Objects.nonNull(ent)) {
ent.setDataModifyTime(LocalDateTime.now());
@ -150,5 +156,7 @@ public class AdminCustomerService {
}
private String convertName(String name) {
return name.replaceAll("\\s+", "");
}
}

View File

@ -18,38 +18,38 @@ import java.util.stream.Collectors;
@Slf4j
public class AppUserScheduledTasks {
@Resource
private IAppUserService appUserService;
/**
* 禁用已过期代理商
* 每天午夜12点执行一次
*/
@Transactional
@Scheduled(cron = "0 0 0 * * ?")
public void disableExpiredAppUser() {
List<AppUser> primaryAppUsers=appUserService.lambdaQuery()
.eq(AppUser::getIsPrimary, true)
.lt(AppUser::getExpireTime, LocalDateTime.now().toLocalDate())
.list();
if (CollectionUtil.isNotEmpty(primaryAppUsers)){
appUserService.lambdaUpdate()
.set(AppUser::getState, UserState.Disabled.getState())
.set(AppUser::getUpdateTime, LocalDateTime.now())
.ne(AppUser::getState, UserState.Disabled.getState())
.in(AppUser::getId, primaryAppUsers.stream().map(AppUser::getId).collect(Collectors.toList()))
.update();
for (AppUser primaryUser : primaryAppUsers) {
List<AppUser> children=appUserService.getChildren(primaryUser);
if (CollectionUtil.isNotEmpty(children)){
appUserService.lambdaUpdate()
.set(AppUser::getState, UserState.Disabled.getState())
.set(AppUser::getUpdateTime, LocalDateTime.now())
.ne(AppUser::getState, UserState.Disabled.getState())
.in(AppUser::getId, children.stream().map(AppUser::getId).collect(Collectors.toList()))
.update();
}
}
}
}
// @Resource
// private IAppUserService appUserService;
//
// /**
// * 禁用已过期代理商
// * 每天午夜12点执行一次
// */
// @Transactional
// @Scheduled(cron = "0 0 0 * * ?")
// public void disableExpiredAppUser() {
// List<AppUser> primaryAppUsers=appUserService.lambdaQuery()
// .eq(AppUser::getIsPrimary, true)
// .lt(AppUser::getExpireTime, LocalDateTime.now().toLocalDate())
// .list();
// if (CollectionUtil.isNotEmpty(primaryAppUsers)){
// appUserService.lambdaUpdate()
// .set(AppUser::getState, UserState.Disabled.getState())
// .set(AppUser::getUpdateTime, LocalDateTime.now())
// .ne(AppUser::getState, UserState.Disabled.getState())
// .in(AppUser::getId, primaryAppUsers.stream().map(AppUser::getId).collect(Collectors.toList()))
// .update();
// for (AppUser primaryUser : primaryAppUsers) {
// List<AppUser> children=appUserService.getChildren(primaryUser);
// if (CollectionUtil.isNotEmpty(children)){
// appUserService.lambdaUpdate()
// .set(AppUser::getState, UserState.Disabled.getState())
// .set(AppUser::getUpdateTime, LocalDateTime.now())
// .ne(AppUser::getState, UserState.Disabled.getState())
// .in(AppUser::getId, children.stream().map(AppUser::getId).collect(Collectors.toList()))
// .update();
// }
// }
// }
// }
}

View File

@ -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>

View File

@ -20,4 +20,9 @@ public class TTest {
public void test2() {
System.out.println(StrUtil.toCamelCase("user_name"));
}
@Test
public void test3() {
System.out.println("" + " 打 撒sfc dffd发多少分多少 分多少分的d f ".replaceAll("\\s+", "") + "");
}
}

View File

@ -11,7 +11,7 @@ public class FileSearch1Request extends PageRequest {
private String key;
/**
* 类型0派工单
* 类型0派工单1服务月报
*/
private Integer type;
}

View File

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@ -83,5 +84,5 @@ public class AdminUserVO {
@JsonProperty("isGongfu")
private boolean isGongfu;
private List<AdminUserVO> children;
private List<AdminUserVO> children = new ArrayList<>();
}

View File

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

View File

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

View File

@ -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;
}

View File

@ -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;
}

View File

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

View File

@ -1,21 +1,30 @@
package com.nflg.mobilebroken.gongfu.controller;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.mobilebroken.common.pojo.ApiResult;
import com.nflg.mobilebroken.common.pojo.PageData;
import com.nflg.mobilebroken.common.pojo.request.FileSearch1Request;
import com.nflg.mobilebroken.common.util.AdminUserUtil;
import com.nflg.mobilebroken.gongfu.pojo.query.FileUploadQuery;
import com.nflg.mobilebroken.repository.entity.GongfuFile;
import com.nflg.mobilebroken.repository.service.IFileUploadRecordService;
import com.nflg.mobilebroken.repository.service.IGongfuFileService;
import com.nflg.mobilebroken.starter.service.FileUploadService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Objects;
@ -27,14 +36,19 @@ import java.util.Objects;
@RequestMapping("/file")
public class FileController extends ControllerBase {
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
@Resource
private IGongfuFileService fileService;
@Resource
private FileUploadService fileUploadService;
/**
* 文件搜索
*/
@PostMapping("/search")
public ApiResult<PageData<GongfuFile>> search(@Valid @RequestBody FileSearch1Request request) {
public ApiResult<PageData<GongfuFile>> search(@RequestBody FileSearch1Request request) {
return ApiResult.success(
fileService.lambdaQuery()
.eq(Objects.nonNull(request.getType()), GongfuFile::getType, request.getType())
@ -43,6 +57,37 @@ public class FileController extends ControllerBase {
);
}
/**
* 文件上传
* @param type 类型1服务月报
* @param fileName 文件名称
* @param file 文件
*/
@PostMapping("/upload")
public ApiResult<Void> upload(@RequestParam Integer type,@RequestParam String fileName,@RequestParam MultipartFile file) throws IOException {
String url = fileUploadService.upload(buildFilePath(getFileType(file.getOriginalFilename())), file);
fileService.save(
new GongfuFile()
.setType(type)
.setFileName(fileName)
.setFileSize(file.getSize())
.setFileSuffix(FilenameUtils.getExtension(file.getOriginalFilename()))
.setFileUrl(url)
.setCreateBy(AdminUserUtil.getUserName())
.setCreateTime(LocalDateTime.now())
);
return ApiResult.success();
}
private String buildFilePath(String fileType) {
return StrUtil.format("gongfu/{}/{}/{}/{}{}", LocalDateTime.now().format(FORMATTER), AdminUserUtil.getUserId()
, RandomUtil.randomString(4), IdUtil.fastUUID(), fileType);
}
private String getFileType(String fileName) {
return "." + FilenameUtils.getExtension(fileName).toLowerCase();
}
/**
* 文件删除
*/

View File

@ -0,0 +1,29 @@
package com.nflg.mobilebroken.gongfu.pojo.query;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
public class FileUploadQuery {
/**
* 类型1服务月报
*/
@NotNull
private Integer type;
/**
* 文件名称
*/
@NotBlank
private String fileName;
/**
* 文件
*/
@NotNull
private MultipartFile file;
}

View File

@ -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>

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}
@ -443,44 +448,78 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
if (CollectionUtil.isEmpty(adminUsers)) {
return Collections.emptyList();
}
List<AdminUserVO> userVOS = convert(roots, department, positions, roleMaps, roles);
getChildren(userVOS.get(0), departments, adminUsers, positions, roleMaps, roles);
for (int index = 1, size = userVOS.size(); index < size; index++) {
userVOS.get(index).setChildren(userVOS.get(0).getChildren());
List<AdminUserVO> rootUserVOS = convert(roots, department, positions, roleMaps, roles);
getChildren(rootUserVOS.get(0), departments, adminUsers, positions, roleMaps, roles);
for (int index = 1, size = rootUserVOS.size(); index < size; index++) {
rootUserVOS.get(index).setChildren(rootUserVOS.get(0).getChildren());
}
return userVOS;
return rootUserVOS;
} else {
List<AdminUser> adminUsers = lambdaQuery()
.eq(AdminUser::getIsDel, false)
.like(StrUtil.isNotBlank(request.getLoginName()), AdminUser::getLoginName, request.getLoginName())
.like(StrUtil.isNotBlank(request.getUserName()), AdminUser::getUserName, request.getUserName())
.eq(request.getState() != null, AdminUser::getState, request.getState())
.list();
if (CollectionUtil.isEmpty(adminUsers)) {
List<AdminUser> searchUsers = adminUsers.stream()
.filter(u -> (StrUtil.isBlank(request.getLoginName()) || StrUtil.contains(u.getLoginName(), request.getLoginName()))
&& (StrUtil.isBlank(request.getUserName()) || StrUtil.contains(u.getUserName(), request.getUserName()))
&& (request.getState() == null || Objects.equals(u.getState(), request.getState()))
)
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(searchUsers)) {
return Collections.emptyList();
}
List<AdminUserVO> userVOS = convert1(adminUsers, departments, positions, roleMaps, roles);
Set<TBaseDepartment> departmentVOS = departments.stream()
.filter(d -> userVOS.stream().map(AdminUserVO::getDepartmentId).anyMatch(dt -> Objects.equals(d.getId(), dt)))
Set<TBaseDepartment> searchDepartments = departments.stream()
.filter(d -> searchUsers.stream().map(AdminUser::getDepartmentId).anyMatch(dt -> Objects.equals(d.getId(), dt)))
.collect(Collectors.toSet());
departmentVOS.forEach(d -> bindParent(d, departmentVOS, departments));
List<TBaseDepartment> rootDepartments = departmentVOS.stream()
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());
// List<AdminUserVO>
// rootDepartments.forEach(d -> getChildren1(d, departmentVOS, adminUsers, positions, roleMaps, roles));
//TODO 绑定树形结构
return userVOS;
List<AdminUser> rootUsers = adminUsers.stream()
.filter(u -> rootDepartments.stream()
.map(TBaseDepartment::getId).anyMatch(dt -> Objects.equals(u.getDepartmentId(), dt))
).collect(Collectors.toList());
List<AdminUserVO> rootUserVOS = convert1(rootUsers, departments, positions, roleMaps, roles);
rootUserVOS.forEach(uvo -> getChildren1(uvo, departments, adminUsers, searchUsers, positions, roleMaps, roles));
return rootUserVOS;
}
}
private void bindParent(TBaseDepartment department, Set<TBaseDepartment> vos, List<TBaseDepartment> departments) {
private void getChildren1(AdminUserVO user, List<TBaseDepartment> departments, List<AdminUser> users, List<AdminUser> searchUsers
, List<TBasePosition> positions, List<AdminUserRoleMap> roleMaps, List<AdminRole> roles) {
List<TBaseDepartment> cdepartments = departments.stream()
.filter(d -> Objects.equals(d.getDeptParentId(), user.getDepartmentId()))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(cdepartments)) {
cdepartments.forEach(department -> {
List<AdminUser> csers = searchUsers.stream()
.filter(u -> Objects.equals(u.getDepartmentId(), department.getId()))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(csers)) {
csers = users.stream()
.filter(u -> Objects.equals(u.getDepartmentId(), department.getId()))
.collect(Collectors.toList());
}
if (CollectionUtil.isNotEmpty(csers)) {
List<AdminUserVO> cuserVOS = convert(csers, department, positions, roleMaps, roles);
user.getChildren().addAll(cuserVOS);
getChildren(cuserVOS.get(0), departments, users, positions, roleMaps, roles);
for (int index = 1, size = cuserVOS.size(); index < size; index++) {
cuserVOS.get(index).setChildren(cuserVOS.get(0).getChildren());
}
}
});
}
}
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));
}
}
@ -540,22 +579,23 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
private void getChildren(AdminUserVO user, List<TBaseDepartment> departments, List<AdminUser> users
, List<TBasePosition> positions, List<AdminUserRoleMap> roleMaps, List<AdminRole> roles) {
TBaseDepartment department = departments.stream()
List<TBaseDepartment> cdepartments = departments.stream()
.filter(d -> Objects.equals(d.getDeptParentId(), user.getDepartmentId()))
.findFirst()
.orElse(null);
if (Objects.nonNull(department)) {
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(cdepartments)) {
cdepartments.forEach(department -> {
List<AdminUser> csers = users.stream()
.filter(u -> Objects.equals(u.getDepartmentId(), department.getId()))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(csers)) {
List<AdminUserVO> cuserVOS = convert(csers, department, positions, roleMaps, roles);
user.setChildren(cuserVOS);
user.getChildren().addAll(cuserVOS);
getChildren(cuserVOS.get(0), departments, users, positions, roleMaps, roles);
for (int index = 1, size = cuserVOS.size(); index < size; index++) {
cuserVOS.get(index).setChildren(cuserVOS.get(0).getChildren());
}
}
});
}
}
}

View File

@ -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());

View File

@ -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())
@ -578,7 +595,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
if (request.getEnable()) {
lambdaUpdate()
.set(AppUser::getState, UserState.Activated.getState())
.set(AppUser::getUpdateBy, AdminUserUtil.getUserId())
.set(AppUser::getUpdateBy, AdminUserUtil.getUserName())
.set(AppUser::getUpdateTime, LocalDateTime.now())
.eq(AppUser::getIsDel, false)
.in(AppUser::getId, request.getIds())
@ -586,7 +603,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
} else {
lambdaUpdate()
.set(AppUser::getState, UserState.Disabled.getState())
.set(AppUser::getUpdateBy, AdminUserUtil.getUserId())
.set(AppUser::getUpdateBy, AdminUserUtil.getUserName())
.set(AppUser::getUpdateTime, LocalDateTime.now())
.eq(AppUser::getIsDel, false)
.in(AppUser::getId, request.getIds())
@ -600,7 +617,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
if (CollectionUtil.isNotEmpty(companyIds)) {
lambdaUpdate()
.set(AppUser::getState, UserState.Disabled.getState())
.set(AppUser::getUpdateBy, AdminUserUtil.getUserId())
.set(AppUser::getUpdateBy, AdminUserUtil.getUserName())
.set(AppUser::getUpdateTime, LocalDateTime.now())
.eq(AppUser::getIsDel, false)
.eq(AppUser::getIsPrimary, false)
@ -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());
}
}

View File

@ -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());
}
}

View File

@ -123,12 +123,14 @@
,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
,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}, '%')

View File

@ -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>