WcsscanbarcodeService.java 1.54 KB
package com.huaheng.pc.config.wcsscanbarcode.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.common.utils.DataUtils;
import com.huaheng.common.utils.DateUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.xml.crypto.Data;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.config.wcsscanbarcode.domain.Wcsscanbarcode;
import com.huaheng.pc.config.wcsscanbarcode.mapper.WcsscanbarcodeMapper;
/**
 *
 * @author Enzo Cotter
 * @date 2019/12/26
 */

@Service
public class WcsscanbarcodeService extends ServiceImpl<WcsscanbarcodeMapper, Wcsscanbarcode> {

    public AjaxResult refresh(){
        LambdaQueryWrapper<Wcsscanbarcode> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(Wcsscanbarcode::getFlag, 0);
        List<Wcsscanbarcode> wcsscanbarcodeList = list(queryWrapper);
        for ( Wcsscanbarcode barcode: wcsscanbarcodeList) {
            if (DateUtils.difference(new Date(), barcode.getCreated()) > 119){
                barcode.setFlag(1);
                barcode.setContent("扫描容器记录超时");
                if (!updateById(barcode)){
                    return AjaxResult.error("更新"+barcode.getBarcode()+"id:"+barcode.getId()+"失败");
                }
            }
        }
        return AjaxResult.success("更新成功");
    }
}