分组和人员
This commit is contained in:
parent
d0629e4f00
commit
05f2954807
|
|
@ -0,0 +1,99 @@
|
||||||
|
package com.bonus.message.controller;
|
||||||
|
|
||||||
|
import com.bonus.common.core.controller.BaseController;
|
||||||
|
import com.bonus.common.core.domain.AjaxResult;
|
||||||
|
import com.bonus.common.core.page.TableDataInfo;
|
||||||
|
import com.bonus.message.dao.GroupVo;
|
||||||
|
import com.bonus.message.dao.WorkerVo;
|
||||||
|
import com.bonus.message.service.GroupService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 马三炮
|
||||||
|
* @date 2026/1/24
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/worker")
|
||||||
|
public class GroupController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GroupService groupService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分组管理列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/getGroupList")
|
||||||
|
public TableDataInfo getGroupList(GroupVo groupVo) {
|
||||||
|
try {
|
||||||
|
startPage();
|
||||||
|
List<GroupVo> list = groupService.getGroupList(groupVo);
|
||||||
|
return getDataTable(list);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return getDataTable(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增分组
|
||||||
|
*/
|
||||||
|
@PostMapping("/addGroup")
|
||||||
|
public AjaxResult addGroup(@RequestBody GroupVo groupVo) {
|
||||||
|
try {
|
||||||
|
int res = groupService.addGroup(groupVo);
|
||||||
|
if (res ==1) {
|
||||||
|
return AjaxResult.success();
|
||||||
|
} else if (res ==2) {
|
||||||
|
return AjaxResult.error("分组已存在");
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error("新增失败");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return AjaxResult.error("系统异常,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除分组
|
||||||
|
*/
|
||||||
|
@PostMapping("/delGroup")
|
||||||
|
public AjaxResult delGroup(@RequestBody GroupVo groupVo) {
|
||||||
|
try {
|
||||||
|
int res = groupService.delGroup(groupVo);
|
||||||
|
if (res > 0) {
|
||||||
|
return AjaxResult.success();
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error("删除失败");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return AjaxResult.error("系统异常,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改分组
|
||||||
|
*/
|
||||||
|
@PostMapping("/updateGroup")
|
||||||
|
public AjaxResult updateGroup(@RequestBody GroupVo groupVo) {
|
||||||
|
try {
|
||||||
|
int res = groupService.updateGroup(groupVo);
|
||||||
|
if (res ==1) {
|
||||||
|
return AjaxResult.success();
|
||||||
|
} else if (res ==2) {
|
||||||
|
return AjaxResult.error("组名已存在");
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error("修改失败");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return AjaxResult.error("系统异常,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,180 @@
|
||||||
|
package com.bonus.message.controller;
|
||||||
|
|
||||||
|
import com.bonus.common.core.controller.BaseController;
|
||||||
|
import com.bonus.common.core.domain.AjaxResult;
|
||||||
|
import com.bonus.common.core.page.TableDataInfo;
|
||||||
|
import com.bonus.common.utils.poi.ExcelUtil;
|
||||||
|
import com.bonus.message.dao.WorkerVo;
|
||||||
|
import com.bonus.message.service.WorkerService;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.poi.util.IOUtils;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 马三炮
|
||||||
|
* @date 2026/1/24
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/worker")
|
||||||
|
public class WorkerController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private WorkerService workerService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取人员管理列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/getWorkerList")
|
||||||
|
public TableDataInfo getWorkerList(WorkerVo workerVo) {
|
||||||
|
try {
|
||||||
|
startPage();
|
||||||
|
List<WorkerVo> list = workerService.getWorkerList(workerVo);
|
||||||
|
return getDataTable(list);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return getDataTable(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增人员
|
||||||
|
*/
|
||||||
|
@PostMapping("/addWorker")
|
||||||
|
public AjaxResult addWorker(@RequestBody WorkerVo workerVo) {
|
||||||
|
try {
|
||||||
|
int res = workerService.addWorker(workerVo);
|
||||||
|
if (res ==1) {
|
||||||
|
return AjaxResult.success();
|
||||||
|
} else if (res ==2) {
|
||||||
|
return AjaxResult.error("手机号已存在");
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error("新增失败");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return AjaxResult.error("系统异常,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除人员
|
||||||
|
*/
|
||||||
|
@PostMapping("/delWorker")
|
||||||
|
public AjaxResult delWorker(@RequestBody WorkerVo workerVo) {
|
||||||
|
try {
|
||||||
|
int res = workerService.delWorker(workerVo);
|
||||||
|
if (res > 0) {
|
||||||
|
return AjaxResult.success();
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error("删除失败");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return AjaxResult.error("系统异常,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改人员
|
||||||
|
*/
|
||||||
|
@PostMapping("/updateWorker")
|
||||||
|
public AjaxResult updateWorker(@RequestBody WorkerVo workerVo) {
|
||||||
|
try {
|
||||||
|
int res = workerService.updateWorker(workerVo);
|
||||||
|
if (res ==1) {
|
||||||
|
return AjaxResult.success();
|
||||||
|
} else if (res ==2) {
|
||||||
|
return AjaxResult.error("手机号已存在");
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error("修改失败");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return AjaxResult.error("系统异常,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("人员模板下载")
|
||||||
|
@PostMapping("/downloadWorkerExcel")
|
||||||
|
public void downloadWorkerExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
InputStream inputStream = null;
|
||||||
|
ServletOutputStream servletOutputStream = null;
|
||||||
|
try {
|
||||||
|
String path = "download/" + "人员导入模板.xlsx";
|
||||||
|
inputStream = this.getClass().getClassLoader().getResourceAsStream(path);
|
||||||
|
response.setContentType("application/vnd.ms-excel");
|
||||||
|
response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||||
|
response.addHeader("charset", "utf-8");
|
||||||
|
response.addHeader("Pragma", "no-cache");
|
||||||
|
String encodeName = URLEncoder.encode("人员导入模板.xlsx", StandardCharsets.UTF_8.toString());
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\"; filename*=utf-8''" + encodeName);
|
||||||
|
servletOutputStream = response.getOutputStream();
|
||||||
|
IOUtils.copy(inputStream, servletOutputStream);
|
||||||
|
response.flushBuffer();
|
||||||
|
log.info("文件下载成功!!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (servletOutputStream != null) {
|
||||||
|
servletOutputStream.close();
|
||||||
|
}
|
||||||
|
if (inputStream != null) {
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入人员
|
||||||
|
*/
|
||||||
|
@PostMapping("/importWorker")
|
||||||
|
public AjaxResult importWorker(MultipartFile file) {
|
||||||
|
try {
|
||||||
|
ExcelUtil<WorkerVo> util = new ExcelUtil<WorkerVo>(WorkerVo.class);
|
||||||
|
List<WorkerVo> workerList = util.importExcel(file.getInputStream());
|
||||||
|
String message = workerService.importWorker(workerList);
|
||||||
|
if ("导入成功".equals(message)) {
|
||||||
|
return success(message);
|
||||||
|
}else {
|
||||||
|
return AjaxResult.error(message);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return AjaxResult.error("模板错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取人员管理列表不分页
|
||||||
|
*/
|
||||||
|
@GetMapping("/getWorkerSelect")
|
||||||
|
public TableDataInfo getWorkerSelect(WorkerVo workerVo) {
|
||||||
|
try {
|
||||||
|
List<WorkerVo> list = workerService.getWorkerList(workerVo);
|
||||||
|
return getDataTable(list);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
return getDataTable(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.bonus.message.dao;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 马三炮
|
||||||
|
* @date 2026/1/24
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class GroupVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作组名称
|
||||||
|
*/
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 分组人员信息
|
||||||
|
*/
|
||||||
|
private List<WorkerVo> workerList;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.bonus.message.dao;
|
||||||
|
|
||||||
|
import com.bonus.common.annotation.Excel;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 马三炮
|
||||||
|
* @date 2026/1/24
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WorkerVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
*/
|
||||||
|
@Excel(name = "姓名")
|
||||||
|
private String workerName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门Id
|
||||||
|
*/
|
||||||
|
private Integer orgId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门名称
|
||||||
|
*/
|
||||||
|
@Excel(name = "所属部门")
|
||||||
|
private String orgName;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 性别 男/女
|
||||||
|
*/
|
||||||
|
@Excel(name = "性别")
|
||||||
|
private String sex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电话
|
||||||
|
*/
|
||||||
|
@Excel(name = "电话")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关键字
|
||||||
|
*/
|
||||||
|
private String keyWord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分组
|
||||||
|
*/
|
||||||
|
private int groupId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.bonus.message.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import com.bonus.message.dao.GroupVo;
|
||||||
|
import com.bonus.message.dao.WorkerVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface GroupMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分组管理列表
|
||||||
|
*/
|
||||||
|
List<GroupVo> getGroupList(GroupVo groupVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取人员列表
|
||||||
|
* @param group
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<WorkerVo> getWorkerList(GroupVo group);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据分组名称查询
|
||||||
|
* @param groupVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
GroupVo getGroupByName(GroupVo groupVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增分组
|
||||||
|
*/
|
||||||
|
int addGroup(GroupVo groupVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除分组
|
||||||
|
*/
|
||||||
|
int delGroup(GroupVo groupVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增分组人员
|
||||||
|
* @param worker
|
||||||
|
*/
|
||||||
|
void addGroupDetails(WorkerVo worker);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改分组
|
||||||
|
*/
|
||||||
|
void updateGroup(GroupVo groupVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据分组删除人员
|
||||||
|
* @param groupVo
|
||||||
|
*/
|
||||||
|
void delGroupDetails(GroupVo groupVo);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.bonus.message.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import com.bonus.common.core.domain.entity.SysDept;
|
||||||
|
import com.bonus.message.dao.WorkerVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface WorkerMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取人员管理列表
|
||||||
|
*/
|
||||||
|
List<WorkerVo> getWorkerList(WorkerVo workerVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据手机号查询
|
||||||
|
* @param workerVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
WorkerVo getWorkerByPhone(WorkerVo workerVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增人员
|
||||||
|
*/
|
||||||
|
int addWorker(WorkerVo workerVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除人员
|
||||||
|
*/
|
||||||
|
int delWorker(WorkerVo workerVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改人员
|
||||||
|
*/
|
||||||
|
int updateWorker(WorkerVo workerVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部门信息
|
||||||
|
* @param workerVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SysDept getDeptById(WorkerVo workerVo);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.bonus.message.service;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.bonus.message.dao.GroupVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface GroupService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分组管理列表
|
||||||
|
*/
|
||||||
|
List<GroupVo> getGroupList(GroupVo groupVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增分组
|
||||||
|
*/
|
||||||
|
int addGroup(GroupVo groupVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除分组
|
||||||
|
*/
|
||||||
|
int delGroup(GroupVo groupVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改分组
|
||||||
|
*/
|
||||||
|
int updateGroup(GroupVo groupVo);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.bonus.message.service;
|
||||||
|
|
||||||
|
import com.bonus.message.dao.WorkerVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface WorkerService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取人员管理列表
|
||||||
|
*/
|
||||||
|
List<WorkerVo> getWorkerList(WorkerVo workerVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增人员
|
||||||
|
*/
|
||||||
|
int addWorker(WorkerVo workerVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除人员
|
||||||
|
*/
|
||||||
|
int delWorker(WorkerVo workerVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改人员
|
||||||
|
*/
|
||||||
|
int updateWorker(WorkerVo workerVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入人员
|
||||||
|
*/
|
||||||
|
String importWorker(List<WorkerVo> workerList);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
package com.bonus.message.service.impl;
|
||||||
|
|
||||||
|
import com.bonus.common.utils.StringUtils;
|
||||||
|
import com.bonus.message.dao.GroupVo;
|
||||||
|
import com.bonus.message.dao.WorkerVo;
|
||||||
|
import com.bonus.message.mapper.GroupMapper;
|
||||||
|
import com.bonus.message.service.GroupService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 马三炮
|
||||||
|
* @date 2026/1/24
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class GroupServiceImpl implements GroupService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GroupMapper groupMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分组管理列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<GroupVo> getGroupList(GroupVo groupVo) {
|
||||||
|
List<GroupVo> groupList = groupMapper.getGroupList(groupVo);
|
||||||
|
for (GroupVo group : groupList) {
|
||||||
|
List<WorkerVo> workerList = groupMapper.getWorkerList(group);
|
||||||
|
group.setWorkerList(workerList);
|
||||||
|
}
|
||||||
|
return groupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增分组
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public int addGroup(GroupVo groupVo) {
|
||||||
|
groupVo.setCreateTime(new Date());
|
||||||
|
if (StringUtils.isNotEmpty(groupVo.getGroupName())){
|
||||||
|
//判断该分组是否存在
|
||||||
|
GroupVo group = groupMapper.getGroupByName(groupVo);
|
||||||
|
if (group != null){
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
groupMapper.addGroup(groupVo);
|
||||||
|
List<WorkerVo> workerList = groupVo.getWorkerList();
|
||||||
|
for (WorkerVo worker : workerList) {
|
||||||
|
worker.setGroupId(groupVo.getId());
|
||||||
|
groupMapper.addGroupDetails(worker);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除分组
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int delGroup(GroupVo groupVo) {
|
||||||
|
return groupMapper.delGroup(groupVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改分组
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public int updateGroup(GroupVo groupVo) {
|
||||||
|
groupVo.setUpdateTime(new Date());
|
||||||
|
if (StringUtils.isNotEmpty(groupVo.getGroupName())){
|
||||||
|
//判断该分组是否存在
|
||||||
|
GroupVo group = groupMapper.getGroupByName(groupVo);
|
||||||
|
if (group != null && groupVo.getId()!= group.getId()){
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
groupMapper.updateGroup(groupVo);
|
||||||
|
groupMapper.delGroupDetails(groupVo);
|
||||||
|
List<WorkerVo> workerList = groupVo.getWorkerList();
|
||||||
|
for (WorkerVo worker : workerList) {
|
||||||
|
worker.setGroupId(groupVo.getId());
|
||||||
|
groupMapper.addGroupDetails(worker);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
package com.bonus.message.service.impl;
|
||||||
|
|
||||||
|
import com.bonus.common.core.domain.entity.SysDept;
|
||||||
|
import com.bonus.common.utils.AesUtil;
|
||||||
|
import com.bonus.common.utils.StringUtils;
|
||||||
|
import com.bonus.message.dao.WorkerVo;
|
||||||
|
import com.bonus.message.mapper.WorkerMapper;
|
||||||
|
import com.bonus.message.service.WorkerService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 马三炮
|
||||||
|
* @date 2026/1/24
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class WorkerServiceImpl implements WorkerService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private WorkerMapper workerMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取人员管理列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<WorkerVo> getWorkerList(WorkerVo workerVo) {
|
||||||
|
List<WorkerVo> workerList = workerMapper.getWorkerList(workerVo);
|
||||||
|
for (WorkerVo worker : workerList) {
|
||||||
|
workerVo.setPhone(AesUtil.encrypt(worker.getPhone()));
|
||||||
|
}
|
||||||
|
return workerList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增人员
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int addWorker(WorkerVo workerVo) {
|
||||||
|
workerVo.setCreateTime(new Date());
|
||||||
|
if (StringUtils.isNotEmpty(workerVo.getPhone())){
|
||||||
|
//判断该手机号是否存在
|
||||||
|
WorkerVo worker = workerMapper.getWorkerByPhone(workerVo);
|
||||||
|
if (worker != null){
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return workerMapper.addWorker(workerVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除人员
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int delWorker(WorkerVo workerVo) {
|
||||||
|
return workerMapper.delWorker(workerVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改人员
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateWorker(WorkerVo workerVo) {
|
||||||
|
workerVo.setUpdateTime(new Date());
|
||||||
|
if (StringUtils.isNotEmpty(workerVo.getPhone())){
|
||||||
|
//判断该手机号是否存在
|
||||||
|
WorkerVo worker = workerMapper.getWorkerByPhone(workerVo);
|
||||||
|
if (worker != null && workerVo.getId() != worker.getId()){
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return workerMapper.updateWorker(workerVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入人员
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public String importWorker(List<WorkerVo> workerList) {
|
||||||
|
|
||||||
|
for (WorkerVo workerVo : workerList) {
|
||||||
|
//对必填项进行校验
|
||||||
|
if(StringUtils.isEmpty(workerVo.getPhone())
|
||||||
|
|| StringUtils.isEmpty(workerVo.getOrgName())
|
||||||
|
|| StringUtils.isEmpty(workerVo.getWorkerName())
|
||||||
|
|| StringUtils.isEmpty(workerVo.getSex())
|
||||||
|
){
|
||||||
|
return "缺少必填项";
|
||||||
|
}
|
||||||
|
|
||||||
|
SysDept sysDept = workerMapper.getDeptById(workerVo);
|
||||||
|
workerVo.setOrgId(sysDept.getDeptId().intValue());
|
||||||
|
addWorker(workerVo);
|
||||||
|
}
|
||||||
|
return "导入成功";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bonus.message.mapper.GroupMapper">
|
||||||
|
<insert id="addGroup" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into pm_group (group_name,remark,create_time)
|
||||||
|
values (#{groupName},#{remark},#{createTime})
|
||||||
|
</insert>
|
||||||
|
<insert id="addGroupDetails">
|
||||||
|
insert into bm_group_details (group_id,worker_id)
|
||||||
|
values (#{groupId},#{id})
|
||||||
|
</insert>
|
||||||
|
<update id="updateGroup">
|
||||||
|
update pm_group
|
||||||
|
<trim prefix="set" suffixOverrides=",">
|
||||||
|
|
||||||
|
<if test="groupName!= null " >
|
||||||
|
group_name=#{groupName},
|
||||||
|
</if>
|
||||||
|
<if test="remark!= null " >
|
||||||
|
remark=#{remark},
|
||||||
|
</if>
|
||||||
|
<if test="updateTime!= null " >
|
||||||
|
update_time=#{updateTime},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
<delete id="delGroup">
|
||||||
|
update pm_group set is_active= '0' where id = #{id}
|
||||||
|
</delete>
|
||||||
|
<delete id="delGroupDetails">
|
||||||
|
delete from bm_group_details where group_id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<select id="getGroupList" resultType="com.bonus.message.dao.GroupVo">
|
||||||
|
select id,group_name,remark from pm_group where is_active= '1'
|
||||||
|
<if test="groupName!= null " >
|
||||||
|
and group_name like concat('%', #{groupName}, '%')
|
||||||
|
</if>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
<select id="getWorkerList" resultType="com.bonus.message.dao.WorkerVo">
|
||||||
|
select pw.id,pw.worker_name,pw.org_id,pw.sex,pw.phone
|
||||||
|
from pm_worker pw
|
||||||
|
left join bm_group_details bgd on pw.id = bgd.worker_id
|
||||||
|
left join pm_group pg on bgd.group_id = pg.id
|
||||||
|
where pg.id = #{id}
|
||||||
|
</select>
|
||||||
|
<select id="getGroupByName" resultType="com.bonus.message.dao.GroupVo">
|
||||||
|
select id,group_name,remark from pm_group where group_name = #{groupName}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bonus.message.mapper.WorkerMapper">
|
||||||
|
<insert id="addWorker">
|
||||||
|
insert into pm_worker (worker_name,org_id,sex,phone,create_time)
|
||||||
|
values (#{workerName},#{orgId},#{sex},#{phone},#{createTime})
|
||||||
|
</insert>
|
||||||
|
<update id="updateWorker">
|
||||||
|
update pm_worker
|
||||||
|
<trim prefix="set" suffixOverrides=",">
|
||||||
|
|
||||||
|
<if test="workerName!= null " >
|
||||||
|
worker_name=#{workerName},
|
||||||
|
</if>
|
||||||
|
<if test="orgId!= null " >
|
||||||
|
org_id=#{orgId},
|
||||||
|
</if>
|
||||||
|
<if test="sex!= null " >
|
||||||
|
sex=#{sex},
|
||||||
|
</if>
|
||||||
|
<if test="phone!= null " >
|
||||||
|
phone=#{phone},
|
||||||
|
</if>
|
||||||
|
<if test="updateTime!= null " >
|
||||||
|
update_time=#{updateTime},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
<delete id="delWorker">
|
||||||
|
update pm_worker set is_active ='0' where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<select id="getWorkerList" resultType="com.bonus.message.dao.WorkerVo">
|
||||||
|
select pw.id,pw.worker_name,pw.org_id,pw.sex,pw.phone, sd.dept_name as orgName
|
||||||
|
from pm_worker pw
|
||||||
|
left join sys_dept sd on pw.org_id = sd.dept_id
|
||||||
|
where is_active = '1'
|
||||||
|
<if test="orgId!= null " >
|
||||||
|
and pw.org_id=#{orgId}
|
||||||
|
</if>
|
||||||
|
<if test="workerName!= null " >
|
||||||
|
and pw.worker_name like concat('%', #{workerName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="sex!= null " >
|
||||||
|
and pw.sex=#{sex}
|
||||||
|
</if>
|
||||||
|
<if test="keyWord!= null " >
|
||||||
|
AND (pw.worker_name like concat('%', #{keyWord}, '%')
|
||||||
|
or sd.dept_name like concat('%', #{keyWord}, '%'))
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
<select id="getWorkerByPhone" resultType="com.bonus.message.dao.WorkerVo">
|
||||||
|
select id,worker_name,org_id,sex,phone from pm_worker where phone = #{phone}
|
||||||
|
</select>
|
||||||
|
<select id="getDeptById" resultType="com.bonus.common.core.domain.entity.SysDept">
|
||||||
|
select dept_id,dept_name from sys_dept where dept_name = #{orgName}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue