|
|
|
|
@ -1,15 +1,20 @@
|
|
|
|
|
package com.zhehekeji.web.service;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.zhehekeji.core.util.Assert;
|
|
|
|
|
import com.zhehekeji.web.entity.LightSource;
|
|
|
|
|
import com.zhehekeji.web.entity.Street;
|
|
|
|
|
import com.zhehekeji.web.mapper.LightSourceMapper;
|
|
|
|
|
import com.zhehekeji.web.mapper.StreetMapper;
|
|
|
|
|
import com.zhehekeji.web.pojo.street.StreetSearch;
|
|
|
|
|
import com.zhehekeji.web.pojo.street.StreetType;
|
|
|
|
|
import com.zhehekeji.web.pojo.street.StreetVO;
|
|
|
|
|
import com.zhehekeji.web.service.robotic.NettyClient;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
|
|
import org.springframework.cache.annotation.CachePut;
|
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
|
@ -31,24 +36,34 @@ public class StreetService {
|
|
|
|
|
private StreetMapper streetMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private NettyClient nettyClient;
|
|
|
|
|
@Resource
|
|
|
|
|
private LightSourceMapper lightSourceMapper;
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
|
|
|
|
@Caching(
|
|
|
|
|
put = {
|
|
|
|
|
@CachePut(value = {"street"},key = "#street.id"),
|
|
|
|
|
@CachePut(value = {"streetByPlcId"},key = "#street.plcId"),
|
|
|
|
|
@CachePut(value = {"street"},key = "#streetVO.id"),
|
|
|
|
|
@CachePut(value = {"streetByPlcId"},key = "#streetVO.plcId"),
|
|
|
|
|
},
|
|
|
|
|
evict = {
|
|
|
|
|
@CacheEvict(value = "getStreetCount")
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
public Street add(Street street) {
|
|
|
|
|
public Street add(StreetVO streetVO) {
|
|
|
|
|
Street street = new Street();
|
|
|
|
|
BeanUtils.copyProperties(streetVO,street);
|
|
|
|
|
List<String> shelves = check(street);
|
|
|
|
|
street.setCreateTime(LocalDateTime.now());
|
|
|
|
|
street.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
street.setVideoStyleRow(1);
|
|
|
|
|
street.setVideoStyleColumn(1);
|
|
|
|
|
if(street.getCamera2Id() != null && street.getCamera2Id() != 0 && street.getCamera1Id() != null && street.getCamera1Id() != 0){
|
|
|
|
|
//如果两个球机 就显示2列
|
|
|
|
|
street.setVideoStyleColumn(2);
|
|
|
|
|
}else {
|
|
|
|
|
street.setVideoStyleColumn(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
streetMapper.insert(street);
|
|
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
|
@ -67,6 +82,11 @@ public class StreetService {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
thread.start();
|
|
|
|
|
LightSource lightSource = new LightSource();
|
|
|
|
|
lightSource.setStreetId(street.getId());
|
|
|
|
|
lightSource.setIp(streetVO.getLightSourceIp());
|
|
|
|
|
lightSource.setPort(streetVO.getLightSourcePort());
|
|
|
|
|
lightSourceMapper.insert(lightSource);
|
|
|
|
|
return street;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -127,17 +147,40 @@ public class StreetService {
|
|
|
|
|
|
|
|
|
|
@Caching(
|
|
|
|
|
evict = {
|
|
|
|
|
@CacheEvict(value = "street",key="#street.id"),
|
|
|
|
|
@CacheEvict(value = "streetByPlcId",key="#street.plcId"),
|
|
|
|
|
@CacheEvict(value = "street",key="#streetVO.id"),
|
|
|
|
|
@CacheEvict(value = "streetByPlcId",key="#streetVO.plcId"),
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
public void edit(Street street) {
|
|
|
|
|
public void edit(StreetVO streetVO) {
|
|
|
|
|
Street street = new Street();
|
|
|
|
|
BeanUtils.copyProperties(streetVO,street);
|
|
|
|
|
check(street);
|
|
|
|
|
if(street.getCamera2Id() != null && street.getCamera2Id() != 0 && street.getCamera1Id() != null && street.getCamera1Id() != 0){
|
|
|
|
|
//如果两个球机 就显示2列
|
|
|
|
|
street.setVideoStyleColumn(2);
|
|
|
|
|
}else {
|
|
|
|
|
street.setVideoStyleColumn(1);
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
streetMapper.updateById(street);
|
|
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
|
Assert.isTrue(false, "PLC ID已存在");
|
|
|
|
|
}
|
|
|
|
|
List<LightSource> list = lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id",street.getId()));
|
|
|
|
|
if(list.size() == 0){
|
|
|
|
|
LightSource lightSource = new LightSource();
|
|
|
|
|
lightSource.setPort(streetVO.getLightSourcePort());
|
|
|
|
|
lightSource.setIp(streetVO.getLightSourceIp());
|
|
|
|
|
lightSource.setStreetId(street.getId());
|
|
|
|
|
lightSourceMapper.insert(lightSource);
|
|
|
|
|
}else {
|
|
|
|
|
LightSource lightSource = new LightSource();
|
|
|
|
|
lightSource.setPort(streetVO.getLightSourcePort());
|
|
|
|
|
lightSource.setIp(streetVO.getLightSourceIp());
|
|
|
|
|
lightSourceMapper.update(lightSource,new UpdateWrapper<LightSource>().eq("street_id",street.getId()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Cacheable(value = "street",key = "#id")
|
|
|
|
|
|