fire_point/src/main/java/com/xkrs/controller/FirePointController.java

178 lines
6.8 KiB
Java
Raw Normal View History

2021-07-13 10:18:08 +08:00
package com.xkrs.controller;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.common.tool.TokenUtil;
import com.xkrs.dao.SysUserDao;
2021-07-13 10:18:08 +08:00
import com.xkrs.model.entity.FirePointEntity;
import com.xkrs.model.entity.SysUserEntity;
2021-07-13 10:18:08 +08:00
import com.xkrs.model.qo.FirePointQo;
2021-07-16 10:47:24 +08:00
import com.xkrs.model.vo.AppTaskBodyVo;
2021-07-13 10:18:08 +08:00
import com.xkrs.service.FirePointService;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
2021-07-16 10:47:24 +08:00
import org.springframework.web.multipart.MultipartFile;
2021-07-13 10:18:08 +08:00
import javax.annotation.Resource;
2021-07-16 10:47:24 +08:00
import java.io.IOException;
2021-07-15 15:22:23 +08:00
import java.util.List;
2021-07-13 10:18:08 +08:00
import java.util.Locale;
import java.util.Map;
2021-07-13 10:18:08 +08:00
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
/**
* @author XinYi Song
*/
@RestController
public class FirePointController {
2021-07-13 10:18:08 +08:00
@Resource
private FirePointService firePointService;
@Resource
private SysUserDao sysUserDao;
2021-07-13 10:18:08 +08:00
/**
* 添加火点数据
* @param firePointQo
* @return
*/
@PostMapping("/insertFirePoint")
public String insertFirePoint(@RequestBody FirePointQo firePointQo){
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
FirePointEntity firePointEntity = firePointService.insertFirePoint(firePointQo);
if(firePointEntity == null){
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"添加数据失败",locale);
}else {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"添加成功",locale);
}
}
/**
* 测试
* @param token
* @return
*/
@GetMapping("/selectUserName")
@PreAuthorize("hasAnyAuthority('auth_general_user')")
public String selectUserName(@RequestHeader(value="Authorization") String token){
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
// 验证token
String tokenUserName = TokenUtil.getTokenUserName(token);
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
if(sysUserEntity == null){
return outputEncapsulationObject(PromptMessageEnum.USER_LOGIN_ERROR,"您还没有注册登录,请先注册登录",locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,sysUserEntity.getUserName(),locale);
}
2021-07-15 15:22:23 +08:00
/**
* 查询今天的好点信息
* @param token
* @return
*/
@GetMapping("/selectTodayFirePoint")
@PreAuthorize("hasAnyAuthority('auth_general_user')")
public String selectTodayFirePoint(@RequestHeader(value="Authorization") String token){
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
List<FirePointEntity> firePointEntities = firePointService.selectTodayFirePoint();
if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
}
/**
* 动态多条件查询火点信息
* @param map
* @param token
* @return
*/
@PostMapping("/selectFirePoint")
@PreAuthorize("hasAnyAuthority('auth_general_user')")
public String selectFirePoint(@RequestBody Map map,@RequestHeader(value="Authorization") String token){
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
// 区县编码
String cityCode = (String) map.get("cityCode");
// 卫星类型
String satelliteType = (String) map.get("satelliteType");
// 植被类型
String landType = (String) map.get("landType");
// 开始时间
String startTime = (String) map.get("startTime");
// 结束时间
String endTime = (String) map.get("endTime");
List<FirePointEntity> firePointEntities = firePointService.selectFirePoint(cityCode, satelliteType, landType, startTime, endTime);
if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
}
/**
* 根据火点编码修改火点状态
* @param map
* @param token
* @return
*/
@PostMapping("/updateTypeByFireCode")
@PreAuthorize("hasAnyAuthority('auth_general_user')")
public String updateTypeByFireCode(@RequestBody Map map, @RequestHeader(value="Authorization") String token){
String fireCode = (String) map.get("fireCode");
String fireType = (String) map.get("fireType");
return firePointService.updateTypeByFireCode(fireCode,fireType,token);
}
2021-07-16 10:47:24 +08:00
/**
* 提交核查任务
* @param files
* @param appTaskBodyVo
* @return
*/
@PostMapping("/insertAppTask")
public String insertAppTask(@RequestParam("files") MultipartFile[] files, AppTaskBodyVo appTaskBodyVo) throws IOException {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
if("".equals(appTaskBodyVo.getFireCode()) || appTaskBodyVo.getFireCode() == null){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"火点编码不能为空",locale);
}
if("".equals(appTaskBodyVo.getTaskInformation()) || appTaskBodyVo.getTaskInformation() == null){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"任务描述不能为空",locale);
}
if(files == null || files.length == 0 ){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"图片不能为空",locale);
}
return firePointService.insertAppTask(files,appTaskBodyVo);
}
/**
* 查询核查的任务信息
* @param fireCode
* @return
*/
@GetMapping("/selectAppTask")
public String selectAppTask(@RequestParam("fireCode") String fireCode) throws Exception {
return firePointService.selectAppTask(fireCode);
}
/**
* 查询近一周的火点信息
* @return
*/
@GetMapping("/selectFirePointBetweenSeven")
public String selectFirePointBetweenSeven(){
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
List<FirePointEntity> firePointEntities = firePointService.selectFirePointBetweenSeven();
if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有火点数据",locale);
}
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,firePointEntities,locale);
}
2021-07-13 10:18:08 +08:00
}