| | |
| | | return new ResultUtil<Fingerprint>().setData(fingerprint); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getAreaIdByToken", method = RequestMethod.GET) |
| | | @ApiOperation(value = "根据token获取区域id") |
| | | public Result<Object> getAreaIdByToken() { |
| | | Area area = getArea(securityUtil.getCurrUser().getId()); |
| | | return new ResultUtil<Object>().setData(area); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getAll", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取全部司机和配送员指纹数据") |
| | | public Result<List<Fingerprint>> getAll() { |
| | | QueryWrapper<Fingerprint> wrapper = new QueryWrapper<>(); |
| | | wrapper.isNotNull("user_id"); |
| | | wrapper.isNotNull("file_id"); |
| | | List<Fingerprint> list = iFingerprintService.list(wrapper); |
| | | return new ResultUtil<List<Fingerprint>>().setData(list); |
| | | } |
| | |
| | | return new ResultUtil<List<Fingerprint>>().setData(list); |
| | | } |
| | | |
| | | public Area getArea(String userId){ |
| | | QueryWrapper<Area> wrapper = new QueryWrapper<Area>(); |
| | | wrapper.eq("user_id",userId); |
| | | Area area = iAreaService.getOne(wrapper); |
| | | if(area==null){ |
| | | QueryWrapper<Car> carQueryWrapper = new QueryWrapper<Car>(); |
| | | carQueryWrapper.eq("user_id",userId); |
| | | Car one = iCarService.getOne(carQueryWrapper); |
| | | // public Area getArea(String userId){ |
| | | // QueryWrapper<Area> wrapper = new QueryWrapper<Area>(); |
| | | // wrapper.eq("user_id",userId); |
| | | // Area area = iAreaService.getOne(wrapper); |
| | | // if(area==null){ |
| | | // QueryWrapper<Car> carQueryWrapper = new QueryWrapper<Car>(); |
| | | // carQueryWrapper.eq("user_id",userId); |
| | | // Car one = iCarService.getOne(carQueryWrapper); |
| | | // |
| | | // QueryWrapper<Area> wrapper3 = new QueryWrapper<Area>(); |
| | | // wrapper3.eq("user_id",one.getFollowUserId()); |
| | | // area = iAreaService.getOne(wrapper3); |
| | | // return area; |
| | | // } |
| | | // return area; |
| | | // } |
| | | |
| | | QueryWrapper<Area> wrapper3 = new QueryWrapper<Area>(); |
| | | wrapper3.eq("user_id",one.getFollowUserId()); |
| | | area = iAreaService.getOne(wrapper3); |
| | | public Area getArea(String userId){ |
| | | QueryWrapper<Car> carQueryWrapper = new QueryWrapper<Car>(); |
| | | carQueryWrapper.eq("user_id",userId).or().eq("follow_user_id",userId); |
| | | Car one = iCarService.getOne(carQueryWrapper); |
| | | if(one==null){ |
| | | return null; |
| | | }else{ |
| | | QueryWrapper<Area> wrapper = new QueryWrapper<Area>(); |
| | | wrapper.eq("car_id",one.getId()); |
| | | Area area = iAreaService.getOne(wrapper); |
| | | return area; |
| | | } |
| | | return area; |
| | | } |
| | | |
| | | @RequestMapping(value = "/getCount", method = RequestMethod.GET) |
| | |
| | | @RequestMapping(value = "/getCode", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取司机或配送员指纹编号") |
| | | public Result<Object> getCode() { |
| | | |
| | | User currUser = securityUtil.getCurrUser(); |
| | | String userId = currUser.getId(); |
| | | |
| | | QueryWrapper<Fingerprint> wrapper = new QueryWrapper<Fingerprint>(); |
| | | wrapper.eq("user_id",userId); |
| | | wrapper.isNull("file_id"); |
| | | Fingerprint one = iFingerprintService.getOne(wrapper); |
| | | if(one!=null){ |
| | | return new ResultUtil<Object>().setData(one.getCode()); |
| | | }else{ |
| | | int code = iFingerprintService.maxCode(); |
| | | |
| | | Fingerprint fingerprint = new Fingerprint(); |
| | | fingerprint.setUserId(userId); |
| | | fingerprint.setType(currUser.getType2()); |
| | | fingerprint.setCode(code); |
| | | fingerprint.setUsername(currUser.getUsername()); |
| | | fingerprint.setPassword(currUser.getDescription()); |
| | | iFingerprintService.saveOrUpdate(fingerprint); |
| | | return new ResultUtil<Object>().setData(code); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/insertOrUpdate", method = RequestMethod.POST) |
| | | @ApiOperation(value = "编辑或更新数据") |
| | | public Result<Fingerprint> saveOrUpdate(Fingerprint fingerprint) { |
| | | if(StrUtil.isEmpty(fingerprint.getFileId())){ |
| | | return ResultUtil.error("fileId不能为空"); |
| | | } |
| | | |
| | | if(StrUtil.isNotEmpty(fingerprint.getUserId())){ |
| | | QueryWrapper<Fingerprint> wp = new QueryWrapper<Fingerprint>(); |
| | | wp.eq("code",fingerprint.getCode()); |
| | | wp.isNotNull("user_id"); |
| | | List<Fingerprint> f = iFingerprintService.list(wp); |
| | | if(f.size()>1){ |
| | | return ResultUtil.error("code重复,请重新获取code并录入指纹"); |
| | | } |
| | | |
| | | QueryWrapper<Fingerprint> wrapper = new QueryWrapper<Fingerprint>(); |
| | | wrapper.eq("code",fingerprint.getCode()); |
| | | wrapper.isNotNull("user_id"); |
| | | wrapper.eq("user_id",fingerprint.getUserId()); |
| | | Fingerprint one = iFingerprintService.getOne(wrapper); |
| | | if(one!=null){ |
| | | return ResultUtil.error("code重复了,请重新获取"); |
| | | one.setFileId(fingerprint.getFileId()); |
| | | // User user = userService.get(fingerprint.getUserId()); |
| | | // one.setUsername(user.getUsername()); |
| | | // one.setPassword(user.getDescription()); |
| | | // one.setType(user.getType2()); |
| | | iFingerprintService.saveOrUpdate(one); |
| | | }else{ |
| | | return ResultUtil.error("未找到需要更新的指纹"); |
| | | } |
| | | |
| | | User user = userService.get(fingerprint.getUserId()); |
| | | fingerprint.setUsername(user.getUsername()); |
| | | fingerprint.setPassword(user.getDescription()); |
| | | fingerprint.setType(user.getType2()); |
| | | } |
| | | |
| | | if(StrUtil.isNotEmpty(fingerprint.getCustomerId())){ |
| | | Customer byId = iCustomerService.getById(fingerprint.getCustomerId()); |
| | | fingerprint.setAreaId(byId.getAreaId()); |
| | |
| | | if(one!=null){ |
| | | return ResultUtil.error("code重复了,请重新获取"); |
| | | } |
| | | }else{ |
| | | return ResultUtil.error("customerId不能为空"); |
| | | } |
| | | |
| | | if(StrUtil.isNotEmpty(fingerprint.getCustomerReceiveId())){ |
| | | CustomerReceive byId = iCustomerReceiveService.getById(fingerprint.getCustomerReceiveId()); |
| | | byId.setFstatus(1); |
| | | iCustomerReceiveService.saveOrUpdate(byId); |
| | | } |
| | | |
| | | if (iFingerprintService.saveOrUpdate(fingerprint)) { |
| | | return new ResultUtil<Fingerprint>().setData(fingerprint); |
| | | } |
| | | } |
| | | |
| | | return new ResultUtil<Fingerprint>().setErrorMsg("操作失败"); |
| | | } |
| | | |