|
|
|
|
@ -10,6 +10,8 @@ import com.zhehekeji.web.pojo.street.StreetSearch;
|
|
|
|
|
import com.zhehekeji.web.pojo.street.StreetVO;
|
|
|
|
|
import com.zhehekeji.web.service.LightSourceService;
|
|
|
|
|
import com.zhehekeji.web.service.StreetService;
|
|
|
|
|
import com.zhehekeji.web.service.client.ClientChanel;
|
|
|
|
|
import com.zhehekeji.web.service.client.LCTransmission;
|
|
|
|
|
import com.zhehekeji.web.service.damLightSource.JYDAMEquip;
|
|
|
|
|
import com.zhehekeji.web.service.damLightSource.JYDamHelper;
|
|
|
|
|
import com.zhehekeji.web.service.hikLightSource.HikControlSocket;
|
|
|
|
|
@ -81,87 +83,38 @@ public class StreetController {
|
|
|
|
|
@GetMapping("/lightSource/open")
|
|
|
|
|
@ApiOperation(value = "开启光源")
|
|
|
|
|
public Result openLightSource(){
|
|
|
|
|
List<LightSource> lightSources = lightSourceService.getLightSource();
|
|
|
|
|
|
|
|
|
|
lightSources.forEach(lightSource -> {
|
|
|
|
|
JSONObject obj = JSONObject.parseObject(configProperties.getLightSource().getInfo());
|
|
|
|
|
if(configProperties.getLightSource().getType() == 1){
|
|
|
|
|
|
|
|
|
|
JYDAMEquip equip = JYDamHelper.Connect(lightSource.getIp(),lightSource.getPort());
|
|
|
|
|
JYDamHelper.openDO(equip,configProperties.getLightSource().getIndex());
|
|
|
|
|
Integer status = JYDamHelper.ReadStatus(equip,configProperties.getLightSource().getNum(),configProperties.getLightSource().getIndex());
|
|
|
|
|
log.info("ip:{},status:{}",lightSource.getIp(),status);
|
|
|
|
|
equip.DisConnect();
|
|
|
|
|
|
|
|
|
|
}else if(configProperties.getLightSource().getType() == 2){
|
|
|
|
|
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClientChanel.keys().forEach(k->{
|
|
|
|
|
LCTransmission lcTransmission = new LCTransmission(k,1);
|
|
|
|
|
ClientChanel.write(lcTransmission.toString(),k);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/lightSource/close")
|
|
|
|
|
@ApiOperation(value = "关闭光源")
|
|
|
|
|
public Result closeLightSource(){
|
|
|
|
|
|
|
|
|
|
List<LightSource> lightSources = lightSourceService.getLightSource();
|
|
|
|
|
|
|
|
|
|
lightSources.forEach(lightSource -> {
|
|
|
|
|
JSONObject obj = JSONObject.parseObject(configProperties.getLightSource().getInfo());
|
|
|
|
|
if(configProperties.getLightSource().getType() == 1){
|
|
|
|
|
|
|
|
|
|
JYDAMEquip equip = JYDamHelper.Connect(lightSource.getIp(),lightSource.getPort());
|
|
|
|
|
JYDamHelper.closeDO(equip,obj.getInteger("index"));
|
|
|
|
|
Integer status = JYDamHelper.ReadStatus(equip,obj.getInteger("num"),obj.getInteger("index"));
|
|
|
|
|
log.info("ip:{},status:{}",lightSource.getIp(),status);
|
|
|
|
|
}else if(configProperties.getLightSource().getType() == 2){
|
|
|
|
|
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClientChanel.keys().forEach(k->{
|
|
|
|
|
LCTransmission lcTransmission = new LCTransmission(k,0);
|
|
|
|
|
ClientChanel.write(lcTransmission.toString(),k);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/lightSource/open/{streetId}")
|
|
|
|
|
@ApiOperation(value = "开启单个巷道光源")
|
|
|
|
|
public Result openStreetLightSource(@PathVariable Integer streetId){
|
|
|
|
|
List<LightSource> lightSources = lightSourceService.getLightSourceByStreetId(streetId);
|
|
|
|
|
lightSources.forEach(lightSource -> {
|
|
|
|
|
if(configProperties.getLightSource().getType() == 1){
|
|
|
|
|
JYDAMEquip equip = JYDamHelper.Connect(lightSource.getIp(),lightSource.getPort());
|
|
|
|
|
JYDamHelper.openDO(equip,configProperties.getLightSource().getIndex());
|
|
|
|
|
Integer status = JYDamHelper.ReadStatus(equip,configProperties.getLightSource().getNum(),configProperties.getLightSource().getIndex());
|
|
|
|
|
log.info("ip:{},status:{}",lightSource.getIp(),status);
|
|
|
|
|
equip.DisConnect();
|
|
|
|
|
}else if(configProperties.getLightSource().getType() == 2){
|
|
|
|
|
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Street street = streetService.streetById(streetId);
|
|
|
|
|
LCTransmission lcTransmission = new LCTransmission(street.getPlcId(),1);
|
|
|
|
|
ClientChanel.write(lcTransmission.toString(),street.getPlcId());
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/lightSource/close/{streetId}")
|
|
|
|
|
@ApiOperation(value = "关闭单个巷道光源")
|
|
|
|
|
public Result closeStreetLightSource(@PathVariable Integer streetId){
|
|
|
|
|
List<LightSource> lightSources = lightSourceService.getLightSourceByStreetId(streetId);
|
|
|
|
|
lightSources.forEach(lightSource -> {
|
|
|
|
|
if(configProperties.getLightSource().getType() == 1){
|
|
|
|
|
JYDAMEquip equip = JYDamHelper.Connect(lightSource.getIp(),lightSource.getPort());
|
|
|
|
|
JYDamHelper.closeDO(equip,configProperties.getLightSource().getIndex());
|
|
|
|
|
Integer status = JYDamHelper.ReadStatus(equip,configProperties.getLightSource().getNum(),configProperties.getLightSource().getIndex());
|
|
|
|
|
log.info("ip:{},status:{}",lightSource.getIp(),status);
|
|
|
|
|
equip.DisConnect();
|
|
|
|
|
}else if(configProperties.getLightSource().getType() == 2){
|
|
|
|
|
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Street street = streetService.streetById(streetId);
|
|
|
|
|
LCTransmission lcTransmission = new LCTransmission(street.getPlcId(),0);
|
|
|
|
|
ClientChanel.write(lcTransmission.toString(),street.getPlcId());
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|