|
|
@@ -19,10 +19,7 @@ import org.sky.scientific.excel.AttendanceMonthlyDataListener;
|
|
|
import org.sky.scientific.excel.AttendanceMonthlyExcel;
|
|
|
import org.sky.scientific.excel.handle.AttendanceMergeStrategy;
|
|
|
import org.sky.scientific.excel.handle.CustomCellStyleHandler;
|
|
|
-import org.sky.scientific.mapper.AttendanceMapper;
|
|
|
-import org.sky.scientific.mapper.SettingMapper;
|
|
|
-import org.sky.scientific.mapper.TechnicianMapper;
|
|
|
-import org.sky.scientific.mapper.XmTechnicianMapper;
|
|
|
+import org.sky.scientific.mapper.*;
|
|
|
import org.sky.scientific.pojo.dto.AttendanceDto;
|
|
|
import org.sky.scientific.pojo.entity.AttendanceEntity;
|
|
|
import org.sky.scientific.pojo.entity.SettingEntity;
|
|
|
@@ -55,6 +52,7 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
|
|
|
private final TechnicianMapper technicianMapper;
|
|
|
private final SettingMapper settingMapper;
|
|
|
private final XmTechnicianMapper xmTechnicianMapper;
|
|
|
+ private final XmTechnicianHoursMapper technicianHoursMapper;
|
|
|
|
|
|
@Override
|
|
|
public IPage<AttendanceVO> selectAttendancePage(AttendanceDto attendance, IPage<AttendanceVO> page) {
|
|
|
@@ -107,6 +105,8 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
|
|
|
//新增
|
|
|
affectNum = baseMapper.insert(attendance);
|
|
|
} else {
|
|
|
+ //获取已填报的工时,新的考勤不能小于已填报工时总和
|
|
|
+ this.judgeAttendance(attendance.getUnicode(), attendance.getWorkDate(), attendance.getWorkHours());
|
|
|
//修改
|
|
|
LambdaQueryWrapper<AttendanceEntity> updateWrapper = Wrappers.<AttendanceEntity>lambdaQuery()
|
|
|
.eq(AttendanceEntity::getUnicode, attendance.getUnicode())
|
|
|
@@ -164,6 +164,9 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
|
|
|
if (dailyAttendance.getWorkHours() > one.getWorkHours()) {
|
|
|
throw new ServiceException("出勤时长不能大于出勤时间设置[" + one.getWorkHours() + "]小时");
|
|
|
}
|
|
|
+ //获取已填报的工时,新的考勤不能小于已填报工时总和
|
|
|
+ this.judgeAttendance(dailyAttendance.getUnicode(), dailyAttendance.getWorkDate(), dailyAttendance.getWorkHours());
|
|
|
+
|
|
|
List<Long> primaryKeyList = dataByTechnicianMonthly.stream().filter(e -> Objects.equals(e.getWorkDate(), dailyAttendance.getWorkDate())).map(AttendanceEntity::getId).toList();
|
|
|
Long primaryKey = CollectionUtil.isEmpty(primaryKeyList) ? null : primaryKeyList.get(0);
|
|
|
AttendanceEntity entity = new AttendanceEntity();
|
|
|
@@ -202,6 +205,13 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void judgeAttendance(String unicode, String workDate, double workHours){
|
|
|
+ //获取已填报的工时,新的考勤不能小于已填报工时总和
|
|
|
+ double workHoursByDay = technicianHoursMapper.sumByUnicodeAndDay(unicode, workDate);
|
|
|
+ if(workHours<workHoursByDay){
|
|
|
+ throw new ServiceException("日期【"+workDate+"】填报的出勤时长不能小于已填报的工时【"+workHoursByDay+"】,请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
@Override
|
|
|
public void exportAttendance(OutputStream os, List<AttendanceVO> list, String yearAndMonth) {
|
|
|
try {
|
|
|
@@ -337,6 +347,10 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
|
|
|
}
|
|
|
List<Long> primaryKeyList = dataByTechnicianMonthly.stream().filter(e -> Objects.equals(e.getWorkDate(), dailyAttendance.getWorkDate())).map(AttendanceEntity::getId).toList();
|
|
|
Long primaryKey = CollectionUtil.isEmpty(primaryKeyList) ? null : primaryKeyList.get(0);
|
|
|
+
|
|
|
+ //获取已填报的工时,新的考勤不能小于已填报工时总和
|
|
|
+ this.judgeAttendance(attendance.getUnicode(), dailyAttendance.getWorkDate(), dailyAttendance.getWorkHours());
|
|
|
+
|
|
|
AttendanceEntity entity = new AttendanceEntity();
|
|
|
if (primaryKey == null) {
|
|
|
entity.setUnicode(attendance.getUnicode());
|
|
|
@@ -365,13 +379,19 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public boolean clearAttendance(List<AttendanceDto> attendanceList) {
|
|
|
if (CollectionUtil.isEmpty(attendanceList)) {
|
|
|
throw new ServiceException("参数不能为空");
|
|
|
}
|
|
|
int affectNum = 0;
|
|
|
- for (AttendanceDto entity : attendanceList) {
|
|
|
- affectNum += baseMapper.clearUnicodeAndMonthly(entity.getUnicode(), entity.getYearAndMonth());
|
|
|
+ for (AttendanceDto dto : attendanceList) {
|
|
|
+ //获取已填报的工时的不能删除
|
|
|
+ double workHoursByMonth = technicianHoursMapper.sumByUnicodeAndMonth(dto.getUnicode(), dto.getYearAndMonth());
|
|
|
+ if(workHoursByMonth > 0){
|
|
|
+ throw new ServiceException("已填报工时数据,无法清除工时数据,请联系管理员");
|
|
|
+ }
|
|
|
+ affectNum += baseMapper.clearUnicodeAndMonthly(dto.getUnicode(), dto.getYearAndMonth());
|
|
|
}
|
|
|
return affectNum >= 0;
|
|
|
}
|
|
|
@@ -405,8 +425,14 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public boolean deleteAttendance(List<AttendanceDto> attendanceList) {
|
|
|
for (AttendanceDto dto : attendanceList) {
|
|
|
+ //获取已填报的工时的不能删除
|
|
|
+ double workHoursByMonth = technicianHoursMapper.sumByUnicodeAndMonth(dto.getUnicode(), dto.getYearAndMonth());
|
|
|
+ if(workHoursByMonth > 0){
|
|
|
+ throw new ServiceException("已填报工时数据,无法删除,请联系管理员");
|
|
|
+ }
|
|
|
baseMapper.deleteByUnicodeAndMonthly(dto.getUnicode(), dto.getYearAndMonth());
|
|
|
}
|
|
|
return true;
|