|
@@ -17,10 +17,7 @@ import org.sky.core.tool.utils.Func;
|
|
|
import org.sky.core.tool.utils.StringUtil;
|
|
import org.sky.core.tool.utils.StringUtil;
|
|
|
import org.sky.scientific.excel.XmTechnicianHoursExcel;
|
|
import org.sky.scientific.excel.XmTechnicianHoursExcel;
|
|
|
import org.sky.scientific.excel.XmTechnicianHoursListener;
|
|
import org.sky.scientific.excel.XmTechnicianHoursListener;
|
|
|
-import org.sky.scientific.mapper.AttendanceMapper;
|
|
|
|
|
-import org.sky.scientific.mapper.XmMapper;
|
|
|
|
|
-import org.sky.scientific.mapper.XmTechnicianHoursMapper;
|
|
|
|
|
-import org.sky.scientific.mapper.XmTechnicianMapper;
|
|
|
|
|
|
|
+import org.sky.scientific.mapper.*;
|
|
|
import org.sky.scientific.pojo.entity.XmTechnicianHours;
|
|
import org.sky.scientific.pojo.entity.XmTechnicianHours;
|
|
|
import org.sky.scientific.pojo.vo.DailyAttendance;
|
|
import org.sky.scientific.pojo.vo.DailyAttendance;
|
|
|
import org.sky.scientific.pojo.vo.XmTechnicianHoursVO;
|
|
import org.sky.scientific.pojo.vo.XmTechnicianHoursVO;
|
|
@@ -47,6 +44,7 @@ public class XmTechnicianHoursServiceImpl extends BaseServiceImpl<XmTechnicianHo
|
|
|
private final XmMapper xmMapper;
|
|
private final XmMapper xmMapper;
|
|
|
private final XmTechnicianMapper xmTechnicianMapper;
|
|
private final XmTechnicianMapper xmTechnicianMapper;
|
|
|
private final AttendanceMapper attendanceMapper;
|
|
private final AttendanceMapper attendanceMapper;
|
|
|
|
|
+ private final TechnicianMapper technicianMapper;
|
|
|
|
|
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -100,7 +98,7 @@ public class XmTechnicianHoursServiceImpl extends BaseServiceImpl<XmTechnicianHo
|
|
|
if (technicianMap.containsKey(techniciankey)) {
|
|
if (technicianMap.containsKey(techniciankey)) {
|
|
|
unicode = technicianMap.get(techniciankey);
|
|
unicode = technicianMap.get(techniciankey);
|
|
|
} else {
|
|
} else {
|
|
|
- unicode = xmTechnicianMapper.countByXmIdAndNumberAndIdCardAndYearMonth(xmId, record.getNumber(), record.getIdCard(), yearAndMonth);
|
|
|
|
|
|
|
+ unicode = technicianMapper.getUnicodeByNumberAndIdentityCard(record.getNumber(), record.getIdCard());
|
|
|
if (unicode == null) {
|
|
if (unicode == null) {
|
|
|
throw new ServiceException("序号为[" + record.getSerialNumber() + "]的研发人员不存在");
|
|
throw new ServiceException("序号为[" + record.getSerialNumber() + "]的研发人员不存在");
|
|
|
}
|
|
}
|
|
@@ -121,16 +119,24 @@ public class XmTechnicianHoursServiceImpl extends BaseServiceImpl<XmTechnicianHo
|
|
|
Map<String, Double> hoursByDateMap = dailyAttendanceList.stream().collect(Collectors.groupingBy(DailyAttendance::getWorkDate, Collectors.summingDouble(DailyAttendance::getWorkHours)));
|
|
Map<String, Double> hoursByDateMap = dailyAttendanceList.stream().collect(Collectors.groupingBy(DailyAttendance::getWorkDate, Collectors.summingDouble(DailyAttendance::getWorkHours)));
|
|
|
|
|
|
|
|
//按人员筛选、根据日期分组,再对工时求和
|
|
//按人员筛选、根据日期分组,再对工时求和
|
|
|
- Map<String, Double> usedByUnicodeAndDateMap = dbList.stream().filter(e -> e.getUnicode().equals(finalUnicode)).collect(Collectors.groupingBy(XmTechnicianHours::getWorkDate, Collectors.summingDouble(XmTechnicianHours::getWorkHours)));
|
|
|
|
|
|
|
+ Map<String, Double> usedByUnicodeAndDateMap = dbList.stream().filter(e -> e.getUnicode().equals(finalUnicode)).collect(Collectors.groupingBy(XmTechnicianHours::getWorkDate, Collectors.summingDouble(XmTechnicianHours::getWorkHours)));
|
|
|
|
|
|
|
|
for (DailyAttendance dailyAttendance : record.getDailyAttendances()) {
|
|
for (DailyAttendance dailyAttendance : record.getDailyAttendances()) {
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Double hoursTotal = hoursByDateMap.get(dailyAttendance.getWorkDate());
|
|
|
|
|
+ if (hoursTotal == null || hoursTotal <= 0) {
|
|
|
|
|
+ throw new ServiceException(dailyAttendance.getWorkDate() + "当天无考勤数据");
|
|
|
|
|
+ }
|
|
|
Double usedHours = usedByUnicodeAndDateMap.get(dailyAttendance.getWorkDate());
|
|
Double usedHours = usedByUnicodeAndDateMap.get(dailyAttendance.getWorkDate());
|
|
|
- if (hoursByDateMap.get(dailyAttendance.getWorkDate()) - usedHours < dailyAttendance.getWorkHours()) {
|
|
|
|
|
|
|
+ if(usedHours==null){
|
|
|
|
|
+ usedHours = 0.0;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (hoursTotal - usedHours < dailyAttendance.getWorkHours()) {
|
|
|
//当 考勤时长 - 当天以用工时 < 新的工时 ,则提示“考勤时长不足”
|
|
//当 考勤时长 - 当天以用工时 < 新的工时 ,则提示“考勤时长不足”
|
|
|
- throw new ServiceException("考勤总时长为" + hoursByDateMap.get(dailyAttendance.getWorkDate()) + "小时,工时已用" + usedHours + "小时,请核对数据");
|
|
|
|
|
|
|
+ throw new ServiceException("[序号"+record.getSerialNumber()+",日期"+dailyAttendance.getWorkDate()+"工时"+dailyAttendance.getWorkHours()+"]的考勤时长不足,出勤总时长" + hoursTotal + ",已用" + usedHours + ",可用"+(hoursTotal-usedHours)+",请核对数据");
|
|
|
}
|
|
}
|
|
|
- List<Long> primaryKeyList = byXmAndUnicodeList.stream().filter(e -> Objects.equals(e.getWorkDate(), dailyAttendance.getWorkDate()) && Objects.equals(e.getXmId(), finalXmId) && Objects.equals(e.getUnicode(), finalUnicode)).map(XmTechnicianHours::getId).toList();
|
|
|
|
|
|
|
+ List<Long> primaryKeyList = byXmAndUnicodeList.stream().filter(e -> Objects.equals(e.getWorkDate(), dailyAttendance.getWorkDate()) && Objects.equals(e.getXmId(), finalXmId) && Objects.equals(e.getUnicode(), finalUnicode)).map(XmTechnicianHours::getId).toList();
|
|
|
Long primaryKey = CollectionUtil.isEmpty(primaryKeyList) ? null : primaryKeyList.get(0);
|
|
Long primaryKey = CollectionUtil.isEmpty(primaryKeyList) ? null : primaryKeyList.get(0);
|
|
|
XmTechnicianHours entity = new XmTechnicianHours();
|
|
XmTechnicianHours entity = new XmTechnicianHours();
|
|
|
if (primaryKey == null) {
|
|
if (primaryKey == null) {
|
|
@@ -219,6 +225,9 @@ public class XmTechnicianHoursServiceImpl extends BaseServiceImpl<XmTechnicianHo
|
|
|
for (DailyAttendance dailyAttendance : dto.getDailyAttendances()) {
|
|
for (DailyAttendance dailyAttendance : dto.getDailyAttendances()) {
|
|
|
//查询一天的考勤时长
|
|
//查询一天的考勤时长
|
|
|
double attendanceHours = dailyAttendanceList.stream().filter(e -> Objects.equals(e.getWorkDate(), dailyAttendance.getWorkDate())).mapToDouble(DailyAttendance::getWorkHours).sum();
|
|
double attendanceHours = dailyAttendanceList.stream().filter(e -> Objects.equals(e.getWorkDate(), dailyAttendance.getWorkDate())).mapToDouble(DailyAttendance::getWorkHours).sum();
|
|
|
|
|
+ if (attendanceHours <= 0) {
|
|
|
|
|
+ throw new ServiceException(dailyAttendance.getWorkDate() + "当天无考勤数据");
|
|
|
|
|
+ }
|
|
|
//查询一天所有项目的工时总和
|
|
//查询一天所有项目的工时总和
|
|
|
double hoursTotal = dbList.stream().filter(e -> Objects.equals(e.getWorkDate(), dailyAttendance.getWorkDate())).mapToDouble(XmTechnicianHours::getWorkHours).sum();
|
|
double hoursTotal = dbList.stream().filter(e -> Objects.equals(e.getWorkDate(), dailyAttendance.getWorkDate())).mapToDouble(XmTechnicianHours::getWorkHours).sum();
|
|
|
|
|
|