package com.rongwei.controller;

import com.rongwei.bscommon.sys.service.*;
import com.rongwei.bsentity.domin.QuShiftDo;
import com.rongwei.bsentity.domin.SrmIssuesListDo;
import com.rongwei.bsentity.vo.VDeptVo;
import com.rongwei.rwcommon.base.R;
import com.rongwei.rwcommonentity.commonservers.vo.SysMindMappingVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/question")
public class QuestionController {

    private final Logger log = LoggerFactory.getLogger(this.getClass().getName());

    @Autowired
    private SysMindMappingBsService sysMindMappingBsService;
    @Autowired
    private SrmIssuesListService srmIssuesListService;
    @Autowired
    private OrgUserSyncService orgUserSyncService;

    /**
     * 故障树图片保存
     * @param sysMindMappingVo
     * @return
     */
    @PostMapping("/saveMindImg")
    public void saveMindImg(@RequestBody SysMindMappingVo sysMindMappingVo) throws IOException {
        sysMindMappingBsService.saveMindImg(sysMindMappingVo);
    }

    /**
     * 鱼骨图图片保存
     * @param srmIssuesListDo
     * @return
     */
    @PostMapping("/saveFishBoneImg")
    public void saveFishBoneImg(@RequestBody SrmIssuesListDo srmIssuesListDo) throws IOException {
        srmIssuesListService.saveFishBoneImg(srmIssuesListDo);
    }

    /**
     * 组织机构同步
     * @return
     */
    @PostMapping("/orgSync")
    public R orgSync(@RequestBody Map<String,Object> map) throws IOException {
        orgUserSyncService.orgSync();
        return R.ok();
    }

    /**
     * 人员同步
     * @return
     */
    @PostMapping("/userSync")
    public R userSync(@RequestBody Map<String,Object> map) throws IOException {
        orgUserSyncService.userSync();
        return R.ok();
    }


    /**
     * 每个小时的5分0秒，执行一次，将对应时间段0分0秒-5分0秒钟创建的消息（sys_notify_announce表），并且标题为“生产问题--xxxx”的消息，修改NOTIFYTYPE为"issuetracking"，发送app推送
     */
    @PostMapping("/productionOverdue")
    public R productionOverdue(){
        srmIssuesListService.productionOverdue();
        return R.ok();
    }
}
