Просмотр исходного кода

新增 mongodb 批量更新功能

zhaiyifei 11 месяцев назад
Родитель
Сommit
e934098e3b

+ 1 - 51
src/main/java/com/yunfeiyun/agmp/iots/device/mapper/IotDeviceMapper.java

@@ -2,8 +2,6 @@ package com.yunfeiyun.agmp.iots.device.mapper;
 
 
 import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
-import com.yunfeiyun.agmp.iot.common.domain.dto.IotDeviceDto;
-import com.yunfeiyun.agmp.iot.common.domain.resvo.IotXmzndeviceResVo;
 import com.yunfeiyun.agmp.iot.common.model.device.IotDeviceStatusResVo;
 import org.apache.ibatis.annotations.Param;
 
@@ -25,17 +23,6 @@ public interface IotDeviceMapper {
      */
     public IotDevice selectIotDeviceByTypeFirmCode(IotDevice iotDevice);
 
-    public IotDevice selectIotDeviceByTypeFirmCodeExt(IotDevice iotDevice);
-
-
-    /**
-     * 修改设备基础
-     *
-     * @param iotDevice 设备基础
-     * @return 结果
-     */
-    public int updateIotDevice(IotDevice iotDevice);
-
     public int insertIotDevice(IotDevice iotDevice);
 
     IotDevice selectIotDeviceByDevBid(String devBid);
@@ -45,12 +32,6 @@ public interface IotDeviceMapper {
 
     List<IotDevice> getDeviceIdByFirmBizId(@Param("firmBizId") String firmBizId, @Param("deviceTypeBizId") String deviceTypeBizId);
 
-    List<IotXmzndeviceResVo> getXmznDeviceList(@Param("firmBizId") String firmBizId);
-
-    IotDevice getDeviceByOriginalId(@Param("originalId") String originalId);
-
-    IotDevice findDeviceByDevCodeAndDevTypeBid(@Param("devCode") String devCode, @Param("devtypeBid") String devTypeBid, @Param("firmBid") String firmBid);
-
     /**
      * 查询设备的的最新数据
      *
@@ -59,44 +40,13 @@ public interface IotDeviceMapper {
      */
     List<IotDeviceStatusResVo> selectAllDeviceConfigStatus(Map param);
 
-    public int deleteIotDeviceByDevBids(String[] devBids);
-
     List<IotDevice> selectAllDeviceByDeviceServiceName(String devtypeServicename);
 
     IotDevice selectDeviceByDeviceServiceNameAndDevCode(@Param("devtypeServicename") String devtypeServicename, @Param("devCode") String devCode);
 
     void updateIotDeviceExtInfo(@Param("devBid") String devBid, @Param("extInfo") String extInfo, @Param("updateDate") String updateDate);
 
-    List<IotDevice> selectIotDeviceList(IotDevice iotDevice);
-
-    public int updateIotDeviceStatusByDevBidList(List<String> devBidList);
-
-    public int updateIotDeviceStatusByDevCodeList(@Param("devStatus") String devStatus, @Param("list") List<String> devCodeList, @Param("firmBid") String firmBid, @Param("devtypeBid") String devtypeBid);
-
-
-    public void updateIotDeviceByDevCodeAndFirmDev(IotDevice iotDevice);
-
-    /**
-     * 根据厂家和设备类型列表获取设备
-     *
-     * @param firmBizId
-     * @param devtypeBids
-     * @return
-     */
-
-    public List<IotDevice> getDeviceListByDevtypeBids(@Param("firmBizId") String firmBizId, @Param("devtypeBids") List<String> devtypeBids);
-
-    public void updateIotDeviceBatch(List<IotDevice> iotDeviceList);
-
-    public IotDevice getDeviceListByDevtypeBidsAndDevCode(
-            @Param("firmBizId") String firmBizId,
-            @Param("devCode") String devCode,
-            @Param("devtypeBids") List<String> devtypeBids
-    );
-
-    List<IotDevice> selectIotDeviceByIotDeviceDTO(IotDeviceDto iotDeviceDto);
-
-    int updateIotDeviceStatusByType(@Param("devStatus") String devStatus, @Param("firmBid") String firmBid, @Param("devtypeBid") String devtypeBid);
+    public int updateIotDeviceBatch(List<IotDevice> iotDeviceList);
 
     List<String> getDeviceCodesByDevconnBid(@Param("devconnBid") String devconnBid);
 

+ 1 - 52
src/main/java/com/yunfeiyun/agmp/iots/service/IIotDeviceService.java

@@ -2,8 +2,6 @@ package com.yunfeiyun.agmp.iots.service;
 
 
 import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
-import com.yunfeiyun.agmp.iot.common.domain.dto.IotDeviceDto;
-import com.yunfeiyun.agmp.iot.common.domain.resvo.IotXmzndeviceResVo;
 import com.yunfeiyun.agmp.iot.common.model.device.IotDeviceStatusResVo;
 
 import java.util.List;
@@ -24,10 +22,8 @@ public interface IIotDeviceService {
      * @return 设备基础集合
      */
     public IotDevice selectIotDeviceByTypeFirmCode(IotDevice iotDevice);
-    public IotDevice selectIotDeviceByTypeFirmCodeExt(IotDevice iotDevice);
 
     public IotDevice selectIotDeviceByTypeFirmCode(String devtypeBid, String firmBid, String devCode);
-    public IotDevice selectIotDeviceByTypeFirmCodeExt(String devtypeBid, String firmBid, String devCode,String extinfo);
 
     /**
      * 修改设备基础
@@ -66,69 +62,22 @@ public interface IIotDeviceService {
      */
     List<IotDevice> getDeviceIdByFirmBizId(String firmBizId, String deviceTypeBizId);
 
-
-    List<IotXmzndeviceResVo> getXmznDeviceList(String firmBizId);
-
     /**
      * 根据OriginalId获取设备(物候数据回调时候会用到)
      *
      * @param originalId
      * @return
      */
-    IotDevice getDeviceByOriginalId(String originalId);
-
-    IotDevice findDeviceByDevCodeAndDevTypeBid(String devCode, String devTypeBid, String firmBid);
 
     List<IotDeviceStatusResVo> selectAllDeviceConfigStatus(Map param);
 
-    public int deleteIotDeviceByDevBids(String[] devBids);
-
     public List<IotDevice> selectAllDeviceByDeviceServiceName(String deviceServiceName);
 
-    public List<IotDevice> selectIotDeviceByIotDeviceDTO(IotDeviceDto iotDeviceDto);
-
     public IotDevice selectDeviceByDeviceServiceNameAndDevCode(String deviceServiceName,String devCode);
 
-    List<IotDevice> selectIotDeviceList(IotDevice iotDevice);
-
-    public int updateIotDeviceStatusByDevBidList(List<String> devBidList);
-
     void updateIotDeviceExtInfo(String devBid, String extInfo);
 
-
-    void updateIotDeviceByDevCodeAndFirmDev(IotDevice iotDevice);
-
-    void updateIotDeviceStatusByDevCodeList(String devStatus,List<String> devCodeList,String devtypeBid,String firmBid);
-    int updateIotDeviceStatusByType(String devStatus,String firmBid,String devtypeBid);
-
-    /**
-     * 根据厂家和设备类型列表获取设备
-     *
-     * @param firmBizId
-     * @param
-     * @return
-     */
-    List<IotDevice> getDeviceListByDevtypeBids(String firmBizId, List<String> devtypeBids);
-
-    /**
-     * 根据厂家和设备类型列表获取设备
-     *
-     * @param firmBizId
-     * @param
-     * @return
-     */
-    IotDevice getDeviceListByDevtypeBidsAndDevCode(String firmBizId, String devCode, List<String> devtypeBids);
-
-    /**
-     * 根据厂家和设备类型map获取设备
-     *
-     * @param firmBizId
-     * @param
-     * @return
-     */
-    Map<String, List<IotDevice>> getXphHttpDeviceMapByDevtypeBids(String firmBizId, List<String> devtypeBids);
-
-    public void updateIotDeviceBatch(List<IotDevice> iotDeviceList);
+    public int updateIotDeviceBatch(List<IotDevice> iotDeviceList);
 
     List<String> getDeviceCodesByDevconnBid(String connectionId);
 

+ 22 - 0
src/main/java/com/yunfeiyun/agmp/iots/service/IotDeviceGeoLocationService.java

@@ -0,0 +1,22 @@
+package com.yunfeiyun.agmp.iots.service;
+
+import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
+import com.yunfeiyun.agmp.iot.common.domain.IotDeviceGeoLocation;
+
+import java.util.List;
+
+public interface IotDeviceGeoLocationService {
+    /**
+     * 插入数据
+     */
+    public void insertBatchData(List<IotDeviceGeoLocation> dataList);
+
+    /**
+     * 更新数据
+     */
+    public void updateBatchData(List<IotDeviceGeoLocation> dataList);
+
+    public void insertOrUpdateBatchData(List<IotDevice> iotDeviceList);
+
+    public List<IotDeviceGeoLocation> selectByDevBidList(List<String> devBidList);
+}

+ 152 - 0
src/main/java/com/yunfeiyun/agmp/iots/service/impl/IotDeviceGeoLocationServiceImpl.java

@@ -0,0 +1,152 @@
+package com.yunfeiyun.agmp.iots.service.impl;
+
+import com.yunfeiyun.agmp.common.utils.DateUtils;
+import com.yunfeiyun.agmp.iot.common.domain.IotDevGeoPoint;
+import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
+import com.yunfeiyun.agmp.iot.common.domain.IotDeviceGeoLocation;
+import com.yunfeiyun.agmp.iot.common.domain.dto.MgUpdateBatchDto;
+import com.yunfeiyun.agmp.iot.common.service.MongoService;
+import com.yunfeiyun.agmp.iot.common.util.BigDecimalUtil;
+import com.yunfeiyun.agmp.iots.service.IotDeviceGeoLocationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class IotDeviceGeoLocationServiceImpl implements IotDeviceGeoLocationService {
+
+    @Autowired
+    private MongoService mongoService;
+
+    /**
+     * 插入或更新数据
+     */
+    @Override
+    public void insertBatchData(List<IotDeviceGeoLocation> dataList) {
+        if(!dataList.isEmpty()) {
+            mongoService.insertList(IotDeviceGeoLocation.class, dataList);
+        }
+    }
+
+    /**
+     * 更新数据
+     *
+     * @param dataList
+     */
+    @Override
+    public void updateBatchData(List<IotDeviceGeoLocation> dataList) {
+        List<MgUpdateBatchDto> updateBatchDtoList = new ArrayList<>();
+        for(IotDeviceGeoLocation item : dataList) {
+            String devGeoBid = item.getDevGeoBid();
+            IotDevGeoPoint geoPoint = item.getDevGeoLocation();
+            String devGeoUpdateddate = DateUtils.dateTimeNow();
+            String devtypeBid = item.getDevtypeBid();
+
+            Query query = new Query(Criteria.where("devGeoBid").is(devGeoBid));
+            Map<String, Object> updateField = new HashMap<>();
+            updateField.put("devGeoUpdateddate", devGeoUpdateddate);
+            updateField.put("devtypeBid", devtypeBid);
+            updateField.put("devGeoLocation", geoPoint);
+
+            MgUpdateBatchDto updateBatchDto = new MgUpdateBatchDto();
+            updateBatchDto.setQuery(query);
+            updateBatchDto.setUpdateField(updateField);
+            updateBatchDtoList.add(updateBatchDto);
+        }
+        if(!updateBatchDtoList.isEmpty()) {
+            mongoService.updateBatch(IotDeviceGeoLocation.class, updateBatchDtoList);
+        }
+    }
+
+    @Override
+    public void insertOrUpdateBatchData(List<IotDevice> iotDeviceList) {
+        List<String> devBidList = new ArrayList<>();
+        for(IotDevice iotDevice : iotDeviceList) {
+            BigDecimal devLng = iotDevice.getDevLngalign();
+            BigDecimal devLat = iotDevice.getDevLatalign();
+            if(devLng == null || devLat == null) {
+                devLng = iotDevice.getDevLng();
+                devLat = iotDevice.getDevLat();
+            }
+            if (devLng == null || devLat == null){
+                continue;
+            }
+
+            String devBid = iotDevice.getDevBid();
+            devBidList.add(devBid);
+        }
+        Map<String, IotDeviceGeoLocation> iotDeviceGeoLocationMap = new HashMap<>();
+        if(!devBidList.isEmpty()) {
+            List<IotDeviceGeoLocation> iotDeviceGeoLocationList = selectByDevBidList(devBidList);
+            for(IotDeviceGeoLocation iotDeviceGeoLocation : iotDeviceGeoLocationList) {
+                iotDeviceGeoLocationMap.put(iotDeviceGeoLocation.getDevBid(), iotDeviceGeoLocation);
+            }
+        }
+        List<IotDeviceGeoLocation> updateList = new ArrayList<>();
+        List<IotDeviceGeoLocation> insertList = new ArrayList<>();
+        for(IotDevice iotDevice : iotDeviceList) {
+            BigDecimal devLng = iotDevice.getDevLngalign();
+            BigDecimal devLat = iotDevice.getDevLatalign();
+            if(devLng == null || devLat == null) {
+                devLng = iotDevice.getDevLng();
+                devLat = iotDevice.getDevLat();
+            }
+
+            String devBid = iotDevice.getDevBid();
+            IotDeviceGeoLocation iotDeviceGeoLocation = iotDeviceGeoLocationMap.get(devBid);
+            if (iotDeviceGeoLocation == null) {
+                iotDeviceGeoLocation = new IotDeviceGeoLocation();
+                iotDeviceGeoLocation.setDevGeoBid(iotDeviceGeoLocation.getUUId());
+                iotDeviceGeoLocation.setTid(iotDevice.getTid());
+                iotDeviceGeoLocation.setDevBid(devBid);
+                iotDeviceGeoLocation.setDevtypeBid(iotDevice.getDevtypeBid());
+                iotDeviceGeoLocation.setDevGeoCreateddate(DateUtils.dateTimeNow());
+                iotDeviceGeoLocation.setDevGeoUpdateddate(DateUtils.dateTimeNow());
+                IotDevGeoPoint geoPoint = new IotDevGeoPoint();
+                geoPoint.setType("Point");
+
+                double[] coordinates = new double[2];
+                coordinates[0] = BigDecimalUtil.toDouble(devLng);
+                coordinates[1] = BigDecimalUtil.toDouble(devLat);
+                geoPoint.setCoordinates(coordinates);
+                iotDeviceGeoLocation.setDevGeoLocation(geoPoint);
+
+                insertList.add(iotDeviceGeoLocation);
+            }else{
+                double[] coordinates = iotDeviceGeoLocation.getDevGeoLocation().getCoordinates();
+                BigDecimal devLngOld = BigDecimalUtil.format(coordinates[0]);
+                BigDecimal devLatOld = BigDecimalUtil.format(coordinates[1]);
+                if(!devLng.equals(devLngOld) || !devLat.equals(devLatOld)) {
+                    coordinates[0] = BigDecimalUtil.toDouble(devLng);
+                    coordinates[1] = BigDecimalUtil.toDouble(devLat);
+
+                    iotDeviceGeoLocation.getDevGeoLocation().setCoordinates(coordinates);
+                    iotDeviceGeoLocation.setDevGeoUpdateddate(DateUtils.dateTimeNow());
+                    iotDeviceGeoLocation.setDevtypeBid(iotDevice.getDevtypeBid());
+
+                    updateList.add(iotDeviceGeoLocation);
+                }
+            }
+        }
+        if(!updateList.isEmpty()) {
+            updateBatchData(updateList);
+        }
+        if(!insertList.isEmpty()) {
+            insertBatchData(insertList);
+        }
+    }
+
+    @Override
+    public List<IotDeviceGeoLocation> selectByDevBidList(List<String> devBidList) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("list_devBid", devBidList);
+        return mongoService.findAll(IotDeviceGeoLocation.class, null);
+    }
+}

+ 31 - 180
src/main/java/com/yunfeiyun/agmp/iots/service/impl/IotDeviceServiceImpl.java

@@ -5,17 +5,20 @@ import com.yunfeiyun.agmp.common.utils.StringUtils;
 import com.yunfeiyun.agmp.common.web.system.service.ISysConfigService;
 import com.yunfeiyun.agmp.iot.common.constant.IotErrorCode;
 import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
-import com.yunfeiyun.agmp.iot.common.domain.dto.IotDeviceDto;
-import com.yunfeiyun.agmp.iot.common.domain.resvo.IotXmzndeviceResVo;
 import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
 import com.yunfeiyun.agmp.iot.common.model.device.IotDeviceStatusResVo;
+import com.yunfeiyun.agmp.iot.common.service.MongoService;
 import com.yunfeiyun.agmp.iots.device.mapper.IotDeviceMapper;
 import com.yunfeiyun.agmp.iots.service.IIotDeviceService;
+import com.yunfeiyun.agmp.iots.service.IotDeviceGeoLocationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -33,6 +36,12 @@ public class IotDeviceServiceImpl implements IIotDeviceService {
     @Autowired
     private ISysConfigService sysConfigService;
 
+    @Autowired
+    private MongoService mongoService;
+
+    @Autowired
+    private IotDeviceGeoLocationService iotDeviceGeoLocationService;
+
     /**
      * 查询设备基础
      *
@@ -45,17 +54,6 @@ public class IotDeviceServiceImpl implements IIotDeviceService {
     }
 
     /**
-     * 查询设备基础
-     *
-     * @param iotDevice 设备基础
-     * @return 设备基础
-     */
-    @Override
-    public IotDevice selectIotDeviceByTypeFirmCodeExt(IotDevice iotDevice) {
-        return iotDeviceMapper.selectIotDeviceByTypeFirmCodeExt(iotDevice);
-    }
-
-    /**
      * @param devtypeBid
      * @param firmBid
      * @param devCode
@@ -81,37 +79,6 @@ public class IotDeviceServiceImpl implements IIotDeviceService {
         return selectIotDeviceByTypeFirmCode(iotDevice);
     }
 
-    /**
-     * @param devtypeBid
-     * @param firmBid
-     * @param devCode
-     * @return
-     */
-    @Override
-    public IotDevice selectIotDeviceByTypeFirmCodeExt(String devtypeBid, String firmBid, String devCode, String extinfo) {
-        IotDevice iotDevice = new IotDevice();
-        if (StringUtils.isEmpty(devtypeBid)) {
-            throw new IotBizException(IotErrorCode.FAILURE.getCode(), "查询设备失败:devtypeBid为空");
-        }
-        if (StringUtils.isEmpty(firmBid)) {
-            throw new IotBizException(IotErrorCode.FAILURE.getCode(), "查询设备失败:firmBid为空");
-
-        }
-        if (StringUtils.isEmpty(devCode)) {
-            throw new IotBizException(IotErrorCode.FAILURE.getCode(), "查询设备失败:devCode为空");
-
-        }
-        if (StringUtils.isEmpty(extinfo)) {
-            throw new IotBizException(IotErrorCode.FAILURE.getCode(), "查询设备失败:extinfo empty");
-
-        }
-        iotDevice.setDevtypeBid(devtypeBid);
-        iotDevice.setFirmBid(firmBid);
-        iotDevice.setDevCode(devCode);
-        //iotDevice.setExtInfo(extinfo);
-        return selectIotDeviceByTypeFirmCodeExt(iotDevice);
-    }
-
     @Override
     public int insertIotDevice(IotDevice iotDevice) {
         return iotDeviceMapper.insertIotDevice(iotDevice);
@@ -128,7 +95,25 @@ public class IotDeviceServiceImpl implements IIotDeviceService {
         if (needFakeStatus(iotDevice.getDevBid())) {
             iotDevice.setDevStatus("1");
         }
-        return iotDeviceMapper.updateIotDevice(iotDevice);
+        List<IotDevice> iotDeviceList = new ArrayList<>();
+        iotDeviceList.add(iotDevice);
+        return updateIotDeviceBatch(iotDeviceList);
+    }
+
+    /**
+     * @param iotDeviceList
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public int updateIotDeviceBatch(List<IotDevice> iotDeviceList) {
+        for (IotDevice iotDevice : iotDeviceList) {
+            if (needFakeStatus(iotDevice.getDevBid())) {
+                iotDevice.setDevStatus("1");
+            }
+        }
+        int status = iotDeviceMapper.updateIotDeviceBatch(iotDeviceList);
+        iotDeviceGeoLocationService.insertOrUpdateBatchData(iotDeviceList);
+        return status;
     }
 
     @Override
@@ -162,22 +147,6 @@ public class IotDeviceServiceImpl implements IIotDeviceService {
         return iotDeviceMapper.getDeviceIdByFirmBizId(firmBizId, deviceTypeBizId);
     }
 
-
-    @Override
-    public List<IotXmzndeviceResVo> getXmznDeviceList(String firmBizId) {
-        return iotDeviceMapper.getXmznDeviceList(firmBizId);
-    }
-
-    @Override
-    public IotDevice getDeviceByOriginalId(String originalId) {
-        return iotDeviceMapper.getDeviceByOriginalId(originalId);
-    }
-
-    @Override
-    public IotDevice findDeviceByDevCodeAndDevTypeBid(String devCode, String devTypeBid, String firmBid) {
-        return iotDeviceMapper.findDeviceByDevCodeAndDevTypeBid(devCode, devTypeBid, firmBid);
-    }
-
     @Override
     public List<IotDeviceStatusResVo> selectAllDeviceConfigStatus(Map param) {
 
@@ -185,49 +154,15 @@ public class IotDeviceServiceImpl implements IIotDeviceService {
     }
 
     @Override
-    public int deleteIotDeviceByDevBids(String[] devBids) {
-        return iotDeviceMapper.deleteIotDeviceByDevBids(devBids);
-    }
-
-    @Override
     public List<IotDevice> selectAllDeviceByDeviceServiceName(String deviceServiceName) {
         return iotDeviceMapper.selectAllDeviceByDeviceServiceName(deviceServiceName);
     }
 
     @Override
-    public List<IotDevice> selectIotDeviceByIotDeviceDTO(IotDeviceDto iotDeviceDto) {
-        return iotDeviceMapper.selectIotDeviceByIotDeviceDTO(iotDeviceDto);
-    }
-
-    @Override
     public IotDevice selectDeviceByDeviceServiceNameAndDevCode(String deviceServiceName, String devCode) {
         return iotDeviceMapper.selectDeviceByDeviceServiceNameAndDevCode(deviceServiceName, devCode);
     }
 
-    /**
-     * @param iotDevice
-     * @return
-     */
-    @Override
-    public List<IotDevice> selectIotDeviceList(IotDevice iotDevice) {
-        return iotDeviceMapper.selectIotDeviceList(iotDevice);
-    }
-
-    /**
-     * @param devBidList
-     * @return
-     */
-    @Override
-    public int updateIotDeviceStatusByDevBidList(List<String> devBidList) {
-        List<String> devBidList2 = new ArrayList<>();
-        for (String devBid : devBidList) {
-            if (!needFakeStatus(devBid)) {
-                devBidList2.add(devBid);
-            }
-        }
-        return iotDeviceMapper.updateIotDeviceStatusByDevBidList(devBidList2);
-    }
-
     @Override
     public void updateIotDeviceExtInfo(String devBid, String extInfo) {
         String updateDate = DateUtils.dateTimeNow();
@@ -235,90 +170,6 @@ public class IotDeviceServiceImpl implements IIotDeviceService {
     }
 
     @Override
-    public void updateIotDeviceByDevCodeAndFirmDev(IotDevice iotDevice) {
-        if (needFakeStatus(iotDevice.getDevBid())) {
-            iotDevice.setDevStatus("1");
-        }
-        iotDeviceMapper.updateIotDeviceByDevCodeAndFirmDev(iotDevice);
-    }
-
-    @Override
-    public void updateIotDeviceStatusByDevCodeList(String devStatus, List<String> devCodeList, String devtypeBid, String firmBid) {
-        List<String> devCodeList2 = new ArrayList<>();
-        for (String devBid : devCodeList) {
-            if (!needFakeStatus(devBid)) {
-                devCodeList2.add(devBid);
-            }
-        }
-        iotDeviceMapper.updateIotDeviceStatusByDevCodeList(devStatus, devCodeList2, devtypeBid, firmBid);
-    }
-
-    @Override
-    public int updateIotDeviceStatusByType(String devStatus, String firmBid, String devtypeBid) {
-        return iotDeviceMapper.updateIotDeviceStatusByType(devStatus, firmBid, devtypeBid);
-    }
-
-    /**
-     * 根据厂家和设备类型列表获取设备
-     *
-     * @param firmBizId
-     * @param devtypeBids
-     * @return
-     */
-    @Override
-    public List<IotDevice> getDeviceListByDevtypeBids(String firmBizId, List<String> devtypeBids) {
-        return iotDeviceMapper.getDeviceListByDevtypeBids(firmBizId, devtypeBids);
-    }
-
-    /**
-     * 根据厂家和设备类型列表获取设备
-     *
-     * @param firmBizId
-     * @param devCode
-     * @param devtypeBids
-     * @return
-     */
-    @Override
-    public IotDevice getDeviceListByDevtypeBidsAndDevCode(String firmBizId, String devCode, List<String> devtypeBids) {
-        return iotDeviceMapper.getDeviceListByDevtypeBidsAndDevCode(firmBizId, devCode, devtypeBids);
-    }
-
-    /**
-     * 根据厂家和设备类型map获取设备
-     *
-     * @param firmBizId
-     * @param devtypeBids
-     * @return
-     */
-    @Override
-    public Map<String, List<IotDevice>> getXphHttpDeviceMapByDevtypeBids(String firmBizId, List<String> devtypeBids) {
-        List<IotDevice> iotDeviceList = getDeviceListByDevtypeBids(firmBizId, devtypeBids);
-        Map<String, List<IotDevice>> iotDeviceMap = new HashMap<>();
-        for (IotDevice iotDevice : iotDeviceList) {
-            String devCode = iotDevice.getDevCode();
-            if (!iotDeviceMap.containsKey(devCode)) {
-                iotDeviceMap.put(devCode, new ArrayList<>());
-            }
-            iotDeviceMap.get(devCode).add(iotDevice);
-        }
-        return iotDeviceMap;
-    }
-
-    /**
-     * @param iotDeviceList
-     */
-    @Transactional(rollbackFor = Exception.class)
-    @Override
-    public void updateIotDeviceBatch(List<IotDevice> iotDeviceList) {
-        for (IotDevice iotDevice : iotDeviceList) {
-            if (needFakeStatus(iotDevice.getDevBid())) {
-                iotDevice.setDevStatus("1");
-            }
-        }
-        iotDeviceMapper.updateIotDeviceBatch(iotDeviceList);
-    }
-
-    @Override
     public List<String> getDeviceCodesByDevconnBid(String devConnBid) {
         return iotDeviceMapper.getDeviceCodesByDevconnBid(devConnBid);
     }

+ 0 - 237
src/main/resources/mapper/IotDeviceMapper.xml

@@ -47,15 +47,6 @@
         where devtypeBid = #{devtypeBid} and firmBid = #{firmBid} and devCode = #{devCode} and devDelstatus = '0'
     </select>
 
-    <select id="selectIotDeviceByTypeFirmCodeExt" parameterType="IotDevice" resultMap="IotDeviceResult">
-        <include refid="selectIotDeviceVo"/>
-        where devtypeBid = #{devtypeBid}
-        and firmBid = #{firmBid}
-        and devCode = #{devCode}
-        and extInfo = #{extInfo}
-        and devDelstatus = '0'
-    </select>
-
     <select id="selectIotDeviceByDevBid" resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
         <include refid="selectIotDeviceVo"/>
         <where>
@@ -72,62 +63,11 @@
         </foreach>
     </select>
 
-    <select id="selectIotDeviceList" parameterType="IotDevice"
-            resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
-        <include refid="selectIotDeviceVo"/>
-        <where>
-            devDelstatus = '0'
-            <if test="devCode != null  and devCode != ''">and devCode = #{devCode}</if>
-            <if test="firmBid != null  and firmBid != ''">and firmBid = #{firmBid}</if>
-            <if test="devtypeBid != null  and devtypeBid != ''">and devtypeBid = #{devtypeBid}</if>
-            <if test="devStatus != null  and devStatus != ''">and devStatus = #{devStatus}</if>
-            <if test="devModifieddate != null  and devModifieddate != ''">
-                and devModifieddate <![CDATA[ <= ]]> #{devModifieddate}
-            </if>
-            <if test="devUpdateddate != null  and devUpdateddate != ''">and devUpdateddate <![CDATA[ <= ]]>
-                #{devUpdateddate}
-            </if>
-        </where>
-    </select>
-
     <select id="getDeviceIdByFirmBizId" resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice"
             parameterType="string">
         select * from IotDevice where firmBid=#{firmBizId} and devtypeBid=#{deviceTypeBizId} and devDelstatus = '0';
     </select>
 
-
-    <select id="getXmznDeviceList" resultType="com.yunfeiyun.agmp.iot.common.domain.resvo.IotXmzndeviceResVo"
-            parameterType="string">
-        select IotDevice.*
-        ,IotXmzndevice.xdName
-        ,IotXmzndevice.xdCata
-        ,IotXmzndevice.xdMac
-        ,IotXmzndevice.xdAddr
-        ,IotXmzndevice.xdDevclassid
-        ,IotXmzndevice.xdDataclass
-        ,IotXmzndevice.xdCtrltype
-        ,IotXmzndevice.xdMonitortype
-        ,IotXmzndevice.xdClassid
-        from IotDevice
-        left join IotXmzndevice on IotXmzndevice.devBid = IotDevice.devBid
-        where IotDevice.firmBid=#{firmBizId} and IotDevice.devDelstatus = '0';
-    </select>
-    <select id="getDeviceByOriginalId" parameterType="java.lang.String"
-            resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
-        select * from IotDevice where devOriginalid=#{originalId} and IotDevice.devDelstatus = '0'
-
-    </select>
-    <select id="findDeviceByDevCodeAndDevTypeBid" resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
-        select * from IotDevice where
-        devCode = #{devCode}
-        <if test="devtypeBid != null and devtypeBid != ''">
-            and devtypeBid = #{devtypeBid}
-        </if>
-        <if test="firmBid != null and firmBid != ''">
-            and firmBid = #{firmBid}
-        </if>
-        limit 1
-    </select>
     <select id="selectAllDeviceConfigStatus"
             resultType="com.yunfeiyun.agmp.iot.common.model.device.IotDeviceStatusResVo" parameterType="map">
                select * from IotDevice a left join IotDeviceconfig b on a.devBid=b.devBid where  a.devDelstatus='0' and  devtypeBid=#{type} ORDER BY devtypeBid  asc
@@ -173,88 +113,9 @@
         group by iotd.devBid
     </select>
 
-
-    <update id="updateIotDevice" parameterType="IotDevice">
-        update IotDevice
-        <trim prefix="SET" suffixOverrides=",">
-            <if test="tid != null">tid = #{tid},</if>
-            <if test="devtypeBid != null and devtypeBid != ''">devtypeBid = #{devtypeBid},</if>
-            <if test="firmBid != null">firmBid = #{firmBid},</if>
-            <if test="devCode != null">devCode = #{devCode},</if>
-            <if test="devName != null">devName = #{devName},</if>
-            <if test="devVersion != null">devVersion = #{devVersion},</if>
-            <if test="devStatus != null">devStatus = #{devStatus},</if>
-            <if test="devProvince != null">devProvince = #{devProvince},</if>
-            <if test="devCity != null">devCity = #{devCity},</if>
-            <if test="devDistrict != null">devDistrict = #{devDistrict},</if>
-            <if test="devLng != null">devLng = #{devLng},</if>
-            <if test="devLat != null">devLat = #{devLat},</if>
-            <if test="devPositionstatus != null">devPositionstatus = #{devPositionstatus},</if>
-            <if test="devPositiontype != null">devPositiontype = #{devPositiontype},</if>
-            <if test="devTag != null">devTag = #{devTag},</if>
-            <if test="devRecogtype != null">devRecogtype = #{devRecogtype},</if>
-            <if test="devNetworktype != null">devNetworktype = #{devNetworktype},</if>
-            <if test="devOnlinedate != null">devOnlinedate = #{devOnlinedate},</if>
-            <if test="devOfflinedate != null">devOfflinedate = #{devOfflinedate},</if>
-            <if test="devSubtype != null">devSubtype = #{devSubtype},</if>
-            <if test="devUpdateddate != null">devUpdateddate = #{devUpdateddate},</if>
-            <if test="devCreator != null">devCreator = #{devCreator},</if>
-            <if test="devModifier != null">devModifier = #{devModifier},</if>
-            <if test="devModifieddate != null">devModifieddate = #{devModifieddate},</if>
-            <if test="devCreateddate != null">devCreateddate = #{devCreateddate},</if>
-            <if test="devDelstatus != null">devDelstatus = #{devDelstatus},</if>
-            <if test="devOriginalid != null">devOriginalid = #{devOriginalid},</if>
-            <if test="devHostingstatus != null">devHostingstatus = #{devHostingstatus},</if>
-            <if test="extInfo != null">extInfo = #{extInfo},</if>
-        </trim>
-        where devBid = #{devBid} and devDelstatus = '0'
-    </update>
     <update id="updateIotDeviceExtInfo">
         update  IotDevice set extInfo=#{extInfo}, devStatus='1' ,devUpdateddate=#{updateDate} ,devModifieddate=#{updateDate} where  devBid=#{devBid}
     </update>
-    <update id="updateIotDeviceByDevCodeAndFirmDev">
-        update IotDevice
-        <trim prefix="SET" suffixOverrides=",">
-            <if test="tid != null">tid = #{tid},</if>
-            <if test="devtypeBid != null and devtypeBid != ''">devtypeBid = #{devtypeBid},</if>
-            <if test="firmBid != null">firmBid = #{firmBid},</if>
-            <if test="devCode != null">devCode = #{devCode},</if>
-            <if test="devName != null">devName = #{devName},</if>
-            <if test="devVersion != null">devVersion = #{devVersion},</if>
-            <if test="devStatus != null">devStatus = #{devStatus},</if>
-            <if test="devProvince != null">devProvince = #{devProvince},</if>
-            <if test="devCity != null">devCity = #{devCity},</if>
-            <if test="devDistrict != null">devDistrict = #{devDistrict},</if>
-            <if test="devLng != null">devLng = #{devLng},</if>
-            <if test="devLat != null">devLat = #{devLat},</if>
-            <if test="devPositionstatus != null">devPositionstatus = #{devPositionstatus},</if>
-            <if test="devPositiontype != null">devPositiontype = #{devPositiontype},</if>
-            <if test="devTag != null">devTag = #{devTag},</if>
-            <if test="devRecogtype != null">devRecogtype = #{devRecogtype},</if>
-            <if test="devNetworktype != null">devNetworktype = #{devNetworktype},</if>
-            <if test="devOnlinedate != null">devOnlinedate = #{devOnlinedate},</if>
-            <if test="devOfflinedate != null">devOfflinedate = #{devOfflinedate},</if>
-            <if test="devSubtype != null">devSubtype = #{devSubtype},</if>
-            <if test="devUpdateddate != null">devUpdateddate = #{devUpdateddate},</if>
-            <if test="devCreator != null">devCreator = #{devCreator},</if>
-            <if test="devModifier != null">devModifier = #{devModifier},</if>
-            <if test="devModifieddate != null">devModifieddate = #{devModifieddate},</if>
-            <if test="devCreateddate != null">devCreateddate = #{devCreateddate},</if>
-            <if test="devDelstatus != null">devDelstatus = #{devDelstatus},</if>
-            <if test="devOriginalid != null">devOriginalid = #{devOriginalid},</if>
-            <if test="devHostingstatus != null">devHostingstatus = #{devHostingstatus},</if>
-            <if test="extInfo != null">extInfo = #{extInfo},</if>
-        </trim>
-        where devCode = #{devCode} and firmBid = #{firmBid} and devtypeBid = #{devtypeBid}
-    </update>
-    <update id="updateIotDeviceStatusByDevCodeList">
-        update IotDevice set devStatus = #{devStatus} where devtypeBid = #{devtypeBid} and firmBid = #{firmBid} and
-        devCode in
-        <foreach item="item" collection="list" open="(" separator="," close=")">
-            #{item}
-        </foreach>
-    </update>
-
 
     <insert id="insertIotDevice" parameterType="IotDevice" useGeneratedKeys="true" keyProperty="id">
         insert into IotDevice
@@ -338,27 +199,6 @@
         </trim>
     </insert>
 
-    <delete id="deleteIotDeviceByDevBids" parameterType="String">
-        update IotDevice set devDelstatus = 1 where devBid in
-        <foreach item="devBid" collection="array" open="(" separator="," close=")">
-            #{devBid}
-        </foreach>
-    </delete>
-
-    <delete id="updateIotDeviceStatusByDevBidList" parameterType="java.util.List">
-        update IotDevice set devStatus = '0' where devBid in
-        <foreach item="devBid" collection="list" open="(" separator="," close=")">
-            #{devBid}
-        </foreach>
-    </delete>
-
-    <select id="getDeviceListByDevtypeBids" resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
-        <include refid="selectIotDeviceVo"/>
-        where devDelstatus = '0' and firmBid = #{firmBizId} and devtypeBid in
-        <foreach item="devtypeBid" collection="devtypeBids" open="(" separator="," close=")">
-            #{devtypeBid}
-        </foreach>
-    </select>
     <select id="selectDeviceByDeviceServiceNameAndDevCode"
             resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
         select
@@ -437,84 +277,7 @@
             where devBid = #{item.devBid} and devDelstatus = '0'
         </foreach>
     </update>
-    <update id="updateIotDeviceStatusByType">
-        update IotDevice set devStatus = #{devStatus} where devtypeBid = #{devtypeBid} and firmBid = #{firmBid}
-    </update>
 
-    <select id="getDeviceListByDevtypeBidsAndDevCode" resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
-        <include refid="selectIotDeviceVo"/>
-        where devDelstatus = '0' and firmBid = #{firmBizId} and devCode = #{devCode} and devtypeBid in
-        <foreach item="devtypeBid" collection="devtypeBids" open="(" separator="," close=")">
-            #{devtypeBid}
-        </foreach>
-    </select>
-    <select id="selectIotDeviceByIotDeviceDTO" resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
-        select
-        d.id,
-        d.devBid,
-        d.tid,
-        d.devtypeBid,
-        d.firmBid,
-        d.devCode,
-        d.devName,
-        d.devVersion,
-        d.devStatus,
-        d.devProvince,
-        d.devCity,
-        d.devDistrict,
-        d.devLng,
-        d.devLat,
-        d.devPositionstatus,
-        d.devPositiontype,
-        d.devTag,
-        d.devRecogtype,
-        d.devNetworktype,
-        d.devOnlinedate,
-        d.devOfflinedate,
-        d.devSubtype,
-        d.devCreator,
-        d.devModifier,
-        d.devUpdateddate,
-        d.devModifieddate,
-        d.devCreateddate,
-        d.devDelstatus,
-        d.extInfo
-        from IotDevice d
-        LEFT JOIN IotDevicetype idt ON d.devtypeBid = idt.devtypeBid
-        <where>
-            devDelstatus = '0'
-            <if test="devBid != null  and devBid != ''">and d.devBid = #{devBid}</if>
-            <if test="tid != null  and tid != ''">and d.tid = #{tid}</if>
-            <if test="devtypeBids != null  and devtypeBids != ''">and e.devtypePid in (${devtypeBids})</if>
-            <if test="devtypeBid != null  and devtypeBid != ''">and e.devtypePid = #{devtypeBid}</if>
-            <if test="firmBid != null  and firmBid != ''">and d.firmBid = #{firmBid}</if>
-            <if test="devSubtype != null  and devSubtype != ''">and d.devSubtype = #{devSubtype}</if>
-            <if test="devTel != null  and devTel != ''">and d.devTel like concat('%', #{devTel}, '%')</if>
-            <if test="devName != null  and devName != ''">and d.devName like concat('%', #{devName}, '%')</if>
-            <if test="devCode != null  and devCode != ''">and d.devCode like concat('%', #{devCode}, '%')</if>
-            <if test="devStatus != null  and devStatus != ''">and d.devStatus = #{devStatus}</if>
-            <if test="devHostingstatus != null  and devHostingstatus != ''">and d.devHostingstatus =
-                #{devHostingstatus}
-            </if>
-            <if test="devtypeBidList != null  and devtypeBidList.size() != 0">
-                and d.devtypeBid in
-                <foreach collection="devtypeBidList" item="item" index="index" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-            <if test="devBids != null  and devBids.size() != 0">
-                and d.devBid in
-                <foreach collection="devBids" item="item" index="index" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-            <if test="serviceName != null and serviceName !=''">
-                and idt.devtypeServicename = #{serviceName}
-            </if>
-        </where>
-        and d.devDelstatus='0'
-        group by d.devBid
-    </select>
     <select id="getDeviceCodesByDevconnBid" resultType="java.lang.String">
         select  devCode from IotDevice where devconnBid=#{devconnBid} and devDelstatus='0'
     </select>