package com.huigou.topsun.controller;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.huigou.cache.DictUtil;
import com.huigou.topsun.sap.sapApplication.application.*;
import com.huigou.topsun.sap.sapApplication.domain.query.SapDialogOrderQuery;
import com.huigou.topsun.sap.sapApplication.domain.query.SapDialogQuery;

import com.huigou.topsun.sap.suppliers.application.SuppliersDataApplication;
import com.huigou.topsun.util.SAPUtils;
import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.bmp.common.easysearch.EasySearch;
import com.huigou.uasp.bmp.common.easysearch.domain.model.EasySearchParse;
import com.huigou.uasp.bmp.common.easysearch.domain.model.QuerySchemeField;
import com.huigou.uasp.bmp.configuration.application.DictionaryApplication;
import com.huigou.uasp.bmp.opm.application.MemEasySearcher;
import com.huigou.uasp.bmp.opm.application.impl.MemEasySearcherImpl;
import com.huigou.util.JSONUtil;
import com.huigou.util.SDO;
import com.huigou.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Auther: xin.lu
 * @Date: 2023/11/24/10:07
 * @Description:
 */
@Controller
@ControllerMapping("/resourceNameGroup")
public class ResourceSearchController {
    @Resource
    private SapDictionaryApplication sapDictionaryApplication;
    @Resource
    private SapPaymentApplication sapPaymentApplication;
    @Autowired
    private SapMaterialApplication sapMaterialApplication;
    @Autowired
    private SapAreaApplication sapAreaApplication;
    @Autowired
    private  DictionaryApplication dictionaryApplication;
    @Autowired
    private SapBankInfoApplication sapBankInfoApplication;
    @Autowired
    private SuppliersDataApplication suppliersDataApplication;

    @EasySearch(queryName = "knttp")
    public Map<String, Object> knttpSelect(SDO sdo){
        Integer intPage = sdo.getInteger("intPage", 1);
        Integer pageSize = sdo.getInteger("pageSize",10);
        PageRequest pageRequest = new PageRequest(intPage - 1, pageSize);
        List<QuerySchemeField> fields =
                Arrays.asList(new QuerySchemeField("科目分配类别", "knttp", "string", 100L),
                        new QuerySchemeField("科目分配类别描述", "text", "string", 100L));
        EasySearchParse easySearchParse = new EasySearchParse();
        easySearchParse.setFields(fields);
        easySearchParse.setWidth(450L);
        List<Map<String,Object>> mapList = new ArrayList<>();
        String filterValue = sdo.getString("filterValue");
        Map<String, String> knttp = DictUtil.getDictionary("knttp");
        knttp.forEach((key, value) -> {
            Map<String, Object> map = new HashMap<>();
            map.put("knttp", value);
            if ("F".equals(key)){
                map.put("text","内部订单");
            }
            if ("K".equals(key)){
                map.put("text","成本中心");
            }
            if ("ZFW".equals(filterValue)) {
                if ("F".equals(key) || "K".equals(key)) {
                    mapList.add(map);
                }
            } else if ("ZNE1".equals(filterValue)) {
                if ("A".equals(key)) {
                    mapList.add(map);
                }
            } else if ("ZNE2".equals(filterValue)) {
                if ("F".equals(key) || "K".equals(key)) {
                    mapList.add(map);
                }
            }
        });
        MemEasySearcher<Map<String, Object>> memEasySearcher = new MemEasySearcherImpl<>();
        Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null);
        return model;
    }

    @EasySearch(queryName = "costCenter")
    public Map<String, Object> costCenterSelect(SDO sdo){
        Integer intPage = sdo.getInteger("intPage", 1);
        Integer pageSize = sdo.getInteger("pageSize",10);
        PageRequest pageRequest = new PageRequest(intPage - 1, pageSize);
        List<QuerySchemeField> fields =
                Arrays.asList(
                        new QuerySchemeField("编码", "code", "string", 100L),
                        new QuerySchemeField("名称", "code", "string", 100L)
                );
        EasySearchParse easySearchParse = new EasySearchParse();
        easySearchParse.setFields(fields);
        easySearchParse.setWidth(450L);
        List<Map<String,Object>> mapList = new ArrayList<>();
        String paramValue = sdo.getString("paramValue");

        MemEasySearcher<Map<String, Object>> memEasySearcher = new MemEasySearcherImpl<>();
        Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null);
        return model;
    }

    @EasySearch(queryName = "sapMaterialSelect")
    public Map<String, Object> sapMaterialSelect(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String filterValue = sdo.getString("filterValue");
        String mtart = sdo.getString("mtart");//如果传了刀模板具，就排除掉
        SapDialogQuery queryRequest = sdo.toObject(SapDialogQuery.class);
        queryRequest.setWerks(filterValue);
        List<Map<String,String>> mapList = sapMaterialApplication.getSapMaterial(queryRequest);
//        if (CollectionUtil.isNotEmpty(mapList)){
//            mapList = mapList
//                    .stream()
//                    .map(map->{
//                        String s = map.get("MATNR");
//                        map.put("MATNR",s.replaceAll("^(0+)", ""));
//                        return map;
//                    })
//                    .collect(Collectors.toList());
//        }
        if (CollectionUtil.isNotEmpty(mapList)){
            if (StringUtil.isNotBlank(mtart)){//固定条件过滤，比如选了工厂后，只能读取改工厂下的物料组
                mapList = mapList
                        .stream()
                        .filter(map -> !map.containsValue(mtart))
                        .collect(Collectors.toList());
            }
        }


        if (CollectionUtil.isNotEmpty(mapList)){
            if (StringUtil.isNotBlank(param)){//模糊条件过滤
                mapList = mapList
                        .stream()
                        .filter(map -> map.values().stream().anyMatch(value->value.contains(param)))
                        .collect(Collectors.toList());
            }

            List<Map<String,String>> newMapList=new ArrayList<>();
            if (StringUtil.isNotBlank(sdo.getString("wlfl1"))){//包含物料分类2
                newMapList = mapList
                        .stream()
                        .filter(map -> map.values().stream().anyMatch(value->value.contains(sdo.getString("wlfl1"))))
                        .collect(Collectors.toList());
            }
            List<Map<String,String>> newMapList2=new ArrayList<>();
            if (StringUtil.isNotBlank(sdo.getString("wlfl2"))){//包含物料分类2
                newMapList2 = mapList
                        .stream()
                        .filter(map -> map.values().stream().anyMatch(value->value.contains(sdo.getString("wlfl2"))))
                        .collect(Collectors.toList());
                newMapList.addAll(newMapList2);
            }

            if (StringUtil.isNotBlank(sdo.getString("noWlfl1"))){//排除物料分类1
                newMapList = mapList
                        .stream()
                        .filter(map -> map.values().stream().noneMatch(value->value.contains(sdo.getString("noWlfl1"))))
                        .collect(Collectors.toList());
            }
            if (StringUtil.isNotBlank(sdo.getString("noWlfl2"))){//排除物料分类2
                newMapList = newMapList
                        .stream()
                        .filter(map -> map.values().stream().noneMatch(value->value.contains(sdo.getString("noWlfl2"))))
                        .collect(Collectors.toList());
            }

            if (StringUtil.isNotBlank(sdo.getString("wlfl1"))||
                 StringUtil.isNotBlank(sdo.getString("noWlfl1"))){//排除物料分类1
                mapList=newMapList;
            }


        }

        Integer intPage = sdo.getInteger("intPage", 1);
        Integer pageSize = sdo.getInteger("pageSize",10);
        PageRequest pageRequest = new PageRequest(intPage - 1, pageSize);
        EasySearchParse easySearchParse = new EasySearchParse();
        List<QuerySchemeField> fields =
                Arrays.asList(
                        new QuerySchemeField("工厂", "WERKS", "string", 60L),
                        new QuerySchemeField("工厂名称", "NAME1", "string", 160L),
                        new QuerySchemeField("物料编码", "MATNR", "string", 140L),
                        new QuerySchemeField("物料名称", "MAKTX", "string", 200L),
                        new QuerySchemeField("物料分类", "MTART", "string", 100L),
                        new QuerySchemeField("物料分类描述", "MTBEZ", "string", 200L),
                        new QuerySchemeField("库存地点", "LGFSB", "string", 100L),
                        new QuerySchemeField("库存地点名称", "LGOBE", "string", 200L),
                        new QuerySchemeField("物料组", "MATKL", "string", 100L),
                        new QuerySchemeField("物料组名称", "WGBEZ", "string", 200L),
                        new QuerySchemeField("基本计量单位", "MEINS", "string", 100L),
                        new QuerySchemeField("基本计量单位名称", "MSEHL", "string", 100L),
                        new QuerySchemeField("采购组", "EKGRP", "string", 100L),
                        new QuerySchemeField("采购组名称", "EKNAM", "string", 200L),
                        new QuerySchemeField("价格基数", "PEINH", "string", 100L)
                );
        easySearchParse.setFields(fields);
        easySearchParse.setWidth(500L);
        MemEasySearcher<Map<String, String>> memEasySearcher = new MemEasySearcherImpl<>();
        Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null);
        return model;
    }

    @EasySearch(queryName = "sapMaterialSelect2")
    public Map<String, Object> sapMaterialSelect2(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String filterValue = sdo.getString("filterValue");
        String filterValue2 = sdo.getString("filterValue2");
        SapDialogQuery queryRequest = sdo.toObject(SapDialogQuery.class);
        queryRequest.setWerks(filterValue);
        List<Map<String,String>> mapList = sapMaterialApplication.getSapMaterial(queryRequest);
        queryRequest.setWerks(filterValue2);
        List<Map<String,String>> mapList2 = sapMaterialApplication.getSapMaterial(queryRequest);

        if (CollectionUtil.isNotEmpty(mapList)){
            if (StringUtil.isNotBlank(param)){//模糊条件过滤
                mapList = mapList
                        .stream()
                        .filter(map -> map.values().stream().anyMatch(value->value.contains(param)))
                        .collect(Collectors.toList());
            }
        }
        if (CollectionUtil.isNotEmpty(mapList2)){
            if (StringUtil.isNotBlank(param)){//模糊条件过滤
                mapList2 = mapList2
                        .stream()
                        .filter(map -> map.values().stream().anyMatch(value->value.contains(param)))
                        .collect(Collectors.toList());
            }
        }
        Set<String> matnrSet = mapList.stream().map(map -> {
            return map.get("MATNR");
        }).collect(Collectors.toSet());

        Set<String> matnrSet2 = mapList2.stream().map(map -> {
            return map.get("MATNR");
        }).collect(Collectors.toSet());

        List<String> collect = matnrSet.stream().filter(matnrSet2::contains).collect(Collectors.toList());

        mapList = mapList.stream().filter(map -> collect.contains(map.get("MATNR"))).collect(Collectors.toList());

        Integer intPage = sdo.getInteger("intPage", 1);
        Integer pageSize = sdo.getInteger("pageSize",10);
        PageRequest pageRequest = new PageRequest(intPage - 1, pageSize);
        EasySearchParse easySearchParse = new EasySearchParse();
        List<QuerySchemeField> fields =
                Arrays.asList(
                        //new QuerySchemeField("工厂", "WERKS", "string", 60L),
                        //new QuerySchemeField("工厂名称", "NAME1", "string", 160L),
                        new QuerySchemeField("物料编码", "MATNR", "string", 140L),
                        new QuerySchemeField("物料名称", "MAKTX", "string", 200L),
                        new QuerySchemeField("物料分类", "MTART", "string", 100L),
                        new QuerySchemeField("物料分类描述", "MTBEZ", "string", 200L),
                        new QuerySchemeField("库存地点", "LGFSB", "string", 100L),
                        new QuerySchemeField("库存地点名称", "LGOBE", "string", 200L),
                        new QuerySchemeField("物料组", "MATKL", "string", 100L),
                        new QuerySchemeField("物料组名称", "WGBEZ", "string", 200L),
                        new QuerySchemeField("基本计量单位", "MEINS", "string", 100L),
                        new QuerySchemeField("基本计量单位名称", "MSEHL", "string", 100L),
                        new QuerySchemeField("采购组", "EKGRP", "string", 100L),
                        new QuerySchemeField("采购组名称", "EKNAM", "string", 200L),
                        new QuerySchemeField("价格基数", "PEINH", "string", 100L)
                );
        easySearchParse.setFields(fields);
        easySearchParse.setWidth(500L);
        MemEasySearcher<Map<String, String>> memEasySearcher = new MemEasySearcherImpl<>();
        Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null);
        return model;
    }

     @EasySearch(queryName = "sapCustomerOrderSelect")
    public Map<String, Object> sapCustomerOrderSelect(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        SapDialogOrderQuery queryRequest = sdo.toObject(SapDialogOrderQuery.class);
        List  <Map<String,String>>mapList = sapMaterialApplication.getSapCustomerOrder(queryRequest);

//        if (CollectionUtil.isNotEmpty(mapList)){
//            if (StringUtil.isNotBlank(param)){//固定条件过滤，
//                mapList = mapList
//                        .stream()
//                        .filter(map -> map.values().stream().anyMatch(value->value.contains(param)))
//                        .collect(Collectors.toList());
//            }
//        }

         Integer intPage = sdo.getInteger("intPage", 1);
         Integer pageSize = sdo.getInteger("pageSize",10);
        PageRequest pageRequest = new PageRequest(intPage - 1, pageSize);
        EasySearchParse easySearchParse = new EasySearchParse();
         List<QuerySchemeField> fields =new ArrayList<>();
        if ("2".equals(queryRequest.getReasonType())){ //生产异常
             fields =
                    Arrays.asList(
                            new QuerySchemeField("订单号", "VBELN", "string", 150L),
                           // new QuerySchemeField("订单描述", "KTEXT", "string", 160L),
                            new QuerySchemeField("物料编码", "MATNR", "string", 160L),
                            new QuerySchemeField("物料描述", "MAKTX", "string", 160L),
                            new QuerySchemeField("数量", "PSMNG", "string", 100L),
                            new QuerySchemeField("单位", "MEINS", "string", 100L)
                    );
        } else {
            fields =
                    Arrays.asList(
                            new QuerySchemeField("订单号", "VBELN", "string", 130L),
                            new QuerySchemeField("客户编号", "KUNNR", "string", 60L),
                            new QuerySchemeField("客户名称", "NAME1", "string", 150L)
                    );
        }
        easySearchParse.setFields(fields);
        easySearchParse.setWidth(500L);
        MemEasySearcher<Map<String, String>> memEasySearcher = new MemEasySearcherImpl<>();
        Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null);
        return model;
    }

    @EasySearch(queryName = "sapCustomerProduceNo")
    public Map<String, Object> sapCustomerProduceNo(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        SapDialogOrderQuery queryRequest = sdo.toObject(SapDialogOrderQuery.class);
        List  <Map<String,String>>mapList = sapMaterialApplication.getSapCustomerOrder(queryRequest);

        Integer intPage = sdo.getInteger("intPage", 1);
        Integer pageSize = sdo.getInteger("pageSize",10);
        PageRequest pageRequest = new PageRequest(intPage - 1, pageSize);
        EasySearchParse easySearchParse = new EasySearchParse();
        List<QuerySchemeField> fields =
                Arrays.asList(
                        new QuerySchemeField("生产单号", "AUFNR", "string", 140L),
                        new QuerySchemeField("物料编码", "MATNR", "string", 140L),
                        new QuerySchemeField("物料名称", "MAKTX", "string", 200L),
                        new QuerySchemeField("数量", "PSMNG", "string", 100L),

                        new QuerySchemeField("单位", "MEINS", "string", 100L),
                        new QuerySchemeField("币别", "KOEIN", "string", 100L),
                        new QuerySchemeField("金额", "KWERT", "string", 200L),
                        new QuerySchemeField("出货日期", "LFDAT", "string", 100L)

                );
        easySearchParse.setFields(fields);
        easySearchParse.setWidth(500L);
        MemEasySearcher<Map<String, String>> memEasySearcher = new MemEasySearcherImpl<>();
        Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null);
        return model;
    }

    @EasySearch(queryName = "dictionarySelect")
    public Map<String, Object> dictionarySelect(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String filterValue = sdo.getString("filterValue");
        String fieldName = sdo.getString("fieldName");
        String []displayName=sdo.getString("displayNames").split(",");
        String []displayLen=sdo.getString("displayLens").split(",");
      //  SapDialogQuery queryRequest = sdo.toObject(SapDialogQuery.class);
      //  queryRequest.setWerks(filterValue);
        Map maps = dictionaryApplication.querySysDictionaryDetailsByCode(fieldName);
        ObjectMapper objectMapper = SAPUtils.objectMapper();
        List<Map<String,String>> mapList = objectMapper.readValue(JSONUtil.toString(maps.get("Rows")), new TypeReference<List<Map<String, String>>>() {});

        if (CollectionUtil.isNotEmpty(mapList)){
            if (StringUtil.isNotBlank(filterValue)){//固定条件过滤，比如选了工厂后，只能读取改工厂下的物料组
                mapList = mapList
                        .stream()
                        .filter(map -> map.containsValue(filterValue))
                        .collect(Collectors.toList());
            }
        }
        if (CollectionUtil.isNotEmpty(mapList)){
            if (StringUtil.isNotBlank(param)){//模糊条件过滤
                mapList = mapList
                        .stream()
                        .filter(map -> map.values().stream().anyMatch(value->value.contains(param)))
                        .collect(Collectors.toList());
            }
        }
        Integer intPage = sdo.getInteger("intPage", 1);
        Integer pageSize = sdo.getInteger("pageSize",10);
        PageRequest pageRequest = new PageRequest(intPage - 1, pageSize);
        EasySearchParse easySearchParse = new EasySearchParse();
        List<QuerySchemeField> fields=new ArrayList<>();
          fields.add(new QuerySchemeField(displayName[0], "name", "string", Long.valueOf(displayLen[0])));
        if (displayName.length>1){
            fields.add(new QuerySchemeField(displayName[1], "value", "string", Long.valueOf(displayLen[1])));
        } else {
            fields.add(new QuerySchemeField("", "value", "hidden", 0L));
        }

        Long widths=0L;
       for (int u=0;u<displayLen.length;u++){
           widths+=Long.valueOf(displayLen[u]);
       }
        easySearchParse.setFields(fields);
        easySearchParse.setWidth(widths);
        MemEasySearcher<Map<String, String>> memEasySearcher = new MemEasySearcherImpl<>();
        Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null);
        return model;
    }

    @EasySearch(queryName = "dictionary")
    public Map<String, Object> queryDictionary(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String fieldName = sdo.getString("fieldName");
        String filterValue = sdo.getString("filterValue");
        String noContain = sdo.getString("noContain");
        String notNull = sdo.getString("notNull");
        List<Map<String, String>> mapList = new ArrayList<>();
        if ("AUFNR".equals(fieldName)){
            mapList = sapDictionaryApplication.getSapDictionary(fieldName,param);
        }else {
            mapList = sapDictionaryApplication.getSapDictionary(fieldName);
        }
        List<QuerySchemeField> fields = new ArrayList<>();
        Long totalWidths=200L;
        if (CollectionUtil.isNotEmpty(mapList)){
            if (StringUtil.isNotBlank(filterValue)){//固定条件过滤，比如选了工厂后，只能读取改工厂下的物料组
                String[] split = filterValue.split(",");
                for (String s : split) {
                    mapList = mapList
                            .stream()
                            .filter(map -> map.values().stream().anyMatch(value->value.contains(s)))
                            //.filter(map -> map.containsValue(filterValue))
                            .collect(Collectors.toList());
                }
            }
            if (StringUtil.isNotBlank(noContain)){//固定条件过滤，不包含
                String[] split = noContain.split(",");
                for (String s : split) {
                    mapList = mapList
                            .stream()
                            .filter(map -> map.values().stream().noneMatch(value->value.contains(s)))
                            //.filter(map -> map.containsValue(filterValue))
                            .collect(Collectors.toList());
                }
            }
            if (StringUtil.isNotBlank(param)){//输入查询条件过滤
                mapList = mapList
                        .stream()
                        .filter(map -> map.values().stream().anyMatch(value->value.contains(param)))
                        .collect(Collectors.toList());
            }
            if (StringUtil.isNotBlank(notNull)){//某个字段的值不为空
                mapList = mapList
                        .stream()
                        .filter(map -> StringUtil.isNotBlank((String)map.get(notNull)))
                        .collect(Collectors.toList());
            }

            if (!CollectionUtils.isEmpty(mapList)){
                Map<String, String> map = mapList.get(0);
                String []widths=sapDictionaryApplication.getWidths(mapList);
                for (int y=0;y<widths.length;y++){
                    totalWidths+=Long.valueOf(widths[y]);
                }

                int x=0;
                for (String key : map.keySet()) {
                    QuerySchemeField querySchemeField = new QuerySchemeField(key,key,"string",Long.valueOf(widths[x]));
                    fields.add(querySchemeField);
                    x++;
                }
            }
        }

        System.out.println("数据条数："+ mapList.size());
        String string = JSONUtil.toString(mapList);
        Integer intPage = sdo.getInteger("intPage", 1);
        Integer pageSize = sdo.getInteger("pageSize",10);
        PageRequest pageRequest = new PageRequest(intPage - 1, pageSize);
        EasySearchParse easySearchParse = new EasySearchParse();
        easySearchParse.setFields(fields);
        easySearchParse.setWidth(totalWidths);
        MemEasySearcher<Map<String, String>> memEasySearcher = new MemEasySearcherImpl<>();
        Map<String, Object> model = memEasySearcher.search(mapList, easySearchParse, pageRequest, null);
        return model;
    }

    @EasySearch(queryName = "getCusAndSuppliers")
    public Map<String, Object> getCusAndSuppliers(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String BUKRS = sdo.getString("BUKRS");
        String ZEP_BPTYPE = sdo.getString("ZEP_BPTYPE");
        List<Map<String, String>> mapList = new ArrayList<>();
        mapList = sapPaymentApplication.getCusAndSuppliers(BUKRS,ZEP_BPTYPE);
        return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
    }

    @EasySearch(queryName = "getCusAndBanks")
    public Map<String, Object> getCusAndBanks(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String PARTNER = sdo.getString("PARTNER");
        String ZEP_BPTYPE = sdo.getString("ZEP_BPTYPE");
        List<Map<String, String>> mapList = new ArrayList<>();
        mapList = sapPaymentApplication.getCusAndBanks(PARTNER,ZEP_BPTYPE);
        return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
    }

    @EasySearch(queryName = "getCompanyAndBankInfos")
    public Map<String, Object> getCompanyAndBankInfos(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String BUKRS = sdo.getString("BUKRS");
        List<Map<String, String>> mapList = new ArrayList<>();
        mapList = sapPaymentApplication.getCompanyAndBankInfos(BUKRS);
        return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
    }

    @EasySearch(queryName = "getCompanyOrders")
    public Map<String, Object> getCompanyOrders(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String BUKRS = sdo.getString("BUKRS");
        List<Map<String, String>> mapList = new ArrayList<>();
        mapList = sapPaymentApplication.getCompanyOrders(BUKRS);
        return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
    }

    @EasySearch(queryName = "getPurchaseOrders")
    public Map<String, Object> getPurchaseOrders(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String BUKRS = sdo.getString("BUKRS");
        String PARTNER = sdo.getString("PARTNER");
        String ZEP_FTYPE = sdo.getString("ZEP_FTYPE");
        List<Map<String, String>> mapList = new ArrayList<>();
        mapList = sapPaymentApplication.getPurchaseOrders(BUKRS,PARTNER,ZEP_FTYPE);
        return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
    }

    @EasySearch(queryName = "getPartnerInvs")
    public Map<String, Object> getPartnerInvs(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String BUKRS = sdo.getString("BUKRS");
        String PARTNER = sdo.getString("PARTNER");
        String ZYL03 = sdo.getString("ZYL03");
        String ZEP_FTYPE = sdo.getString("ZEP_FTYPE");
        List<Map<String, String>> mapList = new ArrayList<>();
        mapList = sapPaymentApplication.getPartnerInvs(BUKRS,PARTNER,ZEP_FTYPE,ZYL03);
        return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
    }

    @EasySearch(queryName = "getArea")
    public Map<String, Object> getArea(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String LAND1 = sdo.getString("LAND1");
        List<Map<String, String>> mapList = new ArrayList<>();
        mapList = sapAreaApplication.getAreas(LAND1);
        return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
    }

    @EasySearch(queryName = "getBankInfo")
    public Map<String, Object> getBankInfo(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String BANKS = sdo.getString("BANKS");
        String noContain = sdo.getString("noContain");
        List<Map<String, String>> mapList = new ArrayList<>();
        mapList = sapBankInfoApplication.getBankInfo(BANKS);
        if (StringUtil.isNotBlank(noContain)){//固定条件过滤，不包含
            String[] split = noContain.split(",");
            for (String s : split) {
                mapList = mapList
                        .stream()
                        .filter(map -> map.values().stream().noneMatch(value->value.contains(s)))
                        .collect(Collectors.toList());
            }
        }
        return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
    }

    @EasySearch(queryName = "selectSuppliersDatas")
    public Map<String, Object> getSuppliersDatas(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String PARTNER = sdo.getString("PARTNER");
      //  String ZEP_BPTYPE = sdo.getString("ZEP_BPTYPE");
        List<Map<String, String>> mapList = new ArrayList<>();
        mapList = suppliersDataApplication.selectSuppliersDatas(PARTNER);
        return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
    }

}
