优化火点入库-去除重复数据

This commit is contained in:
liuchengqian 2022-08-23 14:42:31 +08:00
parent aed56cd96d
commit 1d7b2d0e8e

View File

@ -48,6 +48,8 @@ public class FirePointServiceImpl implements FirePointService {
public static Logger log = LoggerFactory.getLogger(FirePointServiceImpl.class); public static Logger log = LoggerFactory.getLogger(FirePointServiceImpl.class);
private final Locale locale = LocaleContextHolder.getLocale();
@Resource @Resource
private FirePointDao firePointDao; private FirePointDao firePointDao;
@ -148,7 +150,7 @@ public class FirePointServiceImpl implements FirePointService {
*/ */
private boolean checkDuplicatedData(FirePointEntity firePointEntity) { private boolean checkDuplicatedData(FirePointEntity firePointEntity) {
List<FirePointEntity> duplicatedDataList = firePointDao.findDuplicatedData(firePointEntity.getLongitude(), firePointEntity.getLatitude(), firePointEntity.getStreetCode(), firePointEntity.getSatelliteTime(), firePointEntity.getSatelliteType(), firePointEntity.getLandType()); List<FirePointEntity> duplicatedDataList = firePointDao.findDuplicatedData(firePointEntity.getLongitude(), firePointEntity.getLatitude(), firePointEntity.getStreetCode(), firePointEntity.getSatelliteTime(), firePointEntity.getSatelliteType(), firePointEntity.getLandType());
return duplicatedDataList != null && duplicatedDataList.size() > 0; return duplicatedDataList != null && duplicatedDataList.size() > 1;
} }
/** /**
@ -159,7 +161,7 @@ public class FirePointServiceImpl implements FirePointService {
*/ */
private boolean checkDuplicatedDataX(ShanDongFirePointEntity shanDongFirePoint) { private boolean checkDuplicatedDataX(ShanDongFirePointEntity shanDongFirePoint) {
List<FirePointEntity> duplicatedDataList = firePointDao.findDuplicatedData(shanDongFirePoint.getLongitude(), shanDongFirePoint.getLatitude(), shanDongFirePoint.getStreetCode(), shanDongFirePoint.getSatelliteTime(), shanDongFirePoint.getSatelliteType(), shanDongFirePoint.getLandType()); List<FirePointEntity> duplicatedDataList = firePointDao.findDuplicatedData(shanDongFirePoint.getLongitude(), shanDongFirePoint.getLatitude(), shanDongFirePoint.getStreetCode(), shanDongFirePoint.getSatelliteTime(), shanDongFirePoint.getSatelliteType(), shanDongFirePoint.getLandType());
return duplicatedDataList != null && duplicatedDataList.size() > 0; return duplicatedDataList != null && duplicatedDataList.size() > 1;
} }
/** /**
@ -170,7 +172,7 @@ public class FirePointServiceImpl implements FirePointService {
*/ */
private boolean checkDuplicatedData(ShanDongFirePointEntity shanDongFirePoint) { private boolean checkDuplicatedData(ShanDongFirePointEntity shanDongFirePoint) {
List<ShanDongFirePointEntity> duplicatedDataList = shanDongFirePointDao.findDuplicatedData(shanDongFirePoint.getLongitude(), shanDongFirePoint.getLatitude(), shanDongFirePoint.getStreetCode(), shanDongFirePoint.getSatelliteTime(), shanDongFirePoint.getSatelliteType(), shanDongFirePoint.getLandType()); List<ShanDongFirePointEntity> duplicatedDataList = shanDongFirePointDao.findDuplicatedData(shanDongFirePoint.getLongitude(), shanDongFirePoint.getLatitude(), shanDongFirePoint.getStreetCode(), shanDongFirePoint.getSatelliteTime(), shanDongFirePoint.getSatelliteType(), shanDongFirePoint.getLandType());
return duplicatedDataList != null && duplicatedDataList.size() > 0; return duplicatedDataList != null && duplicatedDataList.size() > 1;
} }
/** /**
@ -326,8 +328,6 @@ public class FirePointServiceImpl implements FirePointService {
@Transactional(rollbackOn = Exception.class) @Transactional(rollbackOn = Exception.class)
@Override @Override
public String updateVerifyStateByFireCode(String fireCode, String verifyState) { public String updateVerifyStateByFireCode(String fireCode, String verifyState) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
if ((!"0".equals(verifyState)) && (!"1".equals(verifyState)) && (!"2".equals(verifyState))) { if ((!"0".equals(verifyState)) && (!"1".equals(verifyState)) && (!"2".equals(verifyState))) {
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "审核失败,审核状态参数错误", locale); return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "审核失败,审核状态参数错误", locale);
} }
@ -454,7 +454,7 @@ public class FirePointServiceImpl implements FirePointService {
LocalDate now = LocalDate.now(); LocalDate now = LocalDate.now();
List<Map<String, String>> list = firePointDao.downloadFirePointByVip(dateTimeToString(LocalDateTime.of(now.minusDays(1), LocalTime.MIN))); List<Map<String, String>> list = firePointDao.downloadFirePointByVip(dateTimeToString(LocalDateTime.of(now.minusDays(1), LocalTime.MIN)));
if (list.size() == 0) { if (list.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", LocaleContextHolder.getLocale()); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", locale);
} }
int year = now.getYear(); int year = now.getYear();
int month = now.getMonth().getValue(); int month = now.getMonth().getValue();
@ -468,7 +468,7 @@ public class FirePointServiceImpl implements FirePointService {
} catch (IOException e) { } catch (IOException e) {
log.error("download vip user's fire point fail: {}", e.getMessage()); log.error("download vip user's fire point fail: {}", e.getMessage());
} }
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", LocaleContextHolder.getLocale()); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
} }
/** /**
@ -536,8 +536,6 @@ public class FirePointServiceImpl implements FirePointService {
@Transactional(rollbackOn = Exception.class) @Transactional(rollbackOn = Exception.class)
@Override @Override
public String updateTypeByFireCode(String fireCode, String fireType, String token) { public String updateTypeByFireCode(String fireCode, String fireType, String token) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
String tokenUserName = TokenUtil.getTokenUserName(token); String tokenUserName = TokenUtil.getTokenUserName(token);
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
FirePointEntity byFireCode = firePointDao.findByFireCode(fireCode); FirePointEntity byFireCode = firePointDao.findByFireCode(fireCode);
@ -590,8 +588,6 @@ public class FirePointServiceImpl implements FirePointService {
@Transactional(rollbackOn = Exception.class) @Transactional(rollbackOn = Exception.class)
@Override @Override
public String insertAppTask(MultipartFile[] files, AppTaskBodyVo appTaskBodyVo) throws IOException { public String insertAppTask(MultipartFile[] files, AppTaskBodyVo appTaskBodyVo) throws IOException {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
FirePointEntity byFireCode = firePointDao.findByFireCode(appTaskBodyVo.getFireCode()); FirePointEntity byFireCode = firePointDao.findByFireCode(appTaskBodyVo.getFireCode());
if (byFireCode == null) { if (byFireCode == null) {
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "火点编码错误,请重新输入", locale); return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "火点编码错误,请重新输入", locale);
@ -626,8 +622,6 @@ public class FirePointServiceImpl implements FirePointService {
*/ */
@Override @Override
public String selectAppTask(String fireCode) throws Exception { public String selectAppTask(String fireCode) throws Exception {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
FireTask byTaskFireCode = fireTaskDao.findByTaskFireCode(fireCode); FireTask byTaskFireCode = fireTaskDao.findByTaskFireCode(fireCode);
if (byTaskFireCode == null) { if (byTaskFireCode == null) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有该火点的任务信息", locale); return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有该火点的任务信息", locale);
@ -652,8 +646,6 @@ public class FirePointServiceImpl implements FirePointService {
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
@Override @Override
public String selectFirePointNumMonth() { public String selectFirePointNumMonth() {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
Map map = new HashMap(3); Map map = new HashMap(3);
LocalDateTime localDateTime = LocalDateTime.now(); LocalDateTime localDateTime = LocalDateTime.now();
LocalDateTime localDateTime2 = localDateTime.plusDays(1); LocalDateTime localDateTime2 = localDateTime.plusDays(1);
@ -679,8 +671,6 @@ public class FirePointServiceImpl implements FirePointService {
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
@Override @Override
public String selectFirePointNumDay() { public String selectFirePointNumDay() {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
Map map = new HashMap(3); Map map = new HashMap(3);
LocalDateTime localDateTime = LocalDateTime.now(); LocalDateTime localDateTime = LocalDateTime.now();
LocalDateTime localDateTime2 = localDateTime.plusDays(1); LocalDateTime localDateTime2 = localDateTime.plusDays(1);
@ -706,8 +696,6 @@ public class FirePointServiceImpl implements FirePointService {
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
@Override @Override
public String selectFirePointNumWeek() { public String selectFirePointNumWeek() {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
Map map = new HashMap(3); Map map = new HashMap(3);
LocalDateTime localDateTime = LocalDateTime.now(); LocalDateTime localDateTime = LocalDateTime.now();
LocalDateTime localDateTime2 = localDateTime.plusDays(1); LocalDateTime localDateTime2 = localDateTime.plusDays(1);
@ -757,7 +745,6 @@ public class FirePointServiceImpl implements FirePointService {
System.out.println("街道编号格式化出现错误:" + e.getMessage()); System.out.println("街道编号格式化出现错误:" + e.getMessage());
} }
} }
Locale locale = LocaleContextHolder.getLocale();
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "街道编号格式化完毕", locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "街道编号格式化完毕", locale);
} }