소스 검색

refactor(system): 重构商户场所相关功能

- 新增 AppSitePlaceSchoolDTO 类用于学校场所操作
- 重构 AppSitePlaceController,支持学校场所相关操作
- 重构 AppSitePlaceServiceImpl,实现学校场所相关方法
- 更新 IAppSitePlaceService 接口,添加学校场所相关方法
- 新增 TimeRangeFinder 工具类,用于处理时间段合并
lix 2 주 전
부모
커밋
206382aae1

+ 17 - 56
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/AppSitePlaceController.java

@@ -1,45 +1,21 @@
 package org.jeecg.modules.system.app.controller;
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.common.system.query.QueryRuleEnum;
-import org.jeecg.common.util.oConvertUtils;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 
 import org.jeecg.modules.system.app.dto.*;
 import org.jeecg.modules.system.app.entity.AppSitePlace;
 import org.jeecg.modules.system.app.service.IAppSitePlaceService;
-import org.jeecgframework.poi.excel.ExcelImportUtil;
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
-import org.jeecgframework.poi.excel.entity.ExportParams;
-import org.jeecgframework.poi.excel.entity.ImportParams;
-import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.multipart.MultipartHttpServletRequest;
-import org.springframework.web.servlet.ModelAndView;
-import com.alibaba.fastjson.JSON;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import io.swagger.v3.oas.annotations.Operation;
 import org.jeecg.common.aspect.annotation.AutoLog;
-import org.apache.shiro.authz.annotation.RequiresPermissions;
- /**
+
+/**
  * @Description: 商户场所表
  * @Author: jeecg-boot
  * @Date:   2025-07-09
@@ -63,7 +39,7 @@ public class AppSitePlaceController extends JeecgController<AppSitePlace, IAppSi
 	@Operation(summary="商户场所学校、体育馆包场-分页列表查询")
 	@GetMapping(value = "/list")
 	public Result<IPage<AppSitePlaceCuDTO>> queryPageList(AppSitePlacePageDTO appSitePlace) {
-		return Result.OK(appSitePlaceService.queryWitchPriceRulesPage(appSitePlace));
+		return Result.OK(appSitePlaceService.querySchoolPage(appSitePlace));
 	}
 	/**
 	 * 分页列表查询
@@ -84,12 +60,12 @@ public class AppSitePlaceController extends JeecgController<AppSitePlace, IAppSi
 	 * @param appSitePlace
 	 * @return
 	 */
-	@AutoLog(value = "商户场所学校、体育馆包场-添加")
-	@Operation(summary="商户场所学校、体育馆包场-添加")
+	@AutoLog(value = "商户场所学校-添加")
+	@Operation(summary="商户场所学校-添加")
 //	@RequiresPermissions("org.jeecg.modules.system.app:nm_site_place:add")
 	@PostMapping(value = "/add")
-	public Result<String> add(@RequestBody AppSitePlaceDTO appSitePlace) {
-		appSitePlaceService.saveWitchPriceRules(appSitePlace);
+	public Result<String> add(@RequestBody AppSitePlaceSchoolDTO appSitePlace) {
+		appSitePlaceService.saveSchool(appSitePlace);
 		return Result.OK("添加成功!");
 	}
 	
@@ -99,12 +75,12 @@ public class AppSitePlaceController extends JeecgController<AppSitePlace, IAppSi
 	 * @param appSitePlace
 	 * @return
 	 */
-	@AutoLog(value = "商户场所学校、体育馆包场-编辑")
-	@Operation(summary="商户场所学校、体育馆包场-编辑")
+	@AutoLog(value = "商户场所学校-编辑")
+	@Operation(summary="商户场所学校-编辑")
 //	@RequiresPermissions("org.jeecg.modules.system.app:nm_site_place:edit")
 	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
-	public Result<String> edit(@RequestBody AppSitePlaceDTO appSitePlace) {
-		appSitePlaceService.editWitchPriceRules(appSitePlace);
+	public Result<String> edit(@RequestBody AppSitePlaceSchoolDTO appSitePlace) {
+		appSitePlaceService.editSchool(appSitePlace);
 		return Result.OK("编辑成功!");
 	}
 	
@@ -114,30 +90,15 @@ public class AppSitePlaceController extends JeecgController<AppSitePlace, IAppSi
 	 * @param id
 	 * @return
 	 */
-	@AutoLog(value = "商户场所学校、体育馆包场-通过id删除")
-	@Operation(summary="商户场所学校、体育馆包场-通过id删除")
+	@AutoLog(value = "商户场所学校-通过id删除")
+	@Operation(summary="商户场所学校-通过id删除")
 //	@RequiresPermissions("org.jeecg.modules.system.app:nm_site_place:delete")
 	@DeleteMapping(value = "/delete")
 	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
 		appSitePlaceService.removeById(id);
 		return Result.OK("删除成功!");
 	}
-	
-//	/**
-//	 *  批量删除
-//	 *
-//	 * @param ids
-//	 * @return
-//	 */
-//	@AutoLog(value = "商户场所表-批量删除")
-//	@Operation(summary="商户场所表-批量删除")
-//	@RequiresPermissions("org.jeecg.modules.system.app:nm_site_place:deleteBatch")
-//	@DeleteMapping(value = "/deleteBatch")
-//	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-//		this.appSitePlaceService.removeByIds(Arrays.asList(ids.split(",")));
-//		return Result.OK("批量删除成功!");
-//	}
-//
+
 	/**
 	 * 通过id查询
 	 *
@@ -145,10 +106,10 @@ public class AppSitePlaceController extends JeecgController<AppSitePlace, IAppSi
 	 * @return
 	 */
 	//@AutoLog(value = "商户场所表-通过id查询")
-	@Operation(summary="商户场所学校、体育馆包场-通过id查询")
+	@Operation(summary="商户场所学校通过id查询")
 	@GetMapping(value = "/queryById")
-	public Result<AppSitePlaceDTO> queryById(@RequestParam(name="id",required=true) String id) {
-		return Result.OK(appSitePlaceService.queryWitchPriceRulesById( id));
+	public Result<AppSitePlaceSchoolDTO> queryById(@RequestParam(name="id",required=true) String id) {
+		return Result.OK(appSitePlaceService.querySchoolById( id));
 	}
 
 //    /**

+ 28 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/dto/AppSitePlaceSchoolDTO.java

@@ -0,0 +1,28 @@
+package org.jeecg.modules.system.app.dto;
+
+import io.swagger.v3.oas.annotations.media.ArraySchema;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+/**
+ * @author DM
+ * @date 2025/7/10 16:54
+ * @description
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@AllArgsConstructor
+@NoArgsConstructor
+@Schema(description="场所-学校入参自定义DTO")
+public class AppSitePlaceSchoolDTO {
+    private AppSitePlaceCuDTO appSitePlaceCuDTO;
+    @ArraySchema(arraySchema = @Schema(description = "学校时间规则"))
+    private List<AppSiteRuleDTO> siteRuleDTOS;
+}

+ 2 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/dto/AppSiteRuleDTO.java

@@ -60,8 +60,8 @@ public class AppSiteRuleDTO {
     /**是否教学日0是1不是*/
     @Schema(description = "是否教学日0是1不是")
     private Integer isTeaching;
-
-    @Schema(description = "场数")
+    /**场数*/
+    @Schema(description = "场数/库存")
     private Integer inventory;
 
 }

+ 3 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/entity/AppSitePriceRules.java

@@ -138,4 +138,7 @@ public class AppSitePriceRules implements Serializable {
     @Schema(description = "删除标志;删除状态(0-正常,1-已删除)")
     @TableLogic
     private Integer delFlag;
+    /**场数*/
+    @Schema(description = "场数/库存")
+    private Integer inventory;
 }

+ 35 - 11
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/IAppSitePlaceService.java

@@ -13,37 +13,37 @@ import org.jeecg.modules.system.app.entity.AppSitePlace;
  */
 public interface IAppSitePlaceService extends IService<AppSitePlace> {
     /**
-     *场所新增
+     *学校场所新增
      * @param placeDTO
      * @return
      */
-    Boolean saveWitchPriceRules(AppSitePlaceDTO placeDTO);
+    Boolean saveSchool(AppSitePlaceSchoolDTO placeDTO);
     /**
-     * 场所修改
+     * 学校场所修改
      * @param placeDTO
      * @return
      */
-    Boolean editWitchPriceRules(AppSitePlaceDTO placeDTO);
+    Boolean editSchool(AppSitePlaceSchoolDTO placeDTO);
     /**
-     * 通过id查询场所
+     * 通过id查询学校场所
      * @param id
      * @return
      */
-    AppSitePlaceDTO queryWitchPriceRulesById(String id);
+    AppSitePlaceSchoolDTO querySchoolById(String id);
     /**
-     * 删除场所
+     * 删除学校场所
      * @param id
      * @return
      */
-    Boolean deleteWitchPriceRulesById(String id);
+    Boolean deleteSchoolById(String id);
 
     /**
-     * 分页列表
+     * 学校分页列表
      * @param dto
      * @return
      */
 
-    IPage<AppSitePlaceCuDTO> queryWitchPriceRulesPage(AppSitePlacePageDTO dto);
+    IPage<AppSitePlaceCuDTO> querySchoolPage(AppSitePlacePageDTO dto);
 
 
 
@@ -81,6 +81,30 @@ public interface IAppSitePlaceService extends IService<AppSitePlace> {
      */
     AppSitePlaceUnfixedDTO queryUnfixedById(String id);
 
-
+//体育馆包场
+    /**
+     *学校场所新增
+     * @param placeDTO
+     * @return
+     */
+    Boolean savePack(AppSitePlaceDTO placeDTO);
+    /**
+     * 学校场所修改
+     * @param placeDTO
+     * @return
+     */
+    Boolean editPack(AppSitePlaceDTO placeDTO);
+    /**
+     * 通过id查询学校场所
+     * @param id
+     * @return
+     */
+    AppSitePlaceDTO queryPackById(String id);
+    /**
+     * 删除学校场所
+     * @param id
+     * @return
+     */
+    Boolean deletePackById(String id);
 
 }

+ 139 - 143
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppSitePlaceServiceImpl.java

@@ -19,6 +19,7 @@ import org.jeecg.modules.system.app.mapper.AppSiteMapper;
 import org.jeecg.modules.system.app.mapper.AppSitePlaceMapper;
 import org.jeecg.modules.system.app.mapper.AppSitePriceRulesMapper;
 import org.jeecg.modules.system.app.service.IAppSitePlaceService;
+import org.jeecg.modules.system.app.utils.TimeRangeFinder;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
@@ -46,156 +47,127 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
     @Resource
     private AppCategoryMapper appCategoryMapper;
 
-    //学校 包场 一对多
+    //学校 一对多
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean saveWitchPriceRules(AppSitePlaceDTO placeDTO) {
-//        AppSitePlaceCuDTO appSitePlaceCuDTO = placeDTO.getAppSitePlaceCuDTO();
-//        AppSiteCategoryDOT appSiteCategoryDOT = placeDTO.getAppSiteCategoryDOT();
-//        if (null == appSitePlaceCuDTO.getSiteId())
-//            throw new JeecgBootException("商户补充信息id不能为空", SC_INTERNAL_SERVER_ERROR_500);
-//        AppSite site = appSiteMapper.selectById(appSitePlaceCuDTO.getSiteId());
-//        if (site == null) throw new JeecgBootException("商户不存在");
-//
-//        if (appSitePlaceCuDTO.getInventory() < 1)
-//            throw new JeecgBootException("场所数、票数不能为0或负数", SC_INTERNAL_SERVER_ERROR_500);
-//        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-//        for (String s : appSitePlaceCuDTO.getCategoryId().split(",")) {
-//            AppCategory category = appCategoryMapper.selectById(s);
-//            for (int i = 0; i < appSitePlaceCuDTO.getInventory(); i++) {
-//                AppSitePlace appSitePlace = new AppSitePlace();
-//                BeanUtils.copyProperties(appSitePlaceCuDTO, appSitePlace);
-//                appSitePlace.setName(category.getName() + i);
-//                appSitePlace.setOrgCode(site.getOrgCode());
-//                appSitePlace.setTenantId(site.getTenantId());
-//                appSitePlace.setSiteId(site.getId());
-//                int insert = baseMapper.insert(appSitePlace);
-//                if (insert < 1) {
-//                    throw new JeecgBootException("商户场所保存失败");
-//                }
-//                placeDTO.getSiteRuleDTOS().forEach(rule -> {
-//                    AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
-//                    BeanUtils.copyProperties(rule, appSitePriceRules);
-//                    appSitePriceRules.setSitePlaceId(appSitePlace.getId());
-//                    appSitePriceRules.setOrgCode(appSitePlace.getOrgCode());
-//                    appSitePriceRules.setTenantId(appSitePlace.getTenantId());
-//                    int savePriceResult = appSitePriceRulesMapper.insert(appSitePriceRules);
-//                    if (savePriceResult < 1) {
-//                        throw new JeecgBootException("场所价格规则保存失败", SC_INTERNAL_SERVER_ERROR_500);
-//                    }
-//                });
-//            }
-//        }
-
-        //循环添加
-
+    public Boolean saveSchool(AppSitePlaceSchoolDTO placeDTO) {
+        AppSitePlaceCuDTO appSitePlaceCuDTO = placeDTO.getAppSitePlaceCuDTO();
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        if (null == appSitePlaceCuDTO.getSiteId())
+            throw new JeecgBootException("商户补充信息id不能为空", SC_INTERNAL_SERVER_ERROR_500);
+        AppSite site = appSiteMapper.selectById(appSitePlaceCuDTO.getSiteId());
+        AppSitePlace appSitePlace = new AppSitePlace();
+        BeanUtils.copyProperties(appSitePlaceCuDTO, appSitePlace);
+        appSitePlace.setOrgCode(site.getOrgCode());
+        appSitePlace.setTenantId(site.getTenantId());
+        appSitePlace.setSiteId(site.getId());
+        //时间段提取拼接
+        List<AppSiteRuleDTO> siteRuleDTOS = placeDTO.getSiteRuleDTOS();
+        String  teachingDay= "";
+        String  noTeachingDay= "";
+        if (!siteRuleDTOS.isEmpty()) {
 
+        }
+        site.setTeachingDay(teachingDay);
+        site.setNoTeachingDay(noTeachingDay);
+        int updateById = appSiteMapper.updateById(site);
+        if (updateById < 1) {
+            throw new JeecgBootException("学校补充信息更新失败");
+        }
+        int insert = baseMapper.insert(appSitePlace);
+        if (insert < 1) {
+            throw new JeecgBootException("学校场所信息保存失败");
+        }
+        siteRuleDTOS.forEach(rule -> {
+            AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
+            BeanUtils.copyProperties(rule, appSitePriceRules);
+            appSitePriceRules.setSitePlaceId(appSitePlace.getId());
+            appSitePriceRules.setOrgCode(appSitePlace.getOrgCode());
+            appSitePriceRules.setTenantId(appSitePlace.getTenantId());
+            int savePriceResult = appSitePriceRulesMapper.insert(appSitePriceRules);
+            if (savePriceResult < 1) {
+                throw new JeecgBootException("场所价格规则保存失败", SC_INTERNAL_SERVER_ERROR_500);
+            }
+        });
 
         return Boolean.TRUE;
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean editWitchPriceRules(AppSitePlaceDTO placeDTO) {
-//        AppSitePlaceCuDTO appSitePlaceCuDTO = placeDTO.getAppSitePlaceCuDTO();
-//        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-//        if (null == appSitePlaceCuDTO.getSiteId())
-//            throw new JeecgBootException("商户补充信息id不能为空", SC_INTERNAL_SERVER_ERROR_500);
-//        AppSite site = appSiteMapper.selectById(appSitePlaceCuDTO.getSiteId());
-//        if (site == null) throw new JeecgBootException("商户不存在");
-//        List<AppSitePlace> dbPlaceList = baseMapper.selectList(Wrappers.<AppSitePlace>lambdaQuery().eq(AppSitePlace::getSiteId, appSitePlaceCuDTO.getSiteId()));
-//        if (dbPlaceList.isEmpty()) throw new JeecgBootException("数据不存在", SC_INTERNAL_SERVER_ERROR_500);
-//        //部门校验
-////        checkPermission(dbPlace, sysUser);
-//        Integer inventoryNew = appSitePlaceCuDTO.getInventory();
-//        if (inventoryNew < 1) throw new JeecgBootException("场所数、票数不能为0或负数", SC_INTERNAL_SERVER_ERROR_500);
-//        int size = dbPlaceList.size();
-//        List<AppSiteRuleDTO> siteRuleDTOS = placeDTO.getSiteRuleDTOS();
-//        //场所数量判断
-//        if (size == inventoryNew) {
-//            dbPlaceList.forEach(dbPlace -> {
-//                AppSitePlace appSitePlace = new AppSitePlace();
-//                BeanUtils.copyProperties(appSitePlaceCuDTO, appSitePlace);
-//                //不许更改项赋值
-//                appSitePlace.setOrgCode(site.getOrgCode());
-//                appSitePlace.setTenantId(site.getTenantId());
-//                int update = baseMapper.updateById(appSitePlace);
-//                if (update < 1) {
-//                    throw new JeecgBootException("商户场所保存失败");
-//                }
-//
-//                appSitePriceRulesMapper.selectList(Wrappers.<AppSitePriceRules>lambdaQuery()
-//                        .eq(AppSitePriceRules::getSitePlaceId, dbPlace.getId())).forEach(appSitePriceRules -> {
-//
-//                });
-//
-//            });
-//
-//
-//        }
-//
-//        AppSitePlace appSitePlace = new AppSitePlace();
-//        BeanUtils.copyProperties(appSitePlaceCuDTO, appSitePlace);
-//        //不许更改项赋值
-//        appSitePlace.setOrgCode(site.getOrgCode());
-//        appSitePlace.setTenantId(site.getTenantId());
-//        int update = baseMapper.updateById(appSitePlace);
-//        if (update < 1) {
-//            throw new JeecgBootException("商户场所保存失败");
-//        }
-//        List<AppSitePriceRules> dbRulesList = appSitePriceRulesMapper.selectList(Wrappers.<AppSitePriceRules>lambdaQuery()
-//                .eq(AppSitePriceRules::getSitePlaceId, appSitePlace.getId()));
-//        List<AppSiteRuleDTO> siteRuleDTOS = placeDTO.getSiteRuleDTOS();
-//        //删除
-//        List<AppSitePriceRules> deleteList = dbRulesList.stream().filter(
-//                dbRule -> dbRule.getId() != null && siteRuleDTOS.stream().noneMatch(rule -> dbRule.getId().equals(rule.getId()))).collect(Collectors.toList());
-//        deleteList.forEach(
-//                dbRule -> {
-//                    int deleteResult = appSitePriceRulesMapper.deleteById(dbRule.getId());
-//                    if (deleteResult < 1) {
-//                        throw new JeecgBootException("场所价格规则删除失败");
-//                    }
-//                }
-//        );
-//        //保存
-//        List<AppSitePriceRules> addList = siteRuleDTOS.stream().filter(rule -> rule.getId() == null).map(ruleDTO -> {
-//            AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
-//            BeanUtils.copyProperties(ruleDTO, appSitePriceRules);
-//            appSitePriceRules.setOrgCode(appSitePlace.getOrgCode());
-//            appSitePriceRules.setTenantId(appSitePlace.getTenantId());
-//            appSitePriceRules.setSitePlaceId(appSitePlace.getId());
-//            return appSitePriceRules;
-//        }).collect(Collectors.toList());
-//        addList.forEach(appSitePriceRules -> {
-//            int saveResult = appSitePriceRulesMapper.insert(appSitePriceRules);
-//            if (saveResult < 1) {
-//                throw new JeecgBootException("场所价格规则保存失败", SC_INTERNAL_SERVER_ERROR_500);
-//            }
-//        });
-//        //更新
-//        List<AppSitePriceRules> updateList = siteRuleDTOS.stream().filter(
-//                rule -> rule.getId() != null && dbRulesList.stream().anyMatch(
-//                        dbRule -> dbRule.getId().equals(rule.getId()))).map(ruleDto -> {
-//            AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
-//            BeanUtils.copyProperties(ruleDto, appSitePriceRules);
-//            appSitePriceRules.setSitePlaceId(appSitePlace.getId());
-//            appSitePriceRules.setOrgCode(appSitePlace.getOrgCode());
-//            appSitePriceRules.setTenantId(appSitePlace.getTenantId());
-//            return appSitePriceRules;
-//        }).collect(Collectors.toList());
-//        updateList.forEach(rule -> {
-//            int updateById = appSitePriceRulesMapper.updateById(rule);
-//            if (updateById < 1) {
-//                throw new JeecgBootException("场所价格规则更新失败", SC_INTERNAL_SERVER_ERROR_500);
-//            }
-//        });
+    public Boolean editSchool(AppSitePlaceSchoolDTO placeDTO) {
+        AppSitePlaceCuDTO appSitePlaceCuDTO = placeDTO.getAppSitePlaceCuDTO();
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        if (null == appSitePlaceCuDTO.getSiteId())
+            throw new JeecgBootException("商户补充信息id不能为空", SC_INTERNAL_SERVER_ERROR_500);
+        AppSitePlace dbPlace = baseMapper.selectById(appSitePlaceCuDTO.getSiteId());
+        if (null == dbPlace) throw new JeecgBootException("数据不存在", SC_INTERNAL_SERVER_ERROR_500);
+        //部门校验
+//        checkPermission(dbPlace, sysUser);
+        AppSitePlace appSitePlace = new AppSitePlace();
+        BeanUtils.copyProperties(appSitePlaceCuDTO, appSitePlace);
+        //不许更改项赋值
+        appSitePlace.setOrgCode(sysUser.getOrgCode());
+        appSitePlace.setTenantId(sysUser.getOrgId());
+        appSitePlace.setSiteId(appSitePlaceCuDTO.getSiteId());
+        int update = baseMapper.updateById(appSitePlace);
+        if (update < 1) {
+            throw new JeecgBootException("商户场所保存失败");
+        }
+        List<AppSitePriceRules> dbRulesList = appSitePriceRulesMapper.selectList(Wrappers.<AppSitePriceRules>lambdaQuery()
+                .eq(AppSitePriceRules::getSitePlaceId, appSitePlace.getId()));
+        List<AppSiteRuleDTO> siteRuleDTOS = placeDTO.getSiteRuleDTOS();
+        //删除
+        List<AppSitePriceRules> deleteList = dbRulesList.stream().filter(
+                dbRule -> dbRule.getId() != null && siteRuleDTOS.stream().noneMatch(rule -> dbRule.getId().equals(rule.getId()))).collect(Collectors.toList());
+        deleteList.forEach(
+                dbRule -> {
+                    int deleteResult = appSitePriceRulesMapper.deleteById(dbRule.getId());
+                    if (deleteResult < 1) {
+                        throw new JeecgBootException("场所价格规则删除失败");
+                    }
+                }
+        );
+        //保存
+        List<AppSitePriceRules> addList = siteRuleDTOS.stream().filter(rule -> rule.getId() == null).map(ruleDTO -> {
+            AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
+            BeanUtils.copyProperties(ruleDTO, appSitePriceRules);
+            appSitePriceRules.setOrgCode(appSitePlace.getOrgCode());
+            appSitePriceRules.setTenantId(appSitePlace.getTenantId());
+            appSitePriceRules.setSitePlaceId(appSitePlace.getId());
+            return appSitePriceRules;
+        }).collect(Collectors.toList());
+        addList.forEach(appSitePriceRules -> {
+            int saveResult = appSitePriceRulesMapper.insert(appSitePriceRules);
+            if (saveResult < 1) {
+                throw new JeecgBootException("场所价格规则保存失败", SC_INTERNAL_SERVER_ERROR_500);
+            }
+        });
+        //更新
+        List<AppSitePriceRules> updateList = siteRuleDTOS.stream().filter(
+                rule -> rule.getId() != null && dbRulesList.stream().anyMatch(
+                        dbRule -> dbRule.getId().equals(rule.getId()))).map(ruleDto -> {
+            AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
+            BeanUtils.copyProperties(ruleDto, appSitePriceRules);
+            appSitePriceRules.setSitePlaceId(appSitePlace.getId());
+            appSitePriceRules.setOrgCode(appSitePlace.getOrgCode());
+            appSitePriceRules.setTenantId(appSitePlace.getTenantId());
+            return appSitePriceRules;
+        }).collect(Collectors.toList());
+        updateList.forEach(rule -> {
+            int updateById = appSitePriceRulesMapper.updateById(rule);
+            if (updateById < 1) {
+                throw new JeecgBootException("场所价格规则更新失败", SC_INTERNAL_SERVER_ERROR_500);
+            }
+        });
         return Boolean.TRUE;
     }
 
+
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public AppSitePlaceDTO queryWitchPriceRulesById(String id) {
+    public AppSitePlaceSchoolDTO querySchoolById(String id) {
         AppSitePlace appSitePlace = baseMapper.selectById(id);
         if (null == appSitePlace) throw new JeecgBootException("数据不存在", SC_INTERNAL_SERVER_ERROR_500);
         AppSitePlaceCuDTO appSitePlaceCuDTO = new AppSitePlaceCuDTO();
@@ -208,12 +180,12 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
                     return appSiteRuleDTO;
                 }).collect(Collectors.toList());
 
-        return new AppSitePlaceDTO(appSitePlaceCuDTO, collect,null);
+        return new AppSitePlaceSchoolDTO(appSitePlaceCuDTO, collect);
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean deleteWitchPriceRulesById(String id) {
+    public Boolean deleteSchoolById(String id) {
         AppSitePlace dbPlace = baseMapper.selectById(id);
         if (null == dbPlace) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
@@ -226,7 +198,7 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
     }
 
     @Override
-    public IPage<AppSitePlaceCuDTO> queryWitchPriceRulesPage(AppSitePlacePageDTO dto) {
+    public IPage<AppSitePlaceCuDTO> querySchoolPage(AppSitePlacePageDTO dto) {
         if (null == dto.getType()) throw new JeecgBootException("请选择类型", SC_INTERNAL_SERVER_ERROR_500);
         LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         Page<AppSitePlace> page = new Page<>(dto.getPageNum(), dto.getPageSize());
@@ -247,11 +219,12 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
     public Boolean addUnfixed(AppSitePlaceUnfixedDTO unsetDTO) {
         if (null == unsetDTO.getSiteId()) throw new JeecgBootException("请选择商户门店", SC_INTERNAL_SERVER_ERROR_500);
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        AppSite site = appSiteMapper.selectById(unsetDTO.getSiteId());
         AppSitePlace appSitePlace = new AppSitePlace();
         BeanUtils.copyProperties(unsetDTO, appSitePlace);
         appSitePlace.setType(SitePlaceTypeEnum.UNFIXED.getCode());
-        appSitePlace.setOrgCode(sysUser.getOrgCode());
-        appSitePlace.setTenantId(sysUser.getOrgId());
+        appSitePlace.setOrgCode(site.getOrgCode());
+        appSitePlace.setTenantId(site.getTenantId());
         int insert = baseMapper.insert(appSitePlace);
         if (insert < 1) throw new JeecgBootException("无固定场添加失败", SC_INTERNAL_SERVER_ERROR_500);
         AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
@@ -273,13 +246,13 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
         AppSitePlace dbSitePlace = baseMapper.selectById(unsetDTO.getId());
         if (null == dbSitePlace) throw new JeecgBootException("数据不存在", SC_INTERNAL_SERVER_ERROR_500);
 //        checkPermission(dbSitePlace,sysUser);
-
+        AppSite site = appSiteMapper.selectById(unsetDTO.getSiteId());
         AppSitePlace appSitePlace = new AppSitePlace();
         BeanUtils.copyProperties(unsetDTO, appSitePlace);
         //固定
         appSitePlace.setType(SitePlaceTypeEnum.UNFIXED.getCode());
-        appSitePlace.setOrgCode(sysUser.getOrgCode());
-        appSitePlace.setTenantId(sysUser.getOrgId());
+        appSitePlace.setOrgCode(site.getOrgCode());
+        appSitePlace.setTenantId(site.getTenantId());
         int updateById = baseMapper.updateById(appSitePlace);
         if (updateById < 1) throw new JeecgBootException("无固定场编辑失败", SC_INTERNAL_SERVER_ERROR_500);
         AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
@@ -307,10 +280,12 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
 
     @Override
     public IPage<AppSitePlaceUnfixedDTO> queryUnfixedPage(AppSitePlaceUnfixedPageDTO dto) {
+        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         Page<AppSitePlace> page = new Page<>(dto.getPageNum(), dto.getPageSize());
         LambdaQueryWrapper<AppSitePlace> wrapper = Wrappers.<AppSitePlace>lambdaQuery().eq(AppSitePlace::getType, SitePlaceTypeEnum.UNFIXED.getCode())
                 .eq(AppSitePlace::getSiteId, dto.getSiteId())
                 .like(StringUtils.isNotBlank(dto.getName()), AppSitePlace::getName, dto.getName());
+//                .eq(AppSitePlace::getOrgCode, loginUser.getOrgCode());
 
         IPage<AppSitePlace> resultPage = baseMapper.selectPage(page, wrapper);
         return resultPage.convert(record -> {
@@ -326,6 +301,7 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
 
     @Override
     public AppSitePlaceUnfixedDTO queryUnfixedById(String id) {
+        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         AppSitePlace dbSitePlace = baseMapper.selectById(id);
         if (null == dbSitePlace) throw new JeecgBootException("无固定场数据不存在", SC_INTERNAL_SERVER_ERROR_500);
         AppSitePriceRules appSitePriceRules = appSitePriceRulesMapper.selectOne(
@@ -338,6 +314,26 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
         return appSitePlaceUnfixedDTO;
     }
 
+    @Override
+    public Boolean savePack(AppSitePlaceDTO placeDTO) {
+        return null;
+    }
+
+    @Override
+    public Boolean editPack(AppSitePlaceDTO placeDTO) {
+        return null;
+    }
+
+    @Override
+    public AppSitePlaceDTO queryPackById(String id) {
+        return null;
+    }
+
+    @Override
+    public Boolean deletePackById(String id) {
+        return null;
+    }
+
     /**
      * 权限校验
      *

+ 75 - 3
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/utils/TimeRangeFinder.java

@@ -4,9 +4,10 @@ import org.apache.poi.ss.formula.functions.T;
 import org.jeecg.modules.system.app.dto.AppCoursesRuleDTO;
 import org.w3c.dom.stylesheets.LinkStyle;
 
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @author DM
@@ -14,6 +15,77 @@ import java.util.Optional;
  * @description
  */
 public class TimeRangeFinder {
+    // 定义时间段结构
+     static class TimeRange {
+        LocalTime start;
+        LocalTime end;
 
+        public TimeRange(LocalTime start, LocalTime end) {
+            this.start = start;
+            this.end = end;
+        }
+
+        @Override
+        public String toString() {
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
+            return start.format(formatter) + "-" + end.format(formatter);
+        }
+    }
+
+    // 解析字符串为时间段对象
+    public static List<TimeRange> parseTimeRanges(String input) {
+        if (input == null || input.trim().isEmpty()) {
+            return Collections.emptyList();
+        }
+
+        return Arrays.stream(input.split(","))
+                .map(String::trim)
+                .filter(s -> s.contains("-"))
+                .map(range -> {
+                    String[] parts = range.split("-");
+                    LocalTime start = LocalTime.parse(parts[0].trim(), DateTimeFormatter.ofPattern("H:mm"));
+                    LocalTime end = LocalTime.parse(parts[1].trim(), DateTimeFormatter.ofPattern("H:mm"));
+                    return new TimeRange(start, end);
+                })
+                .sorted(Comparator.comparing(tr -> tr.start))
+                .collect(Collectors.toList());
+    }
+
+    // 合并时间段
+    public static List<TimeRange> mergeTimeRanges(List<TimeRange> ranges) {
+        if (ranges.isEmpty()) return Collections.emptyList();
+
+        List<TimeRange> merged = new ArrayList<>();
+        TimeRange current = ranges.get(0);
+
+        for (int i = 1; i < ranges.size(); i++) {
+            TimeRange next = ranges.get(i);
+            if (!next.start.isAfter(current.end)) {
+                // 有重叠或相邻,合并
+                current = new TimeRange(current.start, current.end.isAfter(next.end) ? current.end : next.end);
+            } else {
+                // 无重叠,加入当前并切换到下一个
+                merged.add(current);
+                current = next;
+            }
+        }
+
+        merged.add(current); // 添加最后一个时间段
+        return merged;
+    }
+
+    // 格式化输出
+    public static String formatMergedRanges(List<TimeRange> merged) {
+        return merged.stream().map(TimeRange::toString).collect(Collectors.joining(","));
+    }
+
+    // 主方法示例
+    public static void main(String[] args) {
+        String input = "6:00-7:00, 6:30-8:00, 18:00-20:00, 19:30-21:00";
+        List<TimeRange> parsed = parseTimeRanges(input);
+        List<TimeRange> merged = mergeTimeRanges(parsed);
+        String result = formatMergedRanges(merged);
+        System.out.println(result); // 输出:6:00-8:00,18:00-21:00
+    }
 
 }