| | |
| | | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.StringTools; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.BaseParamMapper; |
| | | import com.doumee.dao.business.BikesMapper; |
| | | import com.doumee.dao.business.join.BikesJoinMapper; |
| | | import com.doumee.dao.business.model.*; |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.doumee.service.system.SystemDictDataService; |
| | | import com.github.xiaoymin.knife4j.core.util.StrUtil; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private BikesMapper bikesMapper; |
| | | @Autowired |
| | | private BaseParamMapper baseParamMapper; |
| | | @Autowired |
| | | private BikesJoinMapper bikesJoinMapper; |
| | | |
| | | |
| | |
| | | |
| | | @Override |
| | | public String create(Bikes bikes) { |
| | | if(StringUtils.isBlank(bikes.getParamId() ) |
| | | ||StringUtils.isBlank(bikes.getCode()) |
| | | ||StringUtils.isBlank(bikes.getDeviceSn())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | if(baseParamMapper.selectCount(new QueryWrapper<BaseParam>().lambda().eq(BaseParam::getIsdeleted,Constants.ZERO) |
| | | .eq(BaseParam::getType,Constants.FOUR)) ==0){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,请选择正确的电车类型!"); |
| | | } |
| | | QueryWrapper<Bikes> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Bikes::getCode,bikes.getCode()) |
| | | .eq(Bikes::getIsdeleted,Constants.ZERO) |
| | | .eq(Bikes::getType,Constants.ONE); |
| | | Integer count = bikesMapper.selectCount(wrapper); |
| | | if (count > 0){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"车牌号号已存在"); |
| | | } |
| | | LoginUserInfo user =(LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | bikes.setId(UUID.randomUUID().toString()); |
| | | bikes.setCreateDate(new Date()); |
| | | bikes.setCreator(user.getId()); |
| | | bikes.setEditDate(bikes.getCreateDate()); |
| | | bikes.setEditor(user.getId()); |
| | | bikes.setStatus(Constants.ZERO); |
| | | bikes.setIsdeleted(Constants.ZERO); |
| | | bikes.setType(Constants.ONE);//只能新增电车数据 |
| | | bikesMapper.insert(bikes); |
| | | return bikes.getId(); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void updateById(Bikes bikes) { |
| | | QueryWrapper<Bikes> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Bikes::getCode,bikes.getCode()) |
| | | .eq(Bikes::getIsdeleted,Constants.ZERO) |
| | | .ne(Bikes::getId,bikes.getId()) |
| | | .eq(Bikes::getType,Constants.ONE); |
| | | Integer count = bikesMapper.selectCount(wrapper); |
| | | if (count > 0){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"车牌号号已存在"); |
| | | } |
| | | if(StringUtils.isNotBlank(bikes.getParamId()) && |
| | | baseParamMapper.selectCount(new QueryWrapper<BaseParam>().lambda().eq(BaseParam::getIsdeleted,Constants.ZERO) |
| | | .eq(BaseParam::getType,Constants.FOUR)) ==0){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,请选择正确的电车类型!"); |
| | | } |
| | | LoginUserInfo user =(LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | bikes.setEditDate(new Date()); |
| | | bikes.setEditor(user.getId()); |
| | | bikes.setStatus(Constants.ZERO); |
| | | bikes.setIsdeleted(Constants.ZERO); |
| | | bikes.setType(null);//只能新增电车数据 |
| | | bikesMapper.updateById(bikes); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public Bikes findById(String id) { |
| | | return bikesMapper.selectById(id); |
| | | } |
| | | @Override |
| | | public void updateByJtt( Bikes m){ |
| | | if(StringUtils.isBlank(m.getDeviceSn() )){ |
| | | return; |
| | | } |
| | | String tSn = StringTools.leftPad(m.getDeviceSn(),12,'0') ; |
| | | Bikes bikes = bikesJoinMapper.selectOne(new QueryWrapper<Bikes>().lambda() |
| | | .eq(Bikes::getDeviceSn,tSn) |
| | | .eq(Bikes::getIsdeleted,Constants.ZERO) |
| | | .eq(Bikes::getType,Constants.ONE) |
| | | .last("limit 1")); |
| | | if(bikes == null){ |
| | | return; |
| | | } |
| | | bikesJoinMapper.update(null,new UpdateWrapper<Bikes>().lambda() |
| | | .set(m.getLatitude()!=null,Bikes::getLatitude,m.getLatitude()) |
| | | .set(m.getVoltage()!=null,Bikes::getVoltage,m.getVoltage()) |
| | | .set(m.getLongitude()!=null,Bikes::getLongitude,m.getLongitude()) |
| | | .set(m.getHeartDate()!=null,Bikes::getHeartDate,m.getHeartDate()) |
| | | .eq(Bikes::getId,bikes.getId())); |
| | | } |
| | | |
| | | @Override |
| | |
| | | .leftJoin(Sites.class,Sites::getId,Bikes::getSiteId) |
| | | .like(StringUtils.isNotBlank(pageWrap.getModel().getSiteId()),Bikes::getSiteId,pageWrap.getModel().getSiteId()) |
| | | .like(StringUtils.isNotBlank(pageWrap.getModel().getSiteName()), Sites::getName,pageWrap.getModel().getSiteName()) |
| | | .like( pageWrap.getModel().getLockId() !=null,Bikes::getLockId,pageWrap.getModel().getLockId()) |
| | | .ne(Bikes::getLockId,collect.get(Constants.FORCE_BACK_LOCK).getCode()) |
| | | .eq( pageWrap.getModel().getLockId() !=null,Bikes::getLockId,pageWrap.getModel().getLockId()) |
| | | .ne(Bikes::getLockId,Constants.formatIntegerFromStr(collect.get(Constants.FORCE_BACK_LOCK).getCode())) |
| | | .ne(Bikes::getSiteId,collect.get(Constants.FORCE_BACK_SITE).getCode()) |
| | | .isNull(Constants.formatIntegerNum(pageWrap.getModel().getHasBike()) == Constants.ONE,Bikes::getCode) |
| | | .eq(Constants.formatIntegerNum(pageWrap.getModel().getHasBike()) == Constants.ONE,Bikes::getCode,"") |
| | | .isNotNull(Constants.formatIntegerNum(pageWrap.getModel().getHasBike()) == Constants.TWO,Bikes::getCode) |
| | | .ne(Constants.formatIntegerNum(pageWrap.getModel().getHasBike()) == Constants.TWO,Bikes::getCode,""); |
| | | .and(Constants.formatIntegerNum(pageWrap.getModel().getHasBike()) == Constants.ONE, |
| | | s->s.isNull(Bikes::getCode) |
| | | .or(b->b.eq(Bikes::getCode,""))) |
| | | .and(Constants.formatIntegerNum(pageWrap.getModel().getHasBike()) == Constants.TWO,s->s |
| | | .isNotNull(Bikes::getCode) |
| | | .and(b->b.ne(Bikes::getCode,""))); |
| | | queryWrapper.selectAll(Bikes.class) |
| | | .selectAs(BaseParam::getName,Bikes::getParamName) |
| | | .selectAs(Sites::getName,Bikes::getSiteName) ; |