package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
import com.whyc.dto.Response;
|
import com.whyc.mapper.BattInfMapper;
|
import com.whyc.mapper.CircleInfMapper;
|
import com.whyc.pojo.Battinf;
|
import com.whyc.pojo.CircleInf;
|
import com.whyc.pojo.PowerInf;
|
import com.whyc.pojo.StationInf;
|
import org.springframework.stereotype.Service;
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import javax.annotation.Resource;
|
import java.util.List;
|
|
@Service
|
public class CircleInfService {
|
|
@Resource
|
private CircleInfMapper mapper;
|
|
@Resource
|
private BattInfMapper battInfMapper;
|
|
public int add(CircleInf circleInf){
|
return mapper.insert(circleInf);
|
}
|
|
public void updateByDeviceId(CircleInf circleInf){
|
UpdateWrapper<CircleInf> wrapper = new UpdateWrapper<CircleInf>().eq("device_id",circleInf.getDeviceId());
|
mapper.update(circleInf,wrapper);
|
}
|
|
public void deleteByDeviceId(Integer deviceId){
|
QueryWrapper<CircleInf> wrapper = new QueryWrapper<CircleInf>().eq("device_id",deviceId);
|
mapper.delete(wrapper);
|
}
|
//获取动环的设备id
|
public String getDeviceId() {
|
Integer devId = mapper.getMaxDeviceId();
|
if(devId==null||devId==0){
|
devId = 120*1000000;
|
}
|
devId+=1;
|
return String.valueOf(devId);
|
}
|
|
//获取动环信息
|
public Response getCinf(CircleInf cinf,int pageCurr,int pageSize) {
|
PageHelper.startPage(pageCurr,pageSize);
|
List<CircleInf> list=mapper.getCinf(cinf);
|
PageInfo pageInfo=new PageInfo(list);
|
return new Response().setII(1,list!=null,pageInfo,"获取动环信息");
|
}
|
//获取动环下拉资产信息
|
public Response getConditionCid() {
|
List<CircleInf> list=mapper.selectList(null);
|
return new Response().setII(1,list!=null,list,"获取动环下拉资产信息");
|
}
|
|
/**
|
* 新:从站点表校验站点是否存在
|
* 旧:电源添加前校验是否站点存在,从电池表+电源表查询,弃用
|
* */
|
public Battinf judgeBattStationName3(CircleInf cinf){
|
Battinf battinf = new Battinf();
|
battinf.setStationName1(cinf.getStationName1());
|
battinf.setStationName2(cinf.getStationName2());
|
battinf.setStationName3(cinf.getStationName3());
|
battinf.setStationName5(cinf.getStationName5());
|
|
return battInfMapper.judgeBattStationName3(battinf);
|
}
|
}
|