|
|
|
|
@ -16,6 +16,7 @@ import com.zhehekeji.web.mapper.SensorGunMapper;
|
|
|
|
|
import com.zhehekeji.web.mapper.StreetMapper;
|
|
|
|
|
import com.zhehekeji.web.pojo.street.StreetSearch;
|
|
|
|
|
import com.zhehekeji.web.pojo.street.StreetVO;
|
|
|
|
|
import com.zhehekeji.web.service.client.ClientChanel;
|
|
|
|
|
import com.zhehekeji.web.service.robotic.NettyClient;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
@ -85,6 +86,9 @@ public class StreetService {
|
|
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
|
Assert.isTrue(false, "PLC ID已存在");
|
|
|
|
|
}
|
|
|
|
|
if(!StringUtils.isEmpty(street.getPlcIp())){
|
|
|
|
|
ClientChanel.putIp(street.getPlcIp(),street.getPlcId());
|
|
|
|
|
}
|
|
|
|
|
if(configProperties.getServerMode().equals(0)){
|
|
|
|
|
StreetConn.init(street.getId(), street.getPlcId());
|
|
|
|
|
Thread thread = new Thread(new Runnable() {
|
|
|
|
|
@ -147,6 +151,10 @@ public class StreetService {
|
|
|
|
|
lightSourceMapper.deleteByMap(map);
|
|
|
|
|
rfidMapper.deleteByMap(map);
|
|
|
|
|
StreetConn.del(id);
|
|
|
|
|
if(!StringUtils.isEmpty(street.getPlcIp())){
|
|
|
|
|
ClientChanel.deleteIp(street.getPlcIp());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//只是为了删除缓存
|
|
|
|
|
@ -177,6 +185,9 @@ public class StreetService {
|
|
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
|
Assert.isTrue(false, "PLC ID已存在");
|
|
|
|
|
}
|
|
|
|
|
if(!StringUtils.isEmpty(street.getPlcIp())){
|
|
|
|
|
ClientChanel.putIp(street.getPlcIp(),street.getPlcId());
|
|
|
|
|
}
|
|
|
|
|
List<LightSource> list = lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id",street.getId()));
|
|
|
|
|
if(list.size() == 0){
|
|
|
|
|
if(!StringUtils.isEmpty(streetVO.getLightSourceIp()) && streetVO.getLightSourcePort() != null && streetVO.getLightSourcePort() != 0){
|
|
|
|
|
@ -204,6 +215,12 @@ public class StreetService {
|
|
|
|
|
public PageInfo<StreetVO> page(StreetSearch search) {
|
|
|
|
|
PageHelper.startPage(search.getPageNum(), search.getPageSize());
|
|
|
|
|
List<StreetVO> streetVOS = streetMapper.list();
|
|
|
|
|
streetVOS.forEach(streetVO -> {
|
|
|
|
|
//存在chanel则认为在线
|
|
|
|
|
if(ClientChanel.get(streetVO.getPlcId()) != null){
|
|
|
|
|
streetVO.setConnectStatus(1);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return new PageInfo<>(streetVOS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|