Commit f2dfe881 authored by ZhangRunSong's avatar ZhangRunSong
parents ca0925f2 12af672d
......@@ -45,7 +45,18 @@ public class FyglDailyReimbursementController extends BaseController
return getDataTable(list);
}
//获取所有项目名字和id
//根据当前用户角色id,查询所有项目关联的项目-最新
@GetMapping("/getProjectListByUserId")
public AjaxResult getProjectListByUserId()
{
List<FyglDailyReimbursementDTO> projectList = fyglDailyReimbursementService.getProjectListByUserId();
return AjaxResult.success(projectList);
}
//获取所有项目名字和id,用于搜索
@GetMapping("/projectList")
@Anonymous
public AjaxResult projectList()
......
......@@ -2,16 +2,12 @@ package com.ruoyi.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.domain.dto.EmployeeBalanceDTO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
......@@ -33,6 +29,8 @@ public class LeaveApplicationController extends BaseController
{
@Autowired
private ILeaveApplicationService leaveApplicationService;
@Autowired
private SpringUtils springUtils;
/**
* 查询请假申请列表
......@@ -101,4 +99,43 @@ public class LeaveApplicationController extends BaseController
{
return toAjax(leaveApplicationService.deleteLeaveApplicationByIds(ids));
}
/**
* 根据用户ID查询可抵扣的加班时长
* @param userId
* @return
*/
@GetMapping("/deductionOvertimeHours")
public EmployeeBalanceDTO selectDeductionOvertimeHoursByUserId(@RequestParam Long userId) {
return leaveApplicationService.selectDeductionOvertimeHoursByUserId(userId);
}
/**
* 更新员工的加班小时数余额
* @param dto 包含加班小时数余额和员工ID的DTO对象
* @return 更新结果
*/
@Log(title = "请假申请", businessType = BusinessType.UPDATE)
@PutMapping("/updateOvertimeHoursBalance")
public AjaxResult updateOvertimeHoursBalance(@RequestBody EmployeeBalanceDTO dto) {
System.out.println("前端接受的加班小时数余额信息:"+dto);
return toAjax(leaveApplicationService.updateOvertimeHoursBalance(dto));
}
@GetMapping("/project-managers")
public List<String> getProjectManagers() {
return leaveApplicationService.selectProjectManagers();
}
/**
* 获取总经理的nick_name
*/
@GetMapping("/general-manager")
public AjaxResult getGeneralManagerNickName() {
String generalManagerNickName = leaveApplicationService.selectGeneralManagerNickName();
return AjaxResult.success(generalManagerNickName);
}
}
package com.ruoyi.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 员工余额对象 employee_balance
*
* @author hht
* @date 2025-03-06
*/
public class EmployeeBalance extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 唯一标识每条记录
*/
private Long id;
/**
* 员工ID(关联到员工表)
*/
private Long employeeId;
/**
* 年假余额
*/
private BigDecimal annualLeaveBalance;
/**
* 加班时长余额
*/
private BigDecimal overtimeHoursBalance;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createdAt;
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updatedAt;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getEmployeeId() {
return employeeId;
}
public void setEmployeeId(Long employeeId) {
this.employeeId = employeeId;
}
public BigDecimal getAnnualLeaveBalance() {
return annualLeaveBalance;
}
public void setAnnualLeaveBalance(BigDecimal annualLeaveBalance) {
this.annualLeaveBalance = annualLeaveBalance;
}
public BigDecimal getOvertimeHoursBalance() {
return overtimeHoursBalance;
}
public void setOvertimeHoursBalance(BigDecimal overtimeHoursBalance) {
this.overtimeHoursBalance = overtimeHoursBalance;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("employeeId", getEmployeeId())
.append("annualLeaveBalance", getAnnualLeaveBalance())
.append("overtimeHoursBalance", getOvertimeHoursBalance())
.append("createdAt", getCreatedAt())
.append("updatedAt", getUpdatedAt())
.toString();
}
}
......@@ -29,6 +29,14 @@ public class LeaveApplication extends BaseEntity {
@Excel(name = "请假单号")
private String leaveId;
/**
* 用户ID
*/
private Long userId;
/**
* 申请日期
*/
......@@ -73,14 +81,18 @@ public class LeaveApplication extends BaseEntity {
@Excel(name = "请假结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm")
private Date endTime;
/**
* 请假时长
*/
@Excel(name = "请假时长")
private BigDecimal leavetimeHours;
/**
* 扣减加班时长
*/
@Excel(name = "抵扣加班时长")
private BigDecimal deductionOvertimeHours;
/**
* 请假天数
*/
......@@ -90,7 +102,6 @@ public class LeaveApplication extends BaseEntity {
/**
* 合计请假天数
*/
@Excel(name = "合计请假天数")
private BigDecimal totalLeaveDays;
/**
......@@ -106,18 +117,10 @@ public class LeaveApplication extends BaseEntity {
private String proof;
/**
* 审批状态
* 审批状态(0代表待审批,1代表审批中,2代表已通过,3代表已驳回)
*/
@Excel(name = "审批状态")
private String status;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Excel(name = "审批状态", readConverterExp = "0=待审批,1=审批中,2=已通过,3=不通过")
private String approvalStatus;
/**
* 创建时间
......@@ -149,6 +152,10 @@ public class LeaveApplication extends BaseEntity {
return leaveId;
}
public Long getUserId() {return userId;}
public void setUserId(Long userId) {this.userId = userId;}
public void setRequestDate(Date requestDate) {
this.requestDate = requestDate;
}
......@@ -199,6 +206,10 @@ public class LeaveApplication extends BaseEntity {
return leavetimeHours;
}
public BigDecimal getDeductionOvertimeHours() {return deductionOvertimeHours;}
public void setDeductionOvertimeHours(BigDecimal deductionOvertimeHours) {this.deductionOvertimeHours = deductionOvertimeHours;}
public void setLeaveDaysSubtotal(BigDecimal leaveDaysSubtotal) {
this.leaveDaysSubtotal = leaveDaysSubtotal;
}
......@@ -239,6 +250,10 @@ public class LeaveApplication extends BaseEntity {
public void setFirstApprover(String firstApprover) {this.firstApprover = firstApprover;}
public String getApprovalStatus() {return approvalStatus;}
public void setApprovalStatus(String approvalStatus) {this.approvalStatus = approvalStatus;}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
......@@ -261,17 +276,19 @@ public class LeaveApplication extends BaseEntity {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("leaveId", getLeaveId())
.append("userId", getUserId())
.append("requestDate", getRequestDate())
.append("leaveType", getLeaveType())
.append("uname", getUname())
.append("startTime", getStartTime())
.append("endTime", getEndTime())
.append("leavetimeHours", getLeavetimeHours())
.append("deductionOvertimeHours", getDeductionOvertimeHours())
.append("leaveDaysSubtotal", getLeaveDaysSubtotal())
.append("totalLeaveDays", getTotalLeaveDays())
.append("reason", getReason())
.append("proof", getProof())
.append("status", getStatus())
.append("approvalStatus", getApprovalStatus())
.append("createdTime", getCreatedTime())
.append("updatedTime", getUpdatedTime())
.append("firstApprover",getFirstApprover())
......
......@@ -23,6 +23,13 @@ public class OvertimeApplication extends BaseEntity {
*/
private Long id;
/**
* 员工ID
*/
private Long employeeId;
/**
* 加班单号
*/
......@@ -58,9 +65,9 @@ public class OvertimeApplication extends BaseEntity {
/**
* 加班总天数
* 个人加班总时长
*/
private BigDecimal totalOvertimeDays;
private BigDecimal totalOvertimeHours;
......@@ -99,6 +106,9 @@ public class OvertimeApplication extends BaseEntity {
public Long getId() {
return id;
}
public Long getEmployeeId() {return employeeId;}
public void setEmployeeId(Long employeeId) {this.employeeId = employeeId;}
public void setOvertimeId(String overtimeId) {
this.overtimeId = overtimeId;
......@@ -142,15 +152,9 @@ public class OvertimeApplication extends BaseEntity {
return overtimeHours;
}
public BigDecimal getTotalOvertimeHours() {return totalOvertimeHours;}
public void setTotalOvertimeDays(BigDecimal totalOvertimeDays) {
this.totalOvertimeDays = totalOvertimeDays;
}
public BigDecimal getTotalOvertimeDays() {
return totalOvertimeDays;
}
public void setTotalOvertimeHours(BigDecimal totalOvertimeHours) {this.totalOvertimeHours = totalOvertimeHours;}
public String getDivisionLeader() {return divisionLeader;}
......@@ -184,12 +188,13 @@ public class OvertimeApplication extends BaseEntity {
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("employeeId", getEmployeeId())
.append("overtimeId", getOvertimeId())
.append("uname", getUname())
.append("requestDate", getRequestDate())
.append("yearMonth", getYearMonth())
.append("overtimeHours", getOvertimeHours())
.append("totalOvertimeDays", getTotalOvertimeDays())
.append("totalOvertimeHours", getTotalOvertimeHours())
.append("project", getProject())
.append("projectLeader", getProjectLeader())
.append("divisionLeader", getDivisionLeader())
......
package com.ruoyi.domain.dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class EmployeeBalanceDTO {
private BigDecimal overtimeHoursBalance;
private BigDecimal annualLeaveBalance;
private Long employeeId;
}
......@@ -8,6 +8,7 @@ import java.util.List;
@Data
public class FyglDailyReimbursementDTO {
private Long id;
private Integer projectId;
private String projectName;
//项目负责人
private String projectUserName;
......
......@@ -16,6 +16,7 @@ public class OvertimeApplicationBatchDTO {
private String project;
private String divisionLeader;
private String projectLeader;
// 员工的加班列表
private List<OvertimeDetail> employees;
......
......@@ -29,6 +29,9 @@ public class FyglDailyReimbursementVo extends BaseEntity {
//附件
private String accessory;
//项目id
private Integer projectId;
//删除标志 0未删除1已删除
private Integer delFlag;
......
......@@ -21,4 +21,6 @@ public class ProjectEmployeeInfoVo {
private String employeeName;
}
package com.ruoyi.mapper;
import com.ruoyi.domain.EmployeeBalance;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
public interface EmployeeBalanceMapper {
/**
* 检查员工是否已有加班记录
*/
EmployeeBalance selectEmployeeBalanceByEmployeeId(@Param("employeeId") Long employeeId);
/**
* 插入员工余额记录
*/
int insertEmployeeBalance(EmployeeBalance employeeBalance);
/**
* 更新员工余额记录
*/
int updateEmployeeBalance(@Param("employeeId") Long employeeId, @Param("overtimeHoursBalance") BigDecimal overtimeHoursBalance);
}
......@@ -28,6 +28,8 @@ public interface FyglDailyReimbursementMapper
//根据rid删除所有数据
int delDataByRid(Long rid);
List<FyglDailyReimbursementDTO> getProjectListByUserId(Long userId);
public List<FyglDailyReimbursementDetailitemListDTO> selectFyglDailyReimbursementItemListById(@Param("rid") Long rid);
// 查找日常报销每个项目的所有报销
public List<FyglDailyReimbursementTableItemDTO> getItemList(FyglDailyReimbursementVo fyglDailyReimbursementVO);
......
......@@ -2,6 +2,9 @@ package com.ruoyi.mapper;
import java.util.List;
import com.ruoyi.domain.LeaveApplication;
import com.ruoyi.domain.dto.EmployeeBalanceDTO;
import io.lettuce.core.dynamic.annotation.Param;
import java.util.Map;
/**
* 请假申请Mapper接口
......@@ -58,4 +61,33 @@ public interface LeaveApplicationMapper
* @return 结果
*/
public int deleteLeaveApplicationByIds(Long[] ids);
/**
* 根据用户id查询请假总时长
* @param userId
* @return
*/
EmployeeBalanceDTO selectDeductionOvertimeHoursByUserId(@Param("userId") Long userId);
/**
* 更新员工的加班总时长
* @param dto 包含overtimeHoursBalance和employeeId的对象
* @return 更新结果
*/
int updateOvertimeHoursBalance(EmployeeBalanceDTO dto);
/**
* 查询项目经理
* @return
*/
List<String> selectProjectManagers();
/**
* 获取总经理的nick_name
* @return 总经理的nick_name
*/
String selectGeneralManagerNickName();
}
......@@ -60,6 +60,9 @@ public interface OvertimeApplicationMapper
*/
public int deleteOvertimeApplicationByIds(Long[] ids);
//批量添加加班申请
//批量添加加班申请
public int insertOvertimeApplicationBatch(OvertimeApplicationBatchDTO batchRequest);
//根据用户昵称获取用户id
public Long getUserIdByNickName(String nickName);
}
......@@ -64,4 +64,6 @@ public interface IFyglDailyReimbursementService
* @return 结果
*/
public int deleteFyglDailyReimbursementById(Long id);
List<FyglDailyReimbursementDTO> getProjectListByUserId();
}
package com.ruoyi.service;
import java.util.List;
import java.util.Map;
import com.ruoyi.domain.LeaveApplication;
import com.ruoyi.domain.dto.EmployeeBalanceDTO;
import io.lettuce.core.dynamic.annotation.Param;
/**
* 请假申请Service接口
......@@ -58,4 +62,17 @@ public interface ILeaveApplicationService
* @return 结果
*/
public int deleteLeaveApplicationById(Long id);
//根据用户id查询该用户已扣除的加班小时数
EmployeeBalanceDTO selectDeductionOvertimeHoursByUserId(@Param("userId") Long userId);
//更新用户加班总时长
int updateOvertimeHoursBalance(EmployeeBalanceDTO dto);
//查询项目经理列表
List<String> selectProjectManagers();
//查询总经理
String selectGeneralManagerNickName();
}
package com.ruoyi.service;
import java.math.BigDecimal;
import java.util.List;
import com.ruoyi.domain.OvertimeApplication;
import com.ruoyi.domain.dto.OvertimeApplicationBatchDTO;
import io.lettuce.core.dynamic.annotation.Param;
/**
* 加班申请Service接口
......@@ -28,6 +30,13 @@ public interface IOvertimeApplicationService
*/
public List<OvertimeApplication> selectOvertimeApplicationList(OvertimeApplication overtimeApplication);
/**
* 根据昵称查询用户id
*
* @param nickName 用户昵称
* @return 用户id
*/
public Long getUserIdByNickName(String nickName);
/**
* 新增加班申请
*
......@@ -62,4 +71,6 @@ public interface IOvertimeApplicationService
//批量添加加班申请
public int insertOvertimeApplicationBatch(OvertimeApplicationBatchDTO batchRequest);
}
......@@ -105,7 +105,7 @@ public class FyglDailyReimbursementServiceImpl implements IFyglDailyReimbursemen
//先插入最外层表
int i1 = fyglDailyReimbursementMapper.insertFyglDailyReimbursement(fyglDailyReimbursement);
// int i1 = fyglDailyReimbursementMapper.insertFyglDailyReimbursement(fyglDailyReimbursement);
//第二层表
fyglDailyReimbursement.setStatus(2);
fyglDailyReimbursement.setRegistrationTime(DateUtils.getNowDate());
......@@ -119,7 +119,7 @@ public class FyglDailyReimbursementServiceImpl implements IFyglDailyReimbursemen
}
System.out.println("插入对象fyglDailyReimbursement = " + fyglDailyReimbursement);
return i1;
return i2;
}
@Override
......@@ -178,4 +178,22 @@ public class FyglDailyReimbursementServiceImpl implements IFyglDailyReimbursemen
{
return fyglDailyReimbursementMapper.deleteFyglDailyReimbursementById(id);
}
@Override
public List<FyglDailyReimbursementDTO> getProjectListByUserId() {
List<FyglDailyReimbursementDTO> projectListByUserId = fyglDailyReimbursementMapper.getProjectListByUserId(SecurityUtils.getUserId());
System.out.println("结果 = " + projectListByUserId);
for(FyglDailyReimbursementDTO item:projectListByUserId){
Integer passNumber = 0;
Integer notPassNumber = 0;
FyglDailyReimbursementVo fyglDailyReimbursementVo = new FyglDailyReimbursementVo();
fyglDailyReimbursementVo.setProjectId(item.getProjectId());
List<FyglDailyReimbursementTableItemDTO> itemList = fyglDailyReimbursementMapper.getItemList(fyglDailyReimbursementVo);
item.setTableItemList(itemList);
}
return projectListByUserId;
}
}
package com.ruoyi.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.math.BigDecimal;
import java.util.*;
import com.ruoyi.domain.dto.EmployeeBalanceDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.LeaveApplicationMapper;
......@@ -106,4 +106,40 @@ public class LeaveApplicationServiceImpl implements ILeaveApplicationService
{
return leaveApplicationMapper.deleteLeaveApplicationById(id);
}
/**
* 根据用户ID查询总的的加班小时数
* @param userId
* @return
*/
@Override
public EmployeeBalanceDTO selectDeductionOvertimeHoursByUserId(Long userId) {
return leaveApplicationMapper.selectDeductionOvertimeHoursByUserId(userId);
}
/**
* 更新员工的加班小时数余额
* @param dto 包含加班小时数余额和员工ID的DTO对象
* @return 更新结果
*/
@Override
public int updateOvertimeHoursBalance(EmployeeBalanceDTO dto) {
return leaveApplicationMapper.updateOvertimeHoursBalance(dto);
}
/**
* 查询项目经理列表
* @return
*/
@Override
public List<String> selectProjectManagers() {
return leaveApplicationMapper.selectProjectManagers();
}
@Override
public String selectGeneralManagerNickName(){
return leaveApplicationMapper.selectGeneralManagerNickName();
}
}
package com.ruoyi.service.impl;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import com.ruoyi.domain.EmployeeBalance;
import com.ruoyi.domain.dto.OvertimeApplicationBatchDTO;
import com.ruoyi.mapper.EmployeeBalanceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.OvertimeApplicationMapper;
......@@ -22,6 +25,9 @@ public class OvertimeApplicationServiceImpl implements IOvertimeApplicationServi
{
@Autowired
private OvertimeApplicationMapper overtimeApplicationMapper;
@Autowired
private EmployeeBalanceMapper employeeBalanceMapper;
/**
* 查询加班申请
......@@ -47,6 +53,11 @@ public class OvertimeApplicationServiceImpl implements IOvertimeApplicationServi
return overtimeApplicationMapper.selectOvertimeApplicationList(overtimeApplication);
}
@Override
public Long getUserIdByNickName(String nickName) {
return overtimeApplicationMapper.getUserIdByNickName(nickName);
}
/**
* 新增加班申请
*
......@@ -69,6 +80,38 @@ public class OvertimeApplicationServiceImpl implements IOvertimeApplicationServi
String randomNum = Integer.toHexString(random.nextInt(10000)).substring(0, 2);
return randomNum + timestamp;
}
// 插入员工余额
private void updateOrInsertEmployeeBalance(Long employeeId, BigDecimal overtimeHours) {
if (employeeId == null) {
throw new IllegalArgumentException("employeeId cannot be null");
}
EmployeeBalance employeeBalance = employeeBalanceMapper.selectEmployeeBalanceByEmployeeId(employeeId);
if (employeeBalance == null) {
// 如果没有记录,则插入新记录
EmployeeBalance newEmployeeBalance = new EmployeeBalance();
newEmployeeBalance.setEmployeeId(employeeId);
newEmployeeBalance.setOvertimeHoursBalance(overtimeHours);
employeeBalanceMapper.insertEmployeeBalance(newEmployeeBalance);
} else {
// 如果已有记录,则更新记录
employeeBalanceMapper.updateEmployeeBalance(employeeId, overtimeHours);
}
}
// 更新员工余额
private void updateEmployeeBalance(Long employeeId, BigDecimal difference) {
EmployeeBalance employeeBalance = employeeBalanceMapper.selectEmployeeBalanceByEmployeeId(employeeId);
if (employeeBalance == null) {
// 如果没有记录,则插入新记录
EmployeeBalance newEmployeeBalance = new EmployeeBalance();
newEmployeeBalance.setEmployeeId(employeeId);
newEmployeeBalance.setOvertimeHoursBalance(difference);
employeeBalanceMapper.insertEmployeeBalance(newEmployeeBalance);
} else {
// 如果已有记录,则更新记录
employeeBalanceMapper.updateEmployeeBalance(employeeId, difference);
}
}
......@@ -81,6 +124,24 @@ public class OvertimeApplicationServiceImpl implements IOvertimeApplicationServi
@Override
public int updateOvertimeApplication(OvertimeApplication overtimeApplication)
{
System.out.println("我是修改的加班申请数据"+ overtimeApplication );
// 获取原始加班申请记录
OvertimeApplication originalApplication = selectOvertimeApplicationById(overtimeApplication.getId());
System.out.println("我是原始的加班申请数据" + originalApplication );
if (originalApplication == null) {
throw new RuntimeException("加班申请记录不存在,ID: " + overtimeApplication.getId());
}
// 计算加班时长的变化
BigDecimal originalOvertimeHours = new BigDecimal(originalApplication.getOvertimeHours());
BigDecimal newOvertimeHours = new BigDecimal(overtimeApplication.getOvertimeHours());
BigDecimal difference = newOvertimeHours.subtract(originalOvertimeHours);
// 更新员工余额
updateEmployeeBalance(originalApplication.getEmployeeId(), difference);
// 更新加班申请记录
return overtimeApplicationMapper.updateOvertimeApplication(overtimeApplication);
}
......@@ -109,6 +170,12 @@ public class OvertimeApplicationServiceImpl implements IOvertimeApplicationServi
}
/**
* 批量新增加班申请
*
* @param batchRequest 加班申请
* @return 结果
*/
@Override
public int insertOvertimeApplicationBatch(OvertimeApplicationBatchDTO batchRequest)
{
......@@ -123,16 +190,22 @@ public class OvertimeApplicationServiceImpl implements IOvertimeApplicationServi
// 公共字段
entity.setProject(batchRequest.getProject());
entity.setDivisionLeader(batchRequest.getDivisionLeader());
entity.setProjectLeader(batchRequest.getProjectLeader());
// 单条记录字段
long userId = overtimeApplicationMapper.getUserIdByNickName(detail.getUname());
entity.setEmployeeId(userId);
entity.setUname(detail.getUname());
entity.setOvertimeHours(detail.getOvertimeHours());
entity.setRequestDate(detail.getRequestDate());
// 设置归属月份为上个月的月份
entity.setYearMonth(yearMonth);
// 生成加班单号
entity.setOvertimeId(generateLeaveId());
// 其他字段,如 createdTime, updatedTime 等
entity.setCreatedTime(new Date());
// 更新或插入员工余额
updateOrInsertEmployeeBalance(userId, new BigDecimal(detail.getOvertimeHours()));
list.add(entity);
}
......
<?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.ruoyi.mapper.EmployeeBalanceMapper">
<select id="selectEmployeeBalanceByEmployeeId" resultType="com.ruoyi.domain.EmployeeBalance">
SELECT id, employee_id, annual_leave_balance, overtime_hours_balance, created_at, updated_at
FROM employee_balance
WHERE employee_id = #{employeeId}
</select>
<insert id="insertEmployeeBalance">
INSERT INTO employee_balance (employee_id, overtime_hours_balance)
VALUES (#{employeeId}, #{overtimeHoursBalance})
</insert>
<update id="updateEmployeeBalance">
UPDATE employee_balance
SET overtime_hours_balance = overtime_hours_balance + #{overtimeHoursBalance}
WHERE employee_id = #{employeeId}
</update>
</mapper>
......@@ -7,11 +7,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="OvertimeApplication" id="OvertimeApplicationResult">
<result property="id" column="id" />
<result property="overtimeId" column="overtime_id" />
<result property="employeeId" column="employee_id" />
<result property="uname" column="uname" />
<result property="requestDate" column="request_date" />
<result property="yearMonth" column="year_month" />
<result property="overtimeHours" column="overtime_hours" />
<result property="totalOvertimeDays" column="total_overtime_days" />
<result property="totalOvertimeHours" column="total_overtime_hours" />
<result property="project" column="project" />
<result property="projectLeader" column="project_leader" />
<result property="divisionLeader" column="division_leader" />
......@@ -20,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectOvertimeApplicationVo">
select id, overtime_id, uname, request_date, `year_month`, overtime_hours, total_overtime_days, project, project_leader, division_leader, created_time, updated_time from overtime_application
select id, overtime_id,employee_id, uname, request_date, `year_month`, overtime_hours,total_overtime_hours, project, project_leader, division_leader, created_time, updated_time from overtime_application
</sql>
<select id="selectOvertimeApplicationList" parameterType="OvertimeApplication" resultMap="OvertimeApplicationResult">
......@@ -44,24 +45,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into overtime_application
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="overtimeId != null and overtimeId != ''">overtime_id,</if>
<if test="employeeId != null and employeeId != ''">employee_id,</if>
<if test="uname != null and uname != ''">uname,</if>
<if test="requestDate != null">request_date,</if>
<if test="yearMonth != null">`year_month`,</if>
<if test="overtimeHours != null">overtime_hours,</if>
<if test="totalOvertimeHours != null">total_overtime_hours,</if>
<if test="project != null">project,</if>
<if test="projectLeader != null">project_leader,</if>
<if test="divisionLeader != null">division_leader,</if>
<if test="totalOvertimeDays != null">total_overtime_days,</if>
<if test="createdTime != null">created_time,</if>
<if test="updatedTime != null">updated_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="overtimeId != null and overtimeId != ''">#{overtimeId},</if>
<if test="employeeId != null and employeeId != ''">#{employeeId},</if>
<if test="uname != null and uname != ''">#{uname},</if>
<if test="requestDate != null">#{requestDate},</if>
<if test="yearMonth != null">#{yearMonth},</if>
<if test="overtimeHours != null">#{overtimeHours},</if>
<if test="totalOvertimeHours != null">#{totalOvertimeHours},</if>
<if test="project != null">#{project},</if>
<if test="projectLeader != null">#{projectLeader},</if>
<if test="divisionLeader != null">#{divisionLeader},</if>
......@@ -74,10 +78,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update overtime_application
<trim prefix="SET" suffixOverrides=",">
<if test="overtimeId != null and overtimeId != ''">overtime_id = #{overtimeId},</if>
<if test="employeeId != null and employeeId != ''">employee_id = #{employeeId},</if>
<if test="uname != null and uname != ''">uname = #{uname},</if>
<if test="requestDate != null">request_date = #{requestDate},</if>
<if test="yearMonth != null">`year_month` = #{yearMonth},</if>
<if test="overtimeHours != null">overtime_hours = #{overtimeHours},</if>
<if test="totalOvertimeHours != null">total_overtime_hours = #{totalOvertimeHours},</if>
<if test="project != null">project = #{project},</if>
<if test="projectLeader != null">project_leader = #{projectLeader},</if>
<if test="divisionLeader != null">division_leader = #{divisionLeader},</if>
......@@ -97,4 +103,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="getUserIdByNickName" resultType="java.lang.Long">
SELECT user_id
FROM sys_user
WHERE nick_name = #{nickName}
</select>
</mapper>
\ No newline at end of file
......@@ -21,9 +21,9 @@
sys_user su1 ON pm.department_leader_id = su1.user_id
JOIN
sys_user su2 ON pm.project_manager_id = su2.user_id
JOIN
LEFT JOIN
sys_user_project sup ON pm.id = sup.project_id
JOIN
LEFT JOIN
sys_user su3 ON sup.user_id = su3.user_id
WHERE
su2.nick_name = #{projectManagerNickName}
......
......@@ -110,7 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND p.id = r2.project_id
</select>
<select id="getItemList" parameterType="Long" resultType="com.ruoyi.domain.dto.FyglDailyReimbursementTableItemDTO">
<select id="getItemList" resultType="com.ruoyi.domain.dto.FyglDailyReimbursementTableItemDTO">
SELECT
r.id,
r.registration_time as registrationTime,
......@@ -123,7 +123,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
fygl_daily_rembursement_relevancy_r r
LEFT JOIN fygl_daily_reimbursement_relevancy re ON re.rid = r.id
<where>
r.did = #{id}
r.project_id= #{projectId}
<if test="status != null and status != ''"> and r.status = #{status}</if>
<if test="reimbursement != null and reimbursement != ''">and r.reimbursement = #{reimbursement}</if>
</where>
......@@ -157,6 +157,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select p.project_number as projectNumber,p.project_status as projectStatus,p.project_type as projectType,u.user_name as userName,u2.user_name as projectManager from project_manage p,sys_user u,sys_user u2 where p.id = #{pid} and u.user_id = p.department_leader_id and u2.user_id = p.project_manager_id
</select>
<select id="getProjectListByUserId" resultMap="FyglDailyReimbursementDTOResult">
SELECT
p.id as projectId,
p.project_name,
p.start_date,
p.end_date,
u1.nick_name AS department_leader_name,
u2.nick_name AS project_manager_name
FROM
project_manage p
LEFT JOIN sys_user u1 ON u1.user_id = p.department_leader_id
LEFT JOIN sys_user u2 ON u2.user_id = p.project_manager_id
where p.id in (select project_id from project_member where user_id = #{id})
</select>
<insert id="insertFyglDailyReimbursement" parameterType="com.ruoyi.domain.FyglDailyReimbursement" useGeneratedKeys="true" keyProperty="did">
insert into fygl_daily_reimbursement
<trim prefix="(" suffix=")" suffixOverrides=",">
......@@ -179,7 +196,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertFyglDailyReimbursement2" parameterType="com.ruoyi.domain.FyglDailyReimbursement" useGeneratedKeys="true" keyProperty="rid">
insert into fygl_daily_rembursement_relevancy_r
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="did != null">did,</if>
<if test="projectId != null">project_id,</if>
<if test="status != null">`status`,</if>
<if test="accessory != null">accessory,</if>
<if test="serialNumber != null">serial_number,</if>
......@@ -187,7 +204,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="reimbursement != null">reimbursement</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="did != null">#{did},</if>
<if test="projectId != null">#{projectId},</if>
<if test="status != null">#{status},</if>
<if test="accessory != null">#{accessory},</if>
<if test="serialNumber != null">#{serialNumber},</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment