|
@@ -10,15 +10,16 @@ import com.galaxis.manatee.dao.ChuanyunWeekMemberHourDao;
|
|
|
import com.galaxis.manatee.dao.ChuanyunWorkHourDao;
|
|
|
import com.galaxis.manatee.entity.chuanyun.data.object.*;
|
|
|
import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunFindAllBizDTO;
|
|
|
+import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunFindAllBizReturnData;
|
|
|
import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunSaveDTO;
|
|
|
import com.galaxis.manatee.entity.chuanyun.dto.Filter;
|
|
|
import com.galaxis.manatee.manager.ChuanYunManager;
|
|
|
+import com.galaxis.manatee.util.TimeUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
-import java.time.DayOfWeek;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
@@ -205,15 +206,21 @@ public class LogCheckService {
|
|
|
matchers.add("F0000001_2," + chuanyunSelfWorkHourDO.getProjectId());
|
|
|
}
|
|
|
matchers.add("F0000002_2," + chuanyunSelfWorkHourDO.getUserId());
|
|
|
- matchers.add("F0000003_2," + chuanyunSelfWorkHourDO.getDayLogDate());
|
|
|
+ matchers.add("F0000003_2," + TimeUtil.formatDateTime(chuanyunSelfWorkHourDO.getDayLogDate()));
|
|
|
|
|
|
- var filter = Filter.instance(0, 1, true, "And", matchers);
|
|
|
+ var filter = Filter.instance(-1, 100, true, "And", matchers);
|
|
|
var chuanyunFindAllResponse = chuanYunManager.findAll(ChuanyunMemberHourDO.SCHEMA_CODE, filter);
|
|
|
- ChuanyunSaveDTO chuanyunSaveDTO;
|
|
|
+ // 修改bug 删除氚云数据库不生效问题
|
|
|
+ // 1.日期未按照氚云要求格式化。
|
|
|
+ // 2.查询条件未从-1开始查,且只查了1条。
|
|
|
+ // 3.转换json时对象的objectId为null,无法删除氚云数据库。父类中属性需要在转换时指定转换的结果类型
|
|
|
if (chuanyunFindAllResponse.getReturnData() != null) {
|
|
|
- List<ChuanyunMemberHourDO> result = objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>() {
|
|
|
+ List<Object> responses = chuanyunFindAllResponse.getReturnData().getBizObjectArray();
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ responses.forEach(o -> {
|
|
|
+ ChuanyunMemberHourDO chuanyunMemberHourDO = objectMapper.convertValue(o, ChuanyunMemberHourDO.class);
|
|
|
+ chuanYunManager.delete(ChuanyunMemberHourDO.SCHEMA_CODE, chuanyunMemberHourDO.getObjectId());
|
|
|
});
|
|
|
- chuanyunSaveDTO = chuanYunManager.delete(ChuanyunMemberHourDO.SCHEMA_CODE, result.get(0).getObjectId());
|
|
|
}
|
|
|
log.info(chuanyunSelfWorkHourDO.getUserId() + "删除" + chuanyunSelfWorkHourDO.getDayLogDate() + "位于" + chuanyunSelfWorkHourDO.getProjectId() + "工时");
|
|
|
} catch (Exception e) {
|
|
@@ -226,12 +233,17 @@ public class LogCheckService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 校验指定时间后的日工时记录
|
|
|
+ *
|
|
|
+ * @param allUserIdList 用户id集合
|
|
|
+ * @param afterDay 多少天后
|
|
|
+ */
|
|
|
@Async
|
|
|
- public void checkHalfYearDayWorkHour(List<String> allUserIdList) {
|
|
|
+ public void checkDayWorkHourTimeAfter(List<String> allUserIdList, Integer afterDay) {
|
|
|
allUserIdList.parallelStream().forEach(userId -> {
|
|
|
- // 获取半年期的工时
|
|
|
List<ChuanyunWorkHourDO> halfYearSelfWorkHour = chuanyunWorkHourDao.getHalfYearSelfWorkHour(userId);
|
|
|
- LocalDateTime localDateTime = LocalDateTime.now().minusDays(180);
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.now().minusDays(afterDay);
|
|
|
List<ChuanyunSelfWorkHourDO> chuanyunSelfWorkHourList = chuanyunSelfWorkHourDao.findByUserIdAndDayLogDateAfter(userId, localDateTime);
|
|
|
compareDayWorkHour(halfYearSelfWorkHour, chuanyunSelfWorkHourList);
|
|
|
});
|
|
@@ -292,4 +304,63 @@ public class LogCheckService {
|
|
|
allUserIdList.parallelStream().forEach(userId -> {
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按照年月日检验是否存在时区问题的数据
|
|
|
+ *
|
|
|
+ * @param year 年
|
|
|
+ * @param month 月
|
|
|
+ * @param maxDay 当月最后一天
|
|
|
+ */
|
|
|
+ public void checkChuanYunAll(Integer year, Integer month, Integer maxDay) {
|
|
|
+ for (int i = 1; i <= maxDay; i++) {
|
|
|
+ List<String> matchers = new ArrayList<>();
|
|
|
+ LocalDateTime of = LocalDateTime.of(year, month, i, 8, 0, 0);
|
|
|
+ String dateTime = TimeUtil.formatDateTime(of);
|
|
|
+ log.info("dateTime: {}", dateTime);
|
|
|
+ matchers.add("F0000003_2," + dateTime);
|
|
|
+ boolean flag = true;
|
|
|
+ int start = -1;
|
|
|
+ int pageSize = 100;
|
|
|
+ while (flag) {
|
|
|
+ Filter filter = Filter.instance(start, start + pageSize, true, Filter.AND, matchers);
|
|
|
+ ChuanyunFindAllBizDTO<Object> all = null;
|
|
|
+ try {
|
|
|
+ all = chuanYunManager.findAll(ChuanyunMemberHourDO.SCHEMA_CODE, filter);
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (all.getReturnData() == null) {
|
|
|
+ flag = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (all.getReturnData().getTotalCount() >= start + pageSize) {
|
|
|
+ start += pageSize;
|
|
|
+ } else {
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ ChuanyunFindAllBizReturnData<Object> returnData = all.getReturnData();
|
|
|
+
|
|
|
+ if (returnData != null) {
|
|
|
+ List<Object> bizObjectArray = returnData.getBizObjectArray();
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ for (Object o : bizObjectArray) {
|
|
|
+ ChuanyunMemberHourDO chuanyunMemberHourDO = objectMapper.convertValue(o, ChuanyunMemberHourDO.class);
|
|
|
+
|
|
|
+ ChuanyunSaveDTO delete = null;
|
|
|
+ try {
|
|
|
+ delete = chuanYunManager.delete(ChuanyunMemberHourDO.SCHEMA_CODE, chuanyunMemberHourDO.getObjectId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("删除异常 e: {}", e.getMessage());
|
|
|
+ }
|
|
|
+ if (!delete.getSuccessful()) {
|
|
|
+ log.info("删除失败");
|
|
|
+ }
|
|
|
+ log.info("userId: {}, objectId: {}, time: {}", chuanyunMemberHourDO.getUserId(), chuanyunMemberHourDO.getObjectId(), chuanyunMemberHourDO.getDayLogDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|