PC
2024-03-31 608f20e0d5d8f95d9bbb917e95e2913682deb77d
smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/WorkstationFeedbackServiceImpl.java
@@ -1,11 +1,6 @@
package com.qianwen.smartman.modules.mdc.service.impl;
import cn.hutool.core.collection.ListUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.io.Serializable;
import java.lang.invoke.SerializedLambda;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.ZoneId;
@@ -21,11 +16,15 @@
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Resource;
import com.qianwen.smartman.common.constant.ExtCacheConstant;
import com.qianwen.smartman.common.enums.GlobalWcsTypeEnum;
import com.qianwen.smartman.common.utils.ExtraLambdaQueryWrapper;
import com.qianwen.smartman.common.utils.Lambda;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qianwen.core.cache.utils.CacheUtil;
import com.qianwen.core.log.exception.ServiceException;
import com.qianwen.core.mp.support.BaseEntityWrapper;
@@ -35,6 +34,9 @@
import com.qianwen.core.secure.utils.AuthUtil;
import com.qianwen.core.tool.utils.DateUtil;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.common.constant.ExtCacheConstant;
import com.qianwen.smartman.common.enums.GlobalWcsTypeEnum;
import com.qianwen.smartman.common.utils.Lambda;
import com.qianwen.smartman.modules.cps.entity.Employee;
import com.qianwen.smartman.modules.cps.entity.Workstation;
import com.qianwen.smartman.modules.cps.service.IEmployeeService;
@@ -56,9 +58,7 @@
import com.qianwen.smartman.modules.mdc.vo.WorkstationFeedbackInfoVO;
import com.qianwen.smartman.modules.mdc.wrapper.WorkstationFeedbackWrapper;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.hutool.core.collection.ListUtil;
@Service
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/mdc/service/impl/WorkstationFeedbackServiceImpl.class */
@@ -78,112 +78,12 @@
    private IWorkstationFeedbackService selfService;
    @Resource
    private IEmployeeService employeeService;
    static final /* synthetic */ boolean $assertionsDisabled;
    private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
        String implMethodName = lambda.getImplMethodName();
        boolean z = true;
        switch (implMethodName.hashCode()) {
            case -2138899559:
                if (implMethodName.equals("getStartTime")) {
                    z = true;
                    break;
                }
                break;
            case -570382830:
                if (implMethodName.equals("getEndTime")) {
                    z = true;
                    break;
                }
                break;
            case -557259320:
                if (implMethodName.equals("getWorkstationId")) {
                    z = true;
                    break;
                }
                break;
            case -99273003:
                if (implMethodName.equals("getFeedbackType")) {
                    z = false;
                    break;
                }
                break;
            case 98245393:
                if (implMethodName.equals("getId")) {
                    z = true;
                    break;
                }
                break;
        }
        switch (z) {
            case false:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/mdc/entity/WorkstationFeedback") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getFeedbackType();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/mdc/entity/WorkstationFeedback") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getFeedbackType();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/mdc/entity/WorkstationFeedback") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getWorkstationId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/mdc/entity/WorkstationFeedback") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getWorkstationId();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/mdc/entity/WorkstationFeedback") && lambda.getImplMethodSignature().equals("()Ljava/util/Date;")) {
                    return (v0) -> {
                        return v0.getEndTime();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/mdc/entity/WorkstationFeedback") && lambda.getImplMethodSignature().equals("()Ljava/util/Date;")) {
                    return (v0) -> {
                        return v0.getEndTime();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/mdc/entity/WorkstationFeedback") && lambda.getImplMethodSignature().equals("()Ljava/util/Date;")) {
                    return (v0) -> {
                        return v0.getEndTime();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/mdc/entity/WorkstationFeedback") && lambda.getImplMethodSignature().equals("()Ljava/util/Date;")) {
                    return (v0) -> {
                        return v0.getStartTime();
                    };
                }
                break;
        }
        throw new IllegalArgumentException("Invalid lambda deserialization");
    }
    static {
        $assertionsDisabled = !WorkstationFeedbackServiceImpl.class.desiredAssertionStatus();
    }
    /* JADX WARN: Type inference failed for: r0v11, types: [org.springblade.modules.mdc.service.impl.WorkstationFeedbackServiceImpl$1] */
    @Override // org.springblade.modules.mdc.service.IWorkstationFeedbackService
    public IPage<WorkstationFeedbackInfoVO> workstationPage(Query query, boolean excludeImmediate) {
        final List<WorkstationFeedback> immediateFeedback = this.selfService.getImmediateFeedback();
        final List<Long> workstationList = (List) immediateFeedback.stream().map((v0) -> {
        final List<Long> workstationList = immediateFeedback.stream().map((v0) -> {
            return v0.getWorkstationId();
        }).collect(Collectors.toList());
        IPage<Workstation> page = this.workstationService.page(Condition.getPage(query), Lambda.notIn(excludeImmediate && Func.isNotEmpty(immediateFeedback), (v0) -> {
@@ -218,22 +118,29 @@
    @Override // org.springblade.modules.mdc.service.IWorkstationFeedbackService
    public List<WorkstationFeedback> getImmediateFeedback() {
       return list(Lambda.eq(WorkstationFeedback::getFeedbackType, Integer.valueOf(FeedbackType.IMMEDIATE.getValue()))
               .isNull(WorkstationFeedback::getEndTime));
       /*
        return list((Wrapper) Lambda.eq((v0) -> {
            return v0.getFeedbackType();
        }, Integer.valueOf(FeedbackType.IMMEDIATE.getValue())).isNull((v0) -> {
            return v0.getEndTime();
        }));
        }));*/
    }
    @Override // org.springblade.modules.mdc.service.IWorkstationFeedbackService
    public WorkstationFeedback getImmediateFeedback(Serializable workstationId) {
       return getOne(Lambda.eq(WorkstationFeedback::getWorkstationId, workstationId)
               .eq(WorkstationFeedback::getFeedbackType, Integer.valueOf(FeedbackType.IMMEDIATE.getValue()))
               .isNull(WorkstationFeedback::getEndTime));
       /*
        return (WorkstationFeedback) getOne((Wrapper) ((ExtraLambdaQueryWrapper) Lambda.eq((v0) -> {
            return v0.getWorkstationId();
        }, workstationId).eq((v0) -> {
            return v0.getFeedbackType();
        }, Integer.valueOf(FeedbackType.IMMEDIATE.getValue()))).isNull((v0) -> {
            return v0.getEndTime();
        }));
        }));*/
    }
    @Override // org.springblade.modules.mdc.service.IWorkstationFeedbackService
@@ -241,7 +148,7 @@
    public boolean startFeedbackByImmediate(WorkstationImmediateFeedBackDTO dto) {
        Date now = new Date();
        for (String workstationId : dto.getWorkstationIds()) {
            this.redisLockClient.lockFair(ExtCacheConstant.WORK_FEEDBACK.concat(SystemPropertyUtils.VALUE_SEPARATOR.concat(workstationId)), 30L, 100L, () -> {
            this.redisLockClient.lockFair(ExtCacheConstant.WORK_FEEDBACK.concat(":".concat(workstationId)), 30L, 100L, () -> {
                WorkstationFeedback oldFeedback = this.selfService.getImmediateFeedback(workstationId);
                if (oldFeedback != null && oldFeedback.getWcs().equals(dto.getWcs())) {
                    return false;
@@ -279,7 +186,7 @@
            dto.setEndTime(new Date());
        }
        for (String workstationId : dto.getWorkstationIds()) {
            this.redisLockClient.lockFair(ExtCacheConstant.WORK_FEEDBACK.concat(SystemPropertyUtils.VALUE_SEPARATOR).concat(workstationId), 30L, 100L, () -> {
            this.redisLockClient.lockFair(ExtCacheConstant.WORK_FEEDBACK.concat(":").concat(workstationId), 30L, 100L, () -> {
                existTimeOverImmediateFeedbackException(dto);
                WorkstationFeedback addFeedback = new WorkstationFeedback();
                addFeedback.setWorkstationId(Long.valueOf(Long.parseLong(workstationId)));
@@ -317,12 +224,17 @@
        Stream.iterate(start, d -> {
            return d.plusDays(1L);
        }).limit(distance + 1).forEach(date -> {
            String key = String.valueOf(workstationId).concat(SystemPropertyUtils.VALUE_SEPARATOR).concat(Func.formatDate(date));
            String key = String.valueOf(workstationId).concat(":").concat(Func.formatDate(date));
            CacheUtil.evict(IWorkstationFeedbackService.WORK_FEEDBACK_EXP3, GROUP_FEEDBACK_CACHE_KEY, key, false);
        });
    }
    private void existTimeOverImmediateFeedbackException(WorkstationNoImmediateFeedBackDTO dto) {
       if (dto.getWorkstationIds().stream().map(this.selfService::getImmediateFeedback).filter(Objects::nonNull).anyMatch(feedback ->
        (dto.getStartTime().getTime() >= feedback.getStartTime().getTime() || dto.getEndTime().getTime() >= feedback.getStartTime().getTime())))
          throw new ServiceException("存在正在反馈的状态,请先结束当前反馈再提交。");
       /*
        Stream<String> stream = dto.getWorkstationIds().stream();
        IWorkstationFeedbackService iWorkstationFeedbackService = this.selfService;
        iWorkstationFeedbackService.getClass();
@@ -334,7 +246,7 @@
            return dto.getStartTime().getTime() >= feedback.getStartTime().getTime() || dto.getEndTime().getTime() >= feedback.getStartTime().getTime();
        })) {
            throw new ServiceException("存在正在反馈的状态,请先结束当前反馈再提交。");
        }
        }*/
    }
    private Employee getEmployeeById() {
@@ -394,6 +306,16 @@
    }
    private List<WorkstationFeedback> allFeedbackByWorkstationId(final LocalDate statusTime, final Serializable workstationId) {
       return Stream.concat(
               Stream.<Serializable>of(workstationId).map(this.selfService::getImmediateFeedback)
               .filter(Objects::nonNull)
               .filter(feedback -> (statusTime == null || DateUtil.formatDate(feedback.getStartTime()).equals(statusTime.toString()))),
               list(Lambda.eq(WorkstationFeedback::getWorkstationId, workstationId)
                 .dayBetween(statusTime, WorkstationFeedback::getStartTime, WorkstationFeedback::getEndTime))
               .stream()
               .filter(Objects::nonNull))
             .collect(Collectors.toList());
       /*
        Stream of = Stream.of(workstationId);
        IWorkstationFeedbackService iWorkstationFeedbackService = this.selfService;
        iWorkstationFeedbackService.getClass();
@@ -409,13 +331,13 @@
            return v0.getEndTime();
        })).stream().filter((v0) -> {
            return Objects.nonNull(v0);
        })).collect(Collectors.toList());
        })).collect(Collectors.toList());*/
    }
    @Override // org.springblade.modules.mdc.service.IWorkstationFeedbackService
    public List<StatusRecordVO> groupStatusRecordWithFeedbackCache(final LocalDate statusTime, final Long workstationId, final List<StatusRecordVO> recordList) {
        List<StatusRecordVO> statusRecordList = recordList == null ? new ArrayList<>() : recordList;
        List<StatusRecordVO> cancelList = (List) this.feedbackDetailService.cancelFeedback(statusTime, workstationId).stream().map(feedback -> {
        List<StatusRecordVO> cancelList = this.feedbackDetailService.cancelFeedback(statusTime, workstationId).stream().map(feedback -> {
            StatusRecordVO t = new StatusRecordVO();
            t.setStartTime(new Timestamp(feedback.getStartTime().getTime()));
            t.setEndTime(new Timestamp(feedback.getEndTime().getTime()));
@@ -424,12 +346,12 @@
            t.setWcs(-1);
            return t;
        }).collect(Collectors.toList());
        String key = String.join(SystemPropertyUtils.VALUE_SEPARATOR, workstationId + "", statusTime.toString());
        String key = String.join(":", workstationId + "", statusTime.toString());
        if (statusTime.compareTo((ChronoLocalDate) LocalDate.now()) == 0) {
            List<StatusRecordVO> statusRecordVOList = groupStatusRecordWithFeedback(statusTime, workstationId, statusRecordList, cancelList);
            return filterDateStatusRecord(statusRecordVOList, statusTime);
        }
        GroupFeedbackCacheDTO statusData = (GroupFeedbackCacheDTO) CacheUtil.get(IWorkstationFeedbackService.WORK_FEEDBACK_EXP3, GROUP_FEEDBACK_CACHE_KEY, key, () -> {
        GroupFeedbackCacheDTO statusData = CacheUtil.get(IWorkstationFeedbackService.WORK_FEEDBACK_EXP3, GROUP_FEEDBACK_CACHE_KEY, key, () -> {
            GroupFeedbackCacheDTO dto = new GroupFeedbackCacheDTO();
            List<StatusRecordVO> list = groupStatusRecordWithFeedback(statusTime, workstationId, statusRecordList, cancelList);
            dto.setRecordList(list);
@@ -437,6 +359,16 @@
            dto.setCancelNum(cancelList.size());
            return dto;
        }, false);
        //assert statusData != null;
        if (statusData.getStatusNum() != statusRecordList.size() || statusData.getCancelNum() != cancelList.size()) {
            //CacheUtil.evict("blade:feedback#259200", "group:feedback:list:", key, Boolean.valueOf(false));
            CacheUtil.evict(IWorkstationFeedbackService.WORK_FEEDBACK_EXP3, GROUP_FEEDBACK_CACHE_KEY, key, false);
            return groupStatusRecordWithFeedbackCache(statusTime, workstationId, statusRecordList);
         }
         return filterDateStatusRecord(statusData.getRecordList(), statusTime);
        /*
        if ($assertionsDisabled || statusData != null) {
            if (statusData.getStatusNum() != statusRecordList.size() || statusData.getCancelNum() != cancelList.size()) {
                CacheUtil.evict(IWorkstationFeedbackService.WORK_FEEDBACK_EXP3, GROUP_FEEDBACK_CACHE_KEY, key, false);
@@ -445,14 +377,15 @@
            return filterDateStatusRecord(statusData.getRecordList(), statusTime);
        }
        throw new AssertionError();
        */
    }
    private List<StatusRecordVO> groupStatusRecordWithFeedback(final LocalDate statusTime, final Long workstationId, final List<StatusRecordVO> statusRecordList, final List<StatusRecordVO> cancelList) {
        List<StatusRecordVO> sourceList = (List) Stream.concat(allFeedbackByWorkstationId(statusTime, workstationId).stream().map(WorkstationFeedbackWrapper::entityRecordVO), cancelList.stream()).sorted(Comparator.comparing((v0) -> {
        List<StatusRecordVO> sourceList = Stream.concat(allFeedbackByWorkstationId(statusTime, workstationId).stream().map(WorkstationFeedbackWrapper::entityRecordVO), cancelList.stream()).sorted(Comparator.comparing((v0) -> {
            return v0.getFeedbackTime();
        })).collect(Collectors.toList());
        List<StatusRecordVO> feedbackList = groupStatusRecordWithFeedback(sourceList, statusTime);
        List<StatusRecordVO> sourceList2 = (List) Stream.concat(statusRecordList.stream().peek(status -> {
        List<StatusRecordVO> sourceList2 = Stream.concat(statusRecordList.stream().peek(status -> {
            status.setFeedbackTime(status.getStartTime());
        }), feedbackList.stream()).sorted(Comparator.comparing((v0) -> {
            return v0.getFeedbackTime();
@@ -468,18 +401,18 @@
            return v0.getEndTime();
        })).distinct().sorted(Comparator.comparing((v0) -> {
            return v0.getTime();
        })).reduce(first, second -> {
            Optional reduce = sourceList.stream().filter(item -> {
        })).reduce((first, second) -> {
            Optional<StatusRecordVO> reduce = sourceList.stream().filter(item -> {
                return first.getTime() - item.getStartTime().getTime() >= 0 && item.getEndTime().getTime() - second.getTime() >= 0;
            }).reduce(a, b -> {
            }).reduce((a, b) -> {
                if (!b.isHumanFeedback() && a.isHumanFeedback()) {
                    return a;
                }
                return b;
            });
            StatusRecordConvert statusRecordConvert = StatusRecordConvert.INSTANCE;
            statusRecordConvert.getClass();
            reduce.map(this::convert).ifPresent(record -> {
            //StatusRecordConvert statusRecordConvert = StatusRecordConvert.INSTANCE;
            //statusRecordConvert.getClass();
            reduce.map(StatusRecordConvert.INSTANCE::convert).ifPresent(record -> {
                record.setStartTime(first);
                record.setEndTime(second);
                System.out.println(first + "  ->  " + second + "  wcs=" + record.getWcs());
@@ -492,7 +425,7 @@
            });
            return second;
        });
        return (List) targetList.stream().filter(item -> {
        return targetList.stream().filter(item -> {
            return !item.getWcs().equals(-1) && item.getEndTime().getTime() - item.getStartTime().getTime() >= 1000 && item.getStartTime().toLocalDateTime().toLocalDate().compareTo((ChronoLocalDate) statusTime) <= 0 && item.getEndTime().toLocalDateTime().toLocalDate().compareTo((ChronoLocalDate) statusTime) >= 0;
        }).collect(Collectors.toList());
    }