package org.diagbot.push.controller;

import org.diagbot.common.push.bean.ResponseData;
import org.diagbot.common.push.cache.ApplicationCacheUtil;
import org.diagbot.common.push.cache.CacheFileManager;
import org.diagbot.common.push.cache.CacheUtil;
import org.diagbot.nlp.util.NlpCache;
import org.diagbot.pub.api.Response;
import org.diagbot.pub.web.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by louhr on 2019/8/16.
 */
@Controller
@RequestMapping("/cache_file_manager")
public class CacheFileManagerController extends BaseController {

    @RequestMapping(value = "/create_file")
    @ResponseBody
    public Response<ResponseData> create(HttpServletRequest request) throws Exception {
        Response<ResponseData> response = new Response<ResponseData>();
        CacheFileManager cacheFileManager = new CacheFileManager();
        cacheFileManager.createCacheFile();
        //自然语言处理缓存更新
        NlpCache.createSegmentCache();
        NlpCache.createPushCache();
        NlpCache.createClassifyCache();
        NlpCache.createChronicCache();
        NlpCache.createSynonymCache();
        NlpCache.createSegmentCachePacs();
        //更新图谱缓存
        CacheUtil.createDiagSortCache();
        CacheUtil.createSexAgeCache();
        CacheUtil.createVitalCache();
        CacheUtil.createDiagClassifyCache();
        CacheUtil.createDiagClassifyJiCache();
        CacheUtil.createDiagDepartCache();
        //更新大数据缓存
        ApplicationCacheUtil.createDoc_result_mapping_diag_map();
        ApplicationCacheUtil.createDoc_result_mapping_filter_map();
        ApplicationCacheUtil.create_kl_rule_filter_map();
        ApplicationCacheUtil.create_kl_rule_app_filter_map();
        ApplicationCacheUtil.create_kl_diagnose_detail_filter_map();
        return response;
    }
}
