diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java index 88fdafb2..ad0657da 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java @@ -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; diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueDriverController.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueDriverController.java new file mode 100644 index 00000000..f18228bb --- /dev/null +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueDriverController.java @@ -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().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().eq(DriverInfo::getUserId, loginUser.getId())); + rescueInfo.setDriverId(driverInfo.getId()); + Page page = new Page<>(pageNum, pageSize); + if (rescueInfo.getRescueStatus().equals("2")){ + IPage rescueInfos = rescueDriverInfoService.driverRescueList2(driverInfo.getId(), page); + return success(rescueInfos); + }else { + IPage 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 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 page = new Page<>(pageNum, pageSize); + IPage 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; + } +} diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueDriverSocket.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueDriverSocket.java new file mode 100644 index 00000000..33e4f490 --- /dev/null +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueDriverSocket.java @@ -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 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); + } + +} diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueInfoController.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueInfoController.java index 6442086f..62d45c73 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueInfoController.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueInfoController.java @@ -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; diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java index f2efef7d..f4881c58 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java @@ -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 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 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 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(); + } } diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/mapper/RescueDriverInfoMapper.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/mapper/RescueDriverInfoMapper.java index 716e1c82..5bcaf55b 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/mapper/RescueDriverInfoMapper.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/mapper/RescueDriverInfoMapper.java @@ -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 List driverRescueList(@Param("driverId") Long driverId); List driverRescuePage(RescueInfo rescueInfo); + IPage driverRescueList2(@Param("driverId") Long driverId, Page page); + IPage driverRescuePage2(@Param("map") RescueInfo rescueInfo, Page page); + int dqrList(Long driverId); } diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IDriverInfoService.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IDriverInfoService.java index 50640014..a9a36432 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IDriverInfoService.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IDriverInfoService.java @@ -60,4 +60,13 @@ public interface IDriverInfoService extends IService * @return 结果 */ public int deleteDriverInfoById(Long id); + + /** + * 同步数据 + * @author 小李 + * @date 14:51 2024/8/24 + * @param + **/ + void syncData(); + } diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueDriverInfoService.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueDriverInfoService.java index cdc92adf..047b4d25 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueDriverInfoService.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueDriverInfoService.java @@ -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 void setOrderMoney(Long rescueId,Double setMoney) throws Exception; void endRescue(Long rescueId) throws Exception; void addRefuelRecord(RescueRefuelRecord rescueRefuelRecord) throws Exception; - List listRefuelRecord(RescueRefuelRecord rescueRefuelRecord); + IPage listRefuelRecord(RescueRefuelRecord rescueRefuelRecord, Page page); + IPage driverRescueList2(Long id, Page page); + + IPage driverRescuePage2(RescueInfo rescueInfo, Page page); } diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/DriverInfoServiceImpl.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/DriverInfoServiceImpl.java index c1cd08da..c4aed1eb 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/DriverInfoServiceImpl.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/DriverInfoServiceImpl.java @@ -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 implements IDriverInfoService -{ +public class DriverInfoServiceImpl extends ServiceImpl 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 selectDriverInfoList(DriverInfo driverInfo) - { + public List selectDriverInfoList(DriverInfo driverInfo) { return baseMapper.selectDriverInfoList(driverInfo); } @@ -51,8 +81,7 @@ public class DriverInfoServiceImpl extends ServiceImpl driverInfos = baseMapper.selectList(new QueryWrapper<>()); + List companyStaffs = new ArrayList<>(); + driverInfos.stream().forEach(item -> { + AdminUserRespDTO user = adminUserApi.getUser(item.getUserId()); + if (ObjectUtil.isNotEmpty(user)){ + long count = staffService.count(new LambdaQueryWrapper().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); + } + }; } diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueDriverInfoServiceImpl.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueDriverInfoServiceImpl.java index ed928fa7..12dcdde3 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueDriverInfoServiceImpl.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueDriverInfoServiceImpl.java @@ -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 listRefuelRecord(RescueRefuelRecord rescueRefuelRecord) { + public IPage listRefuelRecord(RescueRefuelRecord rescueRefuelRecord, Page page) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(RescueRefuelRecord::getDriverId, rescueRefuelRecord.getDriverId()).orderByDesc(RescueRefuelRecord::getRecordTime); - return refuelRecordService.list(queryWrapper); + IPage result = page; + List list = refuelRecordService.list(page, queryWrapper); + result.setRecords(list); + result.setTotal(list.size()); + return result; } /** @@ -629,7 +635,29 @@ public class RescueDriverInfoServiceImpl extends ServiceImpl driverRescueList2(Long id, Page page){ + IPage 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 driverRescuePage2(RescueInfo rescueInfo, Page page){ + IPage 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; } } diff --git a/dl-module-rescue/src/main/resources/mapper/rescue/RescueDriverInfoMapper.xml b/dl-module-rescue/src/main/resources/mapper/rescue/RescueDriverInfoMapper.xml index eaffee38..d963139f 100644 --- a/dl-module-rescue/src/main/resources/mapper/rescue/RescueDriverInfoMapper.xml +++ b/dl-module-rescue/src/main/resources/mapper/rescue/RescueDriverInfoMapper.xml @@ -98,6 +98,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and ri.driver_id is null ORDER BY rdi.create_time desc + + + + +