/*
 * Copyright [2022] [https://www.xiaonuo.vip]
 *
 * Snowy采用APACHE LICENSE 2.0开源协议，您在使用过程中，需要注意以下几点：
 *
 * 1.请不要删除和修改根目录下的LICENSE文件。
 * 2.请不要删除和修改Snowy源码头部的版权声明。
 * 3.本项目代码可免费商业使用，商业使用请保留源码和相关描述文件的项目出处，作者声明等。
 * 4.分发源码时候，请注明软件出处 https://www.xiaonuo.vip
 * 5.不可二次分发开源参与同类竞品，如有想法可联系团队xiaonuobase@qq.com商议合作。
 * 6.若您的项目无法满足以上几点，需要更多功能代码，获取Snowy商业授权许可，请在官网购买授权，地址为 https://www.xiaonuo.vip
 */
package com.unis.emergencySupport.modular.es.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollStreamUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.unis.biz.modular.dict.entity.BizDict;
import com.unis.emergencySupport.modular.es.entity.EsDeliveryEnterpriseGrain;
import com.unis.emergencySupport.modular.es.entity.EsNetworkEntry;
import com.unis.emergencySupport.modular.es.entity.EsNetworkEntryGrain;
import com.unis.emergencySupport.modular.es.entity.vo.EsDeliveryEnterpriseCountVO;
import com.unis.emergencySupport.modular.es.param.*;
import com.unis.emergencySupport.modular.es.service.EsDeliveryEnterpriseGrainService;
import com.unis.emergencySupport.modular.esstorageenterprise.util.FileImport;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.Chronology;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.unis.common.exception.CommonException;
import com.unis.emergencySupport.modular.es.entity.EsDeliveryEnterprise;
import com.unis.emergencySupport.modular.es.mapper.EsDeliveryEnterpriseMapper;
import com.unis.emergencySupport.modular.es.service.EsDeliveryEnterpriseService;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 应急保障-应急配送企业管理表Service接口实现类
 *
 * @author ZeroLiYi
 * @date  2024/06/01 11:37
 **/
@Service
public class EsDeliveryEnterpriseServiceImpl extends ServiceImpl<EsDeliveryEnterpriseMapper, EsDeliveryEnterprise> implements EsDeliveryEnterpriseService {

    @Resource
    private com.unis.biz.modular.dict.service.impl.BizDictServiceImpl BizDictServiceImpl;

    @Resource
    private EsDeliveryEnterpriseMapper esDeliveryEnterpriseMapper;


    @Resource
    private EsDeliveryEnterpriseGrainService esDeliveryEnterpriseGrainService;
    @Override
    public Page<EsDeliveryEnterprise> page(EsDeliveryEnterprisePageParam esDeliveryEnterprisePageParam) {
        //条形查询器
        QueryWrapper<EsDeliveryEnterprise> queryWrapper = new QueryWrapper<>();
        //分页相关
        if(StringUtils.isNotBlank(esDeliveryEnterprisePageParam.getEnterpriseName())){//名称
            queryWrapper.like("enterprise_name",esDeliveryEnterprisePageParam.getEnterpriseName());
        }
        if(StringUtils.isNotBlank(esDeliveryEnterprisePageParam.getCityState())){//市州
            queryWrapper.eq("city_state",esDeliveryEnterprisePageParam.getCityState());
        }
        if(StringUtils.isNotBlank(esDeliveryEnterprisePageParam.getEmergencyCategory())){//分类
            queryWrapper.eq("emergency_category",esDeliveryEnterprisePageParam.getEmergencyCategory());
        }
        if(StringUtils.isNotBlank(esDeliveryEnterprisePageParam.getManagementAreaCounty())){
            queryWrapper.like("management_area_county",esDeliveryEnterprisePageParam.getManagementAreaCounty());
        }
        Page<EsDeliveryEnterprise> p =new Page<>(esDeliveryEnterprisePageParam.getCurrent(),esDeliveryEnterprisePageParam.getSize());

        return   this.page(p,queryWrapper);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void add(EsDeliveryEnterpriseAddParam esDeliveryEnterpriseAddParam) {
        EsDeliveryEnterprise esDeliveryEnterprise = BeanUtil.toBean(esDeliveryEnterpriseAddParam, EsDeliveryEnterprise.class);
            List<EsDeliveryEnterpriseGrainAddParam> esNetworkEntryGrainAddParam= esDeliveryEnterpriseAddParam.getEsDeliveryEnterpriseGrainAddParamList();
            if(esDeliveryEnterpriseAddParam.getId()==null){//添加

                this.save(esDeliveryEnterprise);

                if(esNetworkEntryGrainAddParam!=null){ //有数据

                    for (EsDeliveryEnterpriseGrainAddParam addparam:esNetworkEntryGrainAddParam) {
                        addparam.setEsDeliveryEnterpriseId(esDeliveryEnterprise.getId());
                        esDeliveryEnterpriseGrainService.add(addparam);
                    }

                }
            }else{//修改
                //修改主表数据
                this.updateById(esDeliveryEnterprise);
                if(esNetworkEntryGrainAddParam!=null){ //有数据

                    for (EsDeliveryEnterpriseGrainAddParam addparam:esNetworkEntryGrainAddParam) {
                        if(addparam.getId()!=null){
                            esDeliveryEnterpriseGrainService.removeById(addparam.getId());
                        }
                        addparam.setEsDeliveryEnterpriseId(esDeliveryEnterprise.getId());
                        esDeliveryEnterpriseGrainService.add(addparam);
                    }

                }

            }


        }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void edit(EsDeliveryEnterpriseEditParam esDeliveryEnterpriseEditParam) {
        EsDeliveryEnterprise esDeliveryEnterprise = this.queryEntity(esDeliveryEnterpriseEditParam.getId());
        BeanUtil.copyProperties(esDeliveryEnterpriseEditParam, esDeliveryEnterprise);
        this.updateById(esDeliveryEnterprise);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void delete(List<EsDeliveryEnterpriseIdParam> esDeliveryEnterpriseIdParamList) {

        for (EsDeliveryEnterpriseIdParam enid:esDeliveryEnterpriseIdParamList
        ) {
            QueryWrapper<EsDeliveryEnterpriseGrain> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("es_delivery_enterprise_id",enid.getId());
            esDeliveryEnterpriseGrainService.remove(queryWrapper);
        }

        // 执行删除
        this.removeByIds(CollStreamUtil.toList(esDeliveryEnterpriseIdParamList, EsDeliveryEnterpriseIdParam::getId));
    }

    @Override
    public EsDeliveryEnterprise detail(EsDeliveryEnterpriseIdParam esDeliveryEnterpriseIdParam) {
        EsDeliveryEnterprise esNetworkEntry =this.queryEntity(esDeliveryEnterpriseIdParam.getId());


        QueryWrapper<EsDeliveryEnterpriseGrain> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("es_delivery_enterprise_id",esDeliveryEnterpriseIdParam.getId());
        List<EsDeliveryEnterpriseGrain> esNetworkEntryGrains = esDeliveryEnterpriseGrainService.list(queryWrapper);
        if(esNetworkEntryGrains!=null){
            esNetworkEntry.setEsDeliveryEnterpriseGrainList(esNetworkEntryGrains);
        }
        return esNetworkEntry;
    }

    @Override
    public EsDeliveryEnterprise queryEntity(String id) {
        EsDeliveryEnterprise esDeliveryEnterprise = this.getById(id);
        if(ObjectUtil.isEmpty(esDeliveryEnterprise)) {
            throw new CommonException("应急保障-应急配送企业管理表不存在，id值为：{}", id);
        }
        return esDeliveryEnterprise;
    }

    @Override
    public List<EsDeliveryEnterpriseCountVO> selectCount(EsDeliveryEnterpriseCountParam esDeliveryEnterpriseCountParam) {
        List<EsDeliveryEnterpriseCountVO> esNetworkEntryCountVOList=new ArrayList<>();
        if(esDeliveryEnterpriseCountParam.getManagementAreaCity()!=null &&!esDeliveryEnterpriseCountParam.getManagementAreaCity().isEmpty()){//市
            esNetworkEntryCountVOList.addAll(esDeliveryEnterpriseMapper.selectCityCount(esDeliveryEnterpriseCountParam));
            esNetworkEntryCountVOList.addAll(esDeliveryEnterpriseMapper.selectCountyCount(esDeliveryEnterpriseCountParam));
        }
        else{

            esNetworkEntryCountVOList.addAll(esDeliveryEnterpriseMapper.selectProvinceCount(esDeliveryEnterpriseCountParam));
            esNetworkEntryCountVOList.addAll(esDeliveryEnterpriseMapper.selectCityCount(esDeliveryEnterpriseCountParam));
        }


        return esNetworkEntryCountVOList;
    }

    @Override
    public Map<String, Object> importByEntityResult(MultipartFile file, Map<String, Object> map) throws IOException {
        BigDecimal quantity=new BigDecimal(0.00);
        Integer in =0;
        Integer index = 6;
        List<String[]> list = FileImport.importByFile(file, index);
        if (list.size() > 0) {
            int res = 0;
            int insertNum = 0;
            int updateNum = 0;
            int skipNum = 0;
            int failNum = 0;
            int size = list.size();
            for (String[] strings : list) {

                /*
                 * 判断是否为整数
                 * 判断第一列是否是 数字 不是跳过
                 */
                String str = strings[0].toString();
                if (!str.matches("^[-\\+]?[\\d]*$")){
                    continue;
                }

                if (strings[13] != null && strings[13] != "" && strings[12] != null && strings[12] != "") {

                    /**
                     * 查询是否存在此条数据
                     * 根据企业名称和社会信用代码
                     */
                    QueryWrapper<EsDeliveryEnterprise> queryWrapper = new QueryWrapper<>();
                    queryWrapper.eq("enterprise_name", strings[12]);
                    queryWrapper.eq("credit_code", strings[13]);
                    List<EsDeliveryEnterprise> mainList = this.list(queryWrapper);

                    if (mainList.size() > 0) {
                        //修改
                        this.importUpdate(strings,mainList,updateNum,res,failNum);
                    } else if(mainList.size() ==0){
                        EsDeliveryEnterprise EsNetworkEntry = new EsDeliveryEnterprise();
                        //新增

                        QueryWrapper<BizDict> queryWrapper1 = new QueryWrapper<>();
                        queryWrapper1.eq("DICT_LABEL",strings[1]);
                        List<BizDict> list1 = BizDictServiceImpl.list(queryWrapper1);
                        if(list1.isEmpty()){
                            throw new IndexOutOfBoundsException(strings[1]+"不是正确的");
                        }
                        EsNetworkEntry.setManagementAreaProvince(list1.get(0).getId());//归口管理地区-省

                        QueryWrapper<BizDict> queryWrapper2 = new QueryWrapper<>();
                        queryWrapper2.eq("DICT_LABEL",strings[2]);
                        List<BizDict> list2 = BizDictServiceImpl.list(queryWrapper2);
                        if(list2.isEmpty()){
                            throw new IndexOutOfBoundsException(strings[2]+"不是正确的");
                        }
                        EsNetworkEntry.setManagementAreaCity(list2.get(0).getId());//归口管理地区-市

                        QueryWrapper<BizDict> queryWrapper3 = new QueryWrapper<>();
                        queryWrapper3.eq("DICT_LABEL",strings[3]);
                        List<BizDict> list3 = BizDictServiceImpl.list(queryWrapper3);
                        if(list3.isEmpty()){
                            throw new IndexOutOfBoundsException(strings[3]+"不是正确的");
                        }
                        EsNetworkEntry.setManagementAreaCounty(list3.get(0).getId());//归口管理地区-县


                        QueryWrapper<BizDict> queryWrapper4 = new QueryWrapper<>();
                        queryWrapper4.eq("DICT_LABEL",strings[4]);
                        List<BizDict> list4 = BizDictServiceImpl.list(queryWrapper4);
                        if(list4.isEmpty()){
                            throw new IndexOutOfBoundsException(strings[4]+"不是正确的");
                        }
                        EsNetworkEntry.setActualAddressProvince(list4.get(0).getId());//实际经营地址-省

                        QueryWrapper<BizDict> queryWrapper5 = new QueryWrapper<>();
                        queryWrapper5.eq("DICT_LABEL",strings[5]);
                        List<BizDict> list5 = BizDictServiceImpl.list(queryWrapper5);
                        if(list5.isEmpty()){
                            throw new IndexOutOfBoundsException(strings[5]+"不是正确的");
                        }
                        EsNetworkEntry.setActualAddressCity(list5.get(0).getId());//实际经营地址-市

                        QueryWrapper<BizDict> queryWrapper6 = new QueryWrapper<>();
                        queryWrapper6.eq("DICT_LABEL",strings[6]);
                        List<BizDict> list6 = BizDictServiceImpl.list(queryWrapper6);
                        if(list6.isEmpty()){
                            throw new IndexOutOfBoundsException(strings[6]+"不是正确的");
                        }
                        EsNetworkEntry.setActualAddressCounty(list6.get(0).getId());//实际经营地址-县


                        if(strings[7] != null && strings[7] != ""){
                            EsNetworkEntry.setIsNationalLevel(1);//供应应急级别-是否国家级，0：否；1：是
                        }else{
                            EsNetworkEntry.setIsNationalLevel(0);//供应应急级别-是否国家级，0：否；1：是
                        }
                        if(strings[8] != null && strings[8] != ""){
                            EsNetworkEntry.setIsProvincialLevel(1);//供应应急级别-是否省级，0：否；1：是
                        }else{
                            EsNetworkEntry.setIsProvincialLevel(0);//供应应急级别-是否省级，0：否；1：是
                        }

                        if(strings[9] != null && strings[9] != ""){
                            EsNetworkEntry.setIsCityLevel(1);//供应应急级别-是否市级，0：否；1：是
                        }else{
                            EsNetworkEntry.setIsCityLevel(0);//供应应急级别-是否市级，0：否；1：是
                        }

                        if(strings[10] != null && strings[10] != ""){
                            EsNetworkEntry.setIsCountyLevel(1);//供应应急级别-是否县级，0：否；1：是
                        }else{
                            EsNetworkEntry.setIsCountyLevel(0);//供应应急级别-是否县级，0：否；1：是
                        }


                        EsNetworkEntry.setHeadquarterCreditCode(strings[11]);//所属总公司企业信用代码
                        EsNetworkEntry.setEnterpriseName(strings[12]);//企业名称
                        //EsNetworkEntry.setCreditCode(strings[13]);//统一社会信用代码
                        if (strings[13] != null && strings[13].length() > 18) {
                            throw new IllegalArgumentException(strings[13]+"统一社会信用代码长度不能超过18位");
                        } else {
                            EsNetworkEntry.setCreditCode(strings[13]);//统一社会信用代码
                        }
                        EsNetworkEntry.setActualBusinessAddress(strings[14]);//实际经营地址（省、市、县、乡镇街道门牌号）

                        QueryWrapper<BizDict> queryWrapper7 = new QueryWrapper<>();
                        queryWrapper7.eq("DICT_LABEL",strings[15].trim());
                        List<BizDict> list7 = BizDictServiceImpl.list(queryWrapper7);
                        EsNetworkEntry.setEnterpriseNature(strings[15]);//企业性质
                        QueryWrapper<BizDict> queryWrapper8 = new QueryWrapper<>();
                        queryWrapper8.eq("DICT_LABEL",strings[16]);
                        List<BizDict> list8 = BizDictServiceImpl.list(queryWrapper8);
                        EsNetworkEntry.setEnterpriseType(strings[16]);//企业类型


                        if (strings[17] != null) {
                            try {
                                BigDecimal longitude = new BigDecimal(strings[17]);
                                // 进行后续的处理
                                EsNetworkEntry.setLongitude(longitude);
                            } catch (NumberFormatException e) {
                                throw new NumberFormatException(strings[17] + " 经度格式不正确");
                            }
                        }


                        if (strings[18] != null) {
                            try {
                                BigDecimal latitude = new BigDecimal(strings[18]);
                                // 进行后续的处理
                                EsNetworkEntry.setLatitude(latitude);
                            } catch (NumberFormatException e) {
                                throw new NumberFormatException(strings[18] + " 纬度格式不正确");
                            }
                        }


                        EsNetworkEntry.setLegalRepresentative(strings[19]);//法人姓名
                        EsNetworkEntry.setLegalContact(strings[20]);//法人联系方式
                        EsNetworkEntry.setEnterpriseContact(strings[21]);//联系人姓名
                        EsNetworkEntry.setContactNumber(strings[22]);//联系电话
                        if(strings[41] != null && strings[41] != "") {
                            if(strings[41]!=null&&!strings[41].isEmpty()){
                                quantity=new BigDecimal(strings[41]);
                            }
                            EsNetworkEntry.setDailyDeliveryCapacity(quantity);
                        }
                        if(strings[51] != null && strings[51] != "") {//原粮库房仓容
                            if(strings[51]!=null&&!strings[51].isEmpty()){
                                quantity=new BigDecimal(strings[51]);
                            }
                            EsNetworkEntry.setGrainWarehouseCapacity(quantity);
                        }
                        if(strings[52] != null && strings[52] != "") {//原粮油罐罐容
                            if(strings[52]!=null&&!strings[52].isEmpty()){
                                quantity=new BigDecimal(strings[52]);
                            }
                            EsNetworkEntry.setVegetableOilTankCapacity(quantity);
                        }
                        if(strings[53] != null && strings[53] != "") {//成品粮库房仓容
                            if(strings[53]!=null&&!strings[53].isEmpty()){
                                quantity=new BigDecimal(strings[53]);
                            }
                            EsNetworkEntry.setFinishedGrainWarehouseCapacity(quantity);
                        }
                        if(strings[54] != null && strings[54] != "") {//成品粮油罐罐容
                            if(strings[54]!=null&&!strings[54].isEmpty()){
                                quantity=new BigDecimal(strings[54]);
                            }
                            EsNetworkEntry.setFinishedOilTankCapacity(quantity);
                        }
                        if(strings[55] != null && strings[55] != "") {//自有运输车辆数
                            if(strings[55]!=null&&!strings[55].isEmpty()){
                                in=Integer.parseInt(strings[55]);
                            }
                            EsNetworkEntry.setOwnTransportVehicles(in);
                        }
                        if(strings[56] != null && strings[56] != "") {//自有车辆日配送能力（吨）
                            if(strings[56]!=null&&!strings[56].isEmpty()){
                                quantity=new BigDecimal(strings[56]);
                            }
                            EsNetworkEntry.setOwnVehiclesDailyDeliveryCapacity(quantity);
                        }

                        EsNetworkEntry.setOwnTransportCapacity(new BigDecimal(0.00));
                        if(strings[57] != null && strings[57] != "") {//日配送能力
                            if(strings[57]!=null&&!strings[57].isEmpty()){
                                quantity=new BigDecimal(strings[57]);
                            }
                            EsNetworkEntry.setOwnVehiclesDailyDeliveryCapacity(quantity);
                        }
                        if(strings[58] != null && strings[58] != "") {//辐射范围（省/市/县）
                            EsNetworkEntry.setRadiationRange(strings[58]);
                        }

                        if(strings[59] != null && strings[59] != ""){
                            if(strings[59].equals("生产")){
                                EsNetworkEntry.setProductionStatus(1);//生产状态，0：停产；1：生产
                            }else{
                                EsNetworkEntry.setProductionStatus(0);//生产状态，0：停产；1：生产
                            }
                        }
                        EsNetworkEntry.setCityState(strings[5].trim());
                        this.save(EsNetworkEntry);
                        /**
                         * 小麦原粮
                         */

                        if((strings[23] != null && strings[23] != "") || (strings[32] != null && strings[32] != "") || (strings[42] != null && strings[42] != "")){
                            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
                            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
                            EsNetworkEntryGrain.setGrainVariety(1);//粮食品种 1：小麦粉成品粮
                            if(strings[23] != null && strings[23] != ""){
                                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                                if(strings[23]!=null&&!strings[23].isEmpty()){
                                    quantity=new BigDecimal(strings[23]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[32] != null && strings[32] != ""){
                                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                                if(strings[32]!=null&&!strings[32].isEmpty()){
                                    quantity=new BigDecimal(strings[32]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[42] != null && strings[42] != ""){
                                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                                if(strings[42]!=null&&!strings[42].isEmpty()){
                                    quantity=new BigDecimal(strings[42]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);//数量
                            }

                            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
                        }
                        /**
                         * 稻谷原粮
                         */
                        if((strings[24] != null && strings[24] != "") || (strings[33] != null && strings[33] != "") || (strings[43] != null && strings[43] != "")){
                            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
                            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
                            EsNetworkEntryGrain.setGrainVariety(2);//粮食品种 稻谷原粮
                            if(strings[24] != null && strings[24] != ""){
                                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                                if(strings[24]!=null&&!strings[24].isEmpty()){
                                    quantity=new BigDecimal(strings[24]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[33] != null && strings[33] != ""){
                                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                                if(strings[33]!=null&&!strings[33].isEmpty()){
                                    quantity=new BigDecimal(strings[33]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[43] != null && strings[43] != ""){
                                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                                if(strings[43]!=null&&!strings[43].isEmpty()){
                                    quantity=new BigDecimal(strings[43]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);//数量
                            }

                            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
                        }
                        /**
                         * 大豆原粮
                         */
                        if((strings[25] != null && strings[25] != "") || (strings[34] != null && strings[34] != "") || (strings[44] != null && strings[44] != "")){
                            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
                            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
                            EsNetworkEntryGrain.setGrainVariety(3);//粮食品种 大豆原粮
                            if(strings[25] != null && strings[25] != ""){
                                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                                if(strings[25]!=null&&!strings[25].isEmpty()){
                                    quantity=new BigDecimal(strings[25]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[34] != null && strings[34] != ""){
                                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                                if(strings[34]!=null&&!strings[34].isEmpty()){
                                    quantity=new BigDecimal(strings[34]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[44] != null && strings[44] != ""){
                                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                                if(strings[44]!=null&&!strings[44].isEmpty()){
                                    quantity=new BigDecimal(strings[44]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);//数量
                            }

                            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
                        }
                        /**
                         * 玉米原粮
                         */
                        if((strings[26] != null && strings[26] != "") || (strings[35] != null && strings[35] != "") || (strings[45] != null && strings[45] != "")){
                            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
                            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
                            EsNetworkEntryGrain.setGrainVariety(4);//粮食品种 玉米原粮
                            if(strings[26] != null && strings[26] != ""){
                                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                                if(strings[26]!=null&&!strings[26].isEmpty()){
                                    quantity=new BigDecimal(strings[26]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[35] != null && strings[35] != ""){
                                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                                if(strings[35]!=null&&!strings[35].isEmpty()){
                                    quantity=new BigDecimal(strings[35]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[45] != null && strings[45] != ""){
                                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                                if(strings[45]!=null&&!strings[45].isEmpty()){
                                    quantity=new BigDecimal(strings[45]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);//数量
                            }

                            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
                        }
                        /**
                         * 其他原粮
                         */
                        if((strings[27] != null && strings[27] != "") || (strings[36] != null && strings[36] != "") || (strings[46] != null && strings[46] != "")){
                            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
                            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
                            EsNetworkEntryGrain.setGrainVariety(5);//粮食品种 其他原粮
                            if(strings[27] != null && strings[27] != ""){
                                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                                if(strings[27]!=null&&!strings[27].isEmpty()){
                                    quantity=new BigDecimal(strings[27]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[36] != null && strings[36] != ""){
                                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                                if(strings[36]!=null&&!strings[36].isEmpty()){
                                    quantity=new BigDecimal(strings[36]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[46] != null && strings[46] != ""){
                                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                                if(strings[46]!=null&&!strings[46].isEmpty()){
                                    quantity=new BigDecimal(strings[46]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);//数量
                            }

                            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
                        }
                        /**
                         * 小麦粉成品粮
                         */
                        if((strings[28] != null && strings[28] != "") || (strings[37] != null && strings[37] != "") || (strings[47] != null && strings[47] != "")){
                            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
                            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
                            EsNetworkEntryGrain.setGrainVariety(6);//粮食品种 小麦粉成品粮
                            if(strings[28] != null && strings[28] != ""){
                                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                                if(strings[28]!=null&&!strings[28].isEmpty()){
                                    quantity=new BigDecimal(strings[28]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[37] != null && strings[37] != ""){
                                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                                if(strings[37]!=null&&!strings[37].isEmpty()){
                                    quantity=new BigDecimal(strings[37]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[47] != null && strings[47] != ""){
                                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                                if(strings[47]!=null&&!strings[47].isEmpty()){
                                    quantity=new BigDecimal(strings[47]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);//数量
                            }

                            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
                        }
                        /**
                         * 大米成品粮
                         */
                        if((strings[29] != null && strings[29] != "") || (strings[38] != null && strings[38] != "") || (strings[48] != null && strings[48] != "")){
                            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
                            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
                            EsNetworkEntryGrain.setGrainVariety(7);//粮食品种 大米成品粮
                            if(strings[29] != null && strings[29] != ""){
                                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                                if(strings[29]!=null&&!strings[29].isEmpty()){
                                    quantity=new BigDecimal(strings[29]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[38] != null && strings[38] != ""){
                                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                                if(strings[38]!=null&&!strings[38].isEmpty()){
                                    quantity=new BigDecimal(strings[38]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[48] != null && strings[48] != ""){
                                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                                if(strings[48]!=null&&!strings[48].isEmpty()){
                                    quantity=new BigDecimal(strings[48]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);//数量
                            }

                            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
                        }
                        /**
                         * 食用油成品粮
                         */
                        if((strings[30] != null && strings[30] != "") || (strings[39] != null && strings[39] != "") || (strings[49] != null && strings[49] != "")){
                            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
                            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
                            EsNetworkEntryGrain.setGrainVariety(8);//粮食品种 食用油成品粮
                            if(strings[30] != null && strings[30] != ""){
                                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                                if(strings[30]!=null&&!strings[30].isEmpty()){
                                    quantity=new BigDecimal(strings[30]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[39] != null && strings[39] != ""){
                                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                                if(strings[39]!=null&&!strings[39].isEmpty()){
                                    quantity=new BigDecimal(strings[39]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[49] != null && strings[49] != ""){
                                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                                if(strings[49]!=null&&!strings[49].isEmpty()){
                                    quantity=new BigDecimal(strings[49]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);//数量
                            }

                            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
                        }
                        /**
                         * 其他成品粮
                         */
                        if((strings[31] != null && strings[31] != "") || (strings[40] != null && strings[40] != "") || (strings[50] != null && strings[50] != "")){
                            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
                            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
                            EsNetworkEntryGrain.setGrainVariety(9);//粮食品种 其他成品粮
                            if(strings[31] != null && strings[31] != ""){
                                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                                if(strings[31]!=null&&!strings[31].isEmpty()){
                                    quantity=new BigDecimal(strings[31]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[40] != null && strings[40] != ""){
                                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                                if(strings[40]!=null&&!strings[40].isEmpty()){
                                    quantity=new BigDecimal(strings[40]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);
                            }else if(strings[50] != null && strings[50] != ""){
                                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                                if(strings[50]!=null&&!strings[50].isEmpty()){
                                    quantity=new BigDecimal(strings[50]);
                                }
                                EsNetworkEntryGrain.setQuantity(quantity);//数量
                            }

                            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
                        }

                        res = 1;
                        if(res>0){
                            insertNum+= 1;
                        } else{
                            failNum+= 1;
                        }
                    }else{
                        skipNum+= 1;
                    }

                }

            }
            map.put("status", 200);
            map.put("massage", "共" + size + ",跳过" + skipNum + ",失败" + failNum + ",成功新增" + insertNum + ",成功更新" + updateNum);
            return map;

        } else {
            map.put("status", 500);
            map.put("massage", "未读取到有效数据或存在无法解析的属性");
            return map;
        }

    }

    @Transactional
    public void importUpdate (String[] strings,List<EsDeliveryEnterprise> list, Integer updateNum, Integer res, Integer failNum){
        BigDecimal quantity=new BigDecimal(0.00);
        Integer in =0;
        EsDeliveryEnterprise EsNetworkEntry = list.get(0);
        EsNetworkEntry.setId(EsNetworkEntry.getId());
        //修改


        QueryWrapper<BizDict> queryWrapper1 = new QueryWrapper<>();
        queryWrapper1.eq("DICT_LABEL",strings[1]);
        List<BizDict> list1 = BizDictServiceImpl.list(queryWrapper1);
        EsNetworkEntry.setManagementAreaProvince(list1.get(0).getId());//归口管理地区-省

        QueryWrapper<BizDict> queryWrapper2 = new QueryWrapper<>();
        queryWrapper2.eq("DICT_LABEL",strings[2]);
        List<BizDict> list2 = BizDictServiceImpl.list(queryWrapper2);
        EsNetworkEntry.setManagementAreaCity(list2.get(0).getId());//归口管理地区-市

        QueryWrapper<BizDict> queryWrapper3 = new QueryWrapper<>();
        queryWrapper3.eq("DICT_LABEL",strings[3]);
        List<BizDict> list3 = BizDictServiceImpl.list(queryWrapper3);
        EsNetworkEntry.setManagementAreaCounty(list3.get(0).getId());//归口管理地区-县


        QueryWrapper<BizDict> queryWrapper4 = new QueryWrapper<>();
        queryWrapper4.eq("DICT_LABEL",strings[4]);
        List<BizDict> list4 = BizDictServiceImpl.list(queryWrapper4);
        EsNetworkEntry.setActualAddressProvince(list4.get(0).getId());//实际经营地址-省

        QueryWrapper<BizDict> queryWrapper5 = new QueryWrapper<>();
        queryWrapper5.eq("DICT_LABEL",strings[5]);
        List<BizDict> list5 = BizDictServiceImpl.list(queryWrapper5);
        EsNetworkEntry.setActualAddressCity(list5.get(0).getId());//实际经营地址-市

        QueryWrapper<BizDict> queryWrapper6 = new QueryWrapper<>();
        queryWrapper6.eq("DICT_LABEL",strings[6]);
        List<BizDict> list6 = BizDictServiceImpl.list(queryWrapper6);
        EsNetworkEntry.setActualAddressCounty(list6.get(0).getId());//实际经营地址-县


        if(strings[7] != null && strings[7] != ""){
            EsNetworkEntry.setIsNationalLevel(1);//供应应急级别-是否国家级，0：否；1：是
        }else{
            EsNetworkEntry.setIsNationalLevel(0);//供应应急级别-是否国家级，0：否；1：是
        }
        if(strings[8] != null && strings[8] != ""){
            EsNetworkEntry.setIsProvincialLevel(1);//供应应急级别-是否省级，0：否；1：是
        }else{
            EsNetworkEntry.setIsProvincialLevel(0);//供应应急级别-是否省级，0：否；1：是
        }

        if(strings[9] != null && strings[9] != ""){
            EsNetworkEntry.setIsCityLevel(1);//供应应急级别-是否市级，0：否；1：是
        }else{
            EsNetworkEntry.setIsCityLevel(0);//供应应急级别-是否市级，0：否；1：是
        }

        if(strings[10] != null && strings[10] != ""){
            EsNetworkEntry.setIsCountyLevel(1);//供应应急级别-是否县级，0：否；1：是
        }else{
            EsNetworkEntry.setIsCountyLevel(0);//供应应急级别-是否县级，0：否；1：是
        }


        EsNetworkEntry.setHeadquarterCreditCode(strings[11]);//所属总公司企业信用代码
        EsNetworkEntry.setEnterpriseName(strings[12]);//企业名称
        EsNetworkEntry.setCreditCode(strings[13]);//统一社会信用代码
        EsNetworkEntry.setActualBusinessAddress(strings[14]);//实际经营地址（省、市、县、乡镇街道门牌号）

        QueryWrapper<BizDict> queryWrapper7 = new QueryWrapper<>();
        queryWrapper7.eq("DICT_LABEL",strings[15].trim());
        List<BizDict> list7 = BizDictServiceImpl.list(queryWrapper7);
        EsNetworkEntry.setEnterpriseNature(strings[15]);//企业性质
        QueryWrapper<BizDict> queryWrapper8 = new QueryWrapper<>();
        queryWrapper8.eq("DICT_LABEL",strings[16]);
        List<BizDict> list8 = BizDictServiceImpl.list(queryWrapper8);
        EsNetworkEntry.setEnterpriseType(strings[16]);//企业类型

        EsNetworkEntry.setLongitude(new BigDecimal(strings[17]));//经度

        EsNetworkEntry.setLatitude(new BigDecimal(strings[18]));//纬度


        EsNetworkEntry.setLegalRepresentative(strings[19]);//法人姓名
        EsNetworkEntry.setLegalContact(strings[20]);//法人联系方式
        EsNetworkEntry.setEnterpriseContact(strings[21]);//联系人姓名
        EsNetworkEntry.setContactNumber(strings[22]);//联系电话
        if(strings[41] != null && strings[41] != "") {
            if(strings[41]!=null&&!strings[41].isEmpty()){
                quantity=new BigDecimal(strings[41]);
            }
            EsNetworkEntry.setDailyDeliveryCapacity(quantity);
        }
        if(strings[51] != null && strings[51] != "") {//原粮库房仓容
            if(strings[51]!=null&&!strings[51].isEmpty()){
                quantity=new BigDecimal(strings[51]);
            }
            EsNetworkEntry.setGrainWarehouseCapacity(quantity);
        }
        if(strings[52] != null && strings[52] != "") {//原粮油罐罐容
            if(strings[52]!=null&&!strings[52].isEmpty()){
                quantity=new BigDecimal(strings[52]);
            }
            EsNetworkEntry.setVegetableOilTankCapacity(quantity);
        }
        if(strings[53] != null && strings[53] != "") {//成品粮库房仓容
            if(strings[53]!=null&&!strings[53].isEmpty()){
                quantity=new BigDecimal(strings[53]);
            }
            EsNetworkEntry.setFinishedGrainWarehouseCapacity(quantity);
        }
        if(strings[54] != null && strings[54] != "") {//成品粮油罐罐容
            if(strings[54]!=null&&!strings[54].isEmpty()){
                quantity=new BigDecimal(strings[54]);
            }
            EsNetworkEntry.setFinishedOilTankCapacity(quantity);
        }
        if(strings[55] != null && strings[55] != "") {//自有运输车辆数
            if(strings[55]!=null&&!strings[55].isEmpty()){
                in=Integer.parseInt(strings[55]);
            }
            EsNetworkEntry.setOwnTransportVehicles(in);
        }
        if(strings[56] != null && strings[56] != "") {//自有车辆日配送能力（吨）
            if(strings[56]!=null&&!strings[56].isEmpty()){
                quantity=new BigDecimal(strings[56]);
            }
            EsNetworkEntry.setOwnVehiclesDailyDeliveryCapacity(quantity);
        }
        EsNetworkEntry.setOwnTransportCapacity(new BigDecimal(0.00));
        if(strings[57] != null && strings[57] != "") {//日配送能力
            if(strings[57]!=null&&!strings[57].isEmpty()){
                quantity=new BigDecimal(strings[57]);
            }
            EsNetworkEntry.setOwnVehiclesDailyDeliveryCapacity(quantity);
        }
        if(strings[58] != null && strings[58] != "") {//辐射范围（省/市/县）
            EsNetworkEntry.setRadiationRange(strings[58]);
        }

        if(strings[59] != null && strings[59] != ""){
            if(strings[59].equals("生产")){
                EsNetworkEntry.setProductionStatus(1);//生产状态，0：停产；1：生产
            }else{
                EsNetworkEntry.setProductionStatus(0);//生产状态，0：停产；1：生产
            }
        }
        EsNetworkEntry.setCityState(strings[5].trim());
        this.updateById(EsNetworkEntry);

        QueryWrapper<EsDeliveryEnterpriseGrain> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("es_delivery_enterprise_id", EsNetworkEntry.getId());
        List<EsDeliveryEnterpriseGrain> zList = esDeliveryEnterpriseGrainService.list(queryWrapper);
        esDeliveryEnterpriseGrainService.removeByIds(zList);

        /**
         * 小麦原粮
         */

        if((strings[23] != null && strings[23] != "") || (strings[32] != null && strings[32] != "") || (strings[42] != null && strings[42] != "")){
            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
            EsNetworkEntryGrain.setGrainVariety(1);//粮食品种 1：小麦粉成品粮
            if(strings[23] != null && strings[23] != ""){
                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                if(strings[23]!=null&&!strings[23].isEmpty()){
                    quantity=new BigDecimal(strings[23]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[32] != null && strings[32] != ""){
                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                if(strings[32]!=null&&!strings[32].isEmpty()){
                    quantity=new BigDecimal(strings[32]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[42] != null && strings[42] != ""){
                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                if(strings[42]!=null&&!strings[42].isEmpty()){
                    quantity=new BigDecimal(strings[42]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);//数量
            }

            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
        }
        /**
         * 稻谷原粮
         */
        if((strings[24] != null && strings[24] != "") || (strings[33] != null && strings[33] != "") || (strings[43] != null && strings[43] != "")){
            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
            EsNetworkEntryGrain.setGrainVariety(2);//粮食品种 稻谷原粮
            if(strings[24] != null && strings[24] != ""){
                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                if(strings[24]!=null&&!strings[24].isEmpty()){
                    quantity=new BigDecimal(strings[24]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[33] != null && strings[33] != ""){
                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                if(strings[33]!=null&&!strings[33].isEmpty()){
                    quantity=new BigDecimal(strings[33]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[43] != null && strings[43] != ""){
                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                if(strings[43]!=null&&!strings[43].isEmpty()){
                    quantity=new BigDecimal(strings[43]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);//数量
            }

            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
        }
        /**
         * 大豆原粮
         */
        if((strings[25] != null && strings[25] != "") || (strings[34] != null && strings[34] != "") || (strings[44] != null && strings[44] != "")){
            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
            EsNetworkEntryGrain.setGrainVariety(3);//粮食品种 大豆原粮
            if(strings[25] != null && strings[25] != ""){
                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                if(strings[25]!=null&&!strings[25].isEmpty()){
                    quantity=new BigDecimal(strings[25]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[34] != null && strings[34] != ""){
                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                if(strings[34]!=null&&!strings[34].isEmpty()){
                    quantity=new BigDecimal(strings[34]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[44] != null && strings[44] != ""){
                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                if(strings[44]!=null&&!strings[44].isEmpty()){
                    quantity=new BigDecimal(strings[44]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);//数量
            }

            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
        }
        /**
         * 玉米原粮
         */
        if((strings[26] != null && strings[26] != "") || (strings[35] != null && strings[35] != "") || (strings[45] != null && strings[45] != "")){
            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
            EsNetworkEntryGrain.setGrainVariety(4);//粮食品种 玉米原粮
            if(strings[26] != null && strings[26] != ""){
                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                if(strings[26]!=null&&!strings[26].isEmpty()){
                    quantity=new BigDecimal(strings[26]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[35] != null && strings[35] != ""){
                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                if(strings[35]!=null&&!strings[35].isEmpty()){
                    quantity=new BigDecimal(strings[35]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[45] != null && strings[45] != ""){
                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                if(strings[45]!=null&&!strings[45].isEmpty()){
                    quantity=new BigDecimal(strings[45]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);//数量
            }

            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
        }
        /**
         * 其他原粮
         */
        if((strings[27] != null && strings[27] != "") || (strings[36] != null && strings[36] != "") || (strings[46] != null && strings[46] != "")){
            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
            EsNetworkEntryGrain.setGrainVariety(5);//粮食品种 其他原粮
            if(strings[27] != null && strings[27] != ""){
                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                if(strings[27]!=null&&!strings[27].isEmpty()){
                    quantity=new BigDecimal(strings[27]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[36] != null && strings[36] != ""){
                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                if(strings[36]!=null&&!strings[36].isEmpty()){
                    quantity=new BigDecimal(strings[36]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[46] != null && strings[46] != ""){
                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                if(strings[46]!=null&&!strings[46].isEmpty()){
                    quantity=new BigDecimal(strings[46]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);//数量
            }

            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
        }
        /**
         * 小麦粉成品粮
         */
        if((strings[28] != null && strings[28] != "") || (strings[37] != null && strings[37] != "") || (strings[47] != null && strings[47] != "")){
            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
            EsNetworkEntryGrain.setGrainVariety(6);//粮食品种 小麦粉成品粮
            if(strings[28] != null && strings[28] != ""){
                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                if(strings[28]!=null&&!strings[28].isEmpty()){
                    quantity=new BigDecimal(strings[28]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[37] != null && strings[37] != ""){
                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                if(strings[37]!=null&&!strings[37].isEmpty()){
                    quantity=new BigDecimal(strings[37]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[47] != null && strings[47] != ""){
                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                if(strings[47]!=null&&!strings[47].isEmpty()){
                    quantity=new BigDecimal(strings[47]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);//数量
            }

            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
        }
        /**
         * 大米成品粮
         */
        if((strings[29] != null && strings[29] != "") || (strings[38] != null && strings[38] != "") || (strings[48] != null && strings[48] != "")){
            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
            EsNetworkEntryGrain.setGrainVariety(7);//粮食品种 大米成品粮
            if(strings[29] != null && strings[29] != ""){
                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                if(strings[29]!=null&&!strings[29].isEmpty()){
                    quantity=new BigDecimal(strings[29]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[38] != null && strings[38] != ""){
                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                if(strings[38]!=null&&!strings[38].isEmpty()){
                    quantity=new BigDecimal(strings[38]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[48] != null && strings[48] != ""){
                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                if(strings[48]!=null&&!strings[48].isEmpty()){
                    quantity=new BigDecimal(strings[48]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);//数量
            }

            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
        }
        /**
         * 食用油成品粮
         */
        if((strings[30] != null && strings[30] != "") || (strings[39] != null && strings[39] != "") || (strings[49] != null && strings[49] != "")){
            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
            EsNetworkEntryGrain.setGrainVariety(8);//粮食品种 食用油成品粮
            if(strings[30] != null && strings[30] != ""){
                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                if(strings[30]!=null&&!strings[30].isEmpty()){
                    quantity=new BigDecimal(strings[30]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[39] != null && strings[39] != ""){
                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                if(strings[39]!=null&&!strings[39].isEmpty()){
                    quantity=new BigDecimal(strings[39]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[49] != null && strings[49] != ""){
                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                if(strings[49]!=null&&!strings[49].isEmpty()){
                    quantity=new BigDecimal(strings[49]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);//数量
            }

            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
        }
        /**
         * 其他成品粮
         */
        if((strings[31] != null && strings[31] != "") || (strings[40] != null && strings[40] != "") || (strings[50] != null && strings[50] != "")){
            EsDeliveryEnterpriseGrain EsNetworkEntryGrain = new EsDeliveryEnterpriseGrain();
            EsNetworkEntryGrain.setEsDeliveryEnterpriseId(EsNetworkEntry.getId());//biz_es_storage_enterprise的id
            EsNetworkEntryGrain.setGrainVariety(9);//粮食品种 其他成品粮
            if(strings[31] != null && strings[31] != ""){
                EsNetworkEntryGrain.setType(1);//类型 1：日库存；
                if(strings[31]!=null&&!strings[31].isEmpty()){
                    quantity=new BigDecimal(strings[31]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[40] != null && strings[40] != ""){
                EsNetworkEntryGrain.setType(2);//类型 2：日吞吐量
                if(strings[40]!=null&&!strings[40].isEmpty()){
                    quantity=new BigDecimal(strings[40]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);
            }else if(strings[50] != null && strings[50] != ""){
                EsNetworkEntryGrain.setType(3);//类型 3：吞吐能力

                if(strings[50]!=null&&!strings[50].isEmpty()){
                    quantity=new BigDecimal(strings[50]);
                }
                EsNetworkEntryGrain.setQuantity(quantity);//数量
            }

            esDeliveryEnterpriseGrainService.save(EsNetworkEntryGrain);
        }


        res = 1;
        if(res>0){
            updateNum+= 1;
        } else{
            failNum+= 1;
        }

    }
}
