WebStatisticsController.java 5.32 KB
package com.lhcredit.project.webbusiness.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lhcredit.common.utils.StringUtils;
import com.lhcredit.common.utils.spring.SpringUtils;
import com.lhcredit.framework.aspectj.lang.annotation.CheckToken;
import com.lhcredit.framework.web.domain.AjaxResult;
import com.lhcredit.framework.web.page.TableDataInfo;
import com.lhcredit.project.business.BasicInformation.service.BasicInformationService;
import com.lhcredit.project.business.TianYC.entity.param.RequestParams;
import com.lhcredit.project.business.TianYC.entity.param.SFParams;
import com.lhcredit.project.business.judicial.domain.VO.PromptStatisticsVO;
import com.lhcredit.project.business.judicial.service.JudicialService;
import com.lhcredit.project.business.judicial.service.PromptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

import static com.lhcredit.framework.web.domain.AjaxResult.success;

@Api(tags = "统计信息")
@Controller
@RequestMapping("/api-V2.0/statistics")
@RequiredArgsConstructor
public class WebStatisticsController {

    private final PromptService promptService;

    private final JudicialService judicialService;

    private final BasicInformationService basicInformationService;

    @ResponseBody
    @ApiOperation(value = "案件统计", notes = "案件统计")
    @ApiImplicitParam(name = "name", value = "公司名称", required = true, dataType = "String")
    @PostMapping("/case/statistics")
    @CheckToken
    public AjaxResult caseInfo(@RequestParam("name") String name) {
        return promptService.findAllCaseCount(name);
    }


    @ResponseBody
    @ApiOperation(value = "风险提示统计", notes = "风险提示统计")
    @PostMapping("/prompt/statistics")
    @CheckToken
    public AjaxResult prompt(@RequestBody SFParams sfParams) {
        //查询公司曾用名
//        WebBasicInformationController bean = SpringUtils.getBean(WebBasicInformationController.class);
//        RequestParams requestParams = new RequestParams();
////        requestParams.setName(sfParams.getName());
//        requestParams.setCreditCode(sfParams.getCreditCode());
//        AjaxResult base = bean.base(requestParams);
//        JSONObject object = JSONObject.parseObject(JSON.toJSONString(base));
//        JSONObject data = object.getJSONObject("data");
//        String historyNames = data.getString("historyNames");
        //----------------------------------------------------------
        AjaxResult prompt = promptService.prompt(sfParams.getCreditCode());
//        //如果曾用名存在
//        if (StringUtils.isNotEmpty(historyNames)){
//            AjaxResult historyNamesPrompt = promptService.prompt(historyNames);
//            Object valOrg = prompt.get("data");
//            Object valhis = historyNamesPrompt.get("data");
//            JSONObject hisVo = JSONObject.parseObject(JSON.toJSONString(valhis));
//            JSONObject orgVo = JSONObject.parseObject(JSON.toJSONString(valOrg));
//            for (Map.Entry<String, Object> entry : orgVo.entrySet()) {
//                if (entry.getValue().getClass().getSimpleName().equals("Integer")){
//                    entry.setValue(orgVo.getInteger(entry.getKey())+hisVo.getInteger(entry.getKey()));
//                }
//            }
//            return AjaxResult.success(orgVo);
//        }
        return prompt;

    }



    @ResponseBody
    @ApiOperation(value = "风险提示统计vx", notes = "风险提示统计vx")
    @PostMapping("/prompt/statisticsVx")
    @CheckToken
    public AjaxResult promptVx(@RequestBody SFParams sfParams) {
        return promptService.promptVx(sfParams.getCreditCode());

    }


    @ResponseBody
    @ApiOperation(value = "司法涉诉总览统计", notes = "司法涉诉总览统计")
    @PostMapping("/caseCount")
    @CheckToken
    public AjaxResult caseCount(@Validated @RequestBody SFParams sfParams) {
        RequestParams requestParams = new RequestParams();
        requestParams.setCreditCode(sfParams.getCreditCode());
        JSONObject jsonObject1 = basicInformationService.baseinfo2(requestParams);
        if (jsonObject1 != null && "2000".equals(jsonObject1.getString("code"))) {
            JSONObject data = jsonObject1.getJSONObject("data");
            sfParams.setName(data.getString("name"));
        }
        return promptService.statics(sfParams.getName());
    }

    @ResponseBody
    @ApiOperation(value = "案件类型分布饼状统计", notes = "案件类型分布饼状统计")
    @PostMapping("/case/pieShaped")
    @CheckToken
    public AjaxResult pieShaped(@RequestBody SFParams sfParams) {
        RequestParams requestParams = new RequestParams();
        requestParams.setCreditCode(sfParams.getCreditCode());
        JSONObject jsonObject1 = basicInformationService.baseinfo2(requestParams);
        if (jsonObject1 != null && "2000".equals(jsonObject1.getString("code"))) {
            JSONObject data = jsonObject1.getJSONObject("data");
            sfParams.setName(data.getString("name"));
        }
        return promptService.pieShaped(sfParams.getName());
    }
}