package com.engine.attendance.workflow.service.impl;

import com.engine.attendance.workflow.service.BusinessTripsApplyService;
import com.engine.common.util.DbTools;
import com.engine.core.impl.Service;
import lombok.extern.slf4j.Slf4j;
import weaver.general.Util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: sy
 * @Description: 出差申请
 * @Date: 2024/3/15
 **/
@Slf4j
public class BusinessTripsApplyServiceImpl extends Service implements BusinessTripsApplyService {
    @Override
    public Map<String, Object> getBusinessTripsApplyList(Map<String, Object> params) {

        Map<String, Object> retmap = new HashMap<String, Object>();
        //获取主表id列表
        String targetUserId = Util.null2String(params.get("targetUserId"));
        String businessTripsType = Util.null2String(params.get("businessTripsType"));
        String startDate = Util.null2String(params.get("startDate"));
        String endDate = Util.null2String(params.get("endDate"));
        log.info("targetUserId : {}, businessTripsType : {}, startDate : {}, endDate : {}", targetUserId, businessTripsType, startDate, endDate);
        //查询子表数据

        String detailSql = "select a.id,a.cxcc,a.ksrq,a.kssj,a.jsrq,a.jssj,a.ccsc,a.qtcc,a.btcc,a.cxsm from uf_jcl_kq_ccjl_dt1 a left join uf_jcl_kq_ccjl b on a.mainid=b.id where (a.cxcc is null or a.cxcc<>1) and a.ccr =? and a.ksrq >= ? and a.ksrq <= ? and b.cclx=?";
        List<Map<String, Object>> detailList = DbTools.getSqlToList(detailSql,targetUserId,startDate,endDate,businessTripsType);
        if (detailList.size() > 0) {
            retmap.put("result", detailList);
        } else {
            retmap.put("result", null);
        }
        log.info("detailList : [{}]", detailList);

        return retmap;
    }
}
