package com.zy.asrs.task;
|
|
import com.alibaba.fastjson.JSON;
|
import com.zy.asrs.entity.BasArmRules;
|
import com.zy.asrs.entity.param.ArmPrecomputeParam;
|
import com.zy.asrs.service.BasArmRulesService;
|
import com.zy.asrs.task.core.ReturnT;
|
import com.zy.asrs.task.handler.ArmRulesHandler;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* Created by vincent on 2020/7/7
|
*/
|
@Component
|
public class ArmRulesScheduler {
|
|
private static final Logger log = LoggerFactory.getLogger(ArmRulesScheduler.class);
|
|
@Autowired
|
private BasArmRulesService basArmRulesService;
|
@Autowired
|
private ArmRulesHandler armRulesHandler;
|
|
@Scheduled(cron = "0/3 * * * * ? ")
|
private void execute(){
|
List<BasArmRules> basArmRules = basArmRulesService.AllStatusSatisfyBasArmRules(0);
|
if (basArmRules.isEmpty()) {
|
return;
|
}
|
for (BasArmRules basArmRule: basArmRules) {
|
try{
|
if (basArmRule.getMaterialHeight()>0 && basArmRule.getMaterialLength()>0 && basArmRule.getMaterialWeight()>0 && basArmRule.getMaterialWidth()>0){
|
ArmPrecomputeParam armPrecomputeParam = new ArmPrecomputeParam(basArmRule);
|
ReturnT<String> returnT = armRulesHandler.start(armPrecomputeParam);
|
if (!returnT.isSuccess()) {
|
log.error("获取码垛数量失败===>"+JSON.toJSON(basArmRule));
|
}
|
} else {
|
basArmRule.setStatus(2);
|
basArmRulesService.updateById(basArmRule);
|
}
|
} catch (Exception e){
|
log.error("获取码垛数量异常===>"+e.getMessage());
|
}
|
}
|
}
|
|
}
|