|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.moral.api.entity.Divisor; | 
|---|
|  |  |  | import com.moral.api.entity.ManageAccount; | 
|---|
|  |  |  | import com.moral.api.mapper.DivisorMapper; | 
|---|
|  |  |  | import com.moral.api.pojo.redisBean.AccountInfoDTO; | 
|---|
|  |  |  | import com.moral.api.service.DivisorService; | 
|---|
|  |  |  | import com.moral.api.util.LogUtils; | 
|---|
|  |  |  | import com.moral.constant.Constants; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.util.TokenUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void insert(Divisor divisor) { | 
|---|
|  |  |  | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | AccountInfoDTO accountInfoDTO = (AccountInfoDTO) TokenUtils.getUserInfoByToken(token); | 
|---|
|  |  |  | ManageAccount manageAccount = accountInfoDTO.getAccount(); | 
|---|
|  |  |  | divisor.setIsDel(Constants.NOT_DELETE); | 
|---|
|  |  |  | divisor.setCreateTime(new Date()); | 
|---|
|  |  |  | divisor.setUpdateTime(new Date()); | 
|---|
|  |  |  | divisor.setCreateName(manageAccount.getUserName()); | 
|---|
|  |  |  | divisorMapper.insert(divisor); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void update(Divisor divisor) { | 
|---|
|  |  |  | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); | 
|---|
|  |  |  | String token = request.getHeader("token"); | 
|---|
|  |  |  | AccountInfoDTO accountInfoDTO = (AccountInfoDTO) TokenUtils.getUserInfoByToken(token); | 
|---|
|  |  |  | ManageAccount manageAccount = accountInfoDTO.getAccount(); | 
|---|
|  |  |  | Divisor divisor1 = divisorMapper.selectById(divisor.getId()); | 
|---|
|  |  |  | divisor.setUpdateTime(new Date()); | 
|---|
|  |  |  | divisor.setUpdateName(manageAccount.getUserName()); | 
|---|
|  |  |  | divisorMapper.updateById(divisor); | 
|---|
|  |  |  | //操作日志记录 | 
|---|
|  |  |  | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); | 
|---|
|  |  |  | StringBuilder content = new StringBuilder(); | 
|---|
|  |  |  | content.append("修改了"+divisor1.getMac()+"走航车高值范围"); | 
|---|
|  |  |  | content.append("修改了"+divisor1.getOrganizationId()+"走航车高值范围"); | 
|---|
|  |  |  | content.append(ObjectUtils.isEmpty(divisor.getDustld())?",尘负荷==>null":",尘负荷==>"+divisor.getDustld()); | 
|---|
|  |  |  | content.append(ObjectUtils.isEmpty(divisor.getCo())?",co==>null":",co==>"+divisor.getCo()); | 
|---|
|  |  |  | content.append(ObjectUtils.isEmpty(divisor.getSo2())?",so2==>null":",so2==>"+divisor.getSo2()); | 
|---|
|  |  |  | 
|---|
|  |  |  | content.append(ObjectUtils.isEmpty(divisor.getO3())?",o3==>null":",o3==>"+divisor.getO3()); | 
|---|
|  |  |  | LogUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 删除 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void delete(Integer id) { | 
|---|
|  |  |  | Divisor divisor = divisorMapper.selectById(id); | 
|---|
|  |  |  | divisor.setIsDel(Constants.DELETE); | 
|---|
|  |  |  | divisorMapper.updateById(divisor); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 详情 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Divisor queryById(Integer id) { | 
|---|
|  |  |  | Divisor divisor = divisorMapper.selectById(id); | 
|---|
|  |  |  | return divisor; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | HashMap<String, Object> result = new HashMap<>(); | 
|---|
|  |  |  | LambdaQueryWrapper<Divisor> wrapper = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | wrapper.eq(Divisor::getIsDel,Constants.NOT_DELETE); | 
|---|
|  |  |  | if (!ObjectUtils.isEmpty(mac)){ | 
|---|
|  |  |  | wrapper.like(Divisor::getMac,mac); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if (!ObjectUtils.isEmpty(mac)){ | 
|---|
|  |  |  | //            wrapper.like(Divisor::getMac,mac); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | Page<Divisor> PageList = new Page<>(Integer.parseInt(page), Integer.parseInt(size)); | 
|---|
|  |  |  | Page<Divisor> divisorPage = divisorMapper.selectPage(PageList, wrapper); | 
|---|
|  |  |  | result.put("total", PageList.getTotal()); | 
|---|