|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.qmth.sop.business.bean.dto.DataPermissionDto;
|
|
import com.qmth.sop.business.bean.dto.DataPermissionDto;
|
|
import com.qmth.sop.business.bean.dto.DateFormDto;
|
|
import com.qmth.sop.business.bean.dto.DateFormDto;
|
|
|
|
+import com.qmth.sop.business.bean.dto.RoleDto;
|
|
import com.qmth.sop.business.bean.dto.SopCrmInfo;
|
|
import com.qmth.sop.business.bean.dto.SopCrmInfo;
|
|
import com.qmth.sop.business.bean.params.DingSaveParam;
|
|
import com.qmth.sop.business.bean.params.DingSaveParam;
|
|
import com.qmth.sop.business.bean.result.*;
|
|
import com.qmth.sop.business.bean.result.*;
|
|
@@ -62,6 +63,8 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
private TBDingHistoryService tbDingHistoryService;
|
|
private TBDingHistoryService tbDingHistoryService;
|
|
@Resource
|
|
@Resource
|
|
private SysUserService sysUserService;
|
|
private SysUserService sysUserService;
|
|
|
|
+ @Resource
|
|
|
|
+ private SysDingObjService sysDingObjService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public DingElementResult findDingElements(String sopNo, Long userId) {
|
|
public DingElementResult findDingElements(String sopNo, Long userId) {
|
|
@@ -69,7 +72,7 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
SopCrmInfo sopCrmInfo = tbCrmService.findSopCrmInfoBySop(sopNo);
|
|
SopCrmInfo sopCrmInfo = tbCrmService.findSopCrmInfoBySop(sopNo);
|
|
Long serviceUnitId = sopCrmInfo.getServiceUnitId();
|
|
Long serviceUnitId = sopCrmInfo.getServiceUnitId();
|
|
|
|
|
|
- DingElementResult dingElementResult = this.baseMapper.findDingResultByUserId(userId, serviceUnitId);
|
|
|
|
|
|
+ DingElementResult dingElementResult = this.findDingRule(userId, serviceUnitId);
|
|
if (Objects.nonNull(dingElementResult)) {
|
|
if (Objects.nonNull(dingElementResult)) {
|
|
Long userArchivesId = dingElementResult.getUserArchivesId();
|
|
Long userArchivesId = dingElementResult.getUserArchivesId();
|
|
String currentDayStr = DateFormatUtils.format(System.currentTimeMillis(), SystemConstant.DEFAULT_DATE_DAY_PATTERN);
|
|
String currentDayStr = DateFormatUtils.format(System.currentTimeMillis(), SystemConstant.DEFAULT_DATE_DAY_PATTERN);
|
|
@@ -217,17 +220,11 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
formList.add(dingFormResult);
|
|
formList.add(dingFormResult);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- SopCrmInfo sopCrmInfo = tbCrmService.findSopCrmInfoBySop(sopNo);
|
|
|
|
- Long serviceUnitId = sopCrmInfo.getServiceUnitId();
|
|
|
|
- DingElementResult dingElementResult = this.baseMapper.findDingResultByUserId(userId, serviceUnitId);
|
|
|
|
- int reissueCardCount = dingElementResult != null ? dingElementResult.getReissueCardCount() : 0;
|
|
|
|
- int applyCount = this.baseMapper.findDingExceptionApplyCount(userId, sopNo);
|
|
|
|
-
|
|
|
|
DingStatisticResult dingStatisticResult = new DingStatisticResult();
|
|
DingStatisticResult dingStatisticResult = new DingStatisticResult();
|
|
dingStatisticResult.setDingFormList(formList);
|
|
dingStatisticResult.setDingFormList(formList);
|
|
dingStatisticResult.setWorkDays(workCount);
|
|
dingStatisticResult.setWorkDays(workCount);
|
|
dingStatisticResult.setExceptionCount(exceptionCount);
|
|
dingStatisticResult.setExceptionCount(exceptionCount);
|
|
- dingStatisticResult.setRemainCount(reissueCardCount != 0 ? reissueCardCount - applyCount : 0);
|
|
|
|
|
|
+ dingStatisticResult.setRemainCount(this.findRemainCount(userId, sopNo));
|
|
return dingStatisticResult;
|
|
return dingStatisticResult;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -236,7 +233,10 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
String sopNo = dingSaveParam.getSopNo();
|
|
String sopNo = dingSaveParam.getSopNo();
|
|
SopCrmInfo sopCrmInfo = tbCrmService.findSopCrmInfoBySop(sopNo);
|
|
SopCrmInfo sopCrmInfo = tbCrmService.findSopCrmInfoBySop(sopNo);
|
|
Long serviceUnitId = sopCrmInfo.getServiceUnitId();
|
|
Long serviceUnitId = sopCrmInfo.getServiceUnitId();
|
|
- DingElementResult dingElementResult = this.baseMapper.findDingResultByUserId(userId, serviceUnitId);
|
|
|
|
|
|
+ DingElementResult dingElementResult = this.findDingRule(userId, serviceUnitId);
|
|
|
|
+ if (Objects.isNull(dingElementResult)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未能获取考勤相关规则");
|
|
|
|
+ }
|
|
|
|
|
|
Long signTime = dingSaveParam.getSignTime();
|
|
Long signTime = dingSaveParam.getSignTime();
|
|
DingDateTypeEnum dateType = sysDingDateService.getDingDateType(DateDisposeUtils.timestampToLocalDate(signTime));
|
|
DingDateTypeEnum dateType = sysDingDateService.getDingDateType(DateDisposeUtils.timestampToLocalDate(signTime));
|
|
@@ -469,4 +469,49 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public DingElementResult findDingRule(Long userId, Long serviceUnitId) {
|
|
|
|
+ List<Long> roleIdList = sysRoleService.listRolesByUserId(userId).stream().map(RoleDto::getId).distinct().collect(Collectors.toList());
|
|
|
|
+ if (CollectionUtils.isEmpty(roleIdList)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("用户缺少角色");
|
|
|
|
+ }
|
|
|
|
+ List<DingElementResult> dingElementResultList = this.baseMapper.findDingResultByUserId(userId, serviceUnitId);
|
|
|
|
+ List<Long> dingGroupIds = dingElementResultList.stream().map(DingElementResult::getDingGroupId).distinct().collect(Collectors.toList());
|
|
|
|
+ if (CollectionUtils.isEmpty(dingGroupIds)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("缺少考勤组id");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<SysDingObj> sysDingObjList = sysDingObjService.list(new QueryWrapper<SysDingObj>()
|
|
|
|
+ .lambda()
|
|
|
|
+ .in(SysDingObj::getDingGroupId, dingGroupIds)
|
|
|
|
+ .in(SysDingObj::getRoleId, roleIdList)
|
|
|
|
+ .eq(SysDingObj::getType, DingObjTypeEnum.DING));
|
|
|
|
+
|
|
|
|
+ if (CollectionUtils.isNotEmpty(sysDingObjList) && sysDingObjList.size() == 1) {
|
|
|
|
+ dingElementResultList = dingElementResultList
|
|
|
|
+ .stream()
|
|
|
|
+ .filter(e -> e.getDingGroupId()
|
|
|
|
+ .equals(sysDingObjList.get(0).getDingGroupId()))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ if (dingElementResultList.size() == 1) {
|
|
|
|
+ return dingElementResultList.get(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public int findRemainCount(Long userId, String sopNo) {
|
|
|
|
+ // TODO: 2023/11/8 查明为什么会有sop找不到对应的派单
|
|
|
|
+ SopCrmInfo sopCrmInfo = tbCrmService.findSopCrmInfoBySop(sopNo);
|
|
|
|
+ if (Objects.isNull(sopCrmInfo)){
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Long serviceUnitId = sopCrmInfo.getServiceUnitId();
|
|
|
|
+ DingElementResult dingElementResult = this.findDingRule(userId, serviceUnitId);
|
|
|
|
+ int reissueCardCount = dingElementResult != null ? dingElementResult.getReissueCardCount() : 0;
|
|
|
|
+ int applyCount = this.baseMapper.findDingExceptionApplyCount(userId, sopNo);
|
|
|
|
+ return reissueCardCount != 0 ? reissueCardCount - applyCount : 0;
|
|
|
|
+ }
|
|
}
|
|
}
|