package com.xhpc.card.controller;

import com.xhpc.card.service.IAnalyzeTheMessageService;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.controller.BaseController;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author yuyang
 * @Date 2025-06-23 15:38
 */
@RestController
@RequestMapping("/analyze")
@Api(value = "解析报文", tags = "解析报文")
public class AnalyzeTheMessage extends BaseController {

    @Resource
    private IAnalyzeTheMessageService analyzeTheMessageService;


    @PostMapping("/content")
    public R content(@RequestBody Map<String,Object> map){
        String content = map.get("content").toString();
        if(content.length()<12){
            return R.fail("请输入正确的报文");
        }

        String sb = content.substring(10, 12);
        switch (sb){
            case "01":
                return analyzeTheMessageService.getRegisterLogic(content);
            case "02":
                return analyzeTheMessageService.getReplyRegisterLogic(content);
            case "03":
                return analyzeTheMessageService.getHBLogic(content);
            case "04":
                return analyzeTheMessageService.getReplyHBLogic(content);
            case "05":
                return analyzeTheMessageService.getRateModelValidateLogic(content);
            case "06":
                return analyzeTheMessageService.getReplyRateModelValidateLogic(content);
            case "09":
                return analyzeTheMessageService.getRateModelRequestLogic(content);
            case "0A":
                return analyzeTheMessageService.getReplyRateModelRequestLogic(content);
            case "13":
                return analyzeTheMessageService.getRealtimeDataLogic(content);
            case "15":
                return analyzeTheMessageService.getBmsChargingHandshakeDataLogic(content);
            case "17":
                return analyzeTheMessageService.getBmsChargingConfigDataLogic(content);
            case "19":
                return analyzeTheMessageService.getBmsChargingCompletedDataLogic(content);
            case "1B":
                return analyzeTheMessageService.getBmsErrorDataLogic(content);
            case "1D":
                return analyzeTheMessageService.getBmsInterruptDataLogic(content);
            case "21":
                return analyzeTheMessageService.getBmsChargerInterruptDataLogic(content);
            case "23":
                return analyzeTheMessageService.getBmsReqChargerOutputDataLogic(content);
            case "25":
                return analyzeTheMessageService.getBmsChargingDataLogic(content);
            case "31":
                return analyzeTheMessageService.getPileStartChargingDataLogic(content);
            case "32":
                return analyzeTheMessageService.getReplyPileStartChargingDataLogic(content);
            case "33":
                return analyzeTheMessageService.getRemoteStartReplyDataLogic(content);
            case "38":
                return analyzeTheMessageService.getReplyRemoteStartReplyDataLogic(content);
            case "35":
                return analyzeTheMessageService.getRemoteStopReplyDataLogic(content);
            case "36":
                return analyzeTheMessageService.getReplyRemoteStopReplyDataLogic(content);
            case "3B":
                return analyzeTheMessageService.getOrderDataLogic(content);
            case "40":
                return analyzeTheMessageService.getReplyOrderDataLogic(content);
            case "41":
                return analyzeTheMessageService.getBalanceUpdateReplyDataLogic(content);
            case "42":
                return analyzeTheMessageService.getReplyBalanceUpdateReplyDataLogic(content);
            case "51":
                return analyzeTheMessageService.getPileConfigReplyDataLogic(content);
            case "52":
                return analyzeTheMessageService.getReplyPileConfigReplyDataLogic(content);
            case "55":
                return analyzeTheMessageService.getPileTimeConfigReplyDataLogic(content);
            case "56":
                return analyzeTheMessageService.getReplyPileTimeConfigReplyDataLogic(content);
            case "57":
                return analyzeTheMessageService.getRateModelConfigReplyDataLogic(content);
            case "58":
                return analyzeTheMessageService.getReplyRateModelConfigReplyDataLogic(content);
            case "91":
                return analyzeTheMessageService.getRemoteRebootReplyDataLogic(content);
            case "92":
                return analyzeTheMessageService.getReplyRemoteRebootReplyDataLogic(content);
            case "93":
                return analyzeTheMessageService.getRemoteUpgradeReplyDataLogic(content);
            case "94":
                return analyzeTheMessageService.getRemoteUpgradeDataLogic(content);

            default:
                return R.fail("请输入正确的报文");
        }
    }

    public static void main(String[] args) {
        String st="6822445E00018083600001000100020C382E352D31330000000000000000000000000000C0C5";

        System.out.println(st.substring(10,12));

    }
}
