dao/src/main/java/com/sandu/ximon/dao/domain/Groups.java
ÎļþÒÑɾ³ý dao/src/main/java/com/sandu/ximon/dao/domain/LCD.java
ÎļþÒÑɾ³ý dao/src/main/java/com/sandu/ximon/dao/domain/LEDProgram.java
@@ -35,7 +35,7 @@ private Integer kind; private String programUel; private String programUrl; private LocalDateTime createTime; dao/src/main/java/com/sandu/ximon/dao/domain/LampPost.java
@@ -28,9 +28,11 @@ private String name; /*æå±å®¢æ·*/ @TableField(updateStrategy = FieldStrategy.IGNORED ) private String belongsClient; /*客æ·id*/ @TableField(updateStrategy = FieldStrategy.IGNORED ) private Long clientId; /*è·¯ç¯ä½ç½®*/ @@ -47,6 +49,7 @@ private String macCode; /*åç»*/ @TableField(updateStrategy = FieldStrategy.IGNORED ) private String lampGroup; /*ç¶æ*/ dao/src/main/java/com/sandu/ximon/dao/domain/Pole.java
@@ -73,6 +73,11 @@ private String deviceCode; /** * ç¯æå¨çº¿ç¶æ */ private String onLineState; /** * ç»å®è®¾å¤æ°é */ private Integer bindingCount; dao/src/main/java/com/sandu/ximon/dao/domain/SOS.java
ÎļþÒÑɾ³ý dao/src/main/java/com/sandu/ximon/dao/domain/SingleLampData.java
@@ -1,58 +1,96 @@ package com.sandu.ximon.dao.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import lombok.Data; import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; import java.time.LocalDateTime; import lombok.Data; /** * åç¯æ°æ® * åç¯çæ§æ°æ®è¡¨ * @TableName single_lamp_data */ @TableName(value ="single_lamp_data") @Data public class SingleLampData implements Serializable { /** * */ @TableId(type = IdType.AUTO) private Long id; /** * */ private Long userId; /*ç¯æåç§°*/ /** * ç¯æåç§° */ private String lampName; /*å¸çµçµå*/ /** * å¸çµçµå */ private Double mainsVoltage; /*å¸çµçµæµ*/ /** * å¸çµçµæµ */ private Double mainsCurrent; /*è®¾å¤æ¸©åº¦*/ /** * è®¾å¤æ¸©åº¦ */ private Double temperature; /*åçå æ°*/ /** * åçå æ° */ private Double powerFactor; /*æååç*/ /** * IMEIå· */ private String imei; /** * ICCIDå· */ private String iccId; /** * æååç */ private Integer activePower; /*æ¬æ¬¡äº®ç¯æ¶é´*/ /** * æ¬æ¬¡äº®ç¯æ¶é´ */ private LocalDateTime lightingTime; /*æ¬æ¬¡ç¨çµé*/ private Double electricityConsumption; /** * æ¬æ¬¡ç¨çµé */ private Double electricityEonsumption; /*æ»ç¨çµé*/ private Double totalAlectricityConsumption; /** * æ»ç¨çµé */ private Double totalElectricityEonsumption; /*ç¯æäº®åº¦*/ /** * ç¯æäº®åº¦ */ private Double lightPoleBrightness; /*æ´æ°æ¶é´*/ /** * æ´æ°æ¶é´ */ private LocalDateTime updateTime; } @TableField(exist = false) private static final long serialVersionUID = 1L; } dao/src/main/java/com/sandu/ximon/dao/mapper/GroupMapper.java
ÎļþÒÑɾ³ý dao/src/main/java/com/sandu/ximon/dao/mapper/PoleBindingMapper.java
@@ -2,10 +2,12 @@ import com.sandu.ximon.dao.domain.PoleBinding; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** * @Entity com.sandu.ximon.dao.domain.PoleBinding */ @Mapper public interface PoleBindingMapper extends BaseMapper<PoleBinding> { } dao/src/main/java/com/sandu/ximon/dao/mapper/SingleLampDataMapper.java
@@ -1,9 +1,17 @@ package com.sandu.ximon.dao.mapper; import com.sandu.common.domain.BaseMapper; import com.sandu.ximon.dao.domain.SingleLampData; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; /** * @Entity com.sandu.ximon.dao.domain.SingleLampData */ @Mapper public interface SingleLampDataMapper extends BaseMapper<SingleLampData> { } dao/src/main/resources/mapper/GroupMapper.xml
ÎļþÒÑɾ³ý dao/src/main/resources/mapper/LEDProgramMapper.xml
@@ -11,6 +11,7 @@ <result property="size" column="size" jdbcType="DOUBLE"/> <result property="pixel" column="pixel" jdbcType="VARCHAR"/> <result property="kind" column="kind" jdbcType="INTEGER"/> <result property="programUrl" column="program_url" jdbcType="VARCHAR"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> </resultMap> dao/src/main/resources/mapper/PoleMapper.xml
@@ -5,27 +5,30 @@ <mapper namespace="com.sandu.ximon.dao.mapper.PoleMapper"> <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.Pole"> <id property="id" column="id" jdbcType="BIGINT"/> <result property="poleCode" column="pole_code" jdbcType="BIGINT"/> <result property="poleName" column="pole_name" jdbcType="VARCHAR"/> <result property="clientId" column="client_id" jdbcType="BIGINT"/> <result property="province" column="province" jdbcType="VARCHAR"/> <result property="city" column="city" jdbcType="VARCHAR"/> <result property="region" column="region" jdbcType="VARCHAR"/> <result property="address" column="address" jdbcType="VARCHAR"/> <result property="lon" column="lon" jdbcType="DECIMAL"/> <result property="lat" column="lat" jdbcType="DECIMAL"/> <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/> <result property="bindingCount" column="binding_count" jdbcType="INTEGER"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <id property="id" column="id" jdbcType="BIGINT"/> <result property="poleCode" column="pole_code" jdbcType="BIGINT"/> <result property="poleName" column="pole_name" jdbcType="VARCHAR"/> <result property="clientId" column="client_id" jdbcType="BIGINT"/> <result property="province" column="province" jdbcType="VARCHAR"/> <result property="city" column="city" jdbcType="VARCHAR"/> <result property="region" column="region" jdbcType="VARCHAR"/> <result property="address" column="address" jdbcType="VARCHAR"/> <result property="lon" column="lon" jdbcType="DECIMAL"/> <result property="lat" column="lat" jdbcType="DECIMAL"/> <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/> <result property="onLineState" column="on_line_state" jdbcType="VARCHAR"/> <result property="bindingCount" column="binding_count" jdbcType="INTEGER"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> </resultMap> <sql id="Base_Column_List"> id,pole_code,pole_name, id ,pole_code,pole_name, client_id,province,city, region,address,lon, lat,device_code,binding_count, lat,device_code, binding_count,on_line_state, create_time,update_time </sql> </mapper> dao/src/main/resources/mapper/SingleLampDataMapper.xml
@@ -5,19 +5,22 @@ <mapper namespace="com.sandu.ximon.dao.mapper.SingleLampDataMapper"> <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.SingleLampData"> <id property="id" column="id" jdbcType="BIGINT"/> <id property="userId" column="user_id" jdbcType="BIGINT"/> <result property="lampName" column="lamp_name" jdbcType="VARCHAR"/> <result property="mainsVoltage" column="mains_voltage" jdbcType="DOUBLE"/> <result property="mainsCurrent" column="mains_current" jdbcType="DOUBLE"/> <result property="temperature" column="temperature" jdbcType="DOUBLE"/> <result property="powerFactor" column="power_factor" jdbcType="DOUBLE"/> <result property="activePower" column="active_power" jdbcType="INTEGER"/> <result property="lightingTime" column="lighting_time" jdbcType="TIMESTAMP"/> <result property="electricityConsumption" column="electricity_eonsumption" jdbcType="DOUBLE"/> <result property="totalAlectricityConsumption" column="total_electricity_eonsumption" jdbcType="DOUBLE"/> <result property="lightPoleBrightness" column="light_pole_brightness" jdbcType="DOUBLE"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <id property="id" column="id" jdbcType="BIGINT"/> <result property="userId" column="user_id" jdbcType="BIGINT"/> <result property="lampName" column="lamp_name" jdbcType="VARCHAR"/> <result property="mainsVoltage" column="mains_voltage" jdbcType="DOUBLE"/> <result property="mainsCurrent" column="mains_current" jdbcType="DOUBLE"/> <result property="temperature" column="temperature" jdbcType="DOUBLE"/> <result property="powerFactor" column="power_factor" jdbcType="DOUBLE"/> <result property="imei" column="imei" jdbcType="VARCHAR"/> <result property="iccId" column="icc_Id" jdbcType="VARCHAR"/> <result property="activePower" column="active_power" jdbcType="INTEGER"/> <result property="lightingTime" column="lighting_time" jdbcType="TIMESTAMP"/> <result property="electricityEonsumption" column="electricity_eonsumption" jdbcType="DOUBLE"/> <result property="totalElectricityEonsumption" column="total_electricity_eonsumption" jdbcType="DOUBLE"/> <result property="lightPoleBrightness" column="light_pole_brightness" jdbcType="DOUBLE"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> </resultMap> </mapper> </mapper> ximon-admin/src/main/java/com/sandu/ximon/admin/controller/GroupController.java
ÎļþÒÑɾ³ý ximon-admin/src/main/java/com/sandu/ximon/admin/controller/LampPostController.java
@@ -81,12 +81,10 @@ LambdaQueryWrapper<LampPost> wrapper = Wrappers.lambdaQuery(LampPost.class); if(receiveParam.getKeyWord()!=null){ wrapper.like(LampPost::getLampId,receiveParam.getKeyWord()) .or(lampPostLambdaQueryWrapper -> { lampPostLambdaQueryWrapper.like(LampPost::getName,receiveParam.getKeyWord()); }); .or(lampPostLambdaQueryWrapper -> lampPostLambdaQueryWrapper.like(LampPost::getName,receiveParam.getKeyWord())); } List<LampPost> lsit= poleService.list(wrapper); return ResponseUtil.success(lsit); List<LampPost> list= poleService.list(wrapper); return ResponseUtil.success(list); } } ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
@@ -55,6 +55,30 @@ return ResponseUtil.success(list); } @GetMapping("listPoleAndState") public ResponseVO<Object> listPoleAndState() { return ResponseUtil.success(poleService.queryStatesAndList()); } /** * 设置ä¸å ç */ @PostMapping("/setMac") public ResponseVO<Object> setMac(@PathVariable Long poleId) { return ResponseUtil.success(poleService.setMac(poleId)); } /** * æ¢å¤ç¯æåºå设置 */ @PostMapping("/poleReset") public ResponseVO<Object> poleReset(@PathVariable Long poleId) { return ResponseUtil.success(poleService.poleReset(poleId)); } /** * ç¯æç»å®è®¾å¤ */ ximon-admin/src/main/java/com/sandu/ximon/admin/param/ReceiveParam.java
@@ -2,6 +2,9 @@ import lombok.Data; /** * éç¨çä¸ä¸ªæ¥æ¶ç±» */ @Data public class ReceiveParam { @@ -12,4 +15,12 @@ private Integer kind; private String keyWord; private Integer lampPostType; private Integer lampPostState; private Integer bindState; private String groupName; } ximon-admin/src/main/java/com/sandu/ximon/admin/service/GroupService.java
ÎļþÒÑɾ³ý ximon-admin/src/main/java/com/sandu/ximon/admin/service/LampPostService.java
@@ -132,6 +132,7 @@ .orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build()); if ("00".equals(rebootFrame.getPayload())) { lampPost.setMacCode(uniqueMac); save= save(lampPost); System.out.println("é坿å"); @@ -202,6 +203,7 @@ for (Long id : Id ) { lampPostMapper.serGroup(group, id); } // return updateBatchById(update); @@ -229,7 +231,7 @@ post.setOnLineState(deviceStatus.getStatus()); } } MacCodes.add(post.getMacCode()); // MacCodes.add(post.getMacCode()); } ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleGroupService.java
@@ -6,7 +6,6 @@ import com.sandu.ximon.admin.param.PoleGroupParam; import com.sandu.ximon.admin.security.SecurityUtils; import com.sandu.ximon.dao.domain.PoleGroup; import com.sandu.ximon.dao.mapper.GroupMapper; import com.sandu.ximon.dao.mapper.PoleGroupMapper; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
@@ -1,14 +1,30 @@ package com.sandu.ximon.admin.service; import com.aliyuncs.iot.model.v20180120.BatchGetDeviceStateResponse; import com.aliyuncs.iot.model.v20180120.QueryDeviceDetailResponse; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.sandu.common.execption.BusinessException; import com.sandu.common.redis.RedisService; import com.sandu.common.service.impl.BaseServiceImpl; import com.sandu.ximon.admin.manager.iot.frame.A1Frame; import com.sandu.ximon.admin.manager.iot.frame.FrameBuilder; import com.sandu.ximon.admin.manager.iot.frame.IRequestFrame; import com.sandu.ximon.admin.manager.iot.frame.inner.request.A1TernaryCodeReqInnerFrame; import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightResetReqInnerFrame; import com.sandu.ximon.admin.manager.iot.frame.inner.request.EmptyRequestInnerFrame; import com.sandu.ximon.admin.manager.iot.frame.inner.response.A1DeviceMacRespInnerFrame; import com.sandu.ximon.admin.manager.iot.frame.inner.response.A1TernaryCodeRespInnerFrame; import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; import com.sandu.ximon.admin.manager.iot.rrpc.dto.WrapResponseCommonFrame; import com.sandu.ximon.admin.manager.iot.rrpc.enums.A1OrderEnum; import com.sandu.ximon.admin.manager.iot.rrpc.enums.A2OrderEnum; import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum; import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService; import com.sandu.ximon.admin.param.PoleBindingParam; import com.sandu.ximon.admin.param.PoleParam; import com.sandu.ximon.admin.redis.LightKey; import com.sandu.ximon.admin.security.SecurityUtils; import com.sandu.ximon.dao.domain.Pole; import com.sandu.ximon.dao.domain.PoleBinding; import com.sandu.ximon.dao.enums.PoleBindingEnums; import com.sandu.ximon.dao.mapper.PoleMapper; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -16,7 +32,9 @@ import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; /** * ç¯æç¸å ³ @@ -79,6 +97,42 @@ return Long.parseLong(sb.toString()); } /** * æ¥è¯¢ç¯æçå¨çº¿ç¶æå¹¶èµå¼ * * @return */ public List<Pole> queryStatesAndList() { // List<LampPost> list = list(Wrappers.lambdaQuery(LampPost.class).eq(LampPost::getClientId, SecurityUtils.getUserId())); //List<Pole> list = list(Wrappers.lambdaQuery(Pole.class)); List<Pole> list = new ArrayList<>(); if (SecurityUtils.getClientId() == null) { list = list(Wrappers.lambdaQuery(Pole.class)); } else { list = list(Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, SecurityUtils.getUserId())); } List<String> MacCodes = new ArrayList<>(); for (Pole post : list) { MacCodes.add(post.getDeviceCode()); } List<BatchGetDeviceStateResponse.DeviceStatus> deviceStatuses = MainBoardInvokeSyncService.getInstance().batchGetDeviceState(MacCodes); for (Pole post : list) { for (BatchGetDeviceStateResponse.DeviceStatus deviceStatus : deviceStatuses) { if (post.getDeviceCode().equals(deviceStatus.getDeviceName())) { post.setOnLineState(deviceStatus.getStatus()); } } // MacCodes.add(post.getDeviceCode()); } return list; } /** * ç¯æç»å®è®¾å¤ * @@ -91,6 +145,136 @@ if (pole == null) { throw new BusinessException("æªæ¾å°è¯¥ç¯æ"); } return poleBindingService.bindPole( poleId, param); return poleBindingService.bindPole(poleId, param); } /** * ç¯ææ¢å¤åºå设置 * * @param id * @return */ public boolean poleReset(Long id) { Pole byId = getById(id); String deviceName = byId.getDeviceCode(); if (byId == null) { throw new BusinessException("æªæ¾å°è¯¥ç¯æ"); } if (deviceName.isEmpty()) { throw new BusinessException("è¯¥ç¯æMca为空"); } IRequestFrame build = FrameBuilder.builderA5() .orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode()) .innerFrame(new A5LightResetReqInnerFrame()) .build(); CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance() .sendRRPC(deviceName, build); System.out.println(commonFrame.toString()); CommonFrame rebootFrame = MainBoardInvokeSyncService.getInstance() .sendRRPC(deviceName, FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame()) .orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build()); if ("00".equals(rebootFrame.getPayload())) { System.out.println("é坿å"); } CommonFrame result = MainBoardInvokeSyncService.getInstance() .sendRRPC(deviceName, FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame()) .orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build()); boolean b = false; if ("00".equals(result.getPayload())) { byId.setDeviceCode(null); b = updateById(byId); System.out.println("é坿å"); } return b; } /** * ç»ç¯ææ³¨åä¸å ç */ public boolean setMac(Long poleId) { Pole pole = getById(poleId); if (pole == null) { throw new BusinessException("æªæ¾å°è¯¥ç¯æ"); } boolean setMac = false; String baseMac = "baseDevice"; A1Frame a1Frame = new A1Frame(A1OrderEnum.REQUEST_READ_DEVICE_UNIQUE_MAC.getCode(), new EmptyRequestInnerFrame()); CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance() .sendRRPC(baseMac, a1Frame); if (commonFrame == null) { throw new BusinessException("读å设å¤å¯ä¸ID失败"); } A1DeviceMacRespInnerFrame a1DeviceMacRespInnerFrame = new A1DeviceMacRespInnerFrame().transformFrame(commonFrame.getPayload()); log.info(commonFrame.toString()); String uniqueMac = a1DeviceMacRespInnerFrame.getMac(); uniqueMac = uniqueMac.toLowerCase(); log.info("å¯ä¸ç {}", uniqueMac); // 2 ä»é¿é注å MainBoardInvokeSyncService.getInstance().registerDevice(uniqueMac); // 3 è·å设å¤è¯¦æ QueryDeviceDetailResponse.Data deviceDetail = MainBoardInvokeSyncService.getInstance().queryDeviceDetail(uniqueMac, null); if (deviceDetail == null) { throw new BusinessException("注å失败"); } log.info(deviceDetail.toString()); // 4 é ç½®Macâ WrapResponseCommonFrame<A1TernaryCodeRespInnerFrame> productKeyResp = MainBoardInvokeSyncService.getInstance() .sendRRPC(baseMac, FrameBuilder.builderA1().innerFrame(new A1TernaryCodeReqInnerFrame(MainBoardInvokeSyncService.getInstance().getProductKey())) .orderType(A1OrderEnum.REQUEST_SET_PRODUCT_KEY.getCode()).build(), A1TernaryCodeRespInnerFrame.class); A1TernaryCodeRespInnerFrame responseInnerFrame = productKeyResp.getResponseInnerFrame(); if (!MainBoardInvokeSyncService.getInstance().getProductKey().equals(responseInnerFrame.getTernaryCode())) { throw new BusinessException("设å¤é ç½®ProductKey失败"); } // 5 é ç½®Macâ¡ WrapResponseCommonFrame<A1TernaryCodeRespInnerFrame> responseCommonFrame = MainBoardInvokeSyncService.getInstance() .sendRRPC(baseMac, FrameBuilder.builderA1().innerFrame(new A1TernaryCodeReqInnerFrame(uniqueMac)) .orderType(A1OrderEnum.REQUEST_SET_DEVICE_NAME.getCode()).build(), A1TernaryCodeRespInnerFrame.class); A1TernaryCodeRespInnerFrame deviceNameFrame = responseCommonFrame.getResponseInnerFrame(); if (!uniqueMac.equals(deviceNameFrame.getTernaryCode())) { throw new BusinessException("设å¤é ç½®å失败"); } // 6 é ç½®Mac⢠WrapResponseCommonFrame<A1TernaryCodeRespInnerFrame> wrapResponseCommonFrame = MainBoardInvokeSyncService.getInstance() .sendRRPC(baseMac, FrameBuilder.builderA1().innerFrame(new A1TernaryCodeReqInnerFrame(deviceDetail.getDeviceSecret())) .orderType(A1OrderEnum.REQUEST_SET_DEVICE_SECRET.getCode()).build(), A1TernaryCodeRespInnerFrame.class); A1TernaryCodeRespInnerFrame deviceSecretFrame = wrapResponseCommonFrame.getResponseInnerFrame(); if (!deviceDetail.getDeviceSecret().equals(deviceSecretFrame.getTernaryCode())) { throw new BusinessException("设å¤å¯é¥å¤±è´¥"); } // 7 éå¯è®¾å¤ å¹¶ä½¿ç¨æ°çMac CommonFrame rebootFrame = MainBoardInvokeSyncService.getInstance() .sendRRPC(baseMac, FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame()) .orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build()); if ("00".equals(rebootFrame.getPayload())) { pole.setDeviceCode(uniqueMac); setMac = updateById(pole); System.out.println("é坿å"); } return setMac; } }