|
|
|
@ -5,9 +5,12 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.zhehekeji.core.util.Assert;
|
|
|
|
import com.zhehekeji.core.util.Assert;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.config.ConfigProperties;
|
|
|
|
import com.zhehekeji.web.entity.LightSource;
|
|
|
|
import com.zhehekeji.web.entity.LightSource;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.entity.SensorGun;
|
|
|
|
import com.zhehekeji.web.entity.Street;
|
|
|
|
import com.zhehekeji.web.entity.Street;
|
|
|
|
import com.zhehekeji.web.mapper.LightSourceMapper;
|
|
|
|
import com.zhehekeji.web.mapper.LightSourceMapper;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.mapper.SensorGunMapper;
|
|
|
|
import com.zhehekeji.web.mapper.StreetMapper;
|
|
|
|
import com.zhehekeji.web.mapper.StreetMapper;
|
|
|
|
import com.zhehekeji.web.pojo.street.StreetSearch;
|
|
|
|
import com.zhehekeji.web.pojo.street.StreetSearch;
|
|
|
|
import com.zhehekeji.web.pojo.street.StreetType;
|
|
|
|
import com.zhehekeji.web.pojo.street.StreetType;
|
|
|
|
@ -43,6 +46,10 @@ public class StreetService {
|
|
|
|
private LightSourceMapper lightSourceMapper;
|
|
|
|
private LightSourceMapper lightSourceMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private StockService stockService;
|
|
|
|
private StockService stockService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private ConfigProperties configProperties;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private SensorGunMapper sensorGunMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
|
|
|
|
|
|
@ -76,19 +83,21 @@ public class StreetService {
|
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
Assert.isTrue(false, "PLC ID已存在");
|
|
|
|
Assert.isTrue(false, "PLC ID已存在");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StreetConn.init(street.getId(), street.getPlcId());
|
|
|
|
if(configProperties.getServerMode().equals(0)){
|
|
|
|
Thread thread = new Thread(new Runnable() {
|
|
|
|
StreetConn.init(street.getId(), street.getPlcId());
|
|
|
|
@Override
|
|
|
|
Thread thread = new Thread(new Runnable() {
|
|
|
|
public void run() {
|
|
|
|
@Override
|
|
|
|
//连接
|
|
|
|
public void run() {
|
|
|
|
try {
|
|
|
|
//连接
|
|
|
|
nettyClient.createClient(street);
|
|
|
|
try {
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
nettyClient.createClient(street);
|
|
|
|
log.error("新增巷道,连接异常");
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
log.error("新增巷道,连接异常");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
thread.start();
|
|
|
|
thread.start();
|
|
|
|
}
|
|
|
|
if(!StringUtils.isEmpty(streetVO.getLightSourceIp()) && streetVO.getLightSourcePort() != null && streetVO.getLightSourcePort() != 0){
|
|
|
|
if(!StringUtils.isEmpty(streetVO.getLightSourceIp()) && streetVO.getLightSourcePort() != null && streetVO.getLightSourcePort() != 0){
|
|
|
|
LightSource lightSource = new LightSource();
|
|
|
|
LightSource lightSource = new LightSource();
|
|
|
|
lightSource.setStreetId(street.getId());
|
|
|
|
lightSource.setStreetId(street.getId());
|
|
|
|
@ -97,6 +106,7 @@ public class StreetService {
|
|
|
|
lightSourceMapper.insert(lightSource);
|
|
|
|
lightSourceMapper.insert(lightSource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
streetVO.setId(street.getId());
|
|
|
|
streetVO.setId(street.getId());
|
|
|
|
|
|
|
|
sensorGunConfig(streetVO,street.getId());
|
|
|
|
Thread thread2 = new Thread(new Runnable() {
|
|
|
|
Thread thread2 = new Thread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
@ -216,6 +226,7 @@ public class StreetService {
|
|
|
|
lightSource.setIp(streetVO.getLightSourceIp());
|
|
|
|
lightSource.setIp(streetVO.getLightSourceIp());
|
|
|
|
lightSourceMapper.update(lightSource,new UpdateWrapper<LightSource>().eq("street_id",street.getId()));
|
|
|
|
lightSourceMapper.update(lightSource,new UpdateWrapper<LightSource>().eq("street_id",street.getId()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sensorGunConfig(streetVO,street.getId());
|
|
|
|
Thread thread2 = new Thread(new Runnable() {
|
|
|
|
Thread thread2 = new Thread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
@ -253,4 +264,26 @@ public class StreetService {
|
|
|
|
return streetMapper.list();
|
|
|
|
return streetMapper.list();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void sensorGunConfig(StreetVO streetVO,Integer streetId){
|
|
|
|
|
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
|
|
|
|
|
map.put("street_id",streetId);
|
|
|
|
|
|
|
|
sensorGunMapper.deleteByMap(map);
|
|
|
|
|
|
|
|
if(!StringUtils.isEmpty(streetVO.getLeftSensorGunIp()) && streetVO.getLeftSensorGunPort() != null){
|
|
|
|
|
|
|
|
SensorGun sensorGun = new SensorGun();
|
|
|
|
|
|
|
|
sensorGun.setStreetId(streetId);
|
|
|
|
|
|
|
|
sensorGun.setDirection(1);
|
|
|
|
|
|
|
|
sensorGun.setIp(streetVO.getLeftSensorGunIp());
|
|
|
|
|
|
|
|
sensorGun.setPort(streetVO.getLeftSensorGunPort());
|
|
|
|
|
|
|
|
sensorGunMapper.insert(sensorGun);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!StringUtils.isEmpty(streetVO.getRightSensorGunIp()) && streetVO.getRightSensorGunPort() != null){
|
|
|
|
|
|
|
|
SensorGun sensorGun = new SensorGun();
|
|
|
|
|
|
|
|
sensorGun.setStreetId(streetId);
|
|
|
|
|
|
|
|
sensorGun.setDirection(2);
|
|
|
|
|
|
|
|
sensorGun.setIp(streetVO.getRightSensorGunIp());
|
|
|
|
|
|
|
|
sensorGun.setPort(streetVO.getRightSensorGunPort());
|
|
|
|
|
|
|
|
sensorGunMapper.insert(sensorGun);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|