|
|
|
|
@ -5,8 +5,10 @@ import com.zhehekeji.common.util.PathUtil;
|
|
|
|
|
import com.zhehekeji.web.entity.*;
|
|
|
|
|
import com.zhehekeji.web.lib.*;
|
|
|
|
|
import com.zhehekeji.web.mapper.*;
|
|
|
|
|
import com.zhehekeji.web.pojo.OrderVO;
|
|
|
|
|
import com.zhehekeji.web.pojo.stock.StockStatus;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
@ -190,31 +192,42 @@ public class PlcService {
|
|
|
|
|
* 2.没有订单,新增告警记录
|
|
|
|
|
* @param plcId
|
|
|
|
|
*/
|
|
|
|
|
public void warnStart(String plcId){
|
|
|
|
|
public void warnStart(String plcId,String signal){
|
|
|
|
|
Street street = streetService.getStreetByPlcId(plcId);
|
|
|
|
|
if(street == null){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
synchronized (plcId.intern()){
|
|
|
|
|
String orderNum = OrderRealtime.getOrderByStreetId(street.getId());
|
|
|
|
|
if(StringUtils.isEmpty(orderNum)){
|
|
|
|
|
//空的 说明没有正在执行的订单
|
|
|
|
|
//新增 告警
|
|
|
|
|
if(OrderRealtime.getWarnId(street.getId()) == null){
|
|
|
|
|
//不存在正在执行的告警记录,就新增
|
|
|
|
|
Warn warn = new Warn();
|
|
|
|
|
warn.setStartTime(LocalDateTime.now());
|
|
|
|
|
warn.setStreetId(street.getId());
|
|
|
|
|
warnMapper.insert(warn);
|
|
|
|
|
OrderRealtime.startWarn(street.getId(),warn.getId());
|
|
|
|
|
//新增 告警
|
|
|
|
|
if(OrderRealtime.getWarnId(street.getId()) == null){
|
|
|
|
|
//不存在正在执行的告警记录,就新增
|
|
|
|
|
Warn warn = new Warn();
|
|
|
|
|
warn.setStartTime(LocalDateTime.now());
|
|
|
|
|
warn.setStreetId(street.getId());
|
|
|
|
|
String orderNum = OrderRealtime.getOrderByStreetId(street.getId());
|
|
|
|
|
if(StringUtils.isEmpty(orderNum)){
|
|
|
|
|
//空的 说明没有正在执行的订单
|
|
|
|
|
log.debug("{}:warn.... no order",plcId);
|
|
|
|
|
}else {
|
|
|
|
|
log.debug("{}:exist warn",plcId);
|
|
|
|
|
//不为空的话,填写工单的位置
|
|
|
|
|
Order order = orderMapper.getOneByOrderNum(orderNum);
|
|
|
|
|
if(order != null){
|
|
|
|
|
OrderVO orderVO = new OrderVO();
|
|
|
|
|
BeanUtils.copyProperties(order,orderVO);
|
|
|
|
|
String location = orderService.location(orderVO,street);
|
|
|
|
|
warn.setLocation(location);
|
|
|
|
|
log.debug("{}:warn.... exist order",plcId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//没有正在执行的工单 不需要填写location
|
|
|
|
|
warn.setSignal(signal);
|
|
|
|
|
warnMapper.insert(warn);
|
|
|
|
|
OrderRealtime.startWarn(street.getId(),warn.getId());
|
|
|
|
|
}else {
|
|
|
|
|
log.debug("{}:warn.... exist order",plcId);
|
|
|
|
|
log.debug("{}:exist warn",plcId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|