hanzhiwei пре 3 година
родитељ
комит
f6ed09063d

+ 60 - 0
zd-model/src/main/java/com/zd/model/domain/Result.java

@@ -0,0 +1,60 @@
+package com.zd.model.domain;
+
+import java.io.Serializable;
+
+/**
+ * 极星算法平台接收返回类
+ */
+@Deprecated
+public class Result implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 成功
+     */
+    public static final int SUCCESS = 1000;
+
+    /**
+     * 失败
+     */
+    public static final int FAIL = 9999;
+
+    /**
+     * 错误代码(1000成功;9999失败;)
+     */
+    private int status_code;
+
+    /**
+     * 提示信息
+     */
+    private String message;
+
+
+    public static  Result ok() {
+        return restResult(SUCCESS, null);
+    }
+
+    private static Result restResult(int code, String msg) {
+        Result apiResult = new Result();
+        apiResult.setStatus_code(code);
+        apiResult.setMessage(msg);
+        return apiResult;
+    }
+
+    public int getStatus_code() {
+        return status_code;
+    }
+
+    public void setStatus_code(int status_code) {
+        this.status_code = status_code;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+}

+ 7 - 6
zd-modules/zd-algorithm/pom.xml

@@ -37,6 +37,7 @@
             <artifactId>mysql-connector-java</artifactId>
         </dependency>
 
+
         <!--mqtt客户端链接服务-->
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -58,12 +59,6 @@
             <version>3.10.0</version>
         </dependency>
 
-        <!-- zd Common Swagger -->
-        <!--<dependency>
-            <groupId>com.zd</groupId>
-            <artifactId>zd-common-swagger</artifactId>
-        </dependency>-->
-
         <!-- 人脸对接  -->
         <dependency>
             <groupId>arcsoft</groupId>
@@ -180,10 +175,16 @@
             <groupId>com.zd.core</groupId>
             <artifactId>common-core</artifactId>
         </dependency>
+
         <dependency>
             <groupId>com.zd.mqtt</groupId>
             <artifactId>common-mqtt</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>com.zd.system</groupId>
+            <artifactId>zd-system-api</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

+ 0 - 236
zd-modules/zd-algorithm/src/main/java/com/zd/alg/alarm/mqtt/MqttConfig.java

@@ -1,236 +0,0 @@
-//package com.zd.alg.alarm.mqtt;
-//
-//import com.alibaba.druid.support.json.JSONUtils;
-//import com.alibaba.fastjson.JSON;
-//import com.zd.alg.alarm.domain.AlarmLog;
-//import com.zd.alg.alarm.service.IAlarmLogService;
-//import com.zd.alg.alarm.utils.AlarmUtil;
-//import com.zd.common.core.utils.DateUtils;
-//import com.zd.system.api.alarm.domain.AlarmEntrty;
-//import com.zd.system.api.alarm.domain.Routes;
-//import com.zd.system.api.alarm.domain.SendTypes;
-//import org.apache.commons.collections4.CollectionUtils;
-//import org.apache.commons.lang.StringUtils;
-//import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.beans.factory.annotation.Value;
-//import org.springframework.context.annotation.Bean;
-//import org.springframework.context.annotation.Configuration;
-//import org.springframework.integration.annotation.ServiceActivator;
-//import org.springframework.integration.channel.DirectChannel;
-//import org.springframework.integration.core.MessageProducer;
-//import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;
-//import org.springframework.integration.mqtt.core.MqttPahoClientFactory;
-//import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter;
-//import org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler;
-//import org.springframework.integration.mqtt.support.DefaultPahoMessageConverter;
-//import org.springframework.integration.mqtt.support.MqttHeaders;
-//import org.springframework.messaging.Message;
-//import org.springframework.messaging.MessageChannel;
-//import org.springframework.messaging.MessageHandler;
-//import org.springframework.messaging.MessagingException;
-//
-//import java.util.HashSet;
-//import java.util.List;
-//import java.util.Map;
-//import java.util.Set;
-//
-///**
-// * mqtt配置
-// */
-//@Configuration
-//public class MqttConfig {
-//
-//    @Autowired
-//    private AlarmUtil alarmUtil;
-//    @Autowired
-//    private IAlarmLogService alarmLogService;
-//
-//    static Logger logger = LoggerFactory.getLogger(MqttConfig.class);
-//
-//    private static final byte[] WILL_DATA;
-//
-//    static {
-//        WILL_DATA = "offline".getBytes();
-//    }
-//
-//    public static final String MQTT_INBOUND_CHANNEL = "mqttInboundChannel";
-//
-//
-//    public static final String MQTT_OUTBOUND_CHANNEL = "mqttOutboundChannel";
-//
-//    @Value("${mqtt.username:}")
-//    private String username;
-//
-//    @Value("${mqtt.password:}")
-//    private String password;
-//
-//    @Value("${mqtt.url}")
-//    private String url;
-//
-//    @Value("${mqtt.defaultTopic}")
-//    private String defaultTopic;
-//
-//    @Value("${mqtt.producer.clientId}")
-//    private String producerClientId;
-//
-//    @Value("${mqtt.consumer.clientId}")
-//    private String consumerClientId;
-//
-//    @Value("${mqtt.consumer.maxInflight}")
-//    private Integer maxInflight;
-//
-//    private MqttPahoMessageDrivenChannelAdapter adapter;
-//
-//    /**
-//     * 连接mqtt配置
-//     */
-//    @Bean
-//    public MqttConnectOptions mqttConnectOptions() {
-//        MqttConnectOptions options = new MqttConnectOptions();
-//        // false,服务器会保留客户端的连接记录
-//        // true,表示每次连接到服务器都以新的身份连接
-//        options.setCleanSession(false);
-//        options.setUserName(username);
-//        options.setPassword(password.toCharArray());
-////        options.setMaxInflight(maxInflight);
-//        options.setServerURIs(StringUtils.split(url, ","));
-//        //超时时间 单位为秒
-//        options.setConnectionTimeout(10);
-//        //会话心跳时间 单位: s, 间隔时间:1.5*20秒向客户端发送心跳判断客户端是否在线
-//        options.setKeepAliveInterval(60);
-//        //设置“遗嘱”消息的话题,若客户端与服务器之间的连接意外中断,服务器将发布客户端的“遗嘱”消息。
-////        options.setWill("willTopic", WILL_DATA, 2, false);
-//        return options;
-//    }
-//
-//
-//    /**
-//     * MQTT客户端
-//     */
-//    @Bean
-//    public MqttPahoClientFactory mqttClientFactory() {
-//        DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory();
-//        factory.setConnectionOptions(mqttConnectOptions());
-//        return factory;
-//    }
-//
-//    /**
-//     * 发送者消息通道
-//     */
-//    @Bean(name = MQTT_OUTBOUND_CHANNEL)
-//    public MessageChannel mqttOutboundChannel() {
-//        return new DirectChannel();
-//    }
-//
-//    /**
-//     * 发送者消息处理
-//     */
-//    @Bean
-//    @ServiceActivator(inputChannel = MQTT_OUTBOUND_CHANNEL)
-//    public MessageHandler mqttOutbound() {
-//        MqttPahoMessageHandler messageHandler = new MqttPahoMessageHandler(
-//                producerClientId,
-//                mqttClientFactory());
-//        messageHandler.setAsync(true);
-//        messageHandler.setDefaultTopic(defaultTopic);
-//        return messageHandler;
-//    }
-//
-//    /**
-//     * 消息订阅
-//     */
-//    @Bean
-//    public MessageProducer inbound() {
-//        // 可同时消费(订阅)多个Topic
-//        adapter = new MqttPahoMessageDrivenChannelAdapter(consumerClientId, mqttClientFactory(), StringUtils.split(defaultTopic, ","));
-//        adapter.setCompletionTimeout(5000);
-//        adapter.setConverter(new DefaultPahoMessageConverter());
-//        adapter.setQos(2);
-//        // 设置订阅通道
-//        adapter.setOutputChannel(mqttInboundChannel());
-//        return adapter;
-//    }
-//
-//
-//    /**
-//     * 消费者消息通道
-//     */
-//    @Bean(name = MQTT_INBOUND_CHANNEL)
-//    public MessageChannel mqttInboundChannel() {
-//        return new DirectChannel();
-//    }
-//
-//    /**
-//     * 消费者消息处理
-//     *设备心跳
-//     */
-//    @Bean
-//    @ServiceActivator(inputChannel = MQTT_INBOUND_CHANNEL)
-//    public MessageHandler mqttInbound() {
-//
-//        return new MessageHandler() {
-//            @Override
-//            public void handleMessage(Message<?> message) throws MessagingException {
-//                String receivedTopic = (String) message.getHeaders().get(MqttHeaders.RECEIVED_TOPIC);
-//
-//                logger.info("MQTT 接收 topic:  {}",receivedTopic);
-//
-//                String msg = (String) message.getPayload();
-//                logger.info("MQTT 接收 消息体:  {}",msg);
-//
-//                try {
-//                    String type = SendTypes.All+"";
-//                    Map<String,Object> map = JSON.parseObject(msg, Map.class);
-//
-//                    map = JSON.parseObject(map.get("data")+"", Map.class);
-//
-//                    String text = (String) map.get("text");
-//                    List<String> list = JSON.parseArray(map.get("to")+"", String.class);
-//                    if(CollectionUtils.isEmpty(list)){
-//                        logger.error("接收告警消息手机号为空!");
-//                        return;
-//                    }
-//
-//                    Set<String> set = new HashSet<>(list);
-//                    String[] to = new String[set.size()];
-//                    set.toArray(to);
-//
-//                    String dataType = (String) map.get("type");
-//                    if(map.get("type") != null && ((SendTypes.All+"").equals(dataType)
-//                            || (SendTypes.Call+"").equals(dataType) || (SendTypes.SMS+"").equals(dataType))){
-//                        type = dataType;
-//                    }
-//
-//                    AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, to, type, text);
-//
-//                    map = alarmUtil.sendPost(alarmEntrty);
-//
-//                    String data = (String) map.get("Reply");
-//                    if("OK".equals(data)){
-//                        String[] phones = alarmEntrty.getTo();
-//                        for (String phone : phones) {
-//                            AlarmLog alarmLog = new AlarmLog();
-//                            alarmLog.setRemark("预案ID/实验室ID: " + receivedTopic.replace(defaultTopic, ""));
-//                            alarmLog.setIsBack(0);
-//                            alarmLog.setStatus("失败");
-//                            alarmLog.setPhone(phone);
-//                            alarmLog.setNotice(alarmEntrty.getText());
-//                            alarmLog.setCreateTime(DateUtils.getNowDate());
-//
-//                            alarmLogService.insertAlarmLog(alarmLog);
-//                        }
-//                    }else {
-//                        logger.error("报警电话推送错误:" + JSONUtils.toJSONString(map));
-//                    }
-//                }catch (Exception e){
-//                    e.printStackTrace();
-//                    logger.error("报警处理数据异常:" + e.getMessage());
-//                }
-//
-//            }
-//        };
-//    }
-//}

+ 4 - 4
zd-modules/zd-algorithm/src/main/resources/mapper/smartlock/SlApplyApprovalMapper.xml

@@ -4,7 +4,7 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zd.alg.smartlock.mapper.SlApplyApprovalMapper">
 
-    <resultMap type="com.zd.alg.smartlock.domain.SlApplyApproval" id="SlApplyApprovalResult">
+    <resultMap type="com.zd.algorithm.api.smartlock.entity.SlApplyApproval" id="SlApplyApprovalResult">
         <result property="id" column="id"/>
         <result property="applyId" column="apply_id"/>
         <result property="deptId" column="dept_id"/>
@@ -37,7 +37,7 @@
                t.creta_time
         from sl_apply_approval as t
     </sql>
-    <select id="selectSlApplyApprovalList" parameterType="com.zd.alg.smartlock.domain.SlApplyApproval"
+    <select id="selectSlApplyApprovalList" parameterType="com.zd.algorithm.api.smartlock.entity.SlApplyApproval"
             resultMap="SlApplyApprovalResult">
         <include refid="selectSlApplyApprovalVo"/>
         <where>
@@ -66,7 +66,7 @@
         where id = #{id}
     </select>
 
-    <insert id="insertSlApplyApproval" parameterType="com.zd.alg.smartlock.domain.SlApplyApproval" useGeneratedKeys="true"
+    <insert id="insertSlApplyApproval" parameterType="com.zd.algorithm.api.smartlock.entity.SlApplyApproval" useGeneratedKeys="true"
             keyProperty="id">
         insert into sl_apply_approval
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -96,7 +96,7 @@
         </trim>
     </insert>
 
-    <update id="updateSlApplyApproval" parameterType="com.zd.alg.smartlock.domain.SlApplyApproval">
+    <update id="updateSlApplyApproval" parameterType="com.zd.algorithm.api.smartlock.entity.SlApplyApproval">
         update sl_apply_approval
         <trim prefix="SET" suffixOverrides=",">
             <if test="applyId != null">apply_id = #{applyId},</if>

+ 4 - 4
zd-modules/zd-algorithm/src/main/resources/mapper/smartlock/SlOpendoorApplyMapper.xml

@@ -4,7 +4,7 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zd.alg.smartlock.mapper.SlOpendoorApplyMapper">
 
-    <resultMap type="com.zd.alg.smartlock.domain.vo.SlOpendoorApplyVo" id="SlOpendoorApplyResult">
+    <resultMap type="com.zd.algorithm.api.smartlock.entity.vo.SlOpendoorApplyVo" id="SlOpendoorApplyResult">
         <result property="id" column="id"/>
         <result property="userId" column="user_id"/>
         <result property="userName" column="user_name"/>
@@ -95,7 +95,7 @@
         LEFT JOIN   sys_dept d on   t.dept_id=d.dept_id
         LEFT JOIN sys_user u on  t.user_id=u.user_id
     </sql>
-    <select id="selectSlOpendoorApplyList" parameterType="com.zd.alg.smartlock.domain.vo.SlOpendoorApplyVo"
+    <select id="selectSlOpendoorApplyList" parameterType="com.zd.algorithm.api.smartlock.entity.vo.SlOpendoorApplyVo"
             resultMap="SlOpendoorApplyResult">
         <include refid="selectSlOpendoorApplyListVo"/>
         <where>
@@ -154,7 +154,7 @@
         where id = #{id}
     </select>
 
-    <insert id="insertSlOpendoorApply" parameterType="com.zd.alg.smartlock.domain.SlOpendoorApply" useGeneratedKeys="true"
+    <insert id="insertSlOpendoorApply" parameterType="com.zd.algorithm.api.smartlock.entity.SlOpendoorApply" useGeneratedKeys="true"
             keyProperty="id">
         insert into sl_opendoor_apply
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -238,7 +238,7 @@
         </trim>
     </insert>
 
-    <update id="updateSlOpendoorApply" parameterType="com.zd.alg.smartlock.domain.SlOpendoorApply">
+    <update id="updateSlOpendoorApply" parameterType="com.zd.algorithm.api.smartlock.entity.SlOpendoorApply">
         update sl_opendoor_apply
         <trim prefix="SET" suffixOverrides=",">
             <if test="userId != null">user_id = #{userId},</if>

+ 4 - 4
zd-modules/zd-algorithm/src/main/resources/mapper/smartlock/SlSubjectRelationMapper.xml

@@ -4,7 +4,7 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zd.alg.smartlock.mapper.SlSubjectRelationMapper">
 
-    <resultMap type="com.zd.alg.smartlock.domain.vo.SlSubjectRelationVo" id="SlSubjectRelationResult">
+    <resultMap type="com.zd.algorithm.api.smartlock.entity.vo.SlSubjectRelationVo" id="SlSubjectRelationResult">
         <result property="id" column="id"/>
         <result property="subjectId" column="subject_id"/>
         <result property="subjectName" column="subject_name"/>
@@ -64,7 +64,7 @@
                t.creat_time
         from sl_subject_relation as t
     </sql>
-    <select id="selectSlSubjectRelationList" parameterType="com.zd.alg.smartlock.domain.SlSubjectRelation"
+    <select id="selectSlSubjectRelationList" parameterType="com.zd.algorithm.api.smartlock.entity.SlSubjectRelation"
             resultMap="SlSubjectRelationResult">
         <include refid="selectSlSubjectRelationVo"/>
         <where>
@@ -98,7 +98,7 @@
         where id = #{id}
     </select>
 
-    <insert id="insertSlSubjectRelation" parameterType="com.zd.alg.smartlock.domain.SlSubjectRelation"
+    <insert id="insertSlSubjectRelation" parameterType="com.zd.algorithm.api.smartlock.entity.SlSubjectRelation"
             useGeneratedKeys="true" keyProperty="id">
         insert into sl_subject_relation
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -153,7 +153,7 @@
         </trim>
     </insert>
 
-    <update id="updateSlSubjectRelation" parameterType="com.zd.alg.smartlock.domain.SlSubjectRelation">
+    <update id="updateSlSubjectRelation" parameterType="com.zd.algorithm.api.smartlock.entity.SlSubjectRelation">
         update sl_subject_relation
         <trim prefix="SET" suffixOverrides=",">
             <if test="subjectId != null">subject_id = #{subjectId},</if>