| | |
| | | |
| | | import cn.exrick.xboot.core.common.utils.PageUtil; |
| | | import cn.exrick.xboot.core.common.utils.ResultUtil; |
| | | import cn.exrick.xboot.core.common.utils.SecurityUtil; |
| | | import cn.exrick.xboot.core.common.vo.PageVo; |
| | | import cn.exrick.xboot.core.common.vo.Result; |
| | | import cn.exrick.xboot.core.entity.User; |
| | | import cn.exrick.xboot.core.service.UserService; |
| | | import cn.exrick.xboot.your.entity.Customer; |
| | | import cn.exrick.xboot.your.entity.CustomerReceive; |
| | | import cn.exrick.xboot.your.entity.Fingerprint; |
| | | import cn.exrick.xboot.your.service.ICustomerReceiveService; |
| | | import cn.exrick.xboot.your.service.ICustomerService; |
| | | import cn.exrick.xboot.your.service.IFingerprintService; |
| | | import cn.exrick.xboot.your.entity.*; |
| | | import cn.exrick.xboot.your.service.*; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | @Autowired |
| | | private ICustomerService iCustomerService; |
| | | |
| | | @Autowired |
| | | private IAreaService iAreaService; |
| | | |
| | | @Autowired |
| | | private ICarService iCarService; |
| | | |
| | | @Autowired |
| | | private SecurityUtil securityUtil; |
| | | |
| | | @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) |
| | | @ApiOperation(value = "通过id获取") |
| | | public Result<Fingerprint> get(@PathVariable String id) { |
| | |
| | | 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); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getAllByAreaId", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取全部片区内指纹数据") |
| | | public Result<List<Fingerprint>> getAllByAreaId(String areaId) { |
| | | public Result<List<Fingerprint>> getAllByAreaId() { |
| | | Area area = getArea(securityUtil.getCurrUser().getId()); |
| | | if(area==null){ |
| | | return ResultUtil.error("该用户还未绑定片区"); |
| | | } |
| | | QueryWrapper<Fingerprint> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("area_id",areaId); |
| | | wrapper.eq("area_id",area.getId()); |
| | | List<Fingerprint> list = iFingerprintService.list(wrapper); |
| | | 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); |
| | | // |
| | | // QueryWrapper<Area> wrapper3 = new QueryWrapper<Area>(); |
| | | // wrapper3.eq("user_id",one.getFollowUserId()); |
| | | // area = iAreaService.getOne(wrapper3); |
| | | // return area; |
| | | // } |
| | | // return area; |
| | | // } |
| | | |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/getCount", method = RequestMethod.GET) |
| | |
| | | wrapper.eq("code",code); |
| | | wrapper.isNotNull("user_id"); |
| | | Fingerprint one = iFingerprintService.getOne(wrapper); |
| | | User user = userService.findByUsername(one.getUsername()); |
| | | if(user==null){ |
| | | return ResultUtil.error("用户已删除"); |
| | | }else{ |
| | | one.setPassword(user.getDescription()); |
| | | } |
| | | return new ResultUtil<Object>().setData(one); |
| | | } |
| | | |
| | |
| | | QueryWrapper<Fingerprint> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("code",code); |
| | | wrapper.eq("area_id",c.getAreaId()); |
| | | wrapper.eq("customer_id",customerId); |
| | | Fingerprint one = iFingerprintService.getOne(wrapper); |
| | | if(one==null){ |
| | | |
| | | QueryWrapper<Fingerprint> wrapper2 = new QueryWrapper<>(); |
| | | wrapper2.eq("code",code); |
| | | wrapper2.eq("area_id",c.getAreaId()); |
| | | Fingerprint one2 = iFingerprintService.getOne(wrapper2); |
| | | if(one2!=null){ |
| | | c.setLikeCusotmerId(one2.getCustomerId()); |
| | | iCustomerService.saveOrUpdate(c); |
| | | } |
| | | return ResultUtil.error("指纹与商户不匹配"); |
| | | } |
| | | |
| | | CustomerReceive customerReceive = iCustomerReceiveService.getById(one.getCustomerReceiveId()); |
| | | return new ResultUtil<Object>().setData(customerReceive); |
| | |
| | | @RequestMapping(value = "/getCode", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取司机或配送员指纹编号") |
| | | public Result<Object> getCode() { |
| | | int code = iFingerprintService.maxCode(); |
| | | return new ResultUtil<Object>().setData(code); |
| | | |
| | | 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.isNotEmpty(fingerprint.getUserId())){ |
| | | User user = userService.get(fingerprint.getUserId()); |
| | | fingerprint.setUsername(user.getUsername()); |
| | | fingerprint.setPassword(user.getDescription()); |
| | | fingerprint.setType(user.getType2()); |
| | | 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.eq("user_id",fingerprint.getUserId()); |
| | | Fingerprint one = iFingerprintService.getOne(wrapper); |
| | | if(one!=null){ |
| | | 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("未找到需要更新的指纹"); |
| | | } |
| | | |
| | | } |
| | | |
| | | if(StrUtil.isNotEmpty(fingerprint.getCustomerId())){ |
| | | Customer byId = iCustomerService.getById(fingerprint.getCustomerId()); |
| | | fingerprint.setAreaId(byId.getAreaId()); |
| | | |
| | | QueryWrapper<Fingerprint> wrapper = new QueryWrapper<Fingerprint>(); |
| | | wrapper.eq("code",fingerprint.getCode()); |
| | | wrapper.eq("area_id",byId.getAreaId()); |
| | | wrapper.isNotNull("customer_id"); |
| | | Fingerprint one = iFingerprintService.getOne(wrapper); |
| | | if(one!=null){ |
| | | return ResultUtil.error("code重复了,请重新获取"); |
| | | } |
| | | }else{ |
| | | return ResultUtil.error("customerId不能为空"); |
| | | } |
| | | if (iFingerprintService.saveOrUpdate(fingerprint)) { |
| | | return new ResultUtil<Fingerprint>().setData(fingerprint); |
| | | |
| | | 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("操作失败"); |
| | | } |
| | | |