Merge remote-tracking branch 'origin/branch_straw_fire_point_debug' into branch_straw_fire_point
This commit is contained in:
commit
d674f9f0cd
@ -6,14 +6,16 @@ import com.xkrs.dao.FirePointPreciseDao;
|
|||||||
import com.xkrs.dao.StreetDao;
|
import com.xkrs.dao.StreetDao;
|
||||||
import com.xkrs.dao.SysUserDao;
|
import com.xkrs.dao.SysUserDao;
|
||||||
import com.xkrs.helper.FirePointSubscribeManager;
|
import com.xkrs.helper.FirePointSubscribeManager;
|
||||||
import com.xkrs.model.entity.FirePointOrdinaryEntity;
|
import com.xkrs.model.bean.VipTimeRangeBean;
|
||||||
|
import com.xkrs.model.entity.SysUserEntity;
|
||||||
import com.xkrs.model.qo.AllFirePointQo;
|
import com.xkrs.model.qo.AllFirePointQo;
|
||||||
import com.xkrs.service.DispatchFirePointService;
|
import com.xkrs.service.DispatchFirePointService;
|
||||||
import com.xkrs.service.impl.FirePointServiceImpl;
|
import com.xkrs.service.impl.FirePointServiceImpl;
|
||||||
|
import com.xkrs.utilsnew.JsonUtils;
|
||||||
|
import com.xkrs.utilsold.DateTimeUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@ -23,7 +25,6 @@ import javax.annotation.Resource;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||||
|
|
||||||
@ -48,66 +49,42 @@ public class DispatchFirePointController {
|
|||||||
@GetMapping("/debug")
|
@GetMapping("/debug")
|
||||||
public String debug() {
|
public String debug() {
|
||||||
|
|
||||||
// List<SysUserEntity> sysUserEntityList = sysUserDao.findAll();
|
System.out.println("开始更新用户VIP时间范围");
|
||||||
// for (SysUserEntity sysUserEntity : sysUserEntityList) {
|
|
||||||
// String addTime = sysUserEntity.getAddTime();
|
List<SysUserEntity> sysUserEntityList = sysUserDao.findAll();
|
||||||
// String vipTimeRangeJson = sysUserEntity.getVipTimeRangeJson();
|
for (SysUserEntity sysUserEntity : sysUserEntityList) {
|
||||||
// if (!DateTimeUtil.isValidDateTime(addTime)) {
|
String addTime = sysUserEntity.getAddTime();
|
||||||
// return sysUserEntity.getUserName();
|
String vipTimeRangeJson = sysUserEntity.getVipTimeRangeJson();
|
||||||
// }
|
if (!DateTimeUtil.isValidDateTime(addTime)) {
|
||||||
// if (!DateTimeUtil.isValidDateTime(vipTimeRangeJson)) {
|
return sysUserEntity.getUserName();
|
||||||
// return sysUserEntity.getUserName();
|
}
|
||||||
// }
|
if (!DateTimeUtil.isValidDateTime(vipTimeRangeJson)) {
|
||||||
// VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItemBean = new VipTimeRangeBean.VipTimeRangeItemBean();
|
return sysUserEntity.getUserName();
|
||||||
// vipTimeRangeItemBean.setStartTime(addTime);
|
}
|
||||||
// vipTimeRangeItemBean.setEndTime(vipTimeRangeJson);
|
VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItemBean = new VipTimeRangeBean.VipTimeRangeItemBean();
|
||||||
// List<VipTimeRangeBean.VipTimeRangeItemBean> list = new ArrayList<>();
|
vipTimeRangeItemBean.setStartTime(addTime);
|
||||||
// list.add(vipTimeRangeItemBean);
|
vipTimeRangeItemBean.setEndTime(vipTimeRangeJson);
|
||||||
// VipTimeRangeBean vipTimeRangeBean = new VipTimeRangeBean();
|
List<VipTimeRangeBean.VipTimeRangeItemBean> list = new ArrayList<>();
|
||||||
// vipTimeRangeBean.setList(list);
|
list.add(vipTimeRangeItemBean);
|
||||||
// String serialize = JsonUtils.<VipTimeRangeBean>serialize(vipTimeRangeBean);
|
VipTimeRangeBean vipTimeRangeBean = new VipTimeRangeBean();
|
||||||
// System.out.println("serialize = " + serialize);
|
vipTimeRangeBean.setList(list);
|
||||||
// sysUserEntity.setVipTimeRangeJson(serialize);
|
String serialize = JsonUtils.<VipTimeRangeBean>serialize(vipTimeRangeBean);
|
||||||
// sysUserDao.save(sysUserEntity);
|
System.out.println("serialize = " + serialize);
|
||||||
|
sysUserEntity.setVipTimeRangeJson(serialize);
|
||||||
|
sysUserDao.save(sysUserEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("开始更新省编码市编码");
|
||||||
|
firePointOrdinaryDao.updateProCityCode();
|
||||||
|
System.out.println("开始更新省名市名");
|
||||||
|
firePointOrdinaryDao.updateProCityName();
|
||||||
|
|
||||||
|
// for (int i = 0; i < 30; i++) {
|
||||||
|
// firePointOrdinaryDao.updateProCityCodeById((long) i);
|
||||||
|
// firePointOrdinaryDao.updateProCityNameById((long) i);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
List<Map<String, String>> maps = streetDao.selectProCityPair();
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "OKKKK", locale);
|
||||||
List<FirePointOrdinaryEntity> firePointOrdinaryEntityList = firePointOrdinaryDao.findAll(Sort.by(Sort.Direction.DESC, "satelliteTime"));
|
|
||||||
int size = firePointOrdinaryEntityList.size();
|
|
||||||
List<String> errorList = new ArrayList<>();
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
FirePointOrdinaryEntity firePointOrdinaryEntity = firePointOrdinaryEntityList.get(i);
|
|
||||||
String countyCode = firePointOrdinaryEntity.getCountyCode();
|
|
||||||
String proCode = countyCode.substring(0, 2) + "0000";
|
|
||||||
firePointOrdinaryEntity.setProCode(proCode);
|
|
||||||
firePointOrdinaryEntity.setProName(obtainProName(maps, proCode));
|
|
||||||
String cityCode = countyCode.substring(0, 4) + "00";
|
|
||||||
firePointOrdinaryEntity.setCityCode(cityCode);
|
|
||||||
firePointOrdinaryEntity.setCityName(obtainCityName(maps, cityCode));
|
|
||||||
firePointOrdinaryDao.save(firePointOrdinaryEntity);
|
|
||||||
if (i % 100 == 0) {
|
|
||||||
System.out.println(i + "/" + size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, errorList, locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String obtainProName(List<Map<String, String>> maps, String proCode) {
|
|
||||||
for (Map<String, String> map : maps) {
|
|
||||||
if (map.get("pro_code").equals(proCode)) {
|
|
||||||
return map.get("pro_name");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String obtainCityName(List<Map<String, String>> maps, String cityCode) {
|
|
||||||
for (Map<String, String> map : maps) {
|
|
||||||
if (map.get("city_code").equals(cityCode)) {
|
|
||||||
return map.get("city_name");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/autoSync")
|
@GetMapping("/autoSync")
|
||||||
|
@ -3,8 +3,27 @@ package com.xkrs.dao;
|
|||||||
import com.xkrs.model.entity.FirePointOrdinaryEntity;
|
import com.xkrs.model.entity.FirePointOrdinaryEntity;
|
||||||
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.Query;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public interface FirePointOrdinaryDao extends JpaRepository<FirePointOrdinaryEntity, Long>, JpaSpecificationExecutor<FirePointOrdinaryEntity> {
|
public interface FirePointOrdinaryDao extends JpaRepository<FirePointOrdinaryEntity, Long>, JpaSpecificationExecutor<FirePointOrdinaryEntity> {
|
||||||
|
|
||||||
|
@Query(value = "UPDATE fire_point_ordinary SET pro_code = concat(left(county_code, 2), '0000'), city_code = concat(left(county_code, 4), '00')", nativeQuery = true)
|
||||||
|
@Modifying(clearAutomatically = true)
|
||||||
|
void updateProCityCode();
|
||||||
|
|
||||||
|
@Query(value = "UPDATE fire_point_ordinary AS f SET pro_name = (SELECT s.pro_name AS proname FROM street AS s WHERE s.pro_code = f.pro_code LIMIT 1), city_name = (SELECT s.city_name AS cityname FROM street AS s WHERE s.city_code = f.city_code LIMIT 1)", nativeQuery = true)
|
||||||
|
@Modifying(clearAutomatically = true)
|
||||||
|
void updateProCityName();
|
||||||
|
|
||||||
|
@Query(value = "UPDATE fire_point_ordinary SET pro_code = concat(left(county_code, 2), '0000'), city_code = concat(left(county_code, 4), '00') WHERE id = ?1", nativeQuery = true)
|
||||||
|
@Modifying(clearAutomatically = true)
|
||||||
|
void updateProCityCodeById(Long id);
|
||||||
|
|
||||||
|
@Query(value = "UPDATE fire_point_ordinary AS f SET pro_name = (SELECT s.pro_name AS proname FROM street AS s WHERE s.pro_code = f.pro_code LIMIT 1), city_name = (SELECT s.city_name AS cityname FROM street AS s WHERE s.city_code = f.city_code LIMIT 1) WHERE id = ?1", nativeQuery = true)
|
||||||
|
@Modifying(clearAutomatically = true)
|
||||||
|
void updateProCityNameById(Long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user