报警,巡检相关接口

dongguan-huaweiyun
LAPTOP-S9HJSOEB\昊天 2 years ago
parent 843de453e3
commit 9c254c1cb5

@ -3,23 +3,28 @@ package com.leaper.web.controller;
import com.github.pagehelper.PageInfo;
import com.leaper.common.util.ValidatorUtil;
import com.leaper.web.entity.CheckLog;
import com.leaper.web.entity.DeviceReq;
import com.leaper.web.pojo.stock.CheckLogSearch;
import com.leaper.web.service.CheckLogService;
import com.leaper.web.service.PlcService;
import com.zhehekeji.core.pojo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Api(tags = "盘点历史")
@Api(tags = "设备相关")
@RequestMapping("/device")
@RestController
@Slf4j
public class DeviceController {
@ -28,11 +33,27 @@ public class DeviceController {
@Resource
private ValidatorUtil validatorUtil;
@ApiOperation("盘点历史")
@PostMapping("")
public Result<PageInfo<CheckLog>> list(@RequestBody CheckLogSearch checkLogSearch){
return Result.success(checkLogService.list(checkLogSearch));
@Resource
PlcService plcService;
@ApiOperation("设备报警")
@PostMapping("warn")
public Result<Map<String, List<String>>> warn(@RequestBody DeviceReq deviceReq) {
log.info("{}设备报警", deviceReq.getDeviceCode());
plcService.warnStart(deviceReq);
Map<String, List<String>> map =
return Result.success(checkLogService.list());
}
@ApiOperation("设备报警")
@PostMapping("巡检")
public Result<Map<String, List<String>>> inspection(@RequestBody DeviceReq deviceReq) {
return Result.success(checkLogService.list());
}
}

@ -0,0 +1,19 @@
package com.leaper.web.entity;
import lombok.Data;
import java.util.List;
@Data
public class DeviceReq {
String deviceCode ;
String warmName ;
List<CameraList> cameraList ;
@Data
public static class CameraList {
String cameraCode ;
String cameraName ;
String cameraId ;
String warnCode ;
}
}

@ -17,6 +17,7 @@ public class Warn {
@TableId(type = IdType.AUTO)
private Long id;
private Integer deviceCode;
private Integer streetId;
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")

@ -516,6 +516,53 @@ public class PlcService {
}
}
/**
*
* 1.
* 2.
*
* @param deviceReq
*/
public void warn(DeviceReq deviceReq) {
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 start...., but no order running", plcId);
} else {
//不为空的话,填写工单的位置
Order order = orderMapper.getOneByOrderNum(orderNum);
if (order != null) {
//stop the order
log.debug("plcId:{},warn start and stop the order",plcId);
orderStopByWarn(orderNum);
OrderVO orderVO = new OrderVO();
BeanUtils.copyProperties(order, orderVO);
String location = orderService.location(orderVO, street);
warn.setLocation(location);
warn.setOrderId(order.getId());
}
}
//没有正在执行的工单 不需要填写location
warn.setSignal(signal);
warnMapper.insert(warn);
OrderRealtime.startWarn(street.getId(), warn.getId());
Street street = streetService.getStreetByPlcId(plcId);
if (street == null) {
return;
}
synchronized (plcId.intern()) {
//新增 告警
if (OrderRealtime.getWarnId(street.getId()) != null) {
log.debug("{}:exist warn", plcId);
return;
}
//不存在正在执行的告警记录,就新增
}
}
/**
*
* -

Loading…
Cancel
Save