添加了分配火点任务,护林员查看火点任务,查询核查信息的接口
This commit is contained in:
parent
1c07a698ad
commit
a447322089
@ -1,7 +1,6 @@
|
|||||||
package com.xkrs.controller;
|
package com.xkrs.controller;
|
||||||
|
|
||||||
import com.xkrs.service.FireAndRangerService;
|
import com.xkrs.service.FireAndRangerService;
|
||||||
import com.xkrs.utils.Result;
|
|
||||||
import org.springframework.security.access.annotation.Secured;
|
import org.springframework.security.access.annotation.Secured;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -25,9 +24,9 @@ public class FireAndRangerController {
|
|||||||
* @param token
|
* @param token
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("hasAnyRole('ROLE_city','ROLE_county')")
|
@PreAuthorize("hasAnyAuthority('auth_general_user')")
|
||||||
@PostMapping("/addFireAndRanger")
|
@PostMapping("/addFireAndRanger")
|
||||||
public Result addFireAndRanger(@RequestBody Map map, @RequestHeader(value="Authorization") String token) throws UnsupportedEncodingException {
|
public String addFireAndRanger(@RequestBody Map map, @RequestHeader(value="Authorization") String token) throws UnsupportedEncodingException {
|
||||||
String rangerName = (String) map.get("rangerName");
|
String rangerName = (String) map.get("rangerName");
|
||||||
String fireCode = (String) map.get("fireCode");
|
String fireCode = (String) map.get("fireCode");
|
||||||
String handler = (String) map.get("handler");
|
String handler = (String) map.get("handler");
|
||||||
@ -40,9 +39,9 @@ public class FireAndRangerController {
|
|||||||
* @param token
|
* @param token
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Secured("ROLE_ranger")
|
@PreAuthorize("hasAnyAuthority('auth_general_user')")
|
||||||
@GetMapping("/selectFireInformation")
|
@GetMapping("/selectFireInformation")
|
||||||
public Result selectFireInformation(@RequestHeader(value="Authorization") String token){
|
public String selectFireInformation(@RequestHeader(value="Authorization") String token){
|
||||||
return fireAndRangerService.selectFireInformation(token);
|
return fireAndRangerService.selectFireInformation(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,9 +50,9 @@ public class FireAndRangerController {
|
|||||||
* @param map
|
* @param map
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("hasAnyRole('ROLE_city','ROLE_county')")
|
@PreAuthorize("hasAnyAuthority('auth_general_user')")
|
||||||
@PostMapping("/findFireAndRanger")
|
@PostMapping("/findFireAndRanger")
|
||||||
public Result findFireAndRangerByFireCode(@RequestBody Map map, @RequestHeader(value="Authorization") String token) throws Exception {
|
public String findFireAndRangerByFireCode(@RequestBody Map map, @RequestHeader(value="Authorization") String token) throws Exception {
|
||||||
String fireCode = (String) map.get("fireCode");
|
String fireCode = (String) map.get("fireCode");
|
||||||
return fireAndRangerService.findFireAndRangerByFireCode(fireCode,token);
|
return fireAndRangerService.findFireAndRangerByFireCode(fireCode,token);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.xkrs.dao;
|
package com.xkrs.dao;
|
||||||
|
|
||||||
import com.xkrs.entity.FireAndRanger;
|
import com.xkrs.model.entity.FireAndRanger;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
@ -23,6 +23,7 @@ public interface FireAndRangerDao extends JpaRepository<FireAndRanger,Long>, Jpa
|
|||||||
/**
|
/**
|
||||||
* 根据护林员手机号查询
|
* 根据护林员手机号查询
|
||||||
* @param rangerName
|
* @param rangerName
|
||||||
|
* @param progressType
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
FireAndRanger findByRangerNameAndProgressType(String rangerName, String progressType);
|
FireAndRanger findByRangerNameAndProgressType(String rangerName, String progressType);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.xkrs.service;
|
package com.xkrs.service;
|
||||||
|
|
||||||
import com.xkrs.utils.Result;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,19 +16,19 @@ public interface FireAndRangerService {
|
|||||||
* @param verifier
|
* @param verifier
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Result addFireAndRanger(String rangerName, String fireCode, String handler, String verifier, String token) throws UnsupportedEncodingException;
|
String addFireAndRanger(String rangerName, String fireCode, String handler, String verifier, String token) throws UnsupportedEncodingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 护林员查看自己的火点任务
|
* 护林员查看自己的火点任务
|
||||||
* @param token
|
* @param token
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Result selectFireInformation(String token);
|
String selectFireInformation(String token);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据火点编码查询处理的信息
|
* 根据火点编码查询处理的信息
|
||||||
* @param fireCode
|
* @param fireCode
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Result findFireAndRangerByFireCode(String fireCode, String token) throws Exception;
|
String findFireAndRangerByFireCode(String fireCode, String token) throws Exception;
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,20 @@ package com.xkrs.service.impl;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
||||||
|
import com.xkrs.common.tool.TokenUtil;
|
||||||
import com.xkrs.dao.*;
|
import com.xkrs.dao.*;
|
||||||
import com.xkrs.entity.*;
|
import com.xkrs.model.entity.*;
|
||||||
|
import com.xkrs.model.vo.AppPhotoVo;
|
||||||
|
import com.xkrs.model.vo.AppTaskBodyVo;
|
||||||
import com.xkrs.service.FireAndRangerService;
|
import com.xkrs.service.FireAndRangerService;
|
||||||
import com.xkrs.utils.*;
|
import com.xkrs.utils.DateTimeUtil;
|
||||||
import com.xkrs.vo.AppPhotoVo;
|
import com.xkrs.utils.ObjectToBeanUtils;
|
||||||
import com.xkrs.vo.AppTaskBodyVo;
|
import com.xkrs.utils.RestTemplateUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.cglib.beans.BeanCopier;
|
import org.springframework.cglib.beans.BeanCopier;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -21,8 +26,11 @@ import java.net.URLEncoder;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xkrs
|
* @author xkrs
|
||||||
*/
|
*/
|
||||||
@ -35,13 +43,13 @@ public class FireAndRangerServiceImpl implements FireAndRangerService {
|
|||||||
private FireAndRangerDao fireAndRangerDao;
|
private FireAndRangerDao fireAndRangerDao;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ForestUserDao forestUserDao;
|
private SysUserDao sysUserDao;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private FirePointDao firePointDao;
|
private FirePointDao firePointDao;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private XkRsForestRangerDao forestRangerDao;
|
private ForestRangerDao forestRangerDao;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RestTemplateUtil restTemplateUtil;
|
private RestTemplateUtil restTemplateUtil;
|
||||||
@ -60,22 +68,21 @@ public class FireAndRangerServiceImpl implements FireAndRangerService {
|
|||||||
*/
|
*/
|
||||||
@Transactional(rollbackOn = Exception.class)
|
@Transactional(rollbackOn = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public Result addFireAndRanger(String rangerName, String fireCode, String handler, String verifier, String token) throws UnsupportedEncodingException {
|
public String addFireAndRanger(String rangerName, String fireCode, String handler, String verifier, String token) throws UnsupportedEncodingException {
|
||||||
|
// 获取区域信息
|
||||||
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
String tokenUserName = TokenUtil.getTokenUserName(token);
|
String tokenUserName = TokenUtil.getTokenUserName(token);
|
||||||
if(tokenUserName == null || "".equals(tokenUserName)){
|
|
||||||
return Result.error("您还未注册和登录,请先注册和登录!");
|
|
||||||
}
|
|
||||||
FireAndRanger byFireCode = fireAndRangerDao.findByFireCode(fireCode);
|
FireAndRanger byFireCode = fireAndRangerDao.findByFireCode(fireCode);
|
||||||
if(byFireCode != null){
|
if(byFireCode != null){
|
||||||
return Result.error("该火点已经分配,请勿重复操作");
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"该火点已经分配,请勿重复操作",locale);
|
||||||
}
|
}
|
||||||
XkRsFirePoint byFireCode1 = firePointDao.findByFireCode(fireCode);
|
FirePointEntity byFireCode1 = firePointDao.findByFireCode(fireCode);
|
||||||
// 给app端推送的消息内容
|
// 给app端推送的消息内容
|
||||||
|
|
||||||
Map<String,Object> map = new HashMap(3);
|
Map<String,Object> map = new HashMap(3);
|
||||||
map.put("latitude",byFireCode1.getLatitude());
|
map.put("latitude",byFireCode1.getLatitude());
|
||||||
map.put("longitude",byFireCode1.getLongitude());
|
map.put("longitude",byFireCode1.getLongitude());
|
||||||
map.put("detailedAddress",byFireCode1.getDetailedAddress());
|
map.put("detailedAddress",byFireCode1.getFirePointAddress());
|
||||||
String content = JSON.toJSONString(map);
|
String content = JSON.toJSONString(map);
|
||||||
String ss = URLEncoder.encode(content,"utf-8");
|
String ss = URLEncoder.encode(content,"utf-8");
|
||||||
|
|
||||||
@ -83,7 +90,7 @@ public class FireAndRangerServiceImpl implements FireAndRangerService {
|
|||||||
|
|
||||||
String url = "https://api.xmpush.xiaomi.com/v3/message/alias?title=收到消息&description=请"+verifier+"去核查该火点信息&payload="+ss+"&restricted_package_name=com.xkrs.fieldverification¬ify_id=2&extra.notify_effect=2&extra.intent_uri=fieldverify://xkrs.com&alias="+rangerName+"&extra.notify_foreground=0&extra.channel_id=mipush";
|
String url = "https://api.xmpush.xiaomi.com/v3/message/alias?title=收到消息&description=请"+verifier+"去核查该火点信息&payload="+ss+"&restricted_package_name=com.xkrs.fieldverification¬ify_id=2&extra.notify_effect=2&extra.intent_uri=fieldverify://xkrs.com&alias="+rangerName+"&extra.notify_foreground=0&extra.channel_id=mipush";
|
||||||
|
|
||||||
String time = LocalDateTimeUtil.localDateTime2String(LocalDateTime.now());
|
String time = DateTimeUtil.dateTimeToString(LocalDateTime.now());
|
||||||
FireAndRanger fireAndRanger = new FireAndRanger();
|
FireAndRanger fireAndRanger = new FireAndRanger();
|
||||||
fireAndRanger.setRangerName(rangerName);
|
fireAndRanger.setRangerName(rangerName);
|
||||||
fireAndRanger.setFireCode(fireCode);
|
fireAndRanger.setFireCode(fireCode);
|
||||||
@ -103,9 +110,9 @@ public class FireAndRangerServiceImpl implements FireAndRangerService {
|
|||||||
|
|
||||||
FireAndRanger save = fireAndRangerDao.save(fireAndRanger);
|
FireAndRanger save = fireAndRangerDao.save(fireAndRanger);
|
||||||
if(save == null){
|
if(save == null){
|
||||||
return Result.error("操作失败");
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"操作失败",locale);
|
||||||
}
|
}
|
||||||
return Result.ok("操作成功");
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"操作成功",locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,22 +121,21 @@ public class FireAndRangerServiceImpl implements FireAndRangerService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Result selectFireInformation(String token) {
|
public String selectFireInformation(String token) {
|
||||||
|
// 获取区域信息
|
||||||
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
String tokenUserName = TokenUtil.getTokenUserName(token);
|
String tokenUserName = TokenUtil.getTokenUserName(token);
|
||||||
if(tokenUserName == null || "".equals(tokenUserName)){
|
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
|
||||||
return Result.error("您还未注册和登录,请先注册和登录!");
|
ForestRanger byRangerPhone = forestRangerDao.findByRangerPhone(sysUserEntity.getUserName());
|
||||||
}
|
|
||||||
XkRsUser xkRsUser = forestUserDao.selectUserName(tokenUserName);
|
|
||||||
XkRsForestRanger byRangerPhone = forestRangerDao.findByRangerPhone(xkRsUser.getNickName());
|
|
||||||
if(byRangerPhone.getRangerType().equals("1")){
|
if(byRangerPhone.getRangerType().equals("1")){
|
||||||
FireAndRanger byRangerName = fireAndRangerDao.findByRangerNameAndProgressType(xkRsUser.getNickName(),"1");
|
FireAndRanger byRangerName = fireAndRangerDao.findByRangerNameAndProgressType(sysUserEntity.getUserName(),"1");
|
||||||
if(byRangerName == null){
|
if(byRangerName == null){
|
||||||
return Result.error("暂时还没有任何任务");
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有任何任务",locale);
|
||||||
}
|
}
|
||||||
XkRsFirePoint byFireCode = firePointDao.findByFireCode(byRangerName.getFireCode());
|
FirePointEntity byFireCode = firePointDao.findByFireCode(byRangerName.getFireCode());
|
||||||
return Result.ok(byFireCode);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,byFireCode,locale);
|
||||||
}else {
|
}else {
|
||||||
return Result.error("暂时还没有任务");
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有任何任务",locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -140,21 +146,20 @@ public class FireAndRangerServiceImpl implements FireAndRangerService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Result findFireAndRangerByFireCode(String fireCode, String token) throws Exception {
|
public String findFireAndRangerByFireCode(String fireCode, String token) throws Exception {
|
||||||
|
// 获取区域信息
|
||||||
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
String tokenUserName = TokenUtil.getTokenUserName(token);
|
String tokenUserName = TokenUtil.getTokenUserName(token);
|
||||||
if(tokenUserName == null || "".equals(tokenUserName)){
|
|
||||||
return Result.error("您还未注册和登录,请先注册和登录!");
|
|
||||||
}
|
|
||||||
FireAndRanger byFireCode = fireAndRangerDao.findByFireCode(fireCode);
|
FireAndRanger byFireCode = fireAndRangerDao.findByFireCode(fireCode);
|
||||||
if(byFireCode == null){
|
if(byFireCode == null){
|
||||||
return Result.error("暂时还没有该火点核查的信息");
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有该火点的核查信息",locale);
|
||||||
}
|
}
|
||||||
Map map = new HashMap(3);
|
Map map = new HashMap(3);
|
||||||
map.put("fire",byFireCode);
|
map.put("fire",byFireCode);
|
||||||
FireTask byTaskFireCode = fireTaskDao.findByTaskFireCode(fireCode);
|
FireTask byTaskFireCode = fireTaskDao.findByTaskFireCode(fireCode);
|
||||||
if(byTaskFireCode == null){
|
if(byTaskFireCode == null){
|
||||||
map.put("task",null);
|
map.put("task",null);
|
||||||
return Result.ok().data(map);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale);
|
||||||
}else {
|
}else {
|
||||||
AppTaskBodyVo appTaskBodyVo = new AppTaskBodyVo();
|
AppTaskBodyVo appTaskBodyVo = new AppTaskBodyVo();
|
||||||
// 做映射,返回vo类对象
|
// 做映射,返回vo类对象
|
||||||
@ -165,7 +170,7 @@ public class FireAndRangerServiceImpl implements FireAndRangerService {
|
|||||||
List<AppPhotoVo> appPhotoVos = ObjectToBeanUtils.objectToBean(photoPath, AppPhotoVo.class);
|
List<AppPhotoVo> appPhotoVos = ObjectToBeanUtils.objectToBean(photoPath, AppPhotoVo.class);
|
||||||
appTaskBodyVo.setTaskFirePhoto(appPhotoVos);
|
appTaskBodyVo.setTaskFirePhoto(appPhotoVos);
|
||||||
map.put("task",appTaskBodyVo);
|
map.put("task",appTaskBodyVo);
|
||||||
return Result.ok().data(map);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user