| | |
| | | package com.fgkj.services; |
| | | |
| | | import com.fgkj.dto.Batt_Maint_Dealarm; |
| | | import com.fgkj.dto.ServiceModel; |
| | | import com.fgkj.dto.*; |
| | | import com.fgkj.mapper.impl.BattInfMapper; |
| | | import com.fgkj.mapper.impl.BattPower_offMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.fgkj.mapper.impl.BattPowerOffMapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | @Service |
| | | public class BattPower_offService { |
| | | |
| | | ServiceModel model = new ServiceModel(); |
| | | |
| | | @Resource |
| | | private BattPower_offMapper mapper; |
| | | private BattPowerOffMapper mapper; |
| | | @Resource |
| | | private BattInfMapper battInfMapper; |
| | | |
| | | public ServiceModel add(Object obj) { |
| | | Boolean bl=mapper.add(obj); |
| | | if(bl){ |
| | | public ServiceModel add(BattPower_off battPowerOff) { |
| | | ServiceModel model = new ServiceModel(); |
| | | int flag = mapper.insert(battPowerOff); |
| | | if (flag > 0) { |
| | | model.setCode(1); |
| | | model.setMsg("添加成功!"); |
| | | } |
| | | else{ |
| | | } else { |
| | | model.setMsg("添加失败!"); |
| | | } |
| | | return model; |
| | | |
| | | } |
| | | public ServiceModel update(Object obj) { |
| | | Boolean bl=mapper.update(obj); |
| | | if(bl){ |
| | | |
| | | public ServiceModel update(BattPower_off battPowerOff) { |
| | | ServiceModel model = new ServiceModel(); |
| | | |
| | | int flag = mapper.updateById(battPowerOff); |
| | | if (flag > 0) { |
| | | model.setCode(1); |
| | | model.setMsg("修改成功!"); |
| | | } |
| | | else{ |
| | | } else { |
| | | model.setMsg("修改失败!"); |
| | | } |
| | | return model; |
| | | } |
| | | public ServiceModel delete(Object obj) { |
| | | Boolean bl=mapper.del(obj); |
| | | if(bl){ |
| | | |
| | | public ServiceModel delete(int id) { |
| | | ServiceModel model = new ServiceModel(); |
| | | |
| | | int flag = mapper.deleteById(id); |
| | | if (flag > 0) { |
| | | model.setCode(1); |
| | | model.setMsg("删除成功!"); |
| | | } |
| | | else{ |
| | | } else { |
| | | model.setMsg("删除失败!"); |
| | | } |
| | | return model; |
| | | } |
| | | |
| | | //机房断电统计查询 |
| | | /* |
| | | * 时间段选择放在:binf的battproductdate*/ |
| | | public ServiceModel serchByCondition(Batt_Maint_Dealarm obj){ |
| | | List list=mapper.serchByCondition(obj); |
| | | |
| | | if(list!=null && list.size()>0){ |
| | | model.setCode(1); |
| | | model.setData(list); |
| | | model.setMsg("查询成功!"); |
| | | }else{ |
| | | model.setCode(0); |
| | | model.setMsg("查询失败!"); |
| | | } |
| | | |
| | | return model; |
| | | public ServiceModel getByCondition(BattInf battInf, PageBean page) { |
| | | PageHelper.startPage(page.getPageNum(), page.getPageSize(), true); |
| | | List<BattPower_off> powerOffs = mapper.getByCondition(battInf); |
| | | PageInfo<BattPower_off> pageInfo = new PageInfo<>(powerOffs); |
| | | return new ServiceModel().set(1,pageInfo); |
| | | } |
| | | |
| | | //机房断电统计(首页上的饼状图) |
| | | public ServiceModel serchPowerOff(Object obj){ |
| | | int powerNum=mapper.serchPowerOff(obj); //断电实时数 |
| | | int devNum=battInfMapper.serchByDeviceId(obj); //总设备数 |
| | | public ServiceModel serchPowerOff(User_inf userInf) { |
| | | int powerNum = mapper.serchPowerOff(userInf); //断电实时数 |
| | | int devNum = battInfMapper.serchByDeviceId(userInf); //总设备数 |
| | | //TODO perry |
| | | // model.setSum(powerNum); |
| | | // model.setNewsum(devNum); |
| | | return model; |
| | | HashMap<String, Integer> map = new HashMap<>(); |
| | | map.put("powerNum",powerNum); |
| | | map.put("devNum",devNum); |
| | | return new ServiceModel().set(1,map); |
| | | } |
| | | |
| | | |
| | | public ServiceModel searchAll(){ |
| | | List list=mapper.searchAll(); |
| | | for (Object object : list) { |
| | | System.out.println(object); |
| | | } |
| | | //System.out.println(list); |
| | | if(list!=null && list.size()>0){ |
| | | model.setCode(1); |
| | | model.setData(list); |
| | | } |
| | | System.out.println(model); |
| | | return model; |
| | | } |
| | | } |