diff --git a/pom.xml b/pom.xml index 1251320..d0dc1b6 100644 --- a/pom.xml +++ b/pom.xml @@ -199,6 +199,11 @@ jedis 3.7.0 + + cn.hutool + hutool-all + ${hutool-all.version} + diff --git a/src/main/java/com/xkrs/SmartUrbanRuralApplication.java b/src/main/java/com/xkrs/SmartUrbanRuralApplication.java index bb6377e..256843c 100644 --- a/src/main/java/com/xkrs/SmartUrbanRuralApplication.java +++ b/src/main/java/com/xkrs/SmartUrbanRuralApplication.java @@ -1,9 +1,19 @@ package com.xkrs; +import com.alibaba.fastjson.JSON; +import com.xkrs.model.vo.ADD; +import com.xkrs.model.vo.DA; +import com.xkrs.service.CameraService; +import com.xkrs.service.impl.CameraServiceImpl; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.jms.annotation.EnableJms; +import javax.annotation.Resource; +import java.io.*; +import java.util.ArrayList; +import java.util.List; + /** * 启动类 * @author XinYi Song @@ -14,6 +24,7 @@ import org.springframework.jms.annotation.EnableJms; public class SmartUrbanRuralApplication { public static void main(String[] args) { + SpringApplication.run(SmartUrbanRuralApplication.class, args); } diff --git a/src/main/java/com/xkrs/controller/CameraController.java b/src/main/java/com/xkrs/controller/CameraController.java index d831fb6..a9c1151 100644 --- a/src/main/java/com/xkrs/controller/CameraController.java +++ b/src/main/java/com/xkrs/controller/CameraController.java @@ -1,9 +1,12 @@ package com.xkrs.controller; +import com.alibaba.fastjson.JSON; import com.xkrs.dao.CameraDao; import com.xkrs.dao.DeviceManagementDao; import com.xkrs.model.entity.CameraInformation; import com.xkrs.model.entity.DeviceManagement; +import com.xkrs.model.vo.ADD; +import com.xkrs.model.vo.DA; import com.xkrs.service.CameraService; import com.xkrs.service.FireService; import org.springframework.web.bind.annotation.GetMapping; @@ -11,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.io.*; +import java.util.ArrayList; import java.util.List; /** @@ -47,9 +52,44 @@ public class CameraController { } @GetMapping("/SelectDeviceManagement") - public List SelectDeviceManagement() + public String SelectDeviceManagement() { - return cameraService.SelectDevice(); + File file = new File("C:\\Users\\HP\\Desktop\\摄像头设备信息.txt"); + try { + BufferedReader br=new BufferedReader(new FileReader(file)); + String contnetTotal=""; + String s; + while (( s=br.readLine())!=null){ + contnetTotal+=s; + } + br.close(); + System.out.println(contnetTotal); + DA tempBran = JSON.parseObject(contnetTotal, DA.class); + + List pageData = tempBran.getData().getPageData(); + List list1=new ArrayList<>(); + + for (DA.DataDTO.PageDataDTO item: pageData) { + ADD add=new ADD(); + add.deviceName=item.getDeviceName(); + add.deviCevode=item.getDeviceCode(); + add.deviceSn=item.getDeviceSn(); + add.deviceCategory=item.getDeviceCategory(); + add.deviceManufacture=item.getDeviceManufacturer(); + add.deviceType=item.getDeviceType(); + add.deviceModel=item.getDeviceModel(); + add.deviceLp=item.getDeviceIp(); + add.devicePort=item.getDevicePort(); + add.ownerCode=item.getOwnerCode(); + list1.add(add); + } + cameraService.InsertPaging(list1); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return "over"; } } diff --git a/src/main/java/com/xkrs/controller/TestController.java b/src/main/java/com/xkrs/controller/TestController.java index eca1cc3..85099ce 100644 --- a/src/main/java/com/xkrs/controller/TestController.java +++ b/src/main/java/com/xkrs/controller/TestController.java @@ -20,10 +20,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.transaction.Transactional; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.util.*; import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; @@ -134,8 +131,9 @@ public class TestController { * @return */ @GetMapping("/getPaging") - public boolean getPaging( String para) { + public String getPaging( String para) { String forecastWeather = ManagementUtil.getPaging(para); + List> listObjectFir = (List>) JSONArray.parse(forecastWeather); ObjectMapper objectMapper = new ObjectMapper(); JsonNode jsonNode = null; @@ -144,6 +142,7 @@ public class TestController { } catch (JsonProcessingException e) { e.printStackTrace(); } + List item= new ArrayList<>(); String method = jsonNode.get("method").asText(); if("vms.alarm.msg".equals(method)){ JsonNode info = jsonNode.get("info"); @@ -162,7 +161,9 @@ public class TestController { fire.setIsOnline(Integer.valueOf(info.get("isOnline").asText())); fire.setSubSystem(info.get("subSystem").asText()); fire.setDevExt(info.get("devExt").asText()); + item.add(fire); } - return true; + + return "成功!"; } } diff --git a/src/main/java/com/xkrs/dao/DeviceManagementDao.java b/src/main/java/com/xkrs/dao/DeviceManagementDao.java index 430deb7..4b86c64 100644 --- a/src/main/java/com/xkrs/dao/DeviceManagementDao.java +++ b/src/main/java/com/xkrs/dao/DeviceManagementDao.java @@ -2,6 +2,7 @@ package com.xkrs.dao; import com.xkrs.model.entity.CameraInformation; import com.xkrs.model.entity.DeviceManagement; +import com.xkrs.model.vo.ADD; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -17,8 +18,8 @@ public interface DeviceManagementDao extends JpaRepository> selectDeviceManagement(DeviceManagement deviceManagement); + @Query(value = "Insert device_management('device_name','device_code','device_sn','device_category','device_type','device_manufacture','device_model','device_lp','device_port','owner_code') " + + "VALUES('?1','?2','?3','?4','?5','?6','?7','?8','?9','?10');",nativeQuery = true) + String selectDeviceManagement(List deviceManagement); } diff --git a/src/main/java/com/xkrs/model/vo/ADD.java b/src/main/java/com/xkrs/model/vo/ADD.java new file mode 100644 index 0000000..60892a1 --- /dev/null +++ b/src/main/java/com/xkrs/model/vo/ADD.java @@ -0,0 +1,18 @@ +package com.xkrs.model.vo; + +/** + * @Author: XinYi Song + * @Date: 2022/3/4 21:30 + */ +public class ADD { + public String deviceName; + public String deviCevode; + public String deviceSn; + public int deviceCategory; + public int deviceType; + public String deviceManufacture; + public String deviceModel; + public String deviceLp; + public int devicePort; + public String ownerCode; +} diff --git a/src/main/java/com/xkrs/model/vo/DA.java b/src/main/java/com/xkrs/model/vo/DA.java new file mode 100644 index 0000000..b224d2d --- /dev/null +++ b/src/main/java/com/xkrs/model/vo/DA.java @@ -0,0 +1,613 @@ +package com.xkrs.model.vo; + +import java.util.List; + +/** + * @Author: XinYi Song + * @Date: 2022/3/4 21:31 + */ +public class DA { + private Boolean success; + private DataDTO data; + private String code; + private String errMsg; + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public DataDTO getData() { + return data; + } + + public void setData(DataDTO data) { + this.data = data; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getErrMsg() { + return errMsg; + } + + public void setErrMsg(String errMsg) { + this.errMsg = errMsg; + } + + public static class DataDTO { + private List pageData; + private Integer currentPage; + private Integer totalPage; + private Integer pageSize; + private Integer totalRows; + + public List getPageData() { + return pageData; + } + + public void setPageData(List pageData) { + this.pageData = pageData; + } + + public Integer getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Integer currentPage) { + this.currentPage = currentPage; + } + + public Integer getTotalPage() { + return totalPage; + } + + public void setTotalPage(Integer totalPage) { + this.totalPage = totalPage; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getTotalRows() { + return totalRows; + } + + public void setTotalRows(Integer totalRows) { + this.totalRows = totalRows; + } + + public static class PageDataDTO { + + private String deviceName; + + private String deviceCode; + + private String deviceSn; + + private Integer deviceCategory; + + private Integer deviceType; + + private String deviceManufacturer; + + private String protocol; + + private String deviceModel; + + private String deviceIp; + + private Integer devicePort; + + private String ownerCode; + + private String loginType; + + private String loginName; + + private String loginPassword; + + private Boolean isPwdChange; + + private String registServerCode; + + private Integer isOnline; + + private String onlineUpdateTime; + + private Integer onlineUpdateVersion; + + private String offlineReason; + + private Integer isVirtual; + + private String subSystem; + + private DataDTO.PageDataDTO.DevExtDTO devExt; + + private List units; + + private String updateTime; + + private String deviceMac; + + private Integer registProxyPort; + + private String registDeviceCode; + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getDeviceCode() { + return deviceCode; + } + + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode; + } + + public String getDeviceSn() { + return deviceSn; + } + + public void setDeviceSn(String deviceSn) { + this.deviceSn = deviceSn; + } + + public Integer getDeviceCategory() { + return deviceCategory; + } + + public void setDeviceCategory(Integer deviceCategory) { + this.deviceCategory = deviceCategory; + } + + public Integer getDeviceType() { + return deviceType; + } + + public void setDeviceType(Integer deviceType) { + this.deviceType = deviceType; + } + + public String getDeviceManufacturer() { + return deviceManufacturer; + } + + public void setDeviceManufacturer(String deviceManufacturer) { + this.deviceManufacturer = deviceManufacturer; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getDeviceModel() { + return deviceModel; + } + + public void setDeviceModel(String deviceModel) { + this.deviceModel = deviceModel; + } + + public String getDeviceIp() { + return deviceIp; + } + + public void setDeviceIp(String deviceIp) { + this.deviceIp = deviceIp; + } + + public Integer getDevicePort() { + return devicePort; + } + + public void setDevicePort(Integer devicePort) { + this.devicePort = devicePort; + } + + public String getOwnerCode() { + return ownerCode; + } + + public void setOwnerCode(String ownerCode) { + this.ownerCode = ownerCode; + } + + public String getLoginType() { + return loginType; + } + + public void setLoginType(String loginType) { + this.loginType = loginType; + } + + public String getLoginName() { + return loginName; + } + + public void setLoginName(String loginName) { + this.loginName = loginName; + } + + public String getLoginPassword() { + return loginPassword; + } + + public void setLoginPassword(String loginPassword) { + this.loginPassword = loginPassword; + } + + public Boolean getPwdChange() { + return isPwdChange; + } + + public void setPwdChange(Boolean pwdChange) { + isPwdChange = pwdChange; + } + + public String getRegistServerCode() { + return registServerCode; + } + + public void setRegistServerCode(String registServerCode) { + this.registServerCode = registServerCode; + } + + public Integer getIsOnline() { + return isOnline; + } + + public void setIsOnline(Integer isOnline) { + this.isOnline = isOnline; + } + + public String getOnlineUpdateTime() { + return onlineUpdateTime; + } + + public void setOnlineUpdateTime(String onlineUpdateTime) { + this.onlineUpdateTime = onlineUpdateTime; + } + + public Integer getOnlineUpdateVersion() { + return onlineUpdateVersion; + } + + public void setOnlineUpdateVersion(Integer onlineUpdateVersion) { + this.onlineUpdateVersion = onlineUpdateVersion; + } + + public String getOfflineReason() { + return offlineReason; + } + + public void setOfflineReason(String offlineReason) { + this.offlineReason = offlineReason; + } + + public Integer getIsVirtual() { + return isVirtual; + } + + public void setIsVirtual(Integer isVirtual) { + this.isVirtual = isVirtual; + } + + public String getSubSystem() { + return subSystem; + } + + public void setSubSystem(String subSystem) { + this.subSystem = subSystem; + } + + public DevExtDTO getDevExt() { + return devExt; + } + + public void setDevExt(DevExtDTO devExt) { + this.devExt = devExt; + } + + public List getUnits() { + return units; + } + + public void setUnits(List units) { + this.units = units; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getDeviceMac() { + return deviceMac; + } + + public void setDeviceMac(String deviceMac) { + this.deviceMac = deviceMac; + } + + public Integer getRegistProxyPort() { + return registProxyPort; + } + + public void setRegistProxyPort(Integer registProxyPort) { + this.registProxyPort = registProxyPort; + } + + public String getRegistDeviceCode() { + return registDeviceCode; + } + + public void setRegistDeviceCode(String registDeviceCode) { + this.registDeviceCode = registDeviceCode; + } + + public static class DevExtDTO { + + private String pictureServerCode; + + private String videoServerCode; + + public String getPictureServerCode() { + return pictureServerCode; + } + + public void setPictureServerCode(String pictureServerCode) { + this.pictureServerCode = pictureServerCode; + } + + public String getVideoServerCode() { + return videoServerCode; + } + + public void setVideoServerCode(String videoServerCode) { + this.videoServerCode = videoServerCode; + } + } + + + public static class UnitsDTO { + + private Integer unitType; + + private Integer unitSeq; + + private DataDTO.PageDataDTO.UnitsDTO.UnitExtDTO unitExt; + + private List channels; + + public Integer getUnitType() { + return unitType; + } + + public void setUnitType(Integer unitType) { + this.unitType = unitType; + } + + public Integer getUnitSeq() { + return unitSeq; + } + + public void setUnitSeq(Integer unitSeq) { + this.unitSeq = unitSeq; + } + + public UnitExtDTO getUnitExt() { + return unitExt; + } + + public void setUnitExt(UnitExtDTO unitExt) { + this.unitExt = unitExt; + } + + public List getChannels() { + return channels; + } + + public void setChannels(List channels) { + this.channels = channels; + } + + public static class UnitExtDTO { + + private String streamType; + + private Integer zeroChnEncode; + + private Integer assistStream; + + public String getStreamType() { + return streamType; + } + + public void setStreamType(String streamType) { + this.streamType = streamType; + } + + public Integer getZeroChnEncode() { + return zeroChnEncode; + } + + public void setZeroChnEncode(Integer zeroChnEncode) { + this.zeroChnEncode = zeroChnEncode; + } + + public Integer getAssistStream() { + return assistStream; + } + + public void setAssistStream(Integer assistStream) { + this.assistStream = assistStream; + } + } + + + public static class ChannelsDTO { + + private String channelName; + + private Integer channelSeq; + + private String channelType; + + private String cameraType; + + private String capability; + + private String ownerCode; + + private String channelCode; + + private Integer stat; + + private Integer isOnline; + + private String onlineUpdateTime; + + private Integer onlineUpdateVersion; + + private DataDTO.PageDataDTO.UnitsDTO.ChannelsDTO.ChExtDTO chExt; + private Integer isVirtual; + + public String getChannelName() { + return channelName; + } + + public void setChannelName(String channelName) { + this.channelName = channelName; + } + + public Integer getChannelSeq() { + return channelSeq; + } + + public void setChannelSeq(Integer channelSeq) { + this.channelSeq = channelSeq; + } + + public String getChannelType() { + return channelType; + } + + public void setChannelType(String channelType) { + this.channelType = channelType; + } + + public String getCameraType() { + return cameraType; + } + + public void setCameraType(String cameraType) { + this.cameraType = cameraType; + } + + public String getCapability() { + return capability; + } + + public void setCapability(String capability) { + this.capability = capability; + } + + public String getOwnerCode() { + return ownerCode; + } + + public void setOwnerCode(String ownerCode) { + this.ownerCode = ownerCode; + } + + public String getChannelCode() { + return channelCode; + } + + public void setChannelCode(String channelCode) { + this.channelCode = channelCode; + } + + public Integer getStat() { + return stat; + } + + public void setStat(Integer stat) { + this.stat = stat; + } + + public Integer getIsOnline() { + return isOnline; + } + + public void setIsOnline(Integer isOnline) { + this.isOnline = isOnline; + } + + public String getOnlineUpdateTime() { + return onlineUpdateTime; + } + + public void setOnlineUpdateTime(String onlineUpdateTime) { + this.onlineUpdateTime = onlineUpdateTime; + } + + public Integer getOnlineUpdateVersion() { + return onlineUpdateVersion; + } + + public void setOnlineUpdateVersion(Integer onlineUpdateVersion) { + this.onlineUpdateVersion = onlineUpdateVersion; + } + + public ChExtDTO getChExt() { + return chExt; + } + + public void setChExt(ChExtDTO chExt) { + this.chExt = chExt; + } + + public Integer getIsVirtual() { + return isVirtual; + } + + public void setIsVirtual(Integer isVirtual) { + this.isVirtual = isVirtual; + } + + public static class ChExtDTO { + } + } + } + } + } +} diff --git a/src/main/java/com/xkrs/service/CameraService.java b/src/main/java/com/xkrs/service/CameraService.java index 0ad6d88..9987628 100644 --- a/src/main/java/com/xkrs/service/CameraService.java +++ b/src/main/java/com/xkrs/service/CameraService.java @@ -2,6 +2,7 @@ package com.xkrs.service; import com.xkrs.model.entity.CameraInformation; import com.xkrs.model.entity.DeviceManagement; +import com.xkrs.model.vo.ADD; import java.util.List; @@ -29,5 +30,5 @@ public interface CameraService { /** * 添加设备分页信息 */ - boolean InsertPaging(DeviceManagement para); + String InsertPaging(List para); } diff --git a/src/main/java/com/xkrs/service/impl/CameraServiceImpl.java b/src/main/java/com/xkrs/service/impl/CameraServiceImpl.java index 9f5eed1..1602187 100644 --- a/src/main/java/com/xkrs/service/impl/CameraServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/CameraServiceImpl.java @@ -5,6 +5,7 @@ import com.xkrs.dao.DeviceManagementDao; import com.xkrs.dao.FireDao; import com.xkrs.model.entity.CameraInformation; import com.xkrs.model.entity.DeviceManagement; +import com.xkrs.model.vo.ADD; import com.xkrs.service.CameraService; import com.xkrs.util.Query; import org.springframework.stereotype.Service; @@ -58,15 +59,15 @@ public class CameraServiceImpl implements CameraService { } @Override - public boolean InsertPaging(DeviceManagement para) + public String InsertPaging(List para) { try { deviceManagementDao.selectDeviceManagement(para); - return true; + return "成功添加!"; } catch (Exception e){ - return false; + return "失败1"; } } }