| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.factory.TableInitFactory; |
| | | import com.whyc.mapper.PageParam2Mapper; |
| | | import com.whyc.mapper.PageParamMapper; |
| | | import com.whyc.pojo.PageParam; |
| | | import com.whyc.pojo.PageParam2; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | @Resource |
| | | private PageParamMapper mapper; |
| | | @Resource |
| | | private PageParam2Mapper param2Mapper; |
| | | |
| | | public Map<Integer, List<PageParam>> getAllList(int categoryId) { |
| | | QueryWrapper<PageParam> wrapper = Wrappers.query(); |
| | |
| | | |
| | | //在线监测-查询拓扑图状态的显示/查询控制信息 |
| | | public Response findByCategoryId(int categoryId) { |
| | | boolean res=mapper.exist(); |
| | | List<PageParam> listparam=TableInitFactory.getPageParamInit(); |
| | | if(!res) { //表不存在,新建表,同时初始化参数 |
| | | mapper.createTable(); |
| | | mapper.init(listparam); |
| | | }else { |
| | | int count=mapper.getCount(); |
| | | if(count==0){ |
| | | boolean inited = mapper.init(listparam); |
| | | } |
| | | } |
| | | List list=mapper.findByCategoryId(categoryId); |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().set(1,pageInfo); |
| | | } |
| | | |
| | | public Response update(int id,int status){ |
| | | //如果id为40(账号登录失败限制次数),status的取值范围必须为1~10 |
| | | if(id == 40 && (status < 1 || status >10)){ |
| | | return new Response().set(1,false,"账号登录失败限制次数不在1~10范围内,修改失败"); |
| | | } |
| | | int flag = mapper.update(id,status); |
| | | return new Response().set(1,flag>0?true:false); |
| | | } |
| | | |
| | | |
| | | public Response updateParamById(PageParam param){ |
| | | if (mapper.updateById(param)>0){ |
| | | return new Response().set(1,true,"更新成功"); |
| | | }else { |
| | | return new Response().set(1, false,"更新失败"); |
| | | } |
| | | } |
| | | |
| | | public Response getListByCategoryId(int categoryId){ |
| | | QueryWrapper<PageParam2> queryWrapper = new QueryWrapper(); |
| | | queryWrapper.eq("categoryId",categoryId); |
| | | List<PageParam2> param2List = param2Mapper.selectList(queryWrapper); |
| | | if (param2List.size()==1){ |
| | | return new Response().set(1,param2List.get(0)); |
| | | }else { |
| | | return new Response().set(1,param2List); |
| | | } |
| | | } |
| | | |
| | | public Response updateAudiCap(PageParam2 pageParam2){ |
| | | int flag = param2Mapper.updateById(pageParam2); |
| | | return new Response().set(1,flag>0?true:false,"更新成功"); |
| | | } |
| | | |
| | | public PageParam getParam(int id) { |
| | | return mapper.selectById(id); |
| | | } |
| | | |
| | | public Response updateStatusList(List<PageParam> pageParamList) { |
| | | mapper.updateStatusList(pageParamList); |
| | | return new Response().set(1, "更新完成"); |
| | | } |
| | | |
| | | //更新放电优化时间 |
| | | public Response updateHisTime(int id, int status) { |
| | | int flag = mapper.update(id, status); |
| | | return new Response().set(1, flag > 0 ? true : false); |
| | | } |
| | | |
| | | public List<PageParam> getList2ByCategoryId(int categoryId) { |
| | | QueryWrapper<PageParam> query = Wrappers.query(); |
| | | query.eq("categoryId",categoryId); |
| | | return mapper.selectList(query); |
| | | } |
| | | } |