食材进销分类

This commit is contained in:
zjf committed 2025-05-28 11:38:33 +08:00
1 parent 57ee976fc8
commit ebbb5cc97e
12 files changed
+385 -3

No files matched your search

@@ -41,4 +41,7 @@ public class CanteenErpMaterialSaveDTO {
@Schema(description="采购价格")
private Integer purchasePrice;
@Schema(description="所属分类id")
private Long categoryId;
}
@@ -96,4 +96,8 @@ public class CanteenErpMaterialEntity extends Model<CanteenErpMaterialEntity> {
@Schema(description="采购价格")
private Integer purchasePrice;
@Schema(description="所属分类id")
private Long categoryId;
}
@@ -0,0 +1,17 @@
package com.bsd.pjcloud.canteen.vo.erp;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class CanteenErpCategorySimpleVo {
@Schema(description = "分类id")
private Long id;
@Schema(description = "分类名称")
private String name;
}
@@ -47,4 +47,7 @@ public class CanteenErpMaterialVO {
@Schema(description="采购价格")
private Integer purchasePrice;
@Schema(description="所属分类id")
private Long categoryId;
}
@@ -0,0 +1,141 @@
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.canteen.entity.CanteenCategoryEntity;
import com.bsd.pjcloud.canteen.vo.erp.CanteenErpCategorySimpleVo;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.canteen.entity.CanteenErpCategoryEntity;
import com.bsd.pjcloud.canteen.service.CanteenErpCategoryService;
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-28 11:12:41
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/canteenErpCategory" )
@Tag(description = "canteenErpCategory" , name = "食材分类管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class CanteenErpCategoryController {
private final CanteenErpCategoryService canteenErpCategoryService;
/**
* 分页查询
* @param page 分页对象
* @param canteenErpCategory 食材分类
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('canteen_canteenErpCategory_view')" )
public R getCanteenErpCategoryPage(@ParameterObject Page page, @ParameterObject CanteenErpCategoryEntity canteenErpCategory) {
LambdaQueryWrapper<CanteenErpCategoryEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(StrUtil.isNotBlank(canteenErpCategory.getName()),CanteenErpCategoryEntity::getName,canteenErpCategory.getName());
return R.ok(canteenErpCategoryService.pageScope(page, wrapper));
}
/**
* 通过id查询食材分类
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('canteen_canteenErpCategory_view')" )
public R getById(@PathVariable("id" ) Long id) {
return R.ok(canteenErpCategoryService.getById(id));
}
/**
* 新增食材分类
* @param canteenErpCategory 食材分类
* @return R
*/
@Operation(summary = "新增食材分类" , description = "新增食材分类" )
@SysLog("新增食材分类" )
@PostMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenErpCategory_add')" )
public R save(@RequestBody CanteenErpCategoryEntity canteenErpCategory) {
canteenErpCategory.setDeptId(SecurityUtils.getUser().getDeptId());
return R.ok(canteenErpCategoryService.save(canteenErpCategory));
}
/**
* 修改食材分类
* @param canteenErpCategory 食材分类
* @return R
*/
@Operation(summary = "修改食材分类" , description = "修改食材分类" )
@SysLog("修改食材分类" )
@PutMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenErpCategory_edit')" )
public R updateById(@RequestBody CanteenErpCategoryEntity canteenErpCategory) {
return R.ok(canteenErpCategoryService.updateById(canteenErpCategory));
}
/**
* 通过id删除食材分类
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除食材分类" , description = "通过id删除食材分类" )
@SysLog("通过id删除食材分类" )
@DeleteMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenErpCategory_del')" )
public R removeById(@RequestBody Long[] ids) {
return R.ok(canteenErpCategoryService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param canteenErpCategory 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('canteen_canteenErpCategory_export')" )
public List<CanteenErpCategoryEntity> export(CanteenErpCategoryEntity canteenErpCategory,Long[] ids) {
return canteenErpCategoryService.list(Wrappers.lambdaQuery(canteenErpCategory).in(ArrayUtil.isNotEmpty(ids), CanteenErpCategoryEntity::getId, ids));
}
/**
* 获取所有分类
* @return
*/
@Operation(summary = "下拉查询")
@GetMapping("/simpleAll")
public R getSimpleAll(@RequestParam(value = "id",required = false)Long categoryId) {
List<CanteenErpCategoryEntity> list = canteenErpCategoryService.listScope(categoryId);
List<CanteenErpCategorySimpleVo> bean = BeanUtils.toBean(list, CanteenErpCategorySimpleVo.class);
return R.ok(bean);
}
}
@@ -0,0 +1,115 @@
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-28 11:12:41
*/
@Data
@TenantTable
@TableName("canteen_erp_category")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "食材分类")
public class CanteenErpCategoryEntity extends Model<CanteenErpCategoryEntity> {
/**
* 分类编号
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="分类编号")
private Long id;
/**
* 父分类编号
*/
@Schema(description="父分类编号")
private Long parentId;
/**
* 分类名称
*/
@Schema(description="分类名称")
private String name;
/**
* 分类图
*/
@Schema(description="分类图")
private String picUrl;
/**
* 分类排序
*/
@Schema(description="分类排序")
private Integer sort;
/**
* 开启状态
*/
@Schema(description="开启状态")
private String status;
/**
* 部门id
*/
@Schema(description="部门id")
private Long deptId;
/**
* merchantId
*/
@Schema(description="merchantId")
private Long merchantId;
/**
* 创建者
*/
@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,11 @@
package com.bsd.pjcloud.canteen.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.canteen.entity.CanteenErpCategoryEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CanteenErpCategoryMapper extends PjcloudBaseMapper<CanteenErpCategoryEntity> {
}
@@ -0,0 +1,29 @@
package com.bsd.pjcloud.canteen.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.canteen.entity.CanteenCategoryEntity;
import com.bsd.pjcloud.canteen.entity.CanteenErpCategoryEntity;
import java.util.List;
public interface CanteenErpCategoryService extends IService<CanteenErpCategoryEntity> {
/**
* 分页查询
* @param page
* @param wrapper
* @return
*/
Object pageScope(Page page, LambdaQueryWrapper<CanteenErpCategoryEntity> wrapper);
/**
* 查询下拉分类
* @param categoryId
* @return
*/
List<CanteenErpCategoryEntity> listScope(Long categoryId);
}
@@ -0,0 +1,36 @@
package com.bsd.pjcloud.canteen.service.impl;
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.CanteenCategoryEntity;
import com.bsd.pjcloud.canteen.entity.CanteenErpCategoryEntity;
import com.bsd.pjcloud.canteen.mapper.CanteenErpCategoryMapper;
import com.bsd.pjcloud.canteen.service.CanteenErpCategoryService;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 食材分类
*
* @author zjf
* @date 2025-05-28 11:12:41
*/
@Service
public class CanteenErpCategoryServiceImpl extends ServiceImpl<CanteenErpCategoryMapper, CanteenErpCategoryEntity> implements CanteenErpCategoryService {
@Override
public Object pageScope(Page page, LambdaQueryWrapper<CanteenErpCategoryEntity> wrapper) {
return baseMapper.selectPageByScope(page, wrapper, DataScope.of());
}
@Override
public List<CanteenErpCategoryEntity> listScope(Long categoryId) {
LambdaQueryWrapper<CanteenErpCategoryEntity> wrapper = new LambdaQueryWrapper<>();
if (categoryId != null) {
wrapper.eq(CanteenErpCategoryEntity::getId, categoryId);
}
return baseMapper.selectListByScope(wrapper, DataScope.of());
}
}
@@ -0,0 +1,22 @@
<?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.CanteenErpCategoryMapper">
<resultMap id="canteenErpCategoryMap" type="com.bsd.pjcloud.canteen.entity.CanteenErpCategoryEntity">
<id property="id" column="id"/>
<result property="parentId" column="parent_id"/>
<result property="name" column="name"/>
<result property="picUrl" column="pic_url"/>
<result property="sort" column="sort"/>
<result property="status" column="status"/>
<result property="deptId" column="dept_id"/>
<result property="merchantId" column="merchant_id"/>
<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>
@@ -15,6 +15,7 @@
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
<result property="purchasePrice" column="purchase_price"/>
<result property="categoryId" column="category_id"/>
</resultMap>
<select id="selectPageDataByScope" resultType="com.bsd.pjcloud.canteen.vo.erp.CanteenErpMaterialVO">
SELECT
@@ -25,9 +25,9 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
username: ${MYSQL_USER:root}
password: ${MYSQL_PWD:root}
url: jdbc:mysql://${MYSQL_HOST:pjcloud-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pjcloudx_job}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true
username: ${MYSQL_USER:root@sys}
password: ${MYSQL_PWD:bsd.1799}
url: jdbc:mysql://${MYSQL_HOST:pjcloud-mysql}:${MYSQL_PORT:2881}/${MYSQL_DB:pjcloudx_job}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true
mvc:
static-path-pattern: /static/**
freemarker: