修改分页查询单位内外的车辆任务接口sql,添加车辆地址和车辆状态字段

main
吴顺杰 1 month ago
parent adcac54754
commit 9bde3b8cce

@ -28,4 +28,14 @@ public class CarGPSResponse implements Serializable {
* 84 * 84
*/ */
public String lng; public String lng;
/**
*
*/
public String addr;
/**
* 线
*/
public String stateCn;
} }

@ -27,4 +27,16 @@ public class CarPageResponse implements Serializable {
*/ */
@ApiModelProperty(value = "车辆关联任务") @ApiModelProperty(value = "车辆关联任务")
public String taskTitle; public String taskTitle;
/**
*
*/
@ApiModelProperty(value = "车辆所在地址")
public String addr;
/**
* 线
*/
@ApiModelProperty(value = "车辆在线状态")
public String stateCn;
} }

@ -24,6 +24,7 @@ import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -95,6 +96,17 @@ public class CarServiceImpl implements CarService {
colDTOS.add(colDTO); colDTOS.add(colDTO);
colDTOS.add(colDTO2); colDTOS.add(colDTO2);
contentResponse.setCol(colDTOS); contentResponse.setCol(colDTOS);
// 将第一个列表转换为Map以getCarPlate为键
Map<String, CarGPSResponse> map1 = list.stream()
.collect(Collectors.toMap(CarGPSResponse::getCarPlate, car -> car));
// 遍历第二个列表找到匹配的carNumber并赋值addr和stateCn
for (CarPageResponse car2 : carPageResponsePage.getRecords()) {
CarGPSResponse car1 = map1.get(car2.getCarNumber());
if (car1 != null) {
car2.setAddr(car1.getAddr());
car2.setStateCn(car1.getStateCn());
}
}
contentResponse.setData(carPageResponsePage.getRecords()); contentResponse.setData(carPageResponsePage.getRecords());
return contentResponse; return contentResponse;
} }

@ -34,21 +34,24 @@
</select> </select>
<select id="pageByPlateNums" resultType="com.ykMap.entity.response.CarPageResponse"> <select id="pageByPlateNums" resultType="com.ykMap.entity.response.CarPageResponse">
SELECT COALESCE(tm.name, '-') as taskTitle,vi.plate_num as carNumber SELECT COALESCE
FROM vehicle_info vi ( tm.NAME, '-' ) AS taskTitle,
INNER JOIN ( vi.plate_num AS carNumber
SELECT original_vehicle_id, MAX(update_time) AS latest_update_time FROM
FROM task_mission ( SELECT * FROM vehicle_info WHERE `state` IN ( '保养中', '损坏', '正常' ) AND `category` IN ( '维护车', '文物车',
WHERE update_time IS NOT NULL '硬币车', '运钞车' )
GROUP BY original_vehicle_id <if test="list.size > 0 and list != null">
) AS latest_tasks ON vi.id = latest_tasks.original_vehicle_id and vi.plate_num IN
INNER JOIN task_mission tm ON latest_tasks.original_vehicle_id = tm.original_vehicle_id <foreach item="plateNum" collection="list" open="(" separator="," close=")">
AND latest_tasks.latest_update_time = tm.update_time #{plateNum}
WHERE vi.plate_num IN </foreach>
<foreach item="plateNum" collection="list" open="(" separator="," close=")"> </if>
#{plateNum} ) AS vi
</foreach> LEFT JOIN ( SELECT original_vehicle_id, MAX( departure_time ) AS latest_departure_time FROM task_mission
ORDER BY tm.update_time DESC WHERE departure_time<= CURRENT_TIME
GROUP BY original_vehicle_id ) AS latest_tasks ON VI.ID = latest_tasks.original_vehicle_id
LEFT JOIN task_mission AS tm ON latest_tasks.original_vehicle_id = tm.original_vehicle_id
AND latest_tasks.latest_departure_time = tm.departure_time
</select> </select>

Loading…
Cancel
Save