package com.chinaweal.aiccs.aiccs.claim.controller;


import com.chinaweal.aiccs.aiccs.abnormal.service.EBaseinfoService;
import com.chinaweal.aiccs.aiccs.claim.entity.SolrExGongan128Xdzkdy;
import com.chinaweal.aiccs.aiccs.claim.service.impl.SolrExGongan128XdzkdyServiceImpl;
import com.chinaweal.aiccs.common.base.controller.BaseController;
import com.chinaweal.youfool.framework.springboot.rest.RestResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

/**
 */
@Transactional
@RestController
@RequestMapping("/claim")
public class ClaimController extends BaseController {

    @Autowired
    private EBaseinfoService eBaseinfoService;

    @Autowired
    private SolrExGongan128XdzkdyServiceImpl solrExGongan128XdzkdyService;

    /**
     * 主动触发跑个体户分区
     */
    @GetMapping("/gthfq")
    public RestResult<?> gthfq() {
        int i = eBaseinfoService.automaticClaimCenter();
        return RestResult.ok(i);
    }

    /**
     * 主动触发跑企业分区
     */
    @GetMapping("/qyfq")
    public RestResult<?> qyfq() {
        int i = eBaseinfoService.autoEntArea();
        return RestResult.ok(i);
    }

    /**
     * 主动进行跑数据，通过csv导入
     */
    @GetMapping("/csvToSolr")
    public RestResult<?> csvToSolr(@RequestParam String csvPath) throws IOException {
        int i = solrExGongan128XdzkdyService.csvToSolr(csvPath);
        return RestResult.ok(i);
    }

    /**
     * test
     */
    @GetMapping("/testfind")
    public RestResult<?> testfind(@RequestParam String dom) throws IOException {
        SolrExGongan128Xdzkdy top1AddressMatchingDegree = solrExGongan128XdzkdyService.getTop1AddressMatchingDegree(dom);
        return RestResult.ok(top1AddressMatchingDegree);
    }

}

