diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/CanteenDishesDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/CanteenDishesDTO.java new file mode 100755 index 0000000000..9d8d22d430 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/CanteenDishesDTO.java @@ -0,0 +1,58 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 日照:食堂菜品 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +@Data +public class CanteenDishesDTO implements Serializable { + + private static final long serialVersionUID = -6277790230274824935L; + + /** + * 菜品主键ID + */ + private String id; + + /** + * 食堂ID + */ + private String canteenId; + + /** + * 菜品名称 + */ + private String name; + + /** + * 菜品编码 + */ + private String code; + + /** + * 菜品单价 + */ + private BigDecimal price; + + /** + * 菜品图片 + */ + private String img; + + /** + * 在售状态 0、上架 1、下架 + */ + private Integer status; + + /** + * 排序 + */ + private Integer sort; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/CanteenMenusDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/CanteenMenusDTO.java new file mode 100755 index 0000000000..5f9f6781db --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/CanteenMenusDTO.java @@ -0,0 +1,55 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 日照:社区食堂菜单 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +@Data +public class CanteenMenusDTO implements Serializable { + + private static final long serialVersionUID = 548014811507509126L; + + /** + * 菜单主键ID + */ + private String id; + + /** + * 社区食堂主键ID + */ + private String canteenId; + + /** + * 菜品 + */ + private String[] dishesMenus; + + /** + * 菜单应用开始时间 + */ + private String startTime; + + /** + * 菜单应用结束时间 + */ + private String endTime; + + /** + * 0、早餐 1、午餐 2、晚餐 + */ + private Integer meals; + + /** + * 是否默认菜单 0、否 1、是 + */ + private Integer def; + + private String dishesName; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/CanteenMenusListDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/CanteenMenusListDTO.java new file mode 100644 index 0000000000..ccb5787f01 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/CanteenMenusListDTO.java @@ -0,0 +1,52 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author yan Lu + * @description 菜单列表对象 + * @create 2023/8/18 10:24 + */ +@Data +public class CanteenMenusListDTO implements Serializable { + + private static final long serialVersionUID = 643911101457641518L; + + /** + * 菜单日期 + */ + private String time; + + /** + * 食堂ID + */ + private String canteenId; + + /** + * 菜单详情参数 + */ + private List mealses; + + @Data + public static class CanteenMenus { + /** + * 菜单ID + */ + private String id; + /** + * 三餐标示 0、早餐 1、中餐 2、晚餐 + */ + private Integer meals; + /** + * 菜单菜品名称 + */ + private String dishesNames; + /** + * 菜品ID + */ + private String[] dishesMenus; + } +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/CommunityCanteenDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/CommunityCanteenDTO.java new file mode 100755 index 0000000000..e019148eff --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/CommunityCanteenDTO.java @@ -0,0 +1,91 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 日照:社区食堂 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-14 + */ +@Data +public class CommunityCanteenDTO implements Serializable { + + private static final long serialVersionUID = -8077509649657658146L; + + /** + * 社区食堂主键ID + */ + private String id; + + /** + * 社区食堂名称 + */ + private String name; + + /** + * 社区食堂地址 + */ + private String address; + + /** + * 组织Id + */ + private String agencyId; + + private String agencyName; + + /** + * 负责人 + */ + private String principal; + + /** + * 负责人电话 + */ + private String mobile; + + /** + * 营业状态 0、营业中 1、歇业 + */ + private Integer business; + + /** + * 三餐供给(0,1,2):0、早餐 1、午餐 2、晚餐 + */ + private String[] threeMeals; + + /** + * 经度 + */ + private String longitude; + + /** + * 纬度 + */ + private String latitude; + + /** + * 营业时间 08:00,18:00 + */ + private String[] businessHours; + + /** + * 食堂图片 + */ + private String imgUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 备注 + */ + private String remarks; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/CanteenDishesController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/CanteenDishesController.java new file mode 100755 index 0000000000..af04db7d08 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/CanteenDishesController.java @@ -0,0 +1,76 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.CanteenDishesDTO; +import com.epmet.service.CanteenDishesService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + + +/** + * 日照:食堂菜品 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +@RestController +@RequestMapping("canteenDishes") +public class CanteenDishesController { + + @Autowired + private CanteenDishesService canteenDishesService; + + @RequestMapping("page") + public Result> page(@RequestBody Map params) { + PageData page = canteenDishesService.page(params); + return new Result>().ok(page); + } + + @RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET}) + public Result get(@PathVariable("id") String id) { + CanteenDishesDTO data = canteenDishesService.get(id); + return new Result().ok(data); + } + + @RequestMapping(value = "list",method = {RequestMethod.POST,RequestMethod.GET}) + public Result> list(@RequestBody Map params) { + return new Result>().ok(canteenDishesService.list(params)); + } + + @NoRepeatSubmit + @PostMapping("save") + public Result save(@RequestBody CanteenDishesDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + canteenDishesService.save(dto); + return new Result(); + } + + @NoRepeatSubmit + @PostMapping("update") + public Result update(@RequestBody CanteenDishesDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + canteenDishesService.update(dto); + return new Result(); + } + + @PostMapping("delete") + public Result delete(@RequestBody String[] ids) { + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + canteenDishesService.delete(ids); + return new Result(); + } + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/CanteenMenusController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/CanteenMenusController.java new file mode 100755 index 0000000000..c48c9c680c --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/CanteenMenusController.java @@ -0,0 +1,92 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.CanteenMenusDTO; +import com.epmet.dto.CanteenMenusListDTO; +import com.epmet.service.CanteenMenusService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + + +/** + * 日照:社区食堂菜单 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +@RestController +@RequestMapping("canteenMenus") +public class CanteenMenusController { + + @Autowired + private CanteenMenusService canteenMenusService; + + @RequestMapping("page") + public Result> page(@RequestBody Map params) { + PageData page = canteenMenusService.page(params); + return new Result>().ok(page); + } + + @RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET}) + public Result get(@PathVariable("id") String id) { + CanteenMenusDTO data = canteenMenusService.get(id); + return new Result().ok(data); + } + + @RequestMapping(value = "list", method = {RequestMethod.POST, RequestMethod.GET}) + public Result> list(@RequestBody Map params) { + return new Result>().ok(canteenMenusService.list(params)); + } + + @RequestMapping("historyMenus") + public Result> historyMenus(@RequestBody Map params) { + return new Result>().ok(canteenMenusService.historyMenus((String) params.get("canteenId"))); + } + + @NoRepeatSubmit + @PostMapping("save") + public Result save(@RequestBody CanteenMenusDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + canteenMenusService.save(dto); + return new Result(); + } + + + @NoRepeatSubmit + @PostMapping("saveOrUpdate") + public Result saveOrUpdate(@RequestBody CanteenMenusDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + canteenMenusService.saveOrUpdateDto(dto); + return new Result(); + } + + @NoRepeatSubmit + @PostMapping("update") + public Result update(@RequestBody CanteenMenusDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + canteenMenusService.update(dto); + return new Result(); + } + + @PostMapping("delete") + public Result delete(@RequestBody String[] ids) { + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + canteenMenusService.delete(ids); + return new Result(); + } + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/CommunityCanteenController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/CommunityCanteenController.java new file mode 100755 index 0000000000..3df06a3f6c --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/CommunityCanteenController.java @@ -0,0 +1,70 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.CommunityCanteenDTO; +import com.epmet.service.CommunityCanteenService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 日照:社区食堂 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-14 + */ +@RestController +@RequestMapping("communityCanteen") +public class CommunityCanteenController { + + @Autowired + private CommunityCanteenService communityCanteenService; + + @RequestMapping("page") + public Result> page(@RequestBody Map params) { + PageData page = communityCanteenService.page(params); + return new Result>().ok(page); + } + + @RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET}) + public Result get(@PathVariable("id") String id) { + CommunityCanteenDTO data = communityCanteenService.get(id); + return new Result().ok(data); + } + + @NoRepeatSubmit + @PostMapping("save") + public Result save(@RequestBody CommunityCanteenDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + communityCanteenService.save(dto); + return new Result(); + } + + @NoRepeatSubmit + @PostMapping("update") + public Result update(@RequestBody CommunityCanteenDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + communityCanteenService.update(dto); + return new Result(); + } + + @PostMapping("delete") + public Result delete(@RequestBody String[] ids) { + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + communityCanteenService.delete(ids); + return new Result(); + } + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/CanteenDishesDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/CanteenDishesDao.java new file mode 100755 index 0000000000..ad92ca7ce2 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/CanteenDishesDao.java @@ -0,0 +1,16 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.CanteenDishesEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 日照:食堂菜品 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +@Mapper +public interface CanteenDishesDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/CanteenMenusDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/CanteenMenusDao.java new file mode 100755 index 0000000000..c38a990c8a --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/CanteenMenusDao.java @@ -0,0 +1,21 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.CanteenMenusEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 日照:社区食堂菜单 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +@Mapper +public interface CanteenMenusDao extends BaseDao { + + List historyMenus(@Param("canteenId") String canteenId); + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/CommunityCanteenDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/CommunityCanteenDao.java new file mode 100755 index 0000000000..98c908a911 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/CommunityCanteenDao.java @@ -0,0 +1,22 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.CommunityCanteenEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 日照:社区食堂 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-14 + */ +@Mapper +public interface CommunityCanteenDao extends BaseDao { + + /** + * 根据agencyId获取食堂的ID + * @param agencyId + * @return + */ + String getCanteentByAgencyId(String agencyId); +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/CanteenDishesEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/CanteenDishesEntity.java new file mode 100755 index 0000000000..aa7258c6b6 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/CanteenDishesEntity.java @@ -0,0 +1,68 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; + +/** + * 日照:食堂菜品 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("canteen_dishes") +public class CanteenDishesEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * 组织ID + */ + private String agencyId; + + /** + * 食堂ID + */ + private String canteenId; + + /** + * 菜品名称 + */ + private String name; + + /** + * 菜品编码 + */ + private String code; + + /** + * 菜品单价 + */ + private BigDecimal price; + + /** + * 菜品图片 + */ + private String img; + + /** + * 在售状态 0、上架 1、下架 + */ + private Integer status; + + /** + * 排序 + */ + private Integer sort; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/CanteenMenusEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/CanteenMenusEntity.java new file mode 100755 index 0000000000..1d58043d04 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/CanteenMenusEntity.java @@ -0,0 +1,56 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 日照:社区食堂菜单 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("canteen_menus") +public class CanteenMenusEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + private String customerId; + + private String agencyId; + + /** + * 社区食堂主键ID + */ + private String canteenId; + + /** + * 菜品 + */ + private String dishesMenus; + + /** + * 菜单应用开始时间 + */ + private Date startTime; + + /** + * 菜单应用结束时间 + */ + private Date endTime; + + /** + * 0、早餐 1、午餐 2、晚餐 + */ + private Integer meals; + + /** + * 是否默认菜单 0、否 1、是 + */ + private Integer def; +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/CommunityCanteenEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/CommunityCanteenEntity.java new file mode 100755 index 0000000000..0f1de80b74 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/CommunityCanteenEntity.java @@ -0,0 +1,91 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 日照:社区食堂 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-14 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("community_canteen") +public class CommunityCanteenEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * 社区食堂名称 + */ + private String name; + + /** + * 社区食堂地址 + */ + private String address; + + /** + * 组织Id + */ + private String agencyId; + + /** + * 负责人 + */ + private String principal; + + /** + * 负责人电话 + */ + private String mobile; + + /** + * 营业状态 0、营业中 1、歇业 + */ + private Integer business; + + /** + * 三餐供给(0,1,2):0、早餐 1、午餐 2、晚餐 + */ + private String threeMeals; + + /** + * 经度 + */ + private String longitude; + + /** + * 纬度 + */ + private String latitude; + + /** + * 营业时间 08:00,18:00 + */ + private String businessHours; + + /** + * 食堂图片 + */ + private String imgUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 备注 + */ + private String remarks; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CanteenDishesExcel.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CanteenDishesExcel.java new file mode 100755 index 0000000000..6b83ad4a5e --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CanteenDishesExcel.java @@ -0,0 +1,61 @@ +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 日照:食堂菜品 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +@Data +public class CanteenDishesExcel { + + @Excel(name = "菜品主键ID") + private String id; + + @Excel(name = "客户Id") + private String customerId; + + @Excel(name = "菜品名称") + private String name; + + @Excel(name = "菜品编码") + private String code; + + @Excel(name = "菜品单价") + private BigDecimal price; + + @Excel(name = "菜品图片") + private String img; + + @Excel(name = "在售状态 0、上架 1、下架") + private Integer status; + + @Excel(name = "排序") + private Integer sort; + + @Excel(name = "删除标识:0.未删除 1.已删除") + private Integer delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CanteenMenusExcel.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CanteenMenusExcel.java new file mode 100755 index 0000000000..483f7d8553 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CanteenMenusExcel.java @@ -0,0 +1,57 @@ +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 日照:社区食堂菜单 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +@Data +public class CanteenMenusExcel { + + @Excel(name = "菜单主键ID") + private String id; + + @Excel(name = "社区食堂主键ID") + private String canteenId; + + @Excel(name = "菜品") + private String dishesMenus; + + @Excel(name = "菜单应用开始时间") + private Date startTime; + + @Excel(name = "菜单应用结束时间") + private Date endTime; + + @Excel(name = "0、早餐 1、午餐 2、晚餐") + private Integer meals; + + @Excel(name = "是否默认菜单 0、否 1、是") + private Integer def; + + @Excel(name = "删除标识:0.未删除 1.已删除") + private Integer delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CommunityCanteenExcel.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CommunityCanteenExcel.java new file mode 100755 index 0000000000..e2f9a6b89f --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CommunityCanteenExcel.java @@ -0,0 +1,81 @@ +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 日照:社区食堂 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-14 + */ +@Data +public class CommunityCanteenExcel { + + @Excel(name = "社区食堂主键ID") + private String id; + + @Excel(name = "客户Id") + private String customerId; + + @Excel(name = "社区食堂名称") + private String name; + + @Excel(name = "社区食堂地址") + private String address; + + @Excel(name = "组织Id") + private String agencyId; + + @Excel(name = "负责人") + private String principal; + + @Excel(name = "负责人电话") + private String mobile; + + @Excel(name = "营业状态 0、营业中 1、歇业") + private Integer business; + + @Excel(name = "三餐供给(0,1,2):0、早餐 1、午餐 2、晚餐") + private String threeMeals; + + @Excel(name = "经度") + private String longitude; + + @Excel(name = "纬度") + private String latitude; + + @Excel(name = "营业时间 08:00,18:00") + private String businessHours; + + @Excel(name = "食堂图片") + private String imgUrl; + + @Excel(name = "排序字段") + private Integer sort; + + @Excel(name = "备注") + private String remarks; + + @Excel(name = "删除标识:0.未删除 1.已删除") + private Integer delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/CanteenDishesService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/CanteenDishesService.java new file mode 100755 index 0000000000..31d1a0cc1f --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/CanteenDishesService.java @@ -0,0 +1,85 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.CanteenDishesDTO; +import com.epmet.entity.CanteenDishesEntity; + +import java.util.List; +import java.util.Map; + +/** + * 日照:食堂菜品 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +public interface CanteenDishesService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2023-08-16 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2023-08-16 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return CanteenDishesDTO + * @author generator + * @date 2023-08-16 + */ + CanteenDishesDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2023-08-16 + */ + void save(CanteenDishesDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2023-08-16 + */ + void update(CanteenDishesDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2023-08-16 + */ + void delete(String[] ids); + + /** + * 根据id获取菜品信息 + * @param dishesIds + * @return + */ + List selectByIds(List dishesIds); +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/CanteenMenusService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/CanteenMenusService.java new file mode 100755 index 0000000000..dc61ddb619 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/CanteenMenusService.java @@ -0,0 +1,91 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.CanteenMenusDTO; +import com.epmet.dto.CanteenMenusListDTO; +import com.epmet.entity.CanteenMenusEntity; + +import java.util.List; +import java.util.Map; + +/** + * 日照:社区食堂菜单 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +public interface CanteenMenusService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2023-08-16 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2023-08-16 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return CanteenMenusDTO + * @author generator + * @date 2023-08-16 + */ + CanteenMenusDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2023-08-16 + */ + void save(CanteenMenusDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2023-08-16 + */ + void update(CanteenMenusDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2023-08-16 + */ + void delete(String[] ids); + + /** + * 获取历史菜单 + * @return + */ + List historyMenus(String canteenId); + + /** + * 自定义保存或更新 + * @param dto + */ + void saveOrUpdateDto(CanteenMenusDTO dto); +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/CommunityCanteenService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/CommunityCanteenService.java new file mode 100755 index 0000000000..5859afd1eb --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/CommunityCanteenService.java @@ -0,0 +1,85 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.CommunityCanteenDTO; +import com.epmet.entity.CommunityCanteenEntity; + +import java.util.List; +import java.util.Map; + +/** + * 日照:社区食堂 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-14 + */ +public interface CommunityCanteenService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2023-08-14 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2023-08-14 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return CommunityCanteenDTO + * @author generator + * @date 2023-08-14 + */ + CommunityCanteenDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2023-08-14 + */ + void save(CommunityCanteenDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2023-08-14 + */ + void update(CommunityCanteenDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2023-08-14 + */ + void delete(String[] ids); + + /** + * 根据AgencyId获取食堂ID + * @param agencyId + * @return + */ + String getCanteentByAgencyId(String agencyId); +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/CanteenDishesServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/CanteenDishesServiceImpl.java new file mode 100755 index 0000000000..b5dd6ed0b3 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/CanteenDishesServiceImpl.java @@ -0,0 +1,134 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.CanteenDishesDao; +import com.epmet.dto.CanteenDishesDTO; +import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.entity.CanteenDishesEntity; +import com.epmet.remote.EpmetUserRemoteService; +import com.epmet.service.CanteenDishesService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 日照:食堂菜品 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +@Service +public class CanteenDishesServiceImpl extends BaseServiceImpl implements CanteenDishesService { + + /** + * 菜品编码前缀 + */ + private static final String PREFIX = "ST"; + + @Resource + private EpmetUserRemoteService remoteService; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, CanteenDishesDTO.class); + } + + @Override + public List list(Map params) { + params.put("status", 0); + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, CanteenDishesDTO.class); + } + + private QueryWrapper getWrapper(Map params) { + QueryWrapper wrapper = new QueryWrapper<>(); + String id = (String) params.get(FieldConstant.ID_HUMP); + String name = (String) params.get(FieldConstant.NAME_HUMP); + String canteenId = (String) params.get("canteenId"); + if (null != params.get("status")) { + if (StringUtils.isNotEmpty(String.valueOf(params.get("status")))) { + Integer state = (Integer) params.get("status"); + wrapper.eq(true, "STATUS", state); + } + } + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + wrapper.like(StringUtils.isNotBlank(name), FieldConstant.NAME, name); + wrapper.eq(StringUtils.isNotEmpty(canteenId), "CANTEEN_ID", canteenId); + LoginUserDetailsResultDTO userDetails = remoteService.getLoginUserDetails(); + wrapper.likeRight(StringUtils.isNotEmpty(userDetails.getOrgIdPath()), "AGENCY_ID", userDetails.getOrgIdPath()); + return wrapper; + } + + @Override + public CanteenDishesDTO get(String id) { + CanteenDishesEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CanteenDishesDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(CanteenDishesDTO dto) { + CanteenDishesEntity entity = ConvertUtils.sourceToTarget(dto, CanteenDishesEntity.class); + LoginUserDetailsResultDTO userDetails = remoteService.getLoginUserDetails(); + entity.setCustomerId(userDetails.getCustomerId()); + entity.setAgencyId(userDetails.getOrgIdPath()); + entity.setCode(createCodeNum(dto.getCanteenId())); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(CanteenDishesDTO dto) { + CanteenDishesEntity entity = ConvertUtils.sourceToTarget(dto, CanteenDishesEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public List selectByIds(List dishesIds) { + return ConvertUtils.sourceToTarget(baseDao.selectBatchIds(dishesIds), CanteenDishesDTO.class); + } + + /** + * 菜品编码生成器 + * @param canteenId + * @return + */ + private String createCodeNum(String canteenId) { + String codeNum = PREFIX; + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotEmpty(canteenId), "CANTEEN_ID", canteenId); + Integer count = baseDao.selectCount(wrapper); + if (count < 999999) { + codeNum += String.valueOf(count + 1).length() == 1 ? "00000" + (count + 1) : + String.valueOf(count + 1).length() == 2 ? "0000" + (count + 1) : + String.valueOf(count + 1).length() == 3 ? "000" + (count + 1) : + String.valueOf(count + 1).length() == 4 ? "00" + (count + 1) : + String.valueOf(count + 1).length() == 5 ? "0" + (count + 1) : String.valueOf(count + 1); + + } + return codeNum; + } + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/CanteenMenusServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/CanteenMenusServiceImpl.java new file mode 100755 index 0000000000..3684c07f53 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/CanteenMenusServiceImpl.java @@ -0,0 +1,314 @@ +package com.epmet.service.impl; + +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.PidUtils; +import com.epmet.dao.CanteenMenusDao; +import com.epmet.dto.CanteenDishesDTO; +import com.epmet.dto.CanteenMenusDTO; +import com.epmet.dto.CanteenMenusListDTO; +import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.entity.CanteenMenusEntity; +import com.epmet.remote.EpmetUserRemoteService; +import com.epmet.service.CanteenDishesService; +import com.epmet.service.CanteenMenusService; +import com.epmet.service.CommunityCanteenService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 日照:社区食堂菜单 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-16 + */ +@Service +public class CanteenMenusServiceImpl extends BaseServiceImpl implements CanteenMenusService { + + @Resource + private EpmetUserRemoteService remoteService; + + @Autowired + private CanteenDishesService canteenDishesService; + + @Autowired + private CommunityCanteenService communityCanteenService; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + PageData reuslt = getPageData(page, CanteenMenusDTO.class); + if (!CollectionUtils.isEmpty(page.getRecords())) { + page.getRecords().forEach(entity -> { + reuslt.getList().forEach(dto -> { + if (dto.getId().equals(entity.getId())) { + buildDate(dto, entity); + List dtoList = canteenDishesService.selectByIds(Arrays.asList(entity.getDishesMenus().split(","))); + if (!CollectionUtils.isEmpty(dtoList)) { + String names = dtoList.stream().map(CanteenDishesDTO::getName).collect(Collectors.joining(",")); + dto.setDishesName(names); + } + } + }); + }); + } + return reuslt; + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + List menusList = new ArrayList<>(); + Set dates = new HashSet<>(); + if (!CollectionUtils.isEmpty(entityList)) { + for (CanteenMenusEntity entity : entityList) { + String date = DateUtil.formatDate(entity.getStartTime()); + if (!dates.contains(date)) { + dates.add(date); + CanteenMenusListDTO menus = new CanteenMenusListDTO(); + menus.setTime(DateUtil.formatDate(entity.getStartTime())); + menus.setCanteenId(entity.getCanteenId()); + List mealses = new ArrayList<>(); + menus.setMealses(mealses); + menusList.add(menus); + } + } + if (!CollectionUtils.isEmpty(menusList)) { + menusList.forEach(menus -> { + entityList.forEach(entity -> { + if (DateUtil.formatDate(entity.getStartTime()).equals(menus.getTime())) { + buildData(entity, menus.getMealses()); + } + }); + }); + } + } + return menusList.stream().sorted(Comparator.comparing(CanteenMenusListDTO::getTime).thenComparing(CanteenMenusListDTO::getTime)).collect(Collectors.toList()); + } + + private void buildData(CanteenMenusEntity entity, List mealses) { + CanteenMenusListDTO.CanteenMenus canteenMenus = new CanteenMenusListDTO.CanteenMenus(); + canteenMenus.setDishesMenus(entity.getDishesMenus().split(",")); + canteenMenus.setId(entity.getId()); + canteenMenus.setMeals(entity.getMeals()); + List dtoList = canteenDishesService.selectByIds(Arrays.asList(entity.getDishesMenus().split(","))); + if (!CollectionUtils.isEmpty(dtoList)) { + String names = dtoList.stream().map(CanteenDishesDTO::getName).collect(Collectors.joining(",")); + canteenMenus.setDishesNames(names); + } + mealses.add(canteenMenus); + } + + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); + String agencyId = (String) params.get("agencyId"); + String startTime = (String) params.get("startTime"); + String canteenId = (String) params.get("canteenId"); + String endTime = (String) params.get("endTime"); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + wrapper.eq(StringUtils.isNotEmpty(canteenId), "CANTEEN_ID", canteenId); + if (StringUtils.isNotEmpty(agencyId)) { + AgencyInfoCache info = CustomerOrgRedis.getAgencyInfo(agencyId); + agencyId = PidUtils.convertPid2OrgIdPath(agencyId, info.getPids()); + wrapper.likeRight(StringUtils.isNotEmpty(agencyId), "AGENCY_ID", agencyId); + } + if (null != params.get("meals")) { + if (StringUtils.isNotEmpty(String.valueOf(params.get("meals")))) { + Integer state = (Integer) params.get("meals"); + wrapper.eq(true, "MEALS", state); + } + } + if (null != params.get("def")) { + if (StringUtils.isNotEmpty(String.valueOf(params.get("def")))) { + Integer def = (Integer) params.get("def"); + wrapper.eq(true, "DEF", def); + } + } + if (StringUtils.isNotEmpty(startTime) && StringUtils.isNotEmpty(endTime)) { + wrapper.between("START_TIME", startTime, endTime); + } +// LoginUserDetailsResultDTO userDetails = remoteService.getLoginUserDetails(); +// wrapper.likeRight(StringUtils.isNotEmpty(userDetails.getOrgIdPath()), "AGENCY_ID", userDetails.getOrgIdPath()); + return wrapper; + } + + @Override + public CanteenMenusDTO get(String id) { + CanteenMenusEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CanteenMenusDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(CanteenMenusDTO dto) { + CanteenMenusEntity entity = ConvertUtils.sourceToTarget(dto, CanteenMenusEntity.class); + if (null != dto.getDishesMenus() && dto.getDishesMenus().length > 0) { + entity.setDishesMenus(StringUtils.join(dto.getDishesMenus(), ",")); + } + if (null == dto.getDef()) { + entity.setDef(0); + if (StringUtils.isNotEmpty(dto.getStartTime())) { + entity.setStartTime(DateUtil.parseDate(dto.getStartTime())); + } + if (StringUtils.isNotEmpty(dto.getEndTime())) { + entity.setEndTime(DateUtil.parseDate(dto.getEndTime())); + } + } + LoginUserDetailsResultDTO userDetails = remoteService.getLoginUserDetails(); + entity.setCustomerId(userDetails.getCustomerId()); + entity.setAgencyId(userDetails.getOrgIdPath()); + if (StringUtils.isEmpty(dto.getCanteenId())) { + String canteenId = communityCanteenService.getCanteentByAgencyId(userDetails.getOrgIdPath()); + entity.setCanteenId(canteenId); + } + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(CanteenMenusDTO dto) { + CanteenMenusEntity entity = ConvertUtils.sourceToTarget(dto, CanteenMenusEntity.class); + if (null != dto.getDishesMenus() && dto.getDishesMenus().length > 0) { + entity.setDishesMenus(StringUtils.join(dto.getDishesMenus(), ",")); + } + if (StringUtils.isNotEmpty(dto.getStartTime())) { + entity.setStartTime(DateUtil.parseDate(dto.getStartTime())); + } + if (StringUtils.isNotEmpty(dto.getEndTime())) { + entity.setEndTime(DateUtil.parseDate(dto.getEndTime())); + } + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public List historyMenus(String canteenId) { + List historyList = baseDao.historyMenus(canteenId); + List resultList = ConvertUtils.sourceToTarget(historyList, CanteenMenusDTO.class); + if (!CollectionUtils.isEmpty(historyList)) { + historyList.forEach(entity -> { + resultList.forEach(res -> { + if (entity.getId().equals(res.getId())) { + buildDate(res, entity); + List dtoList = canteenDishesService.selectByIds(Arrays.asList(entity.getDishesMenus().split(","))); + String names = dtoList.stream().map(CanteenDishesDTO::getName).collect(Collectors.joining("、")); + res.setDishesName(names); + } + }); + }); + } + return resultList; + } + + @Override + public void saveOrUpdateDto(CanteenMenusDTO dto) { + if (StringUtils.isNotEmpty(dto.getStartTime()) && StringUtils.isNotEmpty(dto.getEndTime())) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotEmpty(dto.getCanteenId()), "CANTEEN_ID", dto.getCanteenId()); + wrapper.between("START_TIME", dto.getStartTime(), dto.getEndTime()); + wrapper.eq(true, "MEALS", dto.getMeals()); + LoginUserDetailsResultDTO userDetails = remoteService.getLoginUserDetails(); + wrapper.likeRight(StringUtils.isNotEmpty(userDetails.getOrgIdPath()), "AGENCY_ID", userDetails.getOrgIdPath()); + //获取是否已经存在菜单 + List resultList = baseDao.selectList(wrapper); + List updateList = new ArrayList<>(); + List saveList = new ArrayList<>(); + //获取两个时间之间的所有时间(包含自己) + List dateList = getDateList(dto.getStartTime(), dto.getEndTime()); + //用时间比较已经存在的菜单 + if (!CollectionUtils.isEmpty(resultList)) { + dateList.forEach(dateTime -> { + resultList.forEach(entity -> { + if (entity.getStartTime() == dateTime) {//如果村砸,则更新菜单 + entity.setDishesMenus(StringUtils.join(dto.getDishesMenus(), ",")); + updateList.add(entity); + } else {//如果不存在,则保存 + entity.setDishesMenus(StringUtils.join(dto.getDishesMenus(), ",")); + entity.setStartTime(dateTime); + entity.setEndTime(dateTime); + entity.setCanteenId(dto.getCanteenId()); + entity.setMeals(dto.getMeals()); + entity.setDef(0); + entity.setCustomerId(userDetails.getCustomerId()); + entity.setAgencyId(userDetails.getOrgIdPath()); + saveList.add(entity); + } + }); + }); + } else {//如果都不存在,则所有的都保存 + dateList.forEach(dateTime -> { + CanteenMenusEntity entity = new CanteenMenusEntity(); + entity.setDishesMenus(StringUtils.join(dto.getDishesMenus(), ",")); + entity.setStartTime(dateTime); + entity.setEndTime(dateTime); + entity.setCanteenId(dto.getCanteenId()); + entity.setMeals(dto.getMeals()); + entity.setDef(0); + entity.setCustomerId(userDetails.getCustomerId()); + entity.setAgencyId(userDetails.getOrgIdPath()); + saveList.add(entity); + }); + } + if (!CollectionUtils.isEmpty(saveList)) { + saveOrUpdateBatch(saveList); + } + if (!CollectionUtils.isEmpty(updateList)) { + updateBatchById(updateList); + } + } + } + + private List getDateList(String startDate, String endDate) { + if (StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)) { + return DateUtil.rangeToList(DateUtil.parseDate(startDate), DateUtil.parseDate(endDate), DateField.DAY_OF_YEAR); + } + return null; + } + + /** + * 抽取封装数据 + * + * @param dto + * @param entity + * @return + */ + private CanteenMenusDTO buildDate(CanteenMenusDTO dto, CanteenMenusEntity entity) { + if (null != entity.getStartTime()) { + dto.setStartTime(DateUtil.formatDate(entity.getStartTime())); + } + if (null != entity.getEndTime()) { + dto.setEndTime(DateUtil.formatDate(entity.getEndTime())); + } + if (StringUtils.isNotEmpty(entity.getDishesMenus())) { + dto.setDishesMenus(entity.getDishesMenus().split(",")); + } + return dto; + } +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/CommunityCanteenServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/CommunityCanteenServiceImpl.java new file mode 100755 index 0000000000..e73f0a4843 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/CommunityCanteenServiceImpl.java @@ -0,0 +1,165 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.PidUtils; +import com.epmet.dao.CommunityCanteenDao; +import com.epmet.dto.CommunityCanteenDTO; +import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.entity.CommunityCanteenEntity; +import com.epmet.remote.EpmetUserRemoteService; +import com.epmet.service.CommunityCanteenService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 日照:社区食堂 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-14 + */ +@Service +public class CommunityCanteenServiceImpl extends BaseServiceImpl implements CommunityCanteenService { + + @Resource + private EpmetUserRemoteService remoteService; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + PageData pageData = getPageData(page, CommunityCanteenDTO.class); + page.getRecords().forEach(entity -> { + pageData.getList().forEach(dto -> { + if (entity.getId().equals(dto.getId())) { + dto.setThreeMeals(entity.getThreeMeals().split(",")); + dto.setBusinessHours(entity.getBusinessHours().split(",")); + dto.setAgencyId(entity.getAgencyId().substring(entity.getAgencyId().lastIndexOf(":") + 1)); + dto.setAgencyName(CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()).getOrganizationName()); + } + }); + }); + return pageData; + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + List dtoList = ConvertUtils.sourceToTarget(entityList, CommunityCanteenDTO.class); + if (!CollectionUtils.isEmpty(dtoList)) { + for (CommunityCanteenEntity entity : entityList) { + for (CommunityCanteenDTO dto : dtoList) { + if (entity.getId().equals(dto.getId())) { + dto.setThreeMeals(entity.getThreeMeals().split(",")); + dto.setBusinessHours(entity.getBusinessHours().split(",")); + dto.setAgencyId(entity.getAgencyId().substring(entity.getAgencyId().lastIndexOf(":") + 1)); + dto.setAgencyName(CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()).getOrganizationName()); + } + } + } + } + return dtoList; + } + + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); + String name = (String) params.get("name"); + String agencyId = (String) params.get("agencyId"); + LoginUserDetailsResultDTO userDetails = remoteService.getLoginUserDetails(); + if (StringUtils.isEmpty(agencyId)) { + agencyId = userDetails.getOrgIdPath(); + } else { + AgencyInfoCache info = CustomerOrgRedis.getAgencyInfo(agencyId); + agencyId = PidUtils.convertPid2OrgIdPath(agencyId, info.getPids()); + } + String business = ""; + if (null != params.get("business")) { + business = String.valueOf(params.get("business")); + } + String principal = (String) params.get("principal"); + String mobile = (String) params.get("mobile"); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + wrapper.like(StringUtils.isNotBlank(name), FieldConstant.NAME, name); + wrapper.like(StringUtils.isNotBlank(principal), "PRINCIPAL", principal); + wrapper.like(StringUtils.isNotBlank(mobile), "MOBILE", mobile); + wrapper.likeRight(StringUtils.isNotBlank(agencyId), "AGENCY_ID", agencyId); + wrapper.eq(StringUtils.isNotEmpty(business), "BUSINESS", business); + return wrapper; + } + + @Override + public CommunityCanteenDTO get(String id) { + CommunityCanteenEntity entity = baseDao.selectById(id); + CommunityCanteenDTO dto = ConvertUtils.sourceToTarget(entity, CommunityCanteenDTO.class); + if (StringUtils.isNotEmpty(entity.getBusinessHours())) { + dto.setBusinessHours(entity.getBusinessHours().split(",")); + } + if (StringUtils.isNotEmpty(entity.getThreeMeals())) { + dto.setThreeMeals(entity.getThreeMeals().split(",")); + } + if (StringUtils.isNotEmpty(dto.getAgencyId())) { + dto.setAgencyId(dto.getAgencyId().substring(dto.getAgencyId().lastIndexOf(":"), dto.getAgencyId().length() - 1)); + } + return dto; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(CommunityCanteenDTO dto) { + CommunityCanteenEntity entity = ConvertUtils.sourceToTarget(dto, CommunityCanteenEntity.class); + if (null != dto.getBusinessHours() && dto.getBusinessHours().length > 0) { + entity.setBusinessHours(StringUtils.join(dto.getBusinessHours(), ",")); + } + if (null != dto.getThreeMeals() && dto.getThreeMeals().length > 0) { + entity.setThreeMeals(StringUtils.join(dto.getThreeMeals(), ",")); + } + if (StringUtils.isNotEmpty(dto.getAgencyId())) { + AgencyInfoCache info = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); + entity.setAgencyId(PidUtils.convertPid2OrgIdPath(dto.getAgencyId(), info.getPids())); + entity.setCustomerId(info.getCustomerId()); + } + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(CommunityCanteenDTO dto) { + CommunityCanteenEntity entity = ConvertUtils.sourceToTarget(dto, CommunityCanteenEntity.class); + if (null != dto.getBusinessHours() && dto.getBusinessHours().length > 0) { + entity.setBusinessHours(StringUtils.join(dto.getBusinessHours())); + } + if (null != dto.getThreeMeals() && dto.getThreeMeals().length > 0) { + entity.setThreeMeals(StringUtils.join(dto.getThreeMeals())); + } + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public String getCanteentByAgencyId(String agencyId) { + return baseDao.getCanteentByAgencyId(agencyId); + } + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/CanteenDishesDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/CanteenDishesDao.xml new file mode 100755 index 0000000000..ff8d956bb0 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/CanteenDishesDao.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/CanteenMenusDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/CanteenMenusDao.xml new file mode 100755 index 0000000000..997f63416f --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/CanteenMenusDao.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/CommunityCanteenDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/CommunityCanteenDao.xml new file mode 100755 index 0000000000..b7c4c3a205 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/CommunityCanteenDao.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CommunityCanteenDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CommunityCanteenDTO.java new file mode 100755 index 0000000000..38262f5f6e --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CommunityCanteenDTO.java @@ -0,0 +1,89 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 日照:社区食堂 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-08-14 + */ +@Data +public class CommunityCanteenDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 社区食堂主键ID + */ + private String id; + + /** + * 社区食堂名称 + */ + private String name; + + /** + * 社区食堂地址 + */ + private String address; + + /** + * 组织Id + */ + private String agencyId; + + /** + * 负责人 + */ + private String principal; + + /** + * 负责人电话 + */ + private String mobile; + + /** + * 营业状态 0、营业中 1、歇业 + */ + private Integer business; + + /** + * 三餐供给(0,1,2):0、早餐 1、午餐 2、晚餐 + */ + private String[] threeMeals; + + /** + * 经度 + */ + private String longitude; + + /** + * 纬度 + */ + private String latitude; + + /** + * 营业时间 08:00,18:00 + */ + private String[] businessHours; + + /** + * 食堂图片 + */ + private String imgUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 备注 + */ + private String remarks; + +}