优化代码,添加了查询今日火点信息测试的接口

This commit is contained in:
DESKTOP-G8BCEP0\HP 2021-09-29 08:32:23 +08:00
parent 28741f5585
commit 7a88b4f8df
9 changed files with 70 additions and 22 deletions

View File

@ -6,11 +6,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
<relativePath/>
</parent>
<groupId>com.xkrs</groupId>
<artifactId>fire_point</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.1</version>
<name>fire_point</name>
<description>火点项目</description>
<properties>
@ -206,11 +206,6 @@
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.0.6</version>
</dependency>
<!--<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>${dysmsapi20170525.version}</version>
</dependency>-->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>

View File

@ -67,7 +67,6 @@ public class FileController {
filePath.setScene(map.get("scene"));
filePathDao.save(filePath);
}
//List<Map<String, String>> path = filePathDao.findPath();
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "上传成功!", locale);
}
@ -100,7 +99,6 @@ public class FileController {
filePath.setMd5(map.get("md5"));
filePath.setScene(map.get("scene"));
filePathDao.save(filePath);
//List<Map<String, String>> path = filePathDao.findPath();
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "上传成功!", locale);
}

View File

@ -307,4 +307,21 @@ public class FirePointController {
firePointService.importCityExcel(file);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"导入成功",locale);
}
/**
* 查询今天的火点信息(测试)
* @param token
* @return
*/
@GetMapping("/selectTodayFire")
@PreAuthorize("hasAnyAuthority('auth_general_user')")
public String selectTodayFire(@RequestParam("countyCode") String countyCode,@RequestHeader(value="Authorization") String token){
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
List<FirePoint> firePointEntities = firePointService.selectTodayFire(countyCode);
if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
}
}

View File

@ -86,16 +86,6 @@ public class SysUserController {
return sysUserService.addUser(userQo);
}
/*@RequestMapping(value="/get/all", method = RequestMethod.GET)
@PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')")
public String getAllSysUser(){
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
Iterable<SysUserVo> sysUserDtoList = sysUserService.getAllSysUser();
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,sysUserDtoList,locale);
}*/
/**
* 软删除指定id的普通用户
* @param id

View File

@ -1,13 +1,35 @@
package com.xkrs.dao;
import com.xkrs.model.entity.FirePoint;
import com.xkrs.model.entity.FirePointEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author XinYi Song
*/
@Component
public interface FireDao extends JpaRepository<FirePoint,Long> {
/**
* 查询今天的火点信息
* @param addTime
* @param address
* @return
*/
@Query(value = "select * from fire where add_time like CONCAT('%',:addTime,'%') and fire_point_address like CONCAT('%',:address,'%')",nativeQuery = true)
List<FirePoint> selectTodayFire(String addTime, String address);
/**
* 区县条件查询今天火点信息
* @param addTime
* @param countyCode
* @return
*/
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and county_code = :countyCode",nativeQuery = true)
List<FirePoint> selectTodayFireOne(String addTime,String countyCode);
}

View File

@ -19,7 +19,7 @@ public interface NationwideDao extends JpaRepository<Nationwide,Long> {
* @param proCode
* @return
*/
@Query(value = "select city_name,city_code from nationwide where pro_code = ?",nativeQuery = true)
@Query(value = "select DISTINCT city_name,city_code from nationwide where pro_code = ?",nativeQuery = true)
List<Map<String,String>> findCityByProCode(String proCode);
/**

View File

@ -150,4 +150,11 @@ public interface FirePointService {
* @throws Exception
*/
void importCityExcel(MultipartFile file) throws Exception;
/**
* 查询今日火点信息测试
* @param countyCode
* @return
*/
List<FirePoint> selectTodayFire(String countyCode);
}

View File

@ -86,8 +86,6 @@ public class FireAndRangerServiceImpl implements FireAndRangerService {
String content = JSON.toJSONString(map);
String ss = URLEncoder.encode(content,"utf-8");
//String url = "https://api.xmpush.xiaomi.com/v3/message/alias?title=收到消息&description=请"+rangerName+ "去核查该火点信息&payload="+content+"&restricted_package_name=com.xkrs.fieldverification&notify_id=1&extra.notify_effect=2&extra.intent_uri=fieldverify://xkrs.com&alias="+rangerName;
String url = "https://api.xmpush.xiaomi.com/v3/message/alias?title=收到消息&description=请"+verifier+"去核查该火点信息&payload="+ss+"&restricted_package_name=com.xkrs.fieldverification&notify_id=2&extra.notify_effect=2&extra.intent_uri=fieldverify://xkrs.com&alias="+rangerName+"&extra.notify_foreground=0&extra.channel_id=mipush";
String time = DateTimeUtil.dateTimeToString(LocalDateTime.now());

View File

@ -485,4 +485,25 @@ public class FirePointServiceImpl implements FirePointService {
//批量添加到订单详情
nationwideDao.saveAll(orderDetails);
}
/**
* 查询今日的火点信息测试
* @param countyCode
* @return
*/
@Override
public List<FirePoint> selectTodayFire(String countyCode) {
String addTime = DateTimeUtil.dateToString(LocalDate.now());
if("0000".equals(countyCode.substring(2))){
List<CityEntity> byProCode = cityDao.findByProCode(countyCode);
String proName = byProCode.get(0).getProName();
return fireDao.selectTodayFire(addTime,proName);
}else if("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))){
List<CountyEntity> byCityCode = countyDao.findByCityCode(countyCode);
String cityName = byCityCode.get(0).getCityName();
return fireDao.selectTodayFire(addTime,cityName);
}else {
return fireDao.selectTodayFireOne(addTime,countyCode);
}
}
}