This commit is contained in:
PQZ 2024-11-13 17:48:00 +08:00
commit fecc6bb4da
13 changed files with 183 additions and 38 deletions

View File

@ -81,9 +81,8 @@ public class CustomerMainController {
@PostMapping("/saveCustomerAndCar")
@Operation(summary = "保存客户及车辆信息")
public CommonResult<Boolean> saveCustomerAndCar(@RequestBody CustomerMainSaveReqVO saveReqVO) throws Exception {
customerCarService.saveCustomerAndCar(saveReqVO);
return success(true);
public CommonResult<?> saveCustomerAndCar(@RequestBody CustomerMainSaveReqVO saveReqVO) throws Exception {
return CommonResult.success(customerCarService.saveCustomerAndCar(saveReqVO));
}
/**

View File

@ -100,5 +100,14 @@ public interface CarMainService extends IService<CarMain> {
**/
CarMainRespVO compute(CarMainReqVO reqVO);
/**
* 根据客户信息+车牌号查这个客户是否已有这个车
* @author vinjor-M
* @date 14:41 2024/11/13
* @param userId 用户id
* @param carNumber 车牌号
* @return cn.iocoder.yudao.module.custom.entity.CarMain
**/
CarMain selectByUserIdAndCarNumber(Long userId,String carNumber);
}

View File

@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
* 客户车辆管理关联Service 接口
@ -34,5 +35,5 @@ public interface CustomerCarService extends IService<CustomerCar> {
* @param saveReqVO CustomerMainSaveReqVO
* @return void
**/
void saveCustomerAndCar(CustomerMainSaveReqVO saveReqVO) throws Exception;
Map<String,String> saveCustomerAndCar(CustomerMainSaveReqVO saveReqVO) throws Exception;
}

View File

@ -309,6 +309,28 @@ public class CarMainServiceImpl extends ServiceImpl<CarMainMapper, CarMain> impl
return respVO;
}
/**
* 根据客户信息+车牌号查这个客户是否已有这个车
*
* @param userId 用户id
* @param carNumber 车牌号
* @return cn.iocoder.yudao.module.custom.entity.CarMain
* @author vinjor-M
* @date 14:41 2024/11/13
**/
@Override
public CarMain selectByUserIdAndCarNumber(Long userId, String carNumber) {
LambdaQueryWrapper<CarMain> queryWrapper = new LambdaQueryWrapper<CarMain>()
.eq(CarMain::getUserId,userId)
.eq(CarMain::getLicenseNumber,carNumber);
List<CarMain> rtnList = this.list(queryWrapper);
if(rtnList.isEmpty()){
return null;
}else{
return rtnList.get(0);
}
}
/**
* 根据品牌型号获取保养规则
*

View File

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.custom.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.custom.entity.CarMain;
import cn.iocoder.yudao.module.custom.entity.CustomerCar;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
@ -23,7 +25,9 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.common.BaseConstants.*;
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_CUS;
@ -93,13 +97,16 @@ public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, Custo
* @date 15:51 2024/11/12
**/
@Override
public void saveCustomerAndCar(CustomerMainSaveReqVO saveReqVO) throws Exception {
public Map<String,String> saveCustomerAndCar(CustomerMainSaveReqVO saveReqVO) throws Exception {
Map<String,String> rtnMap = new HashMap<>();
chekData(saveReqVO);
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
saveReqVO.getCar().setLicenseNumber(saveReqVO.getCar().getLicenseNumber().toUpperCase());
//用户信息
AdminUserRespDTO userDTO = adminUserApi.getUserByUsername(saveReqVO.getPhoneNumber());
UserDTO user = BeanUtils.toBean(userDTO, UserDTO.class);
if (null == userDTO){
user = new UserDTO();
//客户信息不存在直接新增客户新增车辆及绑定关系
UserDTO user = new UserDTO();
//如果不存在创建用户
user.setUsername(saveReqVO.getPhoneNumber());
user.setNickname(saveReqVO.getCusName());
@ -107,24 +114,60 @@ public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, Custo
user.setPassword(PASSWORD_DEFAULT);
user.setMobile(saveReqVO.getPhoneNumber());
user.setUserType(USER_TYPE_CUS);
//创建客户
user.setTenantId(loginUser.getTenantId());
//创建用户
Long userId = adminUserApi.createUser(user);
saveReqVO.setUserId(userId);
} else {
saveReqVO.setUserId(user.getId());
}
//客户信息
//创建客户信息
CustomerMain customerMain = BeanUtils.toBean(saveReqVO,CustomerMain.class);
customerMain.setId(null);
customerMain.setDataFrom("02");
//车辆信息
CarMain carMain = saveReqVO.getCar();
customerMainService.save(customerMain);
//创建车辆信息
CarMain carMain = saveReqVO.getCar();
carMain.setUserId(userId);
carMainService.save(carMain);
//关联关系
//客户和车的关联关系
CustomerCar customerCar = new CustomerCar();
customerCar.setCusId(customerMain.getId());
customerCar.setCarId(carMain.getId());
save(customerCar);
//默认车主
customerCar.setIsOwner("1");
this.save(customerCar);
rtnMap.put("userId",userId.toString());
rtnMap.put("carId",carMain.getId());
} else {
//已有 用户
Long userId = userDTO.getId();
saveReqVO.setUserId(userId);
//查是否存在客户信息
CustomerMain customerMain = customerMainService.getCustomerByUserId(userId);
if(null==customerMain){
//不存在客户信息新增客户
customerMain = BeanUtils.toBean(saveReqVO,CustomerMain.class);
customerMain.setId(null);
customerMain.setDataFrom("02");
customerMainService.save(customerMain);
}
//根据客户信息+车牌号查这个客户是否已有这个车
CarMain carMain = carMainService.selectByUserIdAndCarNumber(userId,saveReqVO.getCar().getLicenseNumber());
if(null==carMain){
//这个客户不存在这个车辆信息新增
carMain = saveReqVO.getCar();
carMain.setUserId(userId);
carMainService.save(carMain);
//客户和车的关联关系
CustomerCar customerCar = new CustomerCar();
customerCar.setCusId(customerMain.getId());
customerCar.setCarId(carMain.getId());
//默认车主
customerCar.setIsOwner("1");
this.save(customerCar);
}
rtnMap.put("userId",userId.toString());
rtnMap.put("carId",carMain.getId());
}
return rtnMap;
}
private void chekData(CustomerMainSaveReqVO saveReqVO) throws Exception {
@ -140,8 +183,5 @@ public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, Custo
if (StringUtils.isEmpty(saveReqVO.getCar().getLicenseNumber())){
throw new Exception("车牌号不能为空");
}
if (StringUtils.isEmpty(saveReqVO.getCar().getCarBrand())){
throw new Exception("车辆品牌不能为空");
}
}
}

View File

@ -76,6 +76,9 @@ public enum RecordTypeEnum {
/** 删除工单 */
SCGG("scgg", "删除工单"),
/** 删除工单 */
JC("jc", "交车"),
/** 内返派工 */
NFPG("nfpg", "内返派工");

View File

@ -27,6 +27,10 @@ public enum TicketsStatusEnum {
* 待通知客户取车
*/
WAITING_NOTICE("07","待通知客户取车"),
/**
* 已交车
*/
OVER("08","已交车"),
/**
* 挂单/记账
*/

View File

@ -297,6 +297,19 @@ public class DlRepairTicketsController {
return CommonResult.ok();
}
/**
* 服务顾问交车
* @author vinjor-M
* @date 16:51 2024/11/13
* @param respVO
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@PostMapping("/overOrder")
@Operation(summary = "服务顾问交车")
public CommonResult<?> overOrder(@RequestBody DlRepairTicketsRespVO respVO) {
dlRepairTicketsService.overOrder(respVO);
return CommonResult.ok();
}
/**
* 从总检的角度差维修中已完成的工单数量
* @author vinjor-M

View File

@ -235,4 +235,12 @@ public interface DlRepairTicketsService extends IService<DlRepairTickets> {
* @param id 工单ID
**/
void removeTicketById(String id);
/**
* 服务顾问交车
* @author vinjor-M
* @date 16:51 2024/11/13
* @param respVO
**/
void overOrder(DlRepairTicketsRespVO respVO);
}

View File

@ -1691,6 +1691,28 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 记录操作日志
repairRecordsService.saveRepairRecord(id, null, RecordTypeEnum.SCGG.getCode(), null, null);
}
/**
* 服务顾问交车
*
* @param respVO
* @author vinjor-M
* @date 16:51 2024/11/13
**/
@Override
public void overOrder(DlRepairTicketsRespVO respVO) {
// 更新工单状态
baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
.set(DlRepairTickets::getTicketsWorkStatus, TicketsWorkStatusEnum.END.getCode())
.set(DlRepairTickets::getTicketsStatus, TicketsStatusEnum.OVER.getCode())
//交车时才能把工单置为完成
.set(DlRepairTickets::getIsFinish,"1")
.eq(DlRepairTickets::getId, respVO.getId())
);
// 记录日志
repairRecordsService.saveRepairRecord(respVO.getId(), null, RecordTypeEnum.JC.getCode(), respVO.getRemark(), respVO.getImage());
}
}

View File

@ -216,7 +216,7 @@
from dl_repair_tickets drt
left join dl_repair_titem drti
on drt.id = drti.ticket_id AND drti.deleted = '0'
where (drt.deleted = '0') AND drt.tickets_status IN ('04','05','01','07')
where (drt.deleted = '0') AND drt.tickets_status IN ('04','05','01','07','06','02')
<if test="map.ticketNo != null and map.ticketNo != ''">
and (
drt.ticket_no like concat('%', #{map.ticketNo}, '%')
@ -255,10 +255,11 @@
)
</when>
<otherwise>
-- 服务顾问和仓管查待办都是查未结束的工单 --
AND drt.is_finish = '0'
<if test="map.adviserId != null and map.adviserId != ''">
-- 查服务顾问 待处理的 工单未完成并且服务顾问是自己的 工单已完成且当前处理人是自己的--
AND ( drt.is_finish = '0' AND drt.adviser_id = #{map.adviserId} )
OR (drt.is_finish = '1' AND drt.now_repair_id = #{map.adviserId})
-- 查服务顾问 当前处理人或服务顾问是自己的--
AND ( drt.adviser_id = #{map.adviserId} OR drt.now_repair_id = #{map.adviserId})
</if>
<if test="map.userIds != null and map.userIds.size > 0">
-- 查总检待处理的 --

View File

@ -1,10 +1,14 @@
package cn.iocoder.yudao.module.rescue.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.CoordinateUtil;
import cn.hutool.http.HttpUtil;
import cn.iocoder.yudao.module.custom.entity.CarMain;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import cn.iocoder.yudao.module.custom.service.CustomerCarService;
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO;
import cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo;
import cn.iocoder.yudao.module.partner.service.IPartnerCustomerInfoService;
import cn.iocoder.yudao.module.rescue.domain.*;
@ -81,6 +85,8 @@ public class RescueDriverInfoServiceImpl extends ServiceImpl<RescueDriverInfoMap
private IPartnerCustomerInfoService customerInfoService;
@Resource
private CustomerMainService customerMainService;
@Autowired
private CustomerCarService customerCarService;
public static String Redis_Driver_Key = "Rescue:Driver:";
public static String Redis_Driver_Position_Key = "DriverPosition:";
@ -585,6 +591,21 @@ public class RescueDriverInfoServiceImpl extends ServiceImpl<RescueDriverInfoMap
detailService.save(rescueInfoDetail);
rescueInfo.setRescueStatus("5");
rescueInfoService.updateById(rescueInfo);
/** 将车辆推送到维修中*/
CustomerMainSaveReqVO saveReqVO = new CustomerMainSaveReqVO();
// 绑定用户id
saveReqVO.setUserId(rescueInfo.getUserId());
// 绑定用户手机号
saveReqVO.setPhoneNumber(rescueInfo.getConnectionPhone());
// 客户名称
saveReqVO.setCusName(rescueInfo.getConnectionName());
// 车辆信息
CarMain carMain = new CarMain();
carMain.setCarLicenseImg(rescueInfo.getLicenseNum());
saveReqVO.setCar(carMain);
//推送到维修中
customerCarService.saveCustomerAndCar(saveReqVO);
//处理司机状态
//查询司机是否还存在未结束的救援订单
//处理redis
@ -620,7 +641,6 @@ public class RescueDriverInfoServiceImpl extends ServiceImpl<RescueDriverInfoMap
}
//所在顶级机构
String redisKey = Redis_Driver_Key + driverInfo.getTenantId() + ":" + rescueInfo.getDriverId();
Object temp = redisCache.getCacheMapValue(redisKey, "rescueIds");

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.system.api.user.dto;
import cn.iocoder.yudao.module.system.enums.common.SexEnum;
import lombok.Data;
@Data
@ -51,5 +50,9 @@ public class UserDTO {
* 用户openId
**/
private String openId;
/**
* 用户openId
**/
private Long tenantId;
}