package com.zfire.mall.manager.logic.k3;

import com.zfire.mall.manager.bean.k3.RequestApiBean;
import com.zfire.mall.manager.constant.KingDeeCons;
import com.zfire.mall.manager.plus.entity.KingDeeDepartment;
import com.zfire.mall.manager.plus.service.KingDeeDepartmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

@Service
@Slf4j
public class K3DepartmentLogic {

    @Resource
    KingDeeDepartmentService kingDeeDepartmentService;
    @Resource
    K3Logic k3Logic;

    public List<KingDeeDepartment> list(){
        return kingDeeDepartmentService.list();
    }

//    public void allSync(String orgId, String orgNumber, String startTime, String endTime) throws Exception {
//        // 调用部门接口
//        RequestApiBean request = k3Logic.getInstance(orgId, orgNumber, KingDeeCons.DEPT_INFO, startTime, endTime);
//        String filterStr = "FDocumentStatus = 'C' AND FUseOrgId.FNUMBER = %s "+ k3Logic.supplySql("FAuditDate", request.getStartTime(), request.getEndTime());
//        request.setFieldKeys("FDEPTID,FNUMBER,FNAME,FUseOrgId,FUseOrgId.FNUMBER,FUseOrgId.FName");
//        request.setFilterString(String.format(filterStr, orgNumber));
//        request.setOrderString("FDEPTID ASC");
//
//        String[] fields = new String[]{"id","number","name","useOrgId","useOrgNumber","useOrgName"};
//        List<KingDeeDepartment> objects = k3Logic.allSync(request, fields, KingDeeDepartment.class);
//        if (!CollectionUtils.isEmpty(objects)) {
//            kingDeeDepartmentService.saveOrUpdateBatch(objects);
//        }
//    }
}
