package org.jeecg.module.custom.ocr.utils;

import org.jeecg.module.custom.ocr.dataobject.OcrDictionary;
import org.jeecg.module.custom.ocr.dataobject.OcrDictionaryGroup;
import org.jeecg.module.custom.ocr.dataobject.OcrPicture;
import org.jeecg.module.custom.ocr.service.OcrDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 字典数据报错工具类
 *
 * @author hugh(shuli.yao) 1397940314@qq.com
 * @version 1.0
 * @date 2024/3/16 11:18
 */
@Component
public class DataDictionaryUtil {

    /**
     * 任务计划
     */
    @Autowired
    private OcrDictionaryService ocrDictionaryService;

    /**
     * 图片数据，字典关联检查新增 集合排查
     *
     * @param ocrPictureList
     * @return
     */
//    public boolean pictureDataDictionarySaveArray(List<OcrPicture> ocrPictureList) {
//        for (OcrPicture picture : ocrPictureList) {
//            //1.检查提报人字典是否包含数据
//            if (picture.getUpname() != null && picture.getUpuserid() != null) {
//                OcrDictionaryGroup upNameDG = ocrDictionaryService.queryGroupByField("person");
//                if (upNameDG != null && ocrDictionaryService.isValueExists(upNameDG.getId(), picture.getUpname(), picture.getTenantId())) {
//                    OcrDictionary dictionary = new OcrDictionary();
//                    dictionary.setLable(picture.getUpname());
//                    dictionary.setValue(picture.getUpuserid());
//                    dictionary.setTenantId(picture.getTenantId());
//                    dictionary.setGroupId(upNameDG.getId());
//                    try {
//                        ocrDictionaryService.save(dictionary);
//                    } catch (Exception e) {
//
//                    }
//
//                }
//            }
//
//
//            //2.任务计划
//            if (picture.getPlanname() != null && picture.getPlanid() != null) {
//                OcrDictionaryGroup planNameDG = ocrDictionaryService.queryGroupByField("plan");
//                if (planNameDG != null && ocrDictionaryService.isValueExists(planNameDG.getId(), picture.getPlanname(), picture.getTenantId())) {
//                    OcrDictionary dictionary = new OcrDictionary();
//                    dictionary.setLable(picture.getPlanname());
//                    dictionary.setValue(picture.getPlanid());
//                    dictionary.setTenantId(picture.getTenantId());
//                    dictionary.setGroupId(planNameDG.getId());
//                    try {
//                        ocrDictionaryService.save(dictionary);
//                    } catch (Exception e) {
//
//                    }
//                }
//            }
//            //3.拜访客户类型
//            if (picture.getField2() != null) {
//                OcrDictionaryGroup field2DG = ocrDictionaryService.queryGroupByField("izcustomtype");
//                if (field2DG != null && ocrDictionaryService.isValueExists(field2DG.getId(), picture.getField2(), picture.getTenantId())) {
//                    OcrDictionary dictionary = new OcrDictionary();
//                    dictionary.setLable(picture.getField2());
//                    dictionary.setValue(picture.getField2());
//                    dictionary.setTenantId(picture.getTenantId());
//                    dictionary.setGroupId(field2DG.getId());
//                    try {
//                        ocrDictionaryService.save(dictionary);
//                    } catch (Exception e) {
//
//                    }
//                }
//            }
//
//            //4.拜访客户名称
//            if (picture.getField3() != null) {
//                OcrDictionaryGroup field3DG = ocrDictionaryService.queryGroupByField("izcustomname");
//                if (field3DG != null && ocrDictionaryService.isValueExists(field3DG.getId(), picture.getField3(), picture.getTenantId())) {
//                    OcrDictionary dictionary = new OcrDictionary();
//                    dictionary.setLable(picture.getField3());
//                    dictionary.setValue(picture.getField3());
//                    dictionary.setTenantId(picture.getTenantId());
//                    dictionary.setGroupId(field3DG.getId());
//                    try {
//                        ocrDictionaryService.save(dictionary);
//                    } catch (Exception e) {
//
//                    }
//                }
//            }
//
//            //5.任务来源
//            if (picture.getField4() != null) {
//                OcrDictionaryGroup field4DG = ocrDictionaryService.queryGroupByField("iztaskrrom");
//                if (field4DG != null && ocrDictionaryService.isValueExists(field4DG.getId(), picture.getField4(), picture.getTenantId())) {
//                    OcrDictionary dictionary = new OcrDictionary();
//                    dictionary.setLable(picture.getField4());
//                    dictionary.setValue(picture.getField4());
//                    dictionary.setTenantId(picture.getTenantId());
//                    dictionary.setGroupId(field4DG.getId());
//                    try {
//                        ocrDictionaryService.save(dictionary);
//                    } catch (Exception e) {
//
//                    }
//                }
//            }
//            //6.厂商
//            if (picture.getField5() != null) {
//                OcrDictionaryGroup field5DG = ocrDictionaryService.queryGroupByField("izfirm");
//                if (field5DG != null && ocrDictionaryService.isValueExists(field5DG.getId(), picture.getField5(), picture.getTenantId())) {
//                    OcrDictionary dictionary = new OcrDictionary();
//                    dictionary.setLable(picture.getField5());
//                    dictionary.setValue(picture.getField5());
//                    dictionary.setTenantId(picture.getTenantId());
//                    dictionary.setGroupId(field5DG.getId());
//                    try {
//                        ocrDictionaryService.save(dictionary);
//                    } catch (Exception e) {
//
//                    }
//                }
//            }
//            //7.拜访客户级别
//            if (picture.getField6() != null) {
//                OcrDictionaryGroup field6DG = ocrDictionaryService.queryGroupByField("izcustomlevel");
//                if (field6DG != null && ocrDictionaryService.isValueExists(field6DG.getId(), picture.getField6(), picture.getTenantId())) {
//                    OcrDictionary dictionary = new OcrDictionary();
//                    dictionary.setLable(picture.getField6());
//                    dictionary.setValue(picture.getField6());
//                    dictionary.setTenantId(picture.getTenantId());
//                    dictionary.setGroupId(field6DG.getId());
//                    try {
//                        ocrDictionaryService.save(dictionary);
//                    } catch (Exception e) {
//
//                    }
//                }
//            }
//            //8.拜访项目类别
//            if (picture.getField17() != null) {
//                OcrDictionaryGroup field17DG = ocrDictionaryService.queryGroupByField("izprojecttype");
//                if (field17DG != null && ocrDictionaryService.isValueExists(field17DG.getId(), picture.getField17(), picture.getTenantId())) {
//                    OcrDictionary dictionary = new OcrDictionary();
//                    dictionary.setLable(picture.getField17());
//                    dictionary.setValue(picture.getField17());
//                    dictionary.setTenantId(picture.getTenantId());
//                    dictionary.setGroupId(field17DG.getId());
//                    try {
//                        ocrDictionaryService.save(dictionary);
//                    } catch (Exception e) {
//
//                    }
//                }
//            }
//
//            //9.任务状态
//            if (picture.getTaskstatus() != null) {
//                OcrDictionaryGroup taskStatusDG = ocrDictionaryService.queryGroupByField("iztaskstatus");
//                if (taskStatusDG != null && ocrDictionaryService.isValueExists(taskStatusDG.getId(), picture.getTaskstatus(), picture.getTenantId())) {
//                    OcrDictionary dictionary = new OcrDictionary();
//                    dictionary.setLable(picture.getTaskstatus());
//                    dictionary.setValue(picture.getTaskstatus());
//                    dictionary.setTenantId(picture.getTenantId());
//                    dictionary.setGroupId(taskStatusDG.getId());
//                    try {
//                        ocrDictionaryService.save(dictionary);
//                    } catch (Exception e) {
//
//                    }
//                }
//            }
//
//            //10.产品名称
//            if (picture.getField9() != null) {
//                OcrDictionaryGroup field9DG = ocrDictionaryService.queryGroupByField("izproductname");
//                if (field9DG != null && ocrDictionaryService.isValueExists(field9DG.getId(), picture.getField9(), picture.getTenantId())) {
//                    OcrDictionary dictionary = new OcrDictionary();
//                    dictionary.setLable(picture.getField9());
//                    dictionary.setValue(picture.getField9());
//                    dictionary.setTenantId(picture.getTenantId());
//                    dictionary.setGroupId(field9DG.getId());
//                    try {
//                        ocrDictionaryService.save(dictionary);
//                    } catch (Exception e) {
//
//                    }
//                }
//            }
//
//            //11.地区(城市信息)
//            if (picture.getReleasearea() != null) {
//                OcrDictionaryGroup releaseAreaDG = ocrDictionaryService.queryGroupByField("izvisitcity");
//                if (releaseAreaDG != null && ocrDictionaryService.isValueExists(releaseAreaDG.getId(), picture.getReleasearea(), picture.getTenantId())) {
//                    OcrDictionary dictionary = new OcrDictionary();
//                    dictionary.setLable(picture.getReleasearea());
//                    dictionary.setValue(picture.getReleasearea());
//                    dictionary.setTenantId(picture.getTenantId());
//                    dictionary.setGroupId(releaseAreaDG.getId());
//                    try {
//                        ocrDictionaryService.save(dictionary);
//                    } catch (Exception e) {
//
//                    }
//                }
//            }
//
//            //12.地区(省信息)
//            if (picture.getReleaseprovince() != null) {
//                OcrDictionaryGroup releaseProvinceDG = ocrDictionaryService.queryGroupByField("izvisitpro");
//                if (releaseProvinceDG != null && ocrDictionaryService.isValueExists(releaseProvinceDG.getId(), picture.getReleaseprovince(), picture.getTenantId())) {
//                    OcrDictionary dictionary = new OcrDictionary();
//                    dictionary.setLable(picture.getReleaseprovince());
//                    dictionary.setValue(picture.getReleaseprovince());
//                    dictionary.setTenantId(picture.getTenantId());
//                    dictionary.setGroupId(releaseProvinceDG.getId());
//                    try {
//                        ocrDictionaryService.save(dictionary);
//                    } catch (Exception e) {
//
//                    }
//                }
//            }
//
//            //13.项目信息
//            if (picture.getProjectidname() != null) {
//                OcrDictionaryGroup projectNameDG = ocrDictionaryService.queryGroupByField("project");
//                if (projectNameDG != null && ocrDictionaryService.isValueExists(projectNameDG.getId(), picture.getProjectidname(), picture.getTenantId())) {
//                    OcrDictionary dictionary = new OcrDictionary();
//                    dictionary.setLable(picture.getProjectidname());
//                    dictionary.setValue(picture.getProjectidname());
//                    dictionary.setTenantId(picture.getTenantId());
//                    dictionary.setGroupId(projectNameDG.getId());
//                    try {
//                        ocrDictionaryService.save(dictionary);
//                    } catch (Exception e) {
//
//                    }
//                }
//            }
//
//        }
//        return true;
//    }
}
