|
@@ -0,0 +1,145 @@
|
|
|
+package com.fdkankan.job.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.util.PhoneUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.aliyun.dysmsapi20170525.Client;
|
|
|
+import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
|
|
+import com.aliyun.teautil.models.RuntimeOptions;
|
|
|
+import com.fdkankan.common.constant.CommonStatus;
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.constant.SceneSource;
|
|
|
+import com.fdkankan.common.constant.SceneStatus;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.job.entity.ScenePlus;
|
|
|
+import com.fdkankan.job.entity.ScenePlusExt;
|
|
|
+import com.fdkankan.job.service.IInnerApiService;
|
|
|
+import com.fdkankan.job.service.IScenePlusExtService;
|
|
|
+import com.fdkankan.job.service.IScenePlusService;
|
|
|
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
|
+import com.fdkankan.sms.SmsService;
|
|
|
+import com.fdkankan.web.response.ResultData;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class InnerApiServiceImpl implements IInnerApiService {
|
|
|
+
|
|
|
+ @Value("${4dkk.laserService.basePath}")
|
|
|
+ private String laserHost;
|
|
|
+
|
|
|
+ private final static String SMS_TEM_SCENE_BUILD_NOTICE = "场景码:%s,计算结果:%s";
|
|
|
+
|
|
|
+ private final static String QUEUE_SCENE_BUILD_NOTICE = "job-scene-build-notice";
|
|
|
+
|
|
|
+ private final static String SMS_TEM_CODE_SCENE_BUILD_NOTICE = "SMS_464050961";
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private RabbitMqProducer rabbitMqProducer;
|
|
|
+ @Autowired
|
|
|
+ private SmsService smsService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData sceneBuildNotice(String num, String phone) {
|
|
|
+
|
|
|
+ //校验手机格式
|
|
|
+ if(!PhoneUtil.isMobile(phone)){
|
|
|
+ throw new BusinessException(ErrorCode.PHONE_VIOLATION);
|
|
|
+ }
|
|
|
+
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByNum(num);
|
|
|
+ if(Objects.isNull(scenePlus)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put("num", num);
|
|
|
+ result.put("phone", phone);
|
|
|
+
|
|
|
+ if(scenePlus.getSceneStatus() == SceneStatus.SUCCESS.code() || scenePlus.getSceneStatus() == SceneStatus.NO_DISPLAY.code()){
|
|
|
+ result.put("status", scenePlus.getSceneStatus());
|
|
|
+ result.put("msg", "计算成功");
|
|
|
+ return ResultData.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(scenePlus.getSceneStatus() == SceneStatus.FAILD.code()){
|
|
|
+ result.put("status", scenePlus.getSceneStatus());
|
|
|
+ result.put("msg", "计算失败,失败原因请看场景计算报警群消息");
|
|
|
+ return ResultData.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ rabbitMqProducer.sendByWorkQueue(QUEUE_SCENE_BUILD_NOTICE, result);
|
|
|
+
|
|
|
+ return ResultData.ok("计算中,已开启计算监听,请留意手机短信");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sceneBuildNoticeListenerHandler(JSONObject param) throws Exception {
|
|
|
+ String num = param.getString("num");
|
|
|
+ String phone = param.getString("phone");
|
|
|
+
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByNum(num);
|
|
|
+ if(scenePlus.getSceneStatus() == SceneStatus.wait.code()){
|
|
|
+ try {
|
|
|
+ Thread.sleep(6*1000L);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ rabbitMqProducer.sendByWorkQueue(QUEUE_SCENE_BUILD_NOTICE, param);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ params.put("num", num);
|
|
|
+ params.put("title", scenePlus.getTitle());
|
|
|
+ String msg;
|
|
|
+ if(scenePlus.getSceneStatus() == SceneStatus.FAILD.code()){
|
|
|
+ msg = "计算失败,失败原因请看钉钉群【四维看看-计算失败】。";
|
|
|
+ }else {
|
|
|
+ msg = "计算成功";
|
|
|
+// ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+// if(scenePlus.getSceneSource() == SceneSource.JG.code() || scenePlus.getSceneSource() == SceneSource.SG.code()){
|
|
|
+// msg = msg.concat(",点云场景链接:").concat(laserHost).concat("/uat/index.html?m=").concat(num);
|
|
|
+// if(scenePlusExt.getIsObj() == CommonStatus.YES.code().intValue()){
|
|
|
+// msg = msg.concat(",mesh场景链接:").concat(scenePlusExt.getWebSite());
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+// msg = msg.concat(",场景链接:").concat(scenePlusExt.getWebSite());
|
|
|
+// }
|
|
|
+
|
|
|
+ }
|
|
|
+ params.put("msg", msg);
|
|
|
+ smsService.sendSms(phone, JSON.toJSONString(params), SMS_TEM_CODE_SCENE_BUILD_NOTICE);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String[] args) throws Exception {
|
|
|
+// final boolean mobile = PhoneUtil.isMobile("+8615899973805");
|
|
|
+// System.out.println(mobile);
|
|
|
+ com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
|
|
+ // 必填,您的 AccessKey ID
|
|
|
+ .setAccessKeyId("LTAIUrvuHqj8pvry")
|
|
|
+ // 必填,您的 AccessKey Secret
|
|
|
+ .setAccessKeySecret("JLOVl0k8Ke0aaM8nLMMiUAZ3EiiqI4");
|
|
|
+ // Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
|
|
|
+ config.endpoint = "dysmsapi.aliyuncs.com";
|
|
|
+ Client client = new Client(config);
|
|
|
+
|
|
|
+ com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest()
|
|
|
+ .setPhoneNumbers("15899973805")
|
|
|
+ .setSignName("四维看看").setTemplateCode("SMS_179150247").setTemplateParam("{\"code\":123}");
|
|
|
+ SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, new RuntimeOptions());
|
|
|
+
|
|
|
+ }
|
|
|
+}
|