|
|
|
@ -1,11 +1,16 @@
|
|
|
|
package cn.iocoder.yudao.module.iot.service.recipepoint;
|
|
|
|
package cn.iocoder.yudao.module.iot.service.recipepoint;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.recipepoint.vo.*;
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.recipepoint.vo.*;
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.dataobject.recipepoint.RecipePointDO;
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.dataobject.recipepoint.RecipePointDO;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
@ -15,6 +20,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.mysql.recipepoint.RecipePointMapper;
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.mysql.recipepoint.RecipePointMapper;
|
|
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
|
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
|
|
|
|
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -28,6 +34,8 @@ public class RecipePointServiceImpl implements RecipePointService {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private RecipePointMapper recipePointMapper;
|
|
|
|
private RecipePointMapper recipePointMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private ErpProductUnitService productUnitService;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Long createRecipePoint(RecipePointSaveReqVO createReqVO) {
|
|
|
|
public Long createRecipePoint(RecipePointSaveReqVO createReqVO) {
|
|
|
|
@ -63,7 +71,26 @@ public class RecipePointServiceImpl implements RecipePointService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public PageResult<RecipePointDO> getRecipePointPage(RecipePointPageReqVO pageReqVO) {
|
|
|
|
public PageResult<RecipePointDO> getRecipePointPage(RecipePointPageReqVO pageReqVO) {
|
|
|
|
return recipePointMapper.selectPage(pageReqVO);
|
|
|
|
PageResult<RecipePointDO> pageResult = recipePointMapper.selectPage(pageReqVO);
|
|
|
|
|
|
|
|
Set<Long> unitIds = pageResult.getList().stream()
|
|
|
|
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
|
|
|
|
.map(RecipePointDO::getDataUnit)
|
|
|
|
|
|
|
|
.filter(dataUnit -> dataUnit != null && !dataUnit.trim().isEmpty())
|
|
|
|
|
|
|
|
.filter(dataUnit -> dataUnit.matches("\\d+")) // 确保是纯数字
|
|
|
|
|
|
|
|
.map(Long::valueOf)
|
|
|
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
|
|
Map<Long, ErpProductUnitDO> unitMap = productUnitService.getProductUnitMap(unitIds);
|
|
|
|
|
|
|
|
List<RecipePointDO> recipePointDOList = BeanUtils.toBean(pageResult.getList(), RecipePointDO.class, recipePoint -> {
|
|
|
|
|
|
|
|
Long unitId = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
unitId = Long.valueOf(recipePoint.getDataUnit());
|
|
|
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MapUtils.findAndThen(unitMap, unitId,
|
|
|
|
|
|
|
|
unit -> recipePoint.setDataUnitName(unit.getName()));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return new PageResult<>(recipePointDOList, pageResult.getTotal());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
|