| | |
| | | package cn.exrick.xboot.your.controller; |
| | | |
| | | import cn.exrick.xboot.core.common.constant.SettingConstant; |
| | | import cn.exrick.xboot.core.common.utils.CommonUtil; |
| | | import cn.exrick.xboot.core.common.utils.PageUtil; |
| | | import cn.exrick.xboot.core.common.utils.ResultUtil; |
| | | import cn.exrick.xboot.core.common.vo.PageVo; |
| | | import cn.exrick.xboot.core.common.vo.Result; |
| | | import cn.exrick.xboot.core.entity.Setting; |
| | | import cn.exrick.xboot.core.entity.User; |
| | | import cn.exrick.xboot.core.service.SettingService; |
| | | 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.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.InputStream; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Autowired |
| | | private ICustomerReceiveService iCustomerReceiveService; |
| | | |
| | | @Autowired |
| | | private ICustomerService iCustomerService; |
| | | |
| | | @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) |
| | | @ApiOperation(value = "通过id获取") |
| | | public Result<Fingerprint> get(@PathVariable String id) { |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/getAll", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取全部数据") |
| | | @ApiOperation(value = "获取全部司机和配送员指纹数据") |
| | | public Result<List<Fingerprint>> getAll() { |
| | | QueryWrapper<Fingerprint> wrapper = new QueryWrapper<>(); |
| | | wrapper.isNotNull("user_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) { |
| | | QueryWrapper<Fingerprint> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("area_id",areaId); |
| | | List<Fingerprint> list = iFingerprintService.list(wrapper); |
| | | return new ResultUtil<List<Fingerprint>>().setData(list); |
| | | } |
| | |
| | | return new ResultUtil<IPage<Fingerprint>>().setData(data); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getUserByCode", method = RequestMethod.GET) |
| | | @ApiOperation(value = "用指纹编号司机或配送员的登录名和密码") |
| | | public Result<Object> getUserByCode(String code) { |
| | | QueryWrapper<Fingerprint> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("code",code); |
| | | wrapper.isNotNull("user_id"); |
| | | Fingerprint one = iFingerprintService.getOne(wrapper); |
| | | return new ResultUtil<Object>().setData(one); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getCustomerByCode", method = RequestMethod.GET) |
| | | @ApiOperation(value = "用指纹编号和商户id获取接货人信息") |
| | | public Result<Object> getCustomerByCode(String code,String customerId) { |
| | | Customer c = iCustomerService.getById(customerId); |
| | | 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){ |
| | | return ResultUtil.error("指纹与商户不匹配"); |
| | | } |
| | | |
| | | CustomerReceive customerReceive = iCustomerReceiveService.getById(one.getCustomerReceiveId()); |
| | | return new ResultUtil<Object>().setData(customerReceive); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getCode2", method = RequestMethod.GET) |
| | | @ApiOperation(value = "根据商户id获取接货人编号") |
| | | public Result<Object> getCode2(String customerId) { |
| | | Customer c = iCustomerService.getById(customerId); |
| | | int code = iFingerprintService.maxCode2(c.getAreaId()); |
| | | return new ResultUtil<Object>().setData(code); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getCode", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取司机或配送员指纹编号") |
| | | public Result<Object> getCode() { |
| | | int code = iFingerprintService.maxCode(); |
| | | return new ResultUtil<Object>().setData(code); |
| | | } |
| | | |
| | | @RequestMapping(value = "/insertOrUpdate", method = RequestMethod.POST) |
| | | @ApiOperation(value = "编辑或更新数据") |
| | | public Result<Fingerprint> saveOrUpdate(Fingerprint fingerprint) { |
| | |
| | | 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(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("操作失败"); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/delByIds", method = RequestMethod.POST) |
| | | @ApiOperation(value = "批量通过id删除") |
| | | public Result<Object> delAllByIds(@RequestParam String[] ids) { |