2024-07-08 17:47:02 +08:00
|
|
|
package com.gunshi.project.xyt.service;
|
|
|
|
|
|
2024-07-23 15:25:02 +08:00
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
2024-07-08 17:47:02 +08:00
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
2024-07-22 11:31:08 +08:00
|
|
|
import com.gunshi.project.xyt.entity.vo.GateStautsVo;
|
2024-07-23 15:25:02 +08:00
|
|
|
import com.gunshi.project.xyt.mapper.GateValveRMapper;
|
2024-07-08 17:47:02 +08:00
|
|
|
import com.gunshi.project.xyt.mapper.GateValveRealMapper;
|
2024-07-23 15:25:02 +08:00
|
|
|
import com.gunshi.project.xyt.model.GateValveKey;
|
|
|
|
|
import com.gunshi.project.xyt.model.GateValveKeyAutoDao;
|
|
|
|
|
import com.gunshi.project.xyt.model.GateValveR;
|
2024-07-08 17:47:02 +08:00
|
|
|
import com.gunshi.project.xyt.model.GateValveReal;
|
2024-07-22 11:31:08 +08:00
|
|
|
import com.gunshi.project.xyt.util.DateUtil;
|
2024-07-23 15:25:02 +08:00
|
|
|
import jakarta.annotation.Resource;
|
2024-07-08 17:47:02 +08:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2024-07-23 15:25:02 +08:00
|
|
|
import org.springframework.beans.BeanUtils;
|
2024-07-08 17:47:02 +08:00
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
2024-07-22 15:44:35 +08:00
|
|
|
import java.math.BigDecimal;
|
2024-07-08 17:47:02 +08:00
|
|
|
import java.util.Date;
|
2024-07-22 11:31:08 +08:00
|
|
|
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>
|
|
|
|
|
{
|
2024-07-23 15:25:02 +08:00
|
|
|
@Resource
|
|
|
|
|
private GateValveKeyAutoDao gateValveKeyAutoDao;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private GateValveRMapper gateValveRMapper;
|
2024-07-08 17:47:02 +08:00
|
|
|
|
2024-07-22 11:31:08 +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;
|
|
|
|
|
}
|
2024-07-22 15:44:35 +08:00
|
|
|
|
|
|
|
|
public BigDecimal realQ(String valveCode) {
|
|
|
|
|
return baseMapper.realQ(valveCode);
|
|
|
|
|
}
|
2024-07-23 15:25:02 +08:00
|
|
|
|
|
|
|
|
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("密码不正确");
|
|
|
|
|
}
|
|
|
|
|
//更新闸阀实时表和历史表
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|