diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/domain/AllocStall.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/domain/AllocStall.java index 806ce1a..59200bf 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/domain/AllocStall.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/domain/AllocStall.java @@ -1,6 +1,7 @@ package com.bonus.canteen.core.alloc.domain; import java.util.Date; +import java.util.List; import com.bonus.canteen.core.common.utils.FileUrlUtil; import com.fasterxml.jackson.annotation.JsonFormat; @@ -151,6 +152,8 @@ public class AllocStall extends BaseEntity { @ApiModelProperty(value = "档口收款码链接") private String payCodeUrl; + private List allocStallMealtimeList; + /** 删除标志(0代表存在 2代表删除) */ private String delFlag; diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/domain/AllocStallMealtime.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/domain/AllocStallMealtime.java new file mode 100644 index 0000000..74a0e47 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/domain/AllocStallMealtime.java @@ -0,0 +1,54 @@ +package com.bonus.canteen.core.alloc.domain; + +import com.bonus.canteen.core.common.utils.FileUrlUtil; +import com.bonus.common.core.annotation.Excel; +import com.bonus.common.core.web.domain.BaseEntity; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; + +import java.util.Date; + +/** + * 档口信息对象 alloc_stall_mealtime + * + * @author xsheng + * @date 2025-04-03 + */ + + +@Data +@ToString +public class AllocStallMealtime extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 档口id */ + private Long stallId; + + /** 餐次类型 */ + @Excel(name = "餐次类型") + @ApiModelProperty(value = "餐次类型") + private Long mealtimeType; + + /** 餐次名称 */ + @Excel(name = "餐次名称") + @ApiModelProperty(value = "餐次名称") + private String mealtimeName; + + /** 开始时间 */ + @ApiModelProperty(value = "开始时间") + @JsonFormat(pattern = "HH:mm:ss") + @Excel(name = "开始时间", width = 30, dateFormat = "HH:mm:ss") + private Date startTime; + + /** 结束时间 */ + @ApiModelProperty(value = "结束时间") + @JsonFormat(pattern = "HH:mm:ss") + @Excel(name = "结束时间", width = 30, dateFormat = "HH:mm:ss") + private Date endTime; + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/mapper/AllocStallMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/mapper/AllocStallMapper.java index 2052df7..88611f4 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/mapper/AllocStallMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/mapper/AllocStallMapper.java @@ -2,6 +2,8 @@ package com.bonus.canteen.core.alloc.mapper; import java.util.List; import com.bonus.canteen.core.alloc.domain.AllocStall; +import com.bonus.canteen.core.alloc.domain.AllocStallMealtime; +import org.apache.ibatis.annotations.Param; /** * 档口信息Mapper接口 @@ -57,4 +59,10 @@ public interface AllocStallMapper { * @return 结果 */ public int deleteAllocStallByStallIds(Long[] stallIds); + + public int deleteMealtimeByStallId(Long stallId); + + public List selectMealtimeByStallId(Long stallId); + + public int insertAllocStallMealtime(@Param("list") List allocStallMealtimes); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocStallServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocStallServiceImpl.java index e3cc9af..a1c930c 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocStallServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/alloc/service/impl/AllocStallServiceImpl.java @@ -3,12 +3,14 @@ package com.bonus.canteen.core.alloc.service.impl; import java.util.List; import com.bonus.canteen.core.alloc.domain.AllocStall; +import com.bonus.canteen.core.alloc.domain.AllocStallMealtime; import com.bonus.canteen.core.alloc.mapper.AllocStallMapper; import com.bonus.canteen.core.alloc.service.IAllocStallService; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; /** * 档口信息Service业务层处理 @@ -29,7 +31,10 @@ public class AllocStallServiceImpl implements IAllocStallService { */ @Override public AllocStall selectAllocStallByStallId(Long stallId) { - return allocStallMapper.selectAllocStallByStallId(stallId); + List allocStallMealtimes = allocStallMapper.selectMealtimeByStallId(stallId); + AllocStall allocStall = allocStallMapper.selectAllocStallByStallId(stallId); + allocStall.setAllocStallMealtimeList(allocStallMealtimes); + return allocStall; } /** @@ -53,7 +58,12 @@ public class AllocStallServiceImpl implements IAllocStallService { public int insertAllocStall(AllocStall allocStall) { allocStall.setCreateTime(DateUtils.getNowDate()); try { - return allocStallMapper.insertAllocStall(allocStall); + int stallCount = allocStallMapper.insertAllocStall(allocStall); + if (stallCount > 0 && !CollectionUtils.isEmpty(allocStall.getAllocStallMealtimeList())) { + allocStallMapper.deleteMealtimeByStallId(allocStall.getStallId()); + allocStallMapper.insertAllocStallMealtime(allocStall.getAllocStallMealtimeList()); + } + return stallCount; } catch (Exception e) { throw new ServiceException("错误信息描述"); } @@ -69,7 +79,12 @@ public class AllocStallServiceImpl implements IAllocStallService { public int updateAllocStall(AllocStall allocStall) { allocStall.setUpdateTime(DateUtils.getNowDate()); try { - return allocStallMapper.updateAllocStall(allocStall); + int stallCount = allocStallMapper.updateAllocStall(allocStall); + if (stallCount > 0 && !CollectionUtils.isEmpty(allocStall.getAllocStallMealtimeList())) { + allocStallMapper.deleteMealtimeByStallId(allocStall.getStallId()); + allocStallMapper.insertAllocStallMealtime(allocStall.getAllocStallMealtimeList()); + } + return stallCount; } catch (Exception e) { throw new ServiceException("错误信息描述"); } @@ -83,6 +98,9 @@ public class AllocStallServiceImpl implements IAllocStallService { */ @Override public int deleteAllocStallByStallIds(Long[] stallIds) { + for (int i = 0; i < stallIds.length; i++) { + allocStallMapper.deleteMealtimeByStallId(stallIds[i]); + } return allocStallMapper.deleteAllocStallByStallIds(stallIds); } @@ -94,6 +112,7 @@ public class AllocStallServiceImpl implements IAllocStallService { */ @Override public int deleteAllocStallByStallId(Long stallId) { + allocStallMapper.deleteMealtimeByStallId(stallId); return allocStallMapper.deleteAllocStallByStallId(stallId); } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocStallMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocStallMapper.xml index dba8e1b..65fe0c7 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocStallMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/AllocStallMapper.xml @@ -185,4 +185,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{stallId} + + + delete from alloc_stall_meantime where stall_id = #{stallId} + + + + + + insert into alloc_stall_time(stall_id, mealtime_type, mealtime_name, start_time, end_time) + values + + ( + #{item.stallId}, + #{item.mealtimeType}, + #{item.mealtimeName}, + #{item.startTime}, + #{item.endTime} + ) + + \ No newline at end of file