Merge remote-tracking branch 'origin/master'

master
wj 2 years ago
commit 9be6249cad
  1. 2
      psdc-business/src/main/java/com/psdc/entity/res/PsdcDeviceInfoRes.java
  2. 3
      psdc-business/src/main/java/com/psdc/mapper/PsdcDeviceMapper.java
  3. 2
      psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerRtdataMapper.java
  4. 6
      psdc-business/src/main/java/com/psdc/mapper/PsdcTimerMapper.java
  5. 5
      psdc-business/src/main/java/com/psdc/service/IPsdcDeviceService.java
  6. 4
      psdc-business/src/main/java/com/psdc/service/IPsdcThermometerHtdataService.java
  7. 4
      psdc-business/src/main/java/com/psdc/service/impl/PsdcControlLogServiceImpl.java
  8. 10
      psdc-business/src/main/java/com/psdc/service/impl/PsdcDeviceServiceImpl.java
  9. 4
      psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java
  10. 154
      psdc-business/src/main/java/com/psdc/service/impl/PsdcTimerServiceImpl.java
  11. 21
      psdc-business/src/main/resources/mapper/business/PsdcDeviceMapper.xml
  12. 2
      psdc-business/src/main/resources/mapper/business/PsdcThermometerRtdataMapper.xml
  13. 2
      psdc-business/src/main/resources/mapper/business/PsdcTimerMapper.xml
  14. 11
      psdc-web/src/main/java/com/psdc/controller/index/Index.java
  15. 16
      psdc-web/src/main/java/com/psdc/controller/manager/PsdcDeviceController.java
  16. 3
      psdc-web/src/main/java/com/psdc/controller/monitor/TotalElectricMeterController.java
  17. 11
      psdc-web/src/main/java/com/psdc/controller/monitor/WenDuController.java

@ -58,6 +58,8 @@ public class PsdcDeviceInfoRes {
/** 当前总有功电能 */ /** 当前总有功电能 */
@Excel(name = "总用电量") @Excel(name = "总用电量")
private Double totWh; private Double totWh;
/** 1不可控,2可控 */
private Integer isControl;
/** 设备状态:1-未激活,2-禁用,3-在线,4-离线 */ /** 设备状态:1-未激活,2-禁用,3-在线,4-离线 */
private Integer deviceStatus ; private Integer deviceStatus ;

@ -86,6 +86,9 @@ public interface PsdcDeviceMapper{
List<PsdcDevice> queryByUserId(@Param(value = "userId") Long userId, List<PsdcDevice> queryByUserId(@Param(value = "userId") Long userId,
@Param(value = "parentId") Integer parentId); @Param(value = "parentId") Integer parentId);
List<PsdcDevice> queryByModel(@Param(value = "userId") Long userId,
@Param(value = "devModel") String devModel);
/** /**
* 根据设备id修改设备状态 * 根据设备id修改设备状态
* @param deviceId * @param deviceId

@ -27,7 +27,7 @@ public interface PsdcThermometerRtdataMapper{
@Param("today") String today); @Param("today") String today);
List<PsdcThermometerDataRes> selWenDu(@Param("userId") Long userId, List<PsdcThermometerDataRes> selWenDu(@Param("userId") Long userId,
@Param("parentId") Integer parentId, @Param("modelTypeName") String parentId,
@Param("today") String today); @Param("today") String today);
/** /**

@ -21,7 +21,7 @@ public interface PsdcTimerMapper{
* @param timerId 主键 * @param timerId 主键
* @return 实例对象 * @return 实例对象
*/ */
PsdcTimer queryById(Integer timerId); PsdcTimer queryById(@Param("timerId") Integer timerId);
/** /**
* 通过ID查询单条数据 * 通过ID查询单条数据
@ -29,7 +29,7 @@ public interface PsdcTimerMapper{
* @param timerId 主键 * @param timerId 主键
* @return 实例对象 * @return 实例对象
*/ */
PsdcTimerVo queryById2(Integer timerId); PsdcTimerVo queryById2(@Param("timerId") Integer timerId);
/** /**
* 分页查询指定行数据 * 分页查询指定行数据
* *
@ -71,5 +71,5 @@ public interface PsdcTimerMapper{
* @param timerId 主键 * @param timerId 主键
* @return 影响行数 * @return 影响行数
*/ */
int deleteById(Integer timerId); int deleteById(@Param("timerId") Integer timerId);
} }

@ -24,6 +24,11 @@ public interface IPsdcDeviceService {
*/ */
List<PsdcDevice> queryByUserId(Integer parent); List<PsdcDevice> queryByUserId(Integer parent);
List<PsdcDevice> queryByModel(String model);
List<PsdcDevice> selalldevModel();
/** /**
* 查询所有设备状态 * 查询所有设备状态
* @return * @return

@ -20,11 +20,11 @@ public interface IPsdcThermometerHtdataService {
AjaxResult selTodayThermometer(); AjaxResult selTodayThermometer();
AjaxResult sel8WnDu(Integer modelId); AjaxResult sel8WnDu(String modelId);
PsdcDevicePowerRes selTotalElectricityInfo(Integer deviceId); PsdcDevicePowerRes selTotalElectricityInfo(Integer deviceId);
List selTodayThermometerById(Integer modelId); List selTodayThermometerById(String modelId);
AjaxResult selDzglWenDu(Integer deviceId); AjaxResult selDzglWenDu(Integer deviceId);

@ -23,6 +23,7 @@ public class PsdcControlLogServiceImpl implements IPsdcControlLogService {
* @param controlLogId 主键 * @param controlLogId 主键
* @return 实例对象 * @return 实例对象
*/ */
@Override
public PsdcControlLog queryById(Integer controlLogId){ public PsdcControlLog queryById(Integer controlLogId){
return psdcControlLogMapper.queryById(controlLogId); return psdcControlLogMapper.queryById(controlLogId);
} }
@ -35,6 +36,7 @@ public class PsdcControlLogServiceImpl implements IPsdcControlLogService {
* @param psdcControlLog 实例对象 * @param psdcControlLog 实例对象
* @return 实例对象 * @return 实例对象
*/ */
@Override
public PsdcControlLog insert(PsdcControlLog psdcControlLog){ public PsdcControlLog insert(PsdcControlLog psdcControlLog){
psdcControlLogMapper.insert(psdcControlLog); psdcControlLogMapper.insert(psdcControlLog);
return psdcControlLog; return psdcControlLog;
@ -46,6 +48,7 @@ public class PsdcControlLogServiceImpl implements IPsdcControlLogService {
* @param psdcControlLog 实例对象 * @param psdcControlLog 实例对象
* @return 实例对象 * @return 实例对象
*/ */
@Override
public PsdcControlLog update(PsdcControlLog psdcControlLog){ public PsdcControlLog update(PsdcControlLog psdcControlLog){
psdcControlLogMapper.update(psdcControlLog); psdcControlLogMapper.update(psdcControlLog);
return queryById(psdcControlLog.getControlLogId()); return queryById(psdcControlLog.getControlLogId());
@ -57,6 +60,7 @@ public class PsdcControlLogServiceImpl implements IPsdcControlLogService {
* @param controlLogId 主键 * @param controlLogId 主键
* @return 是否成功 * @return 是否成功
*/ */
@Override
public boolean deleteById(Integer controlLogId){ public boolean deleteById(Integer controlLogId){
int total = psdcControlLogMapper.deleteById(controlLogId); int total = psdcControlLogMapper.deleteById(controlLogId);
return total > 0; return total > 0;

@ -64,6 +64,16 @@ public class PsdcDeviceServiceImpl implements IPsdcDeviceService {
return psdcDeviceMapper.queryByUserId(SecurityUtils.getUserId(), parent); return psdcDeviceMapper.queryByUserId(SecurityUtils.getUserId(), parent);
} }
@Override
public List<PsdcDevice> queryByModel(String model) {
return psdcDeviceMapper.queryByModel(SecurityUtils.getUserId(), model);
}
@Override
public List<PsdcDevice> selalldevModel() {
return psdcDeviceMapper.queryByUserId(null, null);
}
public List<DeviceStatusVo> queryDeviceStatus() { public List<DeviceStatusVo> queryDeviceStatus() {
List<PsdcDevice> psdcDevices = psdcDeviceMapper.queryByUserId(SecurityUtils.getUserId(), 0); List<PsdcDevice> psdcDevices = psdcDeviceMapper.queryByUserId(SecurityUtils.getUserId(), 0);
return psdcDevices.stream().map(psdcDevice -> { return psdcDevices.stream().map(psdcDevice -> {

@ -96,7 +96,7 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
} }
@Override @Override
public AjaxResult sel8WnDu(Integer modelId) { public AjaxResult sel8WnDu(String modelId) {
List<PsdcThermometerDataRes> dataResList = psdcThermometerRtdataMapper.selWenDu(SecurityUtils.getUserId(), modelId, sdf.format(new Date())); List<PsdcThermometerDataRes> dataResList = psdcThermometerRtdataMapper.selWenDu(SecurityUtils.getUserId(), modelId, sdf.format(new Date()));
return AjaxResult.success(dataResList); return AjaxResult.success(dataResList);
} }
@ -116,7 +116,7 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
} }
@Override @Override
public List<Map> selTodayThermometerById(Integer modelId) { public List<Map> selTodayThermometerById(String modelId) {
Date date = new Date(); Date date = new Date();
String tb = sdf.format(date) + " 00:00:00"; // 今天开始检索时间 String tb = sdf.format(date) + " 00:00:00"; // 今天开始检索时间
String te = sdf.format(date) + " 23:59:59"; // 今天结束检索时间 String te = sdf.format(date) + " 23:59:59"; // 今天结束检索时间

@ -25,11 +25,14 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.function.Function;
/** /**
* 定时控制任务表;(psdc_timer)表服务实现类 * 定时控制任务表;(psdc_timer)表服务实现类
* @date : 2023-5-10 *
* @date : 2023-5-10
*/ */
@Service @Service
@Slf4j @Slf4j
@ -43,48 +46,51 @@ public class PsdcTimerServiceImpl implements IPsdcTimerService {
@Resource @Resource
private IPsdcDeviceService psdcDeviceService; private IPsdcDeviceService psdcDeviceService;
/** /**
* 通过ID查询单条数据 * 通过ID查询单条数据
* *
* @param timerId 主键 * @param timerId 主键
* @return 实例对象 * @return 实例对象
*/ */
public PsdcTimerVo queryById(Integer timerId){ @Override
public PsdcTimerVo queryById(Integer timerId) {
return psdcTimerMapper.queryById2(timerId); return psdcTimerMapper.queryById2(timerId);
} }
/** /**
* 新增数据 * 新增数据
* *
* @param psdcTimer 实例对象 * @param psdcTimer 实例对象
* @return 实例对象 * @return 实例对象
*/ */
public PsdcTimer insert(PsdcTimer psdcTimer){ @Override
public PsdcTimer insert(PsdcTimer psdcTimer) {
psdcTimerMapper.insert(psdcTimer); psdcTimerMapper.insert(psdcTimer);
return psdcTimer; return psdcTimer;
} }
/** /**
* 更新数据 * 更新数据
* *
* @param psdcTimer 实例对象 * @param psdcTimer 实例对象
* @return 实例对象 * @return 实例对象
*/ */
public PsdcTimerVo update(PsdcTimer psdcTimer){ @Override
public PsdcTimerVo update(PsdcTimer psdcTimer) {
psdcTimerMapper.update(psdcTimer); psdcTimerMapper.update(psdcTimer);
return queryById(psdcTimer.getTimerId()); return queryById(psdcTimer.getTimerId());
} }
/** /**
* 通过主键删除数据 * 通过主键删除数据
* *
* @param timerId 主键 * @param timerId 主键
* @return 是否成功 * @return 是否成功
*/ */
public boolean deleteById(Integer timerId){ @Override
public boolean deleteById(Integer timerId) {
int total = psdcTimerMapper.deleteById(timerId); int total = psdcTimerMapper.deleteById(timerId);
return total > 0; return total > 0;
} }
@ -92,124 +98,135 @@ public class PsdcTimerServiceImpl implements IPsdcTimerService {
@Override @Override
public List<PsdcTimerVo> query(PsdcTimerRequest psdcTimerRequest) { public List<PsdcTimerVo> query(PsdcTimerRequest psdcTimerRequest) {
psdcTimerRequest.setUserId(SecurityUtils.getUserId()); psdcTimerRequest.setUserId(SecurityUtils.getUserId());
return psdcTimerMapper.queryAllByLimit(psdcTimerRequest); List<PsdcTimerVo> 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 请求类 * @param psdcTimerRunTimeRequest 请求类
* @return int * @return int
*/ */
@Override @Override
@Transactional @Transactional
public Integer addTimer(PsdcTimerRunTimeRequest psdcTimerRunTimeRequest) { public Integer addTimer(PsdcTimerRunTimeRequest psdcTimerRunTimeRequest) {
//获取psdcTimerRunTimeRequest中的timeList数组,根据内容拼出cron表达式 // 获取psdcTimerRunTimeRequest中的timeList数组,根据内容拼出cron表达式
String runDay = psdcTimerRunTimeRequest.getRunday(); String runDay = psdcTimerRunTimeRequest.getRunday();
String runtime = psdcTimerRunTimeRequest.getRuntime(); String runtime = psdcTimerRunTimeRequest.getRuntime();
//设置cron表达式 // 设置cron表达式
String[] cronArr = new String[7]; String[] cronArr = new String[7];
//秒,默认为每分钟的0秒 // 秒,默认为每分钟的0秒
if (runtime == null || !runtime.contains(":") ){ if (runtime == null || !runtime.contains(":")) {
throw new ServiceException("设定执行时间错误,创建定时任务失败,设定时间为:"+runtime); throw new ServiceException("设定执行时间错误,创建定时任务失败,设定时间为:" + runtime);
} }
if (runDay == null || "".equals(runDay)) { if (runDay == null || "".equals(runDay)) {
throw new ServiceException("设定日期错误,创建定时任务失败,设定日期为:" + runDay); throw new ServiceException("设定日期错误,创建定时任务失败,设定日期为:" + runDay);
} }
Integer deviceId = psdcTimerRunTimeRequest.getDeviceId(); Integer deviceId = psdcTimerRunTimeRequest.getDeviceId();
PsdcDevice psdcDevice = psdcDeviceService.queryById(deviceId); PsdcDevice psdcDevice = psdcDeviceService.queryById(deviceId);
if(psdcDevice == null){ if (psdcDevice == null) {
throw new ServiceException("创建定时任务失败,未找到该设备"); throw new ServiceException("创建定时任务失败,未找到该设备");
} }
if (psdcDevice.getIsControl() != 2 ){ if (psdcDevice.getIsControl() != 2) {
throw new ControlException("该设备无法控制,请联系管理员"); throw new ControlException("该设备无法控制,请联系管理员");
} }
String[] split1 = runtime.split(":"); String[] split1 = runtime.split(":");
cronArr[0] = "0"; cronArr[0] = "0";
//分 //
cronArr[1] = split1[1]; cronArr[1] = split1[1];
//时 //
cronArr[2] = split1[0]; cronArr[2] = split1[0];
/* /*
接下来拼装日月或周只有三种情况 接下来拼装日月或周只有三种情况
*/ */
if(runDay.equals("0")){ if (runDay.equals("0")) {
//每天的情况 // 每天的情况
//日 //
cronArr[3] = "*"; cronArr[3] = "*";
//月 //
cronArr[4] = "*"; cronArr[4] = "*";
//周 //
cronArr[5] = "?"; cronArr[5] = "?";
} else if (runDay.length() == 10 && (runDay.contains("-"))) { } else if (runDay.length() == 10 && (runDay.contains("-"))) {
//设定日期情况,就是一次的情况 // 设定日期情况,就是一次的情况
String[] split = runDay.split("-"); String[] split = runDay.split("-");
//日 //
cronArr[3] = split[2]; cronArr[3] = split[2];
//月 //
cronArr[4] = split[1]; cronArr[4] = split[1];
//周 //
cronArr[5] = "?"; cronArr[5] = "?";
} else if (runDay.contains(",")) { } else if (runDay.contains(",")) {
//设定星期情况 // 设定星期情况
String[] split = runDay.split("-"); String[] split = runDay.split("-");
//日 //
cronArr[3] = "?"; cronArr[3] = "?";
//月 //
cronArr[4] = "*"; cronArr[4] = "*";
//周 //
cronArr[5] = StringUtils.join(split,","); cronArr[5] = StringUtils.join(split, ",");
} else { } else {
throw new ServiceException("设定日期错误,创建定时任务失败,设定日期为:" + runDay); throw new ServiceException("设定日期错误,创建定时任务失败,设定日期为:" + runDay);
} }
//年,。暂时不用 // 年,。暂时不用
// cronArr[6] = // cronArr[6] =
String cron = StringUtils.join(cronArr, " "); String cron = StringUtils.join(cronArr, " ");
log.info("cron表达式:{}",cron); log.info("cron表达式:{}", cron);
try { try {
/* /*
创建job对象往quartz中插入执行的任务拿到jobId 创建job对象往quartz中插入执行的任务拿到jobId
*/ */
SysJob job = new SysJob(); SysJob job = new SysJob();
//设备id + 控制键 + 控制值 + 控制日期 + 控制时间 + // 设备id + 控制键 + 控制值 + 控制日期 + 控制时间 +
String jobName = psdcTimerRunTimeRequest.getDeviceId() + "+" + ControlKeyEnum.getControlContext(psdcTimerRunTimeRequest.getControlKey()) + "-" + String jobName = psdcTimerRunTimeRequest.getDeviceId() + "+" + ControlKeyEnum.getControlContext(psdcTimerRunTimeRequest.getControlKey()) + "-" +
psdcTimerRunTimeRequest.getControlValue() + "+" + psdcTimerRunTimeRequest.getRunday() + "+" + psdcTimerRunTimeRequest.getRuntime() + "+" + System.currentTimeMillis(); psdcTimerRunTimeRequest.getControlValue() + "+" + psdcTimerRunTimeRequest.getRunday() + "+" + psdcTimerRunTimeRequest.getRuntime() + "+" + System.currentTimeMillis();
job.setJobName(jobName); job.setJobName(jobName);
//默认 // 默认
job.setJobGroup("psdc"); job.setJobGroup("psdc");
String controlKey = psdcTimerRunTimeRequest.getControlKey(); String controlKey = psdcTimerRunTimeRequest.getControlKey();
String jobClassName = ""; String jobClassName = "";
//判断控制指令 // 判断控制指令
if (controlKey.equals( "startandstop")){ if (controlKey.equals("startandstop")) {
//控制启停 // 控制启停
log.info("控制设备启停"); log.info("控制设备启停");
jobClassName = String.format("psdcDeviceServiceImpl.controlDeviceStartAndStop(%d,%d,'%s',%d))",psdcTimerRunTimeRequest.getDeviceId(),Integer.valueOf(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") ) { } 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.setTemperature(%d,'%s','%s','%s',%d))", psdcTimerRunTimeRequest.getDeviceId(), controlKey, psdcTimerRunTimeRequest.getControlValue(), SecurityUtils.getUsername(), 2);
} }
job.setInvokeTarget(jobClassName); job.setInvokeTarget(jobClassName);
//cron表达式 // cron表达式
job.setCronExpression(cron); job.setCronExpression(cron);
//执行错误放弃执行 // 执行错误放弃执行
job.setMisfirePolicy("3"); job.setMisfirePolicy("3");
//是否并发,不并发 // 是否并发,不并发
job.setConcurrent("1"); job.setConcurrent("1");
job.setCreateBy(SecurityUtils.getUsername()); job.setCreateBy(SecurityUtils.getUsername());
int i = jobService.insertJob(job); int i = jobService.insertJob(job);
SysJob job1 = null; SysJob job1 = null;
if( i > 0){ if (i > 0) {
job1 = jobService.selectJobByName(jobName); job1 = jobService.selectJobByName(jobName);
} else { } else {
throw new ServiceException("创建定时任务失败,请联系管理员"); throw new ServiceException("创建定时任务失败,请联系管理员");
} }
//将创建的任务插入psdcTimer表 // 将创建的任务插入psdcTimer表
PsdcTimer psdcTimer = new PsdcTimer(); PsdcTimer psdcTimer = new PsdcTimer();
BeanUtils.copyProperties(psdcTimerRunTimeRequest,psdcTimer); BeanUtils.copyProperties(psdcTimerRunTimeRequest, psdcTimer);
psdcTimer.setUserId(SecurityUtils.getUserId().intValue()); psdcTimer.setUserId(SecurityUtils.getUserId().intValue());
psdcTimer.setControlContext( ControlKeyEnum.getControlContext(psdcTimerRunTimeRequest.getControlKey())); psdcTimer.setControlContext(ControlKeyEnum.getControlContext(psdcTimerRunTimeRequest.getControlKey()));
psdcTimer.setCronText(cron); psdcTimer.setCronText(cron);
psdcTimer.setJobId(job1.getJobId().intValue()); psdcTimer.setJobId(job1.getJobId().intValue());
psdcTimer.setTimerStatus(Integer.valueOf(job1.getStatus())); psdcTimer.setTimerStatus(Integer.valueOf(job1.getStatus()));
@ -222,21 +239,20 @@ public class PsdcTimerServiceImpl implements IPsdcTimerService {
} }
} }
@Override @Override
@Transactional @Transactional
public int updateStatus(Integer timerId, Integer status) throws SchedulerException { public int updateStatus(Integer timerId, Integer status) throws SchedulerException {
//获取jobId // 获取jobId
PsdcTimer psdcTimer = psdcTimerMapper.queryById(timerId); PsdcTimer psdcTimer = psdcTimerMapper.queryById(timerId);
//修改quartz状态 // 修改quartz状态
SysJob job = new SysJob(); SysJob job = new SysJob();
job.setStatus(status.toString()); job.setStatus(status.toString());
job.setJobId(psdcTimer.getJobId().longValue()); job.setJobId(psdcTimer.getJobId().longValue());
job.setJobGroup("psdc"); job.setJobGroup("psdc");
int i = jobService.changeStatus(job); int i = jobService.changeStatus(job);
if (i > 0){ if (i > 0) {
return psdcTimerMapper.updateStatus(timerId, status); return psdcTimerMapper.updateStatus(timerId, status);
} else { } else {
throw new ServiceException("修改定时任务状态失败"); throw new ServiceException("修改定时任务状态失败");
@ -246,17 +262,13 @@ public class PsdcTimerServiceImpl implements IPsdcTimerService {
@Override @Override
@Transactional @Transactional
public Integer delete(Integer timerId) throws SchedulerException { public Integer delete(Integer timerId) throws SchedulerException {
//获取jobId // 获取jobId
PsdcTimer psdcTimer = psdcTimerMapper.queryById(timerId); PsdcTimer psdcTimer = psdcTimerMapper.queryById(timerId);
//删除quartz任务 // 删除quartz任务
SysJob job = new SysJob(); SysJob job = new SysJob();
job.setJobId(psdcTimer.getJobId().longValue()); job.setJobId(psdcTimer.getJobId().longValue());
job.setJobGroup("psdc"); job.setJobGroup("psdc");
int i = jobService.deleteJob(job); int i = jobService.deleteJob(job);
if (i > 0){ return psdcTimerMapper.deleteById(timerId);
return psdcTimerMapper.deleteById(timerId);
} else {
throw new ServiceException("删除定时任务失败");
}
} }
} }

@ -46,6 +46,7 @@
<result property="tempIn" column="thermometer_value_in" /> <result property="tempIn" column="thermometer_value_in" />
<result property="tempOut" column="thermometer_value_out" /> <result property="tempOut" column="thermometer_value_out" />
<result property="totWh" column="TotWh" /> <result property="totWh" column="TotWh" />
<result property="isControl" column="is_control" />
<result property="deviceAddress" column="device_address" /> <result property="deviceAddress" column="device_address" />
<result property="startTime" column="start_time" /> <result property="startTime" column="start_time" />
<result property="deviceStatus" column="device_status" /> <result property="deviceStatus" column="device_status" />
@ -101,18 +102,31 @@
And parent_id = #{parentId} And parent_id = #{parentId}
</if> </if>
</where> </where>
GROUP BY device_model
</select>
<select id="queryByModel" resultMap="PsdcDeviceMap">
Select * From psdc_device
<where>
<if test="userId != null and userId != ''">
And user_id = #{userId}
</if>
<if test="devModel != null and devModel != ''">
and device_model = #{devModel}
</if>
</where>
</select> </select>
<!--分页查询指定行数据--> <!--分页查询指定行数据 Where !(device_model = "温度传感器" And parent_id = 0) -->
<select id="queryAllByLimit" resultMap="PsdcDeviceMap3"> <select id="queryAllByLimit" resultMap="PsdcDeviceMap3">
Select Select
pd.device_id, device_name, device_address, device_status, device_runstatus, parent_id, device_model, su.user_id, su.user_name, pd.device_id, device_name, device_address, device_status, device_runstatus, parent_id, device_model, su.user_id, su.user_name, is_control,
device_sn, per.TotP, per.TotWh, start_time, ptr.thermometer_value, ptr.thermometer_value_in, ptr.thermometer_value_out device_sn, per.TotP, per.TotWh, start_time, ptr.thermometer_value, ptr.thermometer_value_in, ptr.thermometer_value_out
From psdc_device pd From psdc_device pd
Left Join sys_user su On su.user_id = pd.user_id Left Join sys_user su On su.user_id = pd.user_id
Left Join psdc_electric_rtdata per On per.device_id = pd.device_id Left Join psdc_electric_rtdata per On per.device_id = pd.device_id
Left Join psdc_thermometer_rtdata ptr On ptr.device_id = pd.device_id Left Join psdc_thermometer_rtdata ptr On ptr.device_id = pd.device_id
Where !(device_model = "温度传感器" And parent_id = 0) <where>
<if test="deviceId != null and deviceId != ''"> <if test="deviceId != null and deviceId != ''">
and pd.device_id = #{deviceId} and pd.device_id = #{deviceId}
</if> </if>
@ -161,6 +175,7 @@
<if test="updateTime != null and updateTime != ''"> <if test="updateTime != null and updateTime != ''">
and update_time = #{updateTime} and update_time = #{updateTime}
</if> </if>
</where>
Order by pd.device_id Order by pd.device_id
</select> </select>

@ -40,7 +40,7 @@
From psdc_device pd From psdc_device pd
LEFT join psdc_thermometer_rtdata ptr on pd.device_id = ptr.device_id LEFT join psdc_thermometer_rtdata ptr on pd.device_id = ptr.device_id
And DATE_FORMAT(ptr.update_time,'%Y-%m-%d %H') = #{today} 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}
</select> </select>
<!--分页查询指定行数据--> <!--分页查询指定行数据-->

@ -54,7 +54,7 @@
</select> </select>
<!--分页查询指定行数据--> <!--分页查询指定行数据-->
<select id="queryAllByLimit" resultMap="PsdcTimerMap"> <select id="queryAllByLimit" resultMap="PsdcTimerVoMap">
select 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 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 from psdc_timer pt left join psdc_device pd on pt.device_id = pd.device_id

@ -3,10 +3,7 @@ package com.psdc.controller.index;
import com.psdc.core.domain.AjaxResult; import com.psdc.core.domain.AjaxResult;
import com.psdc.service.IPsdcThermometerHtdataService; import com.psdc.service.IPsdcThermometerHtdataService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@ -21,9 +18,9 @@ public class Index {
return psdcThermometerHtdataService.selTodayThermometer(); return psdcThermometerHtdataService.selTodayThermometer();
} }
@RequestMapping(value = "/8wd/{modelId}", method = RequestMethod.GET) @RequestMapping(value = "/8wd", method = RequestMethod.POST)
public AjaxResult sel8WenDu(@PathVariable(value = "modelId", required = false) Integer modelId) { public AjaxResult sel8WenDu(@RequestParam(value="modelTypeName", defaultValue="") String modelname) {
return psdcThermometerHtdataService.sel8WnDu(modelId); return psdcThermometerHtdataService.sel8WnDu(modelname);
} }
@RequestMapping(value = "/zdb/{modelId}", method = RequestMethod.GET) @RequestMapping(value = "/zdb/{modelId}", method = RequestMethod.GET)

@ -70,7 +70,7 @@ public class PsdcDeviceController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:device:list')") @PreAuthorize("@ss.hasPermi('system:device:list')")
@Log(title = "设备管理", businessType = BusinessType.DELETE) @Log(title = "设备管理", businessType = BusinessType.DELETE)
@DeleteMapping @RequestMapping(value = "/del", method = RequestMethod.POST)
public AjaxResult remove(@Validated @RequestBody Long[] deviceIds) { public AjaxResult remove(@Validated @RequestBody Long[] deviceIds) {
return toAjax(psdcDeviceService.deleteById(deviceIds)); return toAjax(psdcDeviceService.deleteById(deviceIds));
} }
@ -90,6 +90,20 @@ public class PsdcDeviceController extends BaseController {
return AjaxResult.success("用户下拉列表", maps); return AjaxResult.success("用户下拉列表", maps);
} }
@PreAuthorize("@ss.hasPermi('system:device:list')")
@RequestMapping(value = "/selmodels", method = RequestMethod.GET)
public AjaxResult selAllModels() {
List<Map> maps = new ArrayList<>();
List<PsdcDevice> list = psdcDeviceService.selalldevModel();
for (PsdcDevice dd : list){
Map<String, Object> 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')") @PreAuthorize("@ss.hasPermi('system:device:list')")
@RequestMapping(value = "/devicesList", method = RequestMethod.POST) @RequestMapping(value = "/devicesList", method = RequestMethod.POST)
public TableDataInfo controlLogList(@RequestBody JSONObject jsonObject) { public TableDataInfo controlLogList(@RequestBody JSONObject jsonObject) {

@ -46,9 +46,8 @@ public class TotalElectricMeterController {
for (PsdcDevice dd : list){ for (PsdcDevice dd : list){
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("modelName", dd.getDeviceModel()); map.put("modelName", dd.getDeviceModel());
map.put("modelId", dd.getDeviceId());
List<Map> maps2 = new ArrayList<>(); List<Map> maps2 = new ArrayList<>();
List<PsdcDevice> list2 = psdcDeviceService.queryByUserId(dd.getDeviceId()); List<PsdcDevice> list2 = psdcDeviceService.queryByModel(dd.getDeviceModel());
if (list2.size() > 0){ if (list2.size() > 0){
for (PsdcDevice dev : list2){ for (PsdcDevice dev : list2){
Map<String, Object> map2 = new HashMap<>(); Map<String, Object> map2 = new HashMap<>();

@ -4,10 +4,7 @@ import com.psdc.core.domain.AjaxResult;
import com.psdc.service.IPsdcThermometerHtdataService; import com.psdc.service.IPsdcThermometerHtdataService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @Author戴仕崑 * @Author戴仕崑
@ -24,9 +21,9 @@ public class WenDuController {
IPsdcThermometerHtdataService psdcThermometerHtdataService; IPsdcThermometerHtdataService psdcThermometerHtdataService;
@PreAuthorize("@ss.hasPermi('emonitor:wdcgq')") @PreAuthorize("@ss.hasPermi('emonitor:wdcgq')")
@RequestMapping(value = "/sel1/{modelId}", method = RequestMethod.GET) @RequestMapping(value = "/sel1", method = RequestMethod.POST)
public AjaxResult selwd(@PathVariable(value = "modelId", required = false) Integer modelId){ public AjaxResult selwd(@RequestParam(value="modelTypeName", defaultValue="") String modelname){
return AjaxResult.success(psdcThermometerHtdataService.selTodayThermometerById(modelId)); return AjaxResult.success(psdcThermometerHtdataService.selTodayThermometerById(modelname));
} }
} }

Loading…
Cancel
Save