package com.zksy.visualization.controller;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zksy.common.core.domain.Result;
import com.zksy.visualization.config.IccConfigProperty;
import com.zksy.visualization.domain.request.*;
import com.zksy.visualization.domain.response.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author Administrator
 * @version 1.0
 * @project dh-server-micro
 * @description 停车管理
 * @date 2024/12/16 10:58:15
 */
@RestController
@Api(tags = "停车管理", description = "停车管理")
@RequestMapping("/parkingManage")
@Slf4j
public class ParkingManageController {
    @Autowired
    private OkHttpClient httpClient;
    @Autowired
    private IccConfigProperty iccConfigProperty;
    @Autowired
    private RedisTemplate<String,String> redisTemplate;

    @ApiOperation(value = "停车场概览(用户总览/今日收款占比/今日泊位概况)")
    @GetMapping("/parkingLot")
    public Result parkingLot(){
        String authorization = redisTemplate
                .opsForValue()
                .get("Authorization:" + iccConfigProperty.getUsername());
        Request request = new Request.Builder()
                .url("https://" + iccConfigProperty.getHost() + "/evo-apigw/ipms/parkSurvey/platformDetail?noKeepAlive=true")
                .addHeader("Authorization", authorization)
                .build();
        try {
            Response response = httpClient.newCall(request).execute();
            if(!response.isSuccessful()){
                return Result.error("查询停车场概览失败");
            }
            ResponseBody responseBody = response.body();
            if (responseBody != null) {
                String responseString = responseBody.string();
                ObjectMapper objectMapper = new ObjectMapper();
                JsonNode rootNode = objectMapper.readTree(responseString);
                JsonNode success = rootNode.path("success");
                if(success.isBoolean() && success.asBoolean()) {
                    JsonNode dataNode = rootNode.path("data");
                    if (dataNode.isObject()) {
                        ParkingOverviewResponse parkingOverviewResponse = objectMapper.treeToValue(dataNode, ParkingOverviewResponse.class);
                        return Result.ok(parkingOverviewResponse);
                    } else {
                        return Result.ok(null);
                    }
                }else {
                    JsonNode errMsgNode = rootNode.path("errMsg");
                    String errMsg = errMsgNode.isTextual() ? errMsgNode.asText() : "未知错误";
                    return Result.error(errMsg);
                }
            }
        } catch (Exception e) {
            log.error("error:{}", e);
        }
        return Result.error("查询停车场概览失败");
    }

    @ApiOperation(value = "收款统计")
    @GetMapping("/collectionStatistics")
    public Result collectionStatistics(){
        String authorization = redisTemplate
                .opsForValue()
                .get("Authorization:" + iccConfigProperty.getUsername());
        Request request = new Request.Builder()
                .url("https://" + iccConfigProperty.getHost() + "/evo-apigw/ipms/parkSurvey/todaySurvey?type=0")
                .addHeader("Authorization", authorization)
                .build();
        try {
            Response response = httpClient.newCall(request).execute();
            if(!response.isSuccessful()){
                return Result.error("查询收款统计失败");
            }
            ResponseBody responseBody = response.body();
            if (responseBody != null) {
                String responseString = responseBody.string();
                ObjectMapper objectMapper = new ObjectMapper();
                JsonNode rootNode = objectMapper.readTree(responseString);
                JsonNode success = rootNode.path("success");
                if(success.isBoolean() && success.asBoolean()) {
                    JsonNode dataNode = rootNode.path("data");
                    if (dataNode.isObject()) {
                        CollectionStatisticsResponse parkingOverviewResponse = objectMapper.treeToValue(dataNode, CollectionStatisticsResponse.class);
                        return Result.ok(parkingOverviewResponse);
                    } else {
                        return Result.ok(null);
                    }
                }else {
                    JsonNode errMsgNode = rootNode.path("errMsg");
                    String errMsg = errMsgNode.isTextual() ? errMsgNode.asText() : "未知错误";
                    return Result.error(errMsg);
                }
            }
        } catch (Exception e) {
            log.error("查询收款统计失败:{}", e);
        }
        return Result.error("查询收款统计失败");
    }

    @ApiOperation(value = "车流统计")
    @GetMapping("/trafficStatistics")
    public Result TrafficStatistics(){
        String authorization = redisTemplate
                .opsForValue()
                .get("Authorization:" + iccConfigProperty.getUsername());
        Request request = new Request.Builder()
                .url("https://" + iccConfigProperty.getHost() + "/evo-apigw/ipms/parkSurvey/carInOutSurvey?type=0")
                .addHeader("Authorization", authorization)
                .build();
        try {
            Response response = httpClient.newCall(request).execute();
            if(!response.isSuccessful()){
                return Result.error("查询车流统计失败");
            }
            ResponseBody responseBody = response.body();
            if (responseBody != null) {
                String responseString = responseBody.string();
                ObjectMapper objectMapper = new ObjectMapper();
                JsonNode rootNode = objectMapper.readTree(responseString);
                JsonNode success = rootNode.path("success");
                if(success.isBoolean() && success.asBoolean()) {
                    JsonNode dataNode = rootNode.path("data");
                    if (dataNode.isObject()) {
                        TrafficStatisticsResponse parkingOverviewResponse = objectMapper.treeToValue(dataNode, TrafficStatisticsResponse.class);
                        return Result.ok(parkingOverviewResponse);
                    } else {
                        return Result.ok(null);
                    }
                }else {
                    JsonNode errMsgNode = rootNode.path("errMsg");
                    String errMsg = errMsgNode.isTextual() ? errMsgNode.asText() : "未知错误";
                    return Result.error(errMsg);
                }
            }
        } catch (Exception e) {
            log.error("查询车流统计失败:{}", e);
        }
        return Result.error("查询车流统计失败");
    }

    @ApiOperation(value = "查询车场列表")
    @GetMapping("/parkingList")
    public Result ParkingList(ParkingListRequest parkingListRequest){
        String authorization = redisTemplate
                .opsForValue()
                .get("Authorization:" + iccConfigProperty.getUsername());
        HttpUrl url = new HttpUrl.Builder()
                .scheme("https")
                .host(iccConfigProperty.getHost())
                .addPathSegments("/evo-apigw/ipms/parkinglot/query")
                .addQueryParameter("pageNum", String.valueOf(parkingListRequest.getPageNum()))
                .addQueryParameter("pageSize",String.valueOf(parkingListRequest.getPageSize()))
                .addQueryParameter("returnPage",String.valueOf(parkingListRequest.getReturnPage()))
                .addQueryParameter("parkingLotFuzzy",parkingListRequest.getParkingLotFuzzy())
                .build();

        Request request = new Request.Builder()
                .url(url)
                .addHeader("Authorization", authorization)
                .build();
        try {
            Response response = httpClient.newCall(request).execute();
            if(!response.isSuccessful()){
                return Result.error("查询车场列表失败");
            }
            ResponseBody responseBody = response.body();
            if (responseBody != null) {
                String responseString = responseBody.string();
                ObjectMapper objectMapper = new ObjectMapper();
                JsonNode rootNode = objectMapper.readTree(responseString);
                JsonNode success = rootNode.path("success");
                if(success.isBoolean() && success.asBoolean()) {
                    JsonNode dataNode = rootNode.path("data");
                    if (dataNode.isObject()) {
                        ParkingListResponse parkingListResponse = objectMapper.treeToValue(dataNode, ParkingListResponse.class);
                        return Result.ok(parkingListResponse);
                    } else {
                        return Result.ok(null);
                    }
                }else{
                    JsonNode errMsgNode = rootNode.path("errMsg");
                    String errMsg = errMsgNode.isTextual() ? errMsgNode.asText() : "未知错误";
                    return Result.error(errMsg);
                }
            }
        } catch (Exception e) {
            log.error("查询车场列表失败:{}", e);
        }
        return Result.error("查询车场列表失败");
    }

    @ApiOperation(value = "车场余位信息")
    @GetMapping("/parkingVacancy")
    public Result ParkingVacancy(){
        String authorization = redisTemplate
                .opsForValue()
                .get("Authorization:" + iccConfigProperty.getUsername());
        Request request = new Request.Builder()
                .url("https://" + iccConfigProperty.getHost() + "/evo-apigw/ipms/parkinglot/stat")
                .addHeader("Authorization", authorization)
                .build();
        try {
            Response response = httpClient.newCall(request).execute();
            if(!response.isSuccessful()){
                return Result.error("车场余位信息失败");
            }
            ResponseBody responseBody = response.body();
            if (responseBody != null) {
                String responseString = responseBody.string();
                ObjectMapper objectMapper = new ObjectMapper();
                JsonNode rootNode = objectMapper.readTree(responseString);
                JsonNode success = rootNode.path("success");
                if(success.isBoolean() && success.asBoolean()) {
                    JsonNode dataNode = rootNode.path("data");
                    if (dataNode.isObject()) {
                        ParkingVacancyResponse parkingListResponse = objectMapper.treeToValue(dataNode, ParkingVacancyResponse.class);
                        return Result.ok(parkingListResponse);
                    } else {
                        return Result.ok(null);
                    }
                }else{
                    JsonNode errMsgNode = rootNode.path("errMsg");
                    String errMsg = errMsgNode.isTextual() ? errMsgNode.asText() : "未知错误";
                    return Result.error(errMsg);
                }
            }
        } catch (Exception e) {
            log.error("车场余位信息失败:{}", e);
        }
        return Result.error("车场余位信息失败");
    }
    @ApiOperation(value = "车辆列表查询")
    @GetMapping("/queryVehicleList")
    public Result queryVehicleList(QueryVehicleListRequest queryVehicleListRequest){
        String authorization = redisTemplate
                .opsForValue()
                .get("Authorization:" + iccConfigProperty.getUsername());
        HttpUrl url = new HttpUrl.Builder()
                .scheme("https")
                .host(iccConfigProperty.getHost())
                .addPathSegments("/evo-apigw/ipms/car/list")
                .addQueryParameter("pageNum", String.valueOf(queryVehicleListRequest.getPageNum()))
                .addQueryParameter("pageSize",String.valueOf(queryVehicleListRequest.getPageSize()))
                .addQueryParameter("parkinglotCode",String.valueOf(queryVehicleListRequest.getParkinglotCode()))
                .addQueryParameter("ownerNameLikeStr",queryVehicleListRequest.getOwnerNameLikeStr())
                .addQueryParameter("carNumLikeStr", queryVehicleListRequest.getCarNumLikeStr())
                .addQueryParameter("listType",String.valueOf(queryVehicleListRequest.getListType()))
                .build();

        Request request = new Request.Builder()
                .url(url)
                .addHeader("Authorization", authorization)
                .build();
        try {
            Response response = httpClient.newCall(request).execute();
            if(!response.isSuccessful()){
                return Result.error("车辆列表查询失败");
            }
            ResponseBody responseBody = response.body();
            if (responseBody != null) {
                String responseString = responseBody.string();
                ObjectMapper objectMapper = new ObjectMapper();
                JsonNode rootNode = objectMapper.readTree(responseString);
                JsonNode success = rootNode.path("success");
                if(success.isBoolean() && success.asBoolean()) {
                    JsonNode dataNode = rootNode.path("data");
                    if (dataNode.isObject()) {
                        QueryVehicleListResponse queryVehicleListResponse = objectMapper.treeToValue(dataNode, QueryVehicleListResponse.class);
                        return Result.ok(queryVehicleListResponse);
                    } else {
                        return Result.ok(null);
                    }
                }else{
                    JsonNode errMsgNode = rootNode.path("errMsg");
                    String errMsg = errMsgNode.isTextual() ? errMsgNode.asText() : "未知错误";
                    return Result.error(errMsg);
                }
            }
        } catch (Exception e) {
            log.error("车辆列表查询失败:{}", e);
        }
        return Result.error("车辆列表查询失败");
    }

    @ApiOperation(value = "车辆进出信息查询")
    @GetMapping("/entryExitInfo")
    public Result entryExitInfo(EntryExitInfoRequest queryRequest){
        String authorization = redisTemplate
                .opsForValue()
                .get("Authorization:" + iccConfigProperty.getUsername());
        HttpUrl url = new HttpUrl.Builder()
                .scheme("https")
                .host(iccConfigProperty.getHost())
                .addPathSegments("/evo-apigw/ipms/caraccess/find/his")
                .addQueryParameter("pageNum", String.valueOf(queryRequest.getPageNum()))
                .addQueryParameter("pageSize", String.valueOf(queryRequest.getPageSize()))
                .addQueryParameter("entranceChannelIds", queryRequest.getEntranceChannelIds() == null ? "" : queryRequest.getEntranceChannelIds())
                .addQueryParameter("exitusChannelIds", queryRequest.getExitusChannelIds() == null ? "" : queryRequest.getExitusChannelIds())
                .addQueryParameter("carType", queryRequest.getCarType() == null ? "" : String.valueOf(queryRequest.getCarType()))
                .addQueryParameter("departmentId", queryRequest.getDepartmentId() == null ? "" : String.valueOf(queryRequest.getDepartmentId()))
                .addQueryParameter("etcType", queryRequest.getEtcType() == null ? "" : String.valueOf(queryRequest.getEtcType()))
                .addQueryParameter("ownerCode", queryRequest.getOwnerCode() == null ? "" : queryRequest.getOwnerCode())
                .addQueryParameter("ownerLikeStr", queryRequest.getOwnerLikeStr() == null ? "" : queryRequest.getOwnerLikeStr())
                .addQueryParameter("parkingLotCodes", queryRequest.getParkingLotCodes() == null ? "" : queryRequest.getParkingLotCodes())
                .addQueryParameter("enterCarNumLikeStr", queryRequest.getEnterCarNumLikeStr() == null ? "" : queryRequest.getEnterCarNumLikeStr())
                .addQueryParameter("exitCarNumLikeStr", queryRequest.getExitCarNumLikeStr() == null ? "" : queryRequest.getExitCarNumLikeStr())
                .addQueryParameter("enterTimeStrLeft", queryRequest.getEnterTimeStrLeft() == null ? "" : queryRequest.getEnterTimeStrLeft())
                .addQueryParameter("enterTimeStrRight", queryRequest.getEnterTimeStrRight() == null ? "" : queryRequest.getEnterTimeStrRight())
                .addQueryParameter("exitTimeStrLeft", queryRequest.getExitTimeStrLeft() == null ? "" : queryRequest.getExitTimeStrLeft())
                .addQueryParameter("exitTimeStrRight", queryRequest.getExitTimeStrRight() == null ? "" : queryRequest.getExitTimeStrRight())

                .build();

        Request request = new Request.Builder()
                .url(url)
                .addHeader("Authorization", authorization)
                .build();
        try {
            Response response = httpClient.newCall(request).execute();
            if(!response.isSuccessful()){
                return Result.error("车辆列表查询失败");
            }
            ResponseBody responseBody = response.body();
            if (responseBody != null) {
                String responseString = responseBody.string();
                ObjectMapper objectMapper = new ObjectMapper();
                JsonNode rootNode = objectMapper.readTree(responseString);
                JsonNode success = rootNode.path("success");
                if(success.isBoolean() && success.asBoolean()) {
                    JsonNode dataNode = rootNode.path("data");
                    if (dataNode.isObject()) {
                        return Result.ok(dataNode);
                    } else {
                        return Result.ok(null);
                    }
                }else{
                    JsonNode errMsgNode = rootNode.path("errMsg");
                    String errMsg = errMsgNode.isTextual() ? errMsgNode.asText() : "未知错误";
                    return Result.error(errMsg);
                }
            }
        } catch (Exception e) {
            log.error("车辆进出信息查询失败:{}", e);
        }
        return Result.error("车辆进出信息查询");
    }

    @ApiOperation(value = "统计车辆进出总数")
    @GetMapping("/importExportStatistics")
    public Result importExportStatistics(ImportExportStatisticsRequest queryRequest){
        String authorization = redisTemplate
                .opsForValue()
                .get("Authorization:" + iccConfigProperty.getUsername());
        HttpUrl url = new HttpUrl.Builder()
                .scheme("https")
                .host(iccConfigProperty.getHost())
                .addPathSegments("/evo-apigw/ipms/caraccess/find/hisCount")
                // 添加查询参数时检查null值并处理日期格式化
                .addQueryParameter("pageNum", valueOrNull(queryRequest.getPageNum()))
                .addQueryParameter("pageSize", valueOrNull(queryRequest.getPageSize()))
                .addQueryParameter("entranceChannelIds", nullToEmpty(queryRequest.getEntranceChannelIds()))
                .addQueryParameter("exitusChannelIds", nullToEmpty(queryRequest.getExitusChannelIds()))
                .addQueryParameter("carType", valueOrNull(queryRequest.getCarType()))
                .addQueryParameter("departmentId", valueOrNull(queryRequest.getDepartmentId()))
                .addQueryParameter("etcType", valueOrNull(queryRequest.getEtcType()))
                .addQueryParameter("ownerCode", nullToEmpty(queryRequest.getOwnerCode()))
                .addQueryParameter("ownerLikeStr", nullToEmpty(queryRequest.getOwnerLikeStr()))
                .addQueryParameter("parkingLotCodes", nullToEmpty(queryRequest.getParkingLotCodes()))
                .addQueryParameter("enterCarNumLikeStr", nullToEmpty(queryRequest.getEnterCarNumLikeStr()))
                .addQueryParameter("exitCarNumLikeStr", nullToEmpty(queryRequest.getExitCarNumLikeStr()))
                .addQueryParameter("enterTimeStrLeft", nullToEmpty(queryRequest.getEnterTimeStrLeft()))
                .addQueryParameter("enterTimeStrRight", nullToEmpty(queryRequest.getEnterTimeStrRight()))
                .addQueryParameter("exitTimeStrLeft", nullToEmpty(queryRequest.getExitTimeStrLeft()))
                .addQueryParameter("exitTimeStrRight", nullToEmpty(queryRequest.getExitTimeStrRight()))
                .build();

        Request request = new Request.Builder()
                .url(url)
                .addHeader("Authorization", authorization)
                .build();
        try {
            Response response = httpClient.newCall(request).execute();
            if(!response.isSuccessful()){
                return Result.error("统计车辆进出总数失败");
            }
            ResponseBody responseBody = response.body();
            if (responseBody != null) {
                String responseString = responseBody.string();
                ObjectMapper objectMapper = new ObjectMapper();
                JsonNode rootNode = objectMapper.readTree(responseString);
                JsonNode success = rootNode.path("success");
                if(success.isBoolean() && success.asBoolean()) {
                    JsonNode dataNode = rootNode.path("data");
                    if (dataNode != null) {
                        return Result.ok(dataNode);
                    } else {
                        return Result.ok(null);
                    }
                }else{
                    JsonNode errMsgNode = rootNode.path("errMsg");
                    String errMsg = errMsgNode.isTextual() ? errMsgNode.asText() : "未知错误";
                    return Result.error(errMsg);
                }
            }
        } catch (Exception e) {
            log.error("统计车辆进出总数失败:{}", e);
        }
        return Result.error("统计车辆进出总数");
    }
    @ApiOperation(value = "抓拍记录信息")
    @GetMapping("/captureRecord")
    public Result captureRecord(CaptureRecordResponse queryRequest){
        String authorization = redisTemplate
                .opsForValue()
                .get("Authorization:" + iccConfigProperty.getUsername());
        HttpUrl url = new HttpUrl.Builder()
                .scheme("https")
                .host(iccConfigProperty.getHost())
                .addPathSegments("/evo-apigw/ipms/carcapture/find/conditions")
                // 添加查询参数时检查null值并处理日期格式化
                .addQueryParameter("pageNum", String.valueOf(queryRequest.getPageNum()))
                .addQueryParameter("pageSize", String.valueOf(queryRequest.getPageSize()))
                .addQueryParameter("carDirect", nullToEmpty(queryRequest.getCarDirect()))
                .addQueryParameter("queryTimeBegin", formatDate(queryRequest.getQueryTimeBegin()))
                .addQueryParameter("queryTimeEnd", formatDate(queryRequest.getQueryTimeEnd()))
                .addQueryParameter("carNumLikeStr", nullToEmpty(queryRequest.getCarNumLikeStr()))
                .addQueryParameter("devChnId", nullToEmpty(queryRequest.getDevChnId()))
                .addQueryParameter("ownerName", nullToEmpty(queryRequest.getOwnerName()))
                .build();

        Request request = new Request.Builder()
                .url(url)
                .addHeader("Authorization", authorization)
                .build();
        try {
            Response response = httpClient.newCall(request).execute();
            if(!response.isSuccessful()){
                return Result.error("抓拍记录信息失败");
            }
            ResponseBody responseBody = response.body();
            if (responseBody != null) {
                String responseString = responseBody.string();
                ObjectMapper objectMapper = new ObjectMapper();
                JsonNode rootNode = objectMapper.readTree(responseString);
                JsonNode success = rootNode.path("success");
                if(success.isBoolean() && success.asBoolean()) {
                    JsonNode dataNode = rootNode.path("data");
                    if (dataNode != null) {
                        return Result.ok(dataNode);
                    } else {
                        return Result.ok(null);
                    }
                }else{
                    JsonNode errMsgNode = rootNode.path("errMsg");
                    String errMsg = errMsgNode.isTextual() ? errMsgNode.asText() : "未知错误";
                    return Result.error(errMsg);
                }
            }
        } catch (Exception e) {
            log.error("抓拍记录信息失败:{}", e);
        }
        return Result.error("抓拍记录信息");
    }
    @ApiOperation(value = "统计抓拍记录总数")
    @GetMapping("/statisticalSnapshotRecords")
    public Result statisticalSnapshotRecords(StatisticalSnapshotRecordsRequest queryRequest){
        String authorization = redisTemplate
                .opsForValue()
                .get("Authorization:" + iccConfigProperty.getUsername());
        HttpUrl url = new HttpUrl.Builder()
                .scheme("https")
                .host(iccConfigProperty.getHost())
                .addPathSegments("/evo-apigw/ipms/carcapture/find/conditionsCount")
                // 添加查询参数时检查null值
                .addEncodedQueryParameter("carDirect", nullToEmpty(queryRequest.getCarDirect()))
                .addEncodedQueryParameter("queryTimeBegin", nullToEmpty(queryRequest.getQueryTimeBegin()))
                .addEncodedQueryParameter("queryTimeEnd", nullToEmpty(queryRequest.getQueryTimeEnd()))
                .addEncodedQueryParameter("carNumLikeStr", nullToEmpty(queryRequest.getCarNumLikeStr()))
                .addEncodedQueryParameter("devChnId", nullToEmpty(queryRequest.getDevChnId()))
                .addEncodedQueryParameter("ownerName", nullToEmpty(queryRequest.getOwnerName()))
                .build();

        Request request = new Request.Builder()
                .url(url)
                .addHeader("Authorization", authorization)
                .build();
        try {
            Response response = httpClient.newCall(request).execute();
            if(!response.isSuccessful()){
                return Result.error("统计抓拍记录总数失败");
            }
            ResponseBody responseBody = response.body();
            if (responseBody != null) {
                String responseString = responseBody.string();
                ObjectMapper objectMapper = new ObjectMapper();
                JsonNode rootNode = objectMapper.readTree(responseString);
                JsonNode success = rootNode.path("success");
                if(success.isBoolean() && success.asBoolean()) {
                    JsonNode dataNode = rootNode.path("data");
                    if (dataNode != null) {
                        return Result.ok(dataNode);
                    } else {
                        return Result.ok(null);
                    }
                }else{
                    JsonNode errMsgNode = rootNode.path("errMsg");
                    String errMsg = errMsgNode.isTextual() ? errMsgNode.asText() : "未知错误";
                    return Result.error(errMsg);
                }
            }
        } catch (Exception e) {
            log.error("统计抓拍记录总数失败:{}", e);
        }
        return Result.error("统计抓拍记录总数");
    }
    // 辅助方法：将null转换为空字符串
    private String nullToEmpty(String str) {
        return str == null ? "" : str;
    }

    // 辅助方法：将非空的Integer或Long值转换为字符串，否则返回null
    private String valueOrNull(Number number) {
        return number == null ? null : String.valueOf(number);
    }

    // 辅助方法：格式化日期，若日期为null则返回null
    private String formatDate(Date date) {
        if (date == null) {
            return null;
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(date);
    }
}
