diff --git a/micro-auth/src/main/resources/application.yml b/micro-auth/src/main/resources/application.yml index 04d4d8b..e0263bb 100644 --- a/micro-auth/src/main/resources/application.yml +++ b/micro-auth/src/main/resources/application.yml @@ -21,7 +21,7 @@ spring: password: @nacos.password@ discovery: # 注册IP,为了方便测试,写死部署的服务器IP - ip: 49.232.189.43 +# ip: 49.232.189.43 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-common/micro-common-mybatis/pom.xml b/micro-common/micro-common-mybatis/pom.xml index 6ce7d84..61b80bb 100644 --- a/micro-common/micro-common-mybatis/pom.xml +++ b/micro-common/micro-common-mybatis/pom.xml @@ -60,11 +60,11 @@ - - - - - + + + org.postgresql + postgresql + diff --git a/micro-gateway/src/main/resources/application.yml b/micro-gateway/src/main/resources/application.yml index 5f95967..9144566 100644 --- a/micro-gateway/src/main/resources/application.yml +++ b/micro-gateway/src/main/resources/application.yml @@ -23,7 +23,7 @@ spring: password: @nacos.password@ discovery: # 注册IP,为了方便测试,写死部署的服务器IP - ip: 49.232.189.43 +# ip: 49.232.189.43 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-modules/micro-amnt/src/main/resources/application.yml b/micro-modules/micro-amnt/src/main/resources/application.yml index 48190af..f2fcc30 100644 --- a/micro-modules/micro-amnt/src/main/resources/application.yml +++ b/micro-modules/micro-amnt/src/main/resources/application.yml @@ -21,7 +21,7 @@ spring: password: @nacos.password@ discovery: # 注册IP,为了方便测试,写死部署的服务器IP - ip: 49.233.1.167 +# ip: 49.233.1.167 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-modules/micro-bfs/src/main/resources/application.yml b/micro-modules/micro-bfs/src/main/resources/application.yml index e1c4a4b..42c86a9 100644 --- a/micro-modules/micro-bfs/src/main/resources/application.yml +++ b/micro-modules/micro-bfs/src/main/resources/application.yml @@ -21,7 +21,7 @@ spring: password: @nacos.password@ discovery: # 注册IP,为了方便测试,写死部署的服务器IP - ip: 49.232.194.131 +# ip: 49.232.194.131 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-modules/micro-bls/src/main/resources/application.yml b/micro-modules/micro-bls/src/main/resources/application.yml index dfedfc7..66bcf4a 100644 --- a/micro-modules/micro-bls/src/main/resources/application.yml +++ b/micro-modules/micro-bls/src/main/resources/application.yml @@ -21,7 +21,7 @@ spring: password: @nacos.password@ discovery: # 注册IP,为了方便测试,写死部署的服务器IP - ip: 49.232.194.131 +# ip: 49.232.194.131 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-modules/micro-customer/src/main/resources/application.yml b/micro-modules/micro-customer/src/main/resources/application.yml index 97600ea..59d2889 100644 --- a/micro-modules/micro-customer/src/main/resources/application.yml +++ b/micro-modules/micro-customer/src/main/resources/application.yml @@ -21,7 +21,7 @@ spring: password: @nacos.password@ discovery: # 注册IP,为了方便测试,写死部署的服务器IP - ip: 49.233.1.167 +# ip: 49.233.1.167 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-modules/micro-leaf/src/main/resources/application.yml b/micro-modules/micro-leaf/src/main/resources/application.yml index a5b7191..5ab4dd3 100644 --- a/micro-modules/micro-leaf/src/main/resources/application.yml +++ b/micro-modules/micro-leaf/src/main/resources/application.yml @@ -21,7 +21,7 @@ spring: password: @nacos.password@ discovery: # 注册IP,为了方便测试,写死部署的服务器IP - ip: 82.156.199.232 +# ip: 82.156.199.232 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-modules/micro-msg/pom.xml b/micro-modules/micro-msg/pom.xml index 7b01611..9483856 100644 --- a/micro-modules/micro-msg/pom.xml +++ b/micro-modules/micro-msg/pom.xml @@ -144,6 +144,11 @@ 21.1.0.0 + + org.postgresql + postgresql + + diff --git a/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/config/RestConfig.java b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/config/RestConfig.java new file mode 100644 index 0000000..ffea133 --- /dev/null +++ b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/config/RestConfig.java @@ -0,0 +1,20 @@ +package com.sinosoft.msg.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.web.client.RestTemplate; + +import java.time.Duration; + +@Configuration +public class RestConfig { + + @Bean + public RestTemplate restTemplate(RestTemplateBuilder builder) { + return builder + .setConnectTimeout(Duration.ofSeconds(10)) + .setReadTimeout(Duration.ofSeconds(30)) + .build(); + } +} \ No newline at end of file diff --git a/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/constant/MsgConstants.java b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/constant/MsgConstants.java index 106247c..ae9a0e9 100644 --- a/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/constant/MsgConstants.java +++ b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/constant/MsgConstants.java @@ -132,4 +132,5 @@ public interface MsgConstants { //般若短信通道唯一ID String SUPPLIER_WISDOM = "Wisdom"; + String SUPPLIER_NEW="NEW"; } diff --git a/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/config/NewSmsConfig.java b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/config/NewSmsConfig.java new file mode 100644 index 0000000..c1b9a13 --- /dev/null +++ b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/config/NewSmsConfig.java @@ -0,0 +1,33 @@ +package com.sinosoft.msg.core.smsSend.config; + + +import com.sinosoft.common.core.utils.SpringUtils; +import com.sinosoft.msg.core.constant.MsgConstants; +import com.sinosoft.msg.domain.MsgSmsServiceConfig; +import com.sinosoft.msg.service.IMsgSmsServiceConfigService; +import lombok.Data; +import org.dromara.sms4j.provider.config.BaseConfig; + +/** + * 梦网科技短信发送配置类 + */ +@Data +public class NewSmsConfig extends BaseConfig { + private String url; + private String userName; + private String password; + + public NewSmsConfig(){ + MsgSmsServiceConfig config = SpringUtils.getBean(IMsgSmsServiceConfigService.class).getSmsServiceConfigBySupplier(getSupplier()); + this.url=config.getApiAddress(); + this.userName = config.getAccessKeyId(); + this.password = config.getAccessKeySecret(); + } + + @Override + public String getSupplier() { + return MsgConstants.SUPPLIER_NEW; + } + + +} diff --git a/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/domian/Message.java b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/domian/Message.java new file mode 100644 index 0000000..82d7a5c --- /dev/null +++ b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/domian/Message.java @@ -0,0 +1,154 @@ +package com.sinosoft.msg.core.smsSend.domian; + +import javax.xml.bind.annotation.XmlElement; + +public class Message { + + /** + * 短信id + */ + private String messageId; + + /** + * 手机号列表 + */ + private MobileNums mobileNums; + + /** + * 短信标题 + */ + private String messTopic; + + /** + * 发送数据(用;分隔) + */ + private String sendData; + + /** + *数据类型:0:使用模版 1:不使用模版 + */ + private Integer dataType; // 0: 使用模板, 1: 不使用模板 + /** + * 发送方式 0: 即时发送, 1: 定时发送 + */ + private Integer sendWay; // 0: 即时发送, 1: 定时发送 + /** + * 发送日期 + */ + private String fixedDate; // 定时日期,可为空 + /** + *发送时间 + */ + private String fixedTime; // 定时时间,可为空 + /** + * 发送机构 + */ + private String unitCode; // 发送机构,如 "860000" 代表总部 + /** + * 优先级 + */ + private Integer dealOrder; // 优先级 + /** + * 回执匹配方式 + */ + private Integer answerMatch; // 回执匹配方式 + + @XmlElement(name = "MessageId") + public String getMessageId() { + return messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + @XmlElement(name = "MobileNums") + public MobileNums getMobileNums() { + return mobileNums; + } + + public void setMobileNums(MobileNums mobileNums) { + this.mobileNums = mobileNums; + } + + @XmlElement(name = "MessTopic") + public String getMessTopic() { + return messTopic; + } + + public void setMessTopic(String messTopic) { + this.messTopic = messTopic; + } + + @XmlElement(name = "SendData") + public String getSendData() { + return sendData; + } + + public void setSendData(String sendData) { + this.sendData = sendData; + } + + @XmlElement(name = "DataType") + public Integer getDataType() { + return dataType; + } + + public void setDataType(Integer dataType) { + this.dataType = dataType; + } + + @XmlElement(name = "SendWay") + public Integer getSendWay() { + return sendWay; + } + + public void setSendWay(Integer sendWay) { + this.sendWay = sendWay; + } + + @XmlElement(name = "FixedDate") + public String getFixedDate() { + return fixedDate; + } + + public void setFixedDate(String fixedDate) { + this.fixedDate = fixedDate; + } + + @XmlElement(name = "FixedTime") + public String getFixedTime() { + return fixedTime; + } + + public void setFixedTime(String fixedTime) { + this.fixedTime = fixedTime; + } + + @XmlElement(name = "UnitCode") + public String getUnitCode() { + return unitCode; + } + + public void setUnitCode(String unitCode) { + this.unitCode = unitCode; + } + + @XmlElement(name = "DealOrder") + public Integer getDealOrder() { + return dealOrder; + } + + public void setDealOrder(Integer dealOrder) { + this.dealOrder = dealOrder; + } + + @XmlElement(name = "AnswerMatch") + public Integer getAnswerMatch() { + return answerMatch; + } + + public void setAnswerMatch(Integer answerMatch) { + this.answerMatch = answerMatch; + } +} \ No newline at end of file diff --git a/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/domian/MobileNums.java b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/domian/MobileNums.java new file mode 100644 index 0000000..893886e --- /dev/null +++ b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/domian/MobileNums.java @@ -0,0 +1,18 @@ +package com.sinosoft.msg.core.smsSend.domian; + +import javax.xml.bind.annotation.XmlElement; +import java.util.List; + +public class MobileNums { + + private List mobileNum; + + @XmlElement(name = "MobileNum") + public List getMobileNum() { + return mobileNum; + } + + public void setMobileNum(List mobileNum) { + this.mobileNum = mobileNum; + } +} \ No newline at end of file diff --git a/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/domian/PublicInfo.java b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/domian/PublicInfo.java new file mode 100644 index 0000000..bbc9f83 --- /dev/null +++ b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/domian/PublicInfo.java @@ -0,0 +1,34 @@ +package com.sinosoft.msg.core.smsSend.domian; + +import javax.xml.bind.annotation.XmlElement; + +public class PublicInfo { + + /** + * 系统代码 + */ + private String systemCode; + + /** + * 短信服务代码 + */ + private String serviceCode; + + @XmlElement(name = "SystemCode") + public String getSystemCode() { + return systemCode; + } + + public void setSystemCode(String systemCode) { + this.systemCode = systemCode; + } + + @XmlElement(name = "ServiceCode") + public String getServiceCode() { + return serviceCode; + } + + public void setServiceCode(String serviceCode) { + this.serviceCode = serviceCode; + } +} \ No newline at end of file diff --git a/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/domian/SmsDto.java b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/domian/SmsDto.java new file mode 100644 index 0000000..ced6deb --- /dev/null +++ b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/domian/SmsDto.java @@ -0,0 +1,32 @@ +package com.sinosoft.msg.core.smsSend.domian; + +import jakarta.xml.bind.annotation.XmlElement; +import lombok.Data; + +import javax.xml.bind.annotation.XmlRootElement; + +@Data +@XmlRootElement(name = "Messages")//定义xml根节点 +public class SmsDto { + + private PublicInfo publicInfo; + private Message message; + + @XmlElement(name = "PublicInfo") + public PublicInfo getPublicInfo() { + return publicInfo; + } + + public void setPublicInfo(PublicInfo publicInfo) { + this.publicInfo = publicInfo; + } + + @XmlElement(name = "Message") + public Message getMessage() { + return message; + } + + public void setMessage(Message message) { + this.message = message; + } +} diff --git a/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/factory/SmsSend.java b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/factory/SmsSend.java index 6c417f1..67b0247 100644 --- a/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/factory/SmsSend.java +++ b/micro-modules/micro-msg/src/main/java/com/sinosoft/msg/core/smsSend/factory/SmsSend.java @@ -3,6 +3,7 @@ package com.sinosoft.msg.core.smsSend.factory; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.convert.Convert; +import com.alibaba.nacos.shaded.com.google.common.collect.Lists; import com.sinosoft.common.core.constant.Constants; import com.sinosoft.common.core.exception.ServiceException; import com.sinosoft.common.core.utils.StringUtils; @@ -10,6 +11,10 @@ import com.sinosoft.msg.core.constant.MsgConstants; import com.sinosoft.msg.core.enums.SendTypeByLogEnum; import com.sinosoft.msg.core.risk.domain.RiskDecision; import com.sinosoft.msg.core.smsSend.blend.ISmsBlend; +import com.sinosoft.msg.core.smsSend.domian.Message; +import com.sinosoft.msg.core.smsSend.domian.MobileNums; +import com.sinosoft.msg.core.smsSend.domian.PublicInfo; +import com.sinosoft.msg.core.smsSend.domian.SmsDto; import com.sinosoft.msg.core.smsSend.utils.SmsSendUtil; import com.sinosoft.msg.core.util.DateTimeUtils; import com.sinosoft.msg.domain.MsgSmsSendLog; @@ -28,13 +33,16 @@ import org.dromara.sms4j.core.factory.SmsFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.*; +import java.util.stream.Collectors; /** * 短信发送工厂 @@ -58,6 +66,9 @@ public class SmsSend { @Autowired private RedisProcessService redisProcessService; + @Autowired + private RestTemplate restTemplate; + @Value("${sms.send.enabled}") private String smsSendEnabled; //挡板 @@ -141,7 +152,58 @@ public class SmsSend { //发送短信 SmsResponse response = new SmsResponse(); if(smsSendEnabled.equals("true")){ - response = SmsSendUtil.sendMessage(phone, messageTotal,serviceConfig.getSupplier()); + //如果供应商是NEW(不知道是什么厂商随便起的名字)的执行新的短信发送逻辑 + if (MsgConstants.SUPPLIER_NEW.equals(serviceConfig.getSupplier())){ + //构建发送的xml报文 + SmsDto smsDto = new SmsDto(); + PublicInfo publicInfo = new PublicInfo(); + Message message = new Message(); + smsDto.setPublicInfo(publicInfo); + smsDto.setMessage(message); + //设置publicInfo节点 + publicInfo.setServiceCode("**"); + publicInfo.setSystemCode("**"); + + //设置message节点 + message.setMessageId(""); + MobileNums mobileNums = new MobileNums(); + List phoneList = Arrays.asList(phone); + mobileNums.setMobileNum(phoneList); + message.setMobileNums(mobileNums); + message.setMessTopic(configVo.getTemplateName()); + String paramsStr = parms.entrySet().stream() + .map(entry -> entry.getKey() + "=" + entry.getValue()) + .collect(Collectors.joining(";")); + message.setSendData(paramsStr); + message.setDataType(0); + message.setSendWay(0); + message.setUnitCode(bo.getSystem()); + message.setDealOrder(0); + message.setAnswerMatch(0); + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_XML); + headers.setAccept(java.util.Collections.singletonList(MediaType.APPLICATION_XML)); + + HttpEntity entity = new HttpEntity<>(smsDto, headers); + + try { + ResponseEntity response1 = restTemplate.postForEntity(serviceConfig.getApiAddress()+"?userName=" + +serviceConfig.getAccessKeyId()+"&password="+serviceConfig.getAccessKeySecret(), entity, String.class); + if (response1.getStatusCode().is2xxSuccessful()) { + System.out.println(response1.getBody()); +// return response1.getBody(); + } else { + throw new RuntimeException("调用失败,状态码: " + response1.getStatusCode()); + } + } catch (Exception e) { + throw new RuntimeException("发送短信异常: " + e.getMessage(), e); + } + }else { + response = SmsSendUtil.sendMessage(phone, messageTotal,serviceConfig.getSupplier()); + + } + log.info("SmsSend-send,response={},是否成功={}",response,response.isSuccess()); }else{ response.setSuccess(Boolean.TRUE); diff --git a/micro-modules/micro-msg/src/main/resources/application.yml b/micro-modules/micro-msg/src/main/resources/application.yml index 06f888b..c78975f 100644 --- a/micro-modules/micro-msg/src/main/resources/application.yml +++ b/micro-modules/micro-msg/src/main/resources/application.yml @@ -21,7 +21,7 @@ spring: password: @nacos.password@ discovery: # 注册IP,为了方便测试,写死部署的服务器IP - ip: 101.42.50.5 +# ip: 101.42.50.5 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-modules/micro-print/src/main/resources/application.yml b/micro-modules/micro-print/src/main/resources/application.yml index c08cbe7..f4aaebc 100644 --- a/micro-modules/micro-print/src/main/resources/application.yml +++ b/micro-modules/micro-print/src/main/resources/application.yml @@ -20,7 +20,7 @@ spring: username: @nacos.username@ password: @nacos.password@ discovery: - ip: 140.143.188.53 +# ip: 140.143.188.53 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-modules/micro-product/src/main/resources/application.yml b/micro-modules/micro-product/src/main/resources/application.yml index d599244..c8a180c 100644 --- a/micro-modules/micro-product/src/main/resources/application.yml +++ b/micro-modules/micro-product/src/main/resources/application.yml @@ -20,7 +20,7 @@ spring: username: @nacos.username@ password: @nacos.password@ discovery: - ip: 49.232.199.232 +# ip: 49.232.199.232 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-modules/micro-resource/src/main/resources/application.yml b/micro-modules/micro-resource/src/main/resources/application.yml index bebf863..fc9d721 100644 --- a/micro-modules/micro-resource/src/main/resources/application.yml +++ b/micro-modules/micro-resource/src/main/resources/application.yml @@ -20,7 +20,7 @@ spring: username: @nacos.username@ password: @nacos.password@ discovery: - ip: 140.143.188.53 +# ip: 140.143.188.53 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-modules/micro-risk/src/main/resources/application.yml b/micro-modules/micro-risk/src/main/resources/application.yml index d67a680..dede574 100644 --- a/micro-modules/micro-risk/src/main/resources/application.yml +++ b/micro-modules/micro-risk/src/main/resources/application.yml @@ -20,7 +20,7 @@ spring: username: @nacos.username@ password: @nacos.password@ discovery: - ip: 101.42.30.227 +# ip: 101.42.30.227 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-modules/micro-route/src/main/resources/application.yml b/micro-modules/micro-route/src/main/resources/application.yml index c8834b3..cfd619b 100644 --- a/micro-modules/micro-route/src/main/resources/application.yml +++ b/micro-modules/micro-route/src/main/resources/application.yml @@ -22,7 +22,7 @@ spring: username: @nacos.username@ password: @nacos.password@ discovery: - ip: 101.42.30.227 +# ip: 101.42.30.227 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-modules/micro-system/src/main/resources/application.yml b/micro-modules/micro-system/src/main/resources/application.yml index 7c61be6..a02d763 100644 --- a/micro-modules/micro-system/src/main/resources/application.yml +++ b/micro-modules/micro-system/src/main/resources/application.yml @@ -21,7 +21,7 @@ spring: password: @nacos.password@ discovery: # 注册IP,为了方便测试,写死部署的服务器IP - ip: 101.42.50.5 +# ip: 101.42.50.5 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/micro-visual/micro-xxljob/src/main/resources/application.yml b/micro-visual/micro-xxljob/src/main/resources/application.yml index 6000208..aea3dfd 100644 --- a/micro-visual/micro-xxljob/src/main/resources/application.yml +++ b/micro-visual/micro-xxljob/src/main/resources/application.yml @@ -21,7 +21,7 @@ spring: password: @nacos.password@ discovery: # 注册IP,为了方便测试,写死部署的服务器IP - ip: 82.156.199.232 +# ip: 82.156.199.232 # 注册组 group: @nacos.discovery.group@ namespace: ${spring.profiles.active} diff --git a/pom.xml b/pom.xml index e5bb57a..c03ebf2 100644 --- a/pom.xml +++ b/pom.xml @@ -75,8 +75,8 @@ dev - lijingbodev - 82.157.198.128:8848 + micro-dev-z + 106.54.18.101:8848 DEFAULT_GROUP DEFAULT_GROUP nacos