定点、到站回收订单业务功能开发v5

door
LI-CCONG\李聪聪 7 months ago
parent 1667e8c785
commit 711913a20e

@ -89,7 +89,8 @@ public class CommonUtil {
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
Field field = ReflectUtil.getField(clazz, fieldName); Field field = ReflectUtil.getField(clazz, fieldName);
if (field != null) { if (field != null) {
field.set(clazz, value); field.setAccessible(true);
field.set(obj, value);
} }
} }
@ -100,7 +101,8 @@ public class CommonUtil {
if (field == null) { if (field == null) {
return null; return null;
} }
return field.get(clazz); field.setAccessible(true);
return field.get(obj);
} }

@ -42,7 +42,7 @@ public class IndexController {
@ApiOperation("废品类目列表") @ApiOperation("废品类目列表")
@GetMapping("/products") @GetMapping("/products")
public CommonResult<List<ProductSimpleVO>> queryProductList() { public CommonResult<List<ProductSimpleVO>> queryProductList() {
List<Product> productList = priceProductService.queryProductList(Collections.emptyList()); List<Product> productList = priceProductService.queryProductList();
List<ProductSimpleVO> productSimpleVOList = BeanUtils.copyList(productList, ProductSimpleVO.class); List<ProductSimpleVO> productSimpleVOList = BeanUtils.copyList(productList, ProductSimpleVO.class);
return CommonResult.success(productSimpleVOList); return CommonResult.success(productSimpleVOList);
} }

@ -244,7 +244,7 @@ public class RecycleOrderController {
LocationDTO location = (LocationDTO) CommonUtil.obtainField(orderRespVO, "location"); LocationDTO location = (LocationDTO) CommonUtil.obtainField(orderRespVO, "location");
if (location != null) { if (location != null) {
BigDecimal distance = CommonUtil.getDistance(longitude, latitude, location.getLongitude(), location.getLatitude()); BigDecimal distance = CommonUtil.getDistance(longitude, latitude, location.getLongitude(), location.getLatitude());
CommonUtil.assignField(orderRespVO, "distance2", distance); CommonUtil.assignField(orderRespVO, "distance2", distance.doubleValue());
} }
}); });
} }
@ -262,7 +262,8 @@ public class RecycleOrderController {
List<RecycleOrderDetailResponseVO> detailResponseVOList = BeanUtils.copyList(orderProducts, RecycleOrderDetailResponseVO.class); List<RecycleOrderDetailResponseVO> detailResponseVOList = BeanUtils.copyList(orderProducts, RecycleOrderDetailResponseVO.class);
// 查询废品信息 // 查询废品信息
Set<String> productIds = detailResponseVOList.stream().map(RecycleOrderDetailResponseVO::getProductId).collect(Collectors.toSet()); Set<String> productIds = detailResponseVOList.stream().map(RecycleOrderDetailResponseVO::getProductId).collect(Collectors.toSet());
List<Product> productList = priceProductService.queryProductList(productIds); List<Product> productList = priceProductService.getProductListByIds(productIds);
if (CollUtils.isNotEmpty(productList)) {
Map<String, Product> productMap = productList.stream().collect(Collectors.toMap(Product::getId, p -> p, (k1, k2) -> k1)); Map<String, Product> productMap = productList.stream().collect(Collectors.toMap(Product::getId, p -> p, (k1, k2) -> k1));
for (RecycleOrderDetailResponseVO detailVO : detailResponseVOList) { for (RecycleOrderDetailResponseVO detailVO : detailResponseVOList) {
Product product = productMap.get(detailVO.getProductId()); Product product = productMap.get(detailVO.getProductId());
@ -274,6 +275,7 @@ public class RecycleOrderController {
CommonUtil.assignField(v, "orderDetails", orderProductsMap.get(v.getId())); CommonUtil.assignField(v, "orderDetails", orderProductsMap.get(v.getId()));
}); });
} }
}
/** /**
@ -288,7 +290,8 @@ public class RecycleOrderController {
return Optional.ofNullable(clientAddressId).orElse(""); return Optional.ofNullable(clientAddressId).orElse("");
}, (k1, k2) -> k1)); }, (k1, k2) -> k1));
Set<String> addressIds = new HashSet<>(CollUtils.removeEmpty(orderAddressMap.values())); Set<String> addressIds = new HashSet<>(CollUtils.removeEmpty(orderAddressMap.values()));
List<ClientAddress> clientAddresses = clientAddressService.queryAddressList(addressIds); List<ClientAddress> clientAddresses = clientAddressService.getAddressListByIds(addressIds);
if (CollUtils.isNotEmpty(clientAddresses)) {
List<ClientAddressSimpleVO> addressSimpleVOList = BeanUtils.copyList(clientAddresses, ClientAddressSimpleVO.class); List<ClientAddressSimpleVO> addressSimpleVOList = BeanUtils.copyList(clientAddresses, ClientAddressSimpleVO.class);
Map<String, ClientAddressSimpleVO> clientAddressMap = addressSimpleVOList.stream().collect( Map<String, ClientAddressSimpleVO> clientAddressMap = addressSimpleVOList.stream().collect(
Collectors.toMap(ClientAddressSimpleVO::getId, v -> v, (k1, k2) -> k1)); Collectors.toMap(ClientAddressSimpleVO::getId, v -> v, (k1, k2) -> k1));
@ -297,6 +300,7 @@ public class RecycleOrderController {
CommonUtil.assignField(v, "clientAddressId", clientAddressId); CommonUtil.assignField(v, "clientAddressId", clientAddressId);
}); });
} }
}
/** /**
@ -309,6 +313,7 @@ public class RecycleOrderController {
RecycleOrderRespVO::getId, v -> Optional.ofNullable(v.getStaffsId()).orElse(""), (k1, k2) -> k1)); RecycleOrderRespVO::getId, v -> Optional.ofNullable(v.getStaffsId()).orElse(""), (k1, k2) -> k1));
Set<String> recyclerIds = new HashSet<>(CollUtils.removeEmpty(orderRecyclerMap.values())); Set<String> recyclerIds = new HashSet<>(CollUtils.removeEmpty(orderRecyclerMap.values()));
List<Recycler> recyclerList = recyclerService.getRecyclerByIds(recyclerIds); List<Recycler> recyclerList = recyclerService.getRecyclerByIds(recyclerIds);
if (ObjectUtil.isNotEmpty(recyclerList)) {
List<RecyclerSimpleVO> recyclerSimpleVOList = BeanUtils.copyList(recyclerList, RecyclerSimpleVO.class); List<RecyclerSimpleVO> recyclerSimpleVOList = BeanUtils.copyList(recyclerList, RecyclerSimpleVO.class);
Map<String, RecyclerSimpleVO> recyclerMap = recyclerSimpleVOList.stream().collect( Map<String, RecyclerSimpleVO> recyclerMap = recyclerSimpleVOList.stream().collect(
Collectors.toMap(RecyclerSimpleVO::getId, v -> v, (k1, k2) -> k1)); Collectors.toMap(RecyclerSimpleVO::getId, v -> v, (k1, k2) -> k1));
@ -320,6 +325,7 @@ public class RecycleOrderController {
} }
}); });
} }
}
/** /**
@ -335,6 +341,7 @@ public class RecycleOrderController {
}, (k1, k2) -> k1)); }, (k1, k2) -> k1));
Set<String> housingEstateIds = new HashSet<>(CollUtils.removeEmpty(orderHousingEstateMap.values())); Set<String> housingEstateIds = new HashSet<>(CollUtils.removeEmpty(orderHousingEstateMap.values()));
List<HousingEstate> housingEstateList = housingEstateService.getHousingListByIds(housingEstateIds); List<HousingEstate> housingEstateList = housingEstateService.getHousingListByIds(housingEstateIds);
if (CollUtils.isNotEmpty(housingEstateList)) {
List<HousingEstateSimpleVO> housingSimpleVOList = BeanUtils.copyList(housingEstateList, HousingEstateSimpleVO.class); List<HousingEstateSimpleVO> housingSimpleVOList = BeanUtils.copyList(housingEstateList, HousingEstateSimpleVO.class);
Map<String, HousingEstateSimpleVO> housingEstateMap = housingSimpleVOList.stream().collect( Map<String, HousingEstateSimpleVO> housingEstateMap = housingSimpleVOList.stream().collect(
Collectors.toMap(HousingEstateSimpleVO::getId, v -> v, (k1, k2) -> k1)); Collectors.toMap(HousingEstateSimpleVO::getId, v -> v, (k1, k2) -> k1));
@ -343,5 +350,6 @@ public class RecycleOrderController {
CommonUtil.assignField(v, "housingEstateInfo", housingEstateMap.get(housingEstateId)); CommonUtil.assignField(v, "housingEstateInfo", housingEstateMap.get(housingEstateId));
}); });
} }
}
} }

@ -34,7 +34,7 @@ public interface IClientAddressService extends IService<ClientAddress> {
* @param addressIds * @param addressIds
* @return List<RecycleOrderProduct> * @return List<RecycleOrderProduct>
*/ */
List<ClientAddress> queryAddressList(Collection<String> addressIds); List<ClientAddress> getAddressListByIds(Collection<String> addressIds);

@ -22,7 +22,12 @@ public interface IPriceProductService extends IService<PriceProduct> {
* *
* @return List<Product> * @return List<Product>
*/ */
List<Product> queryProductList(Collection<String> productIds); List<Product> queryProductList();
/**
* id
* @return List<Product>
*/
List<Product> getProductListByIds(Collection<String> productIds);
} }

@ -48,8 +48,11 @@ public class ClientAddressServiceImpl extends ServiceImpl<ClientAddressMapper, C
@Override @Override
public List<ClientAddress> queryAddressList(Collection<String> addressIds) { public List<ClientAddress> getAddressListByIds(Collection<String> addressIds) {
LambdaQueryWrapperX<ClientAddress> wrapperX = new LambdaQueryWrapperX<>(); LambdaQueryWrapperX<ClientAddress> wrapperX = new LambdaQueryWrapperX<>();
if (CollUtils.isEmpty(addressIds)) {
return CollUtils.emptyList();
}
wrapperX.in(ClientAddress::getId, addressIds); wrapperX.in(ClientAddress::getId, addressIds);
return list(wrapperX); return list(wrapperX);
} }

@ -1,6 +1,7 @@
package cc.yunxi.service.impl; package cc.yunxi.service.impl;
import cc.yunxi.common.exception.BizIllegalException; import cc.yunxi.common.exception.BizIllegalException;
import cc.yunxi.common.utils.CollUtils;
import cc.yunxi.domain.dto.LocationDTO; import cc.yunxi.domain.dto.LocationDTO;
import cc.yunxi.domain.po.HousingEstate; import cc.yunxi.domain.po.HousingEstate;
import cc.yunxi.domain.po.Recycler; import cc.yunxi.domain.po.Recycler;
@ -48,6 +49,9 @@ public class HousingEstateServiceImpl extends ServiceImpl<HousingEstateMapper, H
@Override @Override
public List<HousingEstate> getHousingListByIds(Collection<String> housingIds) { public List<HousingEstate> getHousingListByIds(Collection<String> housingIds) {
LambdaQueryWrapper<HousingEstate> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<HousingEstate> wrapper = new LambdaQueryWrapper<>();
if (CollUtils.isEmpty(housingIds)) {
return CollUtils.emptyList();
}
wrapper.in(HousingEstate::getId, housingIds); wrapper.in(HousingEstate::getId, housingIds);
return this.list(wrapper); return this.list(wrapper);
} }

@ -31,13 +31,20 @@ public class PriceProductServiceImpl extends ServiceImpl<PriceProductMapper, Pri
@Resource @Resource
private ProductMapper productMapper; private ProductMapper productMapper;
@Override
public List<Product> queryProductList() {
LambdaQueryWrapperX<Product> wrapperX = new LambdaQueryWrapperX<>();
return productMapper.selectList(wrapperX);
}
@Override @Override
public List<Product> queryProductList(Collection<String> productIds) { public List<Product> getProductListByIds(Collection<String> productIds) {
LambdaQueryWrapperX<Product> wrapperX = new LambdaQueryWrapperX<>(); LambdaQueryWrapperX<Product> wrapperX = new LambdaQueryWrapperX<>();
if (CollUtils.isNotEmpty(productIds)) { if (CollUtils.isEmpty(productIds)) {
wrapperX.inIfPresent(Product::getId, productIds); return CollUtils.emptyList();
} }
wrapperX.in(Product::getId, productIds);
return productMapper.selectList(wrapperX); return productMapper.selectList(wrapperX);
} }
} }

@ -5,6 +5,7 @@ import cc.yunxi.common.domain.LambdaUpdateWrapperX;
import cc.yunxi.common.exception.BizIllegalException; import cc.yunxi.common.exception.BizIllegalException;
import cc.yunxi.common.exception.DbException; import cc.yunxi.common.exception.DbException;
import cc.yunxi.common.utils.BeanUtils; import cc.yunxi.common.utils.BeanUtils;
import cc.yunxi.common.utils.CollUtils;
import cc.yunxi.domain.po.Client; import cc.yunxi.domain.po.Client;
import cc.yunxi.domain.po.ClientAccountDetail; import cc.yunxi.domain.po.ClientAccountDetail;
import cc.yunxi.domain.po.ClientAddress; import cc.yunxi.domain.po.ClientAddress;
@ -73,6 +74,9 @@ public class RecyclerServiceImpl extends ServiceImpl<RecyclerMapper, Recycler> i
@Override @Override
public List<Recycler> getRecyclerByIds(Collection<String> recyclerIds) { public List<Recycler> getRecyclerByIds(Collection<String> recyclerIds) {
LambdaQueryWrapperX<Recycler> wrapperX = new LambdaQueryWrapperX<>(); LambdaQueryWrapperX<Recycler> wrapperX = new LambdaQueryWrapperX<>();
if (CollUtils.isEmpty(recyclerIds)) {
return CollUtils.emptyList();
}
wrapperX.in(Recycler::getId, recyclerIds); wrapperX.in(Recycler::getId, recyclerIds);
return list(wrapperX); return list(wrapperX);
} }

Loading…
Cancel
Save