|
|
@@ -90,7 +90,16 @@ public class ActionConfigServiceImpl implements IActionConfigService {
|
|
|
@Override
|
|
|
public int insertActionConfig(ActionConfig actionConfig) {
|
|
|
actionConfig.setCreateTime(DateUtils.getNowDate());
|
|
|
- return actionConfigMapper.insert(actionConfig);
|
|
|
+ int i = actionConfigMapper.insert(actionConfig);
|
|
|
+ if (i > 0) {//更新缓存
|
|
|
+ System.out.println(actionConfig);
|
|
|
+ try {
|
|
|
+ actionCacheBuilder.addCache(actionConfig);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return i;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -102,7 +111,15 @@ public class ActionConfigServiceImpl implements IActionConfigService {
|
|
|
@Override
|
|
|
public int updateActionConfig(ActionConfig actionConfig) {
|
|
|
actionConfig.setUpdateTime(DateUtils.getNowDate());
|
|
|
- return actionConfigMapper.updateById(actionConfig);
|
|
|
+ int i = actionConfigMapper.updateById(actionConfig);
|
|
|
+ if (i > 0) {//更新缓存
|
|
|
+ try {
|
|
|
+ actionCacheBuilder.updateCache(actionConfig);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return i;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -113,7 +130,18 @@ public class ActionConfigServiceImpl implements IActionConfigService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int deleteActionConfigByActionIds(Long[] actionIds) {
|
|
|
- return actionConfigMapper.deleteBatchIds(Arrays.asList(actionIds));
|
|
|
+ List<Long> idList = Arrays.asList(actionIds);
|
|
|
+ int i = actionConfigMapper.deleteBatchIds(idList);
|
|
|
+ if (i > 0) {
|
|
|
+ for (Long id : idList) {
|
|
|
+ try {
|
|
|
+ actionCacheBuilder.deleteCache(id);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return i;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -124,7 +152,15 @@ public class ActionConfigServiceImpl implements IActionConfigService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int deleteActionConfigByActionId(Long actionId) {
|
|
|
- return actionConfigMapper.deleteById(actionId);
|
|
|
+ int i=actionConfigMapper.deleteById(actionId);
|
|
|
+ if (i > 0) {//更新缓存
|
|
|
+ try {
|
|
|
+ actionCacheBuilder.deleteCache(actionId);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return i;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -179,7 +215,7 @@ public class ActionConfigServiceImpl implements IActionConfigService {
|
|
|
@Scheduled(fixedRate = 3000) // 每 3 秒执行一次
|
|
|
public void checkActions() {
|
|
|
// 模拟数据
|
|
|
- EquipmentParamFormVo param = new EquipmentParamFormVo();
|
|
|
+// EquipmentParamFormVo param = new EquipmentParamFormVo();
|
|
|
// param.setCode("D2kxh");
|
|
|
// param.setValue(true);
|
|
|
// CacheCenter.registerNowDataMap.put("D2kxh",param);
|