提交 04314e1d authored 作者: 刘海泉's avatar 刘海泉

Merge remote-tracking branch 'origin/v26.2-jdk17springboot3-20240912' into test_jdk17

...@@ -71,4 +71,22 @@ public enum VehicleWarnConfigEnum { ...@@ -71,4 +71,22 @@ public enum VehicleWarnConfigEnum {
} }
} }
@Getter
@AllArgsConstructor
public enum OrderWarnType {
PENDING_QUOTATION(0, "订单待报价"),
ACCEPTED(3, "订单已承接"),
COMPLETED(9, "订单完成"),
FINISHED(12, "订单完结"),
CANCELED(4, "订单取消");
private final Integer code;
private final String msg;
public static Optional<OrderWarnType> getByCode(int code) {
return Arrays.stream(values()).filter(e -> e.code == code).findFirst();
}
public static String getMsgByCode(int code) {
return getByCode(code).map(OrderWarnType::getMsg).orElse(null);
}
}
} }
...@@ -18,6 +18,8 @@ public class VehicleWarnUserConfigUpdateParam { ...@@ -18,6 +18,8 @@ public class VehicleWarnUserConfigUpdateParam {
@NotNull(message = "id不能为空") @NotNull(message = "id不能为空")
private Integer id; private Integer id;
@Schema(description = "运单预警类型列表") @Schema(description = "运单预警类型列表")
private List<VehicleWarnUserVO.WarnTypeItem> orderWarnTypeList;
@Schema(description = "运单预警类型列表", example = "1")
private List<VehicleWarnUserVO.WarnTypeItem> warnTypeList; private List<VehicleWarnUserVO.WarnTypeItem> warnTypeList;
@Schema(description = "线路预警类型列表") @Schema(description = "线路预警类型列表")
private List<VehicleWarnUserVO.WarnTypeItem> lineWarnTypeList; private List<VehicleWarnUserVO.WarnTypeItem> lineWarnTypeList;
......
...@@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.media.Schema; ...@@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -45,12 +46,36 @@ public class VehicleWarnUserVO { ...@@ -45,12 +46,36 @@ public class VehicleWarnUserVO {
@Schema(description = "修改时间", example = "") @Schema(description = "修改时间", example = "")
private String modifiedTime; private String modifiedTime;
@Schema(description = "运单通知配置列表")
private List<WarnTypeItem> orderWarnTypeItemList;
public List<WarnTypeItem> getOrderWarnTypeItemList() {
List<Integer> warnTypeList = JSON.parseArray(orderWarnTypeJson, Integer.class);
List<WarnTypeItem> list = new ArrayList<>();
if(CollectionUtils.isEmpty(warnTypeList)){
return list;
}
for (VehicleWarnConfigEnum.OrderWarnType item : VehicleWarnConfigEnum.OrderWarnType.values()) {
if (warnTypeList.contains(item.getCode())){
list.add(new WarnTypeItem(item.getCode(), item.getMsg(), 1));
}
else {
list.add(new WarnTypeItem(item.getCode(), item.getMsg(), 0));
}
}
return list;
}
@Schema(description = "运单通知配置列表") @Schema(description = "运单通知配置列表")
private List<WarnTypeItem> warnTypeItemList; private List<WarnTypeItem> warnTypeItemList;
public List<WarnTypeItem> getWarnTypeItemList() { public List<WarnTypeItem> getWarnTypeItemList() {
List<Integer> warnTypeList = JSON.parseArray(warnTypeJson, Integer.class); List<Integer> warnTypeList = JSON.parseArray(warnTypeJson, Integer.class);
List<WarnTypeItem> list = new ArrayList<>(); List<WarnTypeItem> list = new ArrayList<>();
if(CollectionUtils.isEmpty(warnTypeList)){
return list;
}
for (VehicleWarnConfigEnum.WarnType item : VehicleWarnConfigEnum.WarnType.values()) { for (VehicleWarnConfigEnum.WarnType item : VehicleWarnConfigEnum.WarnType.values()) {
if (warnTypeList.contains(item.getCode())){ if (warnTypeList.contains(item.getCode())){
list.add(new WarnTypeItem(item.getCode(), item.getMsg(), 1)); list.add(new WarnTypeItem(item.getCode(), item.getMsg(), 1));
...@@ -68,6 +93,9 @@ public class VehicleWarnUserVO { ...@@ -68,6 +93,9 @@ public class VehicleWarnUserVO {
List<Integer> warnTypeList = JSON.parseArray(lineWarnTypeJson, Integer.class); List<Integer> warnTypeList = JSON.parseArray(lineWarnTypeJson, Integer.class);
List<WarnTypeItem> list = new ArrayList<>(); List<WarnTypeItem> list = new ArrayList<>();
if(CollectionUtils.isEmpty(warnTypeList)){
return list;
}
for (LineWarnConfigEnum.WarnType item : LineWarnConfigEnum.WarnType.values()) { for (LineWarnConfigEnum.WarnType item : LineWarnConfigEnum.WarnType.values()) {
if (warnTypeList.contains(item.getCode())){ if (warnTypeList.contains(item.getCode())){
list.add(new WarnTypeItem(item.getCode(), item.getMsg(), 1)); list.add(new WarnTypeItem(item.getCode(), item.getMsg(), 1));
...@@ -79,6 +107,9 @@ public class VehicleWarnUserVO { ...@@ -79,6 +107,9 @@ public class VehicleWarnUserVO {
return list; return list;
} }
@JsonIgnore
@Schema(description = "订单通知配置", example = "", hidden = true)
private String orderWarnTypeJson;
@JsonIgnore @JsonIgnore
@Schema(description = "预警配置", example = "", hidden = true) @Schema(description = "预警配置", example = "", hidden = true)
private String warnTypeJson; private String warnTypeJson;
......
...@@ -340,6 +340,11 @@ ...@@ -340,6 +340,11 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId> <artifactId>spring-cloud-loadbalancer</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.msl.message</groupId>
<artifactId>message-sdk</artifactId>
</dependency>
</dependencies> </dependencies>
......
package com.clx.performance.config;
import com.msl.common.open.ConfiguredOpenClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Objects;
@Configuration
public class ConfiguredOpenClientConfig {
@Bean
public ConfiguredOpenClient configuredOpenClient(ConfiguredOpenProperties properties) {
return new ConfiguredOpenClient(Objects.requireNonNull(properties.getGatewayUrl()),
Objects.requireNonNull(properties.getAppId()),
Objects.requireNonNull(properties.getAppKey()));
}
}
package com.clx.performance.config;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@ConfigurationProperties(prefix = "message")
@Getter
@Setter
@Configuration
public class ConfiguredOpenProperties {
private String gatewayUrl;
private String appId;
private String appKey;
private String accessKey;
}
...@@ -115,7 +115,8 @@ public class RabbitKeyConstants { ...@@ -115,7 +115,8 @@ public class RabbitKeyConstants {
//同步履约进度表消息----订单部分 //同步履约进度表消息----订单部分
public static final String SYNC_PERFORMANCE_PROGRESS_FOR_ORDER_INFO_QUEUE = "clx_order.sync.performance.progress.for.order.info.queue"; public static final String SYNC_PERFORMANCE_PROGRESS_FOR_ORDER_INFO_QUEUE = "clx_order.sync.performance.progress.for.order.info.queue";
//发送订单状态通知短信queue
public static final String SEND_ORDER_STATUS_NOTICE_SMS_QUEUE = "clx_order.send.order.status.notice.sms.queue";
//货单同步履约进度表queue //货单同步履约进度表queue
......
...@@ -49,6 +49,7 @@ public class VehicleWarnUserController { ...@@ -49,6 +49,7 @@ public class VehicleWarnUserController {
@Operation(summary = "更新通知配置", description = "<br>By:艾庆国") @Operation(summary = "更新通知配置", description = "<br>By:艾庆国")
@PostMapping("/updateConfig") @PostMapping("/updateConfig")
public Result<Void> updateConfig(@RequestBody @Validated VehicleWarnUserConfigUpdateParam param) { public Result<Void> updateConfig(@RequestBody @Validated VehicleWarnUserConfigUpdateParam param) {
if (param.getOrderWarnTypeList() == null) {param.setOrderWarnTypeList(new ArrayList<>());}
if (param.getWarnTypeList() == null) {param.setWarnTypeList(new ArrayList<>());} if (param.getWarnTypeList() == null) {param.setWarnTypeList(new ArrayList<>());}
if (param.getLineWarnTypeList() == null) {param.setLineWarnTypeList(new ArrayList<>());} if (param.getLineWarnTypeList() == null) {param.setLineWarnTypeList(new ArrayList<>());}
vehicleWarnUserService.updateConfig(param); vehicleWarnUserService.updateConfig(param);
......
...@@ -37,6 +37,7 @@ public class VehicleWarnUserDaoImpl extends BaseDaoImpl<VehicleWarnUserMapper, V ...@@ -37,6 +37,7 @@ public class VehicleWarnUserDaoImpl extends BaseDaoImpl<VehicleWarnUserMapper, V
public boolean updateWarnType(VehicleWarnUser item) { public boolean updateWarnType(VehicleWarnUser item) {
return update(lUdWrapper() return update(lUdWrapper()
.eq(VehicleWarnUser::getId, item.getId()) .eq(VehicleWarnUser::getId, item.getId())
.set(VehicleWarnUser::getOrderWarnTypeJson, item.getOrderWarnTypeJson())
.set(VehicleWarnUser::getWarnTypeJson, item.getWarnTypeJson()) .set(VehicleWarnUser::getWarnTypeJson, item.getWarnTypeJson())
.set(VehicleWarnUser::getLineWarnTypeJson, item.getLineWarnTypeJson()) .set(VehicleWarnUser::getLineWarnTypeJson, item.getLineWarnTypeJson())
); );
......
package com.clx.performance.listener;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.json.JSONUtil;
import com.clx.open.sdk.callback.message.OrderInfoMessage;
import com.clx.performance.common.MqWrapper;
import com.clx.performance.config.ConfiguredOpenProperties;
import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.dao.vehiclewarn.VehicleWarnUserDao;
import com.clx.performance.model.vehiclewarn.VehicleWarnUser;
import com.msl.common.open.ConfiguredOpenClient;
import com.msl.common.result.Result;
import com.msl.message.sdk.action.MessageAction;
import com.msl.message.sms.api.sms.SmsMessage;
import com.msl.message.sms.api.sms.content.SmsMessageContentImpl;
import com.msl.message.sms.api.sms.recipient.SmsMessageRecipientImpl;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import static com.clx.performance.enums.OrderEnum.Status.*;
import static com.msl.message.sms.api.enums.RecipientTypeEnum.USER_MOBILE;
@Slf4j
@Component
@AllArgsConstructor
public class SendOrderStatusNoticeSmsListener {
private static final Map<Integer,String> CODE_MAP = new HashMap<>();
private final ConfiguredOpenClient configuredOpenClient;
private final VehicleWarnUserDao vehicleWarnUserDao;
private final ConfiguredOpenProperties properties;
static {
CODE_MAP.put(WAIT_QUOTATION.getCode(),"orderWaitQuotation");
CODE_MAP.put(PLATFORM_UNDERTAKING.getCode(),"orderPlatformUndertaking");
CODE_MAP.put(SUCCESS.getCode(),"orderSuccess");
CODE_MAP.put(COMPLETED.getCode(),"orderCompleted");
CODE_MAP.put(CANCELED.getCode(),"orderCanceled");
}
@RabbitListener(queues = RabbitKeyConstants.SEND_ORDER_STATUS_NOTICE_SMS_QUEUE)
public void onMessage(Message message) {
try{
log.info("监听到发送订单状态通知短信,消息内容{}", new String(message.getBody()));
OrderInfoMessage order = JSONUtil.toBean(new String(message.getBody()),
new TypeReference<MqWrapper<OrderInfoMessage>>() {
},false).getData();
SmsMessage smsMessage = new SmsMessage();
//设置消息内容
SmsMessageContentImpl smsMessageContent= new SmsMessageContentImpl();
//模版code
smsMessageContent.setCode(CODE_MAP.get(order.getOrderStatus()));
//模版参数
Map<String, Object> params = new HashMap<>();
params.put("sendAddressShorter",order.getSendAddressShorter());
params.put("receiveAddressShorter",order.getReveiveAddressShorter());
params.put("orderNo",order.getOrderNo());
smsMessageContent.setParams(params);
//设置消息接收人
SmsMessageRecipientImpl smsMessageRecipient = new SmsMessageRecipientImpl();
smsMessageRecipient.setUserType(USER_MOBILE.getCode());
smsMessageRecipient.setTargets(getTargets(order.getOrderStatus()));
smsMessage.setContent(smsMessageContent);
smsMessage.setRecipient(smsMessageRecipient);
//从消息中心注册获取的通道key
smsMessage.setAccessKey(properties.getAccessKey());
//向消息中心发送消息
Result<Object> result = configuredOpenClient.doAction(new MessageAction(smsMessage));
}catch (Exception e){
log.info("监听到发送订单状态通知短信发生异常,异常原因:{}", ExceptionUtils.getStackTrace(e));
}
}
private String getTargets(int code){
return vehicleWarnUserDao.listAllEnable()
.stream()
.filter(item -> JSONUtil.toList(item.getOrderWarnTypeJson(), Integer.class).contains(code))
.map(VehicleWarnUser::getMobile)
.collect(Collectors.joining(","));
}
}
...@@ -28,6 +28,7 @@ public class VehicleWarnUser implements HasKey<Integer> { ...@@ -28,6 +28,7 @@ public class VehicleWarnUser implements HasKey<Integer> {
private Integer id; //id private Integer id; //id
private String name; //姓名 private String name; //姓名
private String mobile; //手机 private String mobile; //手机
private String orderWarnTypeJson; //订单通知配置
private String warnTypeJson; //预警配置 private String warnTypeJson; //预警配置
private String lineWarnTypeJson; //线路预警配置 private String lineWarnTypeJson; //线路预警配置
private Integer deleteStatus; //删除状态: 0-否;1-是 private Integer deleteStatus; //删除状态: 0-否;1-是
......
...@@ -83,14 +83,19 @@ public class VehicleWarnUserServiceImpl implements VehicleWarnUserService { ...@@ -83,14 +83,19 @@ public class VehicleWarnUserServiceImpl implements VehicleWarnUserService {
VehicleWarnUser vehicleWarnUser = vehicleWarnUserDao VehicleWarnUser vehicleWarnUser = vehicleWarnUserDao
.findById(param.getId()).orElseThrow(ResultEnum.DATA_NOT_FIND); .findById(param.getId()).orElseThrow(ResultEnum.DATA_NOT_FIND);
List<Integer> orderWarnTypeList = param.getOrderWarnTypeList().stream()
.filter(item -> Objects.equals(item.getEnable(), 1))
.map(VehicleWarnUserVO.WarnTypeItem::getWarnType).collect(Collectors.toList());
List<Integer> warnTypeList = param.getWarnTypeList().stream() List<Integer> warnTypeList = param.getWarnTypeList().stream()
.filter(item -> Objects.equals(item.getEnable(), 1)) .filter(item -> Objects.equals(item.getEnable(), 1))
.map(item->item.getWarnType()).collect(Collectors.toList()); .map(VehicleWarnUserVO.WarnTypeItem::getWarnType).collect(Collectors.toList());
List<Integer> lineWarnTypeList = param.getLineWarnTypeList().stream() List<Integer> lineWarnTypeList = param.getLineWarnTypeList().stream()
.filter(item -> Objects.equals(item.getEnable(), 1)) .filter(item -> Objects.equals(item.getEnable(), 1))
.map(item->item.getWarnType()).collect(Collectors.toList()); .map(VehicleWarnUserVO.WarnTypeItem::getWarnType).collect(Collectors.toList());
vehicleWarnUser.setOrderWarnTypeJson(JSON.toJSONString(orderWarnTypeList));
vehicleWarnUser.setWarnTypeJson(JSON.toJSONString(warnTypeList)); vehicleWarnUser.setWarnTypeJson(JSON.toJSONString(warnTypeList));
vehicleWarnUser.setLineWarnTypeJson(JSON.toJSONString(lineWarnTypeList)); vehicleWarnUser.setLineWarnTypeJson(JSON.toJSONString(lineWarnTypeList));
vehicleWarnUserDao.updateWarnType(vehicleWarnUser); vehicleWarnUserDao.updateWarnType(vehicleWarnUser);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论