/*
 * 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.esstorageenterprise.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollStreamUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.unis.basic.info.modular.orgInfo.entity.OrgInfo;
import com.unis.biz.modular.dict.entity.BizDict;
import com.unis.emergencySupport.modular.esstorageenterprise.param.*;
import com.unis.emergencySupport.modular.esstorageenterprise.util.FileImport;
import com.unis.emergencySupport.modular.esstorageenterprisegrain.entity.BizEsStorageEnterpriseGrain;
import com.unis.emergencySupport.modular.esstorageenterprisegrain.param.BizEsStorageEnterpriseGrainAddParam;
import com.unis.emergencySupport.modular.esstorageenterprisegrain.param.BizEsStorageEnterpriseGrainEditParam;
import com.unis.emergencySupport.modular.esstorageenterprisegrain.service.impl.BizEsStorageEnterpriseGrainServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.unis.common.enums.CommonSortOrderEnum;
import com.unis.common.exception.CommonException;
import com.unis.common.page.CommonPageRequest;
import com.unis.emergencySupport.modular.esstorageenterprise.entity.BizEsStorageEnterprise;
import com.unis.emergencySupport.modular.esstorageenterprise.mapper.BizEsStorageEnterpriseMapper;
import com.unis.emergencySupport.modular.esstorageenterprise.service.BizEsStorageEnterpriseService;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 应急保障-应急仓储企业管理表Service接口实现类
 *
 * @author shine
 * @date  2024/05/25 14:37
 **/
@Service
public class BizEsStorageEnterpriseServiceImpl extends ServiceImpl<BizEsStorageEnterpriseMapper, BizEsStorageEnterprise> implements BizEsStorageEnterpriseService {

    @Resource
    private BizEsStorageEnterpriseGrainServiceImpl bizEsStorageEnterpriseGrainServiceImpl;
    @Resource
    private BizEsStorageEnterpriseMapper bizEsStorageEnterpriseMapper;
    @Resource
    private com.unis.biz.modular.dict.service.impl.BizDictServiceImpl BizDictServiceImpl;


    @Override
    public Page<BizEsStorageEnterprise> page(BizEsStorageEnterprisePageParam bizEsStorageEnterprisePageParam) {
        QueryWrapper<BizEsStorageEnterprise> queryWrapper = new QueryWrapper<>();
        if(ObjectUtil.isNotEmpty(bizEsStorageEnterprisePageParam.getEnterpriseName())) {
            queryWrapper.lambda().like(BizEsStorageEnterprise::getEnterpriseName, bizEsStorageEnterprisePageParam.getEnterpriseName());
        }
        if(ObjectUtil.isNotEmpty(bizEsStorageEnterprisePageParam.getCreditCode())) {
            queryWrapper.lambda().eq(BizEsStorageEnterprise::getCreditCode, bizEsStorageEnterprisePageParam.getCreditCode());
        }
        if(ObjectUtil.isNotEmpty(bizEsStorageEnterprisePageParam.getCityState())) {
            queryWrapper.lambda().like(BizEsStorageEnterprise::getCityState, bizEsStorageEnterprisePageParam.getCityState());
        }
        if(ObjectUtil.isNotEmpty(bizEsStorageEnterprisePageParam.getEmergencyCategory())) {
            queryWrapper.lambda().like(BizEsStorageEnterprise::getEmergencyCategory, bizEsStorageEnterprisePageParam.getEmergencyCategory());
        }
        if(ObjectUtil.isAllNotEmpty(bizEsStorageEnterprisePageParam.getSortField(), bizEsStorageEnterprisePageParam.getSortOrder())) {
            CommonSortOrderEnum.validate(bizEsStorageEnterprisePageParam.getSortOrder());
            queryWrapper.orderBy(true, bizEsStorageEnterprisePageParam.getSortOrder().equals(CommonSortOrderEnum.ASC.getValue()),
                    StrUtil.toUnderlineCase(bizEsStorageEnterprisePageParam.getSortField()));
        } else {
            queryWrapper.lambda().orderByAsc(BizEsStorageEnterprise::getId);
        }
        Page<BizEsStorageEnterprise> page = this.page(CommonPageRequest.defaultPage(), queryWrapper);
        /**
         * 子表数据处理
         */
             if(page.getRecords().size()>0){
                 for(BizEsStorageEnterprise bizEsStorageEnterprise:page.getRecords()){
                     QueryWrapper<BizEsStorageEnterpriseGrain> qw = new QueryWrapper<>();
                     qw.eq("es_storage_enterprise_id",bizEsStorageEnterprise.getId());
                     qw.eq("type",1);
                     List<BizEsStorageEnterpriseGrain> list = bizEsStorageEnterpriseGrainServiceImpl.list(qw);
                     /**
                      * grain_variety 粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮；',
                      * type 类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                      */
                     for(BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain:list){
                         if(bizEsStorageEnterpriseGrain.getGrainVariety().equals(1)){
                             bizEsStorageEnterprise.setXmylrkc(bizEsStorageEnterpriseGrain.getQuantity().toString());
                         }else if(bizEsStorageEnterpriseGrain.getGrainVariety().equals(5)){
                             bizEsStorageEnterprise.setQtylrkc(bizEsStorageEnterpriseGrain.getQuantity().toString());
                         }
                     }
                 }
             }
        return page;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void add(BizEsStorageEnterpriseAddParam bizEsStorageEnterpriseAddParam) {
        BizEsStorageEnterprise bizEsStorageEnterprise = BeanUtil.toBean(bizEsStorageEnterpriseAddParam, BizEsStorageEnterprise.class);
        this.save(bizEsStorageEnterprise);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void edit(BizEsStorageEnterpriseEditParam bizEsStorageEnterpriseEditParam) {
        BizEsStorageEnterprise bizEsStorageEnterprise = this.queryEntity(bizEsStorageEnterpriseEditParam.getId());
        BeanUtil.copyProperties(bizEsStorageEnterpriseEditParam, bizEsStorageEnterprise);
        this.updateById(bizEsStorageEnterprise);

        /**
         * 子表修改 先删除 在新增
         */
        QueryWrapper<BizEsStorageEnterpriseGrain> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("es_storage_enterprise_id",bizEsStorageEnterprise.getId());
        List<BizEsStorageEnterpriseGrain> zList = bizEsStorageEnterpriseGrainServiceImpl.list(queryWrapper);
        for(BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain:zList){
            bizEsStorageEnterpriseGrainServiceImpl.removeById(bizEsStorageEnterpriseGrain.getId());
        }

        if(bizEsStorageEnterprise.getBizEsStorageEnterpriseGrainEditParamList().size()>0){
            for(BizEsStorageEnterpriseGrainEditParam BizEsStorageEnterpriseGrainEditParam:bizEsStorageEnterprise.getBizEsStorageEnterpriseGrainEditParamList()){
                BizEsStorageEnterpriseGrain esStorageEnterpriseGrain = BeanUtil.toBean(BizEsStorageEnterpriseGrainEditParam, BizEsStorageEnterpriseGrain.class);
                esStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterpriseEditParam.getId());
                bizEsStorageEnterpriseGrainServiceImpl.save(esStorageEnterpriseGrain);
                /*if( null != esStorageEnterpriseGrain.getId() && "" != esStorageEnterpriseGrain.getId()){
                    bizEsStorageEnterpriseGrainServiceImpl.edit(BizEsStorageEnterpriseGrainEditParam);
                }else{

                }*/
            }
        }
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void delete(List<BizEsStorageEnterpriseIdParam> bizEsStorageEnterpriseIdParamList) {
        // 执行删除
        this.removeByIds(CollStreamUtil.toList(bizEsStorageEnterpriseIdParamList, BizEsStorageEnterpriseIdParam::getId));
        QueryWrapper<BizEsStorageEnterpriseGrain> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("es_storage_enterprise_id", bizEsStorageEnterpriseIdParamList.get(0).getId());
        List<BizEsStorageEnterpriseGrain> list = bizEsStorageEnterpriseGrainServiceImpl.list(queryWrapper);
        bizEsStorageEnterpriseGrainServiceImpl.removeByIds(list);
    }

    @Override
    public BizEsStorageEnterprise detail(BizEsStorageEnterpriseIdParam bizEsStorageEnterpriseIdParam) {
        BizEsStorageEnterprise bizEsStorageEnterprise = this.queryEntity(bizEsStorageEnterpriseIdParam.getId());
        QueryWrapper<BizEsStorageEnterpriseGrain> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("es_storage_enterprise_id", bizEsStorageEnterpriseIdParam.getId());
        List<BizEsStorageEnterpriseGrain> list = bizEsStorageEnterpriseGrainServiceImpl.list(queryWrapper);
        bizEsStorageEnterprise.setBizEsStorageEnterpriseGrain(list);
        return bizEsStorageEnterprise;

    }

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

    @Override
    public void saveAll(BizEsStorageEnterpriseAddParam bizEsStorageEnterpriseAddParam) {
        BizEsStorageEnterprise bizEsStorageEnterprise = BeanUtil.toBean(bizEsStorageEnterpriseAddParam, BizEsStorageEnterprise.class);
        this.save(bizEsStorageEnterprise);
        if(bizEsStorageEnterprise.getBizEsStorageEnterpriseGrainAddParamList().size()>0){
             for(BizEsStorageEnterpriseGrainAddParam bizEsStorageEnterpriseGrainAddParam:bizEsStorageEnterprise.getBizEsStorageEnterpriseGrainAddParamList()){
                 bizEsStorageEnterpriseGrainAddParam.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());
                 bizEsStorageEnterpriseGrainServiceImpl.add(bizEsStorageEnterpriseGrainAddParam);
             }
         }
    }


    @Override
    public Map<String, Object> importByEntityResult(MultipartFile file, Map<String, Object> map) throws Exception {

        // TODO Auto-generated method stub
        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<BizEsStorageEnterprise> queryWrapper = new QueryWrapper<>();
                    queryWrapper.eq("enterprise_name", strings[12]);
                    queryWrapper.eq("credit_code", strings[13]);
                    List<BizEsStorageEnterprise> mainList = this.list(queryWrapper);

                    if (mainList.size() > 0) {
                        //修改
                        this.importUpdate(strings,mainList,updateNum,res,failNum);
                    } else if(mainList.size() ==0){
                        BizEsStorageEnterprise bizEsStorageEnterprise = new BizEsStorageEnterprise();
                        //新增
                        bizEsStorageEnterprise.setEnterpriseName(strings[12]);//企业名称
                        bizEsStorageEnterprise.setCreditCode(strings[13]);//统一社会信用代码
                        //BizEsStorageEnterprise.setEstablishmentTime();//成立时间
                        bizEsStorageEnterprise.setHeadquarterCreditCode(strings[11]);//所属总公司企业信用代码
                        bizEsStorageEnterprise.setLegalRepresentative(strings[19]);//法人姓名
                        bizEsStorageEnterprise.setLegalContact(strings[20]);//法人联系方式
                        bizEsStorageEnterprise.setEnterpriseContact(strings[21]);//企业联系人
                        bizEsStorageEnterprise.setContactNumber(strings[22]);//联系电话
                        //BizEsStorageEnterprise.setCityState();//所属市州

                        /*QueryWrapper<BizDict> queryWrapper7 = new QueryWrapper<>();
                        queryWrapper7.eq("DICT_LABEL",strings[15]);
                        List<BizDict> list7 = BizDictServiceImpl.list(queryWrapper7);
                        bizEsStorageEnterprise.setEnterpriseNature(list7.get(0).getId());//企业性质*/

                        if(!strings[15].isEmpty()){
                            bizEsStorageEnterprise.setEnterpriseNature(strings[15]);//企业性质
                        }else{
                            bizEsStorageEnterprise.setEnterpriseNature("0");//企业性质
                        }

                        /*QueryWrapper<BizDict> queryWrapper8 = new QueryWrapper<>();
                        queryWrapper8.eq("DICT_LABEL",strings[16]);
                        List<BizDict> list8 = BizDictServiceImpl.list(queryWrapper8);
                        bizEsStorageEnterprise.setEnterpriseType(list8.get(0).getId());//企业类型*/

                        if(!strings[16].isEmpty()){
                            bizEsStorageEnterprise.setEnterpriseType(strings[16]);//企业类型
                        }else{
                            bizEsStorageEnterprise.setEnterpriseType("0");//企业类型
                        }

                        if(!strings[17].isEmpty()){
                            bizEsStorageEnterprise.setLongitude(new BigDecimal(strings[17]));//经度
                        }else{
                            bizEsStorageEnterprise.setLongitude(new BigDecimal("0"));//经度
                        }
                        if(!strings[18].isEmpty()){
                            bizEsStorageEnterprise.setLatitude(new BigDecimal(strings[18]));//纬度
                        }else{
                            bizEsStorageEnterprise.setLatitude(new BigDecimal("0"));//纬度
                        }

                        //BizEsStorageEnterprise.setEmergencyCategory();//应急分类
                        if(!strings[14].isEmpty()){
                            bizEsStorageEnterprise.setActualBusinessAddress(strings[14]);//实际经营地址（省、市、县、乡镇街道门牌号）
                        }else{
                            bizEsStorageEnterprise.setActualBusinessAddress("0");//实际经营地址（省、市、县、乡镇街道门牌号）
                        }
                        if(!strings[67].isEmpty()){
                            if(strings[67].equals("生产")){
                                bizEsStorageEnterprise.setProductionStatus(1);//生产状态，0：停产；1：生产
                            }else{
                                bizEsStorageEnterprise.setProductionStatus(0);//生产状态，0：停产；1：生产
                            }
                        }else{
                            bizEsStorageEnterprise.setProductionStatus(1);//生产状态，0：停产；1：生产
                        }


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

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

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



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

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

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

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

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

                        if(!strings[10].isEmpty()){
                            bizEsStorageEnterprise.setIsCountyLevel(1);//供应应急级别-是否县级，0：否；1：是
                        }else{
                            bizEsStorageEnterprise.setIsCountyLevel(0);//供应应急级别-是否县级，0：否；1：是
                        }
                        if(!strings[50].isEmpty()){
                            bizEsStorageEnterprise.setDailyTransportVolume(new BigDecimal(strings[50]));//实际日运输量
                        }
                        if(!strings[60].isEmpty()){
                            bizEsStorageEnterprise.setGrainStorageCapacity(new BigDecimal(strings[60]));//原粮库房仓容（吨）
                        }
                        if(!strings[61].isEmpty()){
                            bizEsStorageEnterprise.setVegetableOilTankCapacity(new BigDecimal(strings[61]));//原粮油罐罐容（吨）

                        }
                        if(!strings[62].isEmpty()){
                            bizEsStorageEnterprise.setFinishedGrainStorageCapacity(new BigDecimal(strings[62]));//成品粮库房容（吨）

                        }
                        if(!strings[63].isEmpty()){
                            bizEsStorageEnterprise.setFinishedOilTankCapacity(new BigDecimal(strings[63]));//成品粮油罐容（吨）

                        }
                        if(!strings[65].isEmpty()){
                            bizEsStorageEnterprise.setOwnVehiclesDailyDeliveryCapacity(new BigDecimal(strings[65]));//自有车辆日配送能力（吨）
                        }else{
                            bizEsStorageEnterprise.setOwnVehiclesDailyDeliveryCapacity(new BigDecimal(0));//自有车辆日配送能力（吨）
                        }
                        if(!strings[64].isEmpty()){
                            bizEsStorageEnterprise.setOwnTransportVehicles(Integer.valueOf(strings[64]));//自有运输车辆数（辆）
                        }else{
                            bizEsStorageEnterprise.setOwnTransportVehicles(0);//自有运输车辆数（辆）
                        }
                        if(!strings[66].isEmpty()){
                            bizEsStorageEnterprise.setOwnTransportCapacity(new BigDecimal(strings[66]));//自有运输能力（吨）
                        }else{
                            bizEsStorageEnterprise.setOwnTransportCapacity(new BigDecimal(0));//自有运输能力（吨）
                        }

                        this.save(bizEsStorageEnterprise);

                        if((!strings[23].isEmpty()) || (!strings[32].isEmpty()) || (!strings[41].isEmpty()) || (!strings[51].isEmpty())){
                            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
                            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
                            bizEsStorageEnterpriseGrain.setGrainVariety(1);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
                            if(!strings[23].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[23]));//数量
                            }else if(!strings[32].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[32]));//数量
                            }else if(!strings[41].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[41]));//数量
                            }else if(!strings[51].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[51]));//数量
                            }
                            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
                        }
                        if((!strings[24].isEmpty()) || (!strings[33].isEmpty()) || (!strings[42].isEmpty()) || (!strings[52].isEmpty())){
                            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
                            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
                            bizEsStorageEnterpriseGrain.setGrainVariety(2);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
                            if(!strings[24].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[24]));//数量

                            }else if(!strings[33].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[33]));//数量

                            }else if(!strings[42].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[42]));//数量

                            }else if(!strings[52].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[52]));//数量

                            }
                            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
                        }
                        if((!strings[25].isEmpty()) || (!strings[34].isEmpty()) || (!strings[43].isEmpty()) || (!strings[53].isEmpty())){
                            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
                            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
                            bizEsStorageEnterpriseGrain.setGrainVariety(3);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
                            if(!strings[25].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[25]));//数量

                            }else if(!strings[34].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[34]));//数量

                            }else if(!strings[43].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[43]));//数量

                            }else if(!strings[53].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[53]));//数量

                            }
                            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
                        }
                        if((!strings[26].isEmpty()) || (!strings[35].isEmpty()) || (!strings[44].isEmpty()) || (!strings[54].isEmpty())){
                            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
                            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
                            bizEsStorageEnterpriseGrain.setGrainVariety(4);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
                            if(!strings[26].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[26]));//数量
                            }else if(!strings[35].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[35]));//数量
                            }else if(!strings[44].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[44]));//数量
                            }else if(!strings[54].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[54]));//数量
                            }
                            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
                        }
                        if((!strings[27].isEmpty()) || (!strings[36].isEmpty()) || (!strings[45].isEmpty()) || (!strings[55].isEmpty())){
                            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
                            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
                            bizEsStorageEnterpriseGrain.setGrainVariety(5);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
                            if(!strings[27].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[27]));//数量
                            }else if(!strings[36].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[36]));//数量
                            }else if(!strings[45].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[45]));//数量
                            }else if(!strings[55].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[55]));//数量
                            }
                            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
                        }
                        if((!strings[28].isEmpty()) || (!strings[37].isEmpty()) || (!strings[46].isEmpty()) || (!strings[56].isEmpty())){
                            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
                            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
                            bizEsStorageEnterpriseGrain.setGrainVariety(6);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
                            if(!strings[28].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[28]));//数量

                            }else if(!strings[37].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[37]));//数量

                            }else if(!strings[46].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[46]));//数量

                            }else if(!strings[56].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[56]));//数量
                            }

                            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
                        }
                        if((!strings[29].isEmpty()) || (!strings[38].isEmpty()) || (!strings[47].isEmpty()) || (!strings[57].isEmpty())){
                            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
                            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
                            bizEsStorageEnterpriseGrain.setGrainVariety(7);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
                            if(!strings[29].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[29]));//数量
                            }else if(!strings[38].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[38]));//数量
                            }else if(!strings[47].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[47]));//数量
                            }else if(!strings[57].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[57]));//数量
                            }

                            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
                        }
                        if((!strings[30].isEmpty()) || (!strings[39].isEmpty()) || (!strings[48].isEmpty()) || (!strings[58].isEmpty())){
                            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
                            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
                            bizEsStorageEnterpriseGrain.setGrainVariety(8);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
                            if(!strings[30].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[30]));//数量
                            }else if(!strings[39].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[39]));//数量
                            }else if(!strings[48].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[48]));//数量
                            }else if(!strings[58].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[58]));//数量
                            }
                            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
                        }
                        if((!strings[31].isEmpty()) || (!strings[40].isEmpty()) || (!strings[49].isEmpty()) || (!strings[59].isEmpty())){
                            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
                            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
                            bizEsStorageEnterpriseGrain.setGrainVariety(9);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
                            if(!strings[31].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[31]));//数量
                            }else if(!strings[40].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[40]));//数量
                            }else if(!strings[49].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[49]));//数量
                            }else if(!strings[59].isEmpty()){
                                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[59]));//数量
                            }
                            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
                        }

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

                }

            }
            map.put("status", 200);
            return map;

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

    }



    public void importUpdate (String[] strings,List<BizEsStorageEnterprise> list,Integer updateNum,Integer res,Integer failNum){

            BizEsStorageEnterprise bizEsStorageEnterprise = list.get(0);
            bizEsStorageEnterprise.setId(bizEsStorageEnterprise.getId());
            //修改
            bizEsStorageEnterprise.setEnterpriseName(strings[12]);//企业名称
            bizEsStorageEnterprise.setCreditCode(strings[13]);//统一社会信用代码
            //BizEsStorageEnterprise.setEstablishmentTime();//成立时间
            bizEsStorageEnterprise.setHeadquarterCreditCode(strings[11]);//所属总公司企业信用代码
            bizEsStorageEnterprise.setLegalRepresentative(strings[19]);//法人姓名
            bizEsStorageEnterprise.setLegalContact(strings[20]);//法人联系方式
            bizEsStorageEnterprise.setEnterpriseContact(strings[21]);//企业联系人
            bizEsStorageEnterprise.setContactNumber(strings[22]);//联系电话
            //BizEsStorageEnterprise.setCityState();//所属市州

                            /*QueryWrapper<BizDict> queryWrapper7 = new QueryWrapper<>();
                            queryWrapper7.eq("DICT_LABEL",strings[15]);
                            List<BizDict> list7 = BizDictServiceImpl.list(queryWrapper7);
                            bizEsStorageEnterprise.setEnterpriseNature(list7.get(0).getId());//企业性质*/

                if(!strings[15].isEmpty()){
                    bizEsStorageEnterprise.setEnterpriseNature(strings[15]);//企业性质
                }else{
                    bizEsStorageEnterprise.setEnterpriseNature("0");//企业性质
                }

                            /*QueryWrapper<BizDict> queryWrapper8 = new QueryWrapper<>();
                            queryWrapper8.eq("DICT_LABEL",strings[16]);
                            List<BizDict> list8 = BizDictServiceImpl.list(queryWrapper8);
                            bizEsStorageEnterprise.setEnterpriseType(list8.get(0).getId());//企业类型*/

            if(!strings[16].isEmpty()){
                bizEsStorageEnterprise.setEnterpriseType(strings[16]);//企业类型
            }else{
                bizEsStorageEnterprise.setEnterpriseType("0");//企业类型
            }

            if(!strings[17].isEmpty()){
                bizEsStorageEnterprise.setLongitude(new BigDecimal(strings[17]));//经度
            }else{
                bizEsStorageEnterprise.setLongitude(new BigDecimal("0"));//经度
            }
            if(!strings[18].isEmpty()){
                bizEsStorageEnterprise.setLatitude(new BigDecimal(strings[18]));//纬度
            }else{
                bizEsStorageEnterprise.setLatitude(new BigDecimal("0"));//纬度
            }

            //BizEsStorageEnterprise.setEmergencyCategory();//应急分类
            if(!strings[14].isEmpty()){
                bizEsStorageEnterprise.setActualBusinessAddress(strings[14]);//实际经营地址（省、市、县、乡镇街道门牌号）
            }else{
                bizEsStorageEnterprise.setActualBusinessAddress("0");//实际经营地址（省、市、县、乡镇街道门牌号）
            }

            if(!strings[67].isEmpty()){
                if(strings[67].equals("生产")){
                    bizEsStorageEnterprise.setProductionStatus(1);//生产状态，0：停产；1：生产
                }else{
                    bizEsStorageEnterprise.setProductionStatus(0);//生产状态，0：停产；1：生产
                }
            }else{
                bizEsStorageEnterprise.setProductionStatus(1);//生产状态，0：停产；1：生产
            }


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

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

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



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

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

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

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

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

            if(!strings[10].isEmpty()){
                bizEsStorageEnterprise.setIsCountyLevel(1);//供应应急级别-是否县级，0：否；1：是
            }else{
                bizEsStorageEnterprise.setIsCountyLevel(0);//供应应急级别-是否县级，0：否；1：是
            }
            if(!strings[50].isEmpty()){
                bizEsStorageEnterprise.setDailyTransportVolume(new BigDecimal(strings[50]));//实际日运输量
            }
            if(!strings[60].isEmpty()){
                bizEsStorageEnterprise.setGrainStorageCapacity(new BigDecimal(strings[60]));//原粮库房仓容（吨）
            }
            if(!strings[61].isEmpty()){
                bizEsStorageEnterprise.setVegetableOilTankCapacity(new BigDecimal(strings[61]));//原粮油罐罐容（吨）

            }
            if(!strings[62].isEmpty()){
                bizEsStorageEnterprise.setFinishedGrainStorageCapacity(new BigDecimal(strings[62]));//成品粮库房容（吨）

            }
            if(!strings[63].isEmpty()){
                bizEsStorageEnterprise.setFinishedOilTankCapacity(new BigDecimal(strings[63]));//成品粮油罐容（吨）

            }
            if(!strings[65].isEmpty()){
                bizEsStorageEnterprise.setOwnVehiclesDailyDeliveryCapacity(new BigDecimal(strings[65]));//自有车辆日配送能力（吨）
            }else{
                bizEsStorageEnterprise.setOwnVehiclesDailyDeliveryCapacity(new BigDecimal(0));//自有车辆日配送能力（吨）
            }
            if(!strings[64].isEmpty()){
                bizEsStorageEnterprise.setOwnTransportVehicles(Integer.valueOf(strings[64]));//自有运输车辆数（辆）
            }else{
                bizEsStorageEnterprise.setOwnTransportVehicles(0);//自有运输车辆数（辆）
            }
            if(!strings[66].isEmpty()){
                bizEsStorageEnterprise.setOwnTransportCapacity(new BigDecimal(strings[66]));//自有运输能力（吨）
            }else{
                bizEsStorageEnterprise.setOwnTransportCapacity(new BigDecimal(0));//自有运输能力（吨）
            }

            this.updateById(bizEsStorageEnterprise);

            QueryWrapper<BizEsStorageEnterpriseGrain> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("es_storage_enterprise_id", bizEsStorageEnterprise.getId());
            List<BizEsStorageEnterpriseGrain> zList = bizEsStorageEnterpriseGrainServiceImpl.list(queryWrapper);
            bizEsStorageEnterpriseGrainServiceImpl.removeByIds(zList);

        if((!strings[23].isEmpty()) || (!strings[32].isEmpty()) || (!strings[41].isEmpty()) || (!strings[51].isEmpty())){
            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
            bizEsStorageEnterpriseGrain.setGrainVariety(1);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
            if(!strings[23].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[23]));//数量
            }else if(!strings[32].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[32]));//数量
            }else if(!strings[41].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[41]));//数量
            }else if(!strings[51].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[51]));//数量
            }
            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
        }
        if((!strings[24].isEmpty()) || (!strings[33].isEmpty()) || (!strings[42].isEmpty()) || (!strings[52].isEmpty())){
            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
            bizEsStorageEnterpriseGrain.setGrainVariety(2);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
            if(!strings[24].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[24]));//数量

            }else if(!strings[33].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[33]));//数量

            }else if(!strings[42].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[42]));//数量

            }else if(!strings[52].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[52]));//数量

            }
            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
        }
        if((!strings[25].isEmpty()) || (!strings[34].isEmpty()) || (!strings[43].isEmpty()) || (!strings[53].isEmpty())){
            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
            bizEsStorageEnterpriseGrain.setGrainVariety(3);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
            if(!strings[25].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[25]));//数量

            }else if(!strings[34].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[34]));//数量

            }else if(!strings[43].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[43]));//数量

            }else if(!strings[53].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[53]));//数量

            }
            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
        }
        if((!strings[26].isEmpty()) || (!strings[35].isEmpty()) || (!strings[44].isEmpty()) || (!strings[54].isEmpty())){
            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
            bizEsStorageEnterpriseGrain.setGrainVariety(4);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
            if(!strings[26].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[26]));//数量
            }else if(!strings[35].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[35]));//数量
            }else if(!strings[44].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[44]));//数量
            }else if(!strings[54].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[54]));//数量
            }
            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
        }
        if((!strings[27].isEmpty()) || (!strings[36].isEmpty()) || (!strings[45].isEmpty()) || (!strings[55].isEmpty())){
            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
            bizEsStorageEnterpriseGrain.setGrainVariety(5);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
            if(!strings[27].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[27]));//数量
            }else if(!strings[36].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[36]));//数量
            }else if(!strings[45].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[45]));//数量
            }else if(!strings[55].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[55]));//数量
            }
            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
        }
        if((!strings[28].isEmpty()) || (!strings[37].isEmpty()) || (!strings[46].isEmpty()) || (!strings[56].isEmpty())){
            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
            bizEsStorageEnterpriseGrain.setGrainVariety(6);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
            if(!strings[28].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[28]));//数量

            }else if(!strings[37].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[37]));//数量

            }else if(!strings[46].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[46]));//数量

            }else if(!strings[56].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[56]));//数量
            }

            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
        }
        if((!strings[29].isEmpty()) || (!strings[38].isEmpty()) || (!strings[47].isEmpty()) || (!strings[57].isEmpty())){
            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
            bizEsStorageEnterpriseGrain.setGrainVariety(7);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
            if(!strings[29].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[29]));//数量
            }else if(!strings[38].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[38]));//数量
            }else if(!strings[47].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[47]));//数量
            }else if(!strings[57].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[57]));//数量
            }

            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
        }
        if((!strings[30].isEmpty()) || (!strings[39].isEmpty()) || (!strings[48].isEmpty()) || (!strings[58].isEmpty())){
            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
            bizEsStorageEnterpriseGrain.setGrainVariety(8);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
            if(!strings[30].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[30]));//数量
            }else if(!strings[39].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[39]));//数量
            }else if(!strings[48].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[48]));//数量
            }else if(!strings[58].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[58]));//数量
            }
            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
        }
        if((!strings[31].isEmpty()) || (!strings[40].isEmpty()) || (!strings[49].isEmpty()) || (!strings[59].isEmpty())){
            BizEsStorageEnterpriseGrain bizEsStorageEnterpriseGrain = new BizEsStorageEnterpriseGrain();
            bizEsStorageEnterpriseGrain.setEsStorageEnterpriseId(bizEsStorageEnterprise.getId());//biz_es_storage_enterprise的id
            bizEsStorageEnterpriseGrain.setGrainVariety(9);//粮食品种 1：小麦原粮:2：稻谷原粮:3：大豆原粮；4：玉米原粮；5：其他原粮；6：小麦粉成品粮；7：大米成品粮；8：食用油成品粮；9：其他成品粮
            if(!strings[31].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(1);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[31]));//数量
            }else if(!strings[40].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(2);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[40]));//数量
            }else if(!strings[49].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(3);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[49]));//数量
            }else if(!strings[59].isEmpty()){
                bizEsStorageEnterpriseGrain.setType(4);//类型 1：日库存；2：日出库量；3：日入库量；4：出库能力
                bizEsStorageEnterpriseGrain.setQuantity(new BigDecimal(strings[59]));//数量
            }
            bizEsStorageEnterpriseGrainServiceImpl.save(bizEsStorageEnterpriseGrain);
        }

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

    }

    @Override
    public List<Map<String, Object>> getAllList(String type) {
        if(type.equals("0")){
            return bizEsStorageEnterpriseMapper.getAllList();
        }else if(Integer.valueOf(type) >0 && Integer.valueOf(type) <5){
            return bizEsStorageEnterpriseMapper.getListByType(type);
        }else{
            return null;
        }
    }

    @Override
    public List<Map<String, Object>> statistics(String city) {

        List<Map<String, Object>> provinceList = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> cityList = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> countyList = new ArrayList<Map<String, Object>>();
            if( null != city &&   "" != city){
                //县
                 countyList = bizEsStorageEnterpriseMapper.getDataByCounty(city);
                List<Map<String, Object>> countyCount= bizEsStorageEnterpriseMapper.getSlByCounty(city);
                for(Map<String, Object> map:countyList){
                    for(Map<String, Object> map1:countyCount){
                        if(map.get("county").equals(map1.get("county"))){
                            map.put("wdsl",map1.get("wdsl"));
                        }
                    }
                }
            }else{

                //省
                 provinceList = bizEsStorageEnterpriseMapper.getDataByProvince();
                List<Map<String, Object>> provinceCount= bizEsStorageEnterpriseMapper.getSlByProvince();
                for(Map<String, Object> map:provinceList){
                    for(Map<String, Object> map1:provinceCount){
                        if(map.get("province").equals(map1.get("province"))){
                            map.put("wdsl",map1.get("wdsl"));
                        }
                    }
                }

                //市
                 cityList = bizEsStorageEnterpriseMapper.getDataByCity();
                List<Map<String, Object>> cityCount= bizEsStorageEnterpriseMapper.getSlByCity();
                for(Map<String, Object> map:cityList){
                    for(Map<String, Object> map1:cityCount){
                        if(map.get("city").equals(map1.get("city"))){
                            map.put("wdsl",map1.get("wdsl"));
                        }
                    }
                }
            }


        List<Map<String, Object>> result = Stream.of(provinceList, cityList, countyList)
                .flatMap(Collection::stream)
                .collect(Collectors.toList());
        return result;
    }

}
