Jelajahi Sumber

#ADD 云从算法

谭斌 1 tahun lalu
induk
melakukan
e09aaa5ea2

+ 6 - 0
device-api-service/pom.xml

@@ -104,5 +104,11 @@
             <version>1.0</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>com.xy</groupId>
+            <artifactId>xy-cloudwalk</artifactId>
+            <version>1.0</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 </project>

+ 14 - 0
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -27,6 +27,7 @@ import com.xy.device.EnumDeviceFaultLevelPayThreshold;
 import com.xy.device.EnumDeviceOnlineStatus;
 import com.xy.device.EnumQualityMercSets;
 import com.xy.dto.*;
+import com.xy.dto.api.biz.ContainerAddDTO;
 import com.xy.dto.be.MercDto;
 import com.xy.entity.*;
 import com.xy.enums.FileExportType;
@@ -75,6 +76,7 @@ import static com.xy.utils.PlusBeans.*;
 @Api(tags = "设备-信息")
 public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceInfo> implements DeviceInfoService {
 
+    private final CloudWalkApiService cloudWalkApiService;
     /**
      * 质检商户code
      */
@@ -415,9 +417,21 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         List<DeviceInfo> deviceInfos = this.listByIds(deviceIds);
         for (DeviceInfo deviceInfo : deviceInfos) {
             Integer deviceType = deviceInfo.getDeviceType();
+            Long deviceId = deviceInfo.getDeviceId();
+
             if (ObjectUtil.equals(deviceType, DeviceTypeEnum.TYPE5.getCode())) {
                 //支付宝设备算法
                 algorithmId = AlgorithmTypeEnum.ALIPAY.getId();
+            } else {
+                //非支付宝算法
+                if (AlgorithmTypeEnum.CLOUD.getId() == algorithmId) {
+                    //云从算法
+                    boolean b = cloudWalkApiService.checkDeviceExist(deviceId);
+                    if (!b) {
+                        //货柜不存在,新增
+                        cloudWalkApiService.containerAdd(new ContainerAddDTO().setContainerCode(String.valueOf(deviceId)));
+                    }
+                }
             }
             int refMercId = deviceInfo.getMercId().intValue();
             String refMercCode = deviceInfo.getMercCode();

+ 5 - 6
device-api-service/src/main/resources/mapper/DeviceInfoMapper.xml

@@ -3,6 +3,7 @@
 <mapper namespace="com.xy.mapper.DeviceInfoMapper">
     <resultMap id="queryPageMap" type="com.xy.mapper.entity.DeviceInfoQueryPage">
         <id column="device_id" property="deviceId"/>
+        <id column="algorithm_id" property="algorithmId"/>
         <result column="device_name" property="deviceName"/>
         <result column="m" property="m"/>
         <result column="lon" property="lon"/>
@@ -311,11 +312,11 @@
                 and active_state = #{query.activeState}
             </if>
 
-            <if test="query.busyStatus != null  ">
+            <if test="query.busyStatus != null">
                 and busy_state = #{query.busyStatus}
             </if>
 
-            <if test="query.deviceType != null  ">
+            <if test="query.deviceType != null">
                 and device_type = #{query.deviceType}
             </if>
 
@@ -325,14 +326,12 @@
             <if test="query.deviceName != null and query.deviceName != ''">
                 and device_name like concat('%', #{query.deviceName}, '%')
             </if>
-            <if test="query.deviceIdList != null and query.deviceIdList.size>0 ">
+            <if test="query.deviceIdList != null and query.deviceIdList.size > 0">
                 and device_id in
                 <foreach collection="query.deviceIdList" index="index" item="item" open="(" separator="," close=")">
                     #{item}
                 </foreach>
             </if>
-
-
         </where>
         group by place_line_id
     </select>
@@ -342,7 +341,7 @@
         LEFT JOIN device_status s ON s.device_id = d.device_id
         <where>
             d.active_state = '1'
-            <if test="mercIdList != null and mercIdList.size()>0">
+            <if test="mercIdList != null and mercIdList.size() > 0">
                 AND d.merc_id IN
                 <foreach collection="mercIdList" item="mercId" index="index"
                          open="(" close=")" separator=",">

+ 1 - 1
device-start/src/main/resources/bootstrap.yml

@@ -10,7 +10,7 @@ cloud:
   center:
     url: 119.96.213.127:9007
     config:
-      shared-configs: redis.yaml,mysql.yaml,mqtt.yaml,xxl-job.yaml,algorithm.yaml,xy-oss.yaml,alipay.yaml
+      shared-configs: redis.yaml,mysql.yaml,mqtt.yaml,xxl-job.yaml,algorithm.yaml,xy-oss.yaml,alipay.yaml,cloudwalk.yaml
       name: device
   service:
     name: dev-device