| | |
| | | /** |
| | | * 创建者ID |
| | | */ |
| | | @JsonIgnore |
| | | private Long createUserId; |
| | | |
| | | /** |
| | |
| | | * led屏幕开关 |
| | | */ |
| | | @TableField(exist = false) |
| | | private Boolean isOpen; |
| | | private String isOpen; |
| | | |
| | | @TableField(exist = false) |
| | | private boolean isOnLine; |
| | | |
| | | /* |
| | | * 灯杆名称 |
| | |
| | | package com.sandu.ximon.dao.mapper; |
| | | |
| | | import com.sandu.ximon.dao.domain.PoleLightemitEntity; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import com.sandu.ximon.dao.domain.PoleLightemitEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | void updateRequestBody(@Param("ledCode")String ledCode, @Param("postBody")String postBody); |
| | | |
| | | List<PoleLightemitEntity> listLed(String keyword, Long userid); |
| | | |
| | | Pole getpole(String lightemitControlCode); |
| | | } |
| | | |
| | | |
| | |
| | | t3.device_type=0 |
| | | <if test=" taskId != null"> |
| | | AND |
| | | task_id = taskId |
| | | t2.task_id = #{taskId} |
| | | </if> |
| | | </select> |
| | | </mapper> |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | lightemit_id,lightemit_name,lightemit_control_code, |
| | | lightemit_id |
| | | ,lightemit_name,lightemit_control_code, |
| | | url,play_time,add_time, |
| | | request_body,player_setting,status, |
| | | remark,create_user_id,create_time |
| | |
| | | </if> |
| | | </where> |
| | | </select> |
| | | <select id="getpole" resultType="com.sandu.ximon.dao.domain.Pole" parameterType="java.lang.String"> |
| | | SELECT |
| | | t1.* |
| | | FROM |
| | | pole t1 |
| | | LEFT JOIN pole_binding t2 ON t1.id = t2.pole_id |
| | | LEFT JOIN pole_lightemit t3 ON t2.device_code = t3.lightemit_control_code |
| | | WHERE |
| | | t2.device_type = 10 |
| | | <if test="lightemitControlCode != null"> |
| | | AND t3.lightemit_control_code = #{lightemitControlCode} |
| | | </if> |
| | | </select> |
| | | </mapper> |
| | |
| | | return ResponseUtil.success(list); |
| | | } |
| | | |
| | | @PostMapping("/EnergySaving") |
| | | public ResponseVO<Object> controlEnergySaving() { |
| | | return ResponseUtil.success(lightService.controlEnergySaving()); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/Energy") |
| | | @AnonymousAccess |
| | | public ResponseVO<Object> Energy() { |
| | | return ResponseUtil.success(lightService.controlEnergy()); |
| | | } |
| | | |
| | | // /** |
| | | // * 获取设备码 |
| | | // */ |
| | | // @GetMapping("/deviceCode") |
| | | // public ResponseVO<Object> getDeviceCode(BaseConditionVO baseConditionVO) { |
| | | // return ResponseUtil.success(lightService.listDeviceCode(baseConditionVO.getPageNo() , baseConditionVO.getPageSize())); |
| | | // } |
| | | @AnonymousAccess |
| | | @PostMapping("/EnergySaving") |
| | | public ResponseVO<Object> controlEnergySaving() { |
| | | return ResponseUtil.success(lightService.controlEnergySaving()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 设置功率 |
| | |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.security.annotation.AnonymousAccess; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.dto.DeviceStatus; |
| | | import com.sandu.ximon.admin.param.PoleBindParam; |
| | | import com.sandu.ximon.admin.param.PoleBindingParam; |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.sql.Wrapper; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 在线数量 |
| | | */ |
| | | @AnonymousAccess |
| | | @GetMapping("/online") |
| | | public ResponseVO<Object> online() { |
| | | return ResponseUtil.success(poleService.poleCount()); |
| | |
| | | public ResponseVO<Object> getOwnerPole(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword |
| | | , @PathVariable Long cilentId) { |
| | | List<Pole> results = poleService.getOwnerPole(baseConditionVO, keyword, cilentId); |
| | | // CommonPage commonPage = CommonPage.restPage(results); |
| | | // int size = results.size(); |
| | | // commonPage.setTotal((long) size); |
| | | // commonPage.setTotalPage(size / baseConditionVO.getPageSize() + 1); |
| | | // if (size % baseConditionVO.getPageSize() == 0) { |
| | | // commonPage.setTotalPage(size / baseConditionVO.getPageSize()); |
| | | // } |
| | | // return ResponseUtil.success(commonPage); |
| | | return ResponseUtil.success(results); |
| | | } |
| | | |
| | | /** |
| | | * 查看灯杆绑定的设备 |
| | | */ |
| | | @AnonymousAccess |
| | | @PostMapping("/getPoleBindDevice/{poleId}") |
| | | public ResponseVO<Object> getPoleBindDevice(@PathVariable Long poleId) { |
| | | return ResponseUtil.success(poleService.getBindByPoleId(poleId)); |
| | |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.security.annotation.AnonymousAccess; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.entity.ProgramPro; |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 测试 |
| | | * @param |
| | | * @return |
| | | */ |
| | | @AnonymousAccess |
| | | @PostMapping("/test/{str}") |
| | | public ResponseVO<Object> setBrightness(@PathVariable String str) { |
| | | return ResponseUtil.success(lightemitUtils.getIsScreenOpen(str)); |
| | | } |
| | | |
| | | |
| | | /* |
| | | 设置亮度 |
| | | */ |
| | |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | |
| | | /** |
| | | * @Author liuhaonan |
| | | * @Date 2022/2/24 10:15 |
| | |
| | | */ |
| | | public class test { |
| | | public static void main(String[] args) { |
| | | // |
| | | // String s="123456";//$2a$10$t0t9gaLuWT/1XFDfbjbUueWcj2G/Dx5vQCrtyRKWNlqkz6C/y.oXK |
| | | // PasswordEncoder pw= new BCryptPasswordEncoder(); |
| | | // //加密 |
| | | // String encode=pw.encode(s); |
| | | // System.out.println(encode); |
| | | // //比较密码 |
| | | // boolean matches=pw.matches(s,encode); |
| | | // System.out.println("=============================="); |
| | | // System.out.println(matches); |
| | | |
| | | String s="123456";//$2a$10$t0t9gaLuWT/1XFDfbjbUueWcj2G/Dx5vQCrtyRKWNlqkz6C/y.oXK |
| | | PasswordEncoder pw= new BCryptPasswordEncoder(); |
| | | //加密 |
| | | String encode=pw.encode(s); |
| | | System.out.println(encode); |
| | | //比较密码 |
| | | boolean matches=pw.matches(s,encode); |
| | | System.out.println("=============================="); |
| | | System.out.println(matches); |
| | | // |
| | | // // LocalDateTime now = LocalDateTime.now(); |
| | | //// Integer week = now.getDayOfWeek().getValue(); |
| | | //// System.out.println("获取当前周:" + week); |
| | | //// |
| | | |
| | | String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | System.out.println(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | /** |
| | | * 时间字符串转为LocalDateTime |
| | | */ |
| | | LocalDateTime parse = LocalDateTime.parse(format, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | System.out.println(parse); |
| | | // String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | // System.out.println(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | // /** |
| | | // * 时间字符串转为LocalDateTime |
| | | // */ |
| | | // LocalDateTime parse = LocalDateTime.parse(format, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | // System.out.println(parse); |
| | | |
| | | } |
| | | } |
| | |
| | | if (week < 1) { |
| | | week = 7; |
| | | } |
| | | map.put(i, "周" + week); |
| | | map.put(i, getlist(week)); |
| | | map.put(i, getlistEnergy(week)); |
| | | } |
| | | |
| | | |
| | |
| | | ControlLightCommandVO startTime = parseSwitchLightCommand(Task.getOpenOrder()); |
| | | ControlLightCommandVO endTime = parseSwitchLightCommand(Task.getCloseOrder()); |
| | | //获取到单灯任务的节能率 |
| | | if (Task.getControlOrder() != null) {//有控等指令 拆分计算 |
| | | if (!Task.getControlOrder().isEmpty()) {//有控等指令 拆分计算 |
| | | List<ControlLightCommandVO> controlLightCommandVOS = parseControlLightCommand(Task.getControlOrder()); |
| | | |
| | | |
| | |
| | | } |
| | | } else {//无控灯指令 直接计算 |
| | | BigDecimal bigDecimal = calculateEnergySaving(startTime, endTime); |
| | | //计算能耗(部分 时长*亮度) |
| | | BigDecimal Energy = calculateEnergyConsumption(startTime, endTime); |
| | | //计算能耗(总 时长*亮度*功率) |
| | | BigDecimal totalEnergy = totalEnergy(Energy, Task.getLightAdress(), poleTaskLightPowerBos); |
| | |
| | | //计算能耗(部分 时长*亮度) |
| | | public BigDecimal calculateEnergyConsumption(ControlLightCommandVO v1, ControlLightCommandVO v2) { |
| | | //计算时长 |
| | | BigDecimal hour = BigDecimal.valueOf((v2.getHour() - v1.getHour())); |
| | | BigDecimal hour; |
| | | if (v2.getHour() > v1.getHour()){ |
| | | hour = BigDecimal.valueOf((v2.getHour() - v1.getHour())); |
| | | }else if (v2.getHour() < v1.getHour()) { |
| | | hour = BigDecimal.valueOf((v2.getHour() + 24 - v1.getHour())); |
| | | } else { |
| | | hour = BigDecimal.valueOf(0); |
| | | } |
| | | BigDecimal min = BigDecimal.valueOf((v2.getMin() - v1.getMin()) / 60); |
| | | BigDecimal totalTime = (hour.add(min)); |
| | | //计算亮灯时长*亮度 |
| | |
| | | } |
| | | } |
| | | |
| | | if(baseConditionVO==null){ |
| | | baseConditionVO = new BaseConditionVO(); |
| | | baseConditionVO.setPageSize(null); |
| | | baseConditionVO.setPageNo(null); |
| | | } |
| | | CommonPage commonPage = ListPagingUtils.pages(temp, baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | return commonPage; |
| | | } |
| | |
| | | import com.sandu.ximon.admin.utils.FileUtil; |
| | | import com.sandu.ximon.admin.utils.HtmlTemplateUtils; |
| | | import com.sandu.ximon.admin.utils.LightemitUtils; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import com.sandu.ximon.dao.domain.PoleLightemitEntity; |
| | | import com.sandu.ximon.dao.mapper.PoleLightemitEntityMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 取出在线的熙讯 |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public List<PoleLightemitEntity> ledOnline(List<PoleLightemitEntity> list) { |
| | | List<PoleLightemitEntity> onLineList = new ArrayList<>(); |
| | | for (PoleLightemitEntity poleLightemitEntity : list) { |
| | | poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true")); |
| | | if (poleLightemitEntity.getIsOpen()) { |
| | | // if(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true")){ |
| | | // poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true")); |
| | | // } |
| | | poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode())); |
| | | boolean ledOnLine = lightemitUtils.getLedOnLine(poleLightemitEntity.getLightemitControlCode()); |
| | | if (ledOnLine) { |
| | | poleLightemitEntity.setOnLine(true); |
| | | onLineList.add(poleLightemitEntity); |
| | | } else { |
| | | poleLightemitEntity.setOnLine(false); |
| | | } |
| | | } |
| | | return onLineList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置在线状态 |
| | | * @param list |
| | | */ |
| | | public void ledOnlineCheck(List<PoleLightemitEntity> list) { |
| | | for (PoleLightemitEntity poleLightemitEntity : list) { |
| | | poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true")); |
| | | |
| | | poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode())); |
| | | poleLightemitEntity.setOnLine(lightemitUtils.getLedOnLine(poleLightemitEntity.getLightemitControlCode())); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | public PoleLightemitEntity getLedByLightControlCode(String lightControlCode) { |
| | | PoleLightemitEntity xiXun = getOne(Wrappers.lambdaQuery(PoleLightemitEntity.class).eq(PoleLightemitEntity::getLightemitControlCode, lightControlCode)); |
| | | Pole getpole = poleLightemitDao.getpole(lightControlCode); |
| | | if (xiXun == null) { |
| | | return null; |
| | | } |
| | | String isScreenOpen = lightemitUtils.getIsScreenOpen(xiXun.getLightemitControlCode()); |
| | | if (isScreenOpen.contains("true")) { |
| | | xiXun.setIsOpen(true); |
| | | } |
| | | xiXun.setIsOpen(false); |
| | | boolean isScreenOpen = lightemitUtils.getLedOnLine(xiXun.getLightemitControlCode()); |
| | | |
| | | xiXun.setIsOpen(lightemitUtils.getIsScreenOpen(lightControlCode)); |
| | | xiXun.setOnLine(isScreenOpen); |
| | | xiXun.setStreetlightName(getpole.getPoleName()); |
| | | xiXun.setStreetlightId(getpole.getId()); |
| | | |
| | | return xiXun; |
| | | } |
| | | |
| | |
| | | */ |
| | | public String getIsScreenOpen(String ledCode) { |
| | | String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new IsScreenOpen())); |
| | | LogUtils.error("getIsScreenOpen:" + result); |
| | | //获取base64图片数据 |
| | | if (StringUtils.isNotBlank(result)) { |
| | | String re; |
| | |
| | | } |
| | | } |
| | | |
| | | /* |
| | | 启动xwalk |
| | | */ |
| | | /*public void startActivity(String ledCode){ |
| | | String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new StartActivity())); |
| | | }*/ |
| | | |
| | | /* |
| | | 使用xwalk加载网页 |
| | | */ |
| | | /*public void callXwalkFn(String ledCode,String username){ |
| | | public boolean getLedOnLine(String ledCode) { |
| | | String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new IsScreenOpen())); |
| | | LogUtils.error("getLedOnLine:" + result); |
| | | //获取base64图片数据 |
| | | if (StringUtils.isNotBlank(result)) { |
| | | String re; |
| | | if (result.contains("not exist")) { |
| | | return false; |
| | | } else { |
| | | return true; |
| | | } |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | CallXwalkFn callXwalkFn = new CallXwalkFn(); |
| | | |
| | | callXwalkFn.setArgUrl(realtimeServerBean.getUrl() + username + "_" + ledCode + ".html"); |
| | | String postBody = new Gson().toJson(callXwalkFn); |
| | | |
| | | //请求地址 |
| | | String url = realtimeServerBean.getCommand() + ledCode; |
| | | //请求 |
| | | String result = post(url,postBody); |
| | | }*/ |
| | | |
| | | /* |
| | | 控制屏幕开关 |