|
@@ -4,11 +4,14 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ruoyi.common.core.redis.RedisCache;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.qdtl.domain.TlArea;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.ruoyi.qdtl.mapper.TlInspectionDeviceMapper;
|
|
|
import com.ruoyi.qdtl.domain.TlInspectionDevice;
|
|
@@ -16,49 +19,53 @@ import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
|
|
|
|
|
|
/**
|
|
|
* 巡检设备管理Service业务层处理
|
|
|
- *
|
|
|
+ *
|
|
|
* @author ruoyi
|
|
|
* @date 2022-02-22
|
|
|
*/
|
|
|
@Service
|
|
|
-public class TlInspectionDeviceServiceImpl implements ITlInspectionDeviceService
|
|
|
-{
|
|
|
+public class TlInspectionDeviceServiceImpl implements ITlInspectionDeviceService {
|
|
|
@Autowired
|
|
|
private TlInspectionDeviceMapper tlInspectionDeviceMapper;
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
|
|
|
/**
|
|
|
* 查询巡检设备管理
|
|
|
- *
|
|
|
+ *
|
|
|
* @param id 巡检设备管理主键
|
|
|
* @return 巡检设备管理
|
|
|
*/
|
|
|
@Override
|
|
|
- public TlInspectionDevice selectTlInspectionDeviceById(Long id)
|
|
|
- {
|
|
|
- return tlInspectionDeviceMapper.selectTlInspectionDeviceById(id);
|
|
|
+ public TlInspectionDevice selectTlInspectionDeviceById(Long id) {
|
|
|
+ TlInspectionDevice cacheObject = redisCache.getCacheObject("tl:device:info:" + id);
|
|
|
+ if (cacheObject != null) {
|
|
|
+ return cacheObject;
|
|
|
+ }
|
|
|
+ TlInspectionDevice tlInspectionDevice = tlInspectionDeviceMapper.selectTlInspectionDeviceById(id);
|
|
|
+ redisCache.setCacheObject("tl:device:info:" + id, tlInspectionDevice);
|
|
|
+ return tlInspectionDevice;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询巡检设备管理列表
|
|
|
- *
|
|
|
+ *
|
|
|
* @param tlInspectionDevice 巡检设备管理
|
|
|
* @return 巡检设备管理
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<TlInspectionDevice> selectTlInspectionDeviceList(TlInspectionDevice tlInspectionDevice)
|
|
|
- {
|
|
|
+ public List<TlInspectionDevice> selectTlInspectionDeviceList(TlInspectionDevice tlInspectionDevice) {
|
|
|
return tlInspectionDeviceMapper.selectTlInspectionDeviceList(tlInspectionDevice);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增巡检设备管理
|
|
|
- *
|
|
|
+ *
|
|
|
* @param tlInspectionDevice 巡检设备管理
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertTlInspectionDevice(TlInspectionDevice tlInspectionDevice)
|
|
|
- {
|
|
|
+ public int insertTlInspectionDevice(TlInspectionDevice tlInspectionDevice) {
|
|
|
tlInspectionDevice.setCreateTime(DateUtils.getNowDate());
|
|
|
// 控制编号和名称不能重复
|
|
|
int count = tlInspectionDeviceMapper.selectExist(tlInspectionDevice);
|
|
@@ -70,13 +77,12 @@ public class TlInspectionDeviceServiceImpl implements ITlInspectionDeviceService
|
|
|
|
|
|
/**
|
|
|
* 修改巡检设备管理
|
|
|
- *
|
|
|
+ *
|
|
|
* @param tlInspectionDevice 巡检设备管理
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateTlInspectionDevice(TlInspectionDevice tlInspectionDevice)
|
|
|
- {
|
|
|
+ public int updateTlInspectionDevice(TlInspectionDevice tlInspectionDevice) {
|
|
|
tlInspectionDevice.setUpdateTime(DateUtils.getNowDate());
|
|
|
// 查询原有的数据
|
|
|
TlInspectionDevice old = selectTlInspectionDeviceById(tlInspectionDevice.getId());
|
|
@@ -100,35 +106,36 @@ public class TlInspectionDeviceServiceImpl implements ITlInspectionDeviceService
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return tlInspectionDeviceMapper.updateTlInspectionDevice(tlInspectionDevice);
|
|
|
+ int i = tlInspectionDeviceMapper.updateTlInspectionDevice(tlInspectionDevice);
|
|
|
+ redisCache.deleteObject("tl:device:info:" + tlInspectionDevice.getId());
|
|
|
+ return i;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 批量删除巡检设备管理
|
|
|
- *
|
|
|
+ *
|
|
|
* @param ids 需要删除的巡检设备管理主键
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteTlInspectionDeviceByIds(Long[] ids)
|
|
|
- {
|
|
|
+ public int deleteTlInspectionDeviceByIds(Long[] ids) {
|
|
|
return tlInspectionDeviceMapper.deleteTlInspectionDeviceByIds(ids);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除巡检设备管理信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param id 巡检设备管理主键
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteTlInspectionDeviceById(Long id)
|
|
|
- {
|
|
|
+ public int deleteTlInspectionDeviceById(Long id) {
|
|
|
+ redisCache.deleteObject("tl:device:info:" + id);
|
|
|
return tlInspectionDeviceMapper.deleteTlInspectionDeviceById(id);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String,Integer> queryDeviceByArea() {
|
|
|
+ public Map<String, Integer> queryDeviceByArea() {
|
|
|
List<JSONObject> jsonObjects = tlInspectionDeviceMapper.queryDeviceByArea();
|
|
|
return jsonObjects.stream().collect(Collectors.toMap(a -> a.getString("areaId"), b -> b.getInteger("cnt")));
|
|
|
}
|