Administrator 1 ano atrás
pai
commit
f986d7d992

+ 15 - 25
ruoyi-admin/src/main/java/com/ruoyi/web/controller/reservat/BomanReservatController.java

@@ -4,6 +4,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.Base64;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -26,14 +27,13 @@ import sun.misc.BASE64Encoder;
 
 /**
  * 陵园预约Controller
- * 
+ *
  * @author ruoyi
  * @date 2023-11-02
  */
 @RestController
 @RequestMapping("/system/reservat")
-public class BomanReservatController extends BaseController
-{
+public class BomanReservatController extends BaseController {
     @Autowired
     private IBomanReservatService bomanReservatService;
 
@@ -42,8 +42,7 @@ public class BomanReservatController extends BaseController
      */
     //@PreAuthorize("@ss.hasPermi('system:reservat:list')")
     @GetMapping("/list")
-    public TableDataInfo list(BomanReservat bomanReservat)
-    {
+    public TableDataInfo list(BomanReservat bomanReservat) {
         startPage();
         List<BomanReservat> list = bomanReservatService.selectBomanReservatList(bomanReservat);
         return getDataTable(list);
@@ -55,8 +54,7 @@ public class BomanReservatController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:reservat:export')")
     @Log(title = "陵园预约", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, BomanReservat bomanReservat)
-    {
+    public void export(HttpServletResponse response, BomanReservat bomanReservat) {
         List<BomanReservat> list = bomanReservatService.selectBomanReservatList(bomanReservat);
         ExcelUtil<BomanReservat> util = new ExcelUtil<BomanReservat>(BomanReservat.class);
         util.exportExcel(response, list, "陵园预约数据");
@@ -67,8 +65,7 @@ public class BomanReservatController extends BaseController
      */
     //@PreAuthorize("@ss.hasPermi('system:reservat:query')")
     @GetMapping(value = "/{reservatId}")
-    public AjaxResult getInfo(@PathVariable("reservatId") Long reservatId)
-    {
+    public AjaxResult getInfo(@PathVariable("reservatId") Long reservatId) {
         return success(bomanReservatService.selectBomanReservatByReservatId(reservatId));
     }
 
@@ -78,10 +75,9 @@ public class BomanReservatController extends BaseController
     //@PreAuthorize("@ss.hasPermi('system:reservat:add')")
     //@Log(title = "陵园预约", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody BomanReservat bomanReservat)
-    {
+    public AjaxResult add(@RequestBody BomanReservat bomanReservat) {
         int i = bomanReservatService.insertBomanReservat(bomanReservat);
-        return  i > 0 ? AjaxResult.success(i) : AjaxResult.error("超过最大可预约人数或接待人员已满,请重新选择");
+        return i > 0 ? AjaxResult.success(i) : AjaxResult.error("超过最大可预约人数或接待人员已满,请重新选择");
     }
 
     /**
@@ -90,9 +86,8 @@ public class BomanReservatController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:reservat:edit')")
     @Log(title = "陵园预约", businessType = BusinessType.UPDATE)
     @PostMapping("/put")
-    public AjaxResult edit(@RequestBody BomanReservat bomanReservat)
-    {
-        return bomanReservatService.updateBomanReservat(bomanReservat) > 0 ? AjaxResult.success() : AjaxResult.error("预约人数已满");
+    public AjaxResult edit(@RequestBody BomanReservat bomanReservat) {
+        return bomanReservatService.updateBomanReservat(bomanReservat);
     }
 
     /**
@@ -100,8 +95,7 @@ public class BomanReservatController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:reservat:sh')")
     @PostMapping("/sh")
-    public AjaxResult examine(@RequestBody BomanReservat bomanReservat)
-    {
+    public AjaxResult examine(@RequestBody BomanReservat bomanReservat) {
         return bomanReservatService.examine(bomanReservat);
     }
 
@@ -110,8 +104,7 @@ public class BomanReservatController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:reservat:hx')")
     @GetMapping("/hx")
-    public AjaxResult verification(Long reservatId)
-    {
+    public AjaxResult verification(Long reservatId) {
         return bomanReservatService.verification(reservatId);
     }
 
@@ -119,8 +112,7 @@ public class BomanReservatController extends BaseController
      * 删除陵园预约
      */
     @GetMapping("/delete/{receptionIds}")
-    public AjaxResult remove(@PathVariable Long[] receptionIds)
-    {
+    public AjaxResult remove(@PathVariable Long[] receptionIds) {
         return toAjax(bomanReservatService.deleteBomanReservatByReservatIds(receptionIds));
     }
 
@@ -128,8 +120,7 @@ public class BomanReservatController extends BaseController
      * 陵园实时参观统计
      */
     @GetMapping("/statistics/realTime")
-    public AjaxResult realTime()
-    {
+    public AjaxResult realTime() {
         return bomanReservatService.realTime();
     }
 
@@ -137,8 +128,7 @@ public class BomanReservatController extends BaseController
      * 陵园实时参观统计
      */
     @GetMapping("/statistics/people")
-    public AjaxResult people()
-    {
+    public AjaxResult people() {
         return bomanReservatService.people();
     }
 

+ 19 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java

@@ -47,6 +47,23 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         return new Date();
     }
 
+
+    /**
+     * 判断两个时间如果再同一天的话,前者是否大于后者
+     * */
+    public static Boolean sameDayCompare(Date dateOne, Date dateTwo) {
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
+        String formatOne = simpleDateFormat.format(dateOne);
+        String formatTwo = simpleDateFormat.format(dateTwo);
+        try {
+            if (simpleDateFormat.parse(formatOne).getTime() > simpleDateFormat.parse(formatTwo).getTime()) {
+                return true;
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
     /**
      * 得到加减某个值的日期 yyyy-MM-dd
      *
@@ -124,6 +141,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         return DateFormatUtils.format(now, "yyyyMMdd");
     }
 
+
+
     /**
      * 日期型字符串转化为日期 格式
      */

+ 1 - 1
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java

@@ -36,7 +36,7 @@ public class MimeTypeUtils
             // 视频格式
             "mp4", "avi", "rmvb","mp3",
             // pdf
-            "pdf" };
+            "pdf","wgt","apk" };
 
     public static String getExtension(String prefix)
     {

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/IBomanReservatService.java

@@ -43,7 +43,7 @@ public interface IBomanReservatService
      * @param bomanReservat 陵园预约
      * @return 结果
      */
-    public int updateBomanReservat(BomanReservat bomanReservat);
+    public AjaxResult updateBomanReservat(BomanReservat bomanReservat);
 
     /**
      * 批量删除陵园预约

+ 52 - 53
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BomanReservatConfigTimeServiceImpl.java

@@ -20,13 +20,12 @@ import com.ruoyi.system.service.IBomanReservatConfigTimeService;
 
 /**
  * 预约时段配置Service业务层处理
- * 
+ *
  * @author boman
  * @date 2023-11-02
  */
 @Service
-public class BomanReservatConfigTimeServiceImpl implements IBomanReservatConfigTimeService 
-{
+public class BomanReservatConfigTimeServiceImpl implements IBomanReservatConfigTimeService {
     @Autowired
     private BomanReservatConfigTimeMapper bomanReservatConfigTimeMapper;
 
@@ -35,75 +34,69 @@ public class BomanReservatConfigTimeServiceImpl implements IBomanReservatConfigT
 
     /**
      * 查询预约时段配置
-     * 
+     *
      * @param reservatConfigTimeId 预约时段配置主键
      * @return 预约时段配置
      */
     @Override
-    public BomanReservatConfigTime selectBomanReservatConfigTimeByReservatConfigTimeId(Long reservatConfigTimeId)
-    {
+    public BomanReservatConfigTime selectBomanReservatConfigTimeByReservatConfigTimeId(Long reservatConfigTimeId) {
         return bomanReservatConfigTimeMapper.selectBomanReservatConfigTimeByReservatConfigTimeId(reservatConfigTimeId);
     }
 
     /**
      * 查询预约时段配置列表
-     * 
+     *
      * @param bomanReservatConfigTime 预约时段配置
      * @return 预约时段配置
      */
     @Override
-    public List<BomanReservatConfigTime> selectBomanReservatConfigTimeList(BomanReservatConfigTime bomanReservatConfigTime)
-    {
+    public List<BomanReservatConfigTime> selectBomanReservatConfigTimeList(BomanReservatConfigTime bomanReservatConfigTime) {
         return bomanReservatConfigTimeMapper.selectBomanReservatConfigTimeList(bomanReservatConfigTime);
     }
 
     /**
      * 新增预约时段配置
-     * 
+     *
      * @param bomanReservatConfigTime 预约时段配置
      * @return 结果
      */
     @Override
-    public int insertBomanReservatConfigTime(BomanReservatConfigTime bomanReservatConfigTime)
-    {
+    public int insertBomanReservatConfigTime(BomanReservatConfigTime bomanReservatConfigTime) {
         bomanReservatConfigTime.setCreateTime(DateUtils.getNowDate());
         return bomanReservatConfigTimeMapper.insertBomanReservatConfigTime(bomanReservatConfigTime);
     }
 
     /**
      * 修改预约时段配置
-     * 
+     *
      * @param bomanReservatConfigTime 预约时段配置
      * @return 结果
      */
     @Override
-    public int updateBomanReservatConfigTime(BomanReservatConfigTime bomanReservatConfigTime)
-    {
+    public int updateBomanReservatConfigTime(BomanReservatConfigTime bomanReservatConfigTime) {
         bomanReservatConfigTime.setUpdateTime(DateUtils.getNowDate());
         return bomanReservatConfigTimeMapper.updateBomanReservatConfigTime(bomanReservatConfigTime);
     }
 
     /**
      * 批量删除预约时段配置
-     * 
+     *
      * @param reservatConfigTimeIds 需要删除的预约时段配置主键
      * @return 结果
      */
     @Override
-    public int deleteBomanReservatConfigTimeByReservatConfigTimeIds(Long[] reservatConfigTimeIds)
-    {
+    public int deleteBomanReservatConfigTimeByReservatConfigTimeIds(Long[] reservatConfigTimeIds) {
         return bomanReservatConfigTimeMapper.deleteBomanReservatConfigTimeByReservatConfigTimeIds(reservatConfigTimeIds);
     }
 
     /**
      * 删除预约时段配置信息
-     * 
+     *
      * @param reservatConfigTimeId 预约时段配置主键
      * @return 结果
      */
     @Override
-    public int deleteBomanReservatConfigTimeByReservatConfigTimeId(Long reservatConfigTimeId)
-    {
+    public int deleteBomanReservatConfigTimeByReservatConfigTimeId(Long reservatConfigTimeId) {
         return bomanReservatConfigTimeMapper.deleteBomanReservatConfigTimeByReservatConfigTimeId(reservatConfigTimeId);
     }
 
@@ -112,62 +105,68 @@ public class BomanReservatConfigTimeServiceImpl implements IBomanReservatConfigT
      */
     @Override
     public AjaxResult getCalendar(String date) {
-        Map<String,Object> map =new HashMap(1);
+        Map<String, Object> map = new HashMap(1);
         //获取所有时段
         List<BomanReservatConfigTime> bomanReservatConfigTimes = bomanReservatConfigTimeMapper.selectBomanReservatConfigTimeList(new BomanReservatConfigTime());
         List<String> monthFullDay = DateUtils.getMonthFullDay(DateUtils.parseDate(date));
-        if (monthFullDay != null && monthFullDay.size() > 0){
+        if (monthFullDay != null && monthFullDay.size() > 0) {
             JSONArray jsonArray = new JSONArray();
             List<BomanReservatConfigTime> bomanReservatConfigTimeList = new ArrayList<>();
             for (String dateMonth : monthFullDay) {
                 bomanReservatConfigTimeList.clear();
                 JSONObject jsonObject = new JSONObject();
-                jsonObject.put("date",dateMonth);
-                jsonObject.put("title","不可约");
+                jsonObject.put("date", dateMonth);
+                jsonObject.put("title", "不可约");
                 int index = 0;
                 //去查询对应日期是否还有时段可以预约
-                if (bomanReservatConfigTimes != null && bomanReservatConfigTimes.size() > 0){
+                if (bomanReservatConfigTimes != null && bomanReservatConfigTimes.size() > 0) {
                     for (BomanReservatConfigTime reservatConfigTime : bomanReservatConfigTimes) {
-                        BomanReservatConfigTime bomanReservatConfigTime = new BomanReservatConfigTime();
-                        BeanUtils.copyBeanProp(bomanReservatConfigTime,reservatConfigTime);
-                        //查询所有时段和最大人数
-                        //去redis找对应日期,对应时段id的预约数量 reservat_num:2023-10-10_1
-                        //已经预约人数
-                        Object  reservatNum= redisCache.getCacheObject(Constants.RESERVAT_NUM + dateMonth + "_" + reservatConfigTime.getReservatConfigTimeId());
-                        bomanReservatConfigTime.setReservatConfigStatus("Y");
-                        if (ObjectUtils.isNotEmpty(reservatNum)){
-                            //判断人数是否大于可预约人数
-                            //如果 x==y 返回0;x<y 返回负数(-1);x>y 返回正数(1)
-                            if (NumberUtils.compare(bomanReservatConfigTime.getReservatConfigNum(),(long)reservatNum) < 1){
-                                bomanReservatConfigTime.setReservatConfigStatus("N");
-                                index++;
+                        //判断时间段结束时间是否大于当前时间
+                            BomanReservatConfigTime bomanReservatConfigTime = new BomanReservatConfigTime();
+                            BeanUtils.copyBeanProp(bomanReservatConfigTime, reservatConfigTime);
+                        if (DateUtils.sameDayCompare(reservatConfigTime.getReservatConfigTimeEnd(), DateUtils.getNowDate())) {
+                            //查询所有时段和最大人数
+                            //去redis找对应日期,对应时段id的预约数量 reservat_num:2023-10-10_1
+                            //已经预约人数
+                            Object reservatNum = redisCache.getCacheObject(Constants.RESERVAT_NUM + dateMonth + "_" + reservatConfigTime.getReservatConfigTimeId());
+                            bomanReservatConfigTime.setReservatConfigStatus("Y");
+                            if (ObjectUtils.isNotEmpty(reservatNum)) {
+                                //判断人数是否大于可预约人数
+                                //如果 x==y 返回0;x<y 返回负数(-1);x>y 返回正数(1)
+                                if (NumberUtils.compare(bomanReservatConfigTime.getReservatConfigNum(), (long) reservatNum) < 1) {
+                                    bomanReservatConfigTime.setReservatConfigStatus("N");
+                                    index++;
+                                }
                             }
-                        }
-                        bomanReservatConfigTimeList.add(bomanReservatConfigTime);
-                        bomanReservatConfigTime.setReceptionPersonnelType("N");
-                        //去查询该时间段接待人员是否已满
-                        Object cacheObject = redisCache.getCacheObject(Constants.RESERVAT_PERSONNEL_NUM + dateMonth + "_" + reservatConfigTime.getReservatConfigTimeId());
-                        if (ObjectUtils.isNotEmpty(cacheObject)){
-                            bomanReservatConfigTime.setReceptionPersonnelType("Y");
+                            bomanReservatConfigTimeList.add(bomanReservatConfigTime);
+                            bomanReservatConfigTime.setReceptionPersonnelType("N");
+                            //去查询该时间段接待人员是否已满
+                            Object cacheObject = redisCache.getCacheObject(Constants.RESERVAT_PERSONNEL_NUM + dateMonth + "_" + reservatConfigTime.getReservatConfigTimeId());
+                            if (ObjectUtils.isNotEmpty(cacheObject)) {
+                                bomanReservatConfigTime.setReceptionPersonnelType("Y");
+                            }
+                        }else {
+                            bomanReservatConfigTime.setReservatConfigStatus("N");
+                            bomanReservatConfigTimeList.add(bomanReservatConfigTime);
                         }
                     }
-                    if (index < bomanReservatConfigTimes.size()){
-                        jsonObject.put("title","可预约");
+                    if (index < bomanReservatConfigTimes.size()) {
+                        jsonObject.put("title", "可预约");
                     }
                     //1: AM 2: PM
                     Map<String, List<BomanReservatConfigTime>> collect = bomanReservatConfigTimeList.stream().sorted(Comparator.comparing(BomanReservatConfigTime::getReservatConfigTimeBegin)).collect(Collectors.groupingBy(BomanReservatConfigTime::getReservatConfigType));
 
                     for (String key : collect.keySet()) {
-                        if ("1".equals(key)){
-                            jsonObject.put("amList",collect.get(key));
-                        }else {
-                            jsonObject.put("pmList",collect.get(key));
+                        if ("1".equals(key)) {
+                            jsonObject.put("amList", collect.get(key));
+                        } else {
+                            jsonObject.put("pmList", collect.get(key));
                         }
                     }
                 }
                 jsonArray.add(jsonObject);
             }
-            map.put("signList",jsonArray);
+            map.put("signList", jsonArray);
         }
         return AjaxResult.success(map);
     }

+ 9 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BomanReservatServiceImpl.java

@@ -168,9 +168,16 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
      * @return 结果
      */
     @Override
-    public int updateBomanReservat(BomanReservat bomanReservat) {
+    public AjaxResult updateBomanReservat(BomanReservat bomanReservat) {
+        //判断该接待人员当前时段是否已经被选择过, 需要传入预约时段id
+        if (bomanReservat.getReceptionId() != null){
+            List<BomanReservat> bomanReservats = bomanReservatMapper.selectBomanReservatList(bomanReservat);
+            if (bomanReservats != null && bomanReservats.size() > 0){
+                return AjaxResult.error("当前讲解员已被选择");
+            }
+        }
         bomanReservat.setUpdateTime(DateUtils.getNowDate());
-        return bomanReservatMapper.updateBomanReservat(bomanReservat);
+        return bomanReservatMapper.updateBomanReservat(bomanReservat)> 0 ? AjaxResult.success() : AjaxResult.error("预约人数已满");
     }
 
     /**