食堂进销

This commit is contained in:
zjf committed 2025-05-12 17:13:06 +08:00
1 parent 612bb85c29
commit 08b84d7cbf
18 files changed
+831

No files matched your search

@@ -0,0 +1,32 @@
package com.bsd.pjcloud.canteen.vo.erp;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class CanteenSpuSimpleVO {
@Schema(description="id")
private Long id;
/**
* 商品名称
*/
@Schema(description="菜品名称")
private String name;
/**
* 商品封面图
*/
@Schema(description="菜品封面图")
private String picUrl;
}
@@ -0,0 +1,54 @@
package com.bsd.pjcloud.canteen.vo.erp;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.baomidou.mybatisplus.annotation.*;
import com.github.yulichang.annotation.EntityMapping;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
@Schema(description = "菜品模版vo")
public class ProductTemplateVO {
/**
* id
*/
@Schema(description="id")
private Long id;
/**
* 模版名称
*/
@Schema(description="模版名称")
private String templateName;
/**
* 菜品id
*/
@Schema(description="菜品id")
private Long dishId;
/**
* 基准产出量(碗)
*/
@Schema(description="基准产出量(碗)")
private Double baseOutput;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
@Schema(description="菜品名称")
private String dishName;
private List<ProductionTemplateDetailVO> canteenProductionTemplateDetailList;
}
@@ -0,0 +1,59 @@
package com.bsd.pjcloud.canteen.vo.erp;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.bsd.pjcloud.common.core.util.TenantTable;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* 加工模版明细表
*
* @author zjf
* @date 2025-05-12 13:53:57
*/
@Data
@Schema(description = "加工模版明细表")
public class ProductionTemplateDetailVO{
/**
* id
*/
@Schema(description="id")
private Long id;
/**
* 模版id
*/
@Schema(description="模版id")
private Long templateId;
/**
* 原料id
*/
@Schema(description="原料id")
private Long materialId;
/**
* 基准用量
*/
@Schema(description="基准用量")
private Double baseUsage;
/**
* 损耗率
*/
@Schema(description="损耗率")
private Double lossRate;
@Schema(description="食材名称")
private String materialName;
}
@@ -0,0 +1,123 @@
package com.bsd.pjcloud.canteen.controller;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateEntity;
import com.bsd.pjcloud.canteen.service.CanteenProductionTemplateService;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
* 加工模版表
*
* @author zjf
* @date 2025-05-12 13:41:26
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/canteenProductionTemplate" )
@Tag(description = "canteenProductionTemplate" , name = "加工模版表管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class CanteenProductionTemplateController {
private final CanteenProductionTemplateService canteenProductionTemplateService;
/**
* 分页查询
* @param page 分页对象
* @param canteenProductionTemplate 加工模版表
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('canteen_canteenProductionTemplate_view')" )
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));
}
/**
* 通过id查询加工模版表
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('canteen_canteenProductionTemplate_view')" )
public R getById(@PathVariable("id" ) Long id) {
return R.ok(canteenProductionTemplateService.getDetailById(id));
}
/**
* 新增加工模版表
* @param canteenProductionTemplate 加工模版表
* @return R
*/
@Operation(summary = "新增加工模版表" , description = "新增加工模版表" )
@SysLog("新增加工模版表" )
@PostMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenProductionTemplate_add')" )
public R save(@RequestBody CanteenProductionTemplateEntity canteenProductionTemplate) {
canteenProductionTemplate.setDeptId(SecurityUtils.getUser().getDeptId());
return R.ok(canteenProductionTemplateService.saveDeep(canteenProductionTemplate));
}
/**
* 修改加工模版表
* @param canteenProductionTemplate 加工模版表
* @return R
*/
@Operation(summary = "修改加工模版表" , description = "修改加工模版表" )
@SysLog("修改加工模版表" )
@PutMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenProductionTemplate_edit')" )
public R updateById(@RequestBody CanteenProductionTemplateEntity canteenProductionTemplate) {
return R.ok(canteenProductionTemplateService.updateDeep(canteenProductionTemplate));
}
/**
* 通过id删除加工模版表
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除加工模版表" , description = "通过id删除加工模版表" )
@SysLog("通过id删除加工模版表" )
@DeleteMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenProductionTemplate_del')" )
public R removeById(@RequestBody Long[] ids) {
return R.ok(canteenProductionTemplateService.removeDeep(ids));
}
/**
* 导出excel 表格
* @param canteenProductionTemplate 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('canteen_canteenProductionTemplate_export')" )
public List<CanteenProductionTemplateEntity> export(CanteenProductionTemplateEntity canteenProductionTemplate,Long[] ids) {
return canteenProductionTemplateService.list(Wrappers.lambdaQuery(canteenProductionTemplate).in(ArrayUtil.isNotEmpty(ids), CanteenProductionTemplateEntity::getId, ids));
}
}
@@ -0,0 +1,119 @@
package com.bsd.pjcloud.canteen.controller;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateDetailEntity;
import com.bsd.pjcloud.canteen.service.CanteenProductionTemplateDetailService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
* 加工模版明细表
*
* @author zjf
* @date 2025-05-12 13:53:57
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/canteenProductionTemplateDetail" )
@Tag(description = "canteenProductionTemplateDetail" , name = "加工模版明细表管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class CanteenProductionTemplateDetailController {
private final CanteenProductionTemplateDetailService canteenProductionTemplateDetailService;
/**
* 分页查询
* @param page 分页对象
* @param canteenProductionTemplateDetail 加工模版明细表
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('canteen_canteenProductionTemplateDetail_view')" )
public R getCanteenProductionTemplateDetailPage(@ParameterObject Page page, @ParameterObject CanteenProductionTemplateDetailEntity canteenProductionTemplateDetail) {
LambdaQueryWrapper<CanteenProductionTemplateDetailEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(canteenProductionTemplateDetailService.page(page, wrapper));
}
/**
* 通过id查询加工模版明细表
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('canteen_canteenProductionTemplateDetail_view')" )
public R getById(@PathVariable("id" ) Long id) {
return R.ok(canteenProductionTemplateDetailService.getById(id));
}
/**
* 新增加工模版明细表
* @param canteenProductionTemplateDetail 加工模版明细表
* @return R
*/
@Operation(summary = "新增加工模版明细表" , description = "新增加工模版明细表" )
@SysLog("新增加工模版明细表" )
@PostMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenProductionTemplateDetail_add')" )
public R save(@RequestBody CanteenProductionTemplateDetailEntity canteenProductionTemplateDetail) {
return R.ok(canteenProductionTemplateDetailService.save(canteenProductionTemplateDetail));
}
/**
* 修改加工模版明细表
* @param canteenProductionTemplateDetail 加工模版明细表
* @return R
*/
@Operation(summary = "修改加工模版明细表" , description = "修改加工模版明细表" )
@SysLog("修改加工模版明细表" )
@PutMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenProductionTemplateDetail_edit')" )
public R updateById(@RequestBody CanteenProductionTemplateDetailEntity canteenProductionTemplateDetail) {
return R.ok(canteenProductionTemplateDetailService.updateById(canteenProductionTemplateDetail));
}
/**
* 通过id删除加工模版明细表
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除加工模版明细表" , description = "通过id删除加工模版明细表" )
@SysLog("通过id删除加工模版明细表" )
@DeleteMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenProductionTemplateDetail_del')" )
public R removeById(@RequestBody Long[] ids) {
return R.ok(canteenProductionTemplateDetailService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param canteenProductionTemplateDetail 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('canteen_canteenProductionTemplateDetail_export')" )
public List<CanteenProductionTemplateDetailEntity> export(CanteenProductionTemplateDetailEntity canteenProductionTemplateDetail,Long[] ids) {
return canteenProductionTemplateDetailService.list(Wrappers.lambdaQuery(canteenProductionTemplateDetail).in(ArrayUtil.isNotEmpty(ids), CanteenProductionTemplateDetailEntity::getId, ids));
}
}
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.canteen.dto.CanteenDailySpuDTO;
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
import com.bsd.pjcloud.canteen.entity.CanteenOnlineSpuEntity;
import com.bsd.pjcloud.canteen.vo.erp.CanteenSpuSimpleVO;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
@@ -58,6 +59,19 @@ public class CanteenSpuController {
}
/**
* 选择菜品分页查询
* 1.生产加工模版选择菜品
* @param page
* @param canteenSpu
* @return
*/
@Operation(summary = "生产加工模版选择菜品分页查询", description = "生产加工模版选择菜品分页查询")
@GetMapping("/getCanteenSpuSimplePage")
public R<Page<CanteenSpuSimpleVO>> getCanteenSpuSimplePage(@ParameterObject Page page, @ParameterObject CanteenSpuEntity canteenSpu) {
return R.ok(canteenSpuService.getCanteenSpuSimplePageScope(page, canteenSpu));
}
/**
* 每日分页查询
*
@@ -0,0 +1,103 @@
package com.bsd.pjcloud.canteen.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
/**
* 加工模版明细表
*
* @author zjf
* @date 2025-05-12 13:53:57
*/
@Data
@TenantTable
@TableName("canteen_production_template_detail")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "加工模版明细表")
public class CanteenProductionTemplateDetailEntity extends Model<CanteenProductionTemplateDetailEntity> {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="id")
private Long id;
/**
* 模版id
*/
@Schema(description="模版id")
private Long templateId;
/**
* 原料id
*/
@Schema(description="原料id")
private Long materialId;
/**
* 部门id
*/
@Schema(description="部门id")
private Long deptId;
/**
* 基准用量
*/
@Schema(description="基准用量")
private Double baseUsage;
/**
* 损耗率
*/
@Schema(description="损耗率")
private Double lossRate;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
/**
* 更新人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新人")
private String updateBy;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新时间")
private LocalDateTime updateTime;
/**
* 是否删除
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="是否删除")
private String delFlag;
/**
* 租户编号
*/
@Schema(description="租户编号")
private Long tenantId;
}
@@ -0,0 +1,104 @@
package com.bsd.pjcloud.canteen.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.github.yulichang.annotation.EntityMapping;
import java.util.List;
/**
* 加工模版表
*
* @author zjf
* @date 2025-05-12 13:41:26
*/
@Data
@TenantTable
@TableName("canteen_production_template")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "加工模版表")
public class CanteenProductionTemplateEntity extends Model<CanteenProductionTemplateEntity> {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="id")
private Long id;
/**
* 模版名称
*/
@Schema(description="模版名称")
private String templateName;
/**
* 菜品id
*/
@Schema(description="菜品id")
private Long dishId;
/**
* 部门id
*/
@Schema(description="部门id")
private Long deptId;
/**
* 基准产出量(碗)
*/
@Schema(description="基准产出量(碗)")
private Double baseOutput;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
/**
* 更新人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新人")
private String updateBy;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新时间")
private LocalDateTime updateTime;
/**
* 是否删除
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="是否删除")
private String delFlag;
/**
* 租户编号
*/
@Schema(description="租户编号")
private Long tenantId;
@ExcelIgnore
@TableField(exist = false)
@EntityMapping(thisField = "id", joinField = "templateId")
private List<CanteenProductionTemplateDetailEntity> canteenProductionTemplateDetailList;
}
@@ -0,0 +1,11 @@
package com.bsd.pjcloud.canteen.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateDetailEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CanteenProductionTemplateDetailMapper extends PjcloudBaseMapper<CanteenProductionTemplateDetailEntity> {
}
@@ -0,0 +1,11 @@
package com.bsd.pjcloud.canteen.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CanteenProductionTemplateMapper extends PjcloudBaseMapper<CanteenProductionTemplateEntity> {
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.canteen.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateDetailEntity;
public interface CanteenProductionTemplateDetailService extends IService<CanteenProductionTemplateDetailEntity> {
}
@@ -0,0 +1,20 @@
package com.bsd.pjcloud.canteen.service;
import com.bsd.pjcloud.canteen.vo.erp.ProductTemplateVO;
import com.github.yulichang.extension.mapping.base.MPJDeepService;
import com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateDetailEntity;
import com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateEntity;
public interface CanteenProductionTemplateService extends MPJDeepService<CanteenProductionTemplateEntity> {
Boolean saveDeep(CanteenProductionTemplateEntity canteenProductionTemplate);
Boolean updateDeep(CanteenProductionTemplateEntity canteenProductionTemplate);
Boolean removeDeep(Long[] ids);
Boolean removeChild(Long[] ids);
ProductTemplateVO getDetailById(Long id);
}
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.canteen.dto.CanteenDailySpuDTO;
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
import com.bsd.pjcloud.canteen.vo.erp.CanteenSpuSimpleVO;
import com.bsd.pjcloud.common.core.util.R;
public interface CanteenSpuService extends IService<CanteenSpuEntity> {
@@ -51,4 +52,6 @@ public interface CanteenSpuService extends IService<CanteenSpuEntity> {
* @return
*/
Object pageDailyScope(Page page, CanteenDailySpuDTO canteenDailySpuDTO);
Page<CanteenSpuSimpleVO> getCanteenSpuSimplePageScope(Page page, CanteenSpuEntity canteenSpu);
}
@@ -0,0 +1,16 @@
package com.bsd.pjcloud.canteen.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateDetailEntity;
import com.bsd.pjcloud.canteen.mapper.CanteenProductionTemplateDetailMapper;
import com.bsd.pjcloud.canteen.service.CanteenProductionTemplateDetailService;
import org.springframework.stereotype.Service;
/**
* 加工模版明细表
*
* @author zjf
* @date 2025-05-12 13:53:57
*/
@Service
public class CanteenProductionTemplateDetailServiceImpl extends ServiceImpl<CanteenProductionTemplateDetailMapper, CanteenProductionTemplateDetailEntity> implements CanteenProductionTemplateDetailService {
}
@@ -0,0 +1,99 @@
package com.bsd.pjcloud.canteen.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.canteen.entity.CanteenErpMaterialEntity;
import com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateEntity;
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
import com.bsd.pjcloud.canteen.mapper.CanteenErpMaterialMapper;
import com.bsd.pjcloud.canteen.mapper.CanteenProductionTemplateMapper;
import com.bsd.pjcloud.canteen.mapper.CanteenSpuMapper;
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 org.springframework.stereotype.Service;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateDetailEntity;
import com.bsd.pjcloud.canteen.mapper.CanteenProductionTemplateDetailMapper;
import org.springframework.transaction.annotation.Transactional;
import lombok.RequiredArgsConstructor;
import java.util.List;
import java.util.Objects;
/**
* 加工模版表
*
* @author zjf
* @date 2025-05-12 13:41:26
*/
@Service
@RequiredArgsConstructor
public class CanteenProductionTemplateServiceImpl extends ServiceImpl<CanteenProductionTemplateMapper, CanteenProductionTemplateEntity> implements CanteenProductionTemplateService {
private final CanteenProductionTemplateDetailMapper canteenProductionTemplateDetailMapper;
private final CanteenSpuMapper canteenSpuMapper;
private final CanteenErpMaterialMapper canteenErpMaterialMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean saveDeep(CanteenProductionTemplateEntity canteenProductionTemplate) {
baseMapper.insert(canteenProductionTemplate);
for (CanteenProductionTemplateDetailEntity canteenProductionTemplateDetail : canteenProductionTemplate.getCanteenProductionTemplateDetailList()) {
canteenProductionTemplateDetail.setTemplateId(canteenProductionTemplate.getId());
canteenProductionTemplateDetailMapper.insert( canteenProductionTemplateDetail);
}
return Boolean.TRUE;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateDeep(CanteenProductionTemplateEntity canteenProductionTemplate) {
baseMapper.updateById(canteenProductionTemplate);
for (CanteenProductionTemplateDetailEntity canteenProductionTemplateDetail : canteenProductionTemplate.getCanteenProductionTemplateDetailList()) {
if (Objects.isNull(canteenProductionTemplateDetail.getId())) {
canteenProductionTemplateDetail.setTemplateId(canteenProductionTemplate.getId());
canteenProductionTemplateDetailMapper.insert(canteenProductionTemplateDetail);
} else {
canteenProductionTemplateDetailMapper.updateById(canteenProductionTemplateDetail);
}
}
return Boolean.TRUE;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean removeDeep(Long[] ids) {
baseMapper.deleteBatchIds(CollUtil.toList(ids));
canteenProductionTemplateDetailMapper.delete(Wrappers.<CanteenProductionTemplateDetailEntity>lambdaQuery().in(CanteenProductionTemplateDetailEntity::getTemplateId, ids));
return Boolean.TRUE;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean removeChild(Long[] ids) {
canteenProductionTemplateDetailMapper.deleteBatchIds(CollUtil.toList(ids));
return Boolean.TRUE;
}
@Override
public ProductTemplateVO getDetailById(Long id) {
CanteenProductionTemplateEntity canteenProductionTemplateEntity = baseMapper.selectById(id);
Long dishId = canteenProductionTemplateEntity.getDishId();
CanteenSpuEntity canteenSpuEntity = canteenSpuMapper.selectById(dishId);
LambdaQueryWrapper<CanteenProductionTemplateDetailEntity> canteenProductionTemplateDetailEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
canteenProductionTemplateDetailEntityLambdaQueryWrapper.eq(CanteenProductionTemplateDetailEntity::getTemplateId, id);
List<CanteenProductionTemplateDetailEntity> canteenProductionTemplateDetailEntities = canteenProductionTemplateDetailMapper.selectList(canteenProductionTemplateDetailEntityLambdaQueryWrapper);
ProductTemplateVO bean = BeanUtils.toBean(canteenProductionTemplateEntity, ProductTemplateVO.class);
bean.setDishName(canteenSpuEntity.getName());
List<ProductionTemplateDetailVO> productionTemplateDetailVOList= BeanUtils.toBean(canteenProductionTemplateDetailEntities, ProductionTemplateDetailVO.class);
for (ProductionTemplateDetailVO productionTemplateDetailVO : productionTemplateDetailVOList) {
Long materialId = productionTemplateDetailVO.getMaterialId();
CanteenErpMaterialEntity canteenErpMaterialEntity = canteenErpMaterialMapper.selectById(materialId);
productionTemplateDetailVO.setMaterialName(canteenErpMaterialEntity.getName());
}
bean.setCanteenProductionTemplateDetailList(productionTemplateDetailVOList);
return bean;
}
}
@@ -17,6 +17,7 @@ import com.bsd.pjcloud.canteen.mapper.CanteenSpuMapper;
import com.bsd.pjcloud.canteen.service.CanteenDailyMenuService;
import com.bsd.pjcloud.canteen.service.CanteenSpuService;
import com.bsd.pjcloud.canteen.vo.ADCanteenSpuListVO;
import com.bsd.pjcloud.canteen.vo.erp.CanteenSpuSimpleVO;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
@@ -133,5 +134,20 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
}
@Override
public Page<CanteenSpuSimpleVO> getCanteenSpuSimplePageScope(Page page, CanteenSpuEntity canteenSpu) {
LambdaQueryWrapper<CanteenSpuEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StrUtil.isNotBlank(canteenSpu.getName()), CanteenSpuEntity::getName, canteenSpu.getName());
wrapper.eq(Objects.nonNull(canteenSpu.getCategoryId()), CanteenSpuEntity::getCategoryId, canteenSpu.getCategoryId());
wrapper.orderByAsc(CanteenSpuEntity::getSort).orderByDesc(CanteenSpuEntity::getId);
Page<CanteenSpuEntity> pageData = baseMapper.selectPageByScope(page, wrapper, DataScope.of());
List<CanteenSpuSimpleVO> canteenSpuSimpleVOList = BeanUtils.toBean(pageData.getRecords(), CanteenSpuSimpleVO.class);
Page<CanteenSpuSimpleVO> canteenSpuSimpleVOPage = new Page<>();
canteenSpuSimpleVOPage.setRecords(canteenSpuSimpleVOList);
org.springframework.beans.BeanUtils.copyProperties(pageData, pageData, "records"); // 复制分页参数
return canteenSpuSimpleVOPage;
}
}
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bsd.pjcloud.canteen.mapper.CanteenProductionTemplateDetailMapper">
<resultMap id="canteenProductionTemplateDetailMap" type="com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateDetailEntity">
<id property="id" column="id"/>
<result property="templateId" column="template_id"/>
<result property="materialId" column="material_id"/>
<result property="deptId" column="dept_id"/>
<result property="baseUsage" column="base_usage"/>
<result property="lossRate" column="loss_rate"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</mapper>
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bsd.pjcloud.canteen.mapper.CanteenProductionTemplateMapper">
<resultMap id="canteenProductionTemplateMap" type="com.bsd.pjcloud.canteen.entity.CanteenProductionTemplateEntity">
<id property="id" column="id"/>
<result property="templateName" column="template_name"/>
<result property="dishId" column="dish_id"/>
<result property="deptId" column="dept_id"/>
<result property="baseOutput" column="base_output"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</mapper>