|
|
|
@ -17,6 +17,7 @@
|
|
|
|
|
package com.logpm.basicdata.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.logpm.basicdata.dto.BasicdataStorageServicesDTO; |
|
|
|
@ -27,16 +28,28 @@ import com.logpm.basicdata.vo.BasicdataStorageServicesVO;
|
|
|
|
|
import com.logpm.basicdata.excel.BasicdataStorageServicesExcel; |
|
|
|
|
import com.logpm.basicdata.mapper.BasicdataStorageServicesMapper; |
|
|
|
|
import com.logpm.basicdata.service.IBasicdataStorageServicesService; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.springblade.core.secure.BladeUser; |
|
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
|
import org.springblade.system.entity.User; |
|
|
|
|
import org.springblade.system.feign.IDeptClient; |
|
|
|
|
import org.springblade.system.feign.IUserClient; |
|
|
|
|
import org.springblade.system.vo.UserVO; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Iterator; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 门店服务仓库表 服务实现类 |
|
|
|
@ -45,12 +58,14 @@ import java.util.Map;
|
|
|
|
|
* @since 2023-05-16 |
|
|
|
|
*/ |
|
|
|
|
@Service |
|
|
|
|
@AllArgsConstructor |
|
|
|
|
public class BasicdataStorageServicesServiceImpl extends BaseServiceImpl<BasicdataStorageServicesMapper, BasicdataStorageServicesEntity> implements IBasicdataStorageServicesService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IBasicdataWarehouseService basicdataWarehouseService; |
|
|
|
|
|
|
|
|
|
private IUserClient userClient; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<BasicdataStorageServicesVO> selectBasicdataStorageServicesPage(IPage<BasicdataStorageServicesVO> page, BasicdataStorageServicesVO basicdataStorageServices) { |
|
|
|
|
return page.setRecords(baseMapper.selectBasicdataStorageServicesPage(page, basicdataStorageServices)); |
|
|
|
@ -67,6 +82,7 @@ public class BasicdataStorageServicesServiceImpl extends BaseServiceImpl<Basicda
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public boolean submitSave(BasicdataStorageServicesDTO basicdataStorageServices) { |
|
|
|
|
|
|
|
|
|
if(ObjectUtils.isNotNull(basicdataStorageServices.getId())){ |
|
|
|
@ -79,19 +95,77 @@ public class BasicdataStorageServicesServiceImpl extends BaseServiceImpl<Basicda
|
|
|
|
|
this.updateById(basicdataStorageServices); |
|
|
|
|
return true; |
|
|
|
|
}else{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> sendWarehouseIds = new ArrayList<>(); |
|
|
|
|
if(ObjectUtils.isNull( basicdataStorageServices.getSendWarehouseIds()) || basicdataStorageServices.getSendWarehouseIds().size() == 0 ){ |
|
|
|
|
|
|
|
|
|
BladeUser user = AuthUtil.getUser(); |
|
|
|
|
R<UserVO> userR = userClient.userInfoByIdOwn(user.getUserId()); |
|
|
|
|
QueryWrapper<BasicdataWarehouseEntity> queryWrapper = new QueryWrapper(); |
|
|
|
|
queryWrapper.eq("tenant_id",user.getTenantId()); |
|
|
|
|
/*if(userR.getData().getRoleName().equals("管理员")){ |
|
|
|
|
//查询全部
|
|
|
|
|
queryWrapper.eq("tenant_id",user.getTenantId()); |
|
|
|
|
}else{ |
|
|
|
|
queryWrapper.eq("department",user.getDeptId()); |
|
|
|
|
}*/ |
|
|
|
|
//查询全部仓库
|
|
|
|
|
List<BasicdataWarehouseEntity> list1 = basicdataWarehouseService.list(queryWrapper); |
|
|
|
|
|
|
|
|
|
//查询有没有过服务舱
|
|
|
|
|
List<BasicdataStorageServicesEntity> list = this.list(Wrappers.<BasicdataStorageServicesEntity>query().lambda() |
|
|
|
|
.eq(BasicdataStorageServicesEntity::getServeWarehouseId, basicdataStorageServices.getServeWarehouseId()) |
|
|
|
|
.eq(BasicdataStorageServicesEntity::getClientId, basicdataStorageServices.getClientId()) |
|
|
|
|
); |
|
|
|
|
if(list.size() > 0){ |
|
|
|
|
// 有
|
|
|
|
|
list.removeIf(q -> { |
|
|
|
|
boolean b = list1.stream().anyMatch(i -> i.getId().equals(q.getSendWarehouseId())); |
|
|
|
|
if (b) { |
|
|
|
|
return list1.removeIf(i -> i.getId().equals(q.getSendWarehouseId())); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
// list1.removeIf(person1 -> list.stream().anyMatch(person2 -> person2.getSendWarehouseId().equals(person1.getId())));
|
|
|
|
|
List<Long> collect = list1.stream().map(BasicdataWarehouseEntity::getId).collect(Collectors.toList()); |
|
|
|
|
sendWarehouseIds = collect.stream().map(String::valueOf).collect(Collectors.toList()); |
|
|
|
|
}else{ |
|
|
|
|
//没有
|
|
|
|
|
List<Long> collect = list1.stream().map(BasicdataWarehouseEntity::getId).collect(Collectors.toList()); |
|
|
|
|
sendWarehouseIds = collect.stream().map(String::valueOf).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
sendWarehouseIds = basicdataStorageServices.getSendWarehouseIds(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
List<BasicdataStorageServicesEntity> servicesEntities = new ArrayList<>(); |
|
|
|
|
basicdataStorageServices.getSendWarehouseIds().forEach( i ->{ |
|
|
|
|
BasicdataStorageServicesEntity basicdataStorageServicesEntity = new BasicdataStorageServicesEntity(); |
|
|
|
|
BeanUtils.copyProperties(basicdataStorageServices,basicdataStorageServicesEntity); |
|
|
|
|
// 获取仓库名称
|
|
|
|
|
BasicdataWarehouseEntity sendBasicdataWarehouseEntity = basicdataWarehouseService.getById(i); |
|
|
|
|
basicdataStorageServicesEntity.setSendWarehouseName(sendBasicdataWarehouseEntity.getName()); |
|
|
|
|
BasicdataWarehouseEntity serveBasicdataWarehouseEntity = basicdataWarehouseService.getById(basicdataStorageServices.getServeWarehouseId()); |
|
|
|
|
basicdataStorageServicesEntity.setServeWarehouseName(serveBasicdataWarehouseEntity.getName()); |
|
|
|
|
basicdataStorageServicesEntity.setSendWarehouseId(i); |
|
|
|
|
servicesEntities.add(basicdataStorageServicesEntity); |
|
|
|
|
sendWarehouseIds.forEach( i ->{ |
|
|
|
|
|
|
|
|
|
List<BasicdataStorageServicesEntity> list = this.list(Wrappers.<BasicdataStorageServicesEntity>query().lambda() |
|
|
|
|
.eq(BasicdataStorageServicesEntity::getServeWarehouseId, basicdataStorageServices.getServeWarehouseId()) |
|
|
|
|
.eq(BasicdataStorageServicesEntity::getSendWarehouseId, i) |
|
|
|
|
.eq(BasicdataStorageServicesEntity::getClientId, basicdataStorageServices.getClientId()) |
|
|
|
|
|
|
|
|
|
); |
|
|
|
|
if(list.size() < 1){ |
|
|
|
|
BasicdataStorageServicesEntity basicdataStorageServicesEntity = new BasicdataStorageServicesEntity(); |
|
|
|
|
BeanUtils.copyProperties(basicdataStorageServices,basicdataStorageServicesEntity); |
|
|
|
|
// 获取仓库名称
|
|
|
|
|
BasicdataWarehouseEntity sendBasicdataWarehouseEntity = basicdataWarehouseService.getById(i); |
|
|
|
|
basicdataStorageServicesEntity.setSendWarehouseName(sendBasicdataWarehouseEntity.getName()); |
|
|
|
|
BasicdataWarehouseEntity serveBasicdataWarehouseEntity = basicdataWarehouseService.getById(basicdataStorageServices.getServeWarehouseId()); |
|
|
|
|
basicdataStorageServicesEntity.setServeWarehouseName(serveBasicdataWarehouseEntity.getName()); |
|
|
|
|
basicdataStorageServicesEntity.setSendWarehouseId(i); |
|
|
|
|
servicesEntities.add(basicdataStorageServicesEntity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
this.saveBatch(servicesEntities); |
|
|
|
|
if(servicesEntities.size() > 0){ |
|
|
|
|
this.saveBatch(servicesEntities); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
// return this.saveOrUpdate(basicdataStorageServices);
|
|
|
|
|