package com.yem.em.utils;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.entity.OrmLocaleValue;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;

import java.math.BigDecimal;
import java.util.*;

/**
 * @author SC
 * @ClassName CommonEmUtils(图册公共帮助类)
 * @date 2023年06月15日
 * @version: 1.0
 */
public class CommonEmUtils {

	/**
	 * @MethodName 获取导入电子目录已使用产品资源号
	 * @Author  SC
	 * @Description
	 * @Date 15:35 2023/9/4
	 * @Param [Etcmanualimporid] [long]
	 * @return java.util.List<java.lang.Long>
	 **/
	public static List<Long> getUseEtcmanualimport(long Etcmanualimporid) {
		List<Long> UsebasemodelibIDl = new ArrayList<>();
		QFilter qFilter = new QFilter("id", QCP.not_equals2, Etcmanualimporid);
		DynamicObject[] etcmanualimportCol = BusinessDataServiceHelper.load("yem_em_etcmanualimport", "id,name,number,yem_basemodelib.id", new QFilter[] { qFilter});
		for(DynamicObject etcmanualimport : etcmanualimportCol){
			DynamicObject yem_basemodelib = etcmanualimport.getDynamicObject("yem_basemodelib");
			if(yem_basemodelib!=null){
				UsebasemodelibIDl.add(yem_basemodelib.getLong("id"));
			}
		}
		return UsebasemodelibIDl;
	}

	/**
	 * @MethodName 获取电子目录已使用产品资源号
	 * @Author  SC
	 * @Description
	 * @Date 15:35 2023/9/4
	 * @Param [Etcmanualimporid] [long]
	 * @return java.util.List<java.lang.Long>
	 **/
	public static List<Long> getUseEtcmanualist(long EtcmanualistID,boolean isresourc) {
		List<Long> UsebasemodelibIDl = new ArrayList<>();
		QFilter qFilter = new QFilter("id", QCP.not_equals2, EtcmanualistID);
		if(isresourc){
			QFilter qFilter1 = new QFilter("yem_resourc", QCP.equals, true);
			qFilter.and(qFilter1);
		}
		DynamicObject[] equipmentlistCol = BusinessDataServiceHelper.load("yem_em_equipmentlist", "id,name,number,yem_basemodelib.id", new QFilter[] { qFilter});
		for(DynamicObject equipmentlist : equipmentlistCol){
			DynamicObject yem_basemodelib = equipmentlist.getDynamicObject("yem_basemodelib");
			if(yem_basemodelib!=null){
				UsebasemodelibIDl.add(yem_basemodelib.getLong("id"));
			}
		}
		return UsebasemodelibIDl;
	}

}
