package com.heyu.api.schedule.impl;


import com.heyu.api.data.constants.ApiConstants;
import com.heyu.api.data.dao.vv.VvPackageDao;
import com.heyu.api.data.entity.vv.VvPackageEntity;
import com.heyu.api.data.enums.RoleEnums;
import com.heyu.api.data.service.vv.VvPackageService;
import com.heyu.api.data.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

@Component("packageUpdateJob")
@Slf4j
public class PackageUpdateJob {


    @Autowired
    private VvPackageDao vvPackageDao;


    @Autowired
    private VvPackageService vvPackageService;

    public void run() {
        log.info("PackageUpdateJob start select " + new Date());
        List<VvPackageEntity> vvPackageEntityList = vvPackageDao.selectVvPackageBySignReceiptStatus(ApiConstants.NOT_SIGN_RECEIPT);
        for (VvPackageEntity vvPackageEntity : vvPackageEntityList) {
            if(StringUtils.isNotEmpty(vvPackageEntity.getTrackNumber())) {
                vvPackageService.selectVvKuaidiAndUpdateData(vvPackageEntity.getTrackNumber(), RoleEnums.job.getRole(), false);
            }
        }
    }
}
