|
@@ -914,14 +914,67 @@ public class SopUserLogsServiceImpl implements ISopUserLogsService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void updateLogDate(UpdateSopUserLogDateVo vo) {
|
|
|
|
|
|
|
+ public R updateLogDate(UpdateSopUserLogDateVo vo) {
|
|
|
if(vo.getDate() == null){
|
|
if(vo.getDate() == null){
|
|
|
throw new BaseException("修改时间不能为空");
|
|
throw new BaseException("修改时间不能为空");
|
|
|
}
|
|
}
|
|
|
if(vo.getIds() == null || vo.getIds().isEmpty()){
|
|
if(vo.getIds() == null || vo.getIds().isEmpty()){
|
|
|
throw new BaseException("营期ID不能为空");
|
|
throw new BaseException("营期ID不能为空");
|
|
|
}
|
|
}
|
|
|
- sopUserLogsMapper.updateSopuserLogsDateById(vo);
|
|
|
|
|
|
|
+// sopUserLogsMapper.updateSopuserLogsDateById(vo);
|
|
|
|
|
+ List<SopUserLogs> sopUserLogs = sopUserLogsMapper.selectSopUserLogsListByIds(vo.getIds());
|
|
|
|
|
+ LocalDate date = vo.getDate();
|
|
|
|
|
+ String targetDateStr = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
|
+
|
|
|
|
|
+ // 记录需要剔除的重复ID
|
|
|
|
|
+ List<String> duplicateIds = new ArrayList<>();
|
|
|
|
|
+ List<String> validIds = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 检查是否存在相同组合的数据
|
|
|
|
|
+ for (SopUserLogs log : sopUserLogs) {
|
|
|
|
|
+ boolean isDuplicate = checkDuplicateCombination(log, sopUserLogs, targetDateStr);
|
|
|
|
|
+ if (isDuplicate) {
|
|
|
|
|
+ duplicateIds.add(log.getId());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ validIds.add(log.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 更新有效记录
|
|
|
|
|
+ if (!validIds.isEmpty()) {
|
|
|
|
|
+ vo.setIds(validIds);
|
|
|
|
|
+ sopUserLogsMapper.updateSopuserLogsDateById(vo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 记录剔除的重复ID
|
|
|
|
|
+ if (!duplicateIds.isEmpty()) {
|
|
|
|
|
+ log.error("根据sopId、qwUserId、corpId、startTime组合检查,剔除重复ID: {},时间:{}", duplicateIds,targetDateStr);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return R.ok().put("data",duplicateIds);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 检查是否存在相同组合的数据
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean checkDuplicateCombination(SopUserLogs currentLog, List<SopUserLogs> allLogs, String targetDate) {
|
|
|
|
|
+ for (SopUserLogs log : allLogs) {
|
|
|
|
|
+ // 跳过自身比较
|
|
|
|
|
+ if (log.getId().equals(currentLog.getId())) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 检查组合是否相同 - 直接比较字符串
|
|
|
|
|
+ boolean sameCombination = Objects.equals(log.getSopId(), currentLog.getSopId()) &&
|
|
|
|
|
+ Objects.equals(log.getQwUserId(), currentLog.getQwUserId()) &&
|
|
|
|
|
+ Objects.equals(log.getCorpId(), currentLog.getCorpId()) &&
|
|
|
|
|
+ targetDate.equals(log.getStartTime()); // 直接比较字符串
|
|
|
|
|
+
|
|
|
|
|
+ if (sameCombination) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|