@@ -10,9 +10,12 @@ 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.oa.domain.OaSalaryItem ;
import com.ruoyi.oa.domain.bo.SysOaAttendanceBo ;
import com.ruoyi.oa.domain.vo.CalcResultVo ;
import com.ruoyi.oa.domain.vo.SysOaAttendanceVo ;
import com.ruoyi.oa.domain.vo.SysOaHolidayVo ;
import com.ruoyi.oa.mapper.OaSalaryItemMapper ;
import com.ruoyi.oa.service.ISysOaAttendanceService ;
import com.ruoyi.oa.service.ISysOaHolidayService ;
import com.ruoyi.oa.utils.OwnHttpUtils ;
import com.ruoyi.system.mapper.SysUserRoleMapper ;
@@ -36,7 +39,6 @@ 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.* ;
import java.time.format.DateTimeFormatter ;
@@ -81,6 +83,9 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
@Autowired
private SysUserRoleMapper sysUserRoleMapper ;
@Autowired
private ISysOaAttendanceService sysOaAttendanceService ;
/**
* 查询薪资管理
*/
@@ -94,11 +99,17 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
*/
@Override
public TableDataInfo < OaSalaryVo > queryPageList ( OaSalaryBo bo , PageQuery pageQuery ) {
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 ( ) ) ;
// 判断一下是否传参 如果没传参则默认查询当月记录,如果当月记录为空则创造当月的记录然后返回回去
Date payTime = bo . getPayTime ( ) ! = null ? bo . getPayTime ( ) : new Date ( ) ;
Page < OaSalaryVo > result = baseMapper . selectStaffVoPage ( pageQuery . build ( ) , lqw , payTime ) ;
if ( result . getRecords ( ) . isEmpty ( ) ) {
// 判断是否有当前月的记录 没有则进行创造新的记录
this . importSalaryUser ( ) ;
result = baseMapper . selectStaffVoPage ( pageQuery . build ( ) , lqw , payTime ) ;
}
return TableDataInfo . build ( result ) ;
}
@@ -108,7 +119,13 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
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 ( ) ) ;
Date payTime = bo . getPayTime ( ) ! = null ? bo . getPayTime ( ) : new Date ( );
Page < OaSalaryVo > result = baseMapper . selectStaffVoPage ( pageQuery . build ( ) , lqw , payTime ) ;
if ( result . getRecords ( ) . isEmpty ( ) ) {
// 判断是否有当前月的记录 没有则进行创造新的记录
this . importSalaryUser ( ) ;
result = baseMapper . selectStaffVoPage ( pageQuery . build ( ) , lqw , payTime ) ;
}
return TableDataInfo . build ( result ) ;
}
@@ -199,6 +216,9 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
String jsonPath = OwnHttpUtils . getJsonName ( bo . getMonthStr ( ) , bo . getFilePath ( ) ) ;
// 2拿到所有的用户
Date yearMonth = StringToDate ( combineYearMonth ( bo . getMonthStr ( ) ) ) ;
// 添加去重思想 即拿到月份如果之前计算过,则将原来的全部删掉然后新增新的
baseMapper . delByPayTime ( yearMonth ) ;
List < SysUser > sysUsers = userService . selectUserList2 ( ) ;
// 3遍历user列表 拿出所有的nickName分别拿到他们的json 进行第二步分析
for ( SysUser user : sysUsers ) {
@@ -277,6 +297,11 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
} ) ;
}
}
List < String > days = getDays ( bo , res . getAbsentDates ( ) ) ;
res . setAbsentDates ( days ) ;
List < String > days05 = getDays ( bo , res . getAbsent05Dates ( ) ) ;
res . setAbsentDates ( days ) ;
res . setAbsent05Dates ( days05 ) ;
buildItemAbsent ( res . getAbsentDates ( ) , salary , 1 . 0 , yearMonth ) ;
buildItemAbsent ( res . getAbsent05Dates ( ) , salary , 0 . 5 , yearMonth ) ;
@@ -350,6 +375,20 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
return " 计算成功 " ;
}
private List < String > getDays ( OaSalaryBo bo , List < String > res ) {
List < String > days = new ArrayList < > ( ) ;
for ( String absentDate : res ) {
String dateString = combineYearMonthAndDay ( bo . getMonthStr ( ) , absentDate ) ;
Date date = StringToDate ( dateString ) ;
SysOaAttendanceBo sysOaAttendanceBo = new SysOaAttendanceBo ( ) ;
sysOaAttendanceBo . setCreateTime ( date ) ;
SysOaAttendanceVo sysOaAttendanceVo = sysOaAttendanceService . queryList ( sysOaAttendanceBo ) . get ( 0 ) ;
if ( sysOaAttendanceVo ! = null & & sysOaAttendanceVo . getProjectId ( ) ! = 0 ) {
days . add ( absentDate ) ;
}
}
return days ;
}
private void buildItemAbsent ( List < String > realDate2 , OaSalary salary , Double flag , Date yearMonth ) {
@@ -378,6 +417,7 @@ public class OaSalaryServiceImpl implements IOaSalaryService {
salaryItemMapper . insert ( oaSalaryItem ) ;
}
/**
* 获取从 startTime 到 endTime( 含首尾) 的所有日期列表
*