|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.sop.business.bean.dto.DataPermissionDto;
|
|
|
import com.qmth.sop.business.bean.dto.DateFormDto;
|
|
|
+import com.qmth.sop.business.bean.dto.RegionCoordinatorDingTimeDto;
|
|
|
import com.qmth.sop.business.bean.dto.SopCrmInfo;
|
|
|
import com.qmth.sop.business.bean.params.DingSaveParam;
|
|
|
import com.qmth.sop.business.bean.result.*;
|
|
@@ -90,18 +91,25 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
private TBCrmDetailService tbCrmDetailService;
|
|
|
|
|
|
@Override
|
|
|
- public DingElementResult findDingElements(String sopNo, Long userId) {
|
|
|
-
|
|
|
- SopCrmInfo sopCrmInfo = tbCrmService.findSopCrmInfoBySop(sopNo);
|
|
|
- if (Objects.isNull(sopCrmInfo)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("未找到sop单号为[%s]的派单信息", sopNo));
|
|
|
+ public DingElementResult findDingElements(Long serviceId, String sopNo, Long userId) {
|
|
|
+ if (SystemConstant.strNotNull(sopNo)) {
|
|
|
+ SopCrmInfo sopCrmInfo = tbCrmService.findSopCrmInfoBySop(sopNo);
|
|
|
+ if (Objects.isNull(sopCrmInfo)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("未找到sop单号为[%s]的派单信息", sopNo));
|
|
|
+ }
|
|
|
}
|
|
|
- DingElementResult dingElementResult = this.findDingRule(userId, sopNo);
|
|
|
+
|
|
|
+ DingElementResult dingElementResult = this.findDingRule(userId, serviceId);
|
|
|
if (Objects.nonNull(dingElementResult)) {
|
|
|
Long userArchivesId = dingElementResult.getUserArchivesId();
|
|
|
String currentDayStr = DateFormatUtils.format(System.currentTimeMillis(), SystemConstant.DEFAULT_DATE_DAY_PATTERN);
|
|
|
- List<TBDing> tbDingList = this.list(new QueryWrapper<TBDing>().lambda().eq(TBDing::getSopNo, sopNo)
|
|
|
- .eq(TBDing::getUserArchivesId, userArchivesId).eq(TBDing::getSignDate, currentDayStr));
|
|
|
+ QueryWrapper<TBDing> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(TBDing::getServiceId, serviceId).eq(TBDing::getUserArchivesId, userArchivesId).eq(TBDing::getSignDate, currentDayStr);
|
|
|
+ if (SystemConstant.strNotNull(sopNo)) {
|
|
|
+ queryWrapper.lambda().eq(TBDing::getSopNo, sopNo);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TBDing> tbDingList = this.list(queryWrapper);
|
|
|
if (CollectionUtils.isNotEmpty(tbDingList)) {
|
|
|
// 有考勤记录
|
|
|
if (tbDingList.size() > 1) {
|
|
@@ -124,7 +132,7 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public DingStatisticResult findDingStatistic(String sopNo, Long userId) {
|
|
|
+ public DingStatisticResult findDingStatistic(Long serviceId, String sopNo, Long userId) {
|
|
|
// 截取年分割截止
|
|
|
final int yearEnd = 4;
|
|
|
// 截取日分割开始
|
|
@@ -138,9 +146,13 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
int exceptionCount = 0;
|
|
|
List<DingFormResult> formList = new ArrayList<>();
|
|
|
if (CollectionUtils.isNotEmpty(dateFormList)) {
|
|
|
+ QueryWrapper<TBDing> dingQueryWrapper = new QueryWrapper<>();
|
|
|
+ dingQueryWrapper.lambda().eq(TBDing::getServiceId, serviceId).eq(TBDing::getUserId, userId).orderByAsc(TBDing::getId);
|
|
|
+ if (SystemConstant.strNotNull(sopNo)) {
|
|
|
+ dingQueryWrapper.lambda().eq(TBDing::getSopNo, sopNo);
|
|
|
+ }
|
|
|
|
|
|
- List<TBDing> tbDingList = this.list(
|
|
|
- new QueryWrapper<TBDing>().lambda().eq(TBDing::getSopNo, sopNo).eq(TBDing::getUserId, userId).orderByAsc(TBDing::getId));
|
|
|
+ List<TBDing> tbDingList = this.list(dingQueryWrapper);
|
|
|
|
|
|
// 签到表
|
|
|
List<DingFormResult> formDingList = new ArrayList<>();
|
|
@@ -158,7 +170,7 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
if (signInTime == null || signInTime == 0) {
|
|
|
signInInfo.setStatus(DingStatusEnum.NO_SIGN);
|
|
|
} else {
|
|
|
- if (sopNo.equals(dingSopNo)) {
|
|
|
+ if (Objects.equals(sopNo, dingSopNo)) {
|
|
|
signInInfo.setStatus(DingStatusEnum.SIGN);
|
|
|
} else {
|
|
|
signInInfo.setStatus(DingStatusEnum.OTHER);
|
|
@@ -179,7 +191,7 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
if (signOutTime == null || signOutTime == 0) {
|
|
|
signOutInfo.setStatus(DingStatusEnum.NO_SIGN);
|
|
|
} else {
|
|
|
- if (sopNo.equals(dingSopNo)) {
|
|
|
+ if (Objects.equals(sopNo, dingSopNo)) {
|
|
|
signOutInfo.setStatus(DingStatusEnum.SIGN);
|
|
|
} else {
|
|
|
signOutInfo.setStatus(DingStatusEnum.OTHER);
|
|
@@ -202,6 +214,7 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
String endDate = dateFormDto.getEndDate();
|
|
|
endDate = endDate.substring(dayStart);
|
|
|
|
|
|
+ // TODO: 2024/9/4 更改补卡记录
|
|
|
// 查询正在补卡中的记录
|
|
|
List<TBDingApply> resigningList = tbDingApplyService.list(
|
|
|
new QueryWrapper<TBDingApply>().lambda().select(TBDingApply::getType, TBDingApply::getApplyTime).eq(TBDingApply::getSopNo, sopNo).eq(TBDingApply::getCreateId, userId)
|
|
@@ -288,23 +301,46 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
|
|
|
@Override
|
|
|
public void dingSave(DingSaveParam dingSaveParam, Long userId) throws IOException {
|
|
|
+ boolean isCoordinator = tbUserArchivesService.containsRegionCoordinator(userId);
|
|
|
+ Long serviceId = dingSaveParam.getServiceId();
|
|
|
String sopNo = dingSaveParam.getSopNo();
|
|
|
- SopCrmInfo sopCrmInfo = tbCrmService.findSopCrmInfoBySop(sopNo);
|
|
|
- if (Objects.isNull(sopCrmInfo)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("未找到sop单号为[%s]的派单信息", sopNo));
|
|
|
+ String crmNo = null;
|
|
|
+ Long flowId = null;
|
|
|
+ List<SopRoleTypeEnum> roleType = new ArrayList<>();
|
|
|
+ if (SystemConstant.strNotNull(sopNo)) {
|
|
|
+ SopCrmInfo sopCrmInfo = tbCrmService.findSopCrmInfoBySop(sopNo);
|
|
|
+ if (Objects.isNull(sopCrmInfo)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("未找到sop单号为[%s]的派单信息", sopNo));
|
|
|
+ }
|
|
|
+ crmNo = sopCrmInfo.getCrmNo();
|
|
|
+ flowId = sopCrmInfo.getFlowId();
|
|
|
+ roleType = tbUserArchivesAllocationService.findSopRoleTypeByUserSopNo(userId, sopNo);
|
|
|
+ if (CollectionUtils.isEmpty(roleType)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到用户在当前sop的身份信息");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!isCoordinator) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("非区域协调人,必须选择sop");
|
|
|
+ }
|
|
|
+ roleType.add(SopRoleTypeEnum.REGION_COORDINATOR);
|
|
|
}
|
|
|
|
|
|
- DingElementResult dingElementResult = this.findDingRule(userId, sopNo);
|
|
|
+ DingElementResult dingElementResult = this.findDingRule(userId, serviceId);
|
|
|
if (Objects.isNull(dingElementResult)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("未能获取考勤相关规则");
|
|
|
}
|
|
|
|
|
|
Long signTime = dingSaveParam.getSignTime();
|
|
|
- TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(sopNo);
|
|
|
- Long scanStartTime = tbCrmDetail.getScanStartTime();
|
|
|
- Long scanEndTime = tbCrmDetail.getScanEndTime();
|
|
|
- Long markPaperStartTime = tbCrmDetail.getMarkPaperStartTime();
|
|
|
- Long markPaperEndTime = tbCrmDetail.getMarkPaperEndTime();
|
|
|
+ if (isCoordinator) {
|
|
|
+ RegionCoordinatorDingTimeDto dingTimeDto = this.findRegionCoordinatorDingTime();
|
|
|
+ Long startTime = dingTimeDto.getStartTime();
|
|
|
+ Long endTime = dingTimeDto.getEndTime();
|
|
|
+ if (signTime < startTime || signTime > endTime) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(
|
|
|
+ String.format("区域协调人请在%s - %s打卡", DateFormatUtils.format(startTime, "yyyy/MM/dd"),
|
|
|
+ DateFormatUtils.format(endTime, "yyyy/MM/dd")));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
DingDateTypeEnum dateType = sysDingDateService.getDingDateType(DateDisposeUtils.timestampToLocalDate(signTime));
|
|
|
|
|
@@ -345,13 +381,6 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
facePass = score.compareTo(limit) > -1;
|
|
|
}
|
|
|
|
|
|
- String crmNo = sopCrmInfo.getCrmNo();
|
|
|
- Long serviceId = sopCrmInfo.getServiceUnitId();
|
|
|
- Long flowId = sopCrmInfo.getFlowId();
|
|
|
- List<SopRoleTypeEnum> roleType = tbUserArchivesAllocationService.findSopRoleTypeByUserSopNo(userId, sopNo);
|
|
|
- if (CollectionUtils.isEmpty(roleType)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("未找到用户在当前sop的身份信息");
|
|
|
- }
|
|
|
String signDate = DateFormatUtils.format(signTime, SystemConstant.DEFAULT_DATE_DAY_PATTERN);
|
|
|
String signYear = DateFormatUtils.format(signTime, SystemConstant.DEFAULT_DATE_YEAR_PATTERN);
|
|
|
String currentDayStr = DateFormatUtils.format(System.currentTimeMillis(), SystemConstant.DEFAULT_DATE_DAY_PATTERN);
|
|
@@ -362,7 +391,13 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
List<TBDing> todayDingList = this.list(
|
|
|
new QueryWrapper<TBDing>().lambda().eq(TBDing::getUserId, userId).eq(TBDing::getSignYear, signYear).eq(TBDing::getSignDate, signDate));
|
|
|
// 该用户在其他sop的当天打卡记录
|
|
|
- List<TBDing> otherSopDingList = todayDingList.stream().filter(e -> !e.getSopNo().equals(sopNo)).collect(Collectors.toList());
|
|
|
+ List<TBDing> otherSopDingList;
|
|
|
+ if (isCoordinator) {
|
|
|
+ otherSopDingList = todayDingList.stream().filter(e -> !e.getServiceId().equals(serviceId)).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ otherSopDingList = todayDingList.stream().filter(e -> !e.getSopNo().equals(sopNo)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
if (CollectionUtils.isNotEmpty(otherSopDingList)) {
|
|
|
List<TBDing> unFinishDingList = otherSopDingList.stream()
|
|
|
.filter(e -> !SystemConstant.longNotNull(e.getSignInTime()) || !SystemConstant.longNotNull(e.getSignOutTime())).collect(Collectors.toList());
|
|
@@ -392,8 +427,12 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
log.error("人脸识别不通过,score :" + score);
|
|
|
throw ExceptionResultEnum.ERROR.exception("人脸识别不通过!");
|
|
|
}
|
|
|
-
|
|
|
- List<TBDing> tbDingList = todayDingList.stream().filter(e -> e.getSopNo().equals(sopNo)).collect(Collectors.toList());
|
|
|
+ List<TBDing> tbDingList;
|
|
|
+ if (isCoordinator) {
|
|
|
+ tbDingList = todayDingList.stream().filter(e -> e.getServiceId().equals(serviceId)).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ tbDingList = todayDingList.stream().filter(e -> e.getSopNo().equals(sopNo)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
if (CollectionUtils.isEmpty(tbDingList)) {
|
|
|
// 没有这天的打卡记录 - 新增打卡记录
|
|
|
TBDing tbDing = new TBDing();
|
|
@@ -447,16 +486,6 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
tbDing.setFaceOutPass(facePass);
|
|
|
break;
|
|
|
}
|
|
|
- Long signInTime = tbDing.getSignInTime();
|
|
|
- Long signOutTime = tbDing.getSignOutTime();
|
|
|
- if (signInTime != null && signInTime > 0 && signOutTime != null && signOutTime > 0) {
|
|
|
- // 打卡异常 (两个打卡时间均不在时间点 -> 异常)
|
|
|
- boolean signInException = !((scanStartTime <= signInTime && signInTime <= scanEndTime) || (
|
|
|
- markPaperStartTime <= signInTime && signInTime <= markPaperEndTime));
|
|
|
- boolean signOutException = !((scanStartTime <= signOutTime && signOutTime <= scanEndTime) || (
|
|
|
- markPaperStartTime <= signOutTime && signOutTime <= markPaperEndTime));
|
|
|
- tbDing.setDingException(signInException && signOutException);
|
|
|
- }
|
|
|
this.updateById(tbDing);
|
|
|
}
|
|
|
}
|
|
@@ -566,11 +595,11 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
public DateFormDto buildSignDateFormBySop(String sopNo) {
|
|
|
DateFormDto result = new DateFormDto();
|
|
|
List<String> dateList = new ArrayList<>();
|
|
|
+ long currentTime = System.currentTimeMillis();
|
|
|
if (sopNo != null && sopNo.length() > 0) {
|
|
|
TFFlowApprove tfFlowApprove = this.findFlowApproveBySopNo(sopNo);
|
|
|
FlowStatusEnum flowStatusEnum = tfFlowApprove.getStatus();
|
|
|
Long updateTime = tfFlowApprove.getUpdateTime();
|
|
|
- Long currentTime = System.currentTimeMillis();
|
|
|
|
|
|
TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(sopNo);
|
|
|
if (Objects.isNull(tbCrmDetail)) {
|
|
@@ -587,7 +616,16 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
}
|
|
|
dateList.sort(Collections.reverseOrder());
|
|
|
result.setDateFormList(dateList);
|
|
|
-
|
|
|
+ } else {
|
|
|
+ // 区协固定打卡时间
|
|
|
+ RegionCoordinatorDingTimeDto dingTimeDto = this.findRegionCoordinatorDingTime();
|
|
|
+ Long startTime = dingTimeDto.getStartTime();
|
|
|
+ if (currentTime < startTime) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ Long endTime = dingTimeDto.getEndTime();
|
|
|
+ result.setDateFormList(DateDisposeUtils.getDaysBetween(startTime, Math.min(currentTime, endTime),
|
|
|
+ SystemConstant.DEFAULT_DATE_YMD_S_PATTERN));
|
|
|
}
|
|
|
if (CollectionUtils.isNotEmpty(dateList)) {
|
|
|
result.setEndDate(dateList.get(0));
|
|
@@ -599,7 +637,11 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
public DingElementResult findDingRule(Long userId, String sopNo) {
|
|
|
SopCrmInfo sopCrmInfo = tbCrmService.findSopCrmInfoBySop(sopNo);
|
|
|
Long serviceUnitId = sopCrmInfo.getServiceUnitId();
|
|
|
+ return this.findDingRule(userId, serviceUnitId);
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public DingElementResult findDingRule(Long userId, Long serviceUnitId) {
|
|
|
List<DingElementResult> dingElementResultList = this.baseMapper.findDingResultByUserId(userId, serviceUnitId);
|
|
|
List<Long> dingGroupIds = dingElementResultList.stream().map(DingElementResult::getDingGroupId).distinct().collect(Collectors.toList());
|
|
|
|
|
@@ -756,4 +798,13 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
|
}
|
|
|
return tfFlowApproves.get(0);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RegionCoordinatorDingTimeDto findRegionCoordinatorDingTime() {
|
|
|
+ SysConfig sysConfig = sysConfigService.findByConfigKey(SystemConstant.REGION_COORDINATOR_DING_TIME);
|
|
|
+ if (Objects.isNull(sysConfig)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("缺少区域协调人打卡时间段");
|
|
|
+ }
|
|
|
+ return JSON.parseObject(sysConfig.getConfigValue(), RegionCoordinatorDingTimeDto.class);
|
|
|
+ }
|
|
|
}
|