Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

LIVE_YE 1 год назад
Родитель
Сommit
919a3e3d28

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

@@ -1,7 +1,10 @@
 package com.ruoyi.web.controller.reservat;
 
+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;
@@ -20,17 +23,17 @@ import com.ruoyi.system.domain.BomanReservat;
 import com.ruoyi.system.service.IBomanReservatService;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.common.core.page.TableDataInfo;
+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;
 
@@ -39,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);
@@ -52,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, "陵园预约数据");
@@ -64,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));
     }
 
@@ -75,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("超过最大可预约人数或接待人员已满,请重新选择");
     }
 
     /**
@@ -87,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);
     }
 
     /**
@@ -97,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);
     }
 
@@ -107,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);
     }
 
@@ -116,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));
     }
 
@@ -125,8 +120,7 @@ public class BomanReservatController extends BaseController
      * 陵园实时参观统计
      */
     @GetMapping("/statistics/realTime")
-    public AjaxResult realTime()
-    {
+    public AjaxResult realTime() {
         return bomanReservatService.realTime();
     }
 
@@ -134,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);
 
     /**
      * 批量删除陵园预约

+ 39 - 44
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BomanReservatConfigTimeServiceImpl.java

@@ -1,9 +1,6 @@
 package com.ruoyi.system.service.impl;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import com.alibaba.fastjson2.JSONArray;
@@ -23,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;
 
@@ -38,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);
     }
 
@@ -115,62 +105,67 @@ 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);
+                        BeanUtils.copyBeanProp(bomanReservatConfigTime, reservatConfigTime);
                         //查询所有时段和最大人数
                         //去redis找对应日期,对应时段id的预约数量 reservat_num:2023-10-10_1
                         //已经预约人数
-                        Object  reservatNum= redisCache.getCacheObject(Constants.RESERVAT_NUM + dateMonth + "_" + reservatConfigTime.getReservatConfigTimeId());
+                        Object reservatNum = redisCache.getCacheObject(Constants.RESERVAT_NUM + dateMonth + "_" + reservatConfigTime.getReservatConfigTimeId());
                         bomanReservatConfigTime.setReservatConfigStatus("Y");
-                        if (ObjectUtils.isNotEmpty(reservatNum)){
+                        if (ObjectUtils.isNotEmpty(reservatNum)) {
                             //判断人数是否大于可预约人数
                             //如果 x==y 返回0;x<y 返回负数(-1);x>y 返回正数(1)
-                            if (NumberUtils.compare(bomanReservatConfigTime.getReservatConfigNum(),(long)reservatNum) < 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)){
+                        if (ObjectUtils.isNotEmpty(cacheObject)) {
                             bomanReservatConfigTime.setReceptionPersonnelType("Y");
                         }
+                        //判断时间段结束时间是否大于当前时间
+                        if (dateMonth.equals(DateUtils.getDate()) && DateUtils.sameDayCompare(DateUtils.getNowDate(),reservatConfigTime.getReservatConfigTimeEnd())) {
+                            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().collect(Collectors.groupingBy(BomanReservatConfigTime::getReservatConfigType));
+                    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);
     }

+ 18 - 32
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BomanReservatServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruoyi.system.service.impl;
 
 import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -21,11 +22,13 @@ import com.ruoyi.system.mapper.ReceptionPersonnelMapper;
 import com.ruoyi.system.mapper.SysUserMapper;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.math.NumberUtils;
+import org.apache.logging.log4j.util.Base64Util;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.BomanReservatMapper;
 import com.ruoyi.system.domain.BomanReservat;
 import com.ruoyi.system.service.IBomanReservatService;
+import sun.misc.BASE64Encoder;
 
 import static com.ruoyi.common.constant.Constants.RESERVAT_PERSONNEL_NUM;
 
@@ -124,12 +127,12 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
                 //查询一下,该时段接待人员是否已满
                 List<BomanReservat> bomanReservats = bomanReservatMapper.selectBomanReservatList(br);
                 //再去查询接待人员数量
-                int i = receptionPersonnelMapper.selectReceptionPersonnelCount();
+                int num = receptionPersonnelMapper.selectReceptionPersonnelCount();
                 if (bomanReservats != null){
-                    if (bomanReservats.size() >= i ){
+                    if (bomanReservats.size() >= num ){
                         return 0;
                     }
-                    if (bomanReservats.size() + 1 == i){
+                    if (bomanReservats.size() + 1 == num){
                         //插入redis该时段接待人员已满
                         String keyPersonnel = Constants.RESERVAT_PERSONNEL_NUM + bomanReservat.getVisitDate() + "_" + reservatConfigTimeId;
                         redisCache.setCacheObject(keyPersonnel,"Y",24, TimeUnit.HOURS);
@@ -165,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("预约人数已满");
     }
 
     /**
@@ -223,28 +233,6 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
         if ("3".equals(bomanReservat.getVisitType()) && "Y".equals(reservat.getIsReception()) && StringUtils.isEmpty(reservat.getReceptionName())) {
             return AjaxResult.error("请先分配接待人员");
         }
-        //如果该时段接待员已满,往redis中插入数据,给前端H5日历进行标识
-        if ("3".equals(bomanReservat.getVisitType()) && "Y".equals(reservat.getIsReception()) && StringUtils.isNotEmpty(reservat.getReceptionName())) {
-            //审核通过且需要接待人员且分配了接待人员
-            BomanReservat br = new BomanReservat();
-            br.setReservatConfigTimeId(reservat.getReservatConfigTimeId());
-            br.setVisitDate(bomanReservat.getVisitDate());
-            br.setVisitType("3");
-            //查询一下,该时段接待人员是否已满
-            List<BomanReservat> bomanReservats = bomanReservatMapper.selectBomanReservatList(br);
-            //再去查询接待人员数量
-            int i = receptionPersonnelMapper.selectReceptionPersonnelCount();
-            if (bomanReservats != null){
-                if (bomanReservats.size() >= i ){
-                    return AjaxResult.error("当前时段接待人员已满");
-                }
-                if (bomanReservats.size() + 1 == i){
-                    //插入redis该时段接待人员已满
-                    String key = Constants.RESERVAT_PERSONNEL_NUM + reservat.getVisitDate() + "_" + reservatConfigTimeId;
-                    redisCache.setCacheObject(key,"Y",24, TimeUnit.HOURS);
-                }
-            }
-        }
         //拒绝,释放名额
         if ("2".equals(bomanReservat.getVisitType())) {
             String visitNum = reservat.getVisitNum();
@@ -261,18 +249,16 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
 
         //审核通过给团队发送通过短信
         if ("3".equals(bomanReservat.getVisitType())) {
-            String visitPhone = bomanReservat.getVisitPhone();
+            String visitPhone = reservat.getVisitPhone();
             JSONObject jsonObject = new JSONObject();
-
-            jsonObject.put("code", bomanReservat.getReservatId());
+            String code = Base64.getEncoder().encodeToString(String.valueOf(reservat.getReservatId()).getBytes(StandardCharsets.UTF_8));
+            jsonObject.put("code", code);
             //陵园预约通过通知 = SMS_464336030
             SendSmsUtils.sendSms(visitPhone, "SMS_464336030", jsonObject.toString());
             System.out.println("给(" + visitPhone + ")团队发送了审核通过的短信");
         }
-
         return i > 0 ? AjaxResult.success() : AjaxResult.error();
     }
-
     /**
      * 预约首页统计
      *