/**
 * Copyright 2019 DH
 * All right reserved.
 * 项目名称: 大恒泰山系统
 * 创建日期:2022/8/23
 */
package org.springblade.modules.business.equipment.inspection.report.wrapper;

import org.springblade.common.cache.DictBizCache;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.enums.EquipmentStatusEnum;
import org.springblade.modules.business.equipment.inspection.base.wrapper.EquipmentInspectionWrapper;
import org.springblade.modules.business.equipment.inspection.report.entity.EquipmentInspectionReportEntity;
import org.springblade.modules.business.equipment.inspection.report.vo.EquipmentInspectionReportVO;
import org.springblade.modules.business.rtumanage.vo.RtuStatusVO;
import org.springblade.modules.system.entity.DictBiz;

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

/***
 * Date:2022/8/23
 * Title:文件所属模块（必须填写）
 * Description：对本文件的详细描述，原则上不能少于30字
 * @author dylan
 * @version 1.0
 * Remark：认为有必要的其他信息
 */

public class EquipmentInspectionReportWrapper extends BaseEntityWrapper<EquipmentInspectionReportEntity, EquipmentInspectionReportVO> {
	public static EquipmentInspectionReportWrapper build() {
		return new EquipmentInspectionReportWrapper();
	}

	@Override
	public EquipmentInspectionReportVO entityVO(EquipmentInspectionReportEntity entity) {
		EquipmentInspectionReportVO equipmentInspectionReportVO = Objects.requireNonNull(BeanUtil.copy(entity, EquipmentInspectionReportVO.class));

		DictBiz biz = DictBizCache.getById(entity.getWaterSensorType());
		if (null != biz) {
			equipmentInspectionReportVO.setWaterSensorTypeText(biz.getDictValue());
		}
		biz = DictBizCache.getById(entity.getGroundSensorType());
		if (null != biz) {
			equipmentInspectionReportVO.setGroundSensorTypeText(biz.getDictValue());
		}
		biz = DictBizCache.getById(entity.getSatelliteModel());
		if (null != biz) {
			equipmentInspectionReportVO.setSatelliteModelText(biz.getDictValue());
		}

		return equipmentInspectionReportVO;
	}

	public void reportQuery(Map<String, Object> report) {
		// 此场景仅在 pg数据库 map类型传参的情况下需要处理，entity传参已经包含数据类型，则无需关心
		// 针对 pg数据库 int类型字段查询需要强转的处理示例
		String searchKey = "inspectionId";
		if (Func.isNotEmpty(report.get(searchKey))) {
			// 数据库字段为int类型，设置"="查询，具体查询参数请见 @org.springblade.core.mp.support.SqlKeyword
			report.put(searchKey.concat("_equal"), Func.toLong(report.get(searchKey)));
			// 默认"like"查询，pg数据库 场景会报错，所以将其删除
			report.remove(searchKey);
		}
	}

	public void toVoInfo(EquipmentInspectionReportVO reportVO) {

		reportVO.setAreaName(reportVO.getAdCity() + "/" + reportVO.getAdDist());

	}
}
