|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.doumee.core.model.PageData; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.annotation.excel.ExcelImporter; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | 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.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.ScientificNotationTUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.dao.admin.request.CarsImport; | 
|---|
|  |  |  | import com.doumee.dao.admin.request.CarsQuery; | 
|---|
|  |  |  | import com.doumee.dao.admin.response.CarsDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.CarsMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.*; | 
|---|
|  |  |  | import com.doumee.dao.business.dao.CompanyMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.dao.MemberMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.CarJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.ParkBookJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Member; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.service.business.CarsService; | 
|---|
|  |  |  | import com.doumee.service.business.impl.hksync.HkSyncParkServiceImpl; | 
|---|
|  |  |  | 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.data.redis.core.RedisTemplate; | 
|---|
|  |  |  | import org.springframework.scheduling.annotation.Async; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  | import org.springframework.web.multipart.MultipartFile; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.concurrent.TimeUnit; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 车辆信息表Service实现 | 
|---|
|  |  |  | 
|---|
|  |  |  | private CarsMapper carsMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RedisTemplate<String, Object> redisTemplate; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CarJoinMapper carJoinMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CompanyMapper companyMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CategoryMapper categoryMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MemberMapper memberMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ParkBookJoinMapper parkBookJoinMapper; | 
|---|
|  |  |  | private ParkBookMapper parkBookJoinMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ParksMapper parksMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer create(Cars cars) { | 
|---|
|  |  |  | carsMapper.insert(cars); | 
|---|
|  |  |  | return cars.getId(); | 
|---|
|  |  |  | public Integer create(Cars model) { | 
|---|
|  |  |  | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | if(loginUserInfo == null){ | 
|---|
|  |  |  | loginUserInfo = model.getLoginUserInfo(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /*    if(StringUtils.isBlank(model.getCode()) | 
|---|
|  |  |  | ||model.getType()==null | 
|---|
|  |  |  | ||model.getCateId()==null | 
|---|
|  |  |  | ||model.getType()<0 | 
|---|
|  |  |  | ||model.getType()>3 | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(model.getMemberId()!=null){ | 
|---|
|  |  |  | //检查车主信息 | 
|---|
|  |  |  | Member member =memberMapper.selectOne(new QueryWrapper<Member>().lambda() | 
|---|
|  |  |  | .eq(Member::getId,model.getMemberId() ) | 
|---|
|  |  |  | .eq(Member::getType,Constants.TWO ) | 
|---|
|  |  |  | .eq(Member::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .last("limit 1")); | 
|---|
|  |  |  | if(member == null){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,车主信息不存在,请返回刷新重试!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | model.setMemberHkId(member.getHkId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.checkCarNo(model.getCode())){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"请输入正确的车牌!"); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //检查车牌号是否重复 | 
|---|
|  |  |  | if(carsMapper.selectCount(new QueryWrapper<Cars>().lambda() | 
|---|
|  |  |  | .eq(Cars::getCode,model.getCode() ) | 
|---|
|  |  |  | .eq(Cars::getIsdeleted,Constants.ZERO ) | 
|---|
|  |  |  | ) >0){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,车辆已经录入,不能重复录入!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | model.setType(Constants.formatIntegerNum(model.getType())); | 
|---|
|  |  |  | model.setCreateDate(new Date()); | 
|---|
|  |  |  | model.setCreator(loginUserInfo.getId()); | 
|---|
|  |  |  | model.setEditDate(new Date()); | 
|---|
|  |  |  | model.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | model.setEdirot(loginUserInfo.getId()); | 
|---|
|  |  |  | model.setStatus(Constants.ZERO); | 
|---|
|  |  |  | model.setHkStatus(Constants.ZERO); | 
|---|
|  |  |  | model.setAuthStatus(Constants.ZERO); | 
|---|
|  |  |  | model.setRemark(""); | 
|---|
|  |  |  | //        model.setHkDate(model.getCreateDate()); | 
|---|
|  |  |  | //        model.setHkId(UUID.randomUUID().toString().replace("-","")); | 
|---|
|  |  |  | carsMapper.insert(model); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return model.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteById(Integer id) { | 
|---|
|  |  |  | carsMapper.deleteById(id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void deleteById(Integer id, LoginUserInfo user) { | 
|---|
|  |  |  | Cars car = carJoinMapper.selectById(id); | 
|---|
|  |  |  | if(car ==null ||Constants.equalsInteger(car.getIsdeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,车辆信息不存在!"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Date date = new Date(); | 
|---|
|  |  |  | //删除已授权下发的包期授权 | 
|---|
|  |  |  | dealCancelBookBiz(car.getCode(),date,parkBookJoinMapper); | 
|---|
|  |  |  | //        Cars model = new Cars(); | 
|---|
|  |  |  | //        model.setEditDate(date); | 
|---|
|  |  |  | //        model.setEdirot(user.getId()); | 
|---|
|  |  |  | //        model.setId(id); | 
|---|
|  |  |  | //        model.setIsdeleted(Constants.ONE); | 
|---|
|  |  |  | carsMapper.update(null,new UpdateWrapper<Cars>().lambda() | 
|---|
|  |  |  | .eq(Cars::getId,id) | 
|---|
|  |  |  | .set(Cars::getStartTime,null) | 
|---|
|  |  |  | .set(Cars::getEndTime,null) | 
|---|
|  |  |  | .set(Cars::getAuthTimeType,null) | 
|---|
|  |  |  | .set(Cars::getAuthStatus,Constants.ZERO) | 
|---|
|  |  |  | .set(Cars::getIsdeleted,Constants.ONE) | 
|---|
|  |  |  | .set(Cars::getEditDate,date) | 
|---|
|  |  |  | .set(Cars::getEdirot,user.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | //        carsMapper.updateById(model); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public static    boolean  dealCancelBookBiz(String code,Date date,ParkBookMapper parkBookJoinMapper){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<ParkBook> parkBooks = parkBookJoinMapper.selectJoinList(ParkBook.class,new MPJLambdaWrapper<ParkBook>() | 
|---|
|  |  |  | .selectAll(ParkBook.class ) | 
|---|
|  |  |  | .selectAs(Parks::getHkId,ParkBook::getParkHkId ) | 
|---|
|  |  |  | .leftJoin(Parks.class,Parks::getId,ParkBook::getParkId) | 
|---|
|  |  |  | .eq(ParkBook::getCarCode,code) | 
|---|
|  |  |  | .eq(ParkBook::getIsdeleted,Constants.ZERO )); | 
|---|
|  |  |  | if(parkBooks !=null){ | 
|---|
|  |  |  | for(ParkBook c : parkBooks){ | 
|---|
|  |  |  | //如果取消预约,则进行取消包期 | 
|---|
|  |  |  | if(StringUtils.isNotBlank(c.getParkHkId()) | 
|---|
|  |  |  | && StringUtils.isNotBlank(c.getCarCode())){ | 
|---|
|  |  |  | boolean result = HkSyncParkServiceImpl.cancelParkBookHk(c); | 
|---|
|  |  |  | if(!result){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,取消已下发授权失败,请联系管理员处理~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | c.setHkStatus(Constants.ONE); | 
|---|
|  |  |  | c.setRemark("取消包期成功"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | c.setHkStatus(Constants.TWO);//下发失败 | 
|---|
|  |  |  | c.setRemark("无效停车场授权下发,取消包期失败,直接删除记录"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | c.setHkDate(date); | 
|---|
|  |  |  | c.setIsdeleted(Constants.ONE); | 
|---|
|  |  |  | parkBookJoinMapper.updateById(c); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public   boolean  dealCancelBookBizNoException(String code,Date date){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | boolean r = true; | 
|---|
|  |  |  | List<ParkBook> parkBooks = parkBookJoinMapper.selectJoinList(ParkBook.class,new MPJLambdaWrapper<ParkBook>() | 
|---|
|  |  |  | .selectAll(ParkBook.class ) | 
|---|
|  |  |  | .selectAs(Parks::getHkId,ParkBook::getParkHkId ) | 
|---|
|  |  |  | .leftJoin(Parks.class,Parks::getId,ParkBook::getParkId) | 
|---|
|  |  |  | .eq(ParkBook::getCarCode,code) | 
|---|
|  |  |  | .eq(ParkBook::getIsdeleted,Constants.ZERO )); | 
|---|
|  |  |  | if(parkBooks !=null){ | 
|---|
|  |  |  | for(ParkBook c : parkBooks){ | 
|---|
|  |  |  | //如果取消预约,则进行取消包期 | 
|---|
|  |  |  | if(StringUtils.isNotBlank(c.getParkHkId()) | 
|---|
|  |  |  | && StringUtils.isNotBlank(c.getCarCode())){ | 
|---|
|  |  |  | boolean result = HkSyncParkServiceImpl.cancelParkBookHk(c); | 
|---|
|  |  |  | if(!result){ | 
|---|
|  |  |  | r=  false; | 
|---|
|  |  |  | c.setHkStatus(Constants.ONE); | 
|---|
|  |  |  | c.setRemark("取消包期失败"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | c.setHkStatus(Constants.ONE); | 
|---|
|  |  |  | c.setRemark("取消包期成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | c.setHkStatus(Constants.TWO);//下发失败 | 
|---|
|  |  |  | c.setRemark("无效停车场授权下发,取消包期失败,直接删除记录"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(r){ | 
|---|
|  |  |  | c.setHkDate(date); | 
|---|
|  |  |  | c.setIsdeleted(Constants.ONE); | 
|---|
|  |  |  | parkBookJoinMapper.updateById(c); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return r; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Async | 
|---|
|  |  |  | public  void dealCarsAuthBiz(List<Cars> carsList){ | 
|---|
|  |  |  | if(carsList== null || carsList.size() == 0 ){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Date date = new Date(); | 
|---|
|  |  |  | MPJLambdaWrapper<Parks> queryWrapper1 = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | queryWrapper1.selectAll(Parks.class); | 
|---|
|  |  |  | queryWrapper1.eq(Parks::getIsdeleted,Constants.ZERO ); | 
|---|
|  |  |  | List<Parks>  parksList = parksMapper.selectList( queryWrapper1); | 
|---|
|  |  |  | if(parksList==null ||parksList.size() == 0){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(Cars model : carsList){ | 
|---|
|  |  |  | model.setAuthTimeType(Constants.ZERO); | 
|---|
|  |  |  | model.setStartTime(null); | 
|---|
|  |  |  | model.setEndTime(null); | 
|---|
|  |  |  | ParkBookServiceImpl.dealCarAuthByModel(model,model.getEdirot(),parksList,date,parkBookJoinMapper); | 
|---|
|  |  |  | model.setAuthStatus(Constants.ONE);//已授权 | 
|---|
|  |  |  | carsMapper.update(null,new UpdateWrapper<Cars>().lambda() | 
|---|
|  |  |  | .eq(Cars::getId,model.getId()) | 
|---|
|  |  |  | .set(Cars::getEditDate,date) | 
|---|
|  |  |  | .set(Cars::getEdirot,model.getEdirot()) | 
|---|
|  |  |  | .set(Cars::getAuthStatus,Constants.ONE) | 
|---|
|  |  |  | .set(Cars::getStartTime,null) | 
|---|
|  |  |  | .set(Cars::getEndTime,null) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void delete(Cars cars) { | 
|---|
|  |  |  | UpdateWrapper<Cars> deleteWrapper = new UpdateWrapper<>(cars); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteByIdInBatch(List<Integer> ids) { | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public void deleteByIdInBatch(List<Integer> ids, LoginUserInfo user) { | 
|---|
|  |  |  | if (CollectionUtils.isEmpty(ids)) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | carsMapper.deleteBatchIds(ids); | 
|---|
|  |  |  | for(Integer id : ids){ | 
|---|
|  |  |  | deleteById(id,user); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void updateById(Cars cars) { | 
|---|
|  |  |  | carsMapper.updateById(cars); | 
|---|
|  |  |  | public void updateById(Cars model) { | 
|---|
|  |  |  | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | if(loginUserInfo == null){ | 
|---|
|  |  |  | loginUserInfo = model.getLoginUserInfo(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /* if(StringUtils.isBlank(model.getCode()) | 
|---|
|  |  |  | ||model.getId()==null | 
|---|
|  |  |  | ||model.getType()==null | 
|---|
|  |  |  | ||model.getCateId()==null | 
|---|
|  |  |  | ||model.getType()<0 | 
|---|
|  |  |  | ||model.getType()>3 | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  | Cars car = carJoinMapper.selectById(model.getId()); | 
|---|
|  |  |  | if(car ==null ||Constants.equalsInteger(car.getIsdeleted(),Constants.ONE)){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,车辆信息不存在!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.checkCarNo(model.getCode())){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"请输入正确的车牌!"); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | if(model.getMemberId()!=null){ | 
|---|
|  |  |  | //检查车主信息 | 
|---|
|  |  |  | Member member =memberMapper.selectOne(new QueryWrapper<Member>().lambda() | 
|---|
|  |  |  | .eq(Member::getId,model.getMemberId() ) | 
|---|
|  |  |  | .eq(Member::getType,Constants.TWO ) | 
|---|
|  |  |  | .eq(Member::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .last("limit 1")); | 
|---|
|  |  |  | if(member == null){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,车主信息不存在,请返回刷新重试!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | model.setMemberHkId(member.getHkId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //检查车牌号是否重复 | 
|---|
|  |  |  | if(carsMapper.selectCount(new QueryWrapper<Cars>().lambda() | 
|---|
|  |  |  | .eq(Cars::getCode,model.getCode() ) | 
|---|
|  |  |  | .ne(Cars::getId,model.getId() ) | 
|---|
|  |  |  | .eq(Cars::getIsdeleted,Constants.ZERO ) | 
|---|
|  |  |  | ) >0){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,车辆已经录入,不能重复录入!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | model.setType(Constants.formatIntegerNum(model.getType())); | 
|---|
|  |  |  | model.setEditDate(new Date()); | 
|---|
|  |  |  | model.setEdirot(loginUserInfo.getId()); | 
|---|
|  |  |  | model.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | model.setHkStatus(Constants.ZERO); | 
|---|
|  |  |  | model.setRemark(""); | 
|---|
|  |  |  | model.setAuthStatus(Constants.ZERO); | 
|---|
|  |  |  | dealCancelBookBiz(car.getCode(),model.getEditDate(),parkBookJoinMapper); | 
|---|
|  |  |  | carsMapper.update(null,new UpdateWrapper<Cars>().lambda() | 
|---|
|  |  |  | .eq(Cars::getId,model.getId()) | 
|---|
|  |  |  | .set(Cars::getAuthStatus,Constants.ZERO) | 
|---|
|  |  |  | .set(Cars::getType,model.getType()) | 
|---|
|  |  |  | .set(Cars::getCode,model.getCode()) | 
|---|
|  |  |  | .set(Cars::getGroupId,model.getGroupId()) | 
|---|
|  |  |  | .set(Cars::getCateId,model.getCateId()) | 
|---|
|  |  |  | .set(Cars::getEditDate,model.getEditDate()) | 
|---|
|  |  |  | .set(Cars::getEdirot,model.getEdirot()) | 
|---|
|  |  |  | .set(Cars::getMemberId,model.getMemberId()) | 
|---|
|  |  |  | .set(Cars::getAuthTimeType,null) | 
|---|
|  |  |  | .set(Cars::getStartTime,null) | 
|---|
|  |  |  | .set(Cars::getEndTime,null) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | return carsMapper.selectById(id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Cars findOne(Cars cars) { | 
|---|
|  |  |  | QueryWrapper<Cars> wrapper = new QueryWrapper<>(cars); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<Cars> findList(Cars cars) { | 
|---|
|  |  |  | if(Objects.nonNull(cars) && Objects.nonNull(cars.getType()) | 
|---|
|  |  |  | && Constants.equalsInteger(Constants.ZERO,cars.getType())){ | 
|---|
|  |  |  | return this.getGwCar(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | cars.setType(null); | 
|---|
|  |  |  | QueryWrapper<Cars> wrapper = new QueryWrapper<>(cars); | 
|---|
|  |  |  | wrapper.lambda().eq(Cars::getIsdeleted,Constants.ZERO); | 
|---|
|  |  |  | return carsMapper.selectList(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<Cars> getGwCar(){ | 
|---|
|  |  |  | List<Cars> list  = carsMapper.selectJoinList(Cars.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<Cars>().selectAll(Cars.class) | 
|---|
|  |  |  | .leftJoin(Category.class,Category::getId,Cars::getCateId) | 
|---|
|  |  |  | .eq(Category::getBizType,Constants.FOUR) | 
|---|
|  |  |  | .eq(Cars::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<Cars> findPage(PageWrap<Cars> pageWrap) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | IPage<Cars> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  | MPJLambdaWrapper<Cars> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.selectAll(Cars.class); | 
|---|
|  |  |  | queryWrapper.selectAs(Parks::getName,Cars::getParksName); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getType,Cars::getMemberType); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getName,Cars::getMemberName); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getIsdeleted,Cars::getMemberDeleted); | 
|---|
|  |  |  | queryWrapper.selectAs(SystemUser::getRealname,Cars::getEditorName); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getPhone,Cars::getMemberPhone); | 
|---|
|  |  |  | queryWrapper.selectAs(Company::getName,Cars::getCompanyName); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.leftJoin(Parks.class,Parks::getId,Cars::getParkId); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getSex,Cars::getMemberSex); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getIdcardDecode,Cars::getMemberCard); | 
|---|
|  |  |  | queryWrapper.selectAs(Company::getCompanyNamePath,Cars::getCompanyName); | 
|---|
|  |  |  | queryWrapper.selectAs(Category::getParentId,Cars::getCatePId); | 
|---|
|  |  |  | queryWrapper.selectAs(Category::getName,Cars::getCateName); | 
|---|
|  |  |  | queryWrapper.select(" c.name as catePName"); | 
|---|
|  |  |  | queryWrapper.select(" c1.COMPANY_NAME_PATH as carCompanyNamePath"); | 
|---|
|  |  |  | queryWrapper.select(" c1.name as carCompanyName"); | 
|---|
|  |  |  | queryWrapper.leftJoin(Member.class,Member::getId,Cars::getMemberId); | 
|---|
|  |  |  | queryWrapper.leftJoin(SystemUser.class,SystemUser::getId,Cars::getEdirot); | 
|---|
|  |  |  | queryWrapper.leftJoin(Company.class,Company::getId,Member::getCompanyId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.leftJoin(Category.class,Category::getId,Cars::getCateId); | 
|---|
|  |  |  | queryWrapper.leftJoin("category c on t4.PARENT_ID = c.id"); | 
|---|
|  |  |  | queryWrapper.leftJoin("company c1 on t.GROUP_ID = c1.id"); | 
|---|
|  |  |  | queryWrapper.and(StringUtils.isNotBlank(pageWrap.getModel().getMemberName()), ms->ms.like(Member::getName,pageWrap.getModel().getMemberName()) | 
|---|
|  |  |  | .or().like(Member::getPhone,pageWrap.getModel().getMemberName())); | 
|---|
|  |  |  | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getCompanyName()),Company::getName,pageWrap.getModel().getCompanyName()); | 
|---|
|  |  |  | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getCompanyName()),Company::getCompanyNamePath,pageWrap.getModel().getCompanyName()); | 
|---|
|  |  |  | queryWrapper.eq(Objects.nonNull(pageWrap.getModel().getMemberType()),Member::getType,pageWrap.getModel().getMemberType()); | 
|---|
|  |  |  | queryWrapper.eq(Objects.nonNull(pageWrap.getModel().getCateId()),Category::getId,pageWrap.getModel().getCateId()); | 
|---|
|  |  |  | queryWrapper.eq(Objects.nonNull(pageWrap.getModel().getCatePId()),Category::getParentId,pageWrap.getModel().getCatePId()); | 
|---|
|  |  |  | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getCode()),Cars::getCode,pageWrap.getModel().getCode()); | 
|---|
|  |  |  | queryWrapper.eq(Cars::getIsdeleted,Constants.ZERO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.eq(pageWrap.getModel().getType()!=null,Cars::getType,pageWrap.getModel().getType()); | 
|---|
|  |  |  | queryWrapper.eq(pageWrap.getModel().getAuthStatus()!=null,Cars::getAuthStatus,pageWrap.getModel().getAuthStatus()); | 
|---|
|  |  |  | queryWrapper.orderByDesc(Cars::getCreateDate); | 
|---|
|  |  |  | //数据权限开始--------------------start---------------- | 
|---|
|  |  |  | LoginUserInfo userInfo =pageWrap.getModel().getLoginUserInfo(); | 
|---|
|  |  |  | if(userInfo!=null && userInfo.getCompanyIdList()!=null){ | 
|---|
|  |  |  | if(  userInfo.getCompanyIdList().size() ==0){ | 
|---|
|  |  |  | //只能看自己(拜访人) | 
|---|
|  |  |  | queryWrapper.eq(Cars::getMemberId,userInfo.getMemberId()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | queryWrapper.in(Cars::getGroupId ,userInfo.getCompanyIdList()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //数据权限开始--------------------end---------------- | 
|---|
|  |  |  |  | 
|---|
|  |  |  | IPage<Cars> result = carJoinMapper.selectJoinPage(page, Cars.class,queryWrapper); | 
|---|
|  |  |  | if(result!=null && result.getRecords()!=null && result.getRecords().size()>0){ | 
|---|
|  |  |  | List<String> codes = new ArrayList<>(); | 
|---|
|  |  |  | for(Cars cars :result.getRecords()){ | 
|---|
|  |  |  | codes.add(cars.getCode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<ParkBook> parkBooks = parkBookJoinMapper.selectJoinList(ParkBook.class,new MPJLambdaWrapper<ParkBook>() | 
|---|
|  |  |  | .selectAll(ParkBook.class) | 
|---|
|  |  |  | .selectAs(Parks::getName,ParkBook::getParksName) | 
|---|
|  |  |  | .leftJoin(Parks.class,Parks::getId,ParkBook::getParkId) | 
|---|
|  |  |  | .in(ParkBook::getCarCode,codes) | 
|---|
|  |  |  | .eq(ParkBook::getIsdeleted,Constants.ZERO) ); | 
|---|
|  |  |  | for(Cars cars :result.getRecords()){ | 
|---|
|  |  |  | if(StringUtils.isNotBlank(cars.getCateName())){ | 
|---|
|  |  |  | cars.setGroupCateName(StringUtils.defaultString(cars.getCatePName(),"") + "/" + StringUtils.defaultString(cars.getCateName(),"")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | cars.setParkBookList(getParkbookListByCode(cars,parkBooks)); | 
|---|
|  |  |  | if(Constants.equalsInteger(cars.getMemberDeleted(),Constants.ONE)){ | 
|---|
|  |  |  | cars.setMemberId(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return PageData.from(result); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private List<ParkBook> getParkbookListByCode(Cars car, List<ParkBook> parkBooks) { | 
|---|
|  |  |  | List<ParkBook> list =null; | 
|---|
|  |  |  | String name = ""; | 
|---|
|  |  |  | for(ParkBook p : parkBooks){ | 
|---|
|  |  |  | if(StringUtils.equals(p.getCarCode(),car.getCode())){ | 
|---|
|  |  |  | if(list == null){ | 
|---|
|  |  |  | list = new ArrayList<>(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | name += p.getParksName(); | 
|---|
|  |  |  | list.add(p); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | car.setParksName(name); | 
|---|
|  |  |  | return  list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | .leftJoin(Parks.class,Parks::getId,ParkBook::getParkId); | 
|---|
|  |  |  | wrapper.selectAs(ParkBook::getCarCode,CarsDTO::getCode) | 
|---|
|  |  |  | .selectAs(ParkBook::getParkId,CarsDTO::getParkId) | 
|---|
|  |  |  | .selectAs(Member::getIsdeleted,CarsDTO::getMemberDeleted) | 
|---|
|  |  |  | .selectAs(ParkBook::getRemark,CarsDTO::getRemark) | 
|---|
|  |  |  | .selectAs(Parks::getName,CarsDTO::getParkName) | 
|---|
|  |  |  | .selectAs(ParkBook::getMemberId,CarsDTO::getMemberId) | 
|---|
|  |  |  | 
|---|
|  |  |  | .selectAs(ParkBook::getCreateDate,CarsDTO::getCreateDate); | 
|---|
|  |  |  | wrapper.orderByDesc(ParkBook::getCreateDate); | 
|---|
|  |  |  | IPage<CarsDTO> carsDTOIPage = parkBookJoinMapper.selectJoinPage(page, CarsDTO.class, wrapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(carsDTOIPage!=null && carsDTOIPage.getRecords()!=null && carsDTOIPage.getRecords().size()>0){ | 
|---|
|  |  |  | for(CarsDTO cars :carsDTOIPage.getRecords()){ | 
|---|
|  |  |  | if(Constants.equalsInteger(cars.getMemberDeleted(),Constants.ONE)){ | 
|---|
|  |  |  | cars.setMemberId(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return PageData.from(carsDTOIPage); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public List<Cars> importBatch(MultipartFile file,  LoginUserInfo loginUserInfo){ | 
|---|
|  |  |  | Boolean importing = (Boolean) redisTemplate.opsForValue().get(Constants.RedisKeys.IMPORTING_CARS); | 
|---|
|  |  |  | if(importing!=null && importing){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,已存在车辆导入任务正在执行中,请稍后再试!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | redisTemplate.opsForValue().set(Constants.RedisKeys.IMPORTING_CARS,true,30, TimeUnit.MINUTES); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | ExcelImporter ie = null; | 
|---|
|  |  |  | List<CarsImport> dataList =null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | ie = new ExcelImporter(file,0,0); | 
|---|
|  |  |  | dataList = ie.getDataList(CarsImport.class,null); | 
|---|
|  |  |  | }  catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(dataList == null || dataList.size() ==0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,录入数据为空!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Cars> allCarsList =  carJoinMapper.selectJoinList(Cars.class,new MPJLambdaWrapper<Cars>() | 
|---|
|  |  |  | .selectAll(Cars.class) | 
|---|
|  |  |  | .eq(Cars::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | List<Company> companyList =  companyMapper.selectJoinList(Company.class,new MPJLambdaWrapper<Company>() | 
|---|
|  |  |  | .selectAll(Company.class) | 
|---|
|  |  |  | .eq(Company::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | List<Category> categoryList  = categoryMapper.selectList(new QueryWrapper<Category>().lambda() | 
|---|
|  |  |  | .eq(Category::getType,Constants.ONE) | 
|---|
|  |  |  | .eq(Category::getIsdeleted,Constants.ZERO)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Member> memberList  = memberMapper.selectJoinList(Member.class,new MPJLambdaWrapper<Member>() | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,Member::getCompanyId) | 
|---|
|  |  |  | .selectAll(Member.class) | 
|---|
|  |  |  | .selectAs(Company::getCompanyNamePath,Member::getCompanyNamePath) | 
|---|
|  |  |  | .eq(Member::getType,Constants.TWO) | 
|---|
|  |  |  | .eq(Member::getIsdeleted,Constants.ZERO)); | 
|---|
|  |  |  | List<Cars> newList = new ArrayList<>(); | 
|---|
|  |  |  | List<Cars> updateList = new ArrayList<>(); | 
|---|
|  |  |  | for(int i=0;i<dataList.size();i++){ | 
|---|
|  |  |  | CarsImport model = dataList.get(i); | 
|---|
|  |  |  | model.setPhone(ScientificNotationTUtil.convertToString(model.getPhone())); | 
|---|
|  |  |  | if(StringUtils.isBlank(model.getCode()) | 
|---|
|  |  |  | &&StringUtils.isBlank(model.getCategoryName()) | 
|---|
|  |  |  | //                        &&StringUtils.isBlank(model.getType()) | 
|---|
|  |  |  | &&StringUtils.isBlank(model.getSex()) | 
|---|
|  |  |  | &&StringUtils.isBlank(model.getIdcard()) | 
|---|
|  |  |  | &&StringUtils.isBlank(model.getParkName()) | 
|---|
|  |  |  | &&StringUtils.isBlank(model.getPhone()) | 
|---|
|  |  |  | &&StringUtils.isBlank(model.getMemberName()) | 
|---|
|  |  |  | &&StringUtils.isBlank(model.getCompanyName())){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | checkModelParam(model,newList,updateList,i,loginUserInfo,allCarsList,memberList,companyList,categoryList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if((newList == null || newList.size() ==0) && updateList.size() == 0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,录入有效数据为空!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(newList.size()>0){ | 
|---|
|  |  |  | carsMapper.insert(newList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(updateList.size()>0){ | 
|---|
|  |  |  | for (Cars c : updateList){ | 
|---|
|  |  |  | carsMapper.updateById(c); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | newList.addAll(updateList); | 
|---|
|  |  |  | return newList; | 
|---|
|  |  |  | }catch (BusinessException e){ | 
|---|
|  |  |  | throw e; | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"车辆信息导入失败,请稍后重试"); | 
|---|
|  |  |  | }finally { | 
|---|
|  |  |  | redisTemplate.delete(Constants.RedisKeys.IMPORTING_CARS); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Cars checkModelParam(CarsImport model, List<Cars> newList | 
|---|
|  |  |  | , List<Cars> updateList | 
|---|
|  |  |  | ,int index | 
|---|
|  |  |  | ,LoginUserInfo loginUserInfo | 
|---|
|  |  |  | ,List<Cars> allList | 
|---|
|  |  |  | ,List<Member> memberList | 
|---|
|  |  |  | ,List<Company> companyList | 
|---|
|  |  |  | ,List<Category> categoryList ) { | 
|---|
|  |  |  | if(StringUtils.isBlank(model.getCode()) | 
|---|
|  |  |  | //                ||StringUtils.isBlank(model.getType()) | 
|---|
|  |  |  | ||StringUtils.isBlank(model.getCategoryName()) | 
|---|
|  |  |  | ||StringUtils.isBlank(model.getCompanyName())){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+(index+2)+"行车辆信息不完整,请检查表格内容!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(model.getPhone().indexOf(".")>=Constants.ZERO){ | 
|---|
|  |  |  | model.setPhone( | 
|---|
|  |  |  | String.valueOf(new BigDecimal(model.getPhone()).intValue()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(Cars param: newList){ | 
|---|
|  |  |  | if(StringUtils.isNotBlank(model.getCode())&&StringUtils.isNotBlank(param.getCode())) { | 
|---|
|  |  |  | if (StringUtils.equals(model.getCode(), param.getCode())) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,第" + (index + 3) + "行车牌号【" + model.getCode() + "】重复出现,请检查表格内容!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Cars cars = findCarsFromList(model.getCode(),allList); | 
|---|
|  |  |  | if(cars == null){ | 
|---|
|  |  |  | cars = new Cars(); | 
|---|
|  |  |  | cars.setCreator(loginUserInfo.getId()); | 
|---|
|  |  |  | cars.setCreateDate(new Date()); | 
|---|
|  |  |  | cars.setIsnew(Constants.ONE); | 
|---|
|  |  |  | newList.add(cars); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | cars.setIsnew(Constants.ZERO); | 
|---|
|  |  |  | updateList.add(cars); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /*  //类型 0安泰公务车 1安泰自有物流车 2其它 | 
|---|
|  |  |  | if(StringUtils.equals(model.getType(),"安泰公务车")){ | 
|---|
|  |  |  | cars.setType(Constants.ZERO); | 
|---|
|  |  |  | }else if(StringUtils.equals(model.getType(),"安泰自有物流车")){ | 
|---|
|  |  |  | cars.setType(Constants.ONE); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | cars.setType(Constants.TWO); | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  | cars.setCode(model.getCode()); | 
|---|
|  |  |  | Company company = findCompanyFromList(model.getCompanyName(),companyList); | 
|---|
|  |  |  | if(company == null){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+(index+2)+"行组织名称【"+model.getCompanyName()+"】不存在,请检查表格内容!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(model.getPhone())){ | 
|---|
|  |  |  | Member member = findMemberFromListByPhone(model.getPhone(),memberList); | 
|---|
|  |  |  | if(member == null){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+(index+2)+"行车主手机号【"+model.getPhone()+"】不存在,请检查表格内容!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | cars.setMember(member); | 
|---|
|  |  |  | cars.setMemberId(member.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Category category = findCategoryFromListByName(model.getCategoryName(),categoryList); | 
|---|
|  |  |  | if(category == null){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+(index+2)+"行车辆分类【"+model.getCategoryName()+"】不存在,请检查表格内容!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | cars.setGroupId(company.getId()); | 
|---|
|  |  |  | cars.setCateId(category.getId()); | 
|---|
|  |  |  | cars.setEditDate(new Date()); | 
|---|
|  |  |  | cars.setEdirot(loginUserInfo.getId()); | 
|---|
|  |  |  | cars.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | return cars; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private Company findCompanyFromList(String companyName, List<Company> companyList) { | 
|---|
|  |  |  | if(companyList !=null){ | 
|---|
|  |  |  | for(Company company : companyList){ | 
|---|
|  |  |  | if(StringUtils.equals(companyName,company.getCompanyNamePath())){ | 
|---|
|  |  |  | return  company; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private Cars findCarsFromList(String code, List<Cars> list) { | 
|---|
|  |  |  | if(list !=null){ | 
|---|
|  |  |  | for(Cars model : list){ | 
|---|
|  |  |  | if(StringUtils.equals(code,model.getCode())){ | 
|---|
|  |  |  | return  model; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private Member findMemberFromListByPhone(String phone, List<Member> list) { | 
|---|
|  |  |  | if(list !=null){ | 
|---|
|  |  |  | for(Member member : list){ | 
|---|
|  |  |  | if(StringUtils.equals(phone,member.getPhone())){ | 
|---|
|  |  |  | return  member; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private Category findCategoryFromListByName(String name, List<Category> list) { | 
|---|
|  |  |  | String[] names = name.split("/"); | 
|---|
|  |  |  | if(names ==null || names.length !=2 ){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Category pc = null; | 
|---|
|  |  |  | if(list !=null){ | 
|---|
|  |  |  | for(Category model : list){ | 
|---|
|  |  |  | if(StringUtils.equals(names[0],model.getName()) && model.getParentId() ==null){ | 
|---|
|  |  |  | pc = model; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(pc ==null){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(Category model : list){ | 
|---|
|  |  |  | if(StringUtils.equals(names[1],model.getName()) && Constants.equalsInteger(model.getParentId() ,pc.getId())){ | 
|---|
|  |  |  | pc = model; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return  pc; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|