救援司机端
This commit is contained in:
parent
2fb14ca078
commit
22209220b8
@ -30,6 +30,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -0,0 +1,173 @@
|
||||
package cn.iocoder.yudao.module.rescue.app.controller.admin;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.rescue.core.controller.BaseController;
|
||||
import cn.iocoder.yudao.module.rescue.core.page.TableDataInfo;
|
||||
import cn.iocoder.yudao.module.rescue.core.redis.RedisCache;
|
||||
import cn.iocoder.yudao.module.rescue.core.text.HttpStatus;
|
||||
import cn.iocoder.yudao.module.rescue.domain.DriverInfo;
|
||||
import cn.iocoder.yudao.module.rescue.domain.RescueInfo;
|
||||
import cn.iocoder.yudao.module.rescue.domain.RescueInfoDetail;
|
||||
import cn.iocoder.yudao.module.rescue.domain.RescueRefuelRecord;
|
||||
import cn.iocoder.yudao.module.rescue.service.IDriverInfoService;
|
||||
import cn.iocoder.yudao.module.rescue.service.IRescueDriverInfoService;
|
||||
import cn.iocoder.yudao.module.rescue.service.IRescueInfoService;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.module.rescue.service.impl.RescueDriverInfoServiceImpl.Redis_Driver_Key;
|
||||
|
||||
/**
|
||||
* app司机端接口
|
||||
*
|
||||
* @author zcy
|
||||
* @date 2023-07-14
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/driver")
|
||||
public class RescueDriverController extends BaseController {
|
||||
@Autowired
|
||||
private IRescueDriverInfoService rescueDriverInfoService;
|
||||
@Autowired
|
||||
private IDriverInfoService driverInfoService;
|
||||
@Autowired
|
||||
private IRescueInfoService rescueInfoService;
|
||||
@Autowired
|
||||
private RedisCache redisCache2;
|
||||
@Autowired
|
||||
private AdminUserApi userService;
|
||||
|
||||
//获取司机状态
|
||||
@GetMapping("/getStatus")
|
||||
public CommonResult getStatus(Long driverId)
|
||||
{
|
||||
return success( rescueDriverInfoService.getStatus(driverId));
|
||||
}
|
||||
//司机数据统计
|
||||
@GetMapping("/driverInfoStatistics")
|
||||
public CommonResult driverInfoStatistics(Long driverId)
|
||||
{
|
||||
return success( rescueDriverInfoService.driverInfoStatistics(driverId));
|
||||
}
|
||||
//司机待救援列表
|
||||
@GetMapping("/driverRescueList")
|
||||
public CommonResult driverRescueList()
|
||||
{
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
DriverInfo driverInfo = driverInfoService.getOne(new LambdaQueryWrapper<DriverInfo>().eq(DriverInfo::getUserId, loginUser.getId()));
|
||||
return success(rescueDriverInfoService.driverRescueList(driverInfo.getId()));
|
||||
}
|
||||
//司机进行中的 已完成的救援信息
|
||||
@GetMapping("/driverRescuePage")
|
||||
public CommonResult driverRescuePage(RescueInfo rescueInfo,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize)
|
||||
{
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
DriverInfo driverInfo = driverInfoService.getOne(new LambdaQueryWrapper<DriverInfo>().eq(DriverInfo::getUserId, loginUser.getId()));
|
||||
rescueInfo.setDriverId(driverInfo.getId());
|
||||
Page<RescueInfo> page = new Page<>(pageNum, pageSize);
|
||||
if (rescueInfo.getRescueStatus().equals("2")){
|
||||
IPage<RescueInfo> rescueInfos = rescueDriverInfoService.driverRescueList2(driverInfo.getId(), page);
|
||||
return success(rescueInfos);
|
||||
}else {
|
||||
IPage<RescueInfo> rescueInfos = rescueDriverInfoService.driverRescuePage2(rescueInfo, page);
|
||||
return success(rescueInfos);
|
||||
}
|
||||
|
||||
}
|
||||
//司机待救援列表
|
||||
@PostMapping("/updateWork")
|
||||
public CommonResult updateWork(Long driverId) throws Exception {
|
||||
DriverInfo driverInfo = driverInfoService.getById(driverId);
|
||||
if (driverInfo.getDriverStatus().equals("2")){
|
||||
driverInfo.setDriverStatus("1");
|
||||
}else {
|
||||
LambdaQueryWrapper<RescueInfo> queryWrapper =new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(RescueInfo::getDriverId,driverId).eq(RescueInfo::getRescueStatus,"3").last("limit 1");
|
||||
RescueInfo one = rescueInfoService.getOne(queryWrapper);
|
||||
if (!ObjectUtil.isEmpty(one)){
|
||||
throw new Exception("有订单进行中,不可暂停");
|
||||
}
|
||||
driverInfo.setDriverStatus("2");
|
||||
}
|
||||
AdminUserRespDTO sysUser = userService.getUser(driverInfo.getUserId());
|
||||
//所在顶级机构
|
||||
String redisKey = Redis_Driver_Key+sysUser.getDeptId()+":"+driverId;
|
||||
if (!redisCache2.hasKey(redisKey)){
|
||||
redisCache2.setCacheMapValue(redisKey,"status",driverInfo.getDriverStatus());
|
||||
}
|
||||
driverInfoService.updateById(driverInfo);
|
||||
return success();
|
||||
}
|
||||
//司机接受或拒绝 choose 0拒绝1接受
|
||||
@PostMapping("/driverAccept")
|
||||
public CommonResult driverAccept(Long rescueDriverId,String choose,String rejectReason) throws Exception {
|
||||
rescueDriverInfoService.driverAccept(rescueDriverId, choose, rejectReason);
|
||||
return success("查询成功");
|
||||
}
|
||||
|
||||
//救援信息详情
|
||||
@GetMapping("/rescueDetail")
|
||||
public CommonResult rescueDetail(Long rescueId)
|
||||
{
|
||||
return success(rescueDriverInfoService.rescueDetail(rescueId));
|
||||
}
|
||||
|
||||
|
||||
//救援信息详情
|
||||
@PostMapping("/uploadDetailByDriver")
|
||||
public CommonResult uploadDetailByDriver(@RequestBody RescueInfoDetail rescueInfoDetail) throws Exception {
|
||||
rescueDriverInfoService.uploadDetailByDriver(rescueInfoDetail);
|
||||
return success("成功");
|
||||
}
|
||||
//设置应收金额
|
||||
@PostMapping("/setOrderMoney")
|
||||
public CommonResult setOrderMoney(@RequestParam("rescueId") String rescueId,@RequestParam("setMoney") Double setMoney) throws Exception {
|
||||
rescueDriverInfoService.setOrderMoney(Long.parseLong(rescueId),setMoney);
|
||||
return success("成功");
|
||||
}
|
||||
//完成救援
|
||||
@PostMapping("/endRescue")
|
||||
public CommonResult endRescue(@RequestParam("rescueId") String rescueId) throws Exception {
|
||||
rescueDriverInfoService.endRescue(Long.parseLong(rescueId));
|
||||
return success("成功");
|
||||
}
|
||||
//上传加油记录
|
||||
@PostMapping("/addRefuelRecord")
|
||||
public CommonResult addRefuelRecord(@RequestBody RescueRefuelRecord rescueRefuelRecord) throws Exception {
|
||||
rescueDriverInfoService.addRefuelRecord(rescueRefuelRecord);
|
||||
return success("成功");
|
||||
}
|
||||
|
||||
//获取加油记录
|
||||
@GetMapping("/listRefuelRecord")
|
||||
public CommonResult listRefuelRecord(RescueRefuelRecord rescueRefuelRecord,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
Page<RescueRefuelRecord> page = new Page<>(pageNum, pageSize);
|
||||
IPage<RescueRefuelRecord> rescueRefuelRecords = rescueDriverInfoService.listRefuelRecord(rescueRefuelRecord, page);
|
||||
return success(rescueRefuelRecords);
|
||||
}
|
||||
|
||||
protected TableDataInfo getDataTable(List<?> list)
|
||||
{
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(list);
|
||||
rspData.setTotal(new PageInfo(list).getTotal());
|
||||
return rspData;
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package cn.iocoder.yudao.module.rescue.app.controller.admin;
|
||||
|
||||
import cn.iocoder.yudao.module.rescue.service.IRescueDriverInfoService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.websocket.*;
|
||||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
/**`1
|
||||
* @Author: chuxia0811
|
||||
* @Date: 2023/7/9 10:21
|
||||
* @Description :
|
||||
*/
|
||||
@ServerEndpoint(value = "/websocket/rescueDriver/{driverId}")
|
||||
@Component
|
||||
public class RescueDriverSocket {
|
||||
private final static Logger log = LoggerFactory.getLogger(RescueDriverSocket.class);
|
||||
// 保存链接的session,key为用户名,value为对应的session名
|
||||
private ConcurrentHashMap<String, Session> sessionMap = new ConcurrentHashMap<>();
|
||||
//关键代码,设置一个静态上下文属性appcontext
|
||||
private static ApplicationContext appcontext;
|
||||
public static void setAppcontext(ApplicationContext appcontext) {
|
||||
RescueDriverSocket.appcontext = appcontext;
|
||||
}
|
||||
public static ApplicationContext getAppcontext() {
|
||||
return appcontext;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建连接
|
||||
* 用于监听建立连接,当有客户端与该服务端点建立连接时,将会自回调该注解标注的方法
|
||||
* @param session
|
||||
* @param driverId
|
||||
*/
|
||||
@OnOpen
|
||||
public void onOpen(Session session, @PathParam(value = "driverId") String driverId) {
|
||||
this.sessionMap.put(driverId,session);
|
||||
//更新司机在线状态
|
||||
IRescueDriverInfoService rescueDriverInfoService = appcontext.getBean(IRescueDriverInfoService.class);
|
||||
rescueDriverInfoService.topLine(Long.parseLong(driverId));
|
||||
log.info("用户{}已创建连接", driverId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用于监听客户端向服务端发送消息,当客户端与服务端发送消息时,将会回调该注解标注的方法
|
||||
* {
|
||||
* longitude:124.11,
|
||||
* latitude:125.33,
|
||||
* positionInfo:"山东省济南市市中区八一立交桥"
|
||||
* }
|
||||
* @param msg
|
||||
* @param driverId
|
||||
*/
|
||||
@OnMessage
|
||||
public void onMessage(String msg,@PathParam(value = "driverId") String driverId){
|
||||
JSONObject requestMsg = JSONObject.parseObject(msg);
|
||||
//更新司机位置信息
|
||||
IRescueDriverInfoService rescueDriverInfoService = appcontext.getBean(IRescueDriverInfoService.class);
|
||||
rescueDriverInfoService.updatePosition(Long.parseLong(driverId),requestMsg);
|
||||
log.info("用户{}发来消息:{}",driverId,msg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用于监听连接关闭,当客户端与该服务端点断开连接时,将会回调该注解标注的方法
|
||||
* @param session
|
||||
* @param driverId
|
||||
*/
|
||||
@OnClose
|
||||
public void onClose(Session session,@PathParam(value = "driverId") String driverId){
|
||||
this.sessionMap.remove(driverId);
|
||||
//更新司机在线状态
|
||||
IRescueDriverInfoService rescueDriverInfoService = appcontext.getBean(IRescueDriverInfoService.class);
|
||||
rescueDriverInfoService.downLine(Long.parseLong(driverId));
|
||||
|
||||
log.info("用户{}已关闭连接", driverId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用于监听该连接上的任何错误,当客户端与该服务端点的连接发生任何异常,都将回调该注解标注的方法
|
||||
* 注意该方法的参数必选Throwable,可选Sessiion以及0-n个String参数,且String参数需要使用@PathParam注解标注
|
||||
* @param throwable
|
||||
* @param driverId
|
||||
*/
|
||||
@OnError
|
||||
public void onError(Throwable throwable,@PathParam(value = "driverId") String driverId){
|
||||
log.error("用户{}连接发生异常", driverId);
|
||||
}
|
||||
|
||||
}
|
@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -7,7 +7,9 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.rescue.core.redis.RedisCache;
|
||||
import cn.iocoder.yudao.module.rescue.domain.DriverInfo;
|
||||
import cn.iocoder.yudao.module.rescue.domain.LoginBody;
|
||||
import cn.iocoder.yudao.module.rescue.service.IDriverInfoService;
|
||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
||||
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
||||
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
||||
@ -19,6 +21,8 @@ import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthLoginRespVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
|
||||
import cn.iocoder.yudao.module.system.service.auth.AdminAuthService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.MenuService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -80,8 +84,8 @@ public class SysLoginController {
|
||||
// private IPartnerWorkerService jcWorkerService;
|
||||
// @Autowired
|
||||
// private IShopConfigService configService;
|
||||
// @Autowired
|
||||
// private IDriverInfoService driverInfoService;
|
||||
@Resource
|
||||
private IDriverInfoService driverInfoService;
|
||||
// @Autowired
|
||||
// private IDriveSchoolInfoService driveSchoolInfoService;
|
||||
//
|
||||
@ -391,27 +395,27 @@ public class SysLoginController {
|
||||
// return ajax;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取救援司机用户信息
|
||||
// *
|
||||
// * @return 用户信息
|
||||
// */
|
||||
// @GetMapping("/getRescueDriverInfo")
|
||||
// public AjaxResult getRescueDriverInfo()
|
||||
// {
|
||||
// LambdaQueryWrapper<DriverInfo> queryWrapper =new LambdaQueryWrapper<>();
|
||||
// SysUser user = SecurityUtils.getLoginUser().getUser();
|
||||
// queryWrapper.eq(DriverInfo::getUserId, user.getUserId());
|
||||
// DriverInfo driverInfo = driverInfoService.getOne(queryWrapper);
|
||||
// if (ObjectUtil.isEmpty(driverInfo)){
|
||||
// return error("信息有误");
|
||||
// }
|
||||
// SysUser sysUser = userService.selectUserById(user.getUserId());
|
||||
// AjaxResult ajax = success();
|
||||
// ajax.put("user", sysUser);
|
||||
// ajax.put("driverInfo", driverInfo);
|
||||
// return ajax;
|
||||
// }
|
||||
/**
|
||||
* 获取救援司机用户信息
|
||||
*
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("/getRescueDriverInfo")
|
||||
public CommonResult getRescueDriverInfo()
|
||||
{
|
||||
LambdaQueryWrapper<DriverInfo> queryWrapper =new LambdaQueryWrapper<>();
|
||||
Long userId = SecurityFrameworkUtils.getLoginUserId();
|
||||
queryWrapper.eq(DriverInfo::getUserId, userId);
|
||||
DriverInfo driverInfo = driverInfoService.getOne(queryWrapper);
|
||||
if (ObjectUtil.isEmpty(driverInfo)){
|
||||
return error(500, "信息有误");
|
||||
}
|
||||
AdminUserRespDTO user = userService.getUser(userId);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("user", user);
|
||||
map.put("driverInfo", driverInfo);
|
||||
return success(map);
|
||||
}
|
||||
//
|
||||
//
|
||||
// /**
|
||||
@ -628,4 +632,17 @@ public class SysLoginController {
|
||||
// // 解析加密后的字符串
|
||||
// return resultStr;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 同步数据
|
||||
* @author 小李
|
||||
* @date 14:51 2024/8/24
|
||||
* @param
|
||||
**/
|
||||
@GetMapping("/sync")
|
||||
@Operation(summary = "同步数据")
|
||||
public CommonResult syncData(){
|
||||
driverInfoService.syncData();
|
||||
return CommonResult.ok();
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import cn.iocoder.yudao.module.rescue.domain.RescueDriverInfo;
|
||||
import cn.iocoder.yudao.module.rescue.domain.RescueInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@ -69,6 +71,9 @@ public interface RescueDriverInfoMapper extends BaseMapper<RescueDriverInfo>
|
||||
List<RescueInfo> driverRescueList(@Param("driverId") Long driverId);
|
||||
List<RescueInfo> driverRescuePage(RescueInfo rescueInfo);
|
||||
|
||||
IPage<RescueInfo> driverRescueList2(@Param("driverId") Long driverId, Page<RescueInfo> page);
|
||||
IPage<RescueInfo> driverRescuePage2(@Param("map") RescueInfo rescueInfo, Page<RescueInfo> page);
|
||||
|
||||
int dqrList(Long driverId);
|
||||
|
||||
}
|
||||
|
@ -60,4 +60,13 @@ public interface IDriverInfoService extends IService<DriverInfo>
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDriverInfoById(Long id);
|
||||
|
||||
/**
|
||||
* 同步数据
|
||||
* @author 小李
|
||||
* @date 14:51 2024/8/24
|
||||
* @param
|
||||
**/
|
||||
void syncData();
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.rescue.service;
|
||||
import cn.iocoder.yudao.module.rescue.domain.*;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
|
||||
@ -43,6 +45,9 @@ public interface IRescueDriverInfoService extends IService<RescueDriverInfo>
|
||||
void setOrderMoney(Long rescueId,Double setMoney) throws Exception;
|
||||
void endRescue(Long rescueId) throws Exception;
|
||||
void addRefuelRecord(RescueRefuelRecord rescueRefuelRecord) throws Exception;
|
||||
List<RescueRefuelRecord> listRefuelRecord(RescueRefuelRecord rescueRefuelRecord);
|
||||
IPage<RescueRefuelRecord> listRefuelRecord(RescueRefuelRecord rescueRefuelRecord, Page<RescueRefuelRecord> page);
|
||||
|
||||
IPage<RescueInfo> driverRescueList2(Long id, Page<RescueInfo> page);
|
||||
|
||||
IPage<RescueInfo> driverRescuePage2(RescueInfo rescueInfo, Page<RescueInfo> page);
|
||||
}
|
||||
|
@ -1,14 +1,31 @@
|
||||
package cn.iocoder.yudao.module.rescue.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.common.CommonErrorCodeConstants;
|
||||
import cn.iocoder.yudao.module.rescue.domain.DriverInfo;
|
||||
import cn.iocoder.yudao.module.rescue.service.IDriverInfoService;
|
||||
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
|
||||
import cn.iocoder.yudao.module.staff.service.CompanyStaffService;
|
||||
import cn.iocoder.yudao.module.staff.service.UniqueCodeService;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import cn.iocoder.yudao.module.rescue.mapper.DriverInfoMapper;
|
||||
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Service业务层处理
|
||||
@ -17,8 +34,23 @@ import java.util.List;
|
||||
* @date 2023-07-18
|
||||
*/
|
||||
@Service
|
||||
public class DriverInfoServiceImpl extends ServiceImpl<DriverInfoMapper, DriverInfo> implements IDriverInfoService
|
||||
{
|
||||
public class DriverInfoServiceImpl extends ServiceImpl<DriverInfoMapper, DriverInfo> implements IDriverInfoService {
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private CompanyStaffService staffService;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private DeptApi deptApi;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private UniqueCodeService uniqueCodeService;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
@ -27,8 +59,7 @@ public class DriverInfoServiceImpl extends ServiceImpl<DriverInfoMapper, DriverI
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public DriverInfo selectDriverInfoById(Long id)
|
||||
{
|
||||
public DriverInfo selectDriverInfoById(Long id) {
|
||||
return baseMapper.selectDriverInfoById(id);
|
||||
}
|
||||
|
||||
@ -39,8 +70,7 @@ public class DriverInfoServiceImpl extends ServiceImpl<DriverInfoMapper, DriverI
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public List<DriverInfo> selectDriverInfoList(DriverInfo driverInfo)
|
||||
{
|
||||
public List<DriverInfo> selectDriverInfoList(DriverInfo driverInfo) {
|
||||
return baseMapper.selectDriverInfoList(driverInfo);
|
||||
}
|
||||
|
||||
@ -51,8 +81,7 @@ public class DriverInfoServiceImpl extends ServiceImpl<DriverInfoMapper, DriverI
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDriverInfo(DriverInfo driverInfo)
|
||||
{
|
||||
public int insertDriverInfo(DriverInfo driverInfo) {
|
||||
return baseMapper.insertDriverInfo(driverInfo);
|
||||
}
|
||||
|
||||
@ -63,8 +92,7 @@ public class DriverInfoServiceImpl extends ServiceImpl<DriverInfoMapper, DriverI
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDriverInfo(DriverInfo driverInfo)
|
||||
{
|
||||
public int updateDriverInfo(DriverInfo driverInfo) {
|
||||
return baseMapper.updateDriverInfo(driverInfo);
|
||||
}
|
||||
|
||||
@ -75,8 +103,7 @@ public class DriverInfoServiceImpl extends ServiceImpl<DriverInfoMapper, DriverI
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDriverInfoByIds(Long[] ids)
|
||||
{
|
||||
public int deleteDriverInfoByIds(Long[] ids) {
|
||||
return baseMapper.deleteDriverInfoByIds(ids);
|
||||
}
|
||||
|
||||
@ -87,8 +114,46 @@ public class DriverInfoServiceImpl extends ServiceImpl<DriverInfoMapper, DriverI
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDriverInfoById(Long id)
|
||||
{
|
||||
public int deleteDriverInfoById(Long id) {
|
||||
return baseMapper.deleteDriverInfoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步数据
|
||||
*
|
||||
* @param
|
||||
* @author 小李
|
||||
* @date 14:51 2024/8/24
|
||||
**/
|
||||
@Override
|
||||
public void syncData(){
|
||||
List<DriverInfo> driverInfos = baseMapper.selectList(new QueryWrapper<>());
|
||||
List<CompanyStaff> companyStaffs = new ArrayList<>();
|
||||
driverInfos.stream().forEach(item -> {
|
||||
AdminUserRespDTO user = adminUserApi.getUser(item.getUserId());
|
||||
if (ObjectUtil.isNotEmpty(user)){
|
||||
long count = staffService.count(new LambdaQueryWrapper<CompanyStaff>().eq(CompanyStaff::getUserId, user.getId()));
|
||||
if (count == 0){
|
||||
CompanyStaff staff = new CompanyStaff();
|
||||
staff.setUserId(user.getId());
|
||||
staff.setDeptId(user.getDeptId());
|
||||
DeptRespDTO dept = deptApi.getDept(user.getDeptId());
|
||||
staff.setCorpId(dept.getCorpId());
|
||||
String uniqueCode = uniqueCodeService.createUniqueCode();
|
||||
if (!ObjectUtil.isNotEmpty(uniqueCode)) {
|
||||
throw exception(CommonErrorCodeConstants.UNIQUE_CODE_CREATE_REPEAT);
|
||||
}
|
||||
staff.setUniqueCode(uniqueCode);
|
||||
|
||||
staff.setName(user.getNickname());
|
||||
staff.setTel(item.getPhonenumber());
|
||||
staff.setSex(String.valueOf(user.getSex()));
|
||||
companyStaffs.add(staff);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(companyStaffs)){
|
||||
staffService.saveBatch(companyStaffs);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ import cn.iocoder.yudao.module.rescue.utils.pay.WechatPayRequest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
@ -609,10 +611,14 @@ public class RescueDriverInfoServiceImpl extends ServiceImpl<RescueDriverInfoMap
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RescueRefuelRecord> listRefuelRecord(RescueRefuelRecord rescueRefuelRecord) {
|
||||
public IPage<RescueRefuelRecord> listRefuelRecord(RescueRefuelRecord rescueRefuelRecord, Page<RescueRefuelRecord> page) {
|
||||
LambdaQueryWrapper<RescueRefuelRecord> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(RescueRefuelRecord::getDriverId, rescueRefuelRecord.getDriverId()).orderByDesc(RescueRefuelRecord::getRecordTime);
|
||||
return refuelRecordService.list(queryWrapper);
|
||||
IPage<RescueRefuelRecord> result = page;
|
||||
List<RescueRefuelRecord> list = refuelRecordService.list(page, queryWrapper);
|
||||
result.setRecords(list);
|
||||
result.setTotal(list.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -629,7 +635,29 @@ public class RescueDriverInfoServiceImpl extends ServiceImpl<RescueDriverInfoMap
|
||||
buff.append(str.charAt(number));
|
||||
}
|
||||
return buff.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<RescueInfo> driverRescueList2(Long id, Page<RescueInfo> page){
|
||||
IPage<RescueInfo> rescueInfos = baseMapper.driverRescueList2(id, page);
|
||||
for (RescueInfo rescueInfo : rescueInfos.getRecords()) {
|
||||
String dljy_type = dictDataService.getDictDataLabel("dljy_type", rescueInfo.getRescueType());
|
||||
rescueInfo.setRescueTypeStr(dljy_type);
|
||||
String car_type = dictDataService.getDictDataLabel("rescue_car_type", rescueInfo.getCarType());
|
||||
rescueInfo.setCarTypeStr(car_type);
|
||||
}
|
||||
return rescueInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<RescueInfo> driverRescuePage2(RescueInfo rescueInfo, Page<RescueInfo> page){
|
||||
IPage<RescueInfo> rescueInfos = baseMapper.driverRescuePage2(rescueInfo, page);
|
||||
for (RescueInfo it : rescueInfos.getRecords()) {
|
||||
String dljy_type = dictDataService.getDictDataLabel("dljy_type", it.getRescueType());
|
||||
it.setRescueTypeStr(dljy_type);
|
||||
String car_type = dictDataService.getDictDataLabel("rescue_car_type", it.getCarType());
|
||||
it.setCarTypeStr(car_type);
|
||||
}
|
||||
return rescueInfos;
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +98,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and ri.driver_id is null
|
||||
ORDER BY rdi.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="driverRescueList2" resultType="cn.iocoder.yudao.module.rescue.domain.RescueInfo">
|
||||
SELECT
|
||||
ri.*,rdi.id as rescueDriverId
|
||||
FROM
|
||||
`rescue_info` ri
|
||||
INNER JOIN rescue_driver_info rdi ON ri.id = rdi.rescue_id AND rdi.driver_accept = '2'
|
||||
WHERE
|
||||
rdi.driver_id =#{driverId} and ri.rescue_status = '2'
|
||||
and ri.driver_id is null
|
||||
ORDER BY rdi.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="driverRescuePage" resultType="cn.iocoder.yudao.module.rescue.domain.RescueInfo">
|
||||
SELECT
|
||||
ri.*,roi.set_money
|
||||
@ -114,6 +127,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
ORDER BY ri.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="driverRescuePage2" resultType="cn.iocoder.yudao.module.rescue.domain.RescueInfo">
|
||||
SELECT
|
||||
ri.*,roi.set_money
|
||||
FROM
|
||||
`rescue_info` ri
|
||||
left join rescue_order_info roi on ri.id = roi.rescue_info_id
|
||||
WHERE
|
||||
ri.driver_id =#{map.driverId}
|
||||
<if test="map.rescueStatus == '3'.toString()">
|
||||
and ri.rescue_status = #{map.rescueStatus}
|
||||
</if>
|
||||
<if test="map.rescueStatus == '5'.toString()">
|
||||
and (ri.rescue_status = '5' or ri.rescue_status = '6')
|
||||
</if>
|
||||
ORDER BY ri.create_time desc
|
||||
</select>
|
||||
<select id="dqrList" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
count(1)
|
||||
|
@ -129,7 +129,7 @@ public class YudaoWebSecurityConfigurerAdapter {
|
||||
.authorizeRequests()
|
||||
// 1.1 静态资源,可匿名访问
|
||||
.antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll()
|
||||
.antMatchers(HttpMethod.POST, "/admin-api/rescue/login", "/admin-api/rescue/loginApp").anonymous()
|
||||
.antMatchers(HttpMethod.POST, "/admin-api/rescue/login", "/admin-api/rescue/loginApp", "/admin-api/rescue/driverLogin").anonymous()
|
||||
// 1.2 设置 @PermitAll 无需认证
|
||||
.antMatchers(HttpMethod.GET, permitAllUrls.get(HttpMethod.GET).toArray(new String[0])).permitAll()
|
||||
.antMatchers(HttpMethod.POST, permitAllUrls.get(HttpMethod.POST).toArray(new String[0])).permitAll()
|
||||
|
Loading…
Reference in New Issue
Block a user