package com.ruoyi.web.controller.Ytj;

import java.util.List;
import java.util.Map;
import java.util.UUID;

import com.alibaba.druid.support.json.JSONUtils;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.json.JSON;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.system.service.IGtgsZxService;
import com.sun.org.apache.xpath.internal.operations.Mod;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GtgsZx;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 注销前台Controller
 *
 * @author ruoyi
 * @date 2020-05-13
 */
@Controller
@RequestMapping("/Ytj/zx")
public class GtgsZxController extends BaseController {
    private String prefix = "Ytj/zx";
    @Autowired
    private IGtgsZxService iGtgsZxService;


    @GetMapping()
    public String zx(ModelMap modelMap) {

        modelMap.put("city", Global.getCityName());
        return prefix + "/Read";
    }

    @GetMapping("/gtzx")
    public String gtzx(ModelMap modelMap) {
        modelMap.put("score", Global.getConfig("ruoyi.rzdbsocre"));
        modelMap.put("city", Global.getCityName());
        return prefix + "/gtzx";
    }


    /**
     * 新增保存注销前台
     */
    @Log(title = "注销前台", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(GtgsZx gtgsZx) {
        String Uuid = UUID.randomUUID().toString().replace("-", "");
        gtgsZx.setId(Uuid);
        return toAjax(iGtgsZxService.insertGtgsZx(gtgsZx));
    }

    /**
     * 新增保存注销前台
     */
    @Log(title = "注销前台", businessType = BusinessType.INSERT)
    @PostMapping("/getInfo")
    @ResponseBody
    public AjaxResult getInfo(@RequestParam("XyCode") String XyCode, @RequestParam("regisCode")String regisCode) {
        String result;
        if(XyCode!=""){
            result= HttpUtils.sendPost(Global.getConfig("ruoyi.pyip") + "/sel_xydm", "xydm=" + XyCode);
        }else {
            result=  HttpUtils.sendPost(Global.getConfig("ruoyi.pyip") + "/sel_zch", "zch=" + regisCode);
        }
        System.out.println("查询返回结果:"+result);
        if(result.equals("0")){
            return AjaxResult.warn("输入有误,请确认 (注册号) 或 (统一社会信用代码)！");
        }else if(result.equals("")){
            return AjaxResult.warn("获取超时,请 重试 或 联系工作人员-18830910706");
        }
        return AjaxResult.success("ok", result);
    }

}
