package com.dgtly.sync.controller;


import com.alibaba.fastjson.JSONObject;
import com.dgtly.common.exception.BusinessException;
import com.dgtly.sync.domain.SyncFailDetail;
import com.dgtly.sync.domain.SyncLog;
import com.dgtly.sync.service.*;
import com.dgtly.system.domain.SysDept;
import com.dgtly.system.service.ISysDeptService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;
import java.util.concurrent.*;

/**
 * 同步数据解析接口
 * 数据调度中心在数据同步成功后会调用相应的接口通知各个模块解析相应的数据
 * interface是框架中放行的前缀
 *
 * qxp
 */
@RestController
@RequestMapping("/interface/sync")
public class SyncController {


    private static final Logger log = LoggerFactory.getLogger(SyncController.class);


    @Autowired
    private IAnalysisDeptService analysisDeptService;

    @Autowired
    private IAnalysisSysUserService analysisSysUserService;

    /**
     * 解析部门数据
     * @param packageId
     * @param jobId
     * @param message
     * @return
     */
    @GetMapping("dept")
    public Object dept(String packageId, String jobId, String message){
        try{
           //analysisDeptService.analysisDept(packageId);
        }catch (Exception e){
            log.error("解析部门出错",e);
        }
        return true;
    }


    /**
     * 解析用户数据
     * @param packageId
     * @param jobId
     * @param message
     * @return
     */
    @GetMapping("user")
    public Object user(String packageId, String jobId, String message){
        try{
            //在这解析处理人事数据（公司，大区，销售部）主管职位，层级架构

            analysisSysUserService.analysisSysUser(null);
            //analysisSysUserService.analysisSysCwUser(null);
            analysisSysUserService.analysisSysYSLUser(null);
            analysisSysUserService.analysisSysDivisionUser();
            analysisSysUserService.analysisSysApplicationServiceUser();
            analysisSysUserService.analysisSysClueReporting();
        }catch (Exception e){
            log.error("解析用户出错",e);
        }
        return true;
    }





}
