|
|
|
@ -30,9 +30,11 @@ 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.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.secure.BladeUser; |
|
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
|
import org.springblade.system.entity.User; |
|
|
|
|
import org.springblade.system.feign.IDeptClient; |
|
|
|
@ -96,73 +98,57 @@ 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()); |
|
|
|
|
boolean b = list.stream().anyMatch(i -> ObjectUtil.isEmpty(i.getSendWarehouseId())); |
|
|
|
|
if(b){ |
|
|
|
|
throw new ServiceException("当前添加已存在!"); |
|
|
|
|
}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<>(); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
List<String> sendWarehouseIds = basicdataStorageServices.getSendWarehouseIds(); |
|
|
|
|
|
|
|
|
|
List<BasicdataStorageServicesEntity> servicesEntities = new ArrayList<>(); |
|
|
|
|
if(ObjectUtil.isEmpty(sendWarehouseIds) || sendWarehouseIds.size() < 1){ |
|
|
|
|
BasicdataStorageServicesEntity basicdataStorageServicesEntity = new BasicdataStorageServicesEntity(); |
|
|
|
|
BeanUtils.copyProperties(basicdataStorageServices,basicdataStorageServicesEntity); |
|
|
|
|
// 获取仓库名称
|
|
|
|
|
BasicdataWarehouseEntity serveBasicdataWarehouseEntity = basicdataWarehouseService.getById(basicdataStorageServices.getServeWarehouseId()); |
|
|
|
|
basicdataStorageServicesEntity.setServeWarehouseName(serveBasicdataWarehouseEntity.getName()); |
|
|
|
|
servicesEntities.add(basicdataStorageServicesEntity); |
|
|
|
|
}else{ |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
if(servicesEntities.size() > 0){ |
|
|
|
|
this.saveBatch(servicesEntities); |
|
|
|
|
} |
|
|
|
|