|  |  |  | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.DateUtil; | 
|---|
|  |  |  | import com.doumee.dao.business.CategoryMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.JkCabinetGridMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.JkKeysMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.JkCabinetGrid; | 
|---|
|  |  |  | import com.doumee.dao.business.model.JkKeys; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.AdminCabinetVO; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.CabinetConfigDataVO; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.CabinetDetailVO; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.CabinetGridInfoVO; | 
|---|
|  |  |  | import com.doumee.dao.business.dao.MemberMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.*; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemDictData; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.LoginUserInfo; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.PageData; | 
|---|
|  |  |  | import com.doumee.service.business.third.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.dao.business.JkCabinetMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.JkCabinet; | 
|---|
|  |  |  | import com.doumee.service.business.JkCabinetService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | private JkCabinetMapper jkCabinetMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CategoryMapper categoryMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private JkCabinetGridMapper jkCabinetGridMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MemberMapper memberMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) | 
|---|
|  |  |  | 
|---|
|  |  |  | jkCabinet.setJwd(jkCabinet.getLongitude() + "," + jkCabinet.getLatitude()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | jkCabinet.setGridNum(jkCabinet.getColumnNum()*jkCabinet.getRowNum()); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(jkCabinet.getManagerId())){ | 
|---|
|  |  |  | jkCabinet.setManagerIdList(Arrays.asList( | 
|---|
|  |  |  | jkCabinet.getManagerId().split(",") | 
|---|
|  |  |  | )); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(jkCabinet.getAuthMemberId())){ | 
|---|
|  |  |  | jkCabinet.setAuthMemberIdList(Arrays.asList( | 
|---|
|  |  |  | jkCabinet.getAuthMemberId().split(",") | 
|---|
|  |  |  | )); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return jkCabinet; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | QueryWrapper<JkCabinet> wrapper = new QueryWrapper<>(jkCabinet); | 
|---|
|  |  |  | return jkCabinetMapper.selectList(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<JkCabinet> findPage(PageWrap<JkCabinet> pageWrap) { | 
|---|
|  |  |  | IPage<JkCabinet> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  | 
|---|
|  |  |  | List<JkCabinet> jkCabinetList = jkCabinetMapper.selectList(new QueryWrapper<JkCabinet>() | 
|---|
|  |  |  | .lambda() | 
|---|
|  |  |  | .eq(JkCabinet::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .apply(" FIND_IN_SET("+loginUserInfo.getId()+",MANAGER_ID) ") | 
|---|
|  |  |  | .apply(" FIND_IN_SET("+loginUserInfo.getMemberId()+",MANAGER_ID) ") | 
|---|
|  |  |  | .orderByAsc(JkCabinet::getCreateDate) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(jkCabinetList)){ | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public CabinetDetailVO getCabinetDetail(Integer cabinetId){ | 
|---|
|  |  |  | public CabinetDetailVO getCabinetDetail(Integer cabinetId,LoginUserInfo loginUserInfo){ | 
|---|
|  |  |  | CabinetDetailVO cabinetDetailVO = new CabinetDetailVO(); | 
|---|
|  |  |  | JkCabinet cabinet = jkCabinetMapper.selectOne(new QueryWrapper<JkCabinet>() | 
|---|
|  |  |  | .lambda() | 
|---|
|  |  |  | .eq(JkCabinet::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .apply(" FIND_IN_SET("+loginUserInfo.getMemberId()+",MANAGER_ID) ") | 
|---|
|  |  |  | .eq(JkCabinet::getId,cabinetId) | 
|---|
|  |  |  | .last(" limit 1") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | 
|---|
|  |  |  | cabinetDetailVO.setServiceKeyNum(Constants.ZERO); | 
|---|
|  |  |  | cabinetDetailVO.setOutKeyNum(Constants.ZERO); | 
|---|
|  |  |  | cabinetDetailVO.setUnBindGridNum(Constants.ZERO); | 
|---|
|  |  |  | cabinetDetailVO.setMemberId(loginUserInfo.getMemberId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //所有柜格信息 | 
|---|
|  |  |  | List<JkCabinetGrid> jkCabinetGridList = | 
|---|
|  |  |  | jkCabinetGridMapper.selectJoinList(JkCabinetGrid.class, new MPJLambdaWrapper<JkCabinetGrid>() | 
|---|
|  |  |  | .selectAll(JkCabinetGrid.class) | 
|---|
|  |  |  | .selectAs(JkKeys::getCarCode,JkCabinetGrid::getCarCode) | 
|---|
|  |  |  | .selectAs(JkKeys::getCode,JkCabinetGrid::getKeyCode) | 
|---|
|  |  |  | .selectAs(JkKeys::getStatus,JkCabinetGrid::getKeyStatus) | 
|---|
|  |  |  | .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId) | 
|---|
|  |  |  | .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(JkCabinetGrid::getCabinetId,cabinet.getId()) | 
|---|
|  |  |  | .orderByDesc(JkCabinetGrid::getCode) | 
|---|
|  |  |  | .orderByAsc(JkCabinetGrid::getCode) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<CabinetGridInfoVO> cabinetGridInfoVOList = new ArrayList<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | CabinetGridInfoVO cabinetGridInfoVO = new CabinetGridInfoVO(); | 
|---|
|  |  |  | BeanUtil.copyProperties(jkCabinetGrid,cabinetGridInfoVO); | 
|---|
|  |  |  | cabinetGridInfoVO.setBindStatus(Objects.isNull(jkCabinetGrid.getKeyId())?Constants.ZERO:Constants.ONE); | 
|---|
|  |  |  | cabinetGridInfoVO.setKeyStatus(Objects.isNull(cabinetGridInfoVO.getKeyStatus())?Constants.ZERO:cabinetGridInfoVO.getKeyStatus()); | 
|---|
|  |  |  | cabinetGridInfoVOList.add(cabinetGridInfoVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | cabinetDetailVO.setCabinetGridInfoVOList(cabinetGridInfoVOList); | 
|---|
|  |  |  | cabinetDetailVO.setErrGridNum( | 
|---|
|  |  |  | cabinetGridInfoVOList.stream().filter(i->Constants.equalsInteger(i.getWorkingStatus(),Constants.ONE)).collect(Collectors.toList()).size() | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public CabinetFaceVO getCabinetFaceVO(String code){ | 
|---|
|  |  |  | CabinetFaceVO cabinetFaceVO = new CabinetFaceVO(); | 
|---|
|  |  |  | List<CabinetFaceInfoVO> driverFaceList = new ArrayList<>(); | 
|---|
|  |  |  | List<CabinetFaceInfoVO> autoFaceList = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | JkCabinet jkCabinet = jkCabinetMapper.selectOne(new QueryWrapper<JkCabinet>().lambda() | 
|---|
|  |  |  | .eq(JkCabinet::getCode,code) | 
|---|
|  |  |  | .eq(JkCabinet::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .last("limit 1") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.nonNull(jkCabinet)){ | 
|---|
|  |  |  | String prefixUrl = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() + | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.FTP,Constants.MEMBER_IMG).getCode(); | 
|---|
|  |  |  | //查询司机信息 | 
|---|
|  |  |  | List<JkCabinetGrid> jkCabinetGridList = jkCabinetGridMapper.selectJoinList(JkCabinetGrid.class,new MPJLambdaWrapper<JkCabinetGrid>() | 
|---|
|  |  |  | .selectAll(JkCabinetGrid.class) | 
|---|
|  |  |  | .selectAs(JkKeys::getCarId,JkCabinetGrid::getCarId) | 
|---|
|  |  |  | .innerJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId) | 
|---|
|  |  |  | .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(JkKeys::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .isNotNull(JkKeys::getCarId) | 
|---|
|  |  |  | .eq(JkCabinetGrid::getCabinetId,jkCabinet.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(jkCabinetGridList)){ | 
|---|
|  |  |  | List<Integer> carIdList = jkCabinetGridList.stream().map(i->i.getKeyId()).collect(Collectors.toList()); | 
|---|
|  |  |  | //查询车辆所有人员信息 | 
|---|
|  |  |  | List<Member> memberList = memberMapper.selectJoinList(Member.class,new MPJLambdaWrapper<Member>() | 
|---|
|  |  |  | .selectAll(Member.class) | 
|---|
|  |  |  | .leftJoin(Cars.class,Cars::getMemberId,Member::getId) | 
|---|
|  |  |  | .leftJoin(JkKeys.class,JkKeys::getCarId,Cars::getId) | 
|---|
|  |  |  | .eq(Member::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(CarDriver::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(CarDriver::getStatus,Constants.ZERO) | 
|---|
|  |  |  | .isNotNull(Member::getFaceImg) | 
|---|
|  |  |  | .in(JkKeys::getId,carIdList) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(memberList)){ | 
|---|
|  |  |  | Set<Member> memberSet = new HashSet<>(memberList); | 
|---|
|  |  |  | for (Member member:memberSet) { | 
|---|
|  |  |  | CabinetFaceInfoVO cabinetFaceInfoVO = new CabinetFaceInfoVO(); | 
|---|
|  |  |  | cabinetFaceInfoVO.setMemberId(member.getId()); | 
|---|
|  |  |  | cabinetFaceInfoVO.setMemberName(member.getName()); | 
|---|
|  |  |  | cabinetFaceInfoVO.setFaceImg(prefixUrl + member.getFaceImg()); | 
|---|
|  |  |  | driverFaceList.add(cabinetFaceInfoVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询设备验证人员 | 
|---|
|  |  |  | List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda() | 
|---|
|  |  |  | .eq(Member::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .isNotNull(Member::getFaceImg) | 
|---|
|  |  |  | .apply(" FIND_IN_SET( id ,'"+jkCabinet.getManagerId()+"') ") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(memberList)){ | 
|---|
|  |  |  | for (Member member:memberList) { | 
|---|
|  |  |  | CabinetFaceInfoVO cabinetFaceInfoVO = new CabinetFaceInfoVO(); | 
|---|
|  |  |  | cabinetFaceInfoVO.setMemberId(member.getId()); | 
|---|
|  |  |  | cabinetFaceInfoVO.setMemberName(member.getName()); | 
|---|
|  |  |  | cabinetFaceInfoVO.setFaceImg(prefixUrl + member.getFaceImg()); | 
|---|
|  |  |  | autoFaceList.add(cabinetFaceInfoVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | cabinetFaceVO.setAutoFaceList(autoFaceList); | 
|---|
|  |  |  | cabinetFaceVO.setDriverFaceList(driverFaceList); | 
|---|
|  |  |  | return cabinetFaceVO; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public CabinetInfoVO getCabinetInfoForDriver(String code){ | 
|---|
|  |  |  | JkCabinet jkCabinet = jkCabinetMapper.selectOne(new QueryWrapper<JkCabinet>() | 
|---|
|  |  |  | .lambda() | 
|---|
|  |  |  | .eq(JkCabinet::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(JkCabinet::getCode,code) | 
|---|
|  |  |  | .orderByAsc(JkCabinet::getCreateDate) | 
|---|
|  |  |  | .last(" limit 1 ") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | CabinetInfoVO cabinetInfoVO = new CabinetInfoVO(); | 
|---|
|  |  |  | if(Objects.nonNull(jkCabinet)){ | 
|---|
|  |  |  | BeanUtil.copyProperties(jkCabinet,cabinetInfoVO); | 
|---|
|  |  |  | //所有柜格信息 | 
|---|
|  |  |  | List<JkCabinetGrid> jkCabinetGridList = | 
|---|
|  |  |  | jkCabinetGridMapper.selectJoinList(JkCabinetGrid.class, new MPJLambdaWrapper<JkCabinetGrid>() | 
|---|
|  |  |  | .selectAll(JkCabinetGrid.class) | 
|---|
|  |  |  | .selectAs(JkKeys::getCarCode,JkCabinetGrid::getCarCode) | 
|---|
|  |  |  | .selectAs(JkKeys::getStatus,JkCabinetGrid::getKeyStatus) | 
|---|
|  |  |  | .selectAs(JkKeys::getCode,JkCabinetGrid::getKeyCode) | 
|---|
|  |  |  | .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId) | 
|---|
|  |  |  | .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(JkCabinetGrid::getCabinetId,jkCabinet.getId()) | 
|---|
|  |  |  | .orderByAsc(JkCabinetGrid::getCode) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<CabinetGridInfoVO> cabinetGridInfoVOList = new ArrayList<>(); | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(jkCabinetGridList)) { | 
|---|
|  |  |  | for (JkCabinetGrid jkCabinetGrid : jkCabinetGridList) { | 
|---|
|  |  |  | CabinetGridInfoVO cabinetGridInfoVO = new CabinetGridInfoVO(); | 
|---|
|  |  |  | BeanUtil.copyProperties(jkCabinetGrid, cabinetGridInfoVO); | 
|---|
|  |  |  | cabinetGridInfoVO.setBindStatus(Objects.isNull(jkCabinetGrid.getKeyId()) ? Constants.ZERO : Constants.ONE); | 
|---|
|  |  |  | cabinetGridInfoVO.setKeyStatus(Objects.isNull(cabinetGridInfoVO.getKeyStatus())?Constants.ZERO:cabinetGridInfoVO.getKeyStatus()); | 
|---|
|  |  |  | cabinetGridInfoVOList.add(cabinetGridInfoVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | cabinetInfoVO.setCabinetGridInfoVOList(cabinetGridInfoVOList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CabinetConfigDataVO cabinetConfigDataVO = new CabinetConfigDataVO(); | 
|---|
|  |  |  | cabinetConfigDataVO.setConcentration(systemDictDataBiz.queryByCode(Constants.CABINET_CONFIG,Constants.CONCENTRATION).getCode()); | 
|---|
|  |  |  | cabinetConfigDataVO.setPressure(systemDictDataBiz.queryByCode(Constants.CABINET_CONFIG,Constants.PRESSURE).getCode()); | 
|---|
|  |  |  | cabinetConfigDataVO.setBlowTime(systemDictDataBiz.queryByCode(Constants.CABINET_CONFIG,Constants.BLOW_TIME).getCode()); | 
|---|
|  |  |  | cabinetConfigDataVO.setThreshold(systemDictDataBiz.queryByCode(Constants.CABINET_CONFIG,Constants.THRESHOLD).getCode()); | 
|---|
|  |  |  | cabinetInfoVO.setCabinetConfigDataVO(cabinetConfigDataVO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | cabinetInfoVO.setLinkPhone(systemDictDataBiz.queryByCode(Constants.CABINET_CONFIG,Constants.LINK_PHONE).getCode()); | 
|---|
|  |  |  | List<Category> categoryList = categoryMapper.selectList(new QueryWrapper<Category>().lambda() | 
|---|
|  |  |  | .eq(Category::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Category::getStatus,Constants.ZERO) | 
|---|
|  |  |  | .eq(Category::getType,Constants.THREE) | 
|---|
|  |  |  | .orderByAsc(Category::getSortnum) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(categoryList)){ | 
|---|
|  |  |  | String prefixUrl = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() + | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.FTP,Constants.BANNER_IMG).getCode(); | 
|---|
|  |  |  | for (Category category:categoryList) { | 
|---|
|  |  |  | category.setImgurlFull(prefixUrl + category.getImgurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | cabinetInfoVO.setBannerList( | 
|---|
|  |  |  | categoryList.stream().map(i->i.getImgurlFull()).collect(Collectors.toList()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return cabinetInfoVO; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void updateRunStatusById(Integer id) { | 
|---|
|  |  |  | jkCabinetMapper.update(null,new UpdateWrapper<JkCabinet>() | 
|---|
|  |  |  | .lambda().set(JkCabinet::getRunStatus,Constants.ZERO) | 
|---|
|  |  |  | .set(JkCabinet::getEditDate, DateUtil.getCurrDateTime()) | 
|---|
|  |  |  | .set(JkCabinet::getHaertTime, DateUtil.getCurrDateTime()) | 
|---|
|  |  |  | .eq(JkCabinet::getId,id)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|