更新火点的街道编号数据
This commit is contained in:
parent
4dc916fd88
commit
43e2b0e357
@ -59,6 +59,16 @@ public class FirePointController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新火点的街道编号数据
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/updateFirePointStreetCode")
|
||||||
|
public String updateFirePointStreetCode() {
|
||||||
|
return firePointService.updateFirePointStreetCode();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试
|
* 测试
|
||||||
*
|
*
|
||||||
|
@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Modifying;
|
|||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.transaction.Transactional;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -26,16 +27,6 @@ public interface FirePointDao extends JpaRepository<FirePointEntity, Long>, JpaS
|
|||||||
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and fire_point_address like CONCAT('%',:address,'%')", nativeQuery = true)
|
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and fire_point_address like CONCAT('%',:address,'%')", nativeQuery = true)
|
||||||
List<FirePointEntity> selectTodayFirePoint(String addTime, String address);
|
List<FirePointEntity> selectTodayFirePoint(String addTime, String address);
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询山东省今天火点信息
|
|
||||||
*
|
|
||||||
* @param addTime
|
|
||||||
* @param address
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and fire_point_address like CONCAT('%',:address,'%') and land_type != '耕地'", nativeQuery = true)
|
|
||||||
List<FirePointEntity> selectTodayFirePointShandong(String addTime, String address);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 区县条件查询今天火点信息
|
* 区县条件查询今天火点信息
|
||||||
*
|
*
|
||||||
@ -56,17 +47,6 @@ public interface FirePointDao extends JpaRepository<FirePointEntity, Long>, JpaS
|
|||||||
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and street_code = :streetCode", nativeQuery = true)
|
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and street_code = :streetCode", nativeQuery = true)
|
||||||
List<FirePointEntity> selectTodayFirePointOneStreet(String addTime, String streetCode);
|
List<FirePointEntity> selectTodayFirePointOneStreet(String addTime, String streetCode);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询山东省县的今天火点信息
|
|
||||||
*
|
|
||||||
* @param addTime
|
|
||||||
* @param countyCode
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%') and county_code = :countyCode and land_type != '耕地'", nativeQuery = true)
|
|
||||||
List<FirePointEntity> selectTodayFirePointOneShandong(String addTime, String countyCode);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据火点编码查询火点信息
|
* 根据火点编码查询火点信息
|
||||||
*
|
*
|
||||||
@ -139,4 +119,9 @@ public interface FirePointDao extends JpaRepository<FirePointEntity, Long>, JpaS
|
|||||||
@Modifying(clearAutomatically = true)
|
@Modifying(clearAutomatically = true)
|
||||||
@Query(value = "update fire_point set before_fire_image = ?2,after_fire_image = ?3 where fire_code = ?1", nativeQuery = true)
|
@Query(value = "update fire_point set before_fire_image = ?2,after_fire_image = ?3 where fire_code = ?1", nativeQuery = true)
|
||||||
void updateBeforeFireAndAfterFireImage(String fireCode, String beforeFireImage, String afterFireImage);
|
void updateBeforeFireAndAfterFireImage(String fireCode, String beforeFireImage, String afterFireImage);
|
||||||
|
|
||||||
|
@Transactional(rollbackOn = Exception.class)
|
||||||
|
@Modifying(clearAutomatically = true)
|
||||||
|
@Query(value = "UPDATE fire_point SET street_code = ?2 WHERE id = ?1", nativeQuery = true)
|
||||||
|
void updateStreetCodeById(Integer id, String streetCode);
|
||||||
}
|
}
|
||||||
|
@ -187,4 +187,11 @@ public interface FirePointService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<FirePoint> selectTodayFire(String countyCode);
|
List<FirePoint> selectTodayFire(String countyCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新火点的街道编号数据
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String updateFirePointStreetCode();
|
||||||
}
|
}
|
||||||
|
@ -147,6 +147,7 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
firePointEntity.setStreetCode(townCode);
|
firePointEntity.setStreetCode(townCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询今天的火点信息
|
* 查询今天的火点信息
|
||||||
*/
|
*/
|
||||||
@ -598,4 +599,57 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
return fireDao.selectTodayFireOne(addTime, countyCode);
|
return fireDao.selectTodayFireOne(addTime, countyCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新火点的街道编号数据
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String updateFirePointStreetCode() {
|
||||||
|
System.out.println("开始格式化街道编号");
|
||||||
|
List<FirePointEntity> firePointEntityList = firePointDao.findAll();
|
||||||
|
long startTimeMillis = System.currentTimeMillis();
|
||||||
|
int listSize = firePointEntityList.size();
|
||||||
|
for (int i = 0; i < listSize; i++) {
|
||||||
|
try {
|
||||||
|
FirePointEntity firePointEntity = firePointEntityList.get(i);
|
||||||
|
List<String> locationList = new ArrayList<>();
|
||||||
|
locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude());
|
||||||
|
GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList);
|
||||||
|
String townCode = geocode.getRegeocodes().get(0).getAddressComponent().get(0).getTowncode();
|
||||||
|
if (townCode.length() > 9) {
|
||||||
|
townCode = townCode.substring(0, 9);
|
||||||
|
}
|
||||||
|
firePointDao.updateStreetCodeById(firePointEntity.getId(), townCode);
|
||||||
|
if (i % 10 == 0) {
|
||||||
|
long spendTimeMillis = System.currentTimeMillis() - startTimeMillis;
|
||||||
|
double remainTimeMillis = (listSize - i) * spendTimeMillis * 1D / i;
|
||||||
|
System.out.println("已完成(" + i + "/" + listSize + "),用时" + formatDuring(spendTimeMillis) + ",剩余" + formatDuring((long) remainTimeMillis));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.out.println("街道编号格式化出现错误:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "街道编号格式化完毕", locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String formatDuring(long mss) {
|
||||||
|
long days = mss / (1000 * 60 * 60 * 24);
|
||||||
|
long hours = (mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
|
||||||
|
long minutes = (mss % (1000 * 60 * 60)) / (1000 * 60);
|
||||||
|
long seconds = (mss % (1000 * 60)) / 1000;
|
||||||
|
if (days <= 0 && hours <= 0 && minutes <= 0) {
|
||||||
|
return seconds + " 秒 ";
|
||||||
|
}
|
||||||
|
if (days <= 0 && hours <= 0) {
|
||||||
|
return minutes + " 分钟 " + seconds + " 秒 ";
|
||||||
|
}
|
||||||
|
if (days <= 0) {
|
||||||
|
return hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 ";
|
||||||
|
}
|
||||||
|
return days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user