update
This commit is contained in:
parent
fc390095a4
commit
b77ca6025e
|
@ -27,9 +27,9 @@ public class Generator {
|
|||
|
||||
public static void main(String[] args) {
|
||||
//表名
|
||||
String tableName = "t_work_flow_notice";
|
||||
String tableName = "t_lc_leave";
|
||||
//表前缀
|
||||
String tablePrefix = "t_";
|
||||
String tablePrefix = "t_lc_";
|
||||
//作者—
|
||||
String author = "zhouyuan";
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class Generator {
|
|||
|
||||
//包配置
|
||||
PackageConfig pc = new PackageConfig();
|
||||
pc.setParent("com.ydool.oa.workFlow");
|
||||
pc.setParent("com.ydool.staff");
|
||||
pc.setEntity("entity");
|
||||
pc.setServiceImpl("service");
|
||||
pc.setMapper("mapper");
|
||||
|
|
|
@ -76,7 +76,7 @@ public class FumigationWorkFlowService implements IWorkFlowType {
|
|||
|
||||
// 1.流程step+1
|
||||
workFlow.setStep(workFlow.getStep() + 1);
|
||||
workFlow.setStepType(WorkFlowStepTypeEnum.APPROVAL.getType());
|
||||
workFlow.setStepType(WorkFlowStepTypeEnum.WRITE.getType());
|
||||
workFlow.setStatus(WorkFlowStatusEnum.ACTIVE.getStatus());
|
||||
boolean flag = workFlowService.updateById(workFlow);
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class FumigationWorkFlowService implements IWorkFlowType {
|
|||
// 3.添加下一步流程环节
|
||||
List<WorkFlowStep> nextWorkFlowStepList = new ArrayList<WorkFlowStep>();
|
||||
for (User nextUser : nextUserList) {
|
||||
WorkFlowStep nextWorkFlowStep = new WorkFlowStep(workFlow, WorkFlowStepTypeEnum.APPROVAL.getType(),
|
||||
WorkFlowStep nextWorkFlowStep = new WorkFlowStep(workFlow, WorkFlowStepTypeEnum.WRITE.getType(),
|
||||
nextUser.getId(), WorkFlowStepStatusEnum.NOT_START.getStatus(), "");
|
||||
nextWorkFlowStepList.add(nextWorkFlowStep);
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public class FumigationWorkFlowService implements IWorkFlowType {
|
|||
for (WorkFlowStep nextWorkFlowStep : nextWorkFlowStepList) {
|
||||
String title =
|
||||
user.getUserName() + "的" + WorkFlowTypeEnum.valueOf(workFlow.getType().toUpperCase()).getName() +
|
||||
"待您审批";
|
||||
"待您填写";
|
||||
WorkFlowNotice nextWorkFlowNotice = new WorkFlowNotice(title, workFlow, nextWorkFlowStep.getUserId());
|
||||
nextWorkFlowNoticeList.add(nextWorkFlowNotice);
|
||||
}
|
||||
|
@ -138,17 +138,23 @@ public class FumigationWorkFlowService implements IWorkFlowType {
|
|||
// 2.判断执行哪个方法
|
||||
switch (workFlow.getStep()) {
|
||||
case 2:
|
||||
// 2.1 熏蒸申报第二步 库点分管人(角色)审批
|
||||
// 2.1 熏蒸申报第二步 库点分管人(角色)填写
|
||||
return second(vo, workFlow, workFlowStep);
|
||||
case 3:
|
||||
// 2.2 熏蒸申报第三步 购销仓储部负责人审批
|
||||
// 2.2 熏蒸申报第三步 库点分管人(角色)审批
|
||||
return third(vo, workFlow, workFlowStep);
|
||||
case 4:
|
||||
// 2.3 熏蒸申报第四步 沈总审批
|
||||
// 2.3 熏蒸申报第四步 库点负责人(角色)审批
|
||||
return fourth(vo, workFlow, workFlowStep);
|
||||
case 5:
|
||||
// 2.3 熏蒸申报第五步 粮食与物资管理科(角色)审批
|
||||
// 2.4 熏蒸申报第五步 购销仓储部负责人审批
|
||||
return fifth(vo, workFlow, workFlowStep);
|
||||
case 6:
|
||||
// 2.5 熏蒸申报第六步 沈总审批
|
||||
return sixth(vo, workFlow, workFlowStep);
|
||||
case 7:
|
||||
// 2.6 熏蒸申报第七步 粮食与物资管理科(角色)审批
|
||||
return seventh(vo, workFlow, workFlowStep);
|
||||
default:
|
||||
throw new ResultException("流程环节错误");
|
||||
}
|
||||
|
@ -156,6 +162,68 @@ public class FumigationWorkFlowService implements IWorkFlowType {
|
|||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult second(WorkFlowStepVo vo, WorkFlow workFlow, WorkFlowStep workFlowStep) {
|
||||
User user = userService.getById(workFlow.getUserId());
|
||||
// 1.流程环节进行变更
|
||||
workFlowStep.setStatus(WorkFlowStepStatusEnum.SUBMIT.getStatus());
|
||||
workFlowStep.setRemarks(vo.getRemarks());
|
||||
boolean flag = workFlowStepService.updateById(workFlowStep);
|
||||
|
||||
// 2.记录流程环节日志
|
||||
WorkFlowStepLog workFlowStepLog = new WorkFlowStepLog(workFlowStep, workFlow.getData());
|
||||
flag = workFlowStepLogService.save(workFlowStepLog);
|
||||
|
||||
// 3.流程step+1 进入下一步
|
||||
workFlow.setStep(workFlow.getStep() + 1);
|
||||
workFlow.setStepType(WorkFlowStepTypeEnum.APPROVAL.getType());
|
||||
workFlow.setStatus(WorkFlowStatusEnum.ACTIVE.getStatus());
|
||||
workFlow.setData(vo.getData());
|
||||
flag = workFlowService.updateById(workFlow);
|
||||
|
||||
// 4.找到库点分管人账号
|
||||
Role role = roleService.getOne(new QueryWrapper<Role>().lambda()
|
||||
.eq(Role::getName, "库点分管人")
|
||||
.last("limit 1")
|
||||
);
|
||||
if (ObjUtil.isEmpty(role)) {
|
||||
throw new ResultException("未找到库点分管人角色");
|
||||
}
|
||||
List<User> nextUserList = userService.list(new QueryWrapper<User>().lambda()
|
||||
.eq(User::getDept, user.getDept())
|
||||
.like(User::getRoles, role.getId())
|
||||
);
|
||||
if (CollUtil.isEmpty(nextUserList)) {
|
||||
throw new ResultException("未找到库点分管人");
|
||||
}
|
||||
// 5.添加下一步流程环节
|
||||
List<WorkFlowStep> nextWorkFlowStepList = new ArrayList<WorkFlowStep>();
|
||||
nextUserList.forEach(businessDeptUser -> {
|
||||
WorkFlowStep nextWorkFlowStep = new WorkFlowStep(workFlow, WorkFlowStepTypeEnum.APPROVAL.getType(),
|
||||
businessDeptUser.getId(), WorkFlowStepStatusEnum.NOT_START.getStatus(), "");
|
||||
nextWorkFlowStepList.add(nextWorkFlowStep);
|
||||
});
|
||||
flag = workFlowStepService.saveBatch(nextWorkFlowStepList);
|
||||
|
||||
// 6.通知库点分管人账号
|
||||
String title =
|
||||
user.getUserName() + "的" + WorkFlowTypeEnum.valueOf(workFlow.getType().toUpperCase()).getName() +
|
||||
"待您审批";
|
||||
List<WorkFlowNotice> workFlowNoticeList = new ArrayList<WorkFlowNotice>();
|
||||
nextUserList.forEach(businessDeptUser -> {
|
||||
WorkFlowNotice workFlowNotice = new WorkFlowNotice(title, workFlow, businessDeptUser.getId());
|
||||
workFlowNoticeList.add(workFlowNotice);
|
||||
});
|
||||
flag = workFlowNoticeService.saveBatch(workFlowNoticeList);
|
||||
|
||||
if (flag) {
|
||||
return AjaxResult.ok().msg("审批成功");
|
||||
} else {
|
||||
throw new ResultException("审批失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult third(WorkFlowStepVo vo, WorkFlow workFlow, WorkFlowStep workFlowStep) {
|
||||
User user = userService.getById(workFlow.getUserId());
|
||||
// 1.流程环节进行变更
|
||||
workFlowStep.setStatus(WorkFlowStepStatusEnum.PASS.getStatus());
|
||||
workFlowStep.setRemarks(vo.getRemarks());
|
||||
|
@ -171,7 +239,66 @@ public class FumigationWorkFlowService implements IWorkFlowType {
|
|||
workFlow.setStatus(WorkFlowStatusEnum.ACTIVE.getStatus());
|
||||
flag = workFlowService.updateById(workFlow);
|
||||
|
||||
// 4.找到购销仓储部负责人
|
||||
// 4.找到库点负责人账号
|
||||
Role role = roleService.getOne(new QueryWrapper<Role>().lambda()
|
||||
.eq(Role::getName, "库点负责人")
|
||||
.last("limit 1")
|
||||
);
|
||||
if (ObjUtil.isNull(role)) {
|
||||
throw new ResultException("库点负责人角色不存在");
|
||||
}
|
||||
List<User> nextUserList = userService.list(new QueryWrapper<User>().lambda()
|
||||
.eq(User::getDept, user.getDept())
|
||||
.like(User::getRoles, role.getId())
|
||||
);
|
||||
if (CollUtil.isEmpty(nextUserList)) {
|
||||
throw new ResultException("库点负责人不存在");
|
||||
}
|
||||
// 5.添加下一步流程环节
|
||||
List<WorkFlowStep> nextWorkFlowStepList = new ArrayList<WorkFlowStep>();
|
||||
nextUserList.forEach(businessDeptUser -> {
|
||||
WorkFlowStep nextWorkFlowStep = new WorkFlowStep(workFlow, WorkFlowStepTypeEnum.APPROVAL.getType(),
|
||||
businessDeptUser.getId(), WorkFlowStepStatusEnum.NOT_START.getStatus(), "");
|
||||
nextWorkFlowStepList.add(nextWorkFlowStep);
|
||||
});
|
||||
flag = workFlowStepService.saveBatch(nextWorkFlowStepList);
|
||||
|
||||
// 6.通知库点负责人账号
|
||||
String title =
|
||||
user.getUserName() + "的" + WorkFlowTypeEnum.valueOf(workFlow.getType().toUpperCase()).getName() +
|
||||
"待您审批";
|
||||
List<WorkFlowNotice> workFlowNoticeList = new ArrayList<WorkFlowNotice>();
|
||||
nextUserList.forEach(businessDeptUser -> {
|
||||
WorkFlowNotice workFlowNotice = new WorkFlowNotice(title, workFlow, businessDeptUser.getId());
|
||||
workFlowNoticeList.add(workFlowNotice);
|
||||
});
|
||||
flag = workFlowNoticeService.saveBatch(workFlowNoticeList);
|
||||
if (flag) {
|
||||
return AjaxResult.ok().msg("审批成功");
|
||||
} else {
|
||||
throw new ResultException("审批失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult fourth(WorkFlowStepVo vo, WorkFlow workFlow, WorkFlowStep workFlowStep) {
|
||||
User user = userService.getById(workFlow.getUserId());
|
||||
// 1.流程环节进行变更
|
||||
workFlowStep.setStatus(WorkFlowStepStatusEnum.PASS.getStatus());
|
||||
workFlowStep.setRemarks(vo.getRemarks());
|
||||
boolean flag = workFlowStepService.updateById(workFlowStep);
|
||||
|
||||
// 2.记录流程环节日志
|
||||
WorkFlowStepLog workFlowStepLog = new WorkFlowStepLog(workFlowStep, workFlow.getData());
|
||||
flag = workFlowStepLogService.save(workFlowStepLog);
|
||||
|
||||
// 3.流程step+1 进入下一步
|
||||
workFlow.setStep(workFlow.getStep() + 1);
|
||||
workFlow.setStepType(WorkFlowStepTypeEnum.APPROVAL.getType());
|
||||
workFlow.setStatus(WorkFlowStatusEnum.ACTIVE.getStatus());
|
||||
flag = workFlowService.updateById(workFlow);
|
||||
|
||||
// 4.找到购销仓储部负责人账号
|
||||
Dept dept = deptService.getOne(new QueryWrapper<Dept>().lambda()
|
||||
.eq(Dept::getName, "购销仓储部")
|
||||
.last("limit 1")
|
||||
|
@ -193,8 +320,6 @@ public class FumigationWorkFlowService implements IWorkFlowType {
|
|||
if (CollUtil.isEmpty(nextUserList)) {
|
||||
throw new ResultException("购销仓储部负责人不存在");
|
||||
}
|
||||
|
||||
|
||||
// 5.添加下一步流程环节
|
||||
List<WorkFlowStep> nextWorkFlowStepList = new ArrayList<WorkFlowStep>();
|
||||
nextUserList.forEach(businessDeptUser -> {
|
||||
|
@ -204,8 +329,7 @@ public class FumigationWorkFlowService implements IWorkFlowType {
|
|||
});
|
||||
flag = workFlowStepService.saveBatch(nextWorkFlowStepList);
|
||||
|
||||
// 6.通知购销仓储部负责人
|
||||
User user = userService.getById(workFlow.getUserId());
|
||||
// 6.通知购销仓储部负责人账号
|
||||
String title =
|
||||
user.getUserName() + "的" + WorkFlowTypeEnum.valueOf(workFlow.getType().toUpperCase()).getName() +
|
||||
"待您审批";
|
||||
|
@ -215,7 +339,6 @@ public class FumigationWorkFlowService implements IWorkFlowType {
|
|||
workFlowNoticeList.add(workFlowNotice);
|
||||
});
|
||||
flag = workFlowNoticeService.saveBatch(workFlowNoticeList);
|
||||
|
||||
if (flag) {
|
||||
return AjaxResult.ok().msg("审批成功");
|
||||
} else {
|
||||
|
@ -224,7 +347,7 @@ public class FumigationWorkFlowService implements IWorkFlowType {
|
|||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult third(WorkFlowStepVo vo, WorkFlow workFlow, WorkFlowStep workFlowStep) {
|
||||
public AjaxResult fifth(WorkFlowStepVo vo, WorkFlow workFlow, WorkFlowStep workFlowStep) {
|
||||
// 1.流程环节进行变更
|
||||
workFlowStep.setStatus(WorkFlowStepStatusEnum.PASS.getStatus());
|
||||
workFlowStep.setRemarks(vo.getRemarks());
|
||||
|
@ -274,7 +397,7 @@ public class FumigationWorkFlowService implements IWorkFlowType {
|
|||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult fourth(WorkFlowStepVo vo, WorkFlow workFlow, WorkFlowStep workFlowStep) {
|
||||
public AjaxResult sixth(WorkFlowStepVo vo, WorkFlow workFlow, WorkFlowStep workFlowStep) {
|
||||
// 1.流程环节进行变更
|
||||
workFlowStep.setStatus(WorkFlowStepStatusEnum.PASS.getStatus());
|
||||
workFlowStep.setRemarks(vo.getRemarks());
|
||||
|
@ -333,7 +456,7 @@ public class FumigationWorkFlowService implements IWorkFlowType {
|
|||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult fifth(WorkFlowStepVo vo, WorkFlow workFlow, WorkFlowStep workFlowStep) {
|
||||
public AjaxResult seventh(WorkFlowStepVo vo, WorkFlow workFlow, WorkFlowStep workFlowStep) {
|
||||
// 1.流程环节进行变更
|
||||
workFlowStep.setStatus(WorkFlowStepStatusEnum.PASS.getStatus());
|
||||
workFlowStep.setRemarks(vo.getRemarks());
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.ydool.oa.workFlow.engine.service.impl;
|
|||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.ydool.common.data.dto.AjaxResult;
|
||||
|
@ -21,6 +23,8 @@ import com.ydool.oa.workFlow.service.WorkFlowNoticeService;
|
|||
import com.ydool.oa.workFlow.service.WorkFlowService;
|
||||
import com.ydool.oa.workFlow.service.WorkFlowStepLogService;
|
||||
import com.ydool.oa.workFlow.service.WorkFlowStepService;
|
||||
import com.ydool.staff.entity.Leave;
|
||||
import com.ydool.staff.service.LeaveService;
|
||||
import com.ydool.system.entity.Config;
|
||||
import com.ydool.system.entity.Role;
|
||||
import com.ydool.system.entity.User;
|
||||
|
@ -62,6 +66,9 @@ public class LeaveWorkFlowService implements IWorkFlowType {
|
|||
@Autowired
|
||||
private RoleServiceImpl roleService;
|
||||
|
||||
@Autowired
|
||||
private LeaveService leaveService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult first(WorkFlow workFlow) {
|
||||
|
@ -196,6 +203,47 @@ public class LeaveWorkFlowService implements IWorkFlowType {
|
|||
WorkFlowNotice workFlowNotice = new WorkFlowNotice(title, workFlow, workFlow.getUserId());
|
||||
flag = workFlowNoticeService.save(workFlowNotice);
|
||||
|
||||
// 7.插入请假记录
|
||||
Leave leave = new Leave();
|
||||
data = JSONUtil.parseObj(data).getStr("data");
|
||||
leave.setUserId(workFlow.getUserId());
|
||||
String name = JSONUtil.parseObj(data).getStr("name");
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
leave.setName(name);
|
||||
}
|
||||
String sex = JSONUtil.parseObj(data).getStr("sex");
|
||||
if (StrUtil.isNotBlank(sex)) {
|
||||
leave.setSex(sex);
|
||||
}
|
||||
String age = JSONUtil.parseObj(data).getStr("age");
|
||||
if (StrUtil.isNotBlank(age)) {
|
||||
leave.setAge(age);
|
||||
}
|
||||
String startDate = JSONUtil.parseObj(data).getStr("start_date");
|
||||
if (StrUtil.isNotBlank(startDate)) {
|
||||
leave.setStartDate(DateUtil.parse(startDate));
|
||||
}
|
||||
String endDate = JSONUtil.parseObj(data).getStr("end_date");
|
||||
if (StrUtil.isNotBlank(endDate)) {
|
||||
leave.setEndDate(DateUtil.parse(endDate));
|
||||
}
|
||||
String leaveDays = JSONUtil.parseObj(data).getStr("leave_days");
|
||||
if (StrUtil.isNotBlank(leaveDays)) {
|
||||
leave.setLeaveDays(leaveDays);
|
||||
}
|
||||
String reasonsForLeave = JSONUtil.parseObj(data).getStr("reasons_for_leave");
|
||||
if (StrUtil.isNotBlank(reasonsForLeave)) {
|
||||
leave.setReasonsForLeave(reasonsForLeave);
|
||||
}
|
||||
String timeOfTerminationOfLeave = JSONUtil.parseObj(data).getStr("time_of_termination_of_leave");
|
||||
if (StrUtil.isNotBlank(timeOfTerminationOfLeave)) {
|
||||
leave.setTimeOfTerminationOfLeave(DateUtil.parse(timeOfTerminationOfLeave));
|
||||
}
|
||||
String remarks = JSONUtil.parseObj(data).getStr("remarks");
|
||||
if (StrUtil.isNotBlank(remarks)) {
|
||||
leave.setRemarks(remarks);
|
||||
}
|
||||
flag = leaveService.save(leave);
|
||||
if (flag) {
|
||||
return AjaxResult.ok().msg("审批成功");
|
||||
} else {
|
||||
|
@ -283,7 +331,52 @@ public class LeaveWorkFlowService implements IWorkFlowType {
|
|||
WorkFlowNotice workFlowNotice = new WorkFlowNotice(title, workFlow, workFlow.getUserId());
|
||||
flag = workFlowNoticeService.save(workFlowNotice);
|
||||
|
||||
return flag ? AjaxResult.ok().msg("审批成功") : AjaxResult.fail("审批失败");
|
||||
// 7.插入请假记录
|
||||
String data = JSONUtil.parseObj(workFlow.getData()).getStr("data");
|
||||
Leave leave = new Leave();
|
||||
leave.setUserId(workFlow.getUserId());
|
||||
String name = JSONUtil.parseObj(data).getStr("name");
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
leave.setName(name);
|
||||
}
|
||||
String sex = JSONUtil.parseObj(data).getStr("sex");
|
||||
if (StrUtil.isNotBlank(sex)) {
|
||||
leave.setSex(sex);
|
||||
}
|
||||
String age = JSONUtil.parseObj(data).getStr("age");
|
||||
if (StrUtil.isNotBlank(age)) {
|
||||
leave.setAge(age);
|
||||
}
|
||||
String startDate = JSONUtil.parseObj(data).getStr("start_date");
|
||||
if (StrUtil.isNotBlank(startDate)) {
|
||||
leave.setStartDate(DateUtil.parse(startDate));
|
||||
}
|
||||
String endDate = JSONUtil.parseObj(data).getStr("end_date");
|
||||
if (StrUtil.isNotBlank(endDate)) {
|
||||
leave.setEndDate(DateUtil.parse(endDate));
|
||||
}
|
||||
String leaveDays = JSONUtil.parseObj(data).getStr("leave_days");
|
||||
if (StrUtil.isNotBlank(leaveDays)) {
|
||||
leave.setLeaveDays(leaveDays);
|
||||
}
|
||||
String reasonsForLeave = JSONUtil.parseObj(data).getStr("reasons_for_leave");
|
||||
if (StrUtil.isNotBlank(reasonsForLeave)) {
|
||||
leave.setReasonsForLeave(reasonsForLeave);
|
||||
}
|
||||
String timeOfTerminationOfLeave = JSONUtil.parseObj(data).getStr("time_of_termination_of_leave");
|
||||
if (StrUtil.isNotBlank(timeOfTerminationOfLeave)) {
|
||||
leave.setTimeOfTerminationOfLeave(DateUtil.parse(timeOfTerminationOfLeave));
|
||||
}
|
||||
String remarks = JSONUtil.parseObj(data).getStr("remarks");
|
||||
if (StrUtil.isNotBlank(remarks)) {
|
||||
leave.setRemarks(remarks);
|
||||
}
|
||||
flag = leaveService.save(leave);
|
||||
if (flag) {
|
||||
return AjaxResult.ok().msg("审批成功");
|
||||
} else {
|
||||
throw new ResultException("审批失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.ydool.staff.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import com.ydool.common.base.BaseController;
|
||||
import com.ydool.common.constant.UrlConstant;
|
||||
import com.ydool.common.data.dto.AjaxResult;
|
||||
import com.ydool.staff.dto.LeaveDto;
|
||||
import com.ydool.staff.dto.PersonnelStatementDto;
|
||||
import com.ydool.staff.request.ExcelLeaveRequest;
|
||||
import com.ydool.staff.service.LeaveService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(UrlConstant.API + "/leave")
|
||||
@Api(tags = "请假报表", value = "请假报表")
|
||||
@ApiSupport(order = 20)
|
||||
public class LeaveController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private LeaveService leaveService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "请假报表",response = LeaveDto.class)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "firstDate",value = "起始时间"),
|
||||
@ApiImplicitParam(name = "finalDate",value = "最终时间"),
|
||||
})
|
||||
public AjaxResult getLeaveReport(String firstDate, String finalDate) {
|
||||
return leaveService.getLeaveReport(firstDate, finalDate);
|
||||
}
|
||||
|
||||
@PostMapping("/export")
|
||||
@ApiOperation(value = "请假报表导出")
|
||||
public void export(@RequestBody ExcelLeaveRequest excelLeaveRequest, HttpServletResponse response) {
|
||||
leaveService.export(excelLeaveRequest, response);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.ydool.staff.dto;
|
||||
|
||||
import com.ydool.staff.entity.Leave;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class LeaveDto extends Leave {
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String userName;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.ydool.staff.entity;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ydool.common.base.BaseEntity;
|
||||
import java.util.Date;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
/**
|
||||
* <p>
|
||||
* 请假表
|
||||
* </p>
|
||||
*
|
||||
* @author zhouyuan
|
||||
* @since 2023-08-23
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_lc_leave")
|
||||
@ApiModel(value="Leave对象", description="请假表")
|
||||
public class Leave extends BaseEntity{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty(value = "姓名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "性别")
|
||||
private String sex;
|
||||
|
||||
@ApiModelProperty(value = "年龄")
|
||||
private String age;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date startDate;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date endDate;
|
||||
|
||||
@ApiModelProperty(value = "请假天数")
|
||||
private String leaveDays;
|
||||
|
||||
@ApiModelProperty(value = "请假事由")
|
||||
private String reasonsForLeave;
|
||||
|
||||
@ApiModelProperty(value = "销假时间")
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date timeOfTerminationOfLeave;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remarks;
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.ydool.staff.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentStyle;
|
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
||||
import com.alibaba.excel.annotation.write.style.HeadStyle;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@HeadRowHeight(20)
|
||||
@ColumnWidth(20)
|
||||
@HeadStyle(horizontalAlignment = HorizontalAlignment.CENTER)
|
||||
@ContentStyle(verticalAlignment = VerticalAlignment.CENTER)
|
||||
public class ExcelLeave {
|
||||
|
||||
@ExcelProperty(value = "用户昵称")
|
||||
private String userName;
|
||||
|
||||
@ExcelProperty(value = "姓名")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty(value = "性别")
|
||||
private String sex;
|
||||
|
||||
@ExcelProperty(value = "年龄")
|
||||
private String age;
|
||||
|
||||
@ExcelProperty(value = "开始时间")
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date startDate;
|
||||
|
||||
@ExcelProperty(value = "结束时间")
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date endDate;
|
||||
|
||||
@ExcelProperty(value = "请假天数")
|
||||
private String leaveDays;
|
||||
|
||||
@ExcelProperty(value = "请假事由")
|
||||
private String reasonsForLeave;
|
||||
|
||||
@ExcelProperty(value = "销假时间")
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date timeOfTerminationOfLeave;
|
||||
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remarks;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.ydool.staff.mapper;
|
||||
|
||||
import com.ydool.staff.entity.Leave;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 请假表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zhouyuan
|
||||
* @since 2023-08-23
|
||||
*/
|
||||
@Mapper
|
||||
public interface LeaveMapper extends MPJBaseMapper<Leave> {
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.ydool.staff.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ExcelLeaveRequest {
|
||||
|
||||
@ApiModelProperty(value = "导出参数")
|
||||
private String[] prams;
|
||||
|
||||
@ApiModelProperty(value = "起始时间")
|
||||
private String firstDate;
|
||||
|
||||
@ApiModelProperty(value = "最终时间")
|
||||
private String finalDate;
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package com.ydool.staff.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.ydool.common.base.BaseService;
|
||||
import com.ydool.common.data.dto.AjaxResult;
|
||||
import com.ydool.common.utils.EasyExcelAlibabaUtil;
|
||||
import com.ydool.staff.dto.LeaveDto;
|
||||
import com.ydool.staff.entity.Leave;
|
||||
import com.ydool.staff.excel.ExcelLeave;
|
||||
import com.ydool.staff.excel.ExcelPersonnelStatement;
|
||||
import com.ydool.staff.mapper.LeaveMapper;
|
||||
import com.ydool.staff.request.ExcelLeaveRequest;
|
||||
import com.ydool.system.entity.User;
|
||||
import com.ydool.system.service.impl.UserServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 请假表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author zhouyuan
|
||||
* @since 2023-08-23
|
||||
*/
|
||||
@Service
|
||||
public class LeaveService extends BaseService<LeaveMapper, Leave> {
|
||||
|
||||
@Autowired
|
||||
private UserServiceImpl userService;
|
||||
|
||||
public AjaxResult getLeaveReport(String firstDate, String finalDate) {
|
||||
QueryWrapper<Leave> leaveQueryWrapper = new QueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(firstDate) && StrUtil.isNotBlank(finalDate)) {
|
||||
leaveQueryWrapper.lambda().between(Leave::getStartDate, DateUtil.parse(firstDate), DateUtil.parse(finalDate)).or().between(Leave::getEndDate, DateUtil.parse(firstDate), DateUtil.parse(finalDate));
|
||||
} else if (StrUtil.isNotBlank(firstDate)) {
|
||||
leaveQueryWrapper.lambda().ge(Leave::getStartDate, DateUtil.parse(firstDate)).le(Leave::getEndDate, DateUtil.parse(firstDate));
|
||||
} else if (StrUtil.isNotBlank(finalDate)) {
|
||||
leaveQueryWrapper.lambda().ge(Leave::getStartDate, DateUtil.parse(finalDate)).le(Leave::getEndDate, DateUtil.parse(finalDate));
|
||||
}
|
||||
List<Leave> leaveList = list(leaveQueryWrapper);
|
||||
List<LeaveDto> leaveDtos = BeanUtil.copyToList(leaveList, LeaveDto.class);
|
||||
if (CollUtil.isNotEmpty(leaveDtos)) {
|
||||
leaveDtos.forEach(leaveDto -> {
|
||||
User user = userService.getById(leaveDto.getUserId());
|
||||
if (ObjUtil.isNotNull(user)) {
|
||||
leaveDto.setUserName(user.getUserName());
|
||||
}
|
||||
});
|
||||
}
|
||||
return AjaxResult.ok().data(leaveDtos);
|
||||
}
|
||||
|
||||
public void export(ExcelLeaveRequest excelLeaveRequest, HttpServletResponse response) {
|
||||
String firstDate = excelLeaveRequest.getFirstDate();
|
||||
String finalDate = excelLeaveRequest.getFinalDate();
|
||||
QueryWrapper<Leave> leaveQueryWrapper = new QueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(firstDate) && StrUtil.isNotBlank(finalDate)) {
|
||||
leaveQueryWrapper.lambda().between(Leave::getStartDate, DateUtil.parse(firstDate), DateUtil.parse(finalDate)).or().between(Leave::getEndDate, DateUtil.parse(firstDate), DateUtil.parse(finalDate));
|
||||
} else if (StrUtil.isNotBlank(firstDate)) {
|
||||
leaveQueryWrapper.lambda().ge(Leave::getStartDate, DateUtil.parse(firstDate)).le(Leave::getEndDate, DateUtil.parse(firstDate));
|
||||
} else if (StrUtil.isNotBlank(finalDate)) {
|
||||
leaveQueryWrapper.lambda().ge(Leave::getStartDate, DateUtil.parse(finalDate)).le(Leave::getEndDate, DateUtil.parse(finalDate));
|
||||
}
|
||||
List<Leave> leaveList = list(leaveQueryWrapper);
|
||||
List<LeaveDto> leaveDtos = BeanUtil.copyToList(leaveList, LeaveDto.class);
|
||||
if (CollUtil.isNotEmpty(leaveDtos)) {
|
||||
leaveDtos.forEach(leaveDto -> {
|
||||
User user = userService.getById(leaveDto.getUserId());
|
||||
if (ObjUtil.isNotNull(user)) {
|
||||
leaveDto.setUserName(user.getUserName());
|
||||
}
|
||||
});
|
||||
}
|
||||
List<ExcelLeave> excelLeaves = BeanUtil.copyToList(leaveDtos, ExcelLeave.class);
|
||||
String fileName = "请假表" + System.currentTimeMillis() + ".xlsx";
|
||||
Set<String> includeColumnFiledNames = new HashSet<>();
|
||||
for (String s : excelLeaveRequest.getPrams()) {
|
||||
includeColumnFiledNames.add(s);
|
||||
}
|
||||
EasyExcelAlibabaUtil.exportDownload(response, ExcelPersonnelStatement.class, excelLeaves, fileName, includeColumnFiledNames);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue