ClockInAnalysisController.java 5.64 KB
package cn.com.glsx.dj.controller;

import cn.com.glsx.dj.request.StaffStatisticRequest;
import cn.com.glsx.dj.smartcarlife.dto.BehaviorAbnormalMonitoringWeeklyStatisticsDTO;
import cn.com.glsx.dj.smartcarlife.dto.ClockInCompleteAnalysisStaffDailyStatisticsDTO;
import cn.com.glsx.dj.smartcarlife.dto.ClockInCompleteAnalysisStaffMonthlyStatisticsDTO;
import cn.com.glsx.dj.smartcarlife.dto.StaffStatisticRequestDTO;
import cn.com.glsx.dj.smartcarlife.remote.ClockInAnalysisRemote;
import cn.com.glsx.dj.util.CommonUtil;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

@Slf4j
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
@Api("打卡分析")
public class ClockInAnalysisController {

    @Autowired
    private ClockInAnalysisRemote clockInAnalysisRemote;
    
    @ApiOperation("月报-打卡完成分析")
    @ServiceMethod(method = "dj.api.pe.analysis.clock.in.monthly.page", needInSession = NeedInSessionType.YES)
    public RopResponse<RpcPagination<ClockInCompleteAnalysisStaffMonthlyStatisticsDTO>> pageClockInMonthly(StaffStatisticRequest request){
        RpcPagination<StaffStatisticRequestDTO> pagination = CommonUtil.getRpcPagination(StaffStatisticRequestDTO.class);
        try {
            pagination.getCondition().parseMerchantStaffMap(CommonUtil.getCycleOrderMerchantSellerPermission(request.getMerchantFilter()));
            pagination.getCondition().setMerchantIds(CommonUtil.getMerchantIdPermission(request.getMerchantFilter()));
            return CommonUtil.convertRopResponse(clockInAnalysisRemote.pageClockInMonthly(pagination));
        } catch (RpcServiceException e) {
            log.error("=====月报-打卡完成分析 rpcServiceException:{}", e.getMessage());
            return RopResponse.error(e);
        } catch (Exception e) {
            log.error("=====月报-打卡完成分析 exception:{}", e.getMessage(), e);
            return RopResponse.error("分页查询月报-打卡完成分析失败");
        }
    }

    @ApiOperation("周报-人员行为异常监测")
    @ServiceMethod(method = "dj.api.pe.analysis.behavior.abnormal.weekly.page", needInSession = NeedInSessionType.YES)
    public RopResponse<RpcPagination<BehaviorAbnormalMonitoringWeeklyStatisticsDTO>> pageBehaviorAbnormalWeekly(StaffStatisticRequest request){
        RpcPagination<StaffStatisticRequestDTO> pagination = CommonUtil.getRpcPagination(StaffStatisticRequestDTO.class);
        try {
            pagination.getCondition().parseMerchantStaffMap(CommonUtil.getCycleOrderMerchantSellerPermission(request.getMerchantFilter()));
            pagination.getCondition().setMerchantIds(CommonUtil.getMerchantIdPermission(request.getMerchantFilter()));
            return CommonUtil.convertRopResponse(clockInAnalysisRemote.pageBehaviorAbnormalWeekly(pagination));
        } catch (RpcServiceException e) {
            log.error("=====周报-人员行为异常监测 rpcServiceException:{}", e.getMessage());
            return RopResponse.error(e);
        } catch (Exception e) {
            log.error("=====周报-人员行为异常监测 exception:{}", e.getMessage(), e);
            return RopResponse.error("分页查询周报-人员行为异常监测失败");
        }
    }

    @ApiOperation("日报-打卡完成分析")
    @ServiceMethod(method = "dj.api.pe.analysis.clock.in.daily.page", needInSession = NeedInSessionType.YES)
    public RopResponse<RpcPagination<ClockInCompleteAnalysisStaffDailyStatisticsDTO>> pageClockInDaily(StaffStatisticRequest request){
        RpcPagination<StaffStatisticRequestDTO> pagination = CommonUtil.getRpcPagination(StaffStatisticRequestDTO.class);
        try {
            pagination.getCondition().parseMerchantStaffMap(CommonUtil.getCycleOrderMerchantSellerPermission(request.getMerchantFilter()));
            pagination.getCondition().setMerchantIds(CommonUtil.getMerchantIdPermission(request.getMerchantFilter()));
            return CommonUtil.convertRopResponse(clockInAnalysisRemote.pageClockInDaily(pagination));
        } catch (RpcServiceException e) {
            log.error("=====日报-打卡完成分析 rpcServiceException:{}", e.getMessage());
            return RopResponse.error(e);
        } catch (Exception e) {
            log.error("=====日报-打卡完成分析 exception:{}", e.getMessage(), e);
            return RopResponse.error("分页查询日报-打卡完成分析失败");
        }
    }

    @ApiOperation("执行打卡数据同步任务")
    @ServiceMethod(method = "dj.api.pe.analysis.clock.in.syncQwClockInData.handle", needInSession = NeedInSessionType.NO)
    public RopResponse<Boolean> handleSyncQwClockInData(StaffStatisticRequest request){
        RpcPagination<StaffStatisticRequestDTO> pagination = CommonUtil.getRpcPagination(StaffStatisticRequestDTO.class);
        try {
            return CommonUtil.convertRopResponse(clockInAnalysisRemote.handleSyncQwClockInData(pagination));
        } catch (RpcServiceException e) {
            log.error("=====执行打卡数据同步任务 rpcServiceException:{}", e.getMessage());
            return RopResponse.error(e);
        } catch (Exception e) {
            log.error("=====执行打卡数据同步任务 exception:{}", e.getMessage(), e);
            return RopResponse.error("执行打卡数据同步任务失败");
        }
    }
}