Selaa lähdekoodia

修改---备案系统发送短信(湖南版)

zhouhaijun 5 päivää sitten
vanhempi
commit
d12934c9e0

+ 1 - 1
src/main/java/com/bootdo/datas/dto/GyDataImportDTO.java

@@ -331,7 +331,7 @@ public class GyDataImportDTO {
     private String securityReorganize;
 
     /**
-     * 状态 0:正常 1:删除 2:已上报 3:通过审核 4:驳回
+     * 状态 0:正常(未提交) 1:删除 2:已上报 3:通过审核 4:驳回
      */
     private String dataStatus;
 

+ 91 - 0
src/main/java/com/bootdo/datas/service/MessageHuNanService.java

@@ -0,0 +1,91 @@
+package com.bootdo.datas.service;
+
+
+import com.bootdo.common.exception.BDException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+
+/**
+ * @author zhouhj
+ */
+@Service
+public class MessageHuNanService {
+    private static final Logger logger = LoggerFactory.getLogger(MessageHuNanService.class);
+
+    @Value("${hunan_message_gateway.url:#{null}}")
+    private String gateWayUrl;
+
+    @Value("${hunan_message_gateway.spcode:#{null}}")
+    private String gatewaySpCode;
+
+    @Value("${hunan_message_gateway.loginname:#{null}}")
+    private String gatewayLoginName;
+
+    @Value("${hunan_message_gateway.password:#{null}}")
+    private String gatewayPassword;
+
+    @Value("${hunan_message_gateway.f:#{null}}")
+    private String riskF;
+
+
+    /**
+     * 安全风险评估审核驳回通知
+     * @param phoneNumbers 手机字符串,多个使用逗号分隔
+     * @param dataName 数据项名称
+     */
+    public void sendMessage(String phoneNumbers, String dataName) throws BDException {
+        String MessageContent = "【湖南数据安全服务平台】现有涉及贵单位的重要数据和核心数据目录备案审核被驳回信息同步给您," +
+                "被驳回数据项名称是:"+dataName+",请尽快登录系统进行处理。";
+        String templateId = "your_template_id";
+        long currentTimeMillis = System.currentTimeMillis();
+        String SerialNumber = String.valueOf(currentTimeMillis);
+        try {
+            URL obj = new URL(gateWayUrl);
+            HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+            con.setRequestMethod("POST");
+            con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=GB2312");
+            con.setDoOutput(true);
+
+            String postParams = "SpCode=" + URLEncoder.encode(gatewaySpCode, "GB2312") +
+                    "&LoginName=" + URLEncoder.encode(gatewayLoginName, "GB2312") +
+                    "&Password=" + URLEncoder.encode(gatewayPassword, "GB2312") +
+                    "&MessageContent=" + URLEncoder.encode(MessageContent, "GB2312") +
+                    "&UserNumber=" + URLEncoder.encode(phoneNumbers, "GB2312") +
+                    "&templateId=" + URLEncoder.encode(templateId, "GB2312") +
+                    "&SerialNumber=" + URLEncoder.encode(SerialNumber, "GB2312") +
+                    "&f=" + URLEncoder.encode(riskF, "GB2312");
+
+            DataOutputStream wr = new DataOutputStream(con.getOutputStream());
+            wr.writeBytes(postParams);
+            wr.flush();
+            wr.close();
+
+            int responseCode = con.getResponseCode();
+            if (responseCode == HttpURLConnection.HTTP_OK) {
+                BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), "GB2312"));
+                String inputLine;
+                StringBuilder response = new StringBuilder();
+                while ((inputLine = in.readLine()) != null) {
+                    response.append(inputLine);
+                }
+                in.close();
+                logger.info("请求成功,响应内容:");
+                logger.info(response.toString());
+            } else {
+                logger.info("请求失败,状态码:" + responseCode);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 6 - 5
src/main/java/com/bootdo/datas/service/impl/GyDataServiceImpl.java

@@ -11,6 +11,7 @@ import com.bootdo.datas.dto.ExamineLogDTO;
 import com.bootdo.datas.dto.GyDataImportDTO;
 import com.bootdo.datas.service.ExamineLogService;
 import com.bootdo.datas.service.GyDataService;
+import com.bootdo.datas.service.MessageHuNanService;
 import com.bootdo.datas.service.MessageService;
 import com.bootdo.datas.tools.ExcelUtils;
 import com.bootdo.datas.tools.gm.FileCryptTool;
@@ -62,7 +63,7 @@ public class GyDataServiceImpl implements GyDataService {
     @Autowired
     private RoleService roleService;
     @Autowired
-    private MessageService messageService;
+    private MessageHuNanService messageHuNanService;
 
     private static Logger log = LoggerFactory.getLogger(GyDataServiceImpl.class);
 
@@ -588,20 +589,20 @@ public class GyDataServiceImpl implements GyDataService {
                 //通过数据id,查询数据信息
                 GyDataImportDTO importDTO = gyDataDao.get(data.getId());
                 if(Objects.nonNull(importDTO)){
-                    log.info("=====================发送短信了===数据信息查询==="+importDTO.toString());
                     //发送短息
-                    if("1".equals(importDTO.getAuditStage())){
+                    if("2".equals(importDTO.getAuditStage())){
+                        log.info("=====================发送短信了===数据信息查询==="+importDTO.toString());
                         //审核阶段:   1:市级,2:省级
                         GyUnitDO gyUnitDO = gyUnitDao.getGyUnitByCreditCode(importDTO.getGyUnitId());
                         log.info("=====================发送短信了===企业信息查询==="+gyUnitDO.toString());
                         if(Objects.nonNull(gyUnitDO)){
                             try {
                                 log.info("=====================发送短信了===start==="+gyUnitDO.toString());
-                                messageService.importance(gyUnitDO.getDataSecurityWay()+","+gyUnitDO.getMobilePhone(),
+                                messageHuNanService.sendMessage(gyUnitDO.getDataSecurityWay()+","+gyUnitDO.getMobilePhone(),
                                         importDTO.getDataName());
                                 log.info("=====================发送短信了===end==="+gyUnitDO.toString());
                             } catch (Exception e) {
-                                log.error("=============messageService.importance=======error======="+e.getMessage());
+                                log.error("=============messageHuNanService.sendMessage=======error======="+e.getMessage());
                                 e.printStackTrace();
                             }
                         }else {

+ 9 - 0
src/main/resources/application-dev.yml

@@ -103,3 +103,12 @@ message_gateway:
   appName: 风险报送系统
   catalog_record.templateId: 2232445
   risk_assessment.templateId: 2232446
+
+#湖南短信网关
+hunan_message_gateway:
+  url: https://api.ums86.com:9600/sms/Api/Send.do
+  spcode: 269167
+  loginname: hn_cyy
+  password: c5718b84559b4bb0f5dad97a222f3714
+  f: 1
+

+ 1 - 1
src/main/resources/application.yml

@@ -52,7 +52,7 @@ mybatis:
 #部署类别 1市级单独部署 2省级单独部署 3省市一体部署
 deployType: 3
 #系统省份,不能为空
-sysProvince: 四川
+sysProvince: 湖南
 #系统地市,当deployType=1时,此处要填上地级市,比如 成都市;当deployType为2、3时要为空
 sysCity: