Compare commits

...

5 Commits

Author SHA1 Message Date
Lx
1f410a5bd3 0905 2025-09-05 16:32:23 +08:00
Lx
9a22b73993 Merge remote-tracking branch 'origin/master' 2025-09-05 16:26:02 +08:00
Lx
808f939a68 Merge branch 'driver'
# Conflicts:
#	dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/mapper/CompanyStaffMapper.java
#	dl-module-company/src/main/resources/mapper/staff/CompanyStaffMapper.xml
#	dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueInfoServiceImpl.java
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/UserRoleMapper.java
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleService.java
2025-09-05 16:25:41 +08:00
Lx
986deb6e1d 0905 2025-09-05 16:12:49 +08:00
Lx
6b324e31cd 0905 2025-09-05 16:05:46 +08:00
48 changed files with 2292 additions and 65 deletions

View File

@ -81,7 +81,7 @@ public class RepairBookingServiceImpl extends ServiceImpl<RepairBookingMapper, R
// 正常的新增修改
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname();
Optional.ofNullable(loginUserId).ifPresent(repairBookingRespVO::setUserId);
// Optional.ofNullable(loginUserId).ifPresent(repairBookingRespVO::setUserId);
Optional.ofNullable(loginUserNickname).ifPresent(repairBookingRespVO::setTurnRepairName);
repairBookingRespVO.setBookingStatus("01");
baseMapper.insertOrUpdate(repairBookingRespVO);

View File

@ -13,13 +13,33 @@ import lombok.Data;
public class RepairBookingRespVO extends RepairBooking {
private String repairText;
/**
* 来源
*/
private String source;
/**
* 渠道
*/
private String channel;
/**
* 顾问手机号
*/
private String adviserPhone;
/**
* 备注
*/
private String remark;
/**
* 轮转预约顾问名称
*/
private String turnRepairName;
/**
* 救援id
*/
private Long rescueId;
}

View File

@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -17,8 +18,11 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.common.DictBaseConstants.COMPANY_STAFF_EDU;
import static cn.iocoder.yudao.common.DictBaseConstants.DICT_SYS_USER_SEX;

View File

@ -37,4 +37,9 @@ public interface CompanyStaffMapper extends BaseMapper<CompanyStaff> {
* @date: 2025/8/11 13:32
*/
UserDTO getStaff(Long id);
/**
* 根据手机号和id查询信息
*/
CompanyStaffRespVO selectByPhoneAndUserId(@Param("phone") String phone, @Param("userId") Long userId);
}

View File

@ -61,6 +61,7 @@ public interface CompanyStaffService extends IService<CompanyStaff> {
* @param userId 用户ID
**/
void deleteStaffByUserId(Long userId);
void deleteStaffByUserIdNew(Long userId);
/**
* 获取当前功能的标签
@ -101,6 +102,10 @@ public interface CompanyStaffService extends IService<CompanyStaff> {
**/
CompanyStaff queryByPhone(String phone);
CompanyStaffRespVO selectByPhoneAndUserId(String phone, Long userId);
/**
* 验证工号是否重复
* @author 小李

View File

@ -310,6 +310,21 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
baseMapper.deleteById(staff.getId());
}
@Override
@DSTransactional
public void deleteStaffByUserIdNew(Long userId) {
/* 获取删除记录详细信息 */
LambdaQueryWrapper<CompanyStaff> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CompanyStaff::getUserId, userId).last("limit 1");
CompanyStaff staff = baseMapper.selectOne(queryWrapper);
/* 删除sys_users记录 */
adminUserApi.deleteUser(staff.getUserId());
/* 删除业务标签表记录 */
busiLabelService.remove(new LambdaQueryWrapper<BusiLabel>().eq(BusiLabel::getMainId, staff.getId()));
/* 删除员工表记录 */
baseMapper.deleteById(staff.getId());
}
/**
* 查询员工
*
@ -466,6 +481,15 @@ public class CompanyStaffServiceImpl extends ServiceImpl<CompanyStaffMapper, Com
}
}
@Override
public CompanyStaffRespVO selectByPhoneAndUserId(String phone, Long userId) {
CompanyStaffRespVO companyStaffRespVO = baseMapper.selectByPhoneAndUserId(phone, userId);
List<Long> roleIds = permissionApi.getRoleIdsByUserId(companyStaffRespVO.getUserId());
companyStaffRespVO.setRoleIds(roleIds);
return companyStaffRespVO;
}
/**
* 验证工号是否重复
*

View File

@ -163,4 +163,23 @@
ORDER BY
su.nickname
</select>
<select id="selectByPhoneAndUserId" resultType="cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO">
SELECT
cs.*,
IFNULL(GROUP_CONCAT(DISTINCT sur.role_id), '') AS roleIdsStr
FROM
company_staff cs
LEFT JOIN
system_user_role sur ON cs.user_id = sur.user_id
AND sur.deleted = 0
WHERE
cs.deleted = 0
AND cs.user_id IS NOT NULL
AND cs.tel = #{phone}
AND cs.user_id = #{userId}
GROUP BY
cs.id;
</select>
</mapper>

View File

@ -68,7 +68,7 @@ public class RescueInfoController extends BaseController {
if (CollectionUtil.isNotEmpty(roles)) {
for (RoleReqDTO role : roles) {
//如果是调度中心
if (role.getCode().equals("admin") || role.getCode().equals("ddzx") || role.getCode().equals("qt") || role.getCode().equals("kj") || role.getCode().equals("cn")) {
if (role.getCode().equals("admin") || role.getCode().equals("ddzx") || role.getCode().equals("qt") || role.getCode().equals("kj") || role.getCode().equals("cn") || role.getCode().equals("car_safekeeping")) {
IPage<RescueInfo> rescueInfos = rescueInfoService.selectRescueInfoListByAdmin(rescueInfo, page);
return success(rescueInfos);
}
@ -281,27 +281,30 @@ public class RescueInfoController extends BaseController {
@PostMapping("/toRepair")
public CommonResult toRepair(Long id) {
RescueInfo rescueInfo = rescueInfoService.getById(id);
public CommonResult toRepair(@RequestBody RepairBookingRespVO repairBookingRespVO) {
RescueInfo rescueInfo = rescueInfoService.getById(repairBookingRespVO.getRescueId());
if("1".equals(rescueInfo.getIsWeiXiu())){
return error("已转维修,请勿重复操作");
}
// 创建维修订单
RepairBookingRespVO repairBooking = new RepairBookingRespVO();
repairBooking.setUserName(rescueInfo.getConnectionName());
repairBooking.setUserMobile(rescueInfo.getConnectionPhone());
repairBooking.setCarNo(rescueInfo.getLicenseNum());
repairBooking.setUserName(repairBookingRespVO.getUserName());
repairBooking.setUserMobile(repairBookingRespVO.getUserMobile());
repairBooking.setCarNo(repairBookingRespVO.getCarNo());
repairBooking.setSource("救援转维修");
repairBooking.setChannel(rescueInfo.getChannel());
repairBooking.setRepairType("06");
repairBooking.setBookingTime(LocalDateTime.now() );
repairBooking.setAdviserId(rescueInfo.getAdviserId());
repairBooking.setAdviserName(rescueInfo.getAdviserName());
repairBooking.setAdviserPhone(rescueInfo.getAdviserPhone());
repairBooking.setAdviserId(repairBookingRespVO.getAdviserId());
repairBooking.setAdviserName(repairBookingRespVO.getAdviserName());
repairBooking.setAdviserPhone(repairBookingRespVO.getAdviserPhone());
dlRepairBookingService.updateBooking(repairBooking);
rescueInfo.setIsWeiXiu("1");
rescueInfo.setZwxUserId(rescueInfoService.safeStringToLong(repairBookingRespVO.getAdviserId(), null));
rescueInfoService.updateRescueInfo(rescueInfo);
return success(rescueInfo);
}
}

View File

@ -162,8 +162,18 @@ public class SysLoginController {
return error(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST);
}
List<RoleReqDTO> roleList = roleApi.getRoleList();
List<String> roleNames = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).map(item -> item.getName()).collect(Collectors.toList());
Boolean flag = (loginBody.getType().equals("0") && roleNames.contains("调度中心")) || (loginBody.getType().equals("0") && roleNames.contains("交警大队") || (loginBody.getType().equals("0") && roleNames.contains("救援二级调度")) || (loginBody.getType().equals("0") && roleNames.contains("二级调度")));
/*List<String> roleNames = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).map(item -> item.getName()).collect(Collectors.toList());
Boolean flag = (loginBody.getType().equals("0") && roleNames.contains("调度中心")) ||
(loginBody.getType().equals("0") && roleNames.contains("交警大队") ||
(loginBody.getType().equals("0") && roleNames.contains("救援二级调度")) ||
(loginBody.getType().equals("0") && roleNames.contains("二级调度")) ||
(loginBody.getType().equals("0") && roleNames.contains("车辆保管员")));*/
List<String> roleCodes = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).map(item -> item.getCode()).collect(Collectors.toList());
Boolean flag = ("0".equals(loginBody.getType()) && roleCodes.contains("ddzx")) ||
("0".equals(loginBody.getType()) && roleCodes.contains("jjdd")) ||
("0".equals(loginBody.getType()) && roleCodes.contains("second_dispatcher")) ||
("0".equals(loginBody.getType()) && roleCodes.contains("first_dispatcher")) ||
("0".equals(loginBody.getType()) && roleCodes.contains("car_safekeeping"));
// 角色认证登录
if (!flag) {
return error(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST);

View File

@ -0,0 +1,163 @@
package cn.iocoder.yudao.module.rescue.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.rescue.core.controller.BaseController;
import cn.iocoder.yudao.module.rescue.domain.RescueChannelSource;
import cn.iocoder.yudao.module.rescue.service.IRescueChannelSourceService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 救援渠道-来源 前端控制器
* </p>
*
* @author author
* @since 2025-09-03
*/
@RestController
@RequestMapping("/rescue-channel-source")
public class RescueChannelSourceController extends BaseController {
@Autowired
private IRescueChannelSourceService rescueChannelSourceService;
/**
* 分页查询渠道列表包含来源
*/
@GetMapping("/channelPage")
public CommonResult<?> getChannelPageList(
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize) {
Page<RescueChannelSource> page = new Page<>(pageNo, pageSize);
return success(rescueChannelSourceService.getChannelPageList(name, page));
}
/**
* 根据渠道ID查询来源列表
*/
@GetMapping("/sources/{channelId}")
public CommonResult<List<RescueChannelSource>> getSourcesByChannelId(@PathVariable("channelId") Integer channelId) {
List<RescueChannelSource> sources = rescueChannelSourceService.getSourcesByChannelId(channelId);
return success(sources);
}
/**
* 根据父id查询子列表
*/
@GetMapping("/listByPid")
public CommonResult<List<RescueChannelSource>> listByPid(@RequestParam(value = "pid", required = false) Integer pid) {
List<RescueChannelSource> list = rescueChannelSourceService.listByPid(pid);
return success(list);
}
@GetMapping("/channelList")
public CommonResult<List<RescueChannelSource>> channelList() {
return success(rescueChannelSourceService.channelList());
}
@GetMapping("/getChannelListByDispatchId")
public CommonResult<List<RescueChannelSource>> getChannelListByDispatchId(@RequestParam(value = "dispatchId", required = false) Long dispatchId) {
return success(rescueChannelSourceService.getChannelListByDispatchId(dispatchId));
}
/**
* 新增渠道
*/
@PostMapping("/createChannel")
public CommonResult<Boolean> createChannel(@RequestBody RescueChannelSource channel) {
channel.setType(0); // 0-业务渠道
return success(rescueChannelSourceService.save(channel));
}
/**
* 新增渠道
*/
@PostMapping("/createChannelApp")
public CommonResult<Boolean> createChannelApp(@RequestBody RescueChannelSource channel) {
channel.setType(0); // 0-业务渠道
return success(rescueChannelSourceService.createChannelApp(channel));
}
/**
* 新增来源
* 父id必传
*/
@PostMapping("/createSource")
public CommonResult<Boolean> createSource(@RequestBody RescueChannelSource source) {
if (source.getPid() == null) {
return CommonResult.error(500, "渠道不能为空");
}
source.setType(1); // 1-客户来源
return success(rescueChannelSourceService.save(source));
}
@PostMapping("/createSourceApp")
public CommonResult<Boolean> createSourceApp(@RequestBody RescueChannelSource source) {
if (source.getPid() == null) {
return CommonResult.error(500, "渠道不能为空");
}
source.setType(1); // 1-客户来源
return success(rescueChannelSourceService.createSourceApp(source));
}
/**
* 修改渠道
*/
@PutMapping("/updateChannel")
public CommonResult<Boolean> updateChannel(@RequestBody RescueChannelSource channel) {
if (channel.getId() == null) {
return CommonResult.error(500, "渠道ID不能为空");
}
channel.setType(0); // 确保类型为渠道
return success(rescueChannelSourceService.updateById(channel));
}
/**
* 修改来源
*/
@PutMapping("/updateSource")
public CommonResult<Boolean> updateSource(@RequestBody RescueChannelSource source) {
if (source.getId() == null) {
return CommonResult.error(500, "来源ID不能为空");
}
source.setType(1); // 确保类型为来源
return success(rescueChannelSourceService.updateById(source));
}
/**
* 删除渠道
*/
@DeleteMapping("/deleteChannel/{id}")
public CommonResult<Boolean> deleteChannel(@PathVariable("id") Integer id) {
// 删除渠道前需要检查是否有子来源
boolean hasChildren = rescueChannelSourceService.hasChildren(id);
if (hasChildren) {
return CommonResult.error(500, "该渠道下存在来源,无法删除");
}
return success(rescueChannelSourceService.removeById(id));
}
/**
* 删除来源
*/
@DeleteMapping("/deleteSource/{id}")
public CommonResult<Boolean> deleteSource(@PathVariable("id") Integer id) {
return success(rescueChannelSourceService.removeById(id));
}
}

View File

@ -0,0 +1,176 @@
package cn.iocoder.yudao.module.rescue.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.rescue.core.controller.BaseController;
import cn.iocoder.yudao.module.rescue.domain.RescueCarInfo;
import cn.iocoder.yudao.module.rescue.domain.RescueDriverCarRelation;
import cn.iocoder.yudao.module.rescue.service.IRescueDriverCarRelationService;
import cn.iocoder.yudao.module.rescue.vo.CarAssignmentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* <p>
* 司机与车辆关联表主车/副车 前端控制器
* </p>
*
* @author author
* @since 2025-09-02
*/
@RestController
@RequestMapping("/rescue/rescue-driver-car-relation")
public class RescueDriverCarRelationController extends BaseController {
@Autowired
private IRescueDriverCarRelationService rescueDriverCarRelationService;
/**
* 根据司机ID获取所有车辆
*/
@GetMapping("/driver/{driverId}")
public CommonResult<List<RescueDriverCarRelation>> getCarsByDriverId(@PathVariable Long driverId) {
return success(rescueDriverCarRelationService.getByDriverId(driverId));
}
@GetMapping("/getCarList")
public CommonResult<List<RescueCarInfo>> getCarList(@RequestParam Long driverId) {
return success(rescueDriverCarRelationService.getCarList(driverId));
}
/**
* 根据司机ID获取主车
*/
@GetMapping("/driver/{driverId}/primary")
public CommonResult<RescueDriverCarRelation> getPrimaryCar(@PathVariable Long driverId) {
return success(rescueDriverCarRelationService.getPrimaryCarByDriverId(driverId));
}
/**
* 根据司机ID获取主车
*/
@GetMapping("/getPrimaryCarInfo")
public CommonResult<RescueCarInfo> getPrimaryCarInfo(@RequestParam Long driverId) {
return success(rescueDriverCarRelationService.getPrimaryCarInfo(driverId));
}
/**
* 根据司机ID获取副车列表
*/
@GetMapping("/driver/{driverId}/secondary")
public CommonResult<List<RescueDriverCarRelation>> getSecondaryCars(@PathVariable Long driverId) {
return success(rescueDriverCarRelationService.getSecondaryCarsByDriverId(driverId));
}
/**
* 根据司机ID获取车辆统计信息
*/
@GetMapping("/driver/{driverId}/stats")
public CommonResult<Map<String, Object>> getCarStats(@PathVariable Long driverId) {
return success(rescueDriverCarRelationService.getCarStatsByDriverId(driverId));
}
/**
* 为司机分配车辆
* @param driverId
* @param carId
* @param isPrimary
* @return
*/
@PostMapping("/assign")
public CommonResult<Boolean> assignCar(@RequestParam Long driverId,
@RequestParam Long carId,
@RequestParam Boolean isPrimary) {
return success(rescueDriverCarRelationService.assignCarToDriver(driverId, carId, isPrimary));
}
/*@PostMapping("/batch-assign")
public CommonResult<Boolean> batchAssignCarsToDriver(@RequestParam("driverId") Long driverId,
@RequestParam(value = "primaryCarId", required = false) Long primaryCarId,
@RequestParam(value = "secondaryCarIds", required = false) List<Long> secondaryCarIds) {
return success(rescueDriverCarRelationService.batchAssignCarsToDriver(driverId, primaryCarId, secondaryCarIds));
}*/
@PostMapping("/batch-assign")
public CommonResult<String> batchAssignCars(@RequestBody CarAssignmentVO request) {
try {
boolean result = rescueDriverCarRelationService.batchAssignCarsToDriver(
request.getDriverId(),
request.getPrimaryCarId(),
request.getSecondaryCarIds()
);
if (result) {
return CommonResult.success("车辆分配成功");
} else {
return CommonResult.error(500, "车辆分配失败");
}
} catch (RuntimeException e) {
// 返回具体的错误信息
return CommonResult.error(500, e.getMessage());
} catch (Exception e) {
return CommonResult.error(500, "系统错误,请稍后重试");
}
}
/**
* 移除车辆关系
*/
@DeleteMapping("/{relationId}")
public CommonResult<Boolean> removeRelation(@PathVariable Long relationId) {
return success(rescueDriverCarRelationService.removeCarFromDriver(relationId));
}
/**
* 切换车辆主副状态
*/
@PutMapping("/{relationId}/toggle-primary")
public CommonResult<Boolean> togglePrimary(@PathVariable Long relationId) {
return success(rescueDriverCarRelationService.toggleCarPrimaryStatus(relationId));
}
/**
* 批量移除车辆关系
*/
@PostMapping("/batch-remove")
public CommonResult<Boolean> batchRemove(@RequestParam Long driverId,
@RequestBody List<Long> carIds) {
return success(rescueDriverCarRelationService.batchRemoveByDriverId(driverId, carIds));
}
/**
* 根据ID获取关系详情
*/
@GetMapping("/{id}")
public CommonResult<RescueDriverCarRelation> getById(@PathVariable Long id) {
return success(rescueDriverCarRelationService.getById(id));
}
/**
* 新增车辆关系
*/
@PostMapping
public CommonResult<Boolean> create(@RequestBody RescueDriverCarRelation relation) {
return success(rescueDriverCarRelationService.save(relation));
}
/**
* 更新车辆关系
*/
@PutMapping
public CommonResult<Boolean> update(@RequestBody RescueDriverCarRelation relation) {
return success(rescueDriverCarRelationService.updateById(relation));
}
/**
* 根据司机id删除对应数据
*/
@GetMapping("/driver/{driverId}/deleted")
public CommonResult deletedByDriverId(@PathVariable Long driverId) {
rescueDriverCarRelationService.deletedByDriverId(driverId);
return success();
}
}

View File

@ -224,6 +224,15 @@ public class RescueInfoSystem extends BaseController {
return success(list);
}
@GetMapping("/driverAndCarList")
public CommonResult<IPage<?>> driverAndCarList(DriverInfoDto driverInfoDto,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
Page<DriverInfo> page = new Page<>(pageNo, pageSize);
IPage<DriverInfo> list = rescueInfoService.driverAndCarList(driverInfoDto, page);
return success(list);
}
@GetMapping("/getDriverById")
public CommonResult getDriverById(Long driverId) {
return CommonResult.success(rescueInfoService.getDriverById(driverId));
@ -265,6 +274,18 @@ public class RescueInfoSystem extends BaseController {
return CommonResult.success(userId);
}
@PostMapping("/addDriverAppNew")
public CommonResult addDriverAppNew(@RequestBody DriverInfo driverInfo) {
Long userId;
try {
userId = rescueInfoService.addDriverAppNew(driverInfo);
} catch (Exception e) {
return CommonResult.error(500, e.getMessage());
}
return CommonResult.success(userId);
}
/**
* 新增文件夹
* @param userId 用户id
@ -284,12 +305,33 @@ public class RescueInfoSystem extends BaseController {
return CommonResult.success("修改成功");
}
/**
* 修改信息司机
*/
@PostMapping("/updateDriverNew")
public CommonResult updateDriverNew(@RequestBody DriverInfo driverInfoDto) {
rescueInfoService.updateDriverNew(driverInfoDto);
return CommonResult.success("修改成功");
}
@PostMapping("/delDriver")
public CommonResult delDriver(Long[] ids) {
rescueInfoService.delDriver(ids);
return CommonResult.success("删除成功");
}
@PostMapping("/delDriverNew")
public CommonResult delDriverNew(Long[] ids) {
rescueInfoService.delDriverNew(ids);
return CommonResult.success("删除成功");
}
@PostMapping("/delDriverStaffNew")
public CommonResult delDriverStaffNew(Long[] ids) {
rescueInfoService.delDriverStaffNew(ids);
return CommonResult.success("删除成功");
}
//获取扣车地点
@GetMapping("/getKcPosition")
public CommonResult getKcPosition(@RequestParam(required = false) String searchValue) {

View File

@ -0,0 +1,163 @@
package cn.iocoder.yudao.module.rescue.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.rescue.core.controller.BaseController;
import cn.iocoder.yudao.module.rescue.domain.RescueTypePhenomenon;
import cn.iocoder.yudao.module.rescue.service.IRescueTypePhenomenonService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 救援类型-现象 前端控制器
* </p>
*
* @author author
* @since 2025-09-05
*/
@RestController
@RequestMapping("/rescue-type-phenomenon")
public class RescueTypePhenomenonController extends BaseController {
@Autowired
private IRescueTypePhenomenonService rescueTypePhenomenonService;
/**
* 分页查询故障类型列表
*/
@GetMapping("/typePage")
public CommonResult<?> getTypePageList(
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize) {
Page<RescueTypePhenomenon> page = new Page<>(pageNo, pageSize);
return success(rescueTypePhenomenonService.getTypePageList(name, page));
}
/**
* 根据故障类型ID查询故障现象列表
*/
@GetMapping("/phenomenon/{typeId}")
public CommonResult<List<RescueTypePhenomenon>> getPhenomenonByTypeId(@PathVariable("typeId") Long typeId) {
List<RescueTypePhenomenon> sources = rescueTypePhenomenonService.getPhenomenonByTypeId(typeId);
return success(sources);
}
/**
* 根据父id查询子列表
*/
@GetMapping("/listPhenomenonByPid")
public CommonResult<List<RescueTypePhenomenon>> listPhenomenonByPid(@RequestParam(value = "pid", required = false) Long pid) {
List<RescueTypePhenomenon> list = rescueTypePhenomenonService.listPhenomenonByPid(pid);
return success(list);
}
/**
* 获取故障类型列表
*/
@GetMapping("/typeList")
public CommonResult<List<RescueTypePhenomenon>> typeList() {
return success(rescueTypePhenomenonService.typeList());
}
/**
* 获取故障现象列表
* @return
*/
@GetMapping("/phenomenonList")
public CommonResult<List<RescueTypePhenomenon>> phenomenonList() {
return success(rescueTypePhenomenonService.phenomenonList());
}
/**
* 新增故障类型
*/
@PostMapping("/createType")
public CommonResult<Boolean> createType(@RequestBody RescueTypePhenomenon type) {
type.setType(0); // 0-故障类型
return success(rescueTypePhenomenonService.save(type));
}
/**
* 新增故障现象
* 父id必传
*/
@PostMapping("/createPhenomenon")
public CommonResult<Boolean> createPhenomenon(@RequestBody RescueTypePhenomenon phenomenon) {
if (phenomenon.getPid() == null) {
return CommonResult.error(500, "故障类型不能为空");
}
phenomenon.setType(1); // 1-故障现象
return success(rescueTypePhenomenonService.save(phenomenon));
}
/**
* App新故障现象
* @param phenomenon
* @return
*/
@PostMapping("/createPhenomenonApp")
public CommonResult<Boolean> createPhenomenonApp(@RequestBody RescueTypePhenomenon phenomenon) {
if (phenomenon.getPid() == null) {
return CommonResult.error(500, "父id不能为空");
}
phenomenon.setType(1); // 1-故障现象
return success(rescueTypePhenomenonService.save(phenomenon));
}
/**
* 修改故障类型
*/
@PutMapping("/updateType")
public CommonResult<Boolean> updateType(@RequestBody RescueTypePhenomenon type) {
if (type.getId() == null) {
return CommonResult.error(500, "故障类型ID不能为空");
}
type.setType(0); // 确保类型为渠道
return success(rescueTypePhenomenonService.updateById(type));
}
/**
* 修改故障现象
*/
@PutMapping("/updatePhenomenon")
public CommonResult<Boolean> updatePhenomenon(@RequestBody RescueTypePhenomenon phenomenon) {
if (phenomenon.getId() == null) {
return CommonResult.error(500, "故障现象ID不能为空");
}
phenomenon.setType(1); // 确保类型为故障现象
return success(rescueTypePhenomenonService.updateById(phenomenon));
}
/**
* 删除故障类型
*/
@DeleteMapping("/deleteType/{id}")
public CommonResult<Boolean> deleteType(@PathVariable("id") Long id) {
// 删除渠道前需要检查是否有子来源
boolean hasChildren = rescueTypePhenomenonService.hasChildren(id);
if (hasChildren) {
return CommonResult.error(500, "该故障类型下存在故障现象,无法删除");
}
return success(rescueTypePhenomenonService.removeById(id));
}
/**
* 删除故障现象
*/
@DeleteMapping("/deletePhenomenon/{id}")
public CommonResult<Boolean> deletePhenomenon(@PathVariable("id") Long id) {
return success(rescueTypePhenomenonService.removeById(id));
}
}

View File

@ -97,6 +97,9 @@ public class DriverInfo extends TenantBaseDO
private long wcNum;
private Long folderId;
@TableField(exist = false)
private List<Long> roleIds;
/**
* 司机类型 01 自有 02 挂靠
*/
@ -113,4 +116,14 @@ public class DriverInfo extends TenantBaseDO
*/
private String channel;
/** 员工类型 */
private String staffType;
@TableField(exist = false)
private List<RescueDriverCarRelation> driverCarRelationList;
@TableField(exist = false)
private List<RescueDriverCarRelation> driverFirstCarRelationList;
@TableField(exist = false)
private List<RescueDriverCarRelation> driverSecondCarRelationList;
}

View File

@ -0,0 +1,57 @@
package cn.iocoder.yudao.module.rescue.domain;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 救援渠道-来源
* </p>
*
* @author author
* @since 2025-09-03
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("rescue_channel_source")
public class RescueChannelSource extends TenantBaseDO {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 父id
*/
private Integer pid;
/**
* 名称
*/
private String name;
/**
* 0-业务渠道 1-客户来源
*/
private Integer type;
/**
* 绑定的用户idss
*/
private String userIds;
@TableField(exist = false)
private Long userId;
}

View File

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.rescue.domain;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 司机与车辆关联表主车/副车
* </p>
*
* @author author
* @since 2025-09-02
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("rescue_driver_car_relation")
public class RescueDriverCarRelation extends TenantBaseDO {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 司机ID关联driver_info.id
*/
private Long driverId;
/**
* 用户ID
*/
private Long userId;
/**
* 车辆ID关联rescue_car_info.id
*/
private Long carId;
/**
* 是否为主车1是主车0是副车
*/
private Boolean isPrimary;
}

View File

@ -78,6 +78,12 @@ public class RescueInfo extends TenantBaseDO
@Excel(name = "车辆类型",dictType="rescue_car_type")
@NotEmpty(message = "车辆类型不能为空")
private String carType;
/**
* 是否为新能源0否1是
*/
private String ifNewEnergy;
/** 救援地点 详细描述 */
@Excel(name = "救援地点")
@NotEmpty(message = "救援地点不能为空")
@ -245,10 +251,20 @@ public class RescueInfo extends TenantBaseDO
private String carOwnerPhone;
/**
* 故障现象
* 故障现象备注
*/
private String faultPhenomenon;
/**
* 故障类型
*/
private String faultType;
/**
* 故障现象
*/
private String phenomenon;
/**
* 救援需求
*/
@ -274,6 +290,11 @@ public class RescueInfo extends TenantBaseDO
*/
private String secondDispatchName;
/**
* 调度电话
*/
private String secondDispatchPhone;
/**
* 来源
*/
@ -294,6 +315,26 @@ public class RescueInfo extends TenantBaseDO
*/
private String channel;
/**
* 救援地点备注
*/
private String remarkRescuePosition;
/**
* 目的地备注
*/
private String remarkDestinationInfo;
/**
* 扣车人userId
*/
private Long kcUserId;
/**
* 转维修人userId
*/
private Long zwxUserId;
@TableField(exist = false)
private String adviserId;
@ -329,4 +370,16 @@ public class RescueInfo extends TenantBaseDO
@TableField(exist = false)
private String orderSigningRealName;
@TableField(exist = false)
private String ifConfirmPay;
@TableField(exist = false)
private String confirmPaymentPersonName;
@TableField(exist = false)
private String confirmPaymentTime;
@TableField(exist = false)
private String confirmPaymentPersonRemark;
}

View File

@ -32,6 +32,9 @@ public class RescueInfoDetail extends TenantBaseDO
/** 补充图片 */
private String supplementImages;
/** 耗时 */
private String timeCost;
/** 创建人所在部门 */
@Excel(name = "创建人所在部门")
private Long deptId;

View File

@ -106,6 +106,9 @@ public class RescueOrderInfo extends TenantBaseDO
/** 挂账备注 */
private String orderSigningRemark;
/** 是否确认收款 0未确认 1已确认 */
private String ifConfirmPay;
/** 确认收款人id */
private Long confirmPaymentPersonId;

View File

@ -0,0 +1,47 @@
package cn.iocoder.yudao.module.rescue.domain;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 救援类型-现象
* </p>
*
* @author author
* @since 2025-09-05
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("rescue_type_phenomenon")
public class RescueTypePhenomenon extends TenantBaseDO {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 父id
*/
private Long pid;
/**
* 名称
*/
private String name;
/**
* 0-类型 1-故障现象
*/
private Integer type;
}

View File

@ -1,12 +1,14 @@
package cn.iocoder.yudao.module.rescue.dto;
import cn.iocoder.yudao.annotation.Excel;
import cn.iocoder.yudao.module.rescue.domain.RescueDriverCarRelation;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class DriverInfoDto {
@ -122,5 +124,8 @@ public class DriverInfoDto {
private String ancestors;
private String searchValue;
@TableField(exist = false)
private List<RescueDriverCarRelation> driverCarRelationList;
}

View File

@ -33,8 +33,11 @@ public enum RescueRoleCommon {
/** 二级调度 */
SECOND_DISPATCHER("second_dispatcher", 2),
/** 车辆保管员 */
CAR_SAFEKEEEPING("car_safekeeping", 3),
/** 救援司机 */
JYSJ("jysj", 3);
JYSJ("jysj", 4);
/** 角色Code */
private final String code;

View File

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.rescue.mapper;
import cn.iocoder.yudao.module.rescue.domain.RescueChannelSource;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 救援渠道-来源 Mapper 接口
* </p>
*
* @author author
* @since 2025-09-03
*/
@Mapper
public interface RescueChannelSourceMapper extends BaseMapper<RescueChannelSource> {
/**
* 分页查询渠道列表包含来源
*/
IPage<RescueChannelSource> selectPageList(IPage<RescueChannelSource> page, @Param("name") String name);
List<RescueChannelSource> getChannelListByDispatchId(@Param("dispatchId") Long dispatchId);
}

View File

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.rescue.mapper;
import cn.iocoder.yudao.module.rescue.domain.RescueCarInfo;
import cn.iocoder.yudao.module.rescue.domain.RescueDriverCarRelation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* <p>
* 司机与车辆关联表主车/副车 Mapper 接口
* </p>
*
* @author author
* @since 2025-09-02
*/
@Mapper
public interface RescueDriverCarRelationMapper extends BaseMapper<RescueDriverCarRelation> {
void deletedByDriverId(Long driverId);
List<RescueCarInfo> getCarList(Long driverId);
RescueCarInfo getPrimaryCarInfo(Long driverId);
List<RescueCarInfo> getSecondaryCarInfo(Long driverId);
}

View File

@ -55,6 +55,7 @@ public interface RescueInfoMapper extends BaseMapper<RescueInfo>
IPage<DriverInfo> driverList(@Param("map") DriverInfoDto user, Page<DriverInfo> page);
List<DriverInfo2Dto> driverListApp(DriverInfoDto user);
List<DriverInfo2Dto> driverListAppNew(DriverInfoDto user);
List<DriverInfo2Dto> secondDriverListApp(DriverInfoDto user);
Map<String,Integer> driverInMap2();
void dealOverTimeRescue();

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.rescue.mapper;
import cn.iocoder.yudao.module.rescue.domain.RescueTypePhenomenon;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 救援类型-现象 Mapper 接口
* </p>
*
* @author author
* @since 2025-09-05
*/
@Mapper
public interface RescueTypePhenomenonMapper extends BaseMapper<RescueTypePhenomenon> {
}

View File

@ -0,0 +1,53 @@
package cn.iocoder.yudao.module.rescue.service;
import cn.iocoder.yudao.module.rescue.domain.RescueChannelSource;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* <p>
* 救援渠道-来源 服务类
* </p>
*
* @author author
* @since 2025-09-03
*/
public interface IRescueChannelSourceService extends IService<RescueChannelSource> {
/**
* 根据父ID查询子列表
* @param pid 父ID
* @return 子列表
*/
List<RescueChannelSource> listByPid(Integer pid);
List<RescueChannelSource> channelList();
List<RescueChannelSource> getChannelListByDispatchId(Long dispatchId);
boolean createChannelApp(RescueChannelSource channel);
boolean createSourceApp(RescueChannelSource source);
/**
* 检查是否有子节点
* @param id 父ID
* @return 是否有子节点
*/
boolean hasChildren(Integer id);
/**
* 分页查询渠道列表
*/
IPage<RescueChannelSource> getChannelPageList(String name, Page<RescueChannelSource> page);
/**
* 根据渠道ID查询来源列表
* @param channelId 渠道ID
* @return 来源列表
*/
List<RescueChannelSource> getSourcesByChannelId(Integer channelId);
}

View File

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.rescue.service;
import cn.iocoder.yudao.module.rescue.domain.RescueCarInfo;
import cn.iocoder.yudao.module.rescue.domain.RescueDriverCarRelation;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
* <p>
* 司机与车辆关联表主车/副车 服务类
* </p>
*
* @author author
* @since 2025-09-02
*/
public interface IRescueDriverCarRelationService extends IService<RescueDriverCarRelation> {
/**
* 根据司机ID获取所有车辆关系
*/
List<RescueDriverCarRelation> getByDriverId(Long driverId);
List<RescueDriverCarRelation> getFirstByDriverId(Long driverId);
List<RescueDriverCarRelation> getSecondByDriverId(Long driverId);
/**
* 根据司机ID获取主车
*/
RescueDriverCarRelation getPrimaryCarByDriverId(Long driverId);
List<RescueCarInfo> getCarList(Long driverId);
RescueCarInfo getPrimaryCarInfo(Long driverId);
List<RescueCarInfo> getSecondaryCarInfo(Long driverId);
/**
* 根据司机ID获取副车列表
*/
List<RescueDriverCarRelation> getSecondaryCarsByDriverId(Long driverId);
/**
* 为司机分配车辆
*/
boolean assignCarToDriver(Long driverId, Long carId, Boolean isPrimary);
boolean batchAssignCarsToDriver(Long driverId, Long primaryCarId, List<Long> secondaryCarIds);
/**
* 移除司机的车辆关系
*/
boolean removeCarFromDriver(Long relationId);
/**
* 切换车辆的主副状态
*/
boolean toggleCarPrimaryStatus(Long relationId);
/**
* 批量删除司机的车辆关系
*/
boolean batchRemoveByDriverId(Long driverId, List<Long> carIds);
/**
* 根据司机ID获取车辆统计信息
*/
Map<String, Object> getCarStatsByDriverId(Long driverId);
/**
* 根据司机id删除对应数据
*/
void deletedByDriverId(Long driverId);
}

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.rescue.service;
import cn.iocoder.yudao.module.booking.vo.RepairBookingRespVO;
import cn.iocoder.yudao.module.rescue.domain.DriverInfo;
import cn.iocoder.yudao.module.rescue.domain.RescueInfo;
import cn.iocoder.yudao.module.rescue.dto.DriverInfo2Dto;
@ -86,13 +87,18 @@ public interface IRescueInfoService extends IService<RescueInfo>
public void deleteRescueInfoById(Long id);
IPage<DriverInfo> driverList(DriverInfoDto user, Page<DriverInfo> page);
IPage<DriverInfo> driverListNew(DriverInfoDto user, Page<DriverInfo> page);
IPage<DriverInfo> driverAndCarList(DriverInfoDto user, Page<DriverInfo> page);
DriverInfo getDriverById(Long driverId);
void addDriver(DriverInfo driverInfo) throws Exception;
Long addDriverNew(DriverInfo driverInfo) throws Exception;
Long addDriverApp(DriverInfo driverInfo) throws Exception;
Long addDriverAppNew(DriverInfo driverInfo) throws Exception;
Long addFolder(Long userId);
void updateDriver(DriverInfo user);
void updateDriverNew(DriverInfo user);
void delDriver(Long[] ids);
void delDriverNew(Long[] ids);
void delDriverStaffNew(Long[] ids);
List<DriverInfo2Dto> driverListApp(DriverInfoDto driverInfoDto);
List<DriverInfo2Dto> driverInMap(DriverInfoDto driverInfoDto);
List<DriverInfo2Dto> secondDriverInMap(DriverInfoDto driverInfoDto);
@ -179,4 +185,6 @@ public interface IRescueInfoService extends IService<RescueInfo>
DriverStaffSaveVO getOnInternal(Long id);
List<DriverInfoExportVO> getAll(DriverInfoDto query);
Long safeStringToLong(String str, Long defaultValue);
}

View File

@ -0,0 +1,47 @@
package cn.iocoder.yudao.module.rescue.service;
import cn.iocoder.yudao.module.rescue.domain.RescueChannelSource;
import cn.iocoder.yudao.module.rescue.domain.RescueTypePhenomenon;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 救援类型-现象 服务类
* </p>
*
* @author author
* @since 2025-09-05
*/
public interface IRescueTypePhenomenonService extends IService<RescueTypePhenomenon> {
/**
* 根据父ID查询子列表
* @param pid 父ID
* @return 子列表
*/
List<RescueTypePhenomenon> listPhenomenonByPid(Long pid);
List<RescueTypePhenomenon> typeList();
List<RescueTypePhenomenon> phenomenonList();
/**
* 检查是否有子节点
* @param id 父ID
* @return 是否有子节点
*/
boolean hasChildren(Long id);
/**
* 分页查询渠道列表
*/
IPage<RescueTypePhenomenon> getTypePageList(String name, Page<RescueTypePhenomenon> page);
/**
* 根据渠道ID查询来源列表
* @return 来源列表
*/
List<RescueTypePhenomenon> getPhenomenonByTypeId(Long typeId);
}

View File

@ -190,7 +190,7 @@ public class RescueCarInfoServiceImpl extends ServiceImpl<RescueCarInfoMapper, R
@Override
public List<RescueCarInfo> getAllCar() {
return baseMapper.getNoAllocationCar();
return baseMapper.getAllCar();
}

View File

@ -0,0 +1,106 @@
package cn.iocoder.yudao.module.rescue.service.impl;
import cn.iocoder.yudao.module.rescue.domain.RescueChannelSource;
import cn.iocoder.yudao.module.rescue.domain.RescueSecondChannelAssociation;
import cn.iocoder.yudao.module.rescue.mapper.RescueChannelSourceMapper;
import cn.iocoder.yudao.module.rescue.mapper.RescueSecondChannelAssociationMapper;
import cn.iocoder.yudao.module.rescue.service.IRescueChannelSourceService;
import cn.iocoder.yudao.module.rescue.service.IRescueSecondChannelAssociationService;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
/**
* <p>
* 救援渠道-来源 服务实现类
* </p>
*
* @author author
* @since 2025-09-03
*/
@Service
public class RescueChannelSourceServiceImpl extends ServiceImpl<RescueChannelSourceMapper, RescueChannelSource> implements IRescueChannelSourceService {
@Resource
private IRescueSecondChannelAssociationService rescueSecondChannelAssociationService;
@Override
public List<RescueChannelSource> listByPid(Integer pid) {
LambdaQueryWrapper<RescueChannelSource> queryWrapper = new LambdaQueryWrapper<>();
if (pid == null) {
queryWrapper.eq(RescueChannelSource::getType, 1);
} else {
queryWrapper.eq(RescueChannelSource::getPid, pid);
}
queryWrapper.eq(RescueChannelSource::getDeleted, false).orderByAsc(RescueChannelSource::getCreateTime);
return this.list(queryWrapper);
}
@Override
public boolean hasChildren(Integer id) {
LambdaQueryWrapper<RescueChannelSource> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueChannelSource::getPid, id).eq(RescueChannelSource::getDeleted, false);
return this.count(queryWrapper) > 0;
}
@Override
public IPage<RescueChannelSource> getChannelPageList(String name, Page<RescueChannelSource> page) {
LambdaQueryWrapper<RescueChannelSource> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueChannelSource::getType, 0); // 只查询渠道
if (name != null && !name.trim().isEmpty()) {
queryWrapper.like(RescueChannelSource::getName, name);
}
queryWrapper.eq(RescueChannelSource::getDeleted, false).orderByAsc(RescueChannelSource::getCreateTime);
return this.page(page, queryWrapper);
}
@Override
public List<RescueChannelSource> getSourcesByChannelId(Integer channelId) {
LambdaQueryWrapper<RescueChannelSource> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueChannelSource::getPid, channelId)
.eq(RescueChannelSource::getType, 1) // 来源类型
.eq(RescueChannelSource::getDeleted, false)
.orderByAsc(RescueChannelSource::getCreateTime);
return this.list(queryWrapper);
}
@Override
public List<RescueChannelSource> channelList() {
LambdaQueryWrapper<RescueChannelSource> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueChannelSource::getType, 0)
.eq(RescueChannelSource::getDeleted, false)
.orderByAsc(RescueChannelSource::getCreateTime);
return this.list(queryWrapper);
}
@Override
public List<RescueChannelSource> getChannelListByDispatchId(Long dispatchId) {
return baseMapper.getChannelListByDispatchId(dispatchId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean createChannelApp(RescueChannelSource channel) {
this.save(channel);
RescueSecondChannelAssociation rescueSecondChannelAssociation = new RescueSecondChannelAssociation();
rescueSecondChannelAssociation.setDispatchId(channel.getUserId());
rescueSecondChannelAssociation.setChannelId(Long.valueOf(channel.getId()));
rescueSecondChannelAssociationService.save(rescueSecondChannelAssociation);
return true;
}
@Override
public boolean createSourceApp(RescueChannelSource source) {
return false;
}
}

View File

@ -0,0 +1,295 @@
package cn.iocoder.yudao.module.rescue.service.impl;
import cn.iocoder.yudao.module.rescue.domain.RescueCarInfo;
import cn.iocoder.yudao.module.rescue.domain.RescueDriverCarRelation;
import cn.iocoder.yudao.module.rescue.mapper.RescueDriverCarRelationMapper;
import cn.iocoder.yudao.module.rescue.service.IRescueCarInfoService;
import cn.iocoder.yudao.module.rescue.service.IRescueDriverCarRelationService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 司机与车辆关联表主车/副车 服务实现类
* </p>
*
* @author author
* @since 2025-09-02
*/
@Service
public class RescueDriverCarRelationServiceImpl extends ServiceImpl<RescueDriverCarRelationMapper, RescueDriverCarRelation> implements IRescueDriverCarRelationService {
@Resource
private IRescueCarInfoService rescueCarInfoService;
@Resource
private RescueDriverCarRelationMapper rescueDriverCarRelationMapper;
@Override
public List<RescueDriverCarRelation> getByDriverId(Long driverId) {
LambdaQueryWrapper<RescueDriverCarRelation> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RescueDriverCarRelation::getDriverId, driverId)
.eq(RescueDriverCarRelation::getDeleted, false)
.orderByDesc(RescueDriverCarRelation::getIsPrimary)
.orderByDesc(RescueDriverCarRelation::getCreateTime);
return this.list(wrapper);
}
@Override
public List<RescueDriverCarRelation> getFirstByDriverId(Long driverId) {
LambdaQueryWrapper<RescueDriverCarRelation> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RescueDriverCarRelation::getDriverId, driverId)
.eq(RescueDriverCarRelation::getIsPrimary, true)
.eq(RescueDriverCarRelation::getDeleted, false)
.orderByDesc(RescueDriverCarRelation::getCreateTime);
return this.list(wrapper);
}
@Override
public List<RescueDriverCarRelation> getSecondByDriverId(Long driverId) {
LambdaQueryWrapper<RescueDriverCarRelation> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RescueDriverCarRelation::getDriverId, driverId)
.eq(RescueDriverCarRelation::getIsPrimary, false)
.eq(RescueDriverCarRelation::getDeleted, false)
.orderByDesc(RescueDriverCarRelation::getCreateTime);
return this.list(wrapper);
}
@Override
public RescueDriverCarRelation getPrimaryCarByDriverId(Long driverId) {
LambdaQueryWrapper<RescueDriverCarRelation> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RescueDriverCarRelation::getDriverId, driverId)
.eq(RescueDriverCarRelation::getIsPrimary, true)
.eq(RescueDriverCarRelation::getDeleted, false);
return this.getOne(wrapper);
}
@Override
public List<RescueCarInfo> getCarList(Long driverId) {
return rescueDriverCarRelationMapper.getCarList(driverId);
}
@Override
public RescueCarInfo getPrimaryCarInfo(Long driverId) {
return rescueDriverCarRelationMapper.getPrimaryCarInfo(driverId);
}
@Override
public List<RescueCarInfo> getSecondaryCarInfo(Long driverId) {
return rescueDriverCarRelationMapper.getSecondaryCarInfo(driverId);
}
@Override
public List<RescueDriverCarRelation> getSecondaryCarsByDriverId(Long driverId) {
LambdaQueryWrapper<RescueDriverCarRelation> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RescueDriverCarRelation::getDriverId, driverId)
.eq(RescueDriverCarRelation::getIsPrimary, false)
.eq(RescueDriverCarRelation::getDeleted, false)
.orderByDesc(RescueDriverCarRelation::getCreateTime);
return this.list(wrapper);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean assignCarToDriver(Long driverId, Long carId, Boolean isPrimary) {
// 检查是否已存在相同关系
LambdaQueryWrapper<RescueDriverCarRelation> checkWrapper = new LambdaQueryWrapper<>();
checkWrapper.eq(RescueDriverCarRelation::getDriverId, driverId)
.eq(RescueDriverCarRelation::getCarId, carId)
.eq(RescueDriverCarRelation::getDeleted, false);
if (this.count(checkWrapper) > 0) {
throw new RuntimeException("该车辆已分配给此司机");
}
// 如果设置为主车需要先取消现有的主车
if (isPrimary) {
RescueDriverCarRelation existingPrimary = getPrimaryCarByDriverId(driverId);
if (existingPrimary != null) {
existingPrimary.setIsPrimary(false);
this.updateById(existingPrimary);
}
}
// 创建新的车辆关系
RescueDriverCarRelation relation = new RescueDriverCarRelation();
relation.setDriverId(driverId);
relation.setCarId(carId);
relation.setIsPrimary(isPrimary);
return this.save(relation);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean batchAssignCarsToDriver(Long driverId, Long primaryCarId, List<Long> secondaryCarIds) {
// 检查重复车辆ID主车和副车不能重复
Set<Long> allCarIds = new HashSet<>();
if (primaryCarId != null) {
allCarIds.add(primaryCarId);
}
if (secondaryCarIds != null) {
for (Long carId : secondaryCarIds) {
if (!allCarIds.add(carId)) {
throw new RuntimeException("车辆ID重复: " + carId);
}
}
}
// 3. 检查车辆是否存在且可用
checkCarsExist(new ArrayList<>(allCarIds));
// 4. 删除该司机现有的所有车辆关系
LambdaUpdateWrapper<RescueDriverCarRelation> deleteWrapper = new LambdaUpdateWrapper<>();
deleteWrapper.eq(RescueDriverCarRelation::getDriverId, driverId)
.set(RescueDriverCarRelation::getDeleted, true);
this.update(deleteWrapper);
// 5. 批量插入新的车辆关系
List<RescueDriverCarRelation> relations = new ArrayList<>();
// 插入主车
if (primaryCarId != null) {
RescueDriverCarRelation primaryRelation = new RescueDriverCarRelation();
primaryRelation.setDriverId(driverId);
primaryRelation.setCarId(primaryCarId);
primaryRelation.setIsPrimary(true);
relations.add(primaryRelation);
}
// 插入副车
if (secondaryCarIds != null && !secondaryCarIds.isEmpty()) {
for (Long carId : secondaryCarIds) {
RescueDriverCarRelation secondaryRelation = new RescueDriverCarRelation();
secondaryRelation.setDriverId(driverId);
secondaryRelation.setCarId(carId);
secondaryRelation.setIsPrimary(false);
relations.add(secondaryRelation);
}
}
// 6. 批量保存
if (!relations.isEmpty()) {
return this.saveBatch(relations);
}
return true;
}
/**
* 检查车辆是否存在
*/
private void checkCarsExist(List<Long> carIds) {
if (carIds == null || carIds.isEmpty()) {
return;
}
List<RescueCarInfo> existingCars = rescueCarInfoService.listByIds(carIds);
if (existingCars.size() != carIds.size()) {
Set<Long> existingCarIds = existingCars.stream()
.map(RescueCarInfo::getId)
.collect(Collectors.toSet());
List<Long> missingCarIds = carIds.stream()
.filter(id -> !existingCarIds.contains(id))
.collect(Collectors.toList());
throw new RuntimeException("以下车辆不存在: " + missingCarIds);
}
}
@Override
public boolean removeCarFromDriver(Long relationId) {
RescueDriverCarRelation relation = this.getById(relationId);
if (relation != null) {
// 软删除
relation.setDeleted(true);
return this.updateById(relation);
}
return false;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean toggleCarPrimaryStatus(Long relationId) {
RescueDriverCarRelation relation = this.getById(relationId);
if (relation == null || relation.getDeleted()) {
return false;
}
// 如果当前是副车要升级为主车
if (!relation.getIsPrimary()) {
// 先取消现有的主车
RescueDriverCarRelation existingPrimary = getPrimaryCarByDriverId(relation.getDriverId());
if (existingPrimary != null) {
existingPrimary.setIsPrimary(false);
this.updateById(existingPrimary);
}
// 设置当前车辆为主车
relation.setIsPrimary(true);
} else {
// 如果当前是主车降级为副车
relation.setIsPrimary(false);
}
return this.updateById(relation);
}
@Override
public boolean batchRemoveByDriverId(Long driverId, List<Long> carIds) {
if (carIds == null || carIds.isEmpty()) {
return false;
}
LambdaQueryWrapper<RescueDriverCarRelation> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(RescueDriverCarRelation::getDriverId, driverId)
.in(RescueDriverCarRelation::getCarId, carIds)
.eq(RescueDriverCarRelation::getDeleted, false);
List<RescueDriverCarRelation> relations = this.list(wrapper);
for (RescueDriverCarRelation relation : relations) {
relation.setDeleted(true);
}
return this.updateBatchById(relations);
}
@Override
public Map<String, Object> getCarStatsByDriverId(Long driverId) {
Map<String, Object> stats = new HashMap<>();
// 获取主车
RescueDriverCarRelation primaryCar = getPrimaryCarByDriverId(driverId);
stats.put("primaryCar", primaryCar);
// 获取副车列表
List<RescueDriverCarRelation> secondaryCars = getSecondaryCarsByDriverId(driverId);
stats.put("secondaryCars", secondaryCars);
stats.put("secondaryCarCount", secondaryCars.size());
// 获取所有车辆
List<RescueDriverCarRelation> allCars = getByDriverId(driverId);
stats.put("totalCarCount", allCars.size());
return stats;
}
/**
* 根据司机id删除对应数据
*/
@Override
public void deletedByDriverId(Long driverId) {
rescueDriverCarRelationMapper.deletedByDriverId(driverId);
}
}

View File

@ -31,6 +31,7 @@ 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.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -89,6 +90,9 @@ public class RescueDriverInfoServiceImpl extends ServiceImpl<RescueDriverInfoMap
@Autowired
private CustomerCarService customerCarService;
@Resource
private IRescueDriverCarRelationService rescueDriverCarRelationService;
public static String Redis_Driver_Key = "Rescue:Driver:";
public static String Redis_Driver_Position_Key = "DriverPosition:";
public static Map<String, Object> driverInfoMap = new HashMap<>();
@ -324,7 +328,25 @@ public class RescueDriverInfoServiceImpl extends ServiceImpl<RescueDriverInfoMap
//接受
rescueDriverInfo.setDriverAccept("1");
this.updateById(rescueDriverInfo);
LambdaQueryWrapper<RescueCarInfo> queryWrapper1 = new LambdaQueryWrapper<>();
RescueCarInfo firstCar = rescueDriverCarRelationService.getPrimaryCarInfo(driverInfo.getId());
List<RescueCarInfo> secondCars = rescueDriverCarRelationService.getSecondaryCarInfo(driverInfo.getId());
// 如果主车不为null使用主车信息如果主车为null使用副车信息如果都为null报错
if(firstCar != null){
rescueInfo.setDriverId(rescueDriverInfo.getDriverId());
rescueInfo.setDriverName(driverUser.getNickname());
rescueInfo.setDriverPhoneNum(driverInfo.getPhonenumber());
rescueInfo.setDriverCarNum(firstCar.getRescueCarNum());
rescueInfo.setDriverCarCategory(firstCar.getCarCategory());
}else if (CollectionUtils.isNotEmpty(secondCars)){
rescueInfo.setDriverId(rescueDriverInfo.getDriverId());
rescueInfo.setDriverName(driverUser.getNickname());
rescueInfo.setDriverPhoneNum(driverInfo.getPhonenumber());
rescueInfo.setDriverCarNum(secondCars.get(0).getRescueCarNum());
rescueInfo.setDriverCarCategory(secondCars.get(0).getCarCategory());
}else {
throw exception0(500, "请联系管理员维护车辆信息开始接单");
}
/*LambdaQueryWrapper<RescueCarInfo> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(RescueCarInfo::getPossessorId, driverInfo.getId());
RescueCarInfo carInfo = carInfoService.getOne(queryWrapper1);
if (ObjectUtils.isNotEmpty(carInfo)) {
@ -335,7 +357,7 @@ public class RescueDriverInfoServiceImpl extends ServiceImpl<RescueDriverInfoMap
rescueInfo.setDriverCarCategory(carInfo.getCarCategory());
} else {
throw exception0(500, "请联系管理员维护车辆信息开始接单");
}
}*/
//状态修改为救援中
rescueInfo.setRescueStatus("3");
rescueInfoService.updateRescueInfo(rescueInfo);
@ -529,10 +551,10 @@ public class RescueDriverInfoServiceImpl extends ServiceImpl<RescueDriverInfoMap
driverPosition.setPositionInfo(positionStr);
positionService.save(driverPosition);
rescueInfoDetail.setPositionId(driverPosition.getId());
if("1".equals(rescueInfoDetail.getType()) && driverPosition.getId() != null){
if("2".equals(rescueInfoDetail.getType()) && driverPosition.getId() != null){
rescueInfoDetail.setAutoRemark("起始地:" + positionStr);
}
if("4".equals(rescueInfoDetail.getType()) && rescueInfoDetail.getHandoverTitle() != null){
if("6".equals(rescueInfoDetail.getType()) && rescueInfoDetail.getHandoverTitle() != null){
rescueInfoDetail.setTitle(recordType + ": " + rescueInfoDetail.getHandoverTitle());
}
} catch (Exception e) {

View File

@ -11,6 +11,7 @@ import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import cn.iocoder.yudao.module.appBase.domain.SysAnnouncement;
import cn.iocoder.yudao.module.appBase.service.ISysAnnouncementService;
import cn.iocoder.yudao.module.booking.vo.RepairBookingRespVO;
import cn.iocoder.yudao.module.constant.InspectionConstants;
import cn.iocoder.yudao.module.constant.UserConstants;
import cn.iocoder.yudao.module.inspection.entity.InspectionFile;
@ -26,6 +27,7 @@ import cn.iocoder.yudao.module.rescue.utils.RedisUtil;
import cn.iocoder.yudao.module.rescue.utils.RedissonDelayQueue;
import cn.iocoder.yudao.module.rescue.utils.StringUtils;
import cn.iocoder.yudao.module.rescue.vo.*;
import cn.iocoder.yudao.module.staff.entity.CompanyStaff;
import cn.iocoder.yudao.module.staff.service.CompanyStaffService;
import cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
@ -52,6 +54,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -130,6 +133,9 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
@Autowired
private AdminUserService adminUserService;
@Resource
private IRescueDriverCarRelationService driverCarRelationService;
/**
@ -477,8 +483,7 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
rescueInfo.setRescueStatus("2");
rescueInfo.setRescueTime(new Date());
baseMapper.insert(rescueInfo);
// detailService.save(new RescueInfoDetail(rescueInfo.getId(), "0", "救援发起", "救援发起"));
detailService.save(new RescueInfoDetail(rescueInfo.getId(), "0", "救援发起", null));
detailService.save(new RescueInfoDetail(rescueInfo.getId(), "1", "救援发起,等待接单", rescueInfo.getRescueDetail()));
// TODO 暂时注掉 后面在看要不要完善
// // 自动通知对应路段司机
@ -596,6 +601,26 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
return driverInfos;
}
@Override
public IPage<DriverInfo> driverAndCarList(DriverInfoDto driverInfo, Page<DriverInfo> page) {
IPage<DriverInfo> driverInfos = baseMapper.driverList(driverInfo, page);
for (DriverInfo info : driverInfos.getRecords()) {
/*LambdaQueryWrapper<RescueCarInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueCarInfo::getPossessorId, info.getId());
List<RescueCarInfo> list = carInfoService.list(queryWrapper);
if (CollectionUtil.isNotEmpty(list)) {
info.setCarInfoList(list);
} else {
info.setCarInfoList(new ArrayList<>());
}*/
List<RescueDriverCarRelation> firstCarList = driverCarRelationService.getFirstByDriverId(info.getId());
info.setDriverFirstCarRelationList(firstCarList);
List<RescueDriverCarRelation> secondCarList = driverCarRelationService.getSecondByDriverId(info.getId());
info.setDriverSecondCarRelationList(secondCarList);
}
return driverInfos;
}
@Override
public DriverInfo getDriverById(Long driverId) {
DriverInfo driverInfo = driverInfoService.getById(driverId);
@ -689,63 +714,86 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
if (!CollectionUtil.isEmpty(list)) {
throw new Exception("该手机号已绑定司机,请不要重复添加");
}
AdminUserRespDTO sysUser = userService.getUserByMobile(driverInfoDto.getPhonenumber());
driverInfoDto.setAuthStatus("2");
// 用于保存司机信息的ID
Long driverInfoId = null;
if (!ObjectUtils.isEmpty(sysUser)) {
CompanyStaffRespVO companyStaff = staffService.selectByPhoneAndUserId(sysUser.getMobile(), sysUser.getId());
if(companyStaff == null){
CompanyStaffRespVO staffRespVO = new CompanyStaffRespVO();
staffRespVO.setLoginAccount(driverInfoDto.getPhonenumber());
staffRespVO.setPassword("123456");
List<Long> roleIds = new ArrayList<>();
if("jysj".equals(driverInfoDto.getStaffType())) {
RoleReqDTO roleReqDTO = roleApi.getRoleInfo("jysj");
roleIds.add(roleReqDTO.getId());
}
staffRespVO.setRoleIds(roleIds);
staffRespVO.setName(driverInfoDto.getRealName());
staffRespVO.setSex(driverInfoDto.getSex());
staffRespVO.setTel(driverInfoDto.getPhonenumber());
staffService.saveStaff(staffRespVO);
}else{
CompanyStaffRespVO staffRespVO = new CompanyStaffRespVO();
// companyStaff 复制到 staffRespVO
BeanUtils.copyProperties(companyStaff, staffRespVO);
// 获取现有的角色ID列表如果为null则创建新列表
List<Long> roleIds = staffRespVO.getRoleIds() != null ?
new ArrayList<>(staffRespVO.getRoleIds()) :
new ArrayList<>();
if ("jysj".equals(driverInfoDto.getStaffType())) {
RoleReqDTO roleReqDTO = roleApi.getRoleInfo("jysj");
// 避免重复添加相同的角色ID
if (roleReqDTO != null && roleReqDTO.getId() != null &&
!roleIds.contains(roleReqDTO.getId())) {
roleIds.add(roleReqDTO.getId());
}
}
staffRespVO.setRoleIds(roleIds);
staffRespVO.setUserId(sysUser.getId());
staffService.updateStaff(staffRespVO);
}
DriverInfo driverInfoQuery = new DriverInfo();
driverInfoQuery.setUserId(sysUser.getId());
List<DriverInfo> driverInfos = driverInfoService.selectDriverInfoList(driverInfoQuery);
if (CollectionUtil.isEmpty(driverInfos)) {
UserDTO newUser = new UserDTO();
newUser.setNickname(driverInfoDto.getRealName());
newUser.setSex(driverInfoDto.getSex());
newUser.setAvatar(driverInfoDto.getAvatar());
newUser.setDeptId(driverInfoDto.getDeptId());
userService.createUser(newUser);
driverInfoDto.setUserId(newUser.getId());
//代表为救援员工 需要添加到司机表中
driverInfoDto.setUserId(sysUser.getId());
driverInfoDto.setDriverStatus("4");
driverInfoService.save(driverInfoDto);
this.addFolder(newUser.getId());
driverInfoDto.setStaffType("jysj");
boolean saveResult = driverInfoService.save(driverInfoDto);
if (saveResult) {
driverInfoId = driverInfoDto.getId();
}
}
} else {
// 新增用户信息
CompanyStaffRespVO staffRespVO = new CompanyStaffRespVO();
staffRespVO.setLoginAccount(driverInfoDto.getPhonenumber());
staffRespVO.setPassword("123456");
RoleReqDTO roleReqDTO = roleApi.getRoleInfo("jysj");
List<Long> roleIds = new ArrayList<>();
roleIds.add((roleReqDTO.getId()));
if("jysj".equals(driverInfoDto.getStaffType())) {
RoleReqDTO roleReqDTO = roleApi.getRoleInfo("jysj");
roleIds.add(roleReqDTO.getId());
}
staffRespVO.setRoleIds(roleIds);
staffRespVO.setName(driverInfoDto.getRealName());
staffRespVO.setSex(driverInfoDto.getSex());
staffRespVO.setTel(driverInfoDto.getPhonenumber());
Long userId = staffService.saveStaff(staffRespVO);
//
//代表为救援员工 需要添加到司机表中
driverInfoDto.setUserId(userId);
driverInfoDto.setDriverStatus("4");
driverInfoService.save(driverInfoDto);
addFolder(userId);
}
if (!CollectionUtil.isEmpty(driverInfoDto.getCarInfoList())) {
for (RescueCarInfo rescueCarInfo : driverInfoDto.getCarInfoList()) {
String rescueCarNum = rescueCarInfo.getRescueCarNum();
LambdaQueryWrapper<RescueCarInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueCarInfo::getRescueCarNum, rescueCarNum);
RescueCarInfo one = carInfoService.getOne(queryWrapper);
if (ObjectUtils.isNotEmpty(one)) {
rescueCarInfo.setCarOwn("1");
rescueCarInfo.setPossessorId(driverInfoDto.getId());
rescueCarInfo.setId(one.getId());
carInfoService.updateById(rescueCarInfo);
} else {
rescueCarInfo.setCarOwn("1");
rescueCarInfo.setPossessorId(driverInfoDto.getId());
carInfoService.save(rescueCarInfo);
}
driverInfoDto.setStaffType("jysj");
boolean saveResult = driverInfoService.save(driverInfoDto);
if (saveResult) {
driverInfoId = driverInfoDto.getId();
}
}
// 关键点返回已生成的司机ID
return driverInfoDto.getId();
return driverInfoId;
}
@Override
@ -818,6 +866,168 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
return driverInfoDto.getUserId();
}
/*@Override
@Transactional
public Long addDriverAppNew(DriverInfo driverInfoDto) throws Exception {
LambdaQueryWrapper<DriverInfo> queryWrapperD = new LambdaQueryWrapper<>();
queryWrapperD.eq(DriverInfo::getPhonenumber, driverInfoDto.getPhonenumber());
List<DriverInfo> list = driverInfoService.list(queryWrapperD);
if (!CollectionUtil.isEmpty(list)) {
throw new Exception("该手机号已绑定司机,请不要重复添加");
}
AdminUserRespDTO sysUser = userService.getUserByMobile(driverInfoDto.getPhonenumber());
driverInfoDto.setAuthStatus("2");
if (!ObjectUtils.isEmpty(sysUser)) {
CompanyStaffRespVO companyStaff = staffService.selectByPhoneAndUserId(sysUser.getMobile(), sysUser.getId());
if(companyStaff == null){
CompanyStaffRespVO staffRespVO = new CompanyStaffRespVO();
staffRespVO.setLoginAccount(driverInfoDto.getPhonenumber());
staffRespVO.setPassword("123456");
List<Long> roleIds = new ArrayList<>();
if("jysj".equals(driverInfoDto.getStaffType())) {
RoleReqDTO roleReqDTO = roleApi.getRoleInfo("jysj");
roleIds.add(roleReqDTO.getId());
}
staffRespVO.setRoleIds(roleIds);
staffRespVO.setName(driverInfoDto.getRealName());
staffRespVO.setSex(driverInfoDto.getSex());
staffRespVO.setTel(driverInfoDto.getPhonenumber());
staffService.saveStaff(staffRespVO);
}else{
CompanyStaffRespVO staffRespVO = new CompanyStaffRespVO();
// companyStaff 复制到 staffRespVO
BeanUtils.copyProperties(companyStaff, staffRespVO);
// 获取现有的角色ID列表如果为null则创建新列表
List<Long> roleIds = staffRespVO.getRoleIds() != null ?
new ArrayList<>(staffRespVO.getRoleIds()) :
new ArrayList<>();
if ("jysj".equals(driverInfoDto.getStaffType())) {
RoleReqDTO roleReqDTO = roleApi.getRoleInfo("jysj");
// 避免重复添加相同的角色ID
if (roleReqDTO != null && roleReqDTO.getId() != null &&
!roleIds.contains(roleReqDTO.getId())) {
roleIds.add(roleReqDTO.getId());
}
}
staffRespVO.setRoleIds(roleIds);
staffRespVO.setUserId(sysUser.getId());
staffService.updateStaff(staffRespVO);
}
DriverInfo driverInfoQuery = new DriverInfo();
driverInfoQuery.setUserId(sysUser.getId());
List<DriverInfo> driverInfos = driverInfoService.selectDriverInfoList(driverInfoQuery);
if (CollectionUtil.isEmpty(driverInfos)) {
//代表为救援员工 需要添加到司机表中
driverInfoDto.setUserId(sysUser.getId());
driverInfoDto.setDriverStatus("4");
driverInfoService.save(driverInfoDto);
}
} else {
// 新增用户信息
CompanyStaffRespVO staffRespVO = new CompanyStaffRespVO();
staffRespVO.setLoginAccount(driverInfoDto.getPhonenumber());
staffRespVO.setPassword("123456");
List<Long> roleIds = new ArrayList<>();
if("jysj".equals(driverInfoDto.getStaffType())) {
RoleReqDTO roleReqDTO = roleApi.getRoleInfo("jysj");
roleIds.add(roleReqDTO.getId());
}
staffRespVO.setRoleIds(roleIds);
staffRespVO.setName(driverInfoDto.getRealName());
staffRespVO.setSex(driverInfoDto.getSex());
staffRespVO.setTel(driverInfoDto.getPhonenumber());
Long userId = staffService.saveStaff(staffRespVO);
//
//代表为救援员工 需要添加到司机表中
driverInfoDto.setUserId(userId);
driverInfoDto.setDriverStatus("4");
driverInfoService.save(driverInfoDto);
}
return driverInfoDto.getUserId();
}*/
@Override
@Transactional
public Long addDriverAppNew(DriverInfo driverInfoDto) throws Exception {
LambdaQueryWrapper<DriverInfo> queryWrapperD = new LambdaQueryWrapper<>();
queryWrapperD.eq(DriverInfo::getPhonenumber, driverInfoDto.getPhonenumber());
List<DriverInfo> list = driverInfoService.list(queryWrapperD);
if (!CollectionUtil.isEmpty(list)) {
throw new Exception("该手机号已绑定司机,请不要重复添加");
}
AdminUserRespDTO sysUser = userService.getUserByMobile(driverInfoDto.getPhonenumber());
driverInfoDto.setAuthStatus("2");
if (!ObjectUtils.isEmpty(sysUser)) {
CompanyStaffRespVO companyStaff = staffService.selectByPhoneAndUserId(sysUser.getMobile(), sysUser.getId());
if (companyStaff == null) {
// 新增员工 - 直接使用前端传入的 roleIds
CompanyStaffRespVO staffRespVO = new CompanyStaffRespVO();
staffRespVO.setLoginAccount(driverInfoDto.getPhonenumber());
staffRespVO.setPassword("123456");
// 直接使用前端传入的角色ID列表
staffRespVO.setRoleIds(driverInfoDto.getRoleIds());
staffRespVO.setName(driverInfoDto.getRealName());
staffRespVO.setSex(driverInfoDto.getSex());
staffRespVO.setTel(driverInfoDto.getPhonenumber());
staffService.saveStaff(staffRespVO);
} else {
// 更新现有员工 - 合并现有的和传入的角色ID
CompanyStaffRespVO staffRespVO = new CompanyStaffRespVO();
BeanUtils.copyProperties(companyStaff, staffRespVO);
// 合并角色ID现有的 + 新传入的去重
Set<Long> mergedRoleIds = new HashSet<>();
// 添加现有的角色ID
if (companyStaff.getRoleIds() != null) {
mergedRoleIds.addAll(companyStaff.getRoleIds());
}
// 添加新传入的角色ID
if (driverInfoDto.getRoleIds() != null) {
mergedRoleIds.addAll(driverInfoDto.getRoleIds());
}
staffRespVO.setRoleIds(new ArrayList<>(mergedRoleIds));
staffRespVO.setUserId(sysUser.getId());
staffService.updateStaff(staffRespVO);
}
DriverInfo driverInfoQuery = new DriverInfo();
driverInfoQuery.setUserId(sysUser.getId());
List<DriverInfo> driverInfos = driverInfoService.selectDriverInfoList(driverInfoQuery);
if (CollectionUtil.isEmpty(driverInfos)) {
// 代表为救援员工需要添加到司机表中
driverInfoDto.setUserId(sysUser.getId());
driverInfoDto.setDriverStatus("4");
driverInfoService.save(driverInfoDto);
}
} else {
// 新增用户信息 - 直接使用前端传入的 roleIds
CompanyStaffRespVO staffRespVO = new CompanyStaffRespVO();
staffRespVO.setLoginAccount(driverInfoDto.getPhonenumber());
staffRespVO.setPassword("123456");
// 直接使用前端传入的角色ID列表
staffRespVO.setRoleIds(driverInfoDto.getRoleIds());
staffRespVO.setName(driverInfoDto.getRealName());
staffRespVO.setSex(driverInfoDto.getSex());
staffRespVO.setTel(driverInfoDto.getPhonenumber());
Long userId = staffService.saveStaff(staffRespVO);
// 代表为救援员工需要添加到司机表中
driverInfoDto.setUserId(userId);
driverInfoDto.setDriverStatus("4");
driverInfoService.save(driverInfoDto);
}
return driverInfoDto.getUserId();
}
@Override
public Long addFolder(Long userId) {
@ -873,6 +1083,70 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
}
}
@Override
@Transactional
public void updateDriverNew(DriverInfo driverInfoDto) {
driverInfoService.updateDriverInfo(driverInfoDto);
// 更新staff表数据
CompanyStaffRespVO staffRespVO = new CompanyStaffRespVO();
staffRespVO.setUserId(driverInfoDto.getUserId());
staffRespVO.setTel(driverInfoDto.getPhonenumber());
staffRespVO.setName(driverInfoDto.getRealName());
staffRespVO.setSex(driverInfoDto.getSex());
// 获取现有的员工信息
CompanyStaffRespVO companyStaff = staffService.selectByPhoneAndUserId(driverInfoDto.getPhonenumber(), driverInfoDto.getUserId());
if (companyStaff != null) {
// 组合角色ID现有的角色ID + 前端传入的角色ID去重
Set<Long> combinedRoleIds = new HashSet<>();
// 添加现有的角色ID
if (companyStaff.getRoleIds() != null) {
combinedRoleIds.addAll(companyStaff.getRoleIds());
}
// 添加前端传入的角色ID
if (driverInfoDto.getRoleIds() != null) {
combinedRoleIds.addAll(driverInfoDto.getRoleIds());
}
staffRespVO.setRoleIds(new ArrayList<>(combinedRoleIds));
} else {
// 如果没有找到现有员工记录直接使用前端传入的角色ID
staffRespVO.setRoleIds(driverInfoDto.getRoleIds());
}
staffService.updateStaff(staffRespVO);
// 清理原有的车辆关联
LambdaQueryWrapper<RescueCarInfo> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(RescueCarInfo::getPossessorId, driverInfoDto.getId()).eq(RescueCarInfo::getCarOwn, "1");
carInfoService.remove(queryWrapper1);
// 处理车辆信息
if (!CollectionUtil.isEmpty(driverInfoDto.getCarInfoList())) {
for (RescueCarInfo rescueCarInfo : driverInfoDto.getCarInfoList()) {
String rescueCarNum = rescueCarInfo.getRescueCarNum();
LambdaQueryWrapper<RescueCarInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueCarInfo::getRescueCarNum, rescueCarNum);
RescueCarInfo one = carInfoService.getOne(queryWrapper);
if (ObjectUtils.isNotEmpty(one)) {
rescueCarInfo.setCarOwn("1");
rescueCarInfo.setPossessorId(driverInfoDto.getId());
rescueCarInfo.setId(one.getId());
carInfoService.updateById(rescueCarInfo);
} else {
rescueCarInfo.setCarOwn("1");
rescueCarInfo.setPossessorId(driverInfoDto.getId());
carInfoService.save(rescueCarInfo);
}
}
}
}
@Override
@Transactional
public void delDriver(Long[] ids) {
@ -887,6 +1161,93 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
}
}
@Override
@Transactional
public void delDriverNew(Long[] ids) {
for (Long id : ids) {
DriverStaffSaveVO onInternal = this.getOnInternal(id);
if (onInternal != null) {
Long userId = onInternal.getUserId();
String tel = onInternal.getMobile();
// 只有当员工存在时才进行相关操作
CompanyStaffRespVO companyStaffRespVO = staffService.selectByPhoneAndUserId(tel, userId);
if (companyStaffRespVO != null) {
// 移除救援司机角色如果存在
List<Long> currentRoleIds = companyStaffRespVO.getRoleIds() != null ?
new ArrayList<>(companyStaffRespVO.getRoleIds()) : new ArrayList<>();
RoleReqDTO rescueDriverRole = roleApi.getRoleInfo("jysj");
if (rescueDriverRole != null && currentRoleIds.contains(rescueDriverRole.getId())) {
currentRoleIds.remove(rescueDriverRole.getId());
// 更新员工角色信息
CompanyStaffRespVO updateStaffVO = new CompanyStaffRespVO();
updateStaffVO.setUserId(userId);
updateStaffVO.setRoleIds(currentRoleIds);
staffService.updateStaff(updateStaffVO);
}
}
// 删除司机信息
driverInfoService.removeById(onInternal.getDriverId());
driverCarRelationService.deletedByDriverId(onInternal.getDriverId());
/*// 解除关联的车辆信息
LambdaQueryWrapper<RescueCarInfo> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(RescueCarInfo::getPossessorId, id).eq(RescueCarInfo::getCarOwn, "1");
carInfoService.remove(queryWrapper1);*/
}
}
}
@Override
@Transactional
public void delDriverStaffNew(Long[] ids) {
for (Long id : ids) {
DriverStaffSaveVO onInternal = this.getOnInternal(id);
if (onInternal != null) {
Long userId = onInternal.getUserId();
String tel = onInternal.getMobile();
// 只有当员工存在时才进行相关操作
CompanyStaffRespVO companyStaffRespVO = staffService.selectByPhoneAndUserId(tel, userId);
if (companyStaffRespVO != null) {
// 获取司机相关的角色ID从driverInfo中
List<Long> driverRoleIds = onInternal.getRoleIds();
if (driverRoleIds != null && !driverRoleIds.isEmpty()) {
// 获取员工当前的角色ID
List<Long> currentRoleIds = companyStaffRespVO.getRoleIds();
if (currentRoleIds != null && !currentRoleIds.isEmpty()) {
// 从员工角色中移除司机相关的角色
List<Long> updatedRoleIds = new ArrayList<>(currentRoleIds);
updatedRoleIds.removeAll(driverRoleIds);
// 只有当角色列表有变化时才更新
if (updatedRoleIds.size() != currentRoleIds.size()) {
CompanyStaffRespVO updateStaffVO = new CompanyStaffRespVO();
updateStaffVO.setUserId(userId);
updateStaffVO.setRoleIds(updatedRoleIds);
staffService.updateStaff(updateStaffVO);
}
}
}
}
// 删除救援员工信息
driverInfoService.removeById(onInternal.getDriverId());
driverCarRelationService.deletedByDriverId(onInternal.getDriverId());
/*// 解除关联的车辆信息
LambdaQueryWrapper<RescueCarInfo> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(RescueCarInfo::getPossessorId, id).eq(RescueCarInfo::getCarOwn, "1");
carInfoService.remove(queryWrapper1);*/
}
}
}
@Override
public List<DriverInfo2Dto> driverListApp(DriverInfoDto driverInfoDto) {
//当前登录用户
@ -1769,6 +2130,26 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
public List<DriverInfoExportVO> getAll(DriverInfoDto query) {
return baseMapper.getAll(query);
}
@Override
public Long safeStringToLong(String str, Long defaultValue) {
if (str == null) {
return defaultValue;
}
// 去除首尾空白字符避免" 123 "这样的字符串
String trimmedStr = str.trim();
if (trimmedStr.isEmpty()) {
return defaultValue;
}
try {
return Long.valueOf(trimmedStr);
} catch (NumberFormatException e) {
return defaultValue;
}
}
public List<RescueInfo> filterRescueInfoByDate(List<RescueInfo> rescueInfos, Date startTime, Date endTime) {
return rescueInfos.stream()
.filter(info -> info.getRescueTime() != null &&

View File

@ -0,0 +1,90 @@
package cn.iocoder.yudao.module.rescue.service.impl;
import cn.iocoder.yudao.module.rescue.domain.RescueChannelSource;
import cn.iocoder.yudao.module.rescue.domain.RescueSecondChannelAssociation;
import cn.iocoder.yudao.module.rescue.domain.RescueTypePhenomenon;
import cn.iocoder.yudao.module.rescue.mapper.RescueTypePhenomenonMapper;
import cn.iocoder.yudao.module.rescue.service.IRescueSecondChannelAssociationService;
import cn.iocoder.yudao.module.rescue.service.IRescueTypePhenomenonService;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
/**
* <p>
* 救援类型-现象 服务实现类
* </p>
*
* @author author
* @since 2025-09-05
*/
@Service
public class RescueTypePhenomenonServiceImpl extends ServiceImpl<RescueTypePhenomenonMapper, RescueTypePhenomenon> implements IRescueTypePhenomenonService {
@Override
public List<RescueTypePhenomenon> listPhenomenonByPid(Long pid) {
LambdaQueryWrapper<RescueTypePhenomenon> queryWrapper = new LambdaQueryWrapper<>();
if (pid == null) {
queryWrapper.eq(RescueTypePhenomenon::getType, 1);
} else {
queryWrapper.eq(RescueTypePhenomenon::getPid, pid);
}
queryWrapper.eq(RescueTypePhenomenon::getDeleted, false)
.orderByAsc(RescueTypePhenomenon::getCreateTime);
return this.list(queryWrapper);
}
@Override
public List<RescueTypePhenomenon> typeList() {
LambdaQueryWrapper<RescueTypePhenomenon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueTypePhenomenon::getType, 0).eq(RescueTypePhenomenon::getDeleted, false);
queryWrapper.orderByAsc(RescueTypePhenomenon::getCreateTime);
return this.list(queryWrapper);
}
@Override
public boolean hasChildren(Long id) {
LambdaQueryWrapper<RescueTypePhenomenon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueTypePhenomenon::getPid, id)
.eq(RescueTypePhenomenon::getDeleted, false);
return this.count(queryWrapper) > 0;
}
@Override
public IPage<RescueTypePhenomenon> getTypePageList(String name, Page<RescueTypePhenomenon> page) {
LambdaQueryWrapper<RescueTypePhenomenon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueTypePhenomenon::getType, 0); // 只查询渠道
if (name != null && !name.trim().isEmpty()) {
queryWrapper.like(RescueTypePhenomenon::getName, name);
}
queryWrapper.eq(RescueTypePhenomenon::getDeleted, false).orderByAsc(RescueTypePhenomenon::getCreateTime);
return this.page(page, queryWrapper);
}
@Override
public List<RescueTypePhenomenon> getPhenomenonByTypeId(Long typeId) {
LambdaQueryWrapper<RescueTypePhenomenon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueTypePhenomenon::getPid, typeId)
.eq(RescueTypePhenomenon::getType, 1)
.eq(RescueTypePhenomenon::getDeleted, false)
.orderByAsc(RescueTypePhenomenon::getCreateTime);
return this.list(queryWrapper);
}
@Override
public List<RescueTypePhenomenon> phenomenonList() {
LambdaQueryWrapper<RescueTypePhenomenon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RescueTypePhenomenon::getType, 1)
.eq(RescueTypePhenomenon::getDeleted, false)
.orderByAsc(RescueTypePhenomenon::getCreateTime);
return this.list(queryWrapper);
}
}

View File

@ -0,0 +1,12 @@
package cn.iocoder.yudao.module.rescue.vo;
import lombok.Data;
import java.util.List;
@Data
public class CarAssignmentVO {
private Long driverId;
private Long primaryCarId;
private List<Long> secondaryCarIds;
}

View File

@ -0,0 +1,4 @@
package cn.iocoder.yudao.module.rescue.vo;
public class ToRepairVO {
}

View File

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.rescue.mapper.DriverInfoMapper">
<sql id="selectDriverInfoVo">
select id, user_id, phonenumber, license_image, id_card_right, id_card_back, auth_status, reject_info, driver_status, driver_longitude, driver_latitude, driver_position_info, driver_offline_time from driver_info
@ -24,7 +24,6 @@
<if test="driverLatitude != null "> and driver_latitude = #{driverLatitude}</if>
<if test="driverPositionInfo != null and driverPositionInfo != ''"> and driver_position_info = #{driverPositionInfo}</if>
<if test="driverOfflineTime != null "> and driver_offline_time = #{driverOfflineTime}</if>
${params.dataScope}
</where>
</select>
@ -97,4 +96,4 @@
#{id}
</foreach>
</delete>
</mapper>
</mapper>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.rescue.mapper.RescueChannelSourceMapper">
<select id="selectPageList" resultType="cn.iocoder.yudao.module.rescue.domain.RescueChannelSource">
SELECT *
FROM rescue_channel_source
WHERE deleted = 0
<if test="name != null and name != ''">
AND name LIKE CONCAT('%', #{name}, '%')
</if>
<if test="type != null">
AND type = #{type}
</if>
ORDER BY sort ASC, create_time DESC
</select>
<select id="getChannelListByDispatchId" resultType="cn.iocoder.yudao.module.rescue.domain.RescueChannelSource">
SELECT
rcs.id,
rcs.name
FROM rescue_second_channel_association rsca
LEFT JOIN rescue_channel_source rcs ON rcs.id = rsca.channel_id AND rcs.type = 0 AND rcs.deleted = 0
where rsca.dispatch_id = #{dispatchId} AND rsca.deleted = 0
ORDER BY rcs.create_time ASC
</select>
</mapper>

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.rescue.mapper.RescueDriverCarRelationMapper">
<update id="deletedByDriverId" parameterType="long">
update rescue_driver_car_relation set deleted = 1 where driver_id = #{driverId} and deleted = 0
</update>
<select id="getCarList" resultType="cn.iocoder.yudao.module.rescue.domain.RescueCarInfo">
SELECT *
FROM rescue_car_info
WHERE id IN (
SELECT car_id
FROM rescue_driver_car_relation
WHERE driver_id = #{driverId}
AND deleted = 0
)
AND deleted = 0
</select>
<select id="getPrimaryCarInfo" resultType="cn.iocoder.yudao.module.rescue.domain.RescueCarInfo">
SELECT *
FROM rescue_car_info
WHERE id = (
SELECT car_id
FROM rescue_driver_car_relation
WHERE driver_id = #{driverId}
AND is_primary = 1
AND deleted = 0
ORDER BY create_time DESC
LIMIT 1
)
AND deleted = 0
</select>
<select id="getSecondaryCarInfo" resultType="cn.iocoder.yudao.module.rescue.domain.RescueCarInfo">
SELECT *
FROM rescue_car_info
WHERE id IN (
SELECT car_id
FROM rescue_driver_car_relation
WHERE driver_id = #{driverId}
AND is_primary = 0
AND deleted = 0
)
AND deleted = 0
</select>
</mapper>

View File

@ -59,12 +59,12 @@
<if test="map.licenseNum != null">
and ri.license_num like concat('%', #{map.licenseNum}, '%')
</if>
<if test="map.deptList != null and map.deptList.size()>0">
<!--<if test="map.deptList != null and map.deptList.size()>0">
and ri.dept_id in
<foreach collection="map.deptList" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
</if>-->
</where>
order by ri.create_time desc
</select>
@ -142,7 +142,11 @@
roi.pay_time,
roi.order_signing_person_name,
roi.order_signing_charge_name,
roi.order_signing_remark
roi.order_signing_remark,
roi.if_confirm_pay,
roi.confirm_payment_person_name,
roi.confirm_payment_time,
roi.confirm_payment_person_remark
FROM rescue_info ri
left join rescue_order_info roi on roi.rescue_info_id = ri.id
where ri.deleted = '0'
@ -335,7 +339,7 @@
FROM driver_info di
INNER JOIN system_users su ON di.user_id = su.id
AND su.deleted = '0'
WHERE 1 = 1
WHERE 1 = 1 AND di.deleted = '0'
<if test="map.nickName != null and map.nickName != ''">
and su.nickname like concat('%', #{map.nickName}, '%')
</if>
@ -373,6 +377,50 @@
</if>
order by di.create_time desc
</select>
<select id="driverListAppNew" resultType="cn.iocoder.yudao.module.rescue.dto.DriverInfo2Dto">
SELECT
di.*,
su.nickname as real_name,
car_data.rescue_car_num
FROM
driver_info di
INNER JOIN
system_users su ON di.user_id = su.id AND su.deleted = '0'
LEFT JOIN
system_dept sd ON sd.id = di.dept_id AND sd.deleted = 0
INNER JOIN (
SELECT
rdcr.driver_id,
COALESCE(
MAX(CASE WHEN rdcr.is_primary = 1 THEN rci.rescue_car_num END),
SUBSTRING_INDEX(GROUP_CONCAT(rci.rescue_car_num ORDER BY rdcr.is_primary DESC, rdcr.create_time SEPARATOR ','), ',', 1)
) as rescue_car_num
FROM
rescue_driver_car_relation rdcr
INNER JOIN
rescue_car_info rci ON rci.id = rdcr.car_id AND rci.deleted = 0
WHERE
rdcr.deleted = 0
<if test="searchValue != null and searchValue != ''">
AND rci.rescue_car_num like concat('%', #{searchValue}, '%')
</if>
GROUP BY
rdcr.driver_id
HAVING
rescue_car_num IS NOT NULL
) car_data ON car_data.driver_id = di.id
WHERE
di.auth_status = '2'
AND di.deleted = 0
<if test="searchValue != null and searchValue != ''">
AND (su.nickname like concat('%', #{searchValue}, '%')
OR di.phonenumber like concat('%', #{searchValue}, '%')
OR car_data.rescue_car_num like concat('%', #{searchValue}, '%'))
</if>
ORDER BY
di.create_time DESC;
</select>
<select id="secondDriverListApp" resultType="cn.iocoder.yudao.module.rescue.dto.DriverInfo2Dto">
SELECT di.*,
su.nickname as real_name,
@ -646,7 +694,8 @@
su.status,
di.id AS driverId,
di.age,
di.folder_id
di.folder_id,
di.staff_type
FROM driver_info di
INNER JOIN system_users su ON di.user_id = su.id AND su.deleted = 0
LEFT JOIN system_user_role sur ON su.id = sur.user_id AND sur.deleted = 0

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.rescue.mapper.RescueTypePhenomenonMapper">
</mapper>

View File

@ -112,7 +112,6 @@ public class RoleController {
/**
* 通过角色id查询角色
*
* @param roleIds
* @return
*/
@GetMapping("/selectListByRoleId")
@ -140,6 +139,16 @@ public class RoleController {
return success(roleService.selectListByRoleIdJY(role));
}
/**
* 救援员工管理查询列表
* @param role
* @return
*/
@GetMapping("/selectListByRoleIdJYNew")
public CommonResult selectListByRoleIdJYNew(RolePageReqVO role){
return success(roleService.selectListByRoleIdJYNew(role));
}
/**
* 通过角色id查询角色
* @return

View File

@ -48,6 +48,7 @@ public interface UserRoleMapper extends BaseMapperX<UserRoleDO> {
IPage<UserDTO> selectListByRoleIdJX(@Param("page") Page<UserDTO> page,@Param("role") RolePageReqVO role);
IPage<DriverUserDTO> selectListByRoleIdJY(@Param("page") Page<DriverUserDTO> page, @Param("role") RolePageReqVO role);
IPage<UserDTO> selectListByRoleIdRepair(@Param("page") Page<UserDTO> page,@Param("role") RolePageReqVO role);
IPage<UserDTO> selectListByRoleIdJYNew(@Param("page") Page<UserDTO> page, @Param("role") RolePageReqVO role);
List<UserDTO> selectByRoleId(Integer roleId);

View File

@ -177,6 +177,7 @@ public interface RoleService {
IPage<UserDTO> selectListByRoleIdJX(RolePageReqVO role);
IPage<DriverUserDTO> selectListByRoleIdJY(RolePageReqVO role);
IPage<UserDTO> selectListByRoleIdJYNew(RolePageReqVO role);
IPage<UserDTO> selectListByRoleIdRepair(RolePageReqVO role);

View File

@ -381,6 +381,12 @@ public class RoleServiceImpl implements RoleService {
return userRoleMapper.selectListByRoleIdJY(page,role);
}
@Override
public IPage<UserDTO> selectListByRoleIdJYNew(RolePageReqVO role) {
Page<UserDTO> page = new Page<>(role.getPageNo(), role.getPageSize());
return userRoleMapper.selectListByRoleIdJYNew(page,role);
}
@Override
public IPage<UserDTO> selectListByRoleIdRepair(RolePageReqVO role) {
Page<UserDTO> page = new Page<>(role.getPageNo(), role.getPageSize());

View File

@ -99,7 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM driver_info di
INNER JOIN system_users su ON di.user_id = su.id AND su.deleted = 0
LEFT JOIN system_user_role sr ON su.id = sr.user_id AND sr.deleted = 0
INNER JOIN system_role role ON role.id = sr.role_id AND role.deleted = 0 AND role.code = 'jysj'
INNER JOIN system_role role ON role.id = sr.role_id AND role.deleted = 0
LEFT JOIN system_role sr2 ON sr.role_id = sr2.id AND sr2.service_package_id = 'jiuyuan'
<where>
<if test="role.nickname != null">
@ -118,6 +118,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
ORDER BY su.nickname
</select>
<select id="selectListByRoleIdJYNew" resultType="cn.iocoder.yudao.module.system.api.user.dto.UserDTO"
parameterType="cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO">
SELECT
su.id,
su.username,
su.nickname,
su.user_type,
su.remark,
su.dept_id,
su.mobile,
su.password,
su.sex,
su.open_id,
su.tenant_id,
su.status,
su.avatar,
GROUP_CONCAT(DISTINCT sr2.name SEPARATOR ',') AS roleNames
FROM driver_info di
LEFT JOIN system_users su ON di.user_id = su.id AND su.deleted = 0
LEFT JOIN system_user_role sr ON su.id = sr.user_id AND sr.deleted = 0
LEFT JOIN system_role role ON role.id = sr.role_id AND role.deleted = 0
LEFT JOIN system_role sr2 ON sr.role_id = sr2.id AND sr2.service_package_id = 'jiuyuan'
<where>
su.id IS NOT NULL AND di.deleted = 0
<if test="role.nickname != null">
AND (su.nickname like CONCAT('%',#{role.nickname},'%') OR su.username like CONCAT('%',#{role.nickname},'%'))
</if>
<if test="role.status != null">
AND su.status = #{role.status}
</if>
</where>
GROUP BY
su.id, su.username, su.nickname, su.user_type, su.remark,
su.dept_id, su.mobile, su.password, su.sex, su.open_id,
su.tenant_id, su.status, su.avatar
<if test="role.roleId != null">
HAVING SUM(sr.role_id = #{role.roleId}) > 0
</if>
ORDER BY su.nickname
</select>
<select id="selectListByRoleIdRepair" resultType="cn.iocoder.yudao.module.system.api.user.dto.UserDTO"
parameterType="cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO">