diff --git a/src/main/java/com/xkrs/controller/FireController.java b/src/main/java/com/xkrs/controller/FireController.java index e33d604..5ca617b 100644 --- a/src/main/java/com/xkrs/controller/FireController.java +++ b/src/main/java/com/xkrs/controller/FireController.java @@ -104,19 +104,11 @@ public class FireController { * @param map * @return */ - @Transactional(rollbackOn = Exception.class) + @PostMapping("/updateFireState") public String updateFireState(@RequestBody Map map){ String alarmCode = (String) map.get("alarmCode"); - Fire byAlarmCode = fireDao.findByAlarmCode(alarmCode); - if(byAlarmCode == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"火情编码错误,请检查!",locale); - } - if("1".equals(byAlarmCode.getFireState())){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"该火情已处理!",locale); - } - fireDao.updateFireState(alarmCode); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功!",locale); + return fireService.updateFireState(alarmCode); } /** diff --git a/src/main/java/com/xkrs/service/FireService.java b/src/main/java/com/xkrs/service/FireService.java index a4b7ff7..b40b49f 100644 --- a/src/main/java/com/xkrs/service/FireService.java +++ b/src/main/java/com/xkrs/service/FireService.java @@ -29,4 +29,11 @@ public interface FireService { * @return */ String findThreeHundredData(); + + /** + * 修改火点状态 + * @param alarmCode + * @return + */ + String updateFireState(String alarmCode); } diff --git a/src/main/java/com/xkrs/service/impl/FireServerImpl.java b/src/main/java/com/xkrs/service/impl/FireServerImpl.java index 49fb91e..308da11 100644 --- a/src/main/java/com/xkrs/service/impl/FireServerImpl.java +++ b/src/main/java/com/xkrs/service/impl/FireServerImpl.java @@ -6,11 +6,13 @@ import com.xkrs.model.entity.Fire; import com.xkrs.service.FireService; import com.xkrs.util.Query; import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import javax.transaction.Transactional; import java.util.List; import java.util.Locale; @@ -78,4 +80,24 @@ public class FireServerImpl implements FireService { } return outputEncapsulationObject(PromptMessageEnum.SUCCESS,threeHundredData,locale); } + + /** + * 修改火点状态 + * @param alarmCode + * @return + */ + @CacheEvict(value = "FireServiceCache",allEntries = true) + @Transactional(rollbackOn = Exception.class) + @Override + public String updateFireState(String alarmCode) { + Fire byAlarmCode = fireDao.findByAlarmCode(alarmCode); + if(byAlarmCode == null){ + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"火情编码错误,请检查!",locale); + } + if("1".equals(byAlarmCode.getFireState())){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"该火情已处理!",locale); + } + fireDao.updateFireState(alarmCode); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功!",locale); + } }