食堂进销

This commit is contained in:
zjf committed 2025-05-13 12:44:04 +08:00
1 parent 44ebc15119
commit 0bfcab00fe
4 files changed
+88 -4

No files matched your search

@@ -133,7 +133,7 @@ public class CanteenErpMaterialController {
*/
@Operation(summary = "选择食材分页数据" , description = "选择食材分页数据" )
@GetMapping("/erpMaterialPage" )
public R getErpMaterialPage(@ParameterObject Page page, @RequestParam("name")String name) {
public R getErpMaterialPage(@ParameterObject Page page, @RequestParam(value = "name",required = false)String name) {
return R.ok(canteenErpMaterialService.getErpMaterialPage(page, name));
}
}
@@ -51,7 +51,7 @@ public class CanteenProductionTemplateController {
public R getCanteenProductionTemplatePage(@ParameterObject Page page, @ParameterObject CanteenProductionTemplateEntity canteenProductionTemplate) {
LambdaQueryWrapper<CanteenProductionTemplateEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(StrUtil.isNotBlank(canteenProductionTemplate.getTemplateName()),CanteenProductionTemplateEntity::getTemplateName,canteenProductionTemplate.getTemplateName());
return R.ok(canteenProductionTemplateService.page(page, wrapper));
return R.ok(canteenProductionTemplateService.pageScope(page, wrapper));
}
@@ -120,4 +120,13 @@ public class CanteenProductionTemplateController {
public List<CanteenProductionTemplateEntity> export(CanteenProductionTemplateEntity canteenProductionTemplate,Long[] ids) {
return canteenProductionTemplateService.list(Wrappers.lambdaQuery(canteenProductionTemplate).in(ArrayUtil.isNotEmpty(ids), CanteenProductionTemplateEntity::getId, ids));
}
@Operation(summary = "选择加工菜品模版分页" , description = "选择加工菜品模版分页" )
@GetMapping("/getSelectTemplatePage" )
public R getSelectTemplatePage(@ParameterObject Page page, @RequestParam(value = "name",required = false)String name) {
return R.ok(canteenProductionTemplateService.getSelectTemplatePageScope(page, name));
}
}
@@ -1,5 +1,7 @@
package com.bsd.pjcloud.canteen.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.canteen.vo.erp.ProductTemplateVO;
import com.github.yulichang.extension.mapping.base.MPJDeepService;
import com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateDetailEntity;
@@ -17,4 +19,22 @@ public interface CanteenProductionTemplateService extends MPJDeepService<Canteen
ProductTemplateVO getDetailById(Long id);
/**
* 分页
* @param page
* @param wrapper
* @return
*/
Object pageScope(Page page, LambdaQueryWrapper<CanteenProductionTemplateEntity> wrapper);
/**
* 获取模版分页选择下拉
* @param page
* @param name
* @return
*/
Object getSelectTemplatePageScope(Page page, String name);
}
@@ -1,6 +1,8 @@
package com.bsd.pjcloud.canteen.service.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.canteen.entity.CanteenErpMaterialEntity;
import com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateEntity;
@@ -12,6 +14,8 @@ import com.bsd.pjcloud.canteen.service.CanteenProductionTemplateService;
import com.bsd.pjcloud.canteen.vo.erp.ProductTemplateVO;
import com.bsd.pjcloud.canteen.vo.erp.ProductionTemplateDetailVO;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -20,8 +24,9 @@ import com.bsd.pjcloud.canteen.mapper.CanteenProductionTemplateDetailMapper;
import org.springframework.transaction.annotation.Transactional;
import lombok.RequiredArgsConstructor;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
* 加工模版表
*
@@ -96,4 +101,54 @@ public class CanteenProductionTemplateServiceImpl extends ServiceImpl<CanteenPro
bean.setCanteenProductionTemplateDetailList(productionTemplateDetailVOList);
return bean;
}
@Override
public Object pageScope(Page page, LambdaQueryWrapper<CanteenProductionTemplateEntity> wrapper) {
Page pageData = baseMapper.selectPageByScope(page, wrapper, DataScope.of());
// pageData.getRecords().forEach(item->{
// });
return pageData;
}
@Override
public Object getSelectTemplatePageScope(Page page, String name) {
Page<CanteenProductionTemplateEntity> pageData = baseMapper.selectPageByScope(page, Wrappers.<CanteenProductionTemplateEntity>lambdaQuery().like(StringUtils.isNotBlank(name),CanteenProductionTemplateEntity::getTemplateName, name), DataScope.of());
List<CanteenProductionTemplateEntity> records = pageData.getRecords();
if (CollectionUtils.isEmpty(records)){
return pageData;
}
List<ProductTemplateVO> canteenProductionTemplateVOList = BeanUtils.toBean(records, ProductTemplateVO.class);
Set<Long> distinctIds = canteenProductionTemplateVOList.stream().map(ProductTemplateVO::getDishId).collect(Collectors.toSet());
List<Long> templateIds = canteenProductionTemplateVOList.stream().map(ProductTemplateVO::getId).collect(Collectors.toList());
List<CanteenSpuEntity> canteenSpuEntities = canteenSpuMapper.selectByIds(distinctIds);
Map<Long, CanteenSpuEntity> dishMap = canteenSpuEntities.stream()
.collect(Collectors.toMap(CanteenSpuEntity::getId, entity -> entity));
List<CanteenProductionTemplateDetailEntity> canteenProductionTemplateDetailEntities = canteenProductionTemplateDetailMapper.selectList(Wrappers.<CanteenProductionTemplateDetailEntity>lambdaQuery().in(CanteenProductionTemplateDetailEntity::getTemplateId, templateIds));
Set<Long> materialIds = canteenProductionTemplateDetailEntities.stream().map(CanteenProductionTemplateDetailEntity::getMaterialId).collect(Collectors.toSet());
List<CanteenErpMaterialEntity> canteenErpMaterialEntities = canteenErpMaterialMapper.selectByIds(materialIds);
Map<Long, CanteenErpMaterialEntity> materialMap = canteenErpMaterialEntities.stream()
.collect(Collectors.toMap(CanteenErpMaterialEntity::getId, entity -> entity));
Page<ProductTemplateVO> productTemplateVOPage = new Page<>();
List<ProductionTemplateDetailVO> productionTemplateDetailVOList = BeanUtils.toBean(canteenProductionTemplateDetailEntities, ProductionTemplateDetailVO.class);
productionTemplateDetailVOList.forEach(item->{
item.setMaterialName(materialMap.getOrDefault(item.getMaterialId(), new CanteenErpMaterialEntity()).getName());
});
Map<Long, List<ProductionTemplateDetailVO>> detailMap = productionTemplateDetailVOList.stream()
.collect(Collectors.groupingBy(ProductionTemplateDetailVO::getTemplateId));
canteenProductionTemplateVOList.forEach(item-> {
item.setDishName(dishMap.getOrDefault(item.getDishId(), new CanteenSpuEntity()).getName());
item.setCanteenProductionTemplateDetailList(detailMap.getOrDefault(item.getId(), new ArrayList<>()));
});
productTemplateVOPage.setRecords(canteenProductionTemplateVOList);
productTemplateVOPage.setTotal(pageData.getTotal());
productTemplateVOPage.setPages(pageData.getPages());
productTemplateVOPage.setCurrent(pageData.getCurrent());
return productTemplateVOPage;
}
}