|
|
@@ -16,6 +16,17 @@
|
|
|
*/
|
|
|
package org.springblade.ship.cable.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import org.springblade.common.cache.DictCache;
|
|
|
+import org.springblade.common.cache.SysCache;
|
|
|
+import org.springblade.common.cache.UserCache;
|
|
|
+import org.springblade.common.enums.DictEnum;
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
+import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springblade.modules.system.entity.Region;
|
|
|
+import org.springblade.modules.system.entity.User;
|
|
|
+import org.springblade.modules.system.excel.CableExcel;
|
|
|
+import org.springblade.modules.system.excel.UserExcel;
|
|
|
import org.springblade.ship.cable.entity.Cable;
|
|
|
import org.springblade.ship.cable.vo.CableVO;
|
|
|
import org.springblade.ship.cable.mapper.CableMapper;
|
|
|
@@ -24,6 +35,9 @@ import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* 服务实现类
|
|
|
*
|
|
|
@@ -38,4 +52,98 @@ public class CableServiceImpl extends BaseServiceImpl<CableMapper, Cable> implem
|
|
|
return page.setRecords(baseMapper.selectCablePage(page, cable));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void importCable(List<CableExcel> data, Boolean isCovered) {
|
|
|
+ List<Cable> listAdd = new ArrayList<>();
|
|
|
+ List<Cable> listUpdate = new ArrayList<>();
|
|
|
+ data.forEach(cableExcel -> {
|
|
|
+ Cable cable = BeanUtil.copy(cableExcel, Cable.class);
|
|
|
+
|
|
|
+ String cable_category = DictCache.getKey("cable_category", cableExcel.getCategory());
|
|
|
+ String cable_model = DictCache.getKey("cable_model", cableExcel.getModel());
|
|
|
+ String ship_cabin = DictCache.getKey("ship_cabin", cableExcel.getBeginCabin());
|
|
|
+ String ship_side = DictCache.getKey("ship_side", cableExcel.getBeginShipSide());
|
|
|
+ String ship_cabin1 = DictCache.getKey("ship_cabin", cableExcel.getEndCabin());
|
|
|
+ String ship_side1 = DictCache.getKey("ship_side", cableExcel.getEndShipSide());
|
|
|
+
|
|
|
+ if (cable_category != null){
|
|
|
+ cable.setCategory(cable_category);
|
|
|
+ }
|
|
|
+ if (cable_model != null){
|
|
|
+ cable.setModel(cable_model);
|
|
|
+ }
|
|
|
+ if (ship_cabin != null){
|
|
|
+ cable.setBeginCabin(ship_cabin);
|
|
|
+ }
|
|
|
+ if (ship_side != null){
|
|
|
+ cable.setBeginShipSide(ship_side);
|
|
|
+ }
|
|
|
+ if (ship_cabin1 != null){
|
|
|
+ cable.setEndCabin(ship_cabin1);
|
|
|
+ }
|
|
|
+ if (ship_side1 != null){
|
|
|
+ cable.setEndShipSide(ship_side1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 覆盖数据
|
|
|
+ if (isCovered) {
|
|
|
+ // 查询数据是否存在
|
|
|
+ Cable old = this.getByAlias(cableExcel.getAlias());
|
|
|
+ if (old != null && old.getId() != null) {
|
|
|
+ cable.setId(old.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (cable.getId() == null){
|
|
|
+ listAdd.add(cable);
|
|
|
+ }else {
|
|
|
+ listUpdate.add(cable);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.saveBatch(listAdd);
|
|
|
+ this.saveOrUpdateBatch(listUpdate);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Cable getByAlias(String alias) {
|
|
|
+ return baseMapper.selectOne(new QueryWrapper<>(new Cable()).lambda().eq(Cable::getAlias, alias));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CableExcel> exportCable(QueryWrapper<Cable> queryWrapper) {
|
|
|
+ List<CableExcel> list = new ArrayList<>();
|
|
|
+ List<Cable> cableList = baseMapper.selectList(queryWrapper);
|
|
|
+ cableList.forEach(cable -> {
|
|
|
+ CableExcel cableExcel = new CableExcel();
|
|
|
+ BeanUtil.copy(cable, cableExcel);
|
|
|
+
|
|
|
+ String cable_category = DictCache.getValue("cable_category", cableExcel.getCategory());
|
|
|
+ String cable_model = DictCache.getValue("cable_model", cableExcel.getModel());
|
|
|
+ String ship_cabin = DictCache.getValue("ship_cabin", cableExcel.getBeginCabin());
|
|
|
+ String ship_side = DictCache.getValue("ship_side", cableExcel.getBeginShipSide());
|
|
|
+ String ship_cabin1 = DictCache.getValue("ship_cabin", cableExcel.getEndCabin());
|
|
|
+ String ship_side1 = DictCache.getValue("ship_side", cableExcel.getEndShipSide());
|
|
|
+
|
|
|
+ if (cable_category != null){
|
|
|
+ cableExcel.setCategory(cable_category);
|
|
|
+ }
|
|
|
+ if (cable_model != null){
|
|
|
+ cableExcel.setModel(cable_model);
|
|
|
+ }
|
|
|
+ if (ship_cabin != null){
|
|
|
+ cableExcel.setBeginCabin(ship_cabin);
|
|
|
+ }
|
|
|
+ if (ship_side != null){
|
|
|
+ cableExcel.setBeginShipSide(ship_side);
|
|
|
+ }
|
|
|
+ if (ship_cabin1 != null){
|
|
|
+ cableExcel.setEndCabin(ship_cabin1);
|
|
|
+ }
|
|
|
+ if (ship_side1 != null){
|
|
|
+ cableExcel.setEndShipSide(ship_side1);
|
|
|
+ }
|
|
|
+
|
|
|
+ list.add(cableExcel);
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|