12.6修改
This commit is contained in:
+11
-2
@@ -2942,10 +2942,19 @@ public class VehicleApplicationService {
|
||||
if (!hasPilot1 && !hasPilot2) {
|
||||
throw new IllegalArgumentException("请选择副驾");
|
||||
}
|
||||
|
||||
UserDriverDTO userDriverDTO = new UserDriverDTO();
|
||||
//将pilot1或是pilot2的id传给userDriverDTO,判断一下谁有值传谁
|
||||
userDriverDTO.setUserId(Long.valueOf(hasPilot1 ? vehicleDto.getPilot1Id() : vehicleDto.getPilot2Id()));
|
||||
userDriverDTO.setVehicleId(vehicleDto.getVehicleId());
|
||||
|
||||
// 更新
|
||||
return vehicleMapper.updatePilotDriver(vehicleDto);
|
||||
vehicleMapper.updatePilotDriver(vehicleDto);
|
||||
|
||||
|
||||
|
||||
userServiceFeign.bindVehicle(userDriverDTO);
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,76 +646,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="updatePilotDriver" parameterType="com.linke.transport.interfaces.dto.vehicle.VehicleDto">
|
||||
<!-- 开启事务 -->
|
||||
START TRANSACTION;
|
||||
|
||||
UPDATE ngwl_test_transport.vehicle v
|
||||
SET
|
||||
<choose>
|
||||
<when test="pilot1Id!= null and pilot1Id != ''">
|
||||
v.pilot1_id = #{pilot1Id},
|
||||
v.pilot1 = #{pilot1}
|
||||
</when>
|
||||
<when test="pilot2Id != null and pilot2Id != ''">
|
||||
v.pilot2_id = #{pilot2Id},
|
||||
v.pilot2 = #{pilot2}
|
||||
</when>
|
||||
</choose>
|
||||
<if test="pilot1Id != null and pilot1Id != ''">
|
||||
v.pilot1_id = #{pilot1Id},
|
||||
</if>
|
||||
<if test="pilot1 != null and pilot1 != ''">
|
||||
v.pilot1 = #{pilot1},
|
||||
</if>
|
||||
<if test="pilot2Id != null and pilot2Id != ''">
|
||||
v.pilot2_id = #{pilot2Id},
|
||||
</if>
|
||||
<if test="pilot2 != null and pilot2 != ''">
|
||||
v.pilot2 = #{pilot2},
|
||||
</if>
|
||||
v.update_time = NOW()
|
||||
WHERE v.vehicle_id = #{vehicleId};
|
||||
|
||||
<!-- 插入或更新车辆与副驾的绑定关系 -->
|
||||
INSERT INTO ngwl_test_user.driver_vehicle_bind
|
||||
(user_id, vehicle_id, driver_bind_id, bind_driver_name, vehicle_license_plate_number, default_flag, del_flag, create_time, update_time)
|
||||
SELECT
|
||||
v.user_id,
|
||||
v.vehicle_id,
|
||||
<choose>
|
||||
<when test="pilot1Id != null and pilot1Id != ''">
|
||||
#{pilot1Id},
|
||||
#{pilot1},
|
||||
</when>
|
||||
<when test="pilot2Id != null and pilot2Id != ''">
|
||||
#{pilot2Id},
|
||||
#{pilot2},
|
||||
</when>
|
||||
</choose>
|
||||
v.vehicle_license_plate_number,
|
||||
2,
|
||||
1,
|
||||
NOW(),
|
||||
NOW()
|
||||
FROM ngwl_test_transport.vehicle v
|
||||
WHERE v.vehicle_id = #{vehicleId}
|
||||
ON DUPLICATE KEY UPDATE
|
||||
bind_driver_name = VALUES(bind_driver_name),
|
||||
update_time = NOW();
|
||||
|
||||
<!-- 插入或更新ngwl_test_wlhy库的tms_driver表中副驾与车辆的关联 -->
|
||||
INSERT INTO ngwl_test_wlhy.tms_driver
|
||||
(driver_id, driver_name, vehicle_type_id, create_time, update_time)
|
||||
VALUES
|
||||
(
|
||||
<choose>
|
||||
<when test="pilot1Id != null and pilot1Id != ''">
|
||||
#{pilot1Id},
|
||||
#{pilot1},
|
||||
</when>
|
||||
<when test="pilot2Id != null and pilot2Id != ''">
|
||||
#{pilot2Id},
|
||||
#{pilot2},
|
||||
</when>
|
||||
</choose>
|
||||
#{vehicleId},
|
||||
NOW(),
|
||||
NOW()
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
driver_name = VALUES(driver_name),
|
||||
vehicle_type_id = VALUES(vehicle_type_id),
|
||||
update_time = NOW();
|
||||
|
||||
<!-- 提交事务 -->
|
||||
COMMIT;
|
||||
</update>
|
||||
|
||||
<delete id="deleteVehicleByVehicleId" parameterType="Long">
|
||||
|
||||
Reference in New Issue
Block a user