| | |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.chinaztt.mes.basic.entity.Factory; |
| | | import com.chinaztt.mes.basic.entity.Warehouse; |
| | | import com.chinaztt.mes.basic.excel.WarehouseData; |
| | | import com.chinaztt.mes.basic.mapper.FactoryMapper; |
| | |
| | | import lombok.SneakyThrows; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 仓库基础数据 |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importWarehouseExcel(List<WarehouseData> list) { |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | return; |
| | | } |
| | | List<SysDictItem> dict = dictUtils.getDict("warehouse_type"); |
| | | List<Factory> factoryList =factoryMapper.selectList(null); |
| | | List<SysDictItem> dict = dictUtils.getDict("storehouse_type"); |
| | | for (WarehouseData data :list){ |
| | | QueryWrapper<Warehouse> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(Warehouse::getWarehouseNo,data.getWarehouseNo()); |
| | | Warehouse warehouse1 = baseMapper.selectOne(wrapper); |
| | | if(!Objects.isNull(warehouse1)){ |
| | | log.error("仓库编号重复"); |
| | | continue; |
| | | } |
| | | Warehouse warehouse = new Warehouse(); |
| | | dict.forEach(a -> { |
| | | if (a.getLabel().equals(data.getType())){ |
| | | warehouse.setWarehouseType(a.getValue()); |
| | | } |
| | | }); |
| | | factoryList.forEach(b -> { |
| | | if (b.getFactoryName().equals(data.getFactoryName())){ |
| | | warehouse.setFactoryId(b.getId()); |
| | | } |
| | | }); |
| | | if (warehouse.getFactoryId()==null){ |
| | | log.error("工厂:" + data.getWarehouseName() + "不存在"); |
| | | continue; |
| | | if("启用".equals(data.getState())){ |
| | | warehouse.setWarehouseStatus(1); |
| | | }else{ |
| | | warehouse.setWarehouseStatus(0); |
| | | } |
| | | if(warehouse.getWarehouseType()==null){ |
| | | log.error("仓库类型:" + data.getType() + "不存在"); |
| | | continue; |
| | | }; |
| | | warehouse.setWarehouseNo(data.getWarehouseNo()); |
| | | warehouse.setWarehouseName(data.getWarehouseName()); |
| | | warehouse.setWarehouseStatus(1); |
| | | //warehouse.setWarehouseStatus(1); |
| | | baseMapper.insert(warehouse); |
| | | } |
| | | } |