zhang
4 小时以前 d03fa8926309e642ff793d58c2cf509ecd617888
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MaintainScheduler.java
@@ -7,6 +7,7 @@
import com.zy.acs.framework.common.DateUtils;
import com.zy.acs.manager.common.config.UplinkProperties;
import com.zy.acs.manager.core.integrate.wms.TaskReportService;
import com.zy.acs.manager.core.integrate.wms.FaultReportService;
import com.zy.acs.manager.core.service.MainLockWrapService;
import com.zy.acs.manager.manager.entity.*;
import com.zy.acs.manager.manager.enums.*;
@@ -17,6 +18,7 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.Instant;
import java.util.Date;
import java.util.List;
import java.util.Optional;
@@ -51,6 +53,10 @@
    private SegmentService segmentService;
    @Autowired
    private TaskReportService taskReportService;
    @Autowired
    private VehFaultRecService vehFaultRecService;
    @Autowired
    private FaultReportService faultReportService;
    @Scheduled(cron = "0/5 * * * * ? ")
    private synchronized void autoCharge(){
@@ -191,4 +197,23 @@
        }
    }
    @Scheduled(cron = "0/3 * * * * ? ")
    private void reportFault() {
        String reportFaultUrl = configService.getVal("reportFaultUrl", String.class);
        if (Cools.isEmpty(reportFaultUrl)) { return; }
        List<VehFaultRec> vehFaultRecList = vehFaultRecService.list((new LambdaQueryWrapper<VehFaultRec>().eq(VehFaultRec::getState, VehFaultRecStateType.PENDING).ge(VehFaultRec::getHappenTime, Instant.now().minusSeconds(3))));
        if (Cools.isEmpty(vehFaultRecList)) { return; }
        for (VehFaultRec vehFaultRec : vehFaultRecList) {
            boolean finished = faultReportService.reportFinished(vehFaultRec,reportFaultUrl);
            if (finished) {
                vehFaultRec.setState(VehFaultRecStateType.REPORT_SUCCESS.name());
            } else {
                log.error("failed to report vehFaultRec to uplink");
                vehFaultRec.setState(VehFaultRecStateType.REPORT_FAILED.name());
            }
            vehFaultRecService.updateById(vehFaultRec);
        }
    }
}