| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * è·¯ç¯å¤æ³¨è¡¨ |
| | | * @TableName light_remark |
| | | */ |
| | | @TableName(value ="light_remark") |
| | | @Data |
| | | public class LightRemark implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 设å¤è¯å«ç |
| | | */ |
| | | private String deviceMac; |
| | | |
| | | /** |
| | | * 夿³¨ä¿¡æ¯ |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private LocalDateTime updateTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * ç¯ä¸æ¥æ°æ®è¡¨ |
| | | * @TableName light_report_data |
| | | */ |
| | | @TableName(value ="light_report_data") |
| | | @Data |
| | | public class LightReportData implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | private Long lightReportDataId; |
| | | |
| | | /** |
| | | * 设å¤mac |
| | | */ |
| | | private String deviceMac; |
| | | |
| | | /** |
| | | * å¸çµçµå |
| | | */ |
| | | private Double voltage; |
| | | |
| | | /** |
| | | * å¸çµçµæµ |
| | | */ |
| | | private Double electricCurrent; |
| | | |
| | | /** |
| | | * è®¾å¤æ¸©åº¦ |
| | | */ |
| | | private Double deviceTemperature; |
| | | |
| | | /** |
| | | * åçå ç´ |
| | | */ |
| | | private Double powerFactor; |
| | | |
| | | /** |
| | | * æååç |
| | | */ |
| | | private Double activePower; |
| | | |
| | | /** |
| | | * æ ååç |
| | | */ |
| | | private Double reactivePower; |
| | | |
| | | /** |
| | | * 亮度ç¾åæ¯ï¼0-100 |
| | | */ |
| | | private Integer lightPercent; |
| | | |
| | | /** |
| | | * æè¿ä¸æ¬¡äº®ç¯æ¶é´ |
| | | */ |
| | | private Long recentlyLightSec; |
| | | |
| | | /** |
| | | * æ»äº®ç¯æ¶é´ |
| | | */ |
| | | private Long totalLightSec; |
| | | |
| | | /** |
| | | * æè¿ä¸æ¬¡ç¨çµé |
| | | */ |
| | | private Double recentlyUsingPower; |
| | | |
| | | /** |
| | | * æ»ç¨çµé |
| | | */ |
| | | private Double totalUsingPower; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private LocalDateTime updateTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * ç¯æè¡¨ |
| | | * @TableName pole |
| | | */ |
| | | @TableName(value ="pole") |
| | | @Data |
| | | public class Pole implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * ç¯æç¼å· |
| | | */ |
| | | private Long poleCode; |
| | | |
| | | /** |
| | | * ç¯æåç§° |
| | | */ |
| | | private String poleName; |
| | | |
| | | /** |
| | | * 客æ·id |
| | | */ |
| | | private Long clientId; |
| | | |
| | | /** |
| | | * ç |
| | | */ |
| | | private String province; |
| | | |
| | | /** |
| | | * å¸ |
| | | */ |
| | | private String city; |
| | | |
| | | /** |
| | | * åº |
| | | */ |
| | | private String region; |
| | | |
| | | /** |
| | | * 详ç»å°å |
| | | */ |
| | | private String address; |
| | | |
| | | /** |
| | | * ç»åº¦ |
| | | */ |
| | | private BigDecimal lon; |
| | | |
| | | /** |
| | | * 纬度 |
| | | */ |
| | | private BigDecimal lat; |
| | | |
| | | /** |
| | | * æºå¨ç |
| | | */ |
| | | private String deviceCode; |
| | | |
| | | /** |
| | | * ç»å®è®¾å¤æ°é |
| | | */ |
| | | private Integer bindingCount; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private LocalDateTime updateTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * åç»è¡¨ |
| | | * @TableName pole_group |
| | | */ |
| | | @TableName(value ="pole_group") |
| | | @Data |
| | | public class PoleGroup implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | private Long groupId; |
| | | |
| | | /** |
| | | * 客æ·id |
| | | */ |
| | | private Long clientId; |
| | | |
| | | /** |
| | | * åç»åç§° |
| | | */ |
| | | private String groupName; |
| | | |
| | | /** |
| | | * ç¯ææ°é |
| | | */ |
| | | private Integer poleCount; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private LocalDateTime updateTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * ç¯æåç»å
³ç³»è¡¨ |
| | | * @TableName pole_group_relation |
| | | */ |
| | | @TableName(value ="pole_group_relation") |
| | | @Data |
| | | public class PoleGroupRelation implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * ç¯æid |
| | | */ |
| | | private Long poleId; |
| | | |
| | | /** |
| | | * åç»id |
| | | */ |
| | | private Long poleGroupId; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private LocalDateTime updateTime; |
| | | |
| | | @TableField(exist = false) |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import com.sandu.ximon.dao.domain.LightRemark; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Entity com.sandu.ximon.dao.domain.LightRemark |
| | | */ |
| | | @Mapper |
| | | public interface LightRemarkMapper extends BaseMapper<LightRemark> { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import com.sandu.ximon.dao.domain.LightReportData; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Entity com.sandu.ximon.dao.domain.LightReportData |
| | | */ |
| | | @Mapper |
| | | public interface LightReportDataMapper extends BaseMapper<LightReportData> { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import com.sandu.ximon.dao.domain.PoleGroup; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Entity com.sandu.ximon.dao.domain.PoleGroup |
| | | */ |
| | | @Mapper |
| | | public interface PoleGroupMapper extends BaseMapper<PoleGroup> { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import com.sandu.ximon.dao.domain.PoleGroupRelation; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Entity com.sandu.ximon.dao.domain.PoleGroupRelation |
| | | */ |
| | | @Mapper |
| | | public interface PoleGroupRelationMapper extends BaseMapper<PoleGroupRelation> { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @Entity com.sandu.ximon.dao.domain.Pole |
| | | */ |
| | | @Mapper |
| | | public interface PoleMapper extends BaseMapper<Pole> { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.sandu.ximon.dao.mapper.LightRemarkMapper"> |
| | | |
| | | <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightRemark"> |
| | | <id property="id" column="id" jdbcType="BIGINT"/> |
| | | <result property="deviceMac" column="device_mac" jdbcType="VARCHAR"/> |
| | | <result property="remark" column="remark" jdbcType="VARCHAR"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | id,device_mac,remark, |
| | | create_time,update_time |
| | | </sql> |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.sandu.ximon.dao.mapper.LightReportDataMapper"> |
| | | |
| | | <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightReportData"> |
| | | <id property="lightReportDataId" column="light_report_data_id" jdbcType="BIGINT"/> |
| | | <result property="deviceMac" column="device_mac" jdbcType="VARCHAR"/> |
| | | <result property="voltage" column="voltage" jdbcType="FLOAT"/> |
| | | <result property="electricCurrent" column="electric_current" jdbcType="FLOAT"/> |
| | | <result property="deviceTemperature" column="device_temperature" jdbcType="FLOAT"/> |
| | | <result property="powerFactor" column="power_factor" jdbcType="FLOAT"/> |
| | | <result property="activePower" column="active_power" jdbcType="FLOAT"/> |
| | | <result property="reactivePower" column="reactive_power" jdbcType="FLOAT"/> |
| | | <result property="lightPercent" column="light_percent" jdbcType="INTEGER"/> |
| | | <result property="recentlyLightSec" column="recently_light_sec" jdbcType="BIGINT"/> |
| | | <result property="totalLightSec" column="total_light_sec" jdbcType="BIGINT"/> |
| | | <result property="recentlyUsingPower" column="recently_using_power" jdbcType="DOUBLE"/> |
| | | <result property="totalUsingPower" column="total_using_power" jdbcType="DOUBLE"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | light_report_data_id,device_mac,voltage, |
| | | electric_current,device_temperature,power_factor, |
| | | active_power,reactive_power,light_percent, |
| | | recently_light_sec,total_light_sec,recently_using_power, |
| | | total_using_power,create_time,update_time |
| | | </sql> |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.sandu.ximon.dao.mapper.PoleGroupMapper"> |
| | | |
| | | <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.PoleGroup"> |
| | | <id property="groupId" column="group_id" jdbcType="BIGINT"/> |
| | | <result property="clientId" column="client_id" jdbcType="BIGINT"/> |
| | | <result property="groupName" column="group_name" jdbcType="VARCHAR"/> |
| | | <result property="poleCount" column="pole_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"> |
| | | group_id,client_id,group_name, |
| | | pole_count,create_time,update_time |
| | | </sql> |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.sandu.ximon.dao.mapper.PoleGroupRelationMapper"> |
| | | |
| | | <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.PoleGroupRelation"> |
| | | <id property="id" column="id" jdbcType="BIGINT"/> |
| | | <result property="poleId" column="pole_id" jdbcType="BIGINT"/> |
| | | <result property="poleGroupId" column="pole_group_id" jdbcType="BIGINT"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | id,pole_id,pole_group_id, |
| | | create_time,update_time |
| | | </sql> |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <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"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | id,pole_code,pole_name, |
| | | client_id,province,city, |
| | | region,address,lon, |
| | | lat,device_code,binding_count, |
| | | create_time,update_time |
| | | </sql> |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.config; |
| | | |
| | | import com.sandu.common.config.BaseRedisConfig; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/13 11:54 |
| | | * å¯å¨redis |
| | | */ |
| | | @Configuration |
| | | public class RedisConfig extends BaseRedisConfig { |
| | | } |
| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import cn.hutool.core.util.RadixUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.security.annotation.AnonymousAccess; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.param.GroupParam; |
| | | import com.sandu.ximon.admin.param.LampPostParam; |
| | |
| | | @RequestMapping("/v1/LampPost") |
| | | public class LampPostController { |
| | | |
| | | private final LampPostService lampPostService; |
| | | private final LampPostService poleService; |
| | | |
| | | @GetMapping("/add") |
| | | public ResponseVO<Object> addLampPost(@RequestBody LampPostParam lampPostParam){ |
| | | return ResponseUtil.success( lampPostService.addLamp(lampPostParam)); |
| | | return ResponseUtil.success( poleService.addLamp(lampPostParam)); |
| | | } |
| | | |
| | | @GetMapping("/update/{id}") |
| | | public ResponseVO<Object> updateLampPost(@PathVariable Long id, @RequestBody LampPostParam lampPostParam){ |
| | | return ResponseUtil.success( lampPostService.updateLamp(id,lampPostParam)); |
| | | return ResponseUtil.success( poleService.updateLamp(id,lampPostParam)); |
| | | } |
| | | |
| | | @GetMapping("/delete/{id}") |
| | | public ResponseVO<Object> deleteLampPost(@PathVariable Long id){ |
| | | return ResponseUtil.success(lampPostService.deleteLampPost(id)); |
| | | return ResponseUtil.success(poleService.deleteLampPost(id)); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/setGroup") |
| | | public ResponseVO<Object> setGroup(@RequestBody GroupParam groupParam){ |
| | | lampPostService.setGroup(groupParam.getGroup(), groupParam.getId()); |
| | | poleService.setGroup(groupParam.getGroup(), groupParam.getId()); |
| | | return ResponseUtil.success("åç»è®¾ç½®æå"); |
| | | } |
| | | |
| | |
| | | */ |
| | | @PostMapping("/list") |
| | | public ResponseVO<Object> listLamp(){ |
| | | return ResponseUtil.success(lampPostService.queryStates()); |
| | | return ResponseUtil.success(poleService.queryStates()); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @GetMapping("/lightReset/{id}") |
| | | public ResponseVO<Object> LightReset(@PathVariable Long id){ |
| | | return ResponseUtil.success(lampPostService.LightReset(id)); |
| | | return ResponseUtil.success(poleService.LightReset(id)); |
| | | } |
| | | |
| | | |
| | |
| | | lampPostLambdaQueryWrapper.like(LampPost::getName,receiveParam.getKeyWord()); |
| | | }); |
| | | } |
| | | List<LampPost> lsit=lampPostService.list(wrapper); |
| | | List<LampPost> lsit= poleService.list(wrapper); |
| | | return ResponseUtil.success(lsit); |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.param.GroupParam; |
| | | import com.sandu.ximon.admin.param.LampPostParam; |
| | | import com.sandu.ximon.admin.param.ReceiveParam; |
| | | import com.sandu.ximon.admin.service.LampPostService; |
| | | import com.sandu.ximon.dao.domain.LampPost; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ç¯ææ¨¡å以å设置åç»å°å¯¹åºç¯æ |
| | | * @author chenjiantian |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/v1/pole") |
| | | public class PoleController { |
| | | |
| | | private final LampPostService poleService; |
| | | |
| | | @GetMapping("/add") |
| | | public ResponseVO<Object> addLampPost(@RequestBody LampPostParam lampPostParam){ |
| | | return ResponseUtil.success( poleService.addLamp(lampPostParam)); |
| | | } |
| | | |
| | | @GetMapping("/update/{id}") |
| | | public ResponseVO<Object> updateLampPost(@PathVariable Long id, @RequestBody LampPostParam lampPostParam){ |
| | | return ResponseUtil.success( poleService.updateLamp(id,lampPostParam)); |
| | | } |
| | | |
| | | @GetMapping("/delete/{id}") |
| | | public ResponseVO<Object> deleteLampPost(@PathVariable Long id){ |
| | | return ResponseUtil.success(poleService.deleteLampPost(id)); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/setGroup") |
| | | public ResponseVO<Object> setGroup(@RequestBody GroupParam groupParam){ |
| | | poleService.setGroup(groupParam.getGroup(), groupParam.getId()); |
| | | return ResponseUtil.success("åç»è®¾ç½®æå"); |
| | | } |
| | | |
| | | // @AnonymousAccess |
| | | //@PostMapping("/list") |
| | | /* public ResponseVO<Object> listLamp(){ |
| | | //List<LampPost> list = lampPostService.list(); |
| | | return ResponseUtil.success(lampPostService.list()); |
| | | //return ResponseUtil.success(lampPostService.listLamp()); |
| | | }*/ |
| | | |
| | | /** |
| | | * æ¥è¯¢ç¯æå表并æºå¸¦å¨çº¿ç¶æ |
| | | * @return |
| | | */ |
| | | @PostMapping("/list") |
| | | public ResponseVO<Object> listLamp(){ |
| | | return ResponseUtil.success(poleService.queryStates()); |
| | | } |
| | | |
| | | /** |
| | | * æ¢å¤åºå设置 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/lightReset/{id}") |
| | | public ResponseVO<Object> LightReset(@PathVariable Long id){ |
| | | return ResponseUtil.success(poleService.LightReset(id)); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/lsitLike") |
| | | public ResponseVO<Object> list( @RequestBody ReceiveParam receiveParam){ |
| | | 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()); |
| | | }); |
| | | } |
| | | List<LampPost> lsit= poleService.list(wrapper); |
| | | return ResponseUtil.success(lsit); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.param.PoleGroupParam; |
| | | import com.sandu.ximon.admin.service.PoleGroupService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * åç»å表åè½ |
| | | * |
| | | * @author chenjiantian |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/v1/pole/group") |
| | | public class PoleGroupController { |
| | | |
| | | private final PoleGroupService poleGroupService; |
| | | |
| | | @GetMapping("/add") |
| | | public ResponseVO<Object> addGroup(@RequestBody @Validated PoleGroupParam param) { |
| | | return ResponseUtil.success(poleGroupService.addGroup(param)); |
| | | } |
| | | |
| | | @PostMapping("/update/{groupId}") |
| | | public ResponseVO<Object> updateGroup(@PathVariable Long groupId, @RequestBody @Validated PoleGroupParam param) { |
| | | return ResponseUtil.success(poleGroupService.updateGroup(groupId, param)); |
| | | } |
| | | |
| | | @GetMapping("/delete/{groupId}") |
| | | public ResponseVO<Object> delGroup(@PathVariable Long groupId) { |
| | | return ResponseUtil.success(poleGroupService.deleteGroup(groupId)); |
| | | } |
| | | |
| | | @PostMapping("/list") |
| | | public ResponseVO<Object> listGroup() { |
| | | return ResponseUtil.success(poleGroupService.groupList()); |
| | | } |
| | | } |
| | |
| | | package com.sandu.ximon.admin.manager.iot.amqp; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.sandu.ximon.admin.manager.iot.amqp.processor.LightDataProcessor; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.*; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonReportMessage; |
| | |
| | | log.info(frame.toString()); |
| | | if (frame.getOrderType().equals(A5OrderEnum.RESPONSE_LIGHT_DATA.getCode())) { |
| | | // åç¯æ°æ®ä¸æ¥å¤ç |
| | | lightDataReportAnalysis(productKey, deviceName, frame); |
| | | LightDataProcessor.getInstance().process(productKey,deviceName,frame); |
| | | } else if (frame.getOrderType().equals(A5OrderEnum.RESPONSE_C3_DATA.getCode())) { |
| | | // C3å
çµæ¡©ä¸æ¥å¤ç |
| | | c3ChargingReportAnalysis(productKey, deviceName, frame); |
| | |
| | | A5AtmosphereHeartbeatReportInnerFrame transformFrame = new A5AtmosphereHeartbeatReportInnerFrame().transformFrame(frame.getPayload()); |
| | | log.info("大æ°å¿è·³ä¸æ¥"); |
| | | log.info(transformFrame.toString()); |
| | | } |
| | | |
| | | private void lightDataReportAnalysis(String productKey, String deviceName, CommonFrame frame) { |
| | | String functionCode = frame.getPayload().substring(2, 4); |
| | | if (A5LightReportEnum.HeartBeat_Data.getCode().equals(functionCode)) { |
| | | // log.info("å¿è·³ç¸åº"); |
| | | A5LightHeartbeatReportInnerFrame heartbeatReportInnerFrame = new A5LightHeartbeatReportInnerFrame().transformFrame(frame.getPayload()); |
| | | // log.info(heartbeatReportInnerFrame.toString()); |
| | | } else if (A5LightReportEnum.Time_Synchronized.getCode().equals(functionCode)) { |
| | | // log.info("è¯·æ±æ¶é´åæ¥"); |
| | | A5LightTimeSyncReportInnerFrame syncRespInnerFrame = new A5LightTimeSyncReportInnerFrame().transformFrame(frame.getPayload()); |
| | | // log.info(syncRespInnerFrame.toString()); |
| | | } else if (A5LightReportEnum.Error_Code.getCode().equals(functionCode)) { |
| | | // log.info("æ
éç 䏿¥"); |
| | | A5LightErrorCodeReportInnerFrame codeRespInnerFrame = new A5LightErrorCodeReportInnerFrame().transformFrame(frame.getPayload()); |
| | | // log.info(codeRespInnerFrame.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | @AllArgsConstructor |
| | | public class InitAmqpListener { |
| | | |
| | | /* private final MqttMainBoardConfig mqttMainBoardConfig; |
| | | private final MqttMainBoardConfig mqttMainBoardConfig; |
| | | |
| | | @PostConstruct |
| | | public void initListener() throws Exception { |
| | | new AmqpClient( |
| | | mqttMainBoardConfig |
| | | ).execute(); |
| | | }*/ |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.amqp.processor; |
| | | |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/13 11:57 |
| | | */ |
| | | public interface IMessageProcessor { |
| | | |
| | | void process(String productKey, String deviceName, CommonFrame frame); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.manager.iot.amqp.processor; |
| | | |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightErrorCodeReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightTimeSyncReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5LightReportEnum; |
| | | import com.sandu.ximon.admin.service.LightReportDataService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/13 11:58 |
| | | * åç¯æ°æ®ä¸æ¥å¤ç |
| | | */ |
| | | @Slf4j |
| | | public class LightDataProcessor implements IMessageProcessor { |
| | | |
| | | private LightDataProcessor() { |
| | | } |
| | | |
| | | public static LightDataProcessor getInstance() { |
| | | return LightDataProcessorHolder.INSTANCE; |
| | | } |
| | | |
| | | private static class LightDataProcessorHolder { |
| | | |
| | | private static final LightDataProcessor INSTANCE = new LightDataProcessor(); |
| | | } |
| | | |
| | | @Override |
| | | public void process(String productKey, String deviceName, CommonFrame frame) { |
| | | String functionCode = frame.getPayload().substring(2, 4); |
| | | if (A5LightReportEnum.HeartBeat_Data.getCode().equals(functionCode)) { |
| | | log.info("å¿è·³ç¸åº"); |
| | | A5LightHeartbeatReportInnerFrame heartbeatReportInnerFrame = new A5LightHeartbeatReportInnerFrame().transformFrame(frame.getPayload()); |
| | | log.info(heartbeatReportInnerFrame.toString()); |
| | | |
| | | SpringContextHolder.getBean(LightReportDataService.class).saveReportData(deviceName,heartbeatReportInnerFrame.getHeartBeatDataPackage()); |
| | | |
| | | // SpringContextHolder.getBean(LightService.class).saveLight(deviceName,heartbeatReportInnerFrame.getHeartBeatDataPackage()); |
| | | |
| | | } else if (A5LightReportEnum.Time_Synchronized.getCode().equals(functionCode)) { |
| | | // log.info("è¯·æ±æ¶é´åæ¥"); |
| | | A5LightTimeSyncReportInnerFrame syncRespInnerFrame = new A5LightTimeSyncReportInnerFrame().transformFrame(frame.getPayload()); |
| | | // log.info(syncRespInnerFrame.toString()); |
| | | } else if (A5LightReportEnum.Error_Code.getCode().equals(functionCode)) { |
| | | // log.info("æ
éç 䏿¥"); |
| | | A5LightErrorCodeReportInnerFrame codeRespInnerFrame = new A5LightErrorCodeReportInnerFrame().transformFrame(frame.getPayload()); |
| | | // log.info(codeRespInnerFrame.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.sandu.ximon.admin.manager.iot.frame.inner.report; |
| | | |
| | | import cn.hutool.core.util.HexUtil; |
| | | import cn.hutool.core.util.NumberUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.BaseResponseInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.IResponseInnerFrame; |
| | |
| | | @Data |
| | | public static class HeartBeatDataPackage implements IResponseInnerFrame<HeartBeatDataPackage> { |
| | | // å¹´RTC 1 |
| | | private String year; |
| | | private Integer year; |
| | | // æRTC 1 |
| | | private String month; |
| | | private Integer month; |
| | | // æ¥RTC 1 |
| | | private String day; |
| | | private Integer day; |
| | | // æ¶RTC 1 |
| | | private String hour; |
| | | private Integer hour; |
| | | // åRTC 1 |
| | | private String min; |
| | | private Integer min; |
| | | // ç§RTC 1 |
| | | private String sec; |
| | | private Integer sec; |
| | | // è®¾å¤æ¸©åº¦ 2 1åèæ´æ°1åèå°æ° |
| | | private String deviceTemperature; |
| | | private Double deviceTemperature; |
| | | // 亮度ç¾åæ¯ 1 |
| | | private String lightPercent; |
| | | private Integer lightPercent; |
| | | // çµç½çµå 2 1åèæ´æ°1åèå°æ° |
| | | private String gridVol; |
| | | private Double voltage; |
| | | // çµç½çµæµ 2 1åèæ´æ°1åèå°æ° |
| | | private String gridCur; |
| | | private Double electricCurrent; |
| | | // 赫å
¹ 2 1åèæ´æ°1åèå°æ° |
| | | private String hertz; |
| | | private Double hertz; |
| | | // åçå ç´ 2 1åèæ´æ°1åèå°æ° |
| | | private String powerFactor; |
| | | private Double powerFactor; |
| | | // æååç 2 1åèæ´æ°1åèå°æ° |
| | | private String activePower; |
| | | private Double activePower; |
| | | // æ ååç 2 1åèæ´æ°1åèå°æ° |
| | | private String reactivePower; |
| | | private Double reactivePower; |
| | | // æè¿ä¸æ¬¡äº®ç¯æ¶é´ 4 ç§ |
| | | private String recentlyLightSec; |
| | | private Long recentlyLightSec; |
| | | // ç´¯è®¡äº®ç¯æ¶é´ 4 |
| | | private String totalLightTime; |
| | | private Long totalLightSec; |
| | | // æè¿ä¸æ¬¡ç¨çµçµé 4 |
| | | private String recentlyUsingPower; |
| | | private Double recentlyUsingPower; |
| | | // 累计ç¨çµçµé 4 |
| | | private String totalUsingPower; |
| | | private Double totalUsingPower; |
| | | // ä¿ç 11 |
| | | private String retain; |
| | | // å帧 |
| | |
| | | @Override |
| | | public HeartBeatDataPackage transformFrame(String hex) { |
| | | this.originFrame = hex; |
| | | this.year = hex.substring(0, 2); |
| | | this.month = hex.substring(2, 4); |
| | | this.day = hex.substring(4, 6); |
| | | this.hour = hex.substring(6, 8); |
| | | this.min = hex.substring(8, 10); |
| | | this.sec = hex.substring(10, 12); |
| | | this.year = HexUtil.hexToInt(hex.substring(0, 2)); |
| | | this.month = HexUtil.hexToInt(hex.substring(2, 4)); |
| | | this.day = HexUtil.hexToInt(hex.substring(4, 6)); |
| | | this.hour = HexUtil.hexToInt(hex.substring(6, 8)); |
| | | this.min = HexUtil.hexToInt(hex.substring(8, 10)); |
| | | this.sec = HexUtil.hexToInt(hex.substring(10, 12)); |
| | | |
| | | this.deviceTemperature = hex.substring(12, 16); |
| | | this.lightPercent = hex.substring(16, 18); |
| | | this.gridVol = hex.substring(18, 22); |
| | | this.gridCur = hex.substring(22, 26); |
| | | this.hertz = hex.substring(26, 30); |
| | | this.powerFactor = hex.substring(30, 34); |
| | | this.activePower = hex.substring(34, 38); |
| | | this.reactivePower = hex.substring(38, 42); |
| | | this.recentlyLightSec = hex.substring(42, 50); |
| | | this.totalLightTime = hex.substring(50, 58); |
| | | this.recentlyUsingPower = hex.substring(58, 66); |
| | | this.totalUsingPower = hex.substring(66, 74); |
| | | this.deviceTemperature = NumberUtil.round(HexUtil.hexToInt(hex.substring(12, 16)) * 0.01, 2).doubleValue(); |
| | | this.lightPercent = HexUtil.hexToInt(hex.substring(16, 18)); |
| | | this.voltage = NumberUtil.round(HexUtil.hexToInt(hex.substring(18, 22)) * 0.1, 1).doubleValue(); |
| | | this.electricCurrent = NumberUtil.round(HexUtil.hexToInt(hex.substring(22, 26)) * 0.001, 3).doubleValue(); |
| | | this.hertz = NumberUtil.round(HexUtil.hexToInt(hex.substring(26, 30)) * 0.01, 2).doubleValue(); |
| | | this.powerFactor = NumberUtil.round(HexUtil.hexToInt(hex.substring(30, 34)) * 0.001, 3).doubleValue(); |
| | | this.activePower = NumberUtil.round(HexUtil.hexToInt(hex.substring(34, 38)) * 0.01, 2).doubleValue(); |
| | | this.reactivePower = NumberUtil.round(HexUtil.hexToInt(hex.substring(38, 42)) * 0.01, 2).doubleValue(); |
| | | this.recentlyLightSec = HexUtil.hexToLong(hex.substring(42, 50)); |
| | | this.totalLightSec = HexUtil.hexToLong(hex.substring(50, 58)); |
| | | this.recentlyUsingPower = NumberUtil.round(HexUtil.hexToInt(hex.substring(58, 66)) * (double) 0.001, 3).doubleValue(); |
| | | this.totalUsingPower = NumberUtil.round(HexUtil.hexToInt(hex.substring(66, 74)) * (double) 0.001, 3).doubleValue(); |
| | | this.retain = hex.substring(74, 96); |
| | | return this; |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(HexUtil.hexToLong("F64D020F")); |
| | | System.out.println(5 * (float) 0.001); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.param; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/13 18:22 |
| | | */ |
| | | @Data |
| | | public class PoleGroupParam { |
| | | |
| | | @NotEmpty(message = "åç»åç§°ä¸è½ä¸ºç©º") |
| | | private String groupName; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.param; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/13 18:22 |
| | | */ |
| | | @Data |
| | | public class PoleGroupRelationParam { |
| | | |
| | | @NotEmpty(message = "ç¯æidä¸è½ä¸ºç©º") |
| | | private List<Long> poleId; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.param; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | */ |
| | | @Data |
| | | public class PoleParam { |
| | | |
| | | @NotEmpty(message = "ç¯æåç§°ä¸è½ä¸ºç©º") |
| | | private String poleName; |
| | | |
| | | /** |
| | | * 客æ·id |
| | | */ |
| | | @NotNull(message = "客æ·idä¸è½ä¸ºç©º") |
| | | private Long clientId; |
| | | |
| | | /** |
| | | * ç |
| | | */ |
| | | @NotEmpty(message = "çä¸è½ä¸ºç©º") |
| | | private String province; |
| | | |
| | | /** |
| | | * å¸ |
| | | */ |
| | | @NotEmpty(message = "å¸ä¸è½ä¸ºç©º") |
| | | private String city; |
| | | |
| | | /** |
| | | * åº |
| | | */ |
| | | private String region; |
| | | |
| | | /** |
| | | * 详ç»å°å |
| | | */ |
| | | @NotEmpty(message = "详ç»å°åä¸è½ä¸ºç©º") |
| | | private String address; |
| | | |
| | | /** |
| | | * ç»åº¦ |
| | | */ |
| | | @NotNull(message = "ç»åº¦ä¸è½ä¸ºç©º") |
| | | private BigDecimal lon; |
| | | |
| | | /** |
| | | * 纬度 |
| | | */ |
| | | @NotNull(message = "纬度ä¸è½ä¸ºç©º") |
| | | private BigDecimal lat; |
| | | |
| | | |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.redis; |
| | | |
| | | import com.sandu.common.redis.BasePrefix; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/9/3 16:40 |
| | | * ç¯ç¸å
³çkey |
| | | */ |
| | | public class LightKey extends BasePrefix { |
| | | public LightKey(int expireSeconds, String prefix) { |
| | | super(expireSeconds, prefix); |
| | | } |
| | | |
| | | @Override |
| | | public String getModelName() { |
| | | return "Light"; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * åç¯ä¸æ¥çmacï¼å¦ææè¯´æè¯¥ä¸æ¥çåç¯ä»¥åå·²ç»ä¸æ¥è¿ |
| | | */ |
| | | public static LightKey REPORT_MAC = new LightKey(0, "ReportMac"); |
| | | |
| | | public static LightKey POLE_SN = new LightKey(300, "PoleSn"); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.dao.domain.LightRemark; |
| | | import com.sandu.ximon.dao.mapper.LightRemarkMapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/13 16:00 |
| | | * ç¯è®¾å¤service |
| | | */ |
| | | @Service |
| | | public class LightRemarkService extends BaseServiceImpl<LightRemarkMapper, LightRemark> { |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightHeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.dao.domain.LightReportData; |
| | | import com.sandu.ximon.dao.mapper.LightReportDataMapper; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | | * @date 2021/12/13 16:00 |
| | | * ç¯ä¸æ¥æ°æ® service |
| | | */ |
| | | @Service |
| | | public class LightReportDataService extends BaseServiceImpl<LightReportDataMapper, LightReportData> { |
| | | |
| | | /** |
| | | * ä¿å䏿¥çç¯å¿è·³æ°æ® |
| | | * |
| | | * @return æ¯å¦æå |
| | | */ |
| | | public boolean saveReportData(String deviceName, A5LightHeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage) { |
| | | |
| | | LightReportData lightReportData = new LightReportData(); |
| | | BeanUtils.copyProperties(heartBeatDataPackage, lightReportData); |
| | | lightReportData.setDeviceMac(deviceName); |
| | | |
| | | return save(lightReportData); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | 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.domain.PoleGroupRelation; |
| | | import com.sandu.ximon.dao.mapper.GroupMapper; |
| | | import com.sandu.ximon.dao.mapper.PoleGroupMapper; |
| | | import com.sandu.ximon.dao.mapper.PoleGroupRelationMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * åç»æä½ |
| | | * |
| | | * @author chenjiantian |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class PoleGroupRelationService extends BaseServiceImpl<PoleGroupRelationMapper, PoleGroupRelation> { |
| | | |
| | | /** |
| | | * ç»å®ç¯æ |
| | | */ |
| | | public boolean saveBinding(Long groupId,List<Long> poleIdList) { |
| | | remove(Wrappers.lambdaQuery(PoleGroupRelation.class).eq(PoleGroupRelation::getPoleGroupId,groupId)); |
| | | List<PoleGroupRelation> batchList = new ArrayList<>(); |
| | | for (Long poleId : poleIdList) { |
| | | PoleGroupRelation poleGroupRelation = new PoleGroupRelation(); |
| | | poleGroupRelation.setPoleGroupId(groupId); |
| | | poleGroupRelation.setPoleId(poleId); |
| | | batchList.add(poleGroupRelation); |
| | | } |
| | | return saveBatch(batchList); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | 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; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * åç»æä½ |
| | | * |
| | | * @author chenjiantian |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class PoleGroupService extends BaseServiceImpl<PoleGroupMapper, PoleGroup> { |
| | | |
| | | private final PoleGroupRelationService poleGroupRelationService; |
| | | |
| | | public boolean addGroup(PoleGroupParam param) { |
| | | PoleGroup group = new PoleGroup(); |
| | | group.setClientId(SecurityUtils.getClientId()); |
| | | group.setGroupName(param.getGroupName()); |
| | | return save(group); |
| | | } |
| | | |
| | | public boolean updateGroup(Long groupId, PoleGroupParam param) { |
| | | PoleGroup poleGroup = getById(groupId); |
| | | if (poleGroup == null) { |
| | | throw new BusinessException("æªæ¾å°è¯¥åç»"); |
| | | } |
| | | PoleGroup update = new PoleGroup(); |
| | | update.setGroupId(groupId); |
| | | update.setGroupName(param.getGroupName()); |
| | | return updateById(update); |
| | | } |
| | | |
| | | public boolean deleteGroup(Long groupId) { |
| | | PoleGroup poleGroup = getById(groupId); |
| | | if (poleGroup == null) { |
| | | throw new BusinessException("æªæ¾å°è¯¥åç»"); |
| | | } |
| | | return removeById(groupId); |
| | | } |
| | | |
| | | public List<PoleGroup> groupList() { |
| | | Long clientId = SecurityUtils.getClientId(); |
| | | if (clientId == null) { |
| | | return list(); |
| | | } else { |
| | | return list(Wrappers.lambdaQuery(PoleGroup.class).eq(PoleGroup::getClientId, clientId)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ç»å®ç¯æ |
| | | */ |
| | | public boolean bindPole(Long groupId,List<Long> poleList) { |
| | | PoleGroup poleGroup = getById(groupId); |
| | | if (poleGroup == null) { |
| | | throw new BusinessException("æªæ¾å°è¯¥åç»"); |
| | | } |
| | | return poleGroupRelationService.saveBinding(groupId,poleList); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.redis.RedisService; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.param.LampPostParam; |
| | | import com.sandu.ximon.admin.param.PoleParam; |
| | | import com.sandu.ximon.admin.redis.LightKey; |
| | | import com.sandu.ximon.admin.security.CountSet; |
| | | import com.sandu.ximon.dao.domain.LampPost; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import com.sandu.ximon.dao.mapper.ClientMapper; |
| | | import com.sandu.ximon.dao.mapper.LampPostMapper; |
| | | import com.sandu.ximon.dao.mapper.PoleMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * ç¯æç¸å
³ |
| | | * |
| | | * @author chenjiantian |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | @AllArgsConstructor |
| | | public class PoleService extends BaseServiceImpl<PoleMapper, Pole> { |
| | | private final CountSet countSet; |
| | | private final LampCountService lampCountService; |
| | | private final ClientMapper clientMapper; |
| | | private final LampPostMapper lampPostMapper; |
| | | private final RedisService redisService; |
| | | |
| | | public boolean addPole(PoleParam param) { |
| | | Pole pole = new Pole(); |
| | | BeanUtils.copyProperties(param, pole); |
| | | pole.setPoleCode(generatePoleCode()); |
| | | return save(pole); |
| | | } |
| | | |
| | | public boolean updatePole(Long poleId, PoleParam param) { |
| | | Pole pole = getById(poleId); |
| | | if (pole == null) { |
| | | throw new BusinessException("æªæ¾å°è¯¥ç¯æ"); |
| | | } |
| | | Pole update = new Pole(); |
| | | BeanUtils.copyProperties(param, update); |
| | | update.setId(poleId); |
| | | return updateById(update); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ç¯æ |
| | | */ |
| | | public boolean deletePole(Long poleId){ |
| | | Pole pole = getById(poleId); |
| | | if (pole == null) { |
| | | throw new BusinessException("æªæ¾å°è¯¥ç¯æ"); |
| | | } |
| | | return removeById(poleId); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * çæç¯æç¼å· |
| | | */ |
| | | private Long generatePoleCode() { |
| | | StringBuilder sb = new StringBuilder(); |
| | | String date = new SimpleDateFormat("yyMMdd").format(new Date()); |
| | | sb.append(date); |
| | | String key = LightKey.POLE_SN.key(null); |
| | | Long increment = redisService.incr(key, 1); |
| | | String incrementStr = increment.toString(); |
| | | if (incrementStr.length() <= 4) { |
| | | sb.append(String.format("%04d", increment)); |
| | | } else { |
| | | sb.append(incrementStr); |
| | | } |
| | | return Long.parseLong(sb.toString()); |
| | | } |
| | | |
| | | } |