diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/constant/InventoryTypeEnum.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/constant/InventoryTypeEnum.java new file mode 100644 index 000000000..405b8ce60 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/constant/InventoryTypeEnum.java @@ -0,0 +1,30 @@ +package com.bsd.pjcloud.canteen.constant; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 入库类型编码前兆 + */ +@AllArgsConstructor +@Getter +public enum InventoryTypeEnum { + + CGRK("1", "CGRK"), + ; + private final String type; + private final String value; + + + // 根据数字返回对应的值 + public static String getValueByType(String type) { + for (InventoryTypeEnum v : InventoryTypeEnum.values()) { + if (v.type.equals(type)) { + return v.value; + } + } + return ""; // 如果没有找到对应的数字 + } + + +} diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/constant/OrderTypeEnum.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/constant/OrderTypeEnum.java new file mode 100644 index 000000000..8b8d4e247 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/constant/OrderTypeEnum.java @@ -0,0 +1,22 @@ +package com.bsd.pjcloud.canteen.constant; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 出库入口 + */ +@AllArgsConstructor +@Getter +public enum OrderTypeEnum { + + RK("1", "入库"), + CK("2", "出库"), + No("0", "无盈亏") + ; + private final String type; + private final String description; + + + +} diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenErpMaterialEditorDTO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenErpMaterialEditorDTO.java new file mode 100644 index 000000000..3b7e1bf82 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenErpMaterialEditorDTO.java @@ -0,0 +1,10 @@ +package com.bsd.pjcloud.canteen.dto.erp; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class CanteenErpMaterialEditorDTO extends CanteenErpMaterialSaveDTO { + + private Long id; +} diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenErpMaterialSaveDTO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenErpMaterialSaveDTO.java new file mode 100644 index 000000000..78908eef7 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenErpMaterialSaveDTO.java @@ -0,0 +1,40 @@ +package com.bsd.pjcloud.canteen.dto.erp; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class CanteenErpMaterialSaveDTO { + + /** + * 商品名称 + */ + @Schema(description="商品名称") + private String name; + + /** + * 商品单位 + */ + @Schema(description="商品单位") + private String unit; + + + /** + * 期初数量 + */ + @Schema(description="期初数量") + private Double baseStock; + + + /** + * 库存上限 + */ + @Schema(description="库存上限") + private Integer inventoryUpperLimit; + + /** + * 库存下限 + */ + @Schema(description="库存下限") + private Integer inventoryLowerLimit; +} diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenInventoryRecordsItemDTO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenInventoryRecordsItemDTO.java new file mode 100644 index 000000000..2cd1cd854 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenInventoryRecordsItemDTO.java @@ -0,0 +1,97 @@ +package com.bsd.pjcloud.canteen.dto.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-07 17:02:53 + */ +@Data +@Schema(description = "采购记录明细表") +public class CanteenInventoryRecordsItemDTO { + + + /** + * 原料id + */ + @Schema(description="原料id") + private Long erpMaterialId; + + + /** + * 出入库数量 + */ + @Schema(description="出入库数量") + private Double quantity; + + /** + * 单价 + */ + @Schema(description="单价") + private Integer unitPrice; + + /** + * 总金额 + */ + @Schema(description="总金额") + private Integer totalAmount; + + /** + * 税率% + */ + @Schema(description="税率%") + private Integer taxRate; + + /** + * 税前金额 + */ + @Schema(description="税前金额") + private Integer taxAmount; + + /** + * 货商 + */ + @Schema(description="货商") + private Long supplierId; + + /** + * 备注 + */ + @Schema(description="备注") + private String remark; + + /** + * 订单类型(1入库 2出库) + */ + @Schema(description="订单类型(1入库 2出库)") + private String orderType; + + /** + * 出入库关联id + */ + @Schema(description="出入库关联id") + private Long inventoryId; + + /** + * 总数 + */ + @Schema(description="总数") + private Integer totalNumber; + + + /** + * 实际单价 + */ + @Schema(description="实际单价") + private Integer realPrice; + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenInventoryRecordsdDTO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenInventoryRecordsdDTO.java new file mode 100644 index 000000000..a8af8727d --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/CanteenInventoryRecordsdDTO.java @@ -0,0 +1,73 @@ +package com.bsd.pjcloud.canteen.dto.erp; + + +import com.baomidou.mybatisplus.annotation.*; +import com.bsd.pjcloud.canteen.entity.CanteenInventoryRecordsItemEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; + +@Data +public class CanteenInventoryRecordsdDTO { + + + /** + * 单据编号(规则生成,出入库编号) + */ + @Schema(description="单据编号(规则生成,出入库编号)") + private String inventoryCode; + + /** + * 单据日期 + */ + @Schema(description="单据日期") + private LocalDate inventoryDate; + + /** + * 单据类型(字典inventory_type)采购入库 + */ + @Schema(description="单据类型采购入库=1") + private String inventoryType; + + + /** + * 经办人id + */ + @Schema(description="经办人id") + private Long handlerUserId; + + + /** + * 货商 + */ + @Schema(description="货商") + private Long supplierId; + + /** + * 备注 + */ + @Schema(description="备注") + private String remark; + + /** + * 订单类型(1入库 2出库) + */ + @Schema(description="订单类型(1入库 2出库)") + private String orderType; + + /** + * 入库总金额 + */ + @Schema(description="入库总金额") + private Integer totalAmount; + + + + @Schema(description="入库明细") + private List canteenInventoryRecordsItemDTOS; + + +} diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/UpdateStockDTO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/UpdateStockDTO.java new file mode 100644 index 000000000..5db2b7532 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/dto/erp/UpdateStockDTO.java @@ -0,0 +1,35 @@ +package com.bsd.pjcloud.canteen.dto.erp; + +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 更新库存 DTO + * + * @author LeeYan9 + * @since 2022-08-26 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UpdateStockDTO { + + /** + * 商品 SKU 编号 + */ + @NotNull(message = "商品 SPU 编号不能为空") + private Long id; + + /** + * 库存变化数量 + * + * 正数:增加库存 + * 负数:扣减库存 + */ + @NotNull(message = "库存变化数量不能为空") + private Double incrCount; + + +} diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenErpMaterialEntity.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenErpMaterialEntity.java similarity index 99% rename from pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenErpMaterialEntity.java rename to pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenErpMaterialEntity.java index e262f1abf..da4d71057 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenErpMaterialEntity.java +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenErpMaterialEntity.java @@ -88,4 +88,7 @@ public class CanteenErpMaterialEntity extends Model { */ @Schema(description="租户编号") private Long tenantId; + + + } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenInventoryRecordsEntity.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenInventoryRecordsEntity.java similarity index 100% rename from pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenInventoryRecordsEntity.java rename to pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenInventoryRecordsEntity.java diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenInventoryRecordsItemEntity.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenInventoryRecordsItemEntity.java similarity index 99% rename from pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenInventoryRecordsItemEntity.java rename to pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenInventoryRecordsItemEntity.java index 9c100f0a5..02c0d0ec8 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenInventoryRecordsItemEntity.java +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenInventoryRecordsItemEntity.java @@ -57,7 +57,7 @@ public class CanteenInventoryRecordsItemEntity extends Model { + + + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description="id") + private Long id; + + /** + * 加工日期 + */ + @Schema(description="加工日期") + private LocalDateTime productionTime; + + /** + * 加工人 + */ + @Schema(description="加工人") + private String handlerUser; + + /** + * 主id + */ + @Schema(description="主id") + private Long recordId; + + /** + * 加工批次号 + */ + @Schema(description="加工批次号") + private String recordCode; + + /** + * 备注 + */ + @Schema(description="备注") + private String remark; + + /** + * 部门id + */ + @Schema(description="部门id") + private Long deptId; + + /** + * 创建人 + */ + @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; +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenProductionRecordItemEntity.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenProductionRecordItemEntity.java new file mode 100644 index 000000000..a09c74bc2 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenProductionRecordItemEntity.java @@ -0,0 +1,121 @@ +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-08 11:05:02 + */ +@Data +@TenantTable +@TableName("canteen_production_record_item") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "食材加工记录明细表") +public class CanteenProductionRecordItemEntity extends Model { + + + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description="id") + private Long id; + + /** + * 关系表菜品id + */ + @Schema(description="关系表菜品id") + private Long itemRelationId; + + /** + * 食材id + */ + @Schema(description="食材id") + private Long materialId; + + /** + * 实际消耗原料量数量 + */ + @Schema(description="实际消耗原料量数量") + private Double inputQuantity; + + /** + * 实际产出菜品量 + */ + @Schema(description="实际产出菜品量") + private Double outputQuantity; + + /** + * 主id + */ + @Schema(description="主id") + private Long recordId; + + /** + * 备注 + */ + @Schema(description="备注") + private String remark; + + /** + * 折损率 + */ + @Schema(description="折损率") + private Double lossRate; + + /** + * 部门id + */ + @Schema(description="部门id") + private Long deptId; + + /** + * 创建人 + */ + @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; +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenStockEntity.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenStockEntity.java similarity index 96% rename from pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenStockEntity.java rename to pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenStockEntity.java index 7f06ce3ad..195537222 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenStockEntity.java +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/CanteenStockEntity.java @@ -53,12 +53,6 @@ public class CanteenStockEntity extends Model { @Schema(description="乐观锁版本号") private Integer version; - /** - * 部门id - */ - @Schema(description="部门id") - private Long deptId; - /** * 库存上限 */ diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/ProductionRecordItemRelationEntity.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/ProductionRecordItemRelationEntity.java new file mode 100644 index 000000000..2e0178da5 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/entity/ProductionRecordItemRelationEntity.java @@ -0,0 +1,40 @@ +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; + +/** + * 食材加工菜品关系表 + * + * @author zjf + * @date 2025-05-08 11:05:33 + */ +@Data +@TableName("production_record_item_relation") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "食材加工菜品关系表") +public class ProductionRecordItemRelationEntity extends Model { + + + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description="id") + private Long id; + + /** + * 菜品id + */ + @Schema(description="菜品id") + private Long dishId; + + /** + * 记录item表id + */ + @Schema(description="记录item表id") + private Long recordItemId; +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenErpMaterialVO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenErpMaterialVO.java new file mode 100644 index 000000000..57b79cb6e --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenErpMaterialVO.java @@ -0,0 +1,46 @@ +package com.bsd.pjcloud.canteen.vo.erp; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class CanteenErpMaterialVO { + + private Long id; + + /** + * 商品名称 + */ + @Schema(description="商品名称") + private String name; + + /** + * 商品单位 + */ + @Schema(description="商品单位") + private String unit; + + + /** + * 期初数量 + */ + @Schema(description="期初数量") + private Double baseStock; + + + /** + * 库存上限 + */ + @Schema(description="库存上限") + private Integer inventoryUpperLimit; + + /** + * 库存下限 + */ + @Schema(description="库存下限") + private Integer inventoryLowerLimit; + + + @Schema(description="当前总库存") + private Double currentStock; +} diff --git a/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenProductionRecordPageVO.java b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenProductionRecordPageVO.java new file mode 100644 index 000000000..1a5eeb2bf --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-api/src/main/java/com/bsd/pjcloud/canteen/vo/erp/CanteenProductionRecordPageVO.java @@ -0,0 +1,70 @@ +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; + +/** + * 食材加工记录表 + * + * @author zjf + * @date 2025-05-08 11:02:09 + */ +@Data +@Schema(description = "食材加工记录表vo") +public class CanteenProductionRecordPageVO { + + + /** + * id + */ + @Schema(description="id") + private Long id; + + /** + * 加工日期 + */ + @Schema(description="加工日期") + private LocalDateTime productionTime; + + /** + * 加工人 + */ + @Schema(description="加工人") + private String handlerUser; + + /** + * 主id + */ + @Schema(description="主id") + private Long recordId; + + /** + * 加工批次号 + */ + @Schema(description="加工批次号") + private String recordCode; + + /** + * 备注 + */ + @Schema(description="备注") + private String remark; + + + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description="创建人") + private String createBy; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description="创建时间") + private LocalDateTime createTime; +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/pom.xml b/pjcloud-canteen/pjcloud-canteen-biz/pom.xml index fd559cc8c..afafa6356 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/pom.xml +++ b/pjcloud-canteen/pjcloud-canteen-biz/pom.xml @@ -14,7 +14,18 @@ + + org.springframework.retry + spring-retry + 1.3.4 + + + + com.bsd + pjcloud-common-sequence + 5.7.0 + com.bsd diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenCommonController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenCommonController.java new file mode 100644 index 000000000..bfeb1590e --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenCommonController.java @@ -0,0 +1,49 @@ +package com.bsd.pjcloud.canteen.controller; + +import com.bsd.pjcloud.canteen.constant.InventoryTypeEnum; +import com.bsd.pjcloud.common.core.util.R; +import com.bsd.pjcloud.common.sequence.sequence.Sequence; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * 超市公共接口 + * + * @author pjcloud + * @date 2025-02-10 12:15:37 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/canteen/common" ) +@Tag(description = "食堂公共部分接口" , name = "食堂公共部分接口" ) +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class CanteenCommonController { + + @Autowired + private Sequence sequence; + + /** + * 采购计划选择商品分页数据 + * 分页查询 + * @param type @link InventoryTypeEnum + * @return + */ + @Operation(summary = "获取业务流水编号" , description = "获取业务流水编号" ) + @GetMapping("/getSequence") + public R getErpSpuPage(@RequestParam("type")String type) { + String valueByType = InventoryTypeEnum.getValueByType(type); + String s = sequence.nextNo(); + String result = valueByType + "-" + s; + return R.ok(result); + } + + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenErpMaterialController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenErpMaterialController.java index dc8d16376..635284e16 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenErpMaterialController.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenErpMaterialController.java @@ -5,6 +5,10 @@ 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.dto.erp.CanteenErpMaterialEditorDTO; +import com.bsd.pjcloud.canteen.dto.erp.CanteenErpMaterialSaveDTO; +import com.bsd.pjcloud.canteen.entity.CanteenStockEntity; +import com.bsd.pjcloud.canteen.service.CanteenStockService; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.log.annotation.SysLog; import com.bsd.pjcloud.canteen.entity.CanteenErpMaterialEntity; @@ -17,10 +21,10 @@ 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.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List; -import java.util.Objects; /** * 原料表 @@ -37,6 +41,8 @@ public class CanteenErpMaterialController { private final CanteenErpMaterialService canteenErpMaterialService; + private final CanteenStockService canteenStockService; + /** * 分页查询 * @param page 分页对象 @@ -47,8 +53,7 @@ public class CanteenErpMaterialController { @GetMapping("/page" ) @PreAuthorize("@pms.hasPermission('canteen_canteenErpMaterial_view')" ) public R getCanteenErpMaterialPage(@ParameterObject Page page, @ParameterObject CanteenErpMaterialEntity canteenErpMaterial) { - LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); - return R.ok(canteenErpMaterialService.page(page, wrapper)); + return R.ok(canteenErpMaterialService.pageScope(page, canteenErpMaterial)); } @@ -61,33 +66,32 @@ public class CanteenErpMaterialController { @GetMapping("/{id}" ) @PreAuthorize("@pms.hasPermission('canteen_canteenErpMaterial_view')" ) public R getById(@PathVariable("id" ) Long id) { - return R.ok(canteenErpMaterialService.getById(id)); + return R.ok(canteenErpMaterialService.getCanteenErpMaterialVOById(id)); } /** * 新增原料表 - * @param canteenErpMaterial 原料表 + * @param * @return R */ @Operation(summary = "新增原料表" , description = "新增原料表" ) @SysLog("新增原料表" ) @PostMapping @PreAuthorize("@pms.hasPermission('canteen_canteenErpMaterial_add')" ) - public R save(@RequestBody CanteenErpMaterialEntity canteenErpMaterial) { - return R.ok(canteenErpMaterialService.save(canteenErpMaterial)); + public R save(@RequestBody CanteenErpMaterialSaveDTO canteenErpMaterialSaveDTO) { + return R.ok(canteenErpMaterialService.saveCanteenErpMaterialDTO(canteenErpMaterialSaveDTO)); } /** * 修改原料表 - * @param canteenErpMaterial 原料表 * @return R */ @Operation(summary = "修改原料表" , description = "修改原料表" ) @SysLog("修改原料表" ) @PutMapping @PreAuthorize("@pms.hasPermission('canteen_canteenErpMaterial_edit')" ) - public R updateById(@RequestBody CanteenErpMaterialEntity canteenErpMaterial) { - return R.ok(canteenErpMaterialService.updateById(canteenErpMaterial)); + public R updateById(@RequestBody CanteenErpMaterialEditorDTO canteenErpMaterialEditorDTO) { + return R.ok(canteenErpMaterialService.updateById(canteenErpMaterialEditorDTO)); } /** @@ -98,9 +102,12 @@ public class CanteenErpMaterialController { @Operation(summary = "通过id删除原料表" , description = "通过id删除原料表" ) @SysLog("通过id删除原料表" ) @DeleteMapping - @PreAuthorize("@pms.hasPermission('canteen_canteenErpMaterial_del')" ) + @PreAuthorize("@pms.hasPermission('canteen_canteenErpMaterial_del')") + @Transactional public R removeById(@RequestBody Long[] ids) { - return R.ok(canteenErpMaterialService.removeBatchByIds(CollUtil.toList(ids))); + boolean b = canteenErpMaterialService.removeBatchByIds(CollUtil.toList(ids)); + canteenStockService.remove(Wrappers.lambdaQuery(CanteenStockEntity.class).in(CanteenStockEntity::getItemId, ids)); + return R.ok(b); } diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenInventoryRecordsController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenInventoryRecordsController.java index fd32649aa..d9711227c 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenInventoryRecordsController.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenInventoryRecordsController.java @@ -6,6 +6,7 @@ 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.dto.erp.CanteenInventoryRecordsdDTO; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.log.annotation.SysLog; import com.bsd.pjcloud.canteen.entity.CanteenInventoryRecordsEntity; @@ -48,10 +49,10 @@ public class CanteenInventoryRecordsController { @GetMapping("/page" ) @PreAuthorize("@pms.hasPermission('canteen_canteenInventoryRecords_view')" ) public R getCanteenInventoryRecordsPage(@ParameterObject Page page, @ParameterObject CanteenInventoryRecordsEntity canteenInventoryRecords) { - LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); - wrapper.eq(StrUtil.isNotBlank(canteenInventoryRecords.getInventoryCode()),CanteenInventoryRecordsEntity::getInventoryCode,canteenInventoryRecords.getInventoryCode()); - wrapper.eq(Objects.nonNull(canteenInventoryRecords.getInventoryDate()),CanteenInventoryRecordsEntity::getInventoryDate,canteenInventoryRecords.getInventoryDate()); - return R.ok(canteenInventoryRecordsService.page(page, wrapper)); +// LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); +// wrapper.eq(StrUtil.isNotBlank(canteenInventoryRecords.getInventoryCode()),CanteenInventoryRecordsEntity::getInventoryCode,canteenInventoryRecords.getInventoryCode()); +// wrapper.eq(Objects.nonNull(canteenInventoryRecords.getInventoryDate()),CanteenInventoryRecordsEntity::getInventoryDate,canteenInventoryRecords.getInventoryDate()); + return R.ok(canteenInventoryRecordsService.pageScope(page, canteenInventoryRecords)); } @@ -69,15 +70,15 @@ public class CanteenInventoryRecordsController { /** * 新增采购记录表 - * @param canteenInventoryRecords 采购记录表 + * @param canteenInventoryRecordsdDTO 采购记录表 * @return R */ @Operation(summary = "新增采购记录表" , description = "新增采购记录表" ) @SysLog("新增采购记录表" ) @PostMapping @PreAuthorize("@pms.hasPermission('canteen_canteenInventoryRecords_add')" ) - public R save(@RequestBody CanteenInventoryRecordsEntity canteenInventoryRecords) { - return R.ok(canteenInventoryRecordsService.save(canteenInventoryRecords)); + public R save(@RequestBody CanteenInventoryRecordsdDTO canteenInventoryRecordsdDTO) { + return R.ok(canteenInventoryRecordsService.saveCanteenInventoryRecordsdDTO(canteenInventoryRecordsdDTO)); } /** diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenProductionRecordController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenProductionRecordController.java new file mode 100644 index 000000000..77098357e --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenProductionRecordController.java @@ -0,0 +1,122 @@ +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.CanteenProductionRecordEntity; +import com.bsd.pjcloud.canteen.service.CanteenProductionRecordService; +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-08 11:02:09 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/canteenProductionRecord" ) +@Tag(description = "canteenProductionRecord" , name = "食材加工记录表管理" ) +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class CanteenProductionRecordController { + + private final CanteenProductionRecordService canteenProductionRecordService; + + /** + * 分页查询 + * @param page 分页对象 + * @param canteenProductionRecord 食材加工记录表 + * @return + */ + @Operation(summary = "分页查询" , description = "分页查询" ) + @GetMapping("/page" ) + @PreAuthorize("@pms.hasPermission('canteen_canteenProductionRecord_view')" ) + public R getCanteenProductionRecordPage(@ParameterObject Page page, @ParameterObject CanteenProductionRecordEntity canteenProductionRecord) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(Objects.nonNull(canteenProductionRecord.getProductionTime()),CanteenProductionRecordEntity::getProductionTime,canteenProductionRecord.getProductionTime()); + wrapper.eq(StrUtil.isNotBlank(canteenProductionRecord.getRecordCode()),CanteenProductionRecordEntity::getRecordCode,canteenProductionRecord.getRecordCode()); + return R.ok(canteenProductionRecordService.page(page, wrapper)); + } + + + /** + * 通过id查询食材加工记录表 + * @param id id + * @return R + */ + @Operation(summary = "通过id查询" , description = "通过id查询" ) + @GetMapping("/{id}" ) + @PreAuthorize("@pms.hasPermission('canteen_canteenProductionRecord_view')" ) + public R getById(@PathVariable("id" ) Long id) { + return R.ok(canteenProductionRecordService.getById(id)); + } + + /** + * 新增食材加工记录表 + * @param canteenProductionRecord 食材加工记录表 + * @return R + */ + @Operation(summary = "新增食材加工记录表" , description = "新增食材加工记录表" ) + @SysLog("新增食材加工记录表" ) + @PostMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenProductionRecord_add')" ) + public R save(@RequestBody CanteenProductionRecordEntity canteenProductionRecord) { + return R.ok(canteenProductionRecordService.save(canteenProductionRecord)); + } + + /** + * 修改食材加工记录表 + * @param canteenProductionRecord 食材加工记录表 + * @return R + */ + @Operation(summary = "修改食材加工记录表" , description = "修改食材加工记录表" ) + @SysLog("修改食材加工记录表" ) + @PutMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenProductionRecord_edit')" ) + public R updateById(@RequestBody CanteenProductionRecordEntity canteenProductionRecord) { + return R.ok(canteenProductionRecordService.updateById(canteenProductionRecord)); + } + + /** + * 通过id删除食材加工记录表 + * @param ids id列表 + * @return R + */ + @Operation(summary = "通过id删除食材加工记录表" , description = "通过id删除食材加工记录表" ) + @SysLog("通过id删除食材加工记录表" ) + @DeleteMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenProductionRecord_del')" ) + public R removeById(@RequestBody Long[] ids) { + return R.ok(canteenProductionRecordService.removeBatchByIds(CollUtil.toList(ids))); + } + + + /** + * 导出excel 表格 + * @param canteenProductionRecord 查询条件 + * @param ids 导出指定ID + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('canteen_canteenProductionRecord_export')" ) + public List export(CanteenProductionRecordEntity canteenProductionRecord,Long[] ids) { + return canteenProductionRecordService.list(Wrappers.lambdaQuery(canteenProductionRecord).in(ArrayUtil.isNotEmpty(ids), CanteenProductionRecordEntity::getId, ids)); + } +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenProductionRecordItemController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenProductionRecordItemController.java new file mode 100644 index 000000000..9d0d058e5 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/CanteenProductionRecordItemController.java @@ -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.CanteenProductionRecordItemEntity; +import com.bsd.pjcloud.canteen.service.CanteenProductionRecordItemService; +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-08 11:05:02 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/canteenProductionRecordItem" ) +@Tag(description = "canteenProductionRecordItem" , name = "食材加工记录明细表管理" ) +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class CanteenProductionRecordItemController { + + private final CanteenProductionRecordItemService canteenProductionRecordItemService; + + /** + * 分页查询 + * @param page 分页对象 + * @param canteenProductionRecordItem 食材加工记录明细表 + * @return + */ + @Operation(summary = "分页查询" , description = "分页查询" ) + @GetMapping("/page" ) + @PreAuthorize("@pms.hasPermission('canteen_canteenProductionRecordItem_view')" ) + public R getCanteenProductionRecordItemPage(@ParameterObject Page page, @ParameterObject CanteenProductionRecordItemEntity canteenProductionRecordItem) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + return R.ok(canteenProductionRecordItemService.page(page, wrapper)); + } + + + /** + * 通过id查询食材加工记录明细表 + * @param id id + * @return R + */ + @Operation(summary = "通过id查询" , description = "通过id查询" ) + @GetMapping("/{id}" ) + @PreAuthorize("@pms.hasPermission('canteen_canteenProductionRecordItem_view')" ) + public R getById(@PathVariable("id" ) Long id) { + return R.ok(canteenProductionRecordItemService.getById(id)); + } + + /** + * 新增食材加工记录明细表 + * @param canteenProductionRecordItem 食材加工记录明细表 + * @return R + */ + @Operation(summary = "新增食材加工记录明细表" , description = "新增食材加工记录明细表" ) + @SysLog("新增食材加工记录明细表" ) + @PostMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenProductionRecordItem_add')" ) + public R save(@RequestBody CanteenProductionRecordItemEntity canteenProductionRecordItem) { + return R.ok(canteenProductionRecordItemService.save(canteenProductionRecordItem)); + } + + /** + * 修改食材加工记录明细表 + * @param canteenProductionRecordItem 食材加工记录明细表 + * @return R + */ + @Operation(summary = "修改食材加工记录明细表" , description = "修改食材加工记录明细表" ) + @SysLog("修改食材加工记录明细表" ) + @PutMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenProductionRecordItem_edit')" ) + public R updateById(@RequestBody CanteenProductionRecordItemEntity canteenProductionRecordItem) { + return R.ok(canteenProductionRecordItemService.updateById(canteenProductionRecordItem)); + } + + /** + * 通过id删除食材加工记录明细表 + * @param ids id列表 + * @return R + */ + @Operation(summary = "通过id删除食材加工记录明细表" , description = "通过id删除食材加工记录明细表" ) + @SysLog("通过id删除食材加工记录明细表" ) + @DeleteMapping + @PreAuthorize("@pms.hasPermission('canteen_canteenProductionRecordItem_del')" ) + public R removeById(@RequestBody Long[] ids) { + return R.ok(canteenProductionRecordItemService.removeBatchByIds(CollUtil.toList(ids))); + } + + + /** + * 导出excel 表格 + * @param canteenProductionRecordItem 查询条件 + * @param ids 导出指定ID + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('canteen_canteenProductionRecordItem_export')" ) + public List export(CanteenProductionRecordItemEntity canteenProductionRecordItem,Long[] ids) { + return canteenProductionRecordItemService.list(Wrappers.lambdaQuery(canteenProductionRecordItem).in(ArrayUtil.isNotEmpty(ids), CanteenProductionRecordItemEntity::getId, ids)); + } +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/ProductionRecordItemRelationController.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/ProductionRecordItemRelationController.java new file mode 100644 index 000000000..32cc24f33 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/controller/ProductionRecordItemRelationController.java @@ -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.ProductionRecordItemRelationEntity; +import com.bsd.pjcloud.canteen.service.ProductionRecordItemRelationService; +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-08 11:05:33 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/productionRecordItemRelation" ) +@Tag(description = "productionRecordItemRelation" , name = "食材加工菜品关系表管理" ) +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class ProductionRecordItemRelationController { + + private final ProductionRecordItemRelationService productionRecordItemRelationService; + + /** + * 分页查询 + * @param page 分页对象 + * @param productionRecordItemRelation 食材加工菜品关系表 + * @return + */ + @Operation(summary = "分页查询" , description = "分页查询" ) + @GetMapping("/page" ) + @PreAuthorize("@pms.hasPermission('canteen_productionRecordItemRelation_view')" ) + public R getProductionRecordItemRelationPage(@ParameterObject Page page, @ParameterObject ProductionRecordItemRelationEntity productionRecordItemRelation) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + return R.ok(productionRecordItemRelationService.page(page, wrapper)); + } + + + /** + * 通过id查询食材加工菜品关系表 + * @param id id + * @return R + */ + @Operation(summary = "通过id查询" , description = "通过id查询" ) + @GetMapping("/{id}" ) + @PreAuthorize("@pms.hasPermission('canteen_productionRecordItemRelation_view')" ) + public R getById(@PathVariable("id" ) Long id) { + return R.ok(productionRecordItemRelationService.getById(id)); + } + + /** + * 新增食材加工菜品关系表 + * @param productionRecordItemRelation 食材加工菜品关系表 + * @return R + */ + @Operation(summary = "新增食材加工菜品关系表" , description = "新增食材加工菜品关系表" ) + @SysLog("新增食材加工菜品关系表" ) + @PostMapping + @PreAuthorize("@pms.hasPermission('canteen_productionRecordItemRelation_add')" ) + public R save(@RequestBody ProductionRecordItemRelationEntity productionRecordItemRelation) { + return R.ok(productionRecordItemRelationService.save(productionRecordItemRelation)); + } + + /** + * 修改食材加工菜品关系表 + * @param productionRecordItemRelation 食材加工菜品关系表 + * @return R + */ + @Operation(summary = "修改食材加工菜品关系表" , description = "修改食材加工菜品关系表" ) + @SysLog("修改食材加工菜品关系表" ) + @PutMapping + @PreAuthorize("@pms.hasPermission('canteen_productionRecordItemRelation_edit')" ) + public R updateById(@RequestBody ProductionRecordItemRelationEntity productionRecordItemRelation) { + return R.ok(productionRecordItemRelationService.updateById(productionRecordItemRelation)); + } + + /** + * 通过id删除食材加工菜品关系表 + * @param ids id列表 + * @return R + */ + @Operation(summary = "通过id删除食材加工菜品关系表" , description = "通过id删除食材加工菜品关系表" ) + @SysLog("通过id删除食材加工菜品关系表" ) + @DeleteMapping + @PreAuthorize("@pms.hasPermission('canteen_productionRecordItemRelation_del')" ) + public R removeById(@RequestBody Long[] ids) { + return R.ok(productionRecordItemRelationService.removeBatchByIds(CollUtil.toList(ids))); + } + + + /** + * 导出excel 表格 + * @param productionRecordItemRelation 查询条件 + * @param ids 导出指定ID + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('canteen_productionRecordItemRelation_export')" ) + public List export(ProductionRecordItemRelationEntity productionRecordItemRelation,Long[] ids) { + return productionRecordItemRelationService.list(Wrappers.lambdaQuery(productionRecordItemRelation).in(ArrayUtil.isNotEmpty(ids), ProductionRecordItemRelationEntity::getId, ids)); + } +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenErpMaterialMapper.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenErpMaterialMapper.java index 4b837959c..d0dd3166c 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenErpMaterialMapper.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenErpMaterialMapper.java @@ -1,11 +1,17 @@ package com.bsd.pjcloud.canteen.mapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsd.pjcloud.canteen.vo.erp.CanteenErpMaterialVO; +import com.bsd.pjcloud.common.data.datascope.DataScope; import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; import com.bsd.pjcloud.canteen.entity.CanteenErpMaterialEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; @Mapper public interface CanteenErpMaterialMapper extends PjcloudBaseMapper { + + Page selectPageDataByScope(Page page, @Param("canteenErpMaterial") CanteenErpMaterialEntity canteenErpMaterial, DataScope of); } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenInventoryRecordsMapper.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenInventoryRecordsMapper.java index 0b0d8aa5e..2c4452d34 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenInventoryRecordsMapper.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenInventoryRecordsMapper.java @@ -1,11 +1,23 @@ package com.bsd.pjcloud.canteen.mapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsd.pjcloud.canteen.vo.erp.CanteenProductionRecordPageVO; +import com.bsd.pjcloud.common.data.datascope.DataScope; import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; import com.bsd.pjcloud.canteen.entity.CanteenInventoryRecordsEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; @Mapper public interface CanteenInventoryRecordsMapper extends PjcloudBaseMapper { + /** + * 分页查询 + * @param page + * @param canteenInventoryRecords + * @param of + * @return + */ + Page selectPageDataByScope(Page page, @Param("canteenInventoryRecords") CanteenInventoryRecordsEntity canteenInventoryRecords, DataScope of); } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenProductionRecordItemMapper.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenProductionRecordItemMapper.java new file mode 100644 index 000000000..c57ea9c8f --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenProductionRecordItemMapper.java @@ -0,0 +1,11 @@ +package com.bsd.pjcloud.canteen.mapper; + +import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; +import com.bsd.pjcloud.canteen.entity.CanteenProductionRecordItemEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CanteenProductionRecordItemMapper extends PjcloudBaseMapper { + + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenProductionRecordMapper.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenProductionRecordMapper.java new file mode 100644 index 000000000..46f5b33c0 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenProductionRecordMapper.java @@ -0,0 +1,11 @@ +package com.bsd.pjcloud.canteen.mapper; + +import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; +import com.bsd.pjcloud.canteen.entity.CanteenProductionRecordEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CanteenProductionRecordMapper extends PjcloudBaseMapper { + + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenStockMapper.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenStockMapper.java index e5de4001e..b523371da 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenStockMapper.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/CanteenStockMapper.java @@ -1,9 +1,12 @@ package com.bsd.pjcloud.canteen.mapper; +import com.bsd.pjcloud.canteen.dto.erp.UpdateStockDTO; import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; import com.bsd.pjcloud.canteen.entity.CanteenStockEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + @Mapper public interface CanteenStockMapper extends PjcloudBaseMapper { diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/ProductionRecordItemRelationMapper.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/ProductionRecordItemRelationMapper.java new file mode 100644 index 000000000..3a0639685 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/mapper/ProductionRecordItemRelationMapper.java @@ -0,0 +1,11 @@ +package com.bsd.pjcloud.canteen.mapper; + +import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; +import com.bsd.pjcloud.canteen.entity.ProductionRecordItemRelationEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface ProductionRecordItemRelationMapper extends PjcloudBaseMapper { + + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenErpMaterialService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenErpMaterialService.java index 0bb1e2c4c..51e44674a 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenErpMaterialService.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenErpMaterialService.java @@ -1,8 +1,37 @@ 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.dto.erp.CanteenErpMaterialEditorDTO; +import com.bsd.pjcloud.canteen.dto.erp.CanteenErpMaterialSaveDTO; import com.bsd.pjcloud.canteen.entity.CanteenErpMaterialEntity; +import com.bsd.pjcloud.canteen.vo.erp.CanteenErpMaterialVO; public interface CanteenErpMaterialService extends IService { + + /** + * 保存 + * @param canteenErpMaterialSaveDTO + * @return + */ + Object saveCanteenErpMaterialDTO(CanteenErpMaterialSaveDTO canteenErpMaterialSaveDTO); + + /** + * 修改 + * @param canteenErpMaterialEditorDTO + * @return + */ + Object updateById(CanteenErpMaterialEditorDTO canteenErpMaterialEditorDTO); + + /** + * 分页查询 + * @param page + + * @return + */ + Page pageScope(Page page, CanteenErpMaterialEntity canteenErpMaterial); + + CanteenErpMaterialVO getCanteenErpMaterialVOById(Long id); } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenInventoryRecordsService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenInventoryRecordsService.java index 139e8f111..f97960f20 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenInventoryRecordsService.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenInventoryRecordsService.java @@ -1,8 +1,27 @@ package com.bsd.pjcloud.canteen.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import com.bsd.pjcloud.canteen.dto.erp.CanteenInventoryRecordsdDTO; import com.bsd.pjcloud.canteen.entity.CanteenInventoryRecordsEntity; +import com.bsd.pjcloud.canteen.vo.erp.CanteenProductionRecordPageVO; public interface CanteenInventoryRecordsService extends IService { + + /** + * 新增 + * @param canteenInventoryRecordsdDTO + * @return + */ + Object saveCanteenInventoryRecordsdDTO(CanteenInventoryRecordsdDTO canteenInventoryRecordsdDTO); + + + /** + * 分页 + * @param page + * @param canteenInventoryRecords + * @return + */ + Page pageScope(Page page, CanteenInventoryRecordsEntity canteenInventoryRecords); } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenProductionRecordItemService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenProductionRecordItemService.java new file mode 100644 index 000000000..21d304a43 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenProductionRecordItemService.java @@ -0,0 +1,8 @@ +package com.bsd.pjcloud.canteen.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsd.pjcloud.canteen.entity.CanteenProductionRecordItemEntity; + +public interface CanteenProductionRecordItemService extends IService { + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenProductionRecordService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenProductionRecordService.java new file mode 100644 index 000000000..8896d5f33 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenProductionRecordService.java @@ -0,0 +1,8 @@ +package com.bsd.pjcloud.canteen.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsd.pjcloud.canteen.entity.CanteenProductionRecordEntity; + +public interface CanteenProductionRecordService extends IService { + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenStockService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenStockService.java index cff489e4a..4a97c61a4 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenStockService.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/CanteenStockService.java @@ -1,8 +1,13 @@ package com.bsd.pjcloud.canteen.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.bsd.pjcloud.canteen.dto.erp.UpdateStockDTO; import com.bsd.pjcloud.canteen.entity.CanteenStockEntity; +import java.util.List; + public interface CanteenStockService extends IService { + + void updateStock(List updateStockDTOS); } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/ProductionRecordItemRelationService.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/ProductionRecordItemRelationService.java new file mode 100644 index 000000000..a8979861f --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/ProductionRecordItemRelationService.java @@ -0,0 +1,8 @@ +package com.bsd.pjcloud.canteen.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsd.pjcloud.canteen.entity.ProductionRecordItemRelationEntity; + +public interface ProductionRecordItemRelationService extends IService { + +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenErpMaterialServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenErpMaterialServiceImpl.java index 6adbdeb1a..728717362 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenErpMaterialServiceImpl.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenErpMaterialServiceImpl.java @@ -1,10 +1,22 @@ 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.dto.erp.CanteenErpMaterialEditorDTO; +import com.bsd.pjcloud.canteen.dto.erp.CanteenErpMaterialSaveDTO; import com.bsd.pjcloud.canteen.entity.CanteenErpMaterialEntity; +import com.bsd.pjcloud.canteen.entity.CanteenStockEntity; import com.bsd.pjcloud.canteen.mapper.CanteenErpMaterialMapper; +import com.bsd.pjcloud.canteen.mapper.CanteenStockMapper; import com.bsd.pjcloud.canteen.service.CanteenErpMaterialService; +import com.bsd.pjcloud.canteen.vo.erp.CanteenErpMaterialVO; +import com.bsd.pjcloud.common.data.datascope.DataScope; +import com.bsd.pjcloud.common.security.util.SecurityUtils; +import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + /** * 原料表 * @@ -12,5 +24,77 @@ import org.springframework.stereotype.Service; * @date 2025-05-07 13:16:32 */ @Service +@AllArgsConstructor public class CanteenErpMaterialServiceImpl extends ServiceImpl implements CanteenErpMaterialService { + + private final CanteenStockMapper canteenStockMapper; + @Override + @Transactional + public Object saveCanteenErpMaterialDTO(CanteenErpMaterialSaveDTO canteenErpMaterialSaveDTO) { + Long deptId = SecurityUtils.getUser().getDeptId(); + CanteenErpMaterialEntity canteenErpMaterialEntity = new CanteenErpMaterialEntity(); + canteenErpMaterialEntity.setName(canteenErpMaterialSaveDTO.getName()); + canteenErpMaterialEntity.setUnit(canteenErpMaterialSaveDTO.getUnit()); + canteenErpMaterialEntity.setDeptId(deptId); + int insert = baseMapper.insert(canteenErpMaterialEntity); + CanteenStockEntity canteenStockEntity = new CanteenStockEntity(); + canteenStockEntity.setItemType("1"); + canteenStockEntity.setItemId(canteenErpMaterialEntity.getId()); + canteenStockEntity.setBaseStock(canteenErpMaterialSaveDTO.getBaseStock()); + canteenStockEntity.setCurrentStock(canteenErpMaterialSaveDTO.getBaseStock()); + canteenStockEntity.setInventoryUpperLimit(canteenErpMaterialSaveDTO.getInventoryUpperLimit()); + canteenStockEntity.setInventoryLowerLimit(canteenErpMaterialSaveDTO.getInventoryLowerLimit()); + canteenStockMapper.insert(canteenStockEntity); + return insert; + } + + @Override + @Transactional + public Object updateById(CanteenErpMaterialEditorDTO canteenErpMaterialEditorDTO) { + Long id = canteenErpMaterialEditorDTO.getId(); + CanteenErpMaterialEntity canteenErpMaterialEntity = new CanteenErpMaterialEntity(); + canteenErpMaterialEntity.setId(id); + canteenErpMaterialEntity.setName(canteenErpMaterialEditorDTO.getName()); + canteenErpMaterialEntity.setUnit(canteenErpMaterialEditorDTO.getUnit()); + + LambdaQueryWrapper canteenStockEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); + canteenStockEntityLambdaQueryWrapper.eq(CanteenStockEntity::getItemId, id); + CanteenStockEntity sourceCanteenStockEntity = canteenStockMapper.selectOne(canteenStockEntityLambdaQueryWrapper); + + CanteenStockEntity canteenStockEntity = new CanteenStockEntity(); + canteenStockEntity.setItemId(canteenErpMaterialEntity.getId()); + canteenStockEntity.setBaseStock(canteenErpMaterialEditorDTO.getBaseStock()); + canteenStockEntity.setCurrentStock(canteenErpMaterialEditorDTO.getBaseStock()+(sourceCanteenStockEntity.getCurrentStock()-sourceCanteenStockEntity.getBaseStock())); + canteenStockEntity.setInventoryUpperLimit(canteenErpMaterialEditorDTO.getInventoryUpperLimit()); + canteenStockEntity.setInventoryLowerLimit(canteenErpMaterialEditorDTO.getInventoryLowerLimit()); + + int i = baseMapper.updateById(canteenErpMaterialEntity); + canteenStockMapper.update(canteenStockEntity, + new LambdaQueryWrapper().eq(CanteenStockEntity::getItemId, id)); + return i; + } + + @Override + public Page pageScope(Page page, CanteenErpMaterialEntity canteenErpMaterial) { + return baseMapper.selectPageDataByScope(page, canteenErpMaterial, DataScope.of()); + } + + + @Override + public CanteenErpMaterialVO getCanteenErpMaterialVOById(Long id) { + CanteenErpMaterialEntity canteenErpMaterialEntity = baseMapper.selectById(id); + LambdaQueryWrapper canteenStockEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); + canteenStockEntityLambdaQueryWrapper.eq(CanteenStockEntity::getItemId, id); + CanteenStockEntity sourceCanteenStockEntity = canteenStockMapper.selectOne(canteenStockEntityLambdaQueryWrapper); + + CanteenErpMaterialVO canteenErpMaterialVO = new CanteenErpMaterialVO(); + canteenErpMaterialVO.setId(canteenErpMaterialEntity.getId()); + canteenErpMaterialVO.setName(canteenErpMaterialEntity.getName()); + canteenErpMaterialVO.setUnit(canteenErpMaterialEntity.getUnit()); + canteenErpMaterialVO.setBaseStock(sourceCanteenStockEntity.getBaseStock()); + canteenErpMaterialVO.setInventoryUpperLimit(sourceCanteenStockEntity.getInventoryUpperLimit()); + canteenErpMaterialVO.setInventoryLowerLimit(sourceCanteenStockEntity.getInventoryLowerLimit()); + canteenErpMaterialVO.setCurrentStock(sourceCanteenStockEntity.getCurrentStock()); + return canteenErpMaterialVO; + } } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenInventoryRecordsServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenInventoryRecordsServiceImpl.java index 6fcf2de4a..1e5483af8 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenInventoryRecordsServiceImpl.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenInventoryRecordsServiceImpl.java @@ -1,10 +1,32 @@ package com.bsd.pjcloud.canteen.service.impl; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsd.pjcloud.canteen.constant.OrderTypeEnum; +import com.bsd.pjcloud.canteen.dto.erp.CanteenInventoryRecordsItemDTO; +import com.bsd.pjcloud.canteen.dto.erp.CanteenInventoryRecordsdDTO; +import com.bsd.pjcloud.canteen.dto.erp.UpdateStockDTO; import com.bsd.pjcloud.canteen.entity.CanteenInventoryRecordsEntity; +import com.bsd.pjcloud.canteen.entity.CanteenInventoryRecordsItemEntity; +import com.bsd.pjcloud.canteen.mapper.CanteenInventoryRecordsItemMapper; import com.bsd.pjcloud.canteen.mapper.CanteenInventoryRecordsMapper; +import com.bsd.pjcloud.canteen.mapper.CanteenProductionRecordItemMapper; +import com.bsd.pjcloud.canteen.mapper.CanteenStockMapper; import com.bsd.pjcloud.canteen.service.CanteenInventoryRecordsService; +import com.bsd.pjcloud.canteen.service.CanteenStockService; +import com.bsd.pjcloud.canteen.vo.erp.CanteenProductionRecordPageVO; +import com.bsd.pjcloud.common.core.util.BeanUtils; +import com.bsd.pjcloud.common.data.datascope.DataScope; +import com.bsd.pjcloud.common.security.util.SecurityUtils; +import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum; +import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; + /** * 采购记录表 * @@ -12,5 +34,61 @@ import org.springframework.stereotype.Service; * @date 2025-05-07 17:00:50 */ @Service +@AllArgsConstructor public class CanteenInventoryRecordsServiceImpl extends ServiceImpl implements CanteenInventoryRecordsService { + + private final CanteenInventoryRecordsItemMapper canteenInventoryRecordsItemMapper; + + private final CanteenStockMapper canteenStockMapper; + + private final CanteenStockService canteenStockService; + @Override + @Transactional + public Object saveCanteenInventoryRecordsdDTO(CanteenInventoryRecordsdDTO canteenInventoryRecordsdDTO) { + + Long deptId = SecurityUtils.getUser().getDeptId(); + CanteenInventoryRecordsEntity canteenInventoryRecordsEntity= BeanUtils.toBean(canteenInventoryRecordsdDTO, CanteenInventoryRecordsEntity.class); + canteenInventoryRecordsEntity.setDeptId(deptId); + canteenInventoryRecordsEntity.setCheckStatus(TaskCheckStatusEnum.RESULT.getCode()); + baseMapper.insert(canteenInventoryRecordsEntity); + Long id = canteenInventoryRecordsEntity.getId(); + + List canteenInventoryRecordsItemDTOS = canteenInventoryRecordsdDTO.getCanteenInventoryRecordsItemDTOS(); + List canteenInventoryRecordsItemEntityList = BeanUtils.toBean(canteenInventoryRecordsItemDTOS, CanteenInventoryRecordsItemEntity.class); + + + List updateStockDTOS = new ArrayList<>(); + for (CanteenInventoryRecordsItemEntity canteenInventoryRecordsItemEntity : canteenInventoryRecordsItemEntityList){ + canteenInventoryRecordsItemEntity.setInventoryId(id); + canteenInventoryRecordsItemEntity.setDeptId(deptId); + String orderType = canteenInventoryRecordsEntity.getOrderType(); + canteenInventoryRecordsItemEntity.setOrderType(orderType); + UpdateStockDTO updateStockDTO = new UpdateStockDTO(); + updateStockDTO.setId(id); + Double quantity = canteenInventoryRecordsItemEntity.getQuantity(); + if (orderType.equals(OrderTypeEnum.RK.getType())){ + updateStockDTO.setIncrCount(quantity); + }else if (orderType.equals(OrderTypeEnum.CK.getType())){ + updateStockDTO.setIncrCount(-quantity); + }else if (orderType.equals(OrderTypeEnum.No.getType())){ + //无需更新库存 + }else { + throw new RuntimeException("订单类型错误"); + } + updateStockDTOS.add(updateStockDTO); + } + + canteenInventoryRecordsItemMapper.insert(canteenInventoryRecordsItemEntityList); + + if (!CollectionUtils.isEmpty(updateStockDTOS)){ + canteenStockService.updateStock(updateStockDTOS); + } + return id; + } + + @Override + public Page pageScope(Page page, CanteenInventoryRecordsEntity canteenInventoryRecords) { + + return baseMapper.selectPageDataByScope(page,canteenInventoryRecords, DataScope.of()); + } } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenProductionRecordItemServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenProductionRecordItemServiceImpl.java new file mode 100644 index 000000000..94dd8f8e1 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenProductionRecordItemServiceImpl.java @@ -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.CanteenProductionRecordItemEntity; +import com.bsd.pjcloud.canteen.mapper.CanteenProductionRecordItemMapper; +import com.bsd.pjcloud.canteen.service.CanteenProductionRecordItemService; +import org.springframework.stereotype.Service; +/** + * 食材加工记录明细表 + * + * @author zjf + * @date 2025-05-08 11:05:02 + */ +@Service +public class CanteenProductionRecordItemServiceImpl extends ServiceImpl implements CanteenProductionRecordItemService { +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenProductionRecordServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenProductionRecordServiceImpl.java new file mode 100644 index 000000000..fd42c1086 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenProductionRecordServiceImpl.java @@ -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.CanteenProductionRecordEntity; +import com.bsd.pjcloud.canteen.mapper.CanteenProductionRecordMapper; +import com.bsd.pjcloud.canteen.service.CanteenProductionRecordService; +import org.springframework.stereotype.Service; +/** + * 食材加工记录表 + * + * @author zjf + * @date 2025-05-08 11:02:09 + */ +@Service +public class CanteenProductionRecordServiceImpl extends ServiceImpl implements CanteenProductionRecordService { +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenStockServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenStockServiceImpl.java index e2cf940b3..1536448a0 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenStockServiceImpl.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenStockServiceImpl.java @@ -1,10 +1,18 @@ 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.dto.erp.UpdateStockDTO; import com.bsd.pjcloud.canteen.entity.CanteenStockEntity; import com.bsd.pjcloud.canteen.mapper.CanteenStockMapper; import com.bsd.pjcloud.canteen.service.CanteenStockService; +import org.springframework.dao.OptimisticLockingFailureException; +import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + /** * 库存表 * @@ -13,4 +21,29 @@ import org.springframework.stereotype.Service; */ @Service public class CanteenStockServiceImpl extends ServiceImpl implements CanteenStockService { + @Override + @Transactional + @Retryable(value = {OptimisticLockingFailureException.class}, maxAttempts = 3) + public void updateStock(List updateStockDTOS) { + // 更新库存(手动乐观锁) + for (UpdateStockDTO item : updateStockDTOS) { + // 1. 先查询当前版本号 + LambdaQueryWrapper stockEntityLambdaQueryWrapper = new LambdaQueryWrapper(); + stockEntityLambdaQueryWrapper.eq(CanteenStockEntity::getItemId,item.getId()); + CanteenStockEntity smErpStockEntity = baseMapper.selectOne(stockEntityLambdaQueryWrapper); + + LambdaQueryWrapper updateStockWithLockWrapper = new LambdaQueryWrapper(); + updateStockWithLockWrapper.eq(CanteenStockEntity::getItemId,item.getId()); + updateStockWithLockWrapper.eq(CanteenStockEntity::getVersion,smErpStockEntity.getVersion()); + CanteenStockEntity updateSmErpStockEntity = new CanteenStockEntity(); + updateSmErpStockEntity.setCurrentStock(smErpStockEntity.getCurrentStock()+item.getIncrCount()); + updateSmErpStockEntity.setVersion(smErpStockEntity.getVersion()+1); + int update = baseMapper.update(updateSmErpStockEntity, updateStockWithLockWrapper); + // 3. 检查更新结果 + if (update == 0) { + throw new RuntimeException("库存更新冲突,请重试操作"); + } + } + + } } \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/ProductionRecordItemRelationServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/ProductionRecordItemRelationServiceImpl.java new file mode 100644 index 000000000..9773b85ee --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/ProductionRecordItemRelationServiceImpl.java @@ -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.ProductionRecordItemRelationEntity; +import com.bsd.pjcloud.canteen.mapper.ProductionRecordItemRelationMapper; +import com.bsd.pjcloud.canteen.service.ProductionRecordItemRelationService; +import org.springframework.stereotype.Service; +/** + * 食材加工菜品关系表 + * + * @author zjf + * @date 2025-05-08 11:05:33 + */ +@Service +public class ProductionRecordItemRelationServiceImpl extends ServiceImpl implements ProductionRecordItemRelationService { +} \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenErpMaterialMapper.xml b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenErpMaterialMapper.xml index 883e8bd42..24818d5bf 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenErpMaterialMapper.xml +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenErpMaterialMapper.xml @@ -15,4 +15,23 @@ + \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenInventoryRecordsMapper.xml b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenInventoryRecordsMapper.xml index ee9c5ec22..0897302e8 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenInventoryRecordsMapper.xml +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenInventoryRecordsMapper.xml @@ -29,4 +29,21 @@ + \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenProductionRecordItemMapper.xml b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenProductionRecordItemMapper.xml new file mode 100644 index 000000000..c7941d081 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenProductionRecordItemMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenProductionRecordMapper.xml b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenProductionRecordMapper.xml new file mode 100644 index 000000000..69cb17355 --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/CanteenProductionRecordMapper.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/ProductionRecordItemRelationMapper.xml b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/ProductionRecordItemRelationMapper.xml new file mode 100644 index 000000000..7d89d71ae --- /dev/null +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/resources/mapper/ProductionRecordItemRelationMapper.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SmErpInventoryRecordsServiceImpl.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SmErpInventoryRecordsServiceImpl.java index 9cc0230bf..e93dd440b 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SmErpInventoryRecordsServiceImpl.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SmErpInventoryRecordsServiceImpl.java @@ -72,8 +72,6 @@ public class SmErpInventoryRecordsServiceImpl extends ServiceImpl items = inventoryRecordSaveDTO.getItems(); //计算主表总金额 int sum = items.stream().mapToInt(InventoryRecordSaveItemDTO::getTotalAmount).sum(); @@ -202,17 +200,17 @@ public class SmErpInventoryRecordsServiceImpl extends ServiceImpl> pageR = remoteFlowApiFlowService.queryMineTask(taskQueryParamDto); - Page data = pageR.getData(); - - final Map processInstanceIdMap = (data != null && !ObjectUtil.isEmpty(data.getRecords())) - ? data.getRecords().stream() - .collect(Collectors.toMap(TaskDto::getProcessInstanceId, taskDto -> taskDto)) - : Collections.emptyMap(); +// TaskQueryParamDto taskQueryParamDto = new TaskQueryParamDto(); +// taskQueryParamDto.setProcessInstanceIds(processInstanceIds); +// taskQueryParamDto.setCurrent(1); +// taskQueryParamDto.setSize(processInstanceIds.size()); +// R> pageR = remoteFlowApiFlowService.queryMineTask(taskQueryParamDto); +// Page data = pageR.getData(); +// +// final Map processInstanceIdMap = (data != null && !ObjectUtil.isEmpty(data.getRecords())) +// ? data.getRecords().stream() +// .collect(Collectors.toMap(TaskDto::getProcessInstanceId, taskDto -> taskDto)) +// : Collections.emptyMap(); // 设置商品名称到主表实体 records.forEach(plan -> { @@ -226,15 +224,15 @@ public class SmErpInventoryRecordsServiceImpl extends ServiceImpl