|
|
@@ -10,6 +10,7 @@ import com.izouma.nineth.dto.MetaServiceResult;
|
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
|
import com.izouma.nineth.enums.MetaAwardTypeEnum;
|
|
|
import com.izouma.nineth.enums.MetaTaskStatus;
|
|
|
+import com.izouma.nineth.enums.MetaTaskTarget;
|
|
|
import com.izouma.nineth.enums.MetaTaskType;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
import com.izouma.nineth.repo.*;
|
|
|
@@ -27,6 +28,7 @@ import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
@@ -39,6 +41,7 @@ public class MetaTaskToUserNewService {
|
|
|
private MetaPropRepo metaPropRepo;
|
|
|
private MetaTaskBindRepo metaTaskBindRepo;
|
|
|
private MetaUserTaskProgressNewRepo metaUserTaskProgressNewRepo;
|
|
|
+ private MetaUserPropRepo metaUserPropRepo;
|
|
|
|
|
|
public Page<MetaTaskToUserNew> all(PageQuery pageQuery) {
|
|
|
return metaTaskToUserNewRepo.findAll(JpaUtils.toSpecification(pageQuery, MetaTaskToUserNew.class), JpaUtils
|
|
|
@@ -303,4 +306,40 @@ public class MetaTaskToUserNewService {
|
|
|
log.info(String.format("[%S]归档日常任务进度[%S]", LocalDateTime.now(), JSONUtils.toJSONString(metaTaskToUserIds)));
|
|
|
metaUserTaskProgressNewRepo.updatePigeonhole(metaTaskToUserIds);
|
|
|
}
|
|
|
+
|
|
|
+ public void handlePropTask(Long userId) {
|
|
|
+ List<MetaAtomTask> metaAtomTasks = metaAtomTaskRepo.findAllByTargetTypeAndDel(MetaTaskTarget.COLLECT_PROP, false);
|
|
|
+ metaAtomTasks.forEach(metaAtomTask -> {
|
|
|
+ // 任务配置
|
|
|
+ List<MetaTargetConfig> metaTargetConfigs = metaAtomTask.getMetaTargetConfig();
|
|
|
+ if (CollectionUtil.isEmpty(metaTargetConfigs)) {
|
|
|
+ throw new BusinessException("");
|
|
|
+ }
|
|
|
+ // 任务领取记录
|
|
|
+ List<MetaTaskToUserNew> metaTaskToUserNews = metaTaskToUserNewRepo.findAllByUserIdAndAtomTaskIdAndPigeonholeAndDel(userId, metaAtomTask.getId(), false, false);
|
|
|
+ AtomicBoolean completed = new AtomicBoolean(true);
|
|
|
+ if (CollectionUtil.isNotEmpty(metaTaskToUserNews)) {
|
|
|
+ // 是否完成
|
|
|
+ metaTargetConfigs.forEach(metaTargetConfig -> {
|
|
|
+ MetaUserProp metaUserProp = metaUserPropRepo.findByUserIdAndMetaPropIdAndDel(userId, Long.parseLong(metaTargetConfig.getMetaPropId()), false);
|
|
|
+ if (Objects.isNull(metaUserProp) || metaUserProp.getNum() < metaTargetConfig.getNum()) {
|
|
|
+ completed.set(false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 调整任务状态
|
|
|
+ metaTaskToUserNews.forEach(metaTaskToUserNew -> {
|
|
|
+ if (MetaTaskStatus.FINISH.equals(metaTaskToUserNew.getStatus())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (completed.get()) {
|
|
|
+ metaTaskToUserNew.setStatus(MetaTaskStatus.COMPLETION);
|
|
|
+ } else {
|
|
|
+ metaTaskToUserNew.setStatus(MetaTaskStatus.PROGRESS);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 重新保存任务状态
|
|
|
+ metaTaskToUserNewRepo.saveAll(metaTaskToUserNews);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|