提交 cdc9d7c2 authored 作者: 艾庆国's avatar 艾庆国

Merge branch 'refs/heads/v16.3_line_warn_20240528' into test

Former-commit-id: 7407643b
...@@ -36,4 +36,10 @@ public class RedisConstants { ...@@ -36,4 +36,10 @@ public class RedisConstants {
public static final String MESSAGE_RESET_PASSWORD_TOKEN = "message:resetpassword:token:"; public static final String MESSAGE_RESET_PASSWORD_TOKEN = "message:resetpassword:token:";
/**
* 线路天气预警
*/
public static final String LINE_WARN_WEATHER = "clx-performance:lineWarn:weather:";
} }
package com.clx.performance.service.impl.linewarn; package com.clx.performance.service.impl.linewarn;
import com.clx.order.vo.feign.FeignAddressVO; import com.clx.order.vo.feign.FeignAddressVO;
import com.clx.performance.constant.RedisConstants;
import com.clx.performance.dao.linewarn.LineWarnConfigDao; import com.clx.performance.dao.linewarn.LineWarnConfigDao;
import com.clx.performance.dao.linewarn.LineWarnInfoDao; import com.clx.performance.dao.linewarn.LineWarnInfoDao;
import com.clx.performance.dto.linewarn.LineWarnCommonInfoDTO; import com.clx.performance.dto.linewarn.LineWarnCommonInfoDTO;
import com.clx.performance.enums.linewarn.LineWarnConfigEnum; import com.clx.performance.enums.linewarn.LineWarnConfigEnum;
import com.clx.performance.enums.linewarn.LineWarnInfoEnum; import com.clx.performance.enums.linewarn.LineWarnInfoEnum;
import com.clx.performance.extranal.order.InternalReportService;
import com.clx.performance.extranal.user.AddressService; import com.clx.performance.extranal.user.AddressService;
import com.clx.performance.model.OrderGoods; import com.clx.performance.model.OrderGoods;
import com.clx.performance.model.linewarn.LineWarnConfig; import com.clx.performance.model.linewarn.LineWarnConfig;
...@@ -18,19 +18,20 @@ import com.msl.common.base.Optional; ...@@ -18,19 +18,20 @@ import com.msl.common.base.Optional;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.TimeUnit;
@Slf4j @Slf4j
@Service @Service
public class LineWarnWeatherWarnServiceImpl implements LineWarnWeatherWarnService { public class LineWarnWeatherWarnServiceImpl implements LineWarnWeatherWarnService {
@Autowired @Autowired
private LineWarnConfigDao lineWarnConfigDao; private LineWarnConfigDao lineWarnConfigDao;
@Autowired
private InternalReportService internalReportService;
@Autowired @Autowired
private LineWarnCommonService lineWarnCommonService; private LineWarnCommonService lineWarnCommonService;
@Autowired @Autowired
...@@ -39,10 +40,15 @@ public class LineWarnWeatherWarnServiceImpl implements LineWarnWeatherWarnServic ...@@ -39,10 +40,15 @@ public class LineWarnWeatherWarnServiceImpl implements LineWarnWeatherWarnServic
private GdUtils gdUtils; private GdUtils gdUtils;
@Autowired @Autowired
private AddressService addressService; private AddressService addressService;
@Autowired
private RedisTemplate<String, String> redisTemplate;
@Override @Override
public void weatherWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo) { public void weatherWarn(OrderGoods orderGoods, LineWarnCommonInfoDTO lineWarnCommonInfo) {
Boolean flag = redisTemplate.opsForValue().setIfAbsent(RedisConstants.LINE_WARN_WEATHER + orderGoods.getOrderGoodsNo(), orderGoods.getOrderGoodsNo(), 1, TimeUnit.HOURS);
if (!flag) {return;}
List<LineWarnConfig> lineWarnConfigList = lineWarnConfigDao List<LineWarnConfig> lineWarnConfigList = lineWarnConfigDao
.listByWarnType(LineWarnConfigEnum.WarnType.WEATHER.getCode()); .listByWarnType(LineWarnConfigEnum.WarnType.WEATHER.getCode());
if (lineWarnConfigList.isEmpty()) {return;} if (lineWarnConfigList.isEmpty()) {return;}
...@@ -65,6 +71,7 @@ public class LineWarnWeatherWarnServiceImpl implements LineWarnWeatherWarnServic ...@@ -65,6 +71,7 @@ public class LineWarnWeatherWarnServiceImpl implements LineWarnWeatherWarnServic
boolean suspend = lineWarnCommonService.suspendCheck(lineWarnInfo); boolean suspend = lineWarnCommonService.suspendCheck(lineWarnInfo);
if (suspend) {return;} if (suspend) {return;}
String weatherAll = "";
Optional<FeignAddressVO> addressOptional = addressService Optional<FeignAddressVO> addressOptional = addressService
.getSendAndReceiveAddress(orderGoods.getSendAddressId(), orderGoods.getReceiveAddressId()); .getSendAndReceiveAddress(orderGoods.getSendAddressId(), orderGoods.getReceiveAddressId());
if (addressOptional.isEmpty()) {return;} if (addressOptional.isEmpty()) {return;}
...@@ -76,6 +83,7 @@ public class LineWarnWeatherWarnServiceImpl implements LineWarnWeatherWarnServic ...@@ -76,6 +83,7 @@ public class LineWarnWeatherWarnServiceImpl implements LineWarnWeatherWarnServic
String weather = gdUtils.getWeather(cityCode); String weather = gdUtils.getWeather(cityCode);
if (weatherCheck(weather)){ if (weatherCheck(weather)){
weatherAll = weather;
// 更新 // 更新
lineWarnCommonService.lineWarnInfoUpdate(orderGoods, lineWarnInfo, lineWarnConfig, weather); lineWarnCommonService.lineWarnInfoUpdate(orderGoods, lineWarnInfo, lineWarnConfig, weather);
} }
...@@ -85,10 +93,20 @@ public class LineWarnWeatherWarnServiceImpl implements LineWarnWeatherWarnServic ...@@ -85,10 +93,20 @@ public class LineWarnWeatherWarnServiceImpl implements LineWarnWeatherWarnServic
feignAddressVO.getReceiveAddress().getLatitude()); feignAddressVO.getReceiveAddress().getLatitude());
String weather = gdUtils.getWeather(cityCode); String weather = gdUtils.getWeather(cityCode);
if (weatherCheck(weather)){ if (weatherCheck(weather)){
// 更新 if (StringUtils.isBlank(weatherAll)){weatherAll = weather;}
lineWarnCommonService.lineWarnInfoUpdate(orderGoods, lineWarnInfo, lineWarnConfig, weather); else {
//不相同,逗号分隔
if (!weatherAll.equals(weather)){
weatherAll = weatherAll + "," + weather;
} }
} }
}
}
if (StringUtils.isNotBlank(weatherAll)){
// 更新
lineWarnCommonService.lineWarnInfoUpdate(orderGoods, lineWarnInfo, lineWarnConfig, weatherAll);
}
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论