gunshi-project-ss/src/main/java/com/gunshi/project/xyt/service/GateValveRealService.java

74 lines
2.4 KiB
Java
Raw Normal View History

2024-07-08 17:47:02 +08:00
package com.gunshi.project.xyt.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.xyt.entity.vo.GateStautsVo;
import com.gunshi.project.xyt.mapper.GateValveRMapper;
2024-07-08 17:47:02 +08:00
import com.gunshi.project.xyt.mapper.GateValveRealMapper;
import com.gunshi.project.xyt.model.GateValveKey;
import com.gunshi.project.xyt.model.GateValveKeyAutoDao;
2024-07-08 17:47:02 +08:00
import com.gunshi.project.xyt.model.GateValveReal;
import com.gunshi.project.xyt.util.DateUtil;
import jakarta.annotation.Resource;
2024-07-08 17:47:02 +08:00
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
2024-07-08 17:47:02 +08:00
import java.util.Date;
import java.util.List;
2024-07-08 17:47:02 +08:00
/**
* :
* author: xusan
* date: 2024-07-08 17:30:37
*/
@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)
public class GateValveRealService extends ServiceImpl<GateValveRealMapper, GateValveReal>
{
@Resource
private GateValveKeyAutoDao gateValveKeyAutoDao;
@Resource
private GateValveRMapper gateValveRMapper;
2024-07-08 17:47:02 +08:00
public List<GateStautsVo> gateStatusList() {
List<GateStautsVo> list = baseMapper.gateStatusList();
for(GateStautsVo vo : list){
if(vo.getTm() != null && DateUtil.hoursBetweenDate(vo.getTm(), new Date()) > 2){
vo.setFlag(1);
}
}
return list;
}
public BigDecimal realQ(String valveCode) {
return baseMapper.realQ(valveCode);
}
public String control(GateValveKey gateValveKey) {
//先判断密码是否正确
String valveCode = gateValveKey.getValveCode();
String key = gateValveKey.getKey();
GateValveKey valveKey = gateValveKeyAutoDao.getById(valveCode);
if(valveKey == null || !key.equals(valveKey.getKey())){
throw new IllegalArgumentException("密码不正确");
}
2024-07-24 09:11:20 +08:00
//todo 给闸阀下发调节指令
// GateValveR gateValveR = new GateValveR();
// BeanUtils.copyProperties(gateValveKey,gateValveR);
// gateValveR.setTm(new Date());
// gateValveRMapper.insert(gateValveR);
//
// GateValveReal real = new GateValveReal();
// BeanUtils.copyProperties(gateValveKey,real);
// real.setTm(new Date());
// this.remove(new QueryWrapper<GateValveReal>().eq("valve_code",valveCode));
// this.save(real);
return "调节闸阀指令已下发";
}
2024-07-08 17:47:02 +08:00
}