Merge branch 'main' of https://gitee.com/hdka/fad_oa
This commit is contained in:
@@ -47,6 +47,14 @@ public class OaSalaryController extends BaseController {
|
||||
public TableDataInfo<OaSalaryVo> list(OaSalaryBo bo, PageQuery pageQuery) {
|
||||
return iOaSalaryService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
/**
|
||||
* 查询薪资管理列表
|
||||
*/
|
||||
@SaCheckPermission("oa:salary:list")
|
||||
@GetMapping("/list-worker")
|
||||
public TableDataInfo<OaSalaryVo> listWorker(OaSalaryBo bo, PageQuery pageQuery) {
|
||||
return iOaSalaryService.listWorker(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量写入user到salary中
|
||||
@@ -70,13 +78,11 @@ public class OaSalaryController extends BaseController {
|
||||
/**
|
||||
* 获取薪资管理详细信息
|
||||
*
|
||||
* @param salaryId 主键
|
||||
*/
|
||||
@SaCheckPermission("oa:salary:query")
|
||||
@GetMapping("/{salaryId}")
|
||||
public R<OaSalaryVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long salaryId) {
|
||||
return R.ok(iOaSalaryService.queryById(salaryId));
|
||||
@GetMapping("/detail")
|
||||
public R<OaSalaryVo> getInfo(@RequestBody OaSalaryBo bo) {
|
||||
return R.ok(iOaSalaryService.queryById(bo.getSalaryId(),bo.getPayTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +122,7 @@ public class OaSalaryController extends BaseController {
|
||||
|
||||
|
||||
@PostMapping("/calc")
|
||||
public void calc(@RequestBody OaSalaryBo bo) {
|
||||
iOaSalaryService.calcSalary(bo);
|
||||
public R<Void> calc(@RequestBody OaSalaryBo bo) {
|
||||
return R.ok(iOaSalaryService.calcSalary(bo));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.ruoyi.oa.domain.OaSalary;
|
||||
import com.ruoyi.oa.domain.bo.OaSalaryBo;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -69,4 +69,5 @@ public class OaSalaryVo extends OaSalary {
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
private List<OaSalaryItemVo> itemList;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.ruoyi.oa.domain.vo.OaSalaryVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 薪资管理Mapper接口
|
||||
*
|
||||
@@ -17,8 +19,12 @@ import org.apache.ibatis.annotations.Param;
|
||||
*/
|
||||
public interface OaSalaryMapper extends BaseMapperPlus<OaSalaryMapper, OaSalary, OaSalaryVo> {
|
||||
|
||||
Page<OaSalaryVo> selectStaffVoPage(Page<Object> build,@Param(Constants.WRAPPER) Wrapper<OaSalary> lqw);
|
||||
Page<OaSalaryVo> selectStaffVoPage(Page<Object> build,@Param(Constants.WRAPPER) Wrapper<OaSalary> lqw,@Param("payTime") Date payTime);
|
||||
|
||||
|
||||
OaSalary selectVoByUserId(Long userId);
|
||||
|
||||
OaSalaryVo selectVoAndItemVoById(@Param("salaryId")Long salaryId,@Param("payTime")Date payTime);
|
||||
|
||||
void delByPayTime(Date date);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package com.ruoyi.oa.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.oa.domain.OaSalary;
|
||||
import com.ruoyi.oa.domain.vo.OaSalaryVo;
|
||||
import com.ruoyi.oa.domain.bo.OaSalaryBo;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -21,7 +22,7 @@ public interface IOaSalaryService {
|
||||
/**
|
||||
* 查询薪资管理
|
||||
*/
|
||||
OaSalaryVo queryById(Long salaryId);
|
||||
OaSalaryVo queryById(Long salaryId, @NotBlank Date payTime);
|
||||
|
||||
/**
|
||||
* 查询薪资管理列表
|
||||
@@ -51,13 +52,17 @@ public interface IOaSalaryService {
|
||||
|
||||
/**
|
||||
* 计算工资
|
||||
*
|
||||
* @param bo
|
||||
* @return
|
||||
*/
|
||||
void calcSalary(OaSalaryBo bo);
|
||||
String calcSalary(OaSalaryBo bo);
|
||||
|
||||
/**
|
||||
* 导入当月所有人的记录
|
||||
* @return
|
||||
*/
|
||||
R<Void> importSalaryUser();
|
||||
|
||||
TableDataInfo<OaSalaryVo> listWorker(OaSalaryBo bo, PageQuery pageQuery);
|
||||
}
|
||||
|
||||
@@ -1,31 +1,25 @@
|
||||
package com.ruoyi.oa.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.service.UserService;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.flowable.utils.TaskUtils;
|
||||
import com.ruoyi.oa.domain.OaSalaryItem;
|
||||
import com.ruoyi.oa.domain.vo.CalcResultVo;
|
||||
import com.ruoyi.oa.domain.vo.SysOaHolidayVo;
|
||||
import com.ruoyi.oa.mapper.OaSalaryItemMapper;
|
||||
import com.ruoyi.oa.service.IOaSalaryItemService;
|
||||
import com.ruoyi.oa.service.ISysOaHolidayService;
|
||||
import com.ruoyi.oa.utils.OwnHttpUtils;
|
||||
import com.ruoyi.system.service.ISysDeptService;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
import com.ruoyi.system.mapper.SysUserRoleMapper;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.workflow.mapper.WfDeployFormMapper;
|
||||
import com.ruoyi.workflow.service.IWfTaskService;
|
||||
import liquibase.pro.packaged.A;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.catalina.User;
|
||||
import org.flowable.engine.HistoryService;
|
||||
import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.TaskService;
|
||||
@@ -42,11 +36,9 @@ import com.ruoyi.oa.mapper.OaSalaryMapper;
|
||||
import com.ruoyi.oa.service.IOaSalaryService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.*;
|
||||
@@ -86,12 +78,15 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
|
||||
@Autowired
|
||||
private OaSalaryItemMapper salaryItemMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserRoleMapper sysUserRoleMapper;
|
||||
|
||||
/**
|
||||
* 查询薪资管理
|
||||
*/
|
||||
@Override
|
||||
public OaSalaryVo queryById(Long salaryId){
|
||||
return baseMapper.selectVoById(salaryId);
|
||||
public OaSalaryVo queryById(Long salaryId,Date payTime){
|
||||
return baseMapper.selectVoAndItemVoById(salaryId,payTime);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,24 +94,41 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<OaSalaryVo> queryPageList(OaSalaryBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<OaSalary> lqw = buildQueryWrapper(bo);
|
||||
Page<OaSalaryVo> result = baseMapper.selectStaffVoPage(pageQuery.build(), lqw);
|
||||
|
||||
List<Long> userIds = sysUserRoleMapper.selectUserIdsByNotRoleId(1852970465740505090L);
|
||||
QueryWrapper<OaSalary> lqw = new QueryWrapper<>();
|
||||
lqw.in("os.user_id",userIds);
|
||||
Page<OaSalaryVo> result = baseMapper.selectStaffVoPage(pageQuery.build(), lqw,bo.getPayTime());
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TableDataInfo<OaSalaryVo> listWorker(OaSalaryBo bo, PageQuery pageQuery) {
|
||||
List<Long> userIds = sysUserRoleMapper.selectUserIdsByRoleId(1852970465740505090L);
|
||||
QueryWrapper<OaSalary> lqw = new QueryWrapper<>();
|
||||
lqw.in("os.user_id",userIds);
|
||||
Page<OaSalaryVo> result = baseMapper.selectStaffVoPage(pageQuery.build(), lqw,bo.getPayTime());
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Void> importSalaryUser() {
|
||||
SysUser sysUser = new SysUser();
|
||||
List<SysUser> sysUsers = userService.selectUserList(sysUser);
|
||||
List<SysUser> sysUsers = userService.selectUserList2();
|
||||
baseMapper.delByPayTime(new Date());
|
||||
for (SysUser user : sysUsers) {
|
||||
OaSalary oaSalary = new OaSalary();
|
||||
oaSalary.setUserId(user.getUserId());
|
||||
oaSalary.setBaseSalary(Double.valueOf(user.getLaborCost()));
|
||||
oaSalary.setPayTime(new Date());
|
||||
baseMapper.insert(oaSalary);
|
||||
if(Objects.nonNull(user)){
|
||||
OaSalary oaSalary = new OaSalary();
|
||||
oaSalary.setUserId(user.getUserId());
|
||||
oaSalary.setBaseSalary(Double.valueOf(user.getLaborCost()));
|
||||
oaSalary.setPayTime(new Date());
|
||||
baseMapper.insert(oaSalary);
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询薪资管理列表
|
||||
*/
|
||||
@@ -130,9 +142,6 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<OaSalary> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getUserId() != null, OaSalary::getUserId, bo.getUserId());
|
||||
lqw.eq(bo.getRealSalary() != null, OaSalary::getRealSalary, bo.getRealSalary());
|
||||
lqw.eq(bo.getPayTime() != null, OaSalary::getPayTime, bo.getPayTime());
|
||||
lqw.eq(bo.getBaseSalary() != null, OaSalary::getBaseSalary, bo.getBaseSalary());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@@ -180,21 +189,22 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
|
||||
|
||||
/**
|
||||
* 计算薪资
|
||||
*
|
||||
* @param bo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void calcSalary(OaSalaryBo bo) {
|
||||
public String calcSalary(OaSalaryBo bo) {
|
||||
// 1先获取对应的json路径 "/home/ubuntu/lyq/fad_oa_kqdeal/202411.json"
|
||||
String jsonPath = OwnHttpUtils.getJsonName(bo.getMonthStr(), bo.getFilePath());
|
||||
// 2拿到所有的用户
|
||||
SysUser sysUser = new SysUser();
|
||||
Date yearMonth = StringToDate(combineYearMonth(bo.getMonthStr()));
|
||||
List<SysUser> sysUsers = userService.selectUserList(sysUser);
|
||||
List<SysUser> sysUsers = userService.selectUserList2();
|
||||
// 3遍历user列表 拿出所有的nickName分别拿到他们的json 进行第二步分析
|
||||
for (SysUser user : sysUsers) {
|
||||
OaSalary salary = baseMapper.selectVoByUserId(user.getUserId());
|
||||
if (salary == null) {
|
||||
return;
|
||||
return jsonPath;
|
||||
}
|
||||
// 3.1 拿到一个人打卡机的记录
|
||||
CalcResultVo res = OwnHttpUtils.getBaseCalc(jsonPath,user.getNickName());
|
||||
@@ -223,10 +233,9 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
|
||||
Long endTimeItem = (Long) processVariables.get("endTimeItem");
|
||||
}
|
||||
// 计算缺席的某天是否请假或者出差
|
||||
List<String> absentDates = res.getAbsentDates();
|
||||
List<String> realDates = new ArrayList<>();
|
||||
List<String> real05Dates = new ArrayList<>();
|
||||
for (String absentDate : absentDates) {
|
||||
for (String absentDate : res.getAbsentDates()) {
|
||||
// 形如2024-11-01
|
||||
String fullDate = combineYearMonthAndDay(bo.getMonthStr(), absentDate);
|
||||
boolean contains = timeRange.contains(fullDate);
|
||||
@@ -235,16 +244,18 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
|
||||
realDates.add(fullDate);
|
||||
}
|
||||
}
|
||||
for (String real05Date : real05Dates) {
|
||||
for (String real05Date : res.getAbsent05Dates()) {
|
||||
String fullDate = combineYearMonthAndDay(bo.getMonthStr(), real05Date);
|
||||
boolean contains = timeRange.contains(fullDate);
|
||||
if (!contains) {
|
||||
real05Dates.add(fullDate);
|
||||
}
|
||||
}
|
||||
res.setAbsentDates(realDates);
|
||||
res.setAbsent05Dates(real05Dates);
|
||||
// 这次已经将缺勤拿出来了 现在还要判断今天是否为节假日
|
||||
List<String> realDate2 =new ArrayList<>();
|
||||
for (String realDate : realDates) {
|
||||
for (String realDate : res.getAbsentDates()) {
|
||||
SysOaHolidayVo sysOaHolidayVo = holidayService.queryHolidayByDate(StringToDate(realDate));
|
||||
if (sysOaHolidayVo != null && sysOaHolidayVo.getType()!=0 ) {
|
||||
// 如果不为节假日则加入进去
|
||||
@@ -252,7 +263,7 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
|
||||
}
|
||||
}
|
||||
List<String> real05Date2 =new ArrayList<>();
|
||||
for (String real05Date : real05Dates) {
|
||||
for (String real05Date : res.getAbsent05Dates()) {
|
||||
SysOaHolidayVo sysOaHolidayVo = holidayService.queryHolidayByDate(StringToDate(real05Date));
|
||||
if (sysOaHolidayVo != null && sysOaHolidayVo.getType()!=0 ) {
|
||||
// 如果不为节假日则加入进去
|
||||
@@ -260,71 +271,92 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
|
||||
}
|
||||
|
||||
}
|
||||
buildItemAbsent(realDate2, salary,1.0,yearMonth);
|
||||
buildItemAbsent(real05Date2, salary,0.5,yearMonth);
|
||||
res.setAbsentDates(realDate2);
|
||||
res.setAbsent05Dates(real05Date2);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
buildItemAbsent(res.getAbsentDates(), salary,1.0,yearMonth);
|
||||
buildItemAbsent(res.getAbsent05Dates(), salary,0.5,yearMonth);
|
||||
|
||||
// 3.4创建其他的item包括了好多罚金
|
||||
// 3.4.1 迟到罚金
|
||||
StringBuilder sb= new StringBuilder();
|
||||
for (String lateDate : res.getLateDates()) {
|
||||
sb.append(lateDate);
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append("迟到日期");
|
||||
OaSalaryItem oaSalaryItem = new OaSalaryItem();
|
||||
oaSalaryItem.setSalaryId(salary.getSalaryId());
|
||||
oaSalaryItem.setPrice(Double.valueOf(res.getLateFee()));
|
||||
oaSalaryItem.setType(4L);
|
||||
oaSalaryItem.setFlag(0L);
|
||||
oaSalaryItem.setReason(sb.toString());
|
||||
oaSalaryItem.setSignTime(yearMonth);
|
||||
salaryItemMapper.insert(oaSalaryItem);
|
||||
StringBuilder sb= new StringBuilder();
|
||||
if (!res.getLateDates().isEmpty()) {
|
||||
for (String lateDate : res.getLateDates()) {
|
||||
sb.append(lateDate);
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append("迟到");
|
||||
|
||||
oaSalaryItem.setSalaryId(salary.getSalaryId());
|
||||
oaSalaryItem.setPrice(Double.valueOf(res.getLateFee()));
|
||||
oaSalaryItem.setType(4L);
|
||||
oaSalaryItem.setFlag(0L);
|
||||
oaSalaryItem.setReason(sb.toString());
|
||||
oaSalaryItem.setSignTime(yearMonth);
|
||||
salaryItemMapper.insert(oaSalaryItem);
|
||||
}
|
||||
|
||||
// 3.4.2 早退罚金
|
||||
sb= new StringBuilder();
|
||||
for (String lateDate : res.getLeaveEarly10Dates()) {
|
||||
sb.append(lateDate);
|
||||
sb.append(",");
|
||||
if (!res.getLeaveEarly10Dates().isEmpty()) {
|
||||
for (String lateDate : res.getLeaveEarly10Dates()) {
|
||||
sb.append(lateDate);
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append("以上为早退十分钟日期");
|
||||
}
|
||||
sb.append("早退日期十分钟");
|
||||
for (String lateDate : res.getLeaveEarly30Dates()) {
|
||||
sb.append(lateDate);
|
||||
sb.append(",");
|
||||
|
||||
if (!res.getLeaveEarly30Dates().isEmpty()) {
|
||||
for (String lateDate : res.getLeaveEarly30Dates()) {
|
||||
sb.append(lateDate);
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append("以上为早退三十分钟日期");
|
||||
}
|
||||
|
||||
if (!res.getLeaveEarly30Dates().isEmpty() || !res.getLeaveEarly10Dates().isEmpty()) {
|
||||
oaSalaryItem = new OaSalaryItem();
|
||||
oaSalaryItem.setSalaryId(salary.getSalaryId());
|
||||
oaSalaryItem.setPrice(Double.valueOf(res.getLeaveEarlyFee()));
|
||||
oaSalaryItem.setType(5L);
|
||||
oaSalaryItem.setFlag(0L);
|
||||
oaSalaryItem.setReason(sb.toString());
|
||||
oaSalaryItem.setSignTime(yearMonth);
|
||||
salaryItemMapper.insert(oaSalaryItem);
|
||||
}
|
||||
sb.append("早退日期三十分钟");
|
||||
oaSalaryItem = new OaSalaryItem();
|
||||
oaSalaryItem.setSalaryId(salary.getSalaryId());
|
||||
oaSalaryItem.setPrice(Double.valueOf(res.getLeaveEarlyFee()));
|
||||
oaSalaryItem.setType(5L);
|
||||
oaSalaryItem.setFlag(0L);
|
||||
oaSalaryItem.setReason(sb.toString());
|
||||
oaSalaryItem.setSignTime(yearMonth);
|
||||
salaryItemMapper.insert(oaSalaryItem);
|
||||
// 3.4.3 打卡罚金
|
||||
sb= new StringBuilder();
|
||||
for (String lateDate : res.getLateDates()) {
|
||||
sb.append(lateDate);
|
||||
sb.append(",");
|
||||
if (!res.getLateDates().isEmpty()){
|
||||
sb= new StringBuilder();
|
||||
for (String lateDate : res.getLateDates()) {
|
||||
sb.append(lateDate);
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append("未打卡");
|
||||
oaSalaryItem = new OaSalaryItem();
|
||||
oaSalaryItem.setSalaryId(salary.getSalaryId());
|
||||
oaSalaryItem.setPrice(Double.valueOf(res.getNotAttendanceFee()));
|
||||
oaSalaryItem.setType(6L);
|
||||
oaSalaryItem.setFlag(0L);
|
||||
oaSalaryItem.setReason(sb.toString());
|
||||
oaSalaryItem.setSignTime(yearMonth);
|
||||
salaryItemMapper.insert(oaSalaryItem);
|
||||
}
|
||||
sb.append("未打卡");
|
||||
oaSalaryItem = new OaSalaryItem();
|
||||
oaSalaryItem.setSalaryId(salary.getSalaryId());
|
||||
oaSalaryItem.setPrice(Double.valueOf(res.getNotAttendanceFee()));
|
||||
oaSalaryItem.setType(6L);
|
||||
oaSalaryItem.setFlag(0L);
|
||||
oaSalaryItem.setReason(sb.toString());
|
||||
oaSalaryItem.setSignTime(yearMonth);
|
||||
salaryItemMapper.insert(oaSalaryItem);
|
||||
}
|
||||
|
||||
return "计算成功";
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void buildItemAbsent(List<String> realDate2, OaSalary salary,Double flag,Date yearMonth) {
|
||||
// 最终这个为缺勤日期
|
||||
if (realDate2.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
OaSalaryItem oaSalaryItem = new OaSalaryItem();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// 接下来将他拼接成一个字符串为扣款原因矿工问题
|
||||
@@ -432,17 +464,17 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
|
||||
|
||||
private Date StringToDate(String dateStr) {
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
// 1. 解析字符串到 YearMonth(只包含年和月)
|
||||
YearMonth yearMonth = YearMonth.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM"));
|
||||
|
||||
// 1. 先解析成 LocalDateTime
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(dateStr, formatter);
|
||||
// 2. 在 YearMonth 基础上指定“日”为 1
|
||||
LocalDate localDate = yearMonth.atDay(1);
|
||||
|
||||
// 2. 转换为 Instant(指定时区)
|
||||
Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant();
|
||||
// 3. 转成 Instant
|
||||
Instant instant = localDate.atStartOfDay(ZoneId.systemDefault()).toInstant();
|
||||
|
||||
// 3. 转换成旧版 Date
|
||||
// 4. 转成旧版本 Date
|
||||
return Date.from(instant);
|
||||
|
||||
}
|
||||
|
||||
private String DateToString(Date date) {
|
||||
|
||||
@@ -10,6 +10,9 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class OwnHttpUtils {
|
||||
@@ -25,9 +28,10 @@ public class OwnHttpUtils {
|
||||
|
||||
public static CalcResultVo getBaseCalc(String fileName, String personName) {
|
||||
// 目标接口地址
|
||||
String jsonBody = String.format("{\"file_name\":\"%s\",\"person_name\":\"%s\"}", fileName, personName);
|
||||
jsonBody = getResult("get_person_info",jsonBody);
|
||||
String jsonBody = String.format("{\"file_name\":%s,\"person_name\":\"%s\"}", fileName, personName);
|
||||
System.out.println(jsonBody);
|
||||
jsonBody = getResult("get_person_info",jsonBody);
|
||||
|
||||
// 1. 将 JSON 字符串解析成 JSONObject
|
||||
JSONObject jsonObject = JSON.parseObject(jsonBody);
|
||||
|
||||
@@ -107,12 +111,7 @@ public class OwnHttpUtils {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String fileName = "/home/ubuntu/lyq/fad_oa_kqdeal/202411.json";
|
||||
String personName = "丁苗松";
|
||||
String jsonBody = String.format("{\"file_name\":\"%s\",\"person_name\":\"%s\"}", fileName, personName);
|
||||
|
||||
|
||||
|
||||
StringToDate("2025-03");
|
||||
}
|
||||
|
||||
|
||||
@@ -164,4 +163,20 @@ public class OwnHttpUtils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Date StringToDate(String dateStr) {
|
||||
|
||||
// 1. 解析字符串到 YearMonth(只包含年和月)
|
||||
YearMonth yearMonth = YearMonth.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM"));
|
||||
|
||||
// 2. 在 YearMonth 基础上指定“日”为 1
|
||||
LocalDate localDate = yearMonth.atDay(1);
|
||||
|
||||
// 3. 转成 Instant
|
||||
Instant instant = localDate.atStartOfDay(ZoneId.systemDefault()).toInstant();
|
||||
|
||||
// 4. 转成旧版本 Date
|
||||
return Date.from(instant);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,13 @@
|
||||
</resultMap>
|
||||
|
||||
|
||||
<delete id="delByPayTime" parameterType="Date">
|
||||
DELETE FROM oa_salary
|
||||
WHERE YEAR(pay_time) = YEAR(#{payTime})
|
||||
AND MONTH(pay_time) = MONTH(#{payTime})
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="selectStaffVoPage" resultMap="OaSalaryResult">
|
||||
SELECT
|
||||
os.salary_id,
|
||||
@@ -45,18 +52,10 @@
|
||||
AND YEAR(osi.sign_time) = YEAR(#{payTime})
|
||||
AND MONTH(osi.sign_time) = MONTH(#{payTime})
|
||||
LEFT JOIN sys_user su ON os.user_id = su.user_id
|
||||
|
||||
<!-- 这里使用 <where> 标签统一管理条件 -->
|
||||
<where>
|
||||
${ew.customSqlSegment}
|
||||
and
|
||||
YEAR(os.pay_time) = YEAR(#{payTime})
|
||||
AND MONTH(os.pay_time) = MONTH(#{payTime})
|
||||
|
||||
<!-- 如果 ew 中带了自定义条件,就在这里追加 -->
|
||||
<if test="ew != null and ew.customSqlSegment != null and ew.customSqlSegment != ''">
|
||||
AND ${ew.customSqlSegment}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
GROUP BY
|
||||
os.salary_id,
|
||||
os.user_id,
|
||||
@@ -74,5 +73,48 @@
|
||||
select * from oa_salary where user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectVoAndItemVoById" resultType="com.ruoyi.oa.domain.vo.OaSalaryVo">
|
||||
SELECT
|
||||
os.salary_id,
|
||||
os.user_id,
|
||||
os.pay_time,
|
||||
os.base_salary,
|
||||
(
|
||||
os.base_salary * DAY(LAST_DAY(#{payTime}))
|
||||
+ COALESCE(SUM(
|
||||
CASE
|
||||
WHEN osi.flag = 1 THEN osi.price
|
||||
WHEN osi.flag = 0 THEN -osi.price
|
||||
ELSE 0
|
||||
END
|
||||
), 0)
|
||||
) AS real_salary,
|
||||
osi.salary_item_id,
|
||||
osi.reason,
|
||||
osi.price,
|
||||
osi.sign_time,
|
||||
su.nick_name
|
||||
FROM oa_salary os
|
||||
LEFT JOIN oa_salary_item osi
|
||||
ON osi.salary_id = os.salary_id
|
||||
AND YEAR(osi.sign_time) = YEAR(#{payTime})
|
||||
AND MONTH(osi.sign_time) = MONTH(#{payTime})
|
||||
LEFT JOIN sys_user su ON os.user_id = su.user_id
|
||||
where os.salary_id = #{salaryId}
|
||||
and
|
||||
YEAR(os.pay_time) = YEAR(#{payTime})
|
||||
AND MONTH(os.pay_time) = MONTH(#{payTime})
|
||||
GROUP BY
|
||||
os.salary_id,
|
||||
os.user_id,
|
||||
os.pay_time,
|
||||
os.base_salary,
|
||||
osi.salary_item_id,
|
||||
osi.type,
|
||||
osi.reason,
|
||||
osi.price,
|
||||
osi.sign_time
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -99,4 +99,11 @@ public interface SysUserMapper extends BaseMapperPlus<SysUserMapper, SysUser, Sy
|
||||
* @return
|
||||
*/
|
||||
SysUser selectUserByIdAndNotDelFlag(Long userId);
|
||||
|
||||
/**
|
||||
* 查询基本数据
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> selectListAndNotDel();
|
||||
|
||||
}
|
||||
|
||||
@@ -14,4 +14,5 @@ public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRoleMapper, Sys
|
||||
|
||||
List<Long> selectUserIdsByRoleId(Long roleId);
|
||||
|
||||
List<Long> selectUserIdsByNotRoleId(Long roleId);
|
||||
}
|
||||
|
||||
@@ -227,4 +227,10 @@ public interface ISysUserService {
|
||||
*/
|
||||
int deleteUserByIds(Long[] userIds);
|
||||
|
||||
/**
|
||||
* 查找所有没有被删除的用户的基本信息
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> selectUserList2();
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -487,6 +488,12 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
return baseMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> selectUserList2() {
|
||||
|
||||
return baseMapper.selectListAndNotDel();
|
||||
}
|
||||
|
||||
@Cacheable(cacheNames = CacheNames.SYS_USER_NAME, key = "#userId")
|
||||
@Override
|
||||
public String selectUserNameById(Long userId) {
|
||||
|
||||
@@ -50,6 +50,17 @@
|
||||
<result property="status" column="role_status"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.ruoyi.common.core.domain.entity.SysUser" id="ClearUser">
|
||||
<id property="userId" column="user_id"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
<result property="nickName" column="nick_name"/>
|
||||
<result property="userType" column="user_type"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="idCard" column="id_card"/>
|
||||
<result property="bankCard" column="bank_card"/>
|
||||
<result property="laborCost" column="labor_cost"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectUserVo">
|
||||
select u.user_id,
|
||||
u.dept_id,
|
||||
@@ -151,4 +162,9 @@
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectListAndNotDel" resultMap="ClearUser">
|
||||
select user_id,user_name,nick_name,labor_cost from sys_user where del_flag ='0'
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -14,4 +14,10 @@
|
||||
on u.user_id = sur.user_id and sur.role_id = #{roleId}
|
||||
</select>
|
||||
|
||||
<select id="selectUserIdsByNotRoleId" resultType="java.lang.Long">
|
||||
select u.user_id from sys_user u
|
||||
inner join sys_user_role sur
|
||||
on u.user_id = sur.user_id and sur.role_id != #{roleId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
/**
|
||||
* 根据月份和文件计算工资
|
||||
* @param {*} param0.monthStr: 月份
|
||||
* @param {*} param0.filePath: 文件路径
|
||||
* @returns
|
||||
*/
|
||||
* 根据月份和文件计算工资
|
||||
* @param {*} param0.monthStr: 月份
|
||||
* @param {*} param0.filePath: 文件路径
|
||||
* @returns
|
||||
*/
|
||||
export function calculateSalary({ monthStr, filePath }) {
|
||||
return request({
|
||||
url: '/oa/salary/calc',
|
||||
@@ -16,10 +16,18 @@ export function calculateSalary({ monthStr, filePath }) {
|
||||
}
|
||||
})
|
||||
}
|
||||
// 查询职工薪资列表
|
||||
export function listStaff(query) {
|
||||
return request({
|
||||
url: '/oa/salary/list-staff',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* oss文件上传
|
||||
*/
|
||||
* oss文件上传
|
||||
*/
|
||||
export function uploadOssFile(data) {
|
||||
return request({
|
||||
url: '/system/oss/upload',
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<div class="home">
|
||||
<div>
|
||||
<el-container style="height: 100vh;">
|
||||
|
||||
<el-main>
|
||||
<el-row :gutter="20">
|
||||
<!-- 右侧展示区域 -->
|
||||
@@ -32,6 +33,7 @@ import Inventory from "../components/Inventory/index.vue";
|
||||
import Announcements from "../components/Announcements/index.vue";
|
||||
import ProjectManagement from "../components/ProjectManagement/index.vue";
|
||||
import FinancialCharts from "../components/FinancialCharts/index.vue";
|
||||
import {importUser} from "@/api/oa/salary";
|
||||
|
||||
export default {
|
||||
name: "Index",
|
||||
@@ -62,6 +64,7 @@ export default {
|
||||
this.getListNotice();
|
||||
},
|
||||
methods: {
|
||||
|
||||
getList() {
|
||||
getCache().then((response) => {
|
||||
this.cache = response.data;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 上传弹窗 -->
|
||||
<el-dialog
|
||||
<el-dialog
|
||||
title="薪资计算"
|
||||
:visible.sync="uploadVisible"
|
||||
width="30%"
|
||||
@@ -23,7 +23,7 @@
|
||||
:disabled="isUploading">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item label="薪资文件" required>
|
||||
<el-upload
|
||||
class="upload-demo"
|
||||
@@ -38,15 +38,16 @@
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="uploadVisible = false" :disabled="isUploading">取消</el-button>
|
||||
<el-button @click="handleUpload" :disabled="fileList.length === 0">确认上传</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="handleSubmit"
|
||||
:loading="isUploading"
|
||||
:disabled="!filePath">
|
||||
:disabled="isUploading"
|
||||
>
|
||||
{{ isUploading ? '计算中...' : '开始计算' }}
|
||||
</el-button>
|
||||
</span>
|
||||
@@ -84,7 +85,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
|
||||
<div class="summary">
|
||||
<span>合计人数:{{currentResult.length}} 人</span>
|
||||
<span class="total-amount">总金额:¥ {{totalAmount}}</span>
|
||||
@@ -109,6 +110,12 @@ export default {
|
||||
currentMonth: '',
|
||||
historyData: [],
|
||||
filePath: '',
|
||||
query:{
|
||||
pageSize:10,
|
||||
pageNum:1,
|
||||
payTime:"2025-03-01"
|
||||
},
|
||||
StaffSalaryList:[]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -131,15 +138,21 @@ export default {
|
||||
this.getHistoryData(firstDayStr)
|
||||
},
|
||||
methods: {
|
||||
getStaffList(){
|
||||
listStaff(this.query).then(res => {
|
||||
this.StaffSalaryList = res.rows
|
||||
console.log(this.StaffSalaryList)
|
||||
})
|
||||
},
|
||||
showUploadDialog() {
|
||||
this.uploadVisible = true
|
||||
},
|
||||
|
||||
|
||||
handleFileChange(file, fileList) {
|
||||
// 限制单个文件上传
|
||||
this.fileList = [fileList[fileList.length - 1]]
|
||||
},
|
||||
|
||||
|
||||
async handleSubmit() {
|
||||
try {
|
||||
this.isUploading = true
|
||||
@@ -166,12 +179,12 @@ export default {
|
||||
this.isUploading = false
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// 上传文件
|
||||
async handleUpload() {
|
||||
const formData = new FormData()
|
||||
formData.append('file', this.fileList[0].raw)
|
||||
|
||||
|
||||
const { data } = await uploadOssFile(formData)
|
||||
|
||||
const filePath = '/data' + data.url.split('/data')[1];
|
||||
@@ -183,7 +196,7 @@ export default {
|
||||
this.fileList = []
|
||||
this.month = ''
|
||||
},
|
||||
|
||||
|
||||
showDetail(row) {
|
||||
// 查看历史详情逻辑
|
||||
console.log('查看详情', row)
|
||||
@@ -251,4 +264,4 @@ export default {
|
||||
.upload-demo {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user