diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/MenuMaterialCategoryController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/MenuMaterialCategoryController.java index ea71c94..7b4ee26 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/MenuMaterialCategoryController.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/MenuMaterialCategoryController.java @@ -2,9 +2,11 @@ package com.bonus.canteen.core.menu.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; import com.bonus.canteen.core.menu.domain.MenuMaterialCategory; import com.bonus.canteen.core.menu.dto.CategoryTreeListDTO; +import com.bonus.canteen.core.menu.dto.MenuMaterialCategoryAddDTO; import com.bonus.canteen.core.menu.service.IMenuMaterialCategoryService; import com.bonus.common.log.enums.OperaType; import io.swagger.annotations.Api; @@ -78,10 +80,10 @@ public class MenuMaterialCategoryController extends BaseController { //@PreventRepeatSubmit //@RequiresPermissions("menu:category:add") @SysLog(title = "原料类别", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增原料类别") - @PostMapping - public AjaxResult add(@RequestBody MenuMaterialCategory menuMaterialCategory) { + @PostMapping("/add") + public AjaxResult add(@RequestBody @Valid MenuMaterialCategoryAddDTO dto) { try { - return toAjax(menuMaterialCategoryService.insertMenuMaterialCategory(menuMaterialCategory)); + return toAjax(menuMaterialCategoryService.insertMenuMaterialCategory(dto)); } catch (Exception e) { return error("系统错误, " + e.getMessage()); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/MenuNutritionController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/MenuNutritionController.java index 662db67..f23ef7e 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/MenuNutritionController.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/MenuNutritionController.java @@ -40,8 +40,8 @@ public class MenuNutritionController extends BaseController { */ @ApiOperation(value = "查询食材营养基础信息列表") //@RequiresPermissions("menu:nutrition:list") - @GetMapping("/list") - public TableDataInfo list(MenuNutrition menuNutrition) { + @PostMapping ("/list") + public TableDataInfo list(@RequestBody MenuNutrition menuNutrition) { startPage(); List list = menuNutritionService.selectMenuNutritionList(menuNutrition); return getDataTable(list); @@ -78,7 +78,7 @@ public class MenuNutritionController extends BaseController { //@PreventRepeatSubmit //@RequiresPermissions("menu:nutrition:add") @SysLog(title = "食材营养基础信息", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增食材营养基础信息") - @PostMapping + @PostMapping("/add") public AjaxResult add(@RequestBody MenuNutritionDTO menuNutrition) { try { return toAjax(menuNutritionService.insertMenuNutrition(menuNutrition)); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/domain/MenuMaterialCategory.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/domain/MenuMaterialCategory.java index 4f1d566..4c35eb5 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/domain/MenuMaterialCategory.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/domain/MenuMaterialCategory.java @@ -1,14 +1,20 @@ package com.bonus.canteen.core.menu.domain; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.extension.activerecord.Model; import com.bonus.common.core.annotation.Excel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.ToString; import com.bonus.common.core.web.domain.BaseEntity; +import java.time.LocalDateTime; + /** * 原料类别对象 menu_material_category - * + * * @author xsheng * @date 2025-04-03 */ @@ -16,56 +22,43 @@ import com.bonus.common.core.web.domain.BaseEntity; @Data @ToString -public class MenuMaterialCategory extends BaseEntity { +public class MenuMaterialCategory extends Model { private static final long serialVersionUID = 1L; - /** 主键id */ + @TableId + @ApiModelProperty("主键id") private Long id; - - /** 区域id */ - @Excel(name = "区域id") - @ApiModelProperty(value = "区域id") - private Long areaId; - - /** 类别id */ - @Excel(name = "类别id") - @ApiModelProperty(value = "类别id") + @ApiModelProperty("类别id") private Long categoryId; - - /** 类别编码 */ - @Excel(name = "类别编码") - @ApiModelProperty(value = "类别编码") + @ApiModelProperty("类别编码") private String categoryNum; - - /** 类别名称 */ - @Excel(name = "类别名称") - @ApiModelProperty(value = "类别名称") + @ApiModelProperty("类别名称") private String categoryName; - - /** 父类id */ - @Excel(name = "父类id") - @ApiModelProperty(value = "父类id") + @ApiModelProperty("父类id") private Long parentId; - - /** 类型(1原料2商品) */ - @Excel(name = "类型(1原料2商品)") - @ApiModelProperty(value = "类型(1原料2商品)") - private Long categoryType; - - /** 乐观锁 */ - @Excel(name = "乐观锁") - @ApiModelProperty(value = "乐观锁") - private Long revision; - - /** 等级(0,1,2,3) */ - @Excel(name = "等级(0,1,2,3)") - @ApiModelProperty(value = "等级(0,1,2,3)") - private Long level; - - /** 大类id */ - @Excel(name = "大类id") - @ApiModelProperty(value = "大类id") + @ApiModelProperty("类型(1原料2商品)") + private Integer categoryType; + @ApiModelProperty("删除标识(1-删除,2-正常)") + private Integer delFlag; + @ApiModelProperty("乐观锁") + private Integer revision; + @TableField(value = "create_by",fill = FieldFill.INSERT) + @ApiModelProperty("创建人") + private String createBy; + @TableField( value = "create_time", fill = FieldFill.INSERT) + @ApiModelProperty("创建时间") + private LocalDateTime createTime; + @TableField(value = "update_by",fill = FieldFill.UPDATE ) + @ApiModelProperty("更新人") + private String updateBy; + @TableField(value = "update_time",fill = FieldFill.UPDATE) + @ApiModelProperty("更新时间") + private LocalDateTime updateTime; + @ApiModelProperty("区域ID") + private Long areaId; + @ApiModelProperty("等级(0,1,2,3)") + private Integer level; + @ApiModelProperty("大类id") private Long bigCategoryId; - } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/domain/MenuNutrition.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/domain/MenuNutrition.java index a35eaf8..19e6924 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/domain/MenuNutrition.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/domain/MenuNutrition.java @@ -46,7 +46,7 @@ public class MenuNutrition extends BaseEntity { /** 标准份重量(g) */ @Excel(name = "标准份重量(g)") @ApiModelProperty(value = "标准份重量(g)") - private BigDecimal weight; + private Double weight; /** 食材基础单价(分) */ @Excel(name = "食材基础单价(分)") @@ -86,7 +86,7 @@ public class MenuNutrition extends BaseEntity { /** 加工时间(min) */ @Excel(name = "加工时间(min)") @ApiModelProperty(value = "加工时间(min)") - private BigDecimal processingTime; + private Double processingTime; /** 推荐组合(以英文逗号分割,食材编码区分不超过20个) */ @Excel(name = "推荐组合(以英文逗号分割,食材编码区分不超过20个)") @@ -101,87 +101,87 @@ public class MenuNutrition extends BaseEntity { /** 可食部分(g/100g) */ @Excel(name = "可食部分(g/100g)") @ApiModelProperty(value = "可食部分(g/100g)") - private BigDecimal edible; + private Double edible; /** 水分(g/100g) */ @Excel(name = "水分(g/100g)") @ApiModelProperty(value = "水分(g/100g)") - private BigDecimal water; + private Double water; /** 热量(千卡/100g) */ @Excel(name = "热量(千卡/100g)") @ApiModelProperty(value = "热量(千卡/100g)") - private BigDecimal calories; + private Double calories; /** 蛋白质(g/100g) */ @Excel(name = "蛋白质(g/100g)") @ApiModelProperty(value = "蛋白质(g/100g)") - private BigDecimal protein; + private Double protein; /** 脂肪(g/100g) */ @Excel(name = "脂肪(g/100g)") @ApiModelProperty(value = "脂肪(g/100g)") - private BigDecimal fat; + private Double fat; /** 碳水化合物(g/100g) */ @Excel(name = "碳水化合物(g/100g)") @ApiModelProperty(value = "碳水化合物(g/100g)") - private BigDecimal carbohydrate; + private Double carbohydrate; /** 不溶性膳食纤维(g/100g) */ @Excel(name = "不溶性膳食纤维(g/100g)") @ApiModelProperty(value = "不溶性膳食纤维(g/100g)") - private BigDecimal dietaryFiber; + private Double dietaryFiber; /** 胆固醇(mg/100g) */ @Excel(name = "胆固醇(mg/100g)") @ApiModelProperty(value = "胆固醇(mg/100g)") - private BigDecimal cholesterol; + private Double cholesterol; /** 灰分(g/100g) */ @Excel(name = "灰分(g/100g)") @ApiModelProperty(value = "灰分(g/100g)") - private BigDecimal ash; + private Double ash; /** 维生素a(μg/100g) */ @Excel(name = "维生素a(μg/100g)") @ApiModelProperty(value = "维生素a(μg/100g)") - private BigDecimal vitaminA; + private Double vitaminA; /** 胡萝卜素(μg/100g) */ @Excel(name = "胡萝卜素(μg/100g)") @ApiModelProperty(value = "胡萝卜素(μg/100g)") - private BigDecimal carotene; + private Double carotene; /** 硫胺素(mg/100g) */ @Excel(name = "硫胺素(mg/100g)") @ApiModelProperty(value = "硫胺素(mg/100g)") - private BigDecimal thiamine; + private Double thiamine; /** 核黄素(mg/100g) */ @Excel(name = "核黄素(mg/100g)") @ApiModelProperty(value = "核黄素(mg/100g)") - private BigDecimal riboflavin; + private Double riboflavin; /** 烟酸/尼克酸(mg/100g) */ @Excel(name = "烟酸/尼克酸(mg/100g)") @ApiModelProperty(value = "烟酸/尼克酸(mg/100g)") - private BigDecimal niacin; + private Double niacin; /** 维生素c(mg/100g) */ @Excel(name = "维生素c(mg/100g)") @ApiModelProperty(value = "维生素c(mg/100g)") - private BigDecimal vitaminC; + private Double vitaminC; /** 维生素d(μg/100g) */ @Excel(name = "维生素d(μg/100g)") @ApiModelProperty(value = "维生素d(μg/100g)") - private BigDecimal vitaminD; + private Double vitaminD; /** 维生素e(mg/100g) */ @Excel(name = "维生素e(mg/100g)") @ApiModelProperty(value = "维生素e(mg/100g)") - private BigDecimal vitaminE; + private Double vitaminE; /** 删除标识(1删除,2正常) */ private Integer delFlag; @@ -189,147 +189,147 @@ public class MenuNutrition extends BaseEntity { /** 胆碱(mg/100g) */ @Excel(name = "胆碱(mg/100g)") @ApiModelProperty(value = "胆碱(mg/100g)") - private BigDecimal choline; + private Double choline; /** 生物素/维生素7(ug/100g) */ @Excel(name = "生物素/维生素7(ug/100g)") @ApiModelProperty(value = "生物素/维生素7(ug/100g)") - private BigDecimal biotin; + private Double biotin; /** 泛酸(mg/100g) */ @Excel(name = "泛酸(mg/100g)") @ApiModelProperty(value = "泛酸(mg/100g)") - private BigDecimal pantothenicAcid; + private Double pantothenicAcid; /** 鸟嘌呤(mg/100g) */ @Excel(name = "鸟嘌呤(mg/100g)") @ApiModelProperty(value = "鸟嘌呤(mg/100g)") - private BigDecimal guanine; + private Double guanine; /** 腺嘌呤(mg/100g) */ @Excel(name = "腺嘌呤(mg/100g)") @ApiModelProperty(value = "腺嘌呤(mg/100g)") - private BigDecimal adenine; + private Double adenine; /** 次黄嘌呤(mg/100g) */ @Excel(name = "次黄嘌呤(mg/100g)") @ApiModelProperty(value = "次黄嘌呤(mg/100g)") - private BigDecimal hypoxanthine; + private Double hypoxanthine; /** 黄嘌呤(mg/100g) */ @Excel(name = "黄嘌呤(mg/100g)") @ApiModelProperty(value = "黄嘌呤(mg/100g)") - private BigDecimal xanthine; + private Double xanthine; /** 总嘌呤含量(mg/100g) */ @Excel(name = "总嘌呤含量(mg/100g)") @ApiModelProperty(value = "总嘌呤含量(mg/100g)") - private BigDecimal purine; + private Double purine; /** 血糖生成指数(GI) */ @Excel(name = "血糖生成指数(GI)") @ApiModelProperty(value = "血糖生成指数(GI)") - private BigDecimal glycemicIndex; + private Double glycemicIndex; /** 植物甾醇总含量(mg/100g) */ @Excel(name = "植物甾醇总含量(mg/100g)") @ApiModelProperty(value = "植物甾醇总含量(mg/100g)") - private BigDecimal totalPhytosterolContent; + private Double totalPhytosterolContent; /** β-谷甾醇(mg/100g) */ @Excel(name = "β-谷甾醇(mg/100g)") @ApiModelProperty(value = "β-谷甾醇(mg/100g)") - private BigDecimal cerealSterol; + private Double cerealSterol; /** 菜油甾醇(mg/100g) */ @Excel(name = "菜油甾醇(mg/100g)") @ApiModelProperty(value = "菜油甾醇(mg/100g)") - private BigDecimal cameliaSterol; + private Double cameliaSterol; /** 豆甾醇(mg/100g) */ @Excel(name = "豆甾醇(mg/100g)") @ApiModelProperty(value = "豆甾醇(mg/100g)") - private BigDecimal sterol; + private Double sterol; /** β-谷甾烷醇(mg/100g) */ @Excel(name = "β-谷甾烷醇(mg/100g)") @ApiModelProperty(value = "β-谷甾烷醇(mg/100g)") - private BigDecimal cerealSteranol; + private Double cerealSteranol; /** 菜油甾烷醇(mg/100g) */ @Excel(name = "菜油甾烷醇(mg/100g)") @ApiModelProperty(value = "菜油甾烷醇(mg/100g)") - private BigDecimal rapesanol; + private Double rapesanol; /** 菜子甾醇(mg/100g) */ @Excel(name = "菜子甾醇(mg/100g)") @ApiModelProperty(value = "菜子甾醇(mg/100g)") - private BigDecimal rapeseedSteranol; + private Double rapeseedSteranol; /** 叶黄素+玉米素(μg/100g) */ @Excel(name = "叶黄素+玉米素(μg/100g)") @ApiModelProperty(value = "叶黄素+玉米素(μg/100g)") - private BigDecimal luteinZeaxanthin; + private Double luteinZeaxanthin; /** 槲皮素(mg/100g) */ @Excel(name = "槲皮素(mg/100g)") @ApiModelProperty(value = "槲皮素(mg/100g)") - private BigDecimal quercetin; + private Double quercetin; /** 杨梅黄酮(mg/100g) */ @Excel(name = "杨梅黄酮(mg/100g)") @ApiModelProperty(value = "杨梅黄酮(mg/100g)") - private BigDecimal myricetin; + private Double myricetin; /** 玉米黄酮(mg/100g) */ @Excel(name = "玉米黄酮(mg/100g)") @ApiModelProperty(value = "玉米黄酮(mg/100g)") - private BigDecimal luteolin; + private Double luteolin; /** 坎二菲醇(mg/100g) */ @Excel(name = "坎二菲醇(mg/100g)") @ApiModelProperty(value = "坎二菲醇(mg/100g)") - private BigDecimal kaemPferol; + private Double kaemPferol; /** 芹菜配基(mg/100g) */ @Excel(name = "芹菜配基(mg/100g)") @ApiModelProperty(value = "芹菜配基(mg/100g)") - private BigDecimal apigenin; + private Double apigenin; /** 大豆异黄酮总含量(mg/100g) */ @Excel(name = "大豆异黄酮总含量(mg/100g)") @ApiModelProperty(value = "大豆异黄酮总含量(mg/100g)") - private BigDecimal isoflavone; + private Double isoflavone; /** 黄豆苷元(mg/100g) */ @Excel(name = "黄豆苷元(mg/100g)") @ApiModelProperty(value = "黄豆苷元(mg/100g)") - private BigDecimal daidzein; + private Double daidzein; /** 染料木黄酮(mg/100g) */ @Excel(name = "染料木黄酮(mg/100g)") @ApiModelProperty(value = "染料木黄酮(mg/100g)") - private BigDecimal genistein; + private Double genistein; /** 黄豆黄素(mg/100g) */ @Excel(name = "黄豆黄素(mg/100g)") @ApiModelProperty(value = "黄豆黄素(mg/100g)") - private BigDecimal glycitein; + private Double glycitein; /** 花青素(mg/100g鲜重,包含飞燕草素、矢车菊素、芍药素) */ @Excel(name = "花青素(mg/100g鲜重,包含飞燕草素、矢车菊素、芍药素)") @ApiModelProperty(value = "花青素(mg/100g鲜重,包含飞燕草素、矢车菊素、芍药素)") - private BigDecimal anthocyan; + private Double anthocyan; /** 白藜芦醇(μg/100g) */ @Excel(name = "白藜芦醇(μg/100g)") @ApiModelProperty(value = "白藜芦醇(μg/100g)") - private BigDecimal resveratrol; + private Double resveratrol; /** 白藜芦醇苷(μg/100g) */ @Excel(name = "白藜芦醇苷(μg/100g)") @ApiModelProperty(value = "白藜芦醇苷(μg/100g)") - private BigDecimal polydatin; + private Double polydatin; /** 备注/原产地 */ @Excel(name = "备注/原产地") @@ -339,167 +339,167 @@ public class MenuNutrition extends BaseEntity { /** 钙(mg/100g) */ @Excel(name = "钙(mg/100g)") @ApiModelProperty(value = "钙(mg/100g)") - private BigDecimal calcium; + private Double calcium; /** 磷(mg/100g) */ @Excel(name = "磷(mg/100g)") @ApiModelProperty(value = "磷(mg/100g)") - private BigDecimal phosphorus; + private Double phosphorus; /** 钾(mg/100g) */ @Excel(name = "钾(mg/100g)") @ApiModelProperty(value = "钾(mg/100g)") - private BigDecimal kalium; + private Double kalium; /** 钠(mg/100g) */ @Excel(name = "钠(mg/100g)") @ApiModelProperty(value = "钠(mg/100g)") - private BigDecimal sodium; + private Double sodium; /** 镁(mg/100g) */ @Excel(name = "镁(mg/100g)") @ApiModelProperty(value = "镁(mg/100g)") - private BigDecimal magnesium; + private Double magnesium; /** 铁(mg/100g) */ @Excel(name = "铁(mg/100g)") @ApiModelProperty(value = "铁(mg/100g)") - private BigDecimal iron; + private Double iron; /** 锌(mg/100g) */ @Excel(name = "锌(mg/100g)") @ApiModelProperty(value = "锌(mg/100g)") - private BigDecimal zinc; + private Double zinc; /** 硒(μg/100g) */ @Excel(name = "硒(μg/100g)") @ApiModelProperty(value = "硒(μg/100g)") - private BigDecimal selenium; + private Double selenium; /** 铜(mg/100g) */ @Excel(name = "铜(mg/100g)") @ApiModelProperty(value = "铜(mg/100g)") - private BigDecimal cuprum; + private Double cuprum; /** 锰(mg/100g) */ @Excel(name = "锰(mg/100g)") @ApiModelProperty(value = "锰(mg/100g)") - private BigDecimal manganese; + private Double manganese; /** 异亮氨酸(mg/100g) */ @Excel(name = "异亮氨酸(mg/100g)") @ApiModelProperty(value = "异亮氨酸(mg/100g)") - private BigDecimal isoleucine; + private Double isoleucine; /** 亮氨酸(mg/100g) */ @Excel(name = "亮氨酸(mg/100g)") @ApiModelProperty(value = "亮氨酸(mg/100g)") - private BigDecimal leucine; + private Double leucine; /** 赖氨酸(mg/100g) */ @Excel(name = "赖氨酸(mg/100g)") @ApiModelProperty(value = "赖氨酸(mg/100g)") - private BigDecimal lysine; + private Double lysine; /** 含硫氨基酸(mg/100g) */ @Excel(name = "含硫氨基酸(mg/100g)") @ApiModelProperty(value = "含硫氨基酸(mg/100g)") - private BigDecimal saaTotal; + private Double saaTotal; /** 芳香族氨基酸(mg/100g) */ @Excel(name = "芳香族氨基酸(mg/100g)") @ApiModelProperty(value = "芳香族氨基酸(mg/100g)") - private BigDecimal aaaTotal; + private Double aaaTotal; /** 苏氨酸(mg/100g) */ @Excel(name = "苏氨酸(mg/100g)") @ApiModelProperty(value = "苏氨酸(mg/100g)") - private BigDecimal threonine; + private Double threonine; /** 色氨酸(mg/100g) */ @Excel(name = "色氨酸(mg/100g)") @ApiModelProperty(value = "色氨酸(mg/100g)") - private BigDecimal tryptophan; + private Double tryptophan; /** 缬氨酸(mg/100g) */ @Excel(name = "缬氨酸(mg/100g)") @ApiModelProperty(value = "缬氨酸(mg/100g)") - private BigDecimal valine; + private Double valine; /** 精氨酸(mg/100g) */ @Excel(name = "精氨酸(mg/100g)") @ApiModelProperty(value = "精氨酸(mg/100g)") - private BigDecimal arginine; + private Double arginine; /** 组氨酸(mg/100g) */ @Excel(name = "组氨酸(mg/100g)") @ApiModelProperty(value = "组氨酸(mg/100g)") - private BigDecimal histidine; + private Double histidine; /** 丙氨酸(mg/100g) */ @Excel(name = "丙氨酸(mg/100g)") @ApiModelProperty(value = "丙氨酸(mg/100g)") - private BigDecimal alanine; + private Double alanine; /** 天冬氨酸(mg/100g) */ @Excel(name = "天冬氨酸(mg/100g)") @ApiModelProperty(value = "天冬氨酸(mg/100g)") - private BigDecimal asparticAcid; + private Double asparticAcid; /** 谷氨酸(mg/100g) */ @Excel(name = "谷氨酸(mg/100g)") @ApiModelProperty(value = "谷氨酸(mg/100g)") - private BigDecimal glutamate; + private Double glutamate; /** 甘氨酸(mg/100g) */ @Excel(name = "甘氨酸(mg/100g)") @ApiModelProperty(value = "甘氨酸(mg/100g)") - private BigDecimal glycine; + private Double glycine; /** 脯氨酸(mg/100g) */ @Excel(name = "脯氨酸(mg/100g)") @ApiModelProperty(value = "脯氨酸(mg/100g)") - private BigDecimal proline; + private Double proline; /** 丝氨酸(mg/100g) */ @Excel(name = "丝氨酸(mg/100g)") @ApiModelProperty(value = "丝氨酸(mg/100g)") - private BigDecimal serine; + private Double serine; /** 脂肪酸(g/100g可食部) */ @Excel(name = "脂肪酸(g/100g可食部)") @ApiModelProperty(value = "脂肪酸(g/100g可食部)") - private BigDecimal fattyAcid; + private Double fattyAcid; /** 饱和脂肪酸(g/100g可食部) */ @Excel(name = "饱和脂肪酸(g/100g可食部)") @ApiModelProperty(value = "饱和脂肪酸(g/100g可食部)") - private BigDecimal saturatedFattyAcid; + private Double saturatedFattyAcid; /** 单不饱和脂肪酸(g/100g可食部) */ @Excel(name = "单不饱和脂肪酸(g/100g可食部)") @ApiModelProperty(value = "单不饱和脂肪酸(g/100g可食部)") - private BigDecimal monounsaturatedFattyAcid; + private Double monounsaturatedFattyAcid; /** 多不饱和脂肪酸(g/100g可食部) */ @Excel(name = "多不饱和脂肪酸(g/100g可食部)") @ApiModelProperty(value = "多不饱和脂肪酸(g/100g可食部)") - private BigDecimal polyunsaturatedFattyAcid; + private Double polyunsaturatedFattyAcid; /** 碘(μg/100g) */ @Excel(name = "碘(μg/100g)") @ApiModelProperty(value = "碘(μg/100g)") - private BigDecimal iodine; + private Double iodine; /** 叶酸(mg/100g) */ @Excel(name = "叶酸(mg/100g)") @ApiModelProperty(value = "叶酸(mg/100g)") - private BigDecimal folic; + private Double folic; /** 视黄醇(μg/100g) */ @Excel(name = "视黄醇(μg/100g)") @ApiModelProperty(value = "视黄醇(μg/100g)") - private BigDecimal retinol; + private Double retinol; /** 是否默认(1-默认,2-非默认) */ @Excel(name = "是否默认(1-默认,2-非默认)") diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/dto/MenuMaterialCategoryAddDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/dto/MenuMaterialCategoryAddDTO.java new file mode 100644 index 0000000..ba49cb0 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/dto/MenuMaterialCategoryAddDTO.java @@ -0,0 +1,25 @@ +package com.bonus.canteen.core.menu.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @author xliu + * @date 2025/4/9 13:31 + */ +@Data +public class MenuMaterialCategoryAddDTO { + + @ApiModelProperty("类别名称") + private @NotBlank( + message = "{menu_category_name_null}" + ) String categoryName; + @ApiModelProperty("父类id") + private Long parentId; + @ApiModelProperty("类型(1原料2商品)") + private Integer categoryType; + @ApiModelProperty("区域ID") + private Long areaId; +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/dto/MenuNutritionDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/dto/MenuNutritionDTO.java index ddffa18..2ed6a38 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/dto/MenuNutritionDTO.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/dto/MenuNutritionDTO.java @@ -13,6 +13,8 @@ import java.util.List; @Data public class MenuNutritionDTO { + private Long id; + @ApiModelProperty("食材营养id") private Long nutritionId; @ApiModelProperty("食材编码") @@ -32,9 +34,7 @@ public class MenuNutritionDTO { @ApiModelProperty("食材颜色") private String color; @ApiModelProperty("食材大类") - private @NotNull( - message = "{menu_big_type_null}" - ) String bigType; + private @NotNull( message = "{menu_big_type_null}" ) String bigType; @ApiModelProperty("食材小类") private @NotNull( message = "{menu_little_type_null}" @@ -219,4 +219,6 @@ public class MenuNutritionDTO { private Integer current; private Integer size; + private Long updateBy; + private String remark; } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/enums/LeLevelEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/enums/LeLevelEnum.java new file mode 100644 index 0000000..bfdd0df --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/enums/LeLevelEnum.java @@ -0,0 +1,32 @@ +package com.bonus.canteen.core.menu.enums; + +public enum LeLevelEnum { + FIRST(1, "一级"), + SECOND(2, "二级"), + THIRD(3, "三级"), + FOURTH(4, "四级"), + FIFTH(5, "五级"), + SIXTH(6, "六级"), + SEVENTH(7, "七级"); + + private final Integer key; + private final String desc; + + private LeLevelEnum(Integer key, String desc) { + this.key = key; + this.desc = desc; + } + + public Integer getKey() { + return this.key; + } + + public String getDesc() { + return this.desc; + } + + // $FF: synthetic method + private static LeLevelEnum[] $values() { + return new LeLevelEnum[]{FIRST, SECOND, THIRD, FOURTH, FIFTH, SIXTH, SEVENTH}; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/enums/MgrRoleTypeEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/enums/MgrRoleTypeEnum.java new file mode 100644 index 0000000..80b76e5 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/enums/MgrRoleTypeEnum.java @@ -0,0 +1,44 @@ +package com.bonus.canteen.core.menu.enums; + +import java.util.Objects; + +public enum MgrRoleTypeEnum { + ROLE_ADMIN(1, "全数据类"), + ROLE_ORG(2, "组织类"), + ROLE_MERCHANT(3, "商户/仓库类"); + + private final Integer key; + private final String value; + + public static MgrRoleTypeEnum getEnumByKey(Integer key) { + MgrRoleTypeEnum[] var1 = values(); + int var2 = var1.length; + + for(int var3 = 0; var3 < var2; ++var3) { + MgrRoleTypeEnum roleType = var1[var3]; + if (Objects.equals(roleType.key, key)) { + return roleType; + } + } + + return null; + } + + public Integer getKey() { + return this.key; + } + + public String getValue() { + return this.value; + } + + private MgrRoleTypeEnum(final Integer key, final String value) { + this.key = key; + this.value = value; + } + + // $FF: synthetic method + private static MgrRoleTypeEnum[] $values() { + return new MgrRoleTypeEnum[]{ROLE_ADMIN, ROLE_ORG, ROLE_MERCHANT}; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/enums/RoleCodeEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/enums/RoleCodeEnum.java new file mode 100644 index 0000000..eac48f5 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/enums/RoleCodeEnum.java @@ -0,0 +1,85 @@ +package com.bonus.canteen.core.menu.enums; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author xliu + * @date 2025/4/9 14:39 + */ +public enum RoleCodeEnum { + ROLE_SUPER_ADMIN("ROLE_ADMIN", "管理员"), + ROLE_ADMIN("ROLE_ADMIN", "全数据类"), + ROLE_ORG("ROLE_ORG", "组织类"), + ROLE_MERCHANT("ROLE_MERCHANT", "商户/仓库类"); + + private final String key; + private final String value; + + private RoleCodeEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public static String getKey(String value) { + RoleCodeEnum[] roleCodeEnums = values(); + RoleCodeEnum[] var2 = roleCodeEnums; + int var3 = roleCodeEnums.length; + + for(int var4 = 0; var4 < var3; ++var4) { + RoleCodeEnum roleCodeEnum = var2[var4]; + if (roleCodeEnum.value().equals(value)) { + return roleCodeEnum.key(); + } + } + + return null; + } + + public static String getValue(String key) { + RoleCodeEnum[] roleCodeEnums = values(); + RoleCodeEnum[] var2 = roleCodeEnums; + int var3 = roleCodeEnums.length; + + for(int var4 = 0; var4 < var3; ++var4) { + RoleCodeEnum roleCodeEnum = var2[var4]; + if (roleCodeEnum.key().equals(key)) { + return roleCodeEnum.value(); + } + } + + return null; + } + + public static List> getAllEnumsList() { + RoleCodeEnum[] roleCodeEnums = values(); + List> roleCodeList = new ArrayList(); + RoleCodeEnum[] var2 = roleCodeEnums; + int var3 = roleCodeEnums.length; + + for(int var4 = 0; var4 < var3; ++var4) { + RoleCodeEnum roleCodeEnum = var2[var4]; + Map roleCodeMap = new HashMap(); + roleCodeMap.put("key", roleCodeEnum.key); + roleCodeMap.put("value", roleCodeEnum.value); + roleCodeList.add(roleCodeMap); + } + + return roleCodeList; + } + + public String key() { + return this.key; + } + + public String value() { + return this.value; + } + + // $FF: synthetic method + private static RoleCodeEnum[] $values() { + return new RoleCodeEnum[]{ROLE_SUPER_ADMIN, ROLE_ADMIN, ROLE_ORG, ROLE_MERCHANT}; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuMaterialCategoryMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuMaterialCategoryMapper.java index b90c212..8b6d7d8 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuMaterialCategoryMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuMaterialCategoryMapper.java @@ -2,9 +2,13 @@ package com.bonus.canteen.core.menu.mapper; import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.bonus.canteen.core.menu.domain.MenuMaterialCategory; import com.bonus.canteen.core.menu.dto.CategoryTreeListDTO; -import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVo; +import com.bonus.canteen.core.menu.po.MgrUserAuthPO; +import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVO; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; /** * 原料类别Mapper接口 @@ -12,7 +16,7 @@ import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVo; * @author xsheng * @date 2025-04-03 */ -public interface MenuMaterialCategoryMapper { +public interface MenuMaterialCategoryMapper extends BaseMapper { /** * 查询原料类别 * @@ -61,5 +65,12 @@ public interface MenuMaterialCategoryMapper { */ public int deleteMenuMaterialCategoryByIds(Long[] ids); - List selectCategoryTree(CategoryTreeListDTO content); + List selectCategoryTrees(CategoryTreeListDTO content); + @Select({"select category_id id, parent_id, category_name,category_type,area_id from menu_material_category ${ew.customSqlSegment}"}) + List selectCategoryTree(CategoryTreeListDTO content); + + @Select({"select MAX(category_num) from menu_material_category where parent_id = #{parentId} and category_type = #{categoryType} and del_flag = #{delFlag}"}) + String getCategoryChildMaxNum(@Param("parentId") Long parentId, @Param("categoryType") Integer categoryType, @Param("delFlag") Integer delFlag); + + List getTenantAreaIdList(@Param("excludeMiddle") Integer excludeMiddle, @Param("authPO") MgrUserAuthPO mgrUserAuthPO); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/po/MgrUserAuthPO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/po/MgrUserAuthPO.java new file mode 100644 index 0000000..063665c --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/po/MgrUserAuthPO.java @@ -0,0 +1,50 @@ +package com.bonus.canteen.core.menu.po; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class MgrUserAuthPO { + @ApiModelProperty("角色类型") + private Integer roleType; + @ApiModelProperty("角色编码") + private String roleCode; + @ApiModelProperty("用户id") + private Long userId; + @ApiModelProperty("用户名称") + private String userName; + + public Integer getRoleType() { + return this.roleType; + } + + public String getRoleCode() { + return this.roleCode; + } + + public Long getUserId() { + return this.userId; + } + + public String getUserName() { + return this.userName; + } + + public void setRoleType(final Integer roleType) { + this.roleType = roleType; + } + + public void setRoleCode(final String roleCode) { + this.roleCode = roleCode; + } + + public void setUserId(final Long userId) { + this.userId = userId; + } + + public void setUserName(final String userName) { + this.userName = userName; + } + + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/IMenuMaterialCategoryService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/IMenuMaterialCategoryService.java index ae2ba55..83e1ff4 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/IMenuMaterialCategoryService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/IMenuMaterialCategoryService.java @@ -2,9 +2,11 @@ package com.bonus.canteen.core.menu.service; import java.util.List; +import com.baomidou.mybatisplus.extension.service.IService; import com.bonus.canteen.core.menu.domain.MenuMaterialCategory; import com.bonus.canteen.core.menu.dto.CategoryTreeListDTO; -import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVo; +import com.bonus.canteen.core.menu.dto.MenuMaterialCategoryAddDTO; +import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVO; /** * 原料类别Service接口 @@ -12,7 +14,7 @@ import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVo; * @author xsheng * @date 2025-04-03 */ -public interface IMenuMaterialCategoryService { +public interface IMenuMaterialCategoryService extends IService { /** * 查询原料类别 * @@ -35,7 +37,7 @@ public interface IMenuMaterialCategoryService { * @param menuMaterialCategory 原料类别 * @return 结果 */ - public int insertMenuMaterialCategory(MenuMaterialCategory menuMaterialCategory); + public int insertMenuMaterialCategory(MenuMaterialCategoryAddDTO menuMaterialCategory); /** * 修改原料类别 @@ -61,5 +63,9 @@ public interface IMenuMaterialCategoryService { */ public int deleteMenuMaterialCategoryById(Long id); - List getTree(CategoryTreeListDTO content); + List getTree(CategoryTreeListDTO content); + + void syncAllCategoryBigCategoryAndLevel(); + + void generateCategoryNum(Long categoryId, Long parentId, Integer categoryType); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuMaterialCategoryServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuMaterialCategoryServiceImpl.java index c938d28..5686beb 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuMaterialCategoryServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuMaterialCategoryServiceImpl.java @@ -1,23 +1,38 @@ package com.bonus.canteen.core.menu.service.impl; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.bonus.canteen.core.menu.domain.BaseTreeNode; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.bonus.canteen.core.menu.dto.CategoryTreeListDTO; -import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVo; +import com.bonus.canteen.core.menu.dto.MenuMaterialCategoryAddDTO; +import com.bonus.canteen.core.menu.enums.MgrRoleTypeEnum; +import com.bonus.canteen.core.menu.enums.RoleCodeEnum; +import com.bonus.canteen.core.menu.po.MgrUserAuthPO; +import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVO; +import com.bonus.canteen.core.menu.enums.LeLevelEnum; +import com.bonus.canteen.core.utils.BnsConstants; +import com.bonus.canteen.core.utils.GlobalConstants; import com.bonus.canteen.core.utils.TreeNodeUtil; import com.bonus.common.core.exception.ServiceException; -import com.bonus.common.core.utils.DateUtils; import com.bonus.common.houqin.constant.DelFlagEnum; +import com.bonus.common.houqin.constant.LeConstants; +import com.bonus.common.houqin.i18n.I18n; +import com.bonus.common.houqin.utils.id.Id; +import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.system.api.model.LoginUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.bonus.canteen.core.menu.mapper.MenuMaterialCategoryMapper; import com.bonus.canteen.core.menu.domain.MenuMaterialCategory; import com.bonus.canteen.core.menu.service.IMenuMaterialCategoryService; +import org.springframework.util.CollectionUtils; /** * 原料类别Service业务层处理 @@ -26,7 +41,7 @@ import com.bonus.canteen.core.menu.service.IMenuMaterialCategoryService; * @date 2025-04-03 */ @Service -public class MenuMaterialCategoryServiceImpl implements IMenuMaterialCategoryService { +public class MenuMaterialCategoryServiceImpl extends ServiceImpl implements IMenuMaterialCategoryService { @Autowired private MenuMaterialCategoryMapper menuMaterialCategoryMapper; @@ -55,19 +70,162 @@ public class MenuMaterialCategoryServiceImpl implements IMenuMaterialCategorySer /** * 新增原料类别 * - * @param menuMaterialCategory 原料类别 + * @param content 原料类别 * @return 结果 */ @Override - public int insertMenuMaterialCategory(MenuMaterialCategory menuMaterialCategory) { - menuMaterialCategory.setCreateTime(DateUtils.getNowDate()); + public int insertMenuMaterialCategory(MenuMaterialCategoryAddDTO content) { try { - return menuMaterialCategoryMapper.insertMenuMaterialCategory(menuMaterialCategory); + int num = 0; + Long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getCategoryName, content.getCategoryName()) + .eq(content.getAreaId() != null, MenuMaterialCategory::getAreaId, + content.getAreaId()) + .isNull(content.getAreaId() == null, MenuMaterialCategory::getAreaId) + .eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key())); + if (ObjectUtil.isNotNull(count) && count > 0L) { + throw new ServiceException(I18n.getMessage("menu_material_name_repeat", new Object[0])); + } else { + Long parentId = content.getParentId(); + if (ObjectUtil.isNotNull(parentId) && parentId != -1L) { + Long countParent = this.baseMapper.selectCount(Wrappers.lambdaQuery(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getCategoryId, parentId)); + if (ObjectUtil.isNull(countParent) || countParent <= 0L) { + throw new ServiceException(I18n.getMessage("menu_parent_type_not_exist", new Object[0])); + } + } + + String username = SecurityUtils.getUsername(); + MenuMaterialCategory materialCategory = new MenuMaterialCategory(); + BeanUtil.copyProperties(content, materialCategory, new String[0]); + materialCategory.setCategoryId(Id.next()); + materialCategory.setCreateBy(username); + this.syncAllCategoryBigCategoryAndLevel(); + MenuMaterialCategory parentCategory = this.baseMapper.selectOne( + Wrappers.lambdaQuery(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getCategoryId, content.getParentId()) + .select(MenuMaterialCategory::getCategoryId, MenuMaterialCategory::getLevel, + MenuMaterialCategory::getBigCategoryId)); + materialCategory.setLevel(parentCategory.getLevel() + 1); + materialCategory.setBigCategoryId(parentCategory.getBigCategoryId()); + num = this.baseMapper.insert(materialCategory); + // MqUtil.pushToTenantAllDevice(materialCategory, LeMqConstant.Topic.DRP_SYNC_MATERIAL_BIG_CATEGORY); + this.generateCategoryNum(materialCategory.getCategoryId(), materialCategory.getParentId(), materialCategory.getCategoryType()); + + } + //return menuMaterialCategoryMapper.insertMenuMaterialCategory(menuMaterialCategory); + return num; } catch (Exception e) { throw new ServiceException("错误信息描述"); } } + @Override + public void generateCategoryNum(Long categoryId, Long parentId, Integer categoryType) { + MenuMaterialCategory parentCategory = this.baseMapper.selectOne(Wrappers.lambdaQuery(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getCategoryId, parentId) + .eq(MenuMaterialCategory::getCategoryType, categoryType) + .eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key()) + .select(MenuMaterialCategory::getCategoryId, MenuMaterialCategory::getParentId, + MenuMaterialCategory::getCategoryNum)); + if (ObjectUtil.isNotEmpty(parentCategory)) { + if (CharSequenceUtil.isNotEmpty(parentCategory.getCategoryNum())) { + String maxCategoryNum = this.baseMapper.getCategoryChildMaxNum(parentCategory.getCategoryId(), categoryType, + DelFlagEnum.DEL_FALSE.key()); + String categoryNum = ""; + if (CharSequenceUtil.isNotEmpty(maxCategoryNum)) { + String lastStr = maxCategoryNum.substring(maxCategoryNum.lastIndexOf("-") + 1); + String lastNum = String.format("%02d", Integer.parseInt(lastStr) + 1); + String var10000 = parentCategory.getCategoryNum(); + categoryNum = var10000 + "-" + lastNum; + } else { + categoryNum = parentCategory.getCategoryNum() + "-01"; + } + + this.baseMapper.update(null, Wrappers.lambdaUpdate(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getCategoryId, categoryId) + .set(MenuMaterialCategory::getCategoryNum, categoryNum)); + } else { + this.generateCategoryNum(parentCategory.getCategoryId(), parentCategory.getParentId(), categoryType); + } + } else { + this.baseMapper.update(null,Wrappers.lambdaUpdate(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getParentId, -1).eq(MenuMaterialCategory::getCategoryType, categoryType) + .set(MenuMaterialCategory::getCategoryNum, categoryType)); + } + + MenuMaterialCategory menuMaterialCategory = this.baseMapper.selectOne(Wrappers.lambdaQuery(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getCategoryId, categoryId).eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key()) + .select(MenuMaterialCategory::getCategoryNum)); + if (!ObjectUtil.isNotEmpty(menuMaterialCategory) || !CharSequenceUtil.isNotEmpty(menuMaterialCategory.getCategoryNum())) { + this.generateCategoryNum(categoryId, parentId, categoryType); + } + } + + @Override + public void syncAllCategoryBigCategoryAndLevel() { + Long checkIfExistLevel = this.baseMapper.selectCount(new LambdaQueryWrapper<>(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key()) + .isNull(MenuMaterialCategory::getBigCategoryId).or() + .isNull(MenuMaterialCategory::getLevel)); + System.err.println("[货品类别_所有货品类别的所属大类和等级]_未赋值大类id和等级的类别数量:{}"+checkIfExistLevel); + if (checkIfExistLevel <= 0L) { + System.err.println("[货品类别_所有货品类别的所属大类和等级]_不需要同步,跳过!"); + } else { + List topCategoryList = this.baseMapper.selectList(Wrappers.lambdaQuery(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getParentId, -1).eq(MenuMaterialCategory::getDelFlag, + DelFlagEnum.DEL_FALSE.key())); + Iterator var3 = topCategoryList.iterator(); + + while(true) { + List menuMaterialCategoryList; + do { + if (!var3.hasNext()) { + return; + } + + MenuMaterialCategory topCategory = (MenuMaterialCategory)var3.next(); + this.baseMapper.update(null,Wrappers.lambdaUpdate(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getCategoryId, topCategory.getCategoryId()) + .set(MenuMaterialCategory::getLevel, 0) + .set(MenuMaterialCategory::getBigCategoryId, topCategory.getCategoryId())); + menuMaterialCategoryList = this.baseMapper.selectList(Wrappers.lambdaQuery(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getParentId, topCategory.getCategoryId())); + } while(CollUtil.isEmpty(menuMaterialCategoryList)); + + Iterator var6 = menuMaterialCategoryList.iterator(); + + while(var6.hasNext()) { + MenuMaterialCategory menuMaterialCategory = (MenuMaterialCategory)var6.next(); + this.baseMapper.update(null, Wrappers.lambdaUpdate(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getCategoryId, menuMaterialCategory.getCategoryId()) + .set(MenuMaterialCategory::getLevel, LeLevelEnum.FIRST.getKey()) + .set(MenuMaterialCategory::getBigCategoryId, menuMaterialCategory.getCategoryId())); + menuMaterialCategory.setLevel(LeLevelEnum.FIRST.getKey()); + menuMaterialCategory.setBigCategoryId(menuMaterialCategory.getCategoryId()); + this.setChildBigCategoryAndLevel(menuMaterialCategory, LeLevelEnum.FIRST.getKey() + 1, menuMaterialCategory.getCategoryId()); + } + } + } + } + + public void setChildBigCategoryAndLevel(MenuMaterialCategory parentCategory, Integer level, Long bigCategoryId) { + List childCategoryList = this.baseMapper.selectList(Wrappers.lambdaQuery(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getParentId, parentCategory.getCategoryId())); + if (!CollUtil.isEmpty(childCategoryList)) { + Iterator var5 = childCategoryList.iterator(); + + while(var5.hasNext()) { + MenuMaterialCategory childCategory = (MenuMaterialCategory)var5.next(); + this.baseMapper.update(null, Wrappers.lambdaUpdate(MenuMaterialCategory.class) + .eq(MenuMaterialCategory::getCategoryId, childCategory.getCategoryId()) + .set(MenuMaterialCategory::getLevel, level) + .set(MenuMaterialCategory::getBigCategoryId, bigCategoryId)); + this.setChildBigCategoryAndLevel(childCategory, level + 1, bigCategoryId); + } + + } + } /** * 修改原料类别 * @@ -76,7 +234,6 @@ public class MenuMaterialCategoryServiceImpl implements IMenuMaterialCategorySer */ @Override public int updateMenuMaterialCategory(MenuMaterialCategory menuMaterialCategory) { - menuMaterialCategory.setUpdateTime(DateUtils.getNowDate()); try { return menuMaterialCategoryMapper.updateMenuMaterialCategory(menuMaterialCategory); } catch (Exception e) { @@ -107,12 +264,85 @@ public class MenuMaterialCategoryServiceImpl implements IMenuMaterialCategorySer } @Override - public List getTree(CategoryTreeListDTO content) { + public List getTree(CategoryTreeListDTO content) { +// LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper(); +// lambdaQueryWrapper.eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key()); +// content.setAreaAuth(getTenantAreaIdList(BnsConstants.COMMON_YES)); +// if (ObjectUtil.isNotEmpty(content.getCategoryType())) { +// lambdaQueryWrapper.eq(MenuMaterialCategory::getCategoryType, content.getCategoryType()); +// } +// +// if (ObjectUtil.isNotEmpty(content.getAreaId())) { +// lambdaQueryWrapper.and((i) -> { +// i.eq(MenuMaterialCategory::getAreaId, content.getAreaId()).or() +// .isNull(MenuMaterialCategory::getAreaId); +// }); +// } +// +// if (ObjectUtil.isNotEmpty(content.getAreaAuth())) { +// lambdaQueryWrapper.and((i) -> { +// i.in(MenuMaterialCategory::getAreaId, content.getAreaAuth()).or() +// .isNull(MenuMaterialCategory::getAreaId); +// }); +// } +// +// if (ObjectUtil.isNotEmpty(content.getIfAdd()) && ObjectUtil.isEmpty(content.getAreaId())) { +// lambdaQueryWrapper.isNull(MenuMaterialCategory::getAreaId); +// } +// +// List sqlList = this.baseMapper.selectCategoryTree(lambdaQueryWrapper); + + // Map areaNameMap = this.allocCanteenApi.getAreaNameMap(sqlList.stream().map(MenuCategoryTreeVO::getAreaId).filter(Objects::nonNull).collect(Collectors.toList())); + + + List list = menuMaterialCategoryMapper.selectCategoryTrees(content); + - List list = menuMaterialCategoryMapper.selectCategoryTree(content); return TreeNodeUtil.assembleTree(list); } + public List getTenantAreaIdList(Integer excludeMiddle) { + MgrUserAuthPO mgrUserAuthPO = this.getUserAuthPO(); + return ObjectUtil.equal(mgrUserAuthPO.getRoleType(), LeConstants.DATA_DEFAULT_INTEGER) ? CollUtil.newArrayList(new Long[0]) : menuMaterialCategoryMapper.getTenantAreaIdList(excludeMiddle, mgrUserAuthPO); + } + public MgrUserAuthPO getUserAuthPO() { + MgrUserAuthPO userAuthPO = new MgrUserAuthPO(); + LoginUser user = SecurityUtils.getLoginUser(); + user.setUserid(SecurityUtils.getUserId()); + user.setUsername(SecurityUtils.getUsername()); + Set roleSet = user.getRoles(); + if (CollectionUtils.isEmpty(roleSet)) { + throw new ServiceException(I18n.getMessage("auth_user_no_role_code", new Object[0])); + } + Integer roleType = null; + String roleCodeResult = null; + for (String roleCode : roleSet) { + roleCodeResult = roleCode; + if (roleCode.startsWith(RoleCodeEnum.ROLE_ADMIN.key()) || GlobalConstants.SUPER_ADMIN_ROLE_KEY.equals(roleCode)) { + roleType = MgrRoleTypeEnum.ROLE_ADMIN.getKey(); +// if (CharSequenceUtil.split(roleCode, "&&").size() > 1) { +// roleType = MgrRoleTypeV2Enum.ROLE_ADMIN.getKey(); +// } else { +// roleType = LeConstants.DATA_DEFAULT_INTEGER; +// } + break; + } else if (roleCode.startsWith(RoleCodeEnum.ROLE_ORG.key())) { + roleType = MgrRoleTypeEnum.ROLE_ORG.getKey(); + break; + } else { + if (!roleCode.startsWith(RoleCodeEnum.ROLE_MERCHANT.key())) { + throw new ServiceException(I18n.getMessage("auth_role_type_error", new Object[0])); + } + roleType = MgrRoleTypeEnum.ROLE_MERCHANT.getKey(); + break; + } + } + userAuthPO.setUserId(user.getUserid()); + userAuthPO.setRoleType(roleType); + userAuthPO.setRoleCode(roleCodeResult); + userAuthPO.setUserName(user.getUsername()); + return userAuthPO; + } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuNutritionServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuNutritionServiceImpl.java index f5c6fbe..36d9609 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuNutritionServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuNutritionServiceImpl.java @@ -93,10 +93,14 @@ public class MenuNutritionServiceImpl implements IMenuNutritionService { return menuNutritionMapper.updateMenuNutrition(menuNutritionDTO); }else{ + if(menuNutrition == null){ + menuNutrition = new MenuNutrition(); + } Long nutritionId = Id.next(); menuNutrition.setNutritionId(Id.next()); menuNutrition.setCrby(username); menuNutrition.setId(nutritionId); + BnsUtils.copyProperties(menuNutritionDTO, menuNutrition); return menuNutritionMapper.insertMenuNutrition(menuNutrition); } } catch (Exception e) { @@ -151,7 +155,7 @@ public class MenuNutritionServiceImpl implements IMenuNutritionService { } return menuNutritionMapper.updateMenuNutrition(menuNutritionDTO); } catch (Exception e) { - throw new ServiceException("错误信息描述"); + throw new ServiceException(e.toString()); } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/vo/MenuCategoryTreeVo.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/vo/MenuCategoryTreeVO.java similarity index 89% rename from bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/vo/MenuCategoryTreeVo.java rename to bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/vo/MenuCategoryTreeVO.java index bbcd677..085d1ae 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/vo/MenuCategoryTreeVo.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/vo/MenuCategoryTreeVO.java @@ -11,7 +11,7 @@ import java.io.Serializable; * @date 2025/4/7 16:49 */ @Data -public class MenuCategoryTreeVo extends BaseTreeNode implements Serializable { +public class MenuCategoryTreeVO extends BaseTreeNode implements Serializable { @ApiModelProperty("区域ID") private Long areaId; @ApiModelProperty("区域名称") diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/utils/BnsConstants.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/utils/BnsConstants.java new file mode 100644 index 0000000..c5a890d --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/utils/BnsConstants.java @@ -0,0 +1,32 @@ +package com.bonus.canteen.core.utils; + +/** + * @author xliu + * @date 2025/4/9 14:34 + */ +public interface BnsConstants { + String ID_TEMPORARY_PRE = "xnznkjxnznkj"; + String NUM_PRE = "0"; + Long DATA_DEFAULT_LONG = -1L; + Integer DATA_DEFAULT_INTEGER = -1; + Integer COMMON_YES = 1; + Integer COMMON_NO = 2; + Integer MAX_CARD_NUM = 100000; + Integer MAX_CUST_LIMIT_ID = 65535; + Integer MIN_DATA_NUM = 1; + Integer MAX_CUST_PSN_TYPE = 100; + String DEFAULT_GRADE_NAME = "普通会员"; + String DEFAULT_PSN_TYPE_NAME = "类别"; + String MAPPING_OBJECT = "object"; + String MAPPING_PAGE = "page"; + String MERCHANT_ID = "MERCHANT-ID"; + String MERCHANT_ID_LOW = "merchant-id"; + String OPENID = "openid"; + String SOURCE_TYPE = "source-type"; + String FACE_VER = "face-ver"; + String MACHINE_SN = "machine-sn"; + String MACHINE_NUM = "machine-num"; + String MERCHANT_DEFAULT = "(默认)"; + String DEFAULT_ORG_NUM = "0"; + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/utils/GlobalConstants.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/utils/GlobalConstants.java new file mode 100644 index 0000000..8711692 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/utils/GlobalConstants.java @@ -0,0 +1,81 @@ +package com.bonus.canteen.core.utils; + +/** + * 全局常量 + * @author bns_han + */ +public class GlobalConstants { + /** + * super admin role key + */ + public static final String SUPER_ADMIN_ROLE_KEY = "admin"; + /** + * 字符串 MSIE + */ + public static final String STRING_MSIE = "MSIE"; + /** + * 字符串 Firefox + */ + public static final String STRING_FIREFOX = "Firefox"; + /** + * 字符串 Chrome + */ + public static final String STRING_CHROME = "Chrome"; + /** + * 字符串 #// + */ + public static final String STRING_HASH_HASH = "#//"; + /** + * 字符串 unknown + */ + public static final String STRING_UNKNOWN = "unknown"; + /** + * 字符串 , + */ + public static final String STRING_COMMA = ","; + /** + * 字符串 * + */ + public static final String STRING_ASTERISK = "*"; + /** + * 字符串 ascending + */ + public static final String STRING_ASCENDING = "ascending"; + /** + * 字符串 descending + */ + public static final String STRING_DESCENDING = "descending"; + /** + * 字符串 application/json + */ + public static final String STRING_APPLICATION_JSON = "application/json"; + /** + * 字符串 XMLHttpRequest + */ + public static final String STRING_XML_HTTP_REQUEST = "XMLHttpRequest"; + /** + * 字符串 .json + */ + public static final String STRING_JSON = ".json"; + /** + * 字符串 .xml + */ + public static final String STRING_XML = ".xml"; + /** + * 字符串 _ + */ + public static final String STRING_UNDERLINE = "_"; + /** + * 字符串 win + */ + public static final String STRING_WIN = "win"; + /** + * 字符串 ok + */ + public static final String STRING_OK = "ok"; + /** + * 字符串 true + */ + public static final String STRING_TRUE = "true"; + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuMaterialCategoryMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuMaterialCategoryMapper.xml index 3bc65d3..0d67f6b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuMaterialCategoryMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuMaterialCategoryMapper.xml @@ -113,7 +113,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select category_id as id, parent_id as parentId, category_name as categoryName,category_type as categoryType,area_id as areaId from menu_material_category + + diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionMapper.xml index 98b44c1..89a19f4 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionMapper.xml @@ -130,103 +130,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -452,21 +359,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update menu_nutrition - nutrition_id = #{nutritionId}, nutrition_code = #{nutritionCode}, nutrition_name = #{nutritionName}, - nutrition_image_url = #{nutritionImageUrl}, - weight = #{weight}, - price = #{price}, - color = #{color}, - category_id = #{categoryId}, big_type = #{bigType}, little_type = #{littleType}, - label = #{label}, - processing_method = #{processingMethod}, processing_time = #{processingTime}, - recommended_combination = #{recommendedCombination}, - combination_not_recommended = #{combinationNotRecommended}, + edible = #{edible}, water = #{water}, calories = #{calories}, @@ -474,6 +372,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" fat = #{fat}, carbohydrate = #{carbohydrate}, dietary_fiber = #{dietaryFiber}, + cholesterol = #{cholesterol}, ash = #{ash}, vitamin_a = #{vitaminA}, @@ -548,12 +447,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" iodine = #{iodine}, folic = #{folic}, retinol = #{retinol}, - default_flag = #{defaultFlag}, - revision = #{revision}, - create_by = #{createBy}, - create_time = #{createTime}, update_by = #{updateBy}, - update_time = #{updateTime}, remark = #{remark}, where id = #{id} @@ -573,7 +467,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"