| | |
| | | |
| | | 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); |
| | | } |
| | | |
| | |
| | | if(StringUtils.isBlank(m.getDeviceSn() )){ |
| | | return; |
| | | } |
| | | String tSn = m.getDeviceSn(); |
| | | if(tSn.length() <12){ |
| | | for (int i = 0; i < 12-tSn.length(); i++) { |
| | | tSn = "0"+tSn; |
| | | } |
| | | } |
| | | 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) |