diff --git a/psdc-business/src/main/java/com/psdc/entity/res/PsdcDeviceInfoRes.java b/psdc-business/src/main/java/com/psdc/entity/res/PsdcDeviceInfoRes.java index f4be2eb..f754b6b 100644 --- a/psdc-business/src/main/java/com/psdc/entity/res/PsdcDeviceInfoRes.java +++ b/psdc-business/src/main/java/com/psdc/entity/res/PsdcDeviceInfoRes.java @@ -58,6 +58,8 @@ public class PsdcDeviceInfoRes { /** 当前总有功电能 */ @Excel(name = "总用电量") private Double totWh; + /** 1不可控,2可控 */ + private Integer isControl; /** 设备状态:1-未激活,2-禁用,3-在线,4-离线 */ private Integer deviceStatus ; diff --git a/psdc-business/src/main/java/com/psdc/mapper/PsdcDeviceMapper.java b/psdc-business/src/main/java/com/psdc/mapper/PsdcDeviceMapper.java index c65e6c8..028ff3d 100644 --- a/psdc-business/src/main/java/com/psdc/mapper/PsdcDeviceMapper.java +++ b/psdc-business/src/main/java/com/psdc/mapper/PsdcDeviceMapper.java @@ -86,6 +86,9 @@ public interface PsdcDeviceMapper{ List queryByUserId(@Param(value = "userId") Long userId, @Param(value = "parentId") Integer parentId); + List queryByModel(@Param(value = "userId") Long userId, + @Param(value = "devModel") String devModel); + /** * 根据设备id修改设备状态 * @param deviceId diff --git a/psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerRtdataMapper.java b/psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerRtdataMapper.java index 80bde91..4c6d085 100644 --- a/psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerRtdataMapper.java +++ b/psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerRtdataMapper.java @@ -27,7 +27,7 @@ public interface PsdcThermometerRtdataMapper{ @Param("today") String today); List selWenDu(@Param("userId") Long userId, - @Param("parentId") Integer parentId, + @Param("modelTypeName") String parentId, @Param("today") String today); /** diff --git a/psdc-business/src/main/java/com/psdc/mapper/PsdcTimerMapper.java b/psdc-business/src/main/java/com/psdc/mapper/PsdcTimerMapper.java index a22ac1d..20a228d 100644 --- a/psdc-business/src/main/java/com/psdc/mapper/PsdcTimerMapper.java +++ b/psdc-business/src/main/java/com/psdc/mapper/PsdcTimerMapper.java @@ -21,7 +21,7 @@ public interface PsdcTimerMapper{ * @param timerId 主键 * @return 实例对象 */ - PsdcTimer queryById(Integer timerId); + PsdcTimer queryById(@Param("timerId") Integer timerId); /** * 通过ID查询单条数据 @@ -29,7 +29,7 @@ public interface PsdcTimerMapper{ * @param timerId 主键 * @return 实例对象 */ - PsdcTimerVo queryById2(Integer timerId); + PsdcTimerVo queryById2(@Param("timerId") Integer timerId); /** * 分页查询指定行数据 * @@ -71,5 +71,5 @@ public interface PsdcTimerMapper{ * @param timerId 主键 * @return 影响行数 */ - int deleteById(Integer timerId); + int deleteById(@Param("timerId") Integer timerId); } \ No newline at end of file diff --git a/psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java b/psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java index 3c26354..4cf6224 100644 --- a/psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java +++ b/psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java @@ -24,6 +24,11 @@ public interface IPsdcDeviceService { */ List queryByUserId(Integer parent); + List queryByModel(String model); + + List selalldevModel(); + + /** * 查询所有设备状态 * @return diff --git a/psdc-business/src/main/java/com/psdc/service/IPsdcThermometerHtdataService.java b/psdc-business/src/main/java/com/psdc/service/IPsdcThermometerHtdataService.java index e4f536a..48cfbe9 100644 --- a/psdc-business/src/main/java/com/psdc/service/IPsdcThermometerHtdataService.java +++ b/psdc-business/src/main/java/com/psdc/service/IPsdcThermometerHtdataService.java @@ -20,11 +20,11 @@ public interface IPsdcThermometerHtdataService { AjaxResult selTodayThermometer(); - AjaxResult sel8WnDu(Integer modelId); + AjaxResult sel8WnDu(String modelId); PsdcDevicePowerRes selTotalElectricityInfo(Integer deviceId); - List selTodayThermometerById(Integer modelId); + List selTodayThermometerById(String modelId); AjaxResult selDzglWenDu(Integer deviceId); diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcControlLogServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcControlLogServiceImpl.java index 1998696..8c99a26 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcControlLogServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcControlLogServiceImpl.java @@ -23,6 +23,7 @@ public class PsdcControlLogServiceImpl implements IPsdcControlLogService { * @param controlLogId 主键 * @return 实例对象 */ + @Override public PsdcControlLog queryById(Integer controlLogId){ return psdcControlLogMapper.queryById(controlLogId); } @@ -35,6 +36,7 @@ public class PsdcControlLogServiceImpl implements IPsdcControlLogService { * @param psdcControlLog 实例对象 * @return 实例对象 */ + @Override public PsdcControlLog insert(PsdcControlLog psdcControlLog){ psdcControlLogMapper.insert(psdcControlLog); return psdcControlLog; @@ -46,6 +48,7 @@ public class PsdcControlLogServiceImpl implements IPsdcControlLogService { * @param psdcControlLog 实例对象 * @return 实例对象 */ + @Override public PsdcControlLog update(PsdcControlLog psdcControlLog){ psdcControlLogMapper.update(psdcControlLog); return queryById(psdcControlLog.getControlLogId()); @@ -57,6 +60,7 @@ public class PsdcControlLogServiceImpl implements IPsdcControlLogService { * @param controlLogId 主键 * @return 是否成功 */ + @Override public boolean deleteById(Integer controlLogId){ int total = psdcControlLogMapper.deleteById(controlLogId); return total > 0; diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java index 5ac56f6..63f3c3f 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java @@ -64,6 +64,16 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService { return psdcDeviceMapper.queryByUserId(SecurityUtils.getUserId(), parent); } + @Override + public List queryByModel(String model) { + return psdcDeviceMapper.queryByModel(SecurityUtils.getUserId(), model); + } + + @Override + public List selalldevModel() { + return psdcDeviceMapper.queryByUserId(null, null); + } + public List queryDeviceStatus() { List psdcDevices = psdcDeviceMapper.queryByUserId(SecurityUtils.getUserId(), 0); return psdcDevices.stream().map(psdcDevice -> { diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java index 3db1f74..6702874 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java @@ -96,7 +96,7 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS } @Override - public AjaxResult sel8WnDu(Integer modelId) { + public AjaxResult sel8WnDu(String modelId) { List dataResList = psdcThermometerRtdataMapper.selWenDu(SecurityUtils.getUserId(), modelId, sdf.format(new Date())); return AjaxResult.success(dataResList); } @@ -116,7 +116,7 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS } @Override - public List selTodayThermometerById(Integer modelId) { + public List selTodayThermometerById(String modelId) { Date date = new Date(); String tb = sdf.format(date) + " 00:00:00"; // 今天开始检索时间 String te = sdf.format(date) + " 23:59:59"; // 今天结束检索时间 diff --git a/psdc-business/src/main/java/com/psdc/service/impl/PsdcTimerServiceImpl.java b/psdc-business/src/main/java/com/psdc/service/impl/PsdcTimerServiceImpl.java index 2f52d20..5d58b98 100644 --- a/psdc-business/src/main/java/com/psdc/service/impl/PsdcTimerServiceImpl.java +++ b/psdc-business/src/main/java/com/psdc/service/impl/PsdcTimerServiceImpl.java @@ -25,11 +25,14 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.List; +import java.util.Objects; +import java.util.function.Function; /** * 定时控制任务表;(psdc_timer)表服务实现类 - * @date : 2023-5-10 + * + * @date : 2023-5-10 */ @Service @Slf4j @@ -43,48 +46,51 @@ public class PsdcTimerServiceImpl implements IPsdcTimerService { @Resource private IPsdcDeviceService psdcDeviceService; - - /** - * 通过ID查询单条数据 + + /** + * 通过ID查询单条数据 * * @param timerId 主键 * @return 实例对象 */ - public PsdcTimerVo queryById(Integer timerId){ + @Override + public PsdcTimerVo queryById(Integer timerId) { return psdcTimerMapper.queryById2(timerId); } - - - /** + + /** * 新增数据 * * @param psdcTimer 实例对象 * @return 实例对象 */ - public PsdcTimer insert(PsdcTimer psdcTimer){ + @Override + public PsdcTimer insert(PsdcTimer psdcTimer) { psdcTimerMapper.insert(psdcTimer); return psdcTimer; } - - /** + + /** * 更新数据 * * @param psdcTimer 实例对象 * @return 实例对象 */ - public PsdcTimerVo update(PsdcTimer psdcTimer){ + @Override + public PsdcTimerVo update(PsdcTimer psdcTimer) { psdcTimerMapper.update(psdcTimer); return queryById(psdcTimer.getTimerId()); } - - /** + + /** * 通过主键删除数据 * * @param timerId 主键 * @return 是否成功 */ - public boolean deleteById(Integer timerId){ + @Override + public boolean deleteById(Integer timerId) { int total = psdcTimerMapper.deleteById(timerId); return total > 0; } @@ -92,124 +98,135 @@ public class PsdcTimerServiceImpl implements IPsdcTimerService { @Override public List query(PsdcTimerRequest psdcTimerRequest) { psdcTimerRequest.setUserId(SecurityUtils.getUserId()); - return psdcTimerMapper.queryAllByLimit(psdcTimerRequest); + List psdcTimerVos = psdcTimerMapper.queryAllByLimit(psdcTimerRequest); + for (PsdcTimerVo psdcTimerVo : psdcTimerVos) { + if ("startandstop".equals(psdcTimerVo.getControlKey())) { + if ("1".equals(psdcTimerVo.getControlValue())) { + psdcTimerVo.setControlValue("开启"); + } else { + psdcTimerVo.setControlValue("关闭"); + } + } + } + return psdcTimerVos; } /** * 创建定时任务 + * * @param psdcTimerRunTimeRequest 请求类 * @return int */ @Override @Transactional public Integer addTimer(PsdcTimerRunTimeRequest psdcTimerRunTimeRequest) { - //获取psdcTimerRunTimeRequest中的timeList数组,根据内容拼出cron表达式 + // 获取psdcTimerRunTimeRequest中的timeList数组,根据内容拼出cron表达式 String runDay = psdcTimerRunTimeRequest.getRunday(); String runtime = psdcTimerRunTimeRequest.getRuntime(); - //设置cron表达式 + // 设置cron表达式 String[] cronArr = new String[7]; - //秒,默认为每分钟的0秒 - if (runtime == null || !runtime.contains(":") ){ - throw new ServiceException("设定执行时间错误,创建定时任务失败,设定时间为:"+runtime); + // 秒,默认为每分钟的0秒 + if (runtime == null || !runtime.contains(":")) { + throw new ServiceException("设定执行时间错误,创建定时任务失败,设定时间为:" + runtime); } if (runDay == null || "".equals(runDay)) { - throw new ServiceException("设定日期错误,创建定时任务失败,设定日期为:" + runDay); + throw new ServiceException("设定日期错误,创建定时任务失败,设定日期为:" + runDay); } Integer deviceId = psdcTimerRunTimeRequest.getDeviceId(); PsdcDevice psdcDevice = psdcDeviceService.queryById(deviceId); - if(psdcDevice == null){ + if (psdcDevice == null) { throw new ServiceException("创建定时任务失败,未找到该设备"); } - if (psdcDevice.getIsControl() != 2 ){ + if (psdcDevice.getIsControl() != 2) { throw new ControlException("该设备无法控制,请联系管理员"); } String[] split1 = runtime.split(":"); cronArr[0] = "0"; - //分 + // 分 cronArr[1] = split1[1]; - //时 + // 时 cronArr[2] = split1[0]; /* 接下来拼装日月,或周,只有三种情况 */ - if(runDay.equals("0")){ - //每天的情况 - //日 + if (runDay.equals("0")) { + // 每天的情况 + // 日 cronArr[3] = "*"; - //月 + // 月 cronArr[4] = "*"; - //周 + // 周 cronArr[5] = "?"; } else if (runDay.length() == 10 && (runDay.contains("-"))) { - //设定日期情况,就是一次的情况 + // 设定日期情况,就是一次的情况 String[] split = runDay.split("-"); - //日 + // 日 cronArr[3] = split[2]; - //月 + // 月 cronArr[4] = split[1]; - //周 + // 周 cronArr[5] = "?"; } else if (runDay.contains(",")) { - //设定星期情况 + // 设定星期情况 String[] split = runDay.split("-"); - //日 + // 日 cronArr[3] = "?"; - //月 + // 月 cronArr[4] = "*"; - //周 - cronArr[5] = StringUtils.join(split,","); + // 周 + cronArr[5] = StringUtils.join(split, ","); } else { - throw new ServiceException("设定日期错误,创建定时任务失败,设定日期为:" + runDay); + throw new ServiceException("设定日期错误,创建定时任务失败,设定日期为:" + runDay); } - //年,。暂时不用 + // 年,。暂时不用 // cronArr[6] = String cron = StringUtils.join(cronArr, " "); - log.info("cron表达式:{}",cron); + log.info("cron表达式:{}", cron); try { /* 创建job对象,往quartz中插入执行的任务,拿到jobId */ SysJob job = new SysJob(); - //设备id + 控制键 + 控制值 + 控制日期 + 控制时间 + + // 设备id + 控制键 + 控制值 + 控制日期 + 控制时间 + String jobName = psdcTimerRunTimeRequest.getDeviceId() + "+" + ControlKeyEnum.getControlContext(psdcTimerRunTimeRequest.getControlKey()) + "-" + psdcTimerRunTimeRequest.getControlValue() + "+" + psdcTimerRunTimeRequest.getRunday() + "+" + psdcTimerRunTimeRequest.getRuntime() + "+" + System.currentTimeMillis(); job.setJobName(jobName); - //默认 + // 默认 job.setJobGroup("psdc"); String controlKey = psdcTimerRunTimeRequest.getControlKey(); String jobClassName = ""; - //判断控制指令 - if (controlKey.equals( "startandstop")){ - //控制启停 + // 判断控制指令 + if (controlKey.equals("startandstop")) { + // 控制启停 log.info("控制设备启停"); - jobClassName = String.format("psdcDeviceServiceImpl.controlDeviceStartAndStop(%d,%d,'%s',%d))",psdcTimerRunTimeRequest.getDeviceId(),Integer.valueOf(psdcTimerRunTimeRequest.getControlValue()),SecurityUtils.getUsername(),2); - } else if (controlKey.equals( "intemp") || controlKey.equals( "outtemp") || controlKey.equals( "temp") ) { - //控制温度 - jobClassName = String.format("psdcDeviceServiceImpl.setTemperature(%d,'%s','%s','%s',%d))",psdcTimerRunTimeRequest.getDeviceId(),controlKey,psdcTimerRunTimeRequest.getControlValue(),SecurityUtils.getUsername(),2); + jobClassName = String.format("psdcDeviceServiceImpl.controlDeviceStartAndStop(%d,%d,'%s',%d))", psdcTimerRunTimeRequest.getDeviceId(), Integer.valueOf(psdcTimerRunTimeRequest.getControlValue()), SecurityUtils.getUsername(), 2); + } else if (controlKey.equals("intemp") || controlKey.equals("outtemp") || controlKey.equals("temp")) { + // 控制温度 + jobClassName = String.format("psdcDeviceServiceImpl.setTemperature(%d,'%s','%s','%s',%d))", psdcTimerRunTimeRequest.getDeviceId(), controlKey, psdcTimerRunTimeRequest.getControlValue(), SecurityUtils.getUsername(), 2); } job.setInvokeTarget(jobClassName); - //cron表达式 + // cron表达式 job.setCronExpression(cron); - //执行错误放弃执行 + // 执行错误放弃执行 job.setMisfirePolicy("3"); - //是否并发,不并发 + // 是否并发,不并发 job.setConcurrent("1"); job.setCreateBy(SecurityUtils.getUsername()); int i = jobService.insertJob(job); SysJob job1 = null; - if( i > 0){ + if (i > 0) { job1 = jobService.selectJobByName(jobName); - } else { + } else { throw new ServiceException("创建定时任务失败,请联系管理员"); } - //将创建的任务插入psdcTimer表 + // 将创建的任务插入psdcTimer表 PsdcTimer psdcTimer = new PsdcTimer(); - BeanUtils.copyProperties(psdcTimerRunTimeRequest,psdcTimer); + BeanUtils.copyProperties(psdcTimerRunTimeRequest, psdcTimer); psdcTimer.setUserId(SecurityUtils.getUserId().intValue()); - psdcTimer.setControlContext( ControlKeyEnum.getControlContext(psdcTimerRunTimeRequest.getControlKey())); + psdcTimer.setControlContext(ControlKeyEnum.getControlContext(psdcTimerRunTimeRequest.getControlKey())); psdcTimer.setCronText(cron); psdcTimer.setJobId(job1.getJobId().intValue()); psdcTimer.setTimerStatus(Integer.valueOf(job1.getStatus())); @@ -222,21 +239,20 @@ public class PsdcTimerServiceImpl implements IPsdcTimerService { } - } @Override @Transactional public int updateStatus(Integer timerId, Integer status) throws SchedulerException { - //获取jobId + // 获取jobId PsdcTimer psdcTimer = psdcTimerMapper.queryById(timerId); - //修改quartz状态 + // 修改quartz状态 SysJob job = new SysJob(); job.setStatus(status.toString()); job.setJobId(psdcTimer.getJobId().longValue()); job.setJobGroup("psdc"); int i = jobService.changeStatus(job); - if (i > 0){ + if (i > 0) { return psdcTimerMapper.updateStatus(timerId, status); } else { throw new ServiceException("修改定时任务状态失败"); @@ -246,17 +262,13 @@ public class PsdcTimerServiceImpl implements IPsdcTimerService { @Override @Transactional public Integer delete(Integer timerId) throws SchedulerException { - //获取jobId + // 获取jobId PsdcTimer psdcTimer = psdcTimerMapper.queryById(timerId); - //删除quartz任务 + // 删除quartz任务 SysJob job = new SysJob(); job.setJobId(psdcTimer.getJobId().longValue()); job.setJobGroup("psdc"); int i = jobService.deleteJob(job); - if (i > 0){ - return psdcTimerMapper.deleteById(timerId); - } else { - throw new ServiceException("删除定时任务失败"); - } + return psdcTimerMapper.deleteById(timerId); } } \ No newline at end of file diff --git a/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml b/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml index 609e06e..fa25ed7 100644 --- a/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml +++ b/psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml @@ -46,6 +46,7 @@ + @@ -101,18 +102,31 @@ And parent_id = #{parentId} + GROUP BY device_model + + + - + diff --git a/psdc-business/src/main/resources/mapper/business/PsdcThermometerRtdataMapper.xml b/psdc-business/src/main/resources/mapper/business/PsdcThermometerRtdataMapper.xml index 008a7b6..1398471 100644 --- a/psdc-business/src/main/resources/mapper/business/PsdcThermometerRtdataMapper.xml +++ b/psdc-business/src/main/resources/mapper/business/PsdcThermometerRtdataMapper.xml @@ -40,7 +40,7 @@ From psdc_device pd LEFT join psdc_thermometer_rtdata ptr on pd.device_id = ptr.device_id And DATE_FORMAT(ptr.update_time,'%Y-%m-%d %H') = #{today} - Where pd.user_id = ${userId} And pd.parent_id = ${parentId} + Where pd.user_id = ${userId} And pd.device_model = #{modelTypeName} diff --git a/psdc-business/src/main/resources/mapper/business/PsdcTimerMapper.xml b/psdc-business/src/main/resources/mapper/business/PsdcTimerMapper.xml index 0473492..8715af1 100644 --- a/psdc-business/src/main/resources/mapper/business/PsdcTimerMapper.xml +++ b/psdc-business/src/main/resources/mapper/business/PsdcTimerMapper.xml @@ -54,7 +54,7 @@ - select pt.timer_id,pt.device_id,pd.device_name,pt.user_id,pt.runday,pt.runtime,pt.control_key,pt.control_context,pt.control_value,pt.cron_text,pt.job_id,pt.timer_status,pt.create_by,pt.create_time,pt.update_by,pt.update_time from psdc_timer pt left join psdc_device pd on pt.device_id = pd.device_id diff --git a/psdc-web/src/main/java/com/psdc/controller/index/Index.java b/psdc-web/src/main/java/com/psdc/controller/index/Index.java index f65392d..801dcef 100644 --- a/psdc-web/src/main/java/com/psdc/controller/index/Index.java +++ b/psdc-web/src/main/java/com/psdc/controller/index/Index.java @@ -3,10 +3,7 @@ package com.psdc.controller.index; import com.psdc.core.domain.AjaxResult; import com.psdc.service.IPsdcThermometerHtdataService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RestController @@ -21,9 +18,9 @@ public class Index { return psdcThermometerHtdataService.selTodayThermometer(); } - @RequestMapping(value = "/8wd/{modelId}", method = RequestMethod.GET) - public AjaxResult sel8WenDu(@PathVariable(value = "modelId", required = false) Integer modelId) { - return psdcThermometerHtdataService.sel8WnDu(modelId); + @RequestMapping(value = "/8wd", method = RequestMethod.POST) + public AjaxResult sel8WenDu(@RequestParam(value="modelTypeName", defaultValue="") String modelname) { + return psdcThermometerHtdataService.sel8WnDu(modelname); } @RequestMapping(value = "/zdb/{modelId}", method = RequestMethod.GET) diff --git a/psdc-web/src/main/java/com/psdc/controller/manager/PsdcDeviceController.java b/psdc-web/src/main/java/com/psdc/controller/manager/PsdcDeviceController.java index 9ea4bd9..24dd656 100644 --- a/psdc-web/src/main/java/com/psdc/controller/manager/PsdcDeviceController.java +++ b/psdc-web/src/main/java/com/psdc/controller/manager/PsdcDeviceController.java @@ -70,7 +70,7 @@ public class PsdcDeviceController extends BaseController { @PreAuthorize("@ss.hasPermi('system:device:list')") @Log(title = "设备管理", businessType = BusinessType.DELETE) - @DeleteMapping + @RequestMapping(value = "/del", method = RequestMethod.POST) public AjaxResult remove(@Validated @RequestBody Long[] deviceIds) { return toAjax(psdcDeviceService.deleteById(deviceIds)); } @@ -90,6 +90,20 @@ public class PsdcDeviceController extends BaseController { return AjaxResult.success("用户下拉列表", maps); } + @PreAuthorize("@ss.hasPermi('system:device:list')") + @RequestMapping(value = "/selmodels", method = RequestMethod.GET) + public AjaxResult selAllModels() { + List maps = new ArrayList<>(); + List list = psdcDeviceService.selalldevModel(); + for (PsdcDevice dd : list){ + Map map = new HashMap<>(); + map.put("label", dd.getDeviceModel()); + map.put("value", dd.getDeviceModel()); + maps.add(map); + } + return AjaxResult.success("模型下拉列表", maps); + } + @PreAuthorize("@ss.hasPermi('system:device:list')") @RequestMapping(value = "/devicesList", method = RequestMethod.POST) public TableDataInfo controlLogList(@RequestBody JSONObject jsonObject) { diff --git a/psdc-web/src/main/java/com/psdc/controller/monitor/TotalElectricMeterController.java b/psdc-web/src/main/java/com/psdc/controller/monitor/TotalElectricMeterController.java index f40f559..ae8cb66 100644 --- a/psdc-web/src/main/java/com/psdc/controller/monitor/TotalElectricMeterController.java +++ b/psdc-web/src/main/java/com/psdc/controller/monitor/TotalElectricMeterController.java @@ -46,9 +46,8 @@ public class TotalElectricMeterController { for (PsdcDevice dd : list){ Map map = new HashMap<>(); map.put("modelName", dd.getDeviceModel()); - map.put("modelId", dd.getDeviceId()); List maps2 = new ArrayList<>(); - List list2 = psdcDeviceService.queryByUserId(dd.getDeviceId()); + List list2 = psdcDeviceService.queryByModel(dd.getDeviceModel()); if (list2.size() > 0){ for (PsdcDevice dev : list2){ Map map2 = new HashMap<>(); diff --git a/psdc-web/src/main/java/com/psdc/controller/monitor/WenDuController.java b/psdc-web/src/main/java/com/psdc/controller/monitor/WenDuController.java index 4054b01..021630a 100644 --- a/psdc-web/src/main/java/com/psdc/controller/monitor/WenDuController.java +++ b/psdc-web/src/main/java/com/psdc/controller/monitor/WenDuController.java @@ -4,10 +4,7 @@ import com.psdc.core.domain.AjaxResult; import com.psdc.service.IPsdcThermometerHtdataService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * @Author:戴仕崑 @@ -24,9 +21,9 @@ public class WenDuController { IPsdcThermometerHtdataService psdcThermometerHtdataService; @PreAuthorize("@ss.hasPermi('emonitor:wdcgq')") - @RequestMapping(value = "/sel1/{modelId}", method = RequestMethod.GET) - public AjaxResult selwd(@PathVariable(value = "modelId", required = false) Integer modelId){ - return AjaxResult.success(psdcThermometerHtdataService.selTodayThermometerById(modelId)); + @RequestMapping(value = "/sel1", method = RequestMethod.POST) + public AjaxResult selwd(@RequestParam(value="modelTypeName", defaultValue="") String modelname){ + return AjaxResult.success(psdcThermometerHtdataService.selTodayThermometerById(modelname)); } }