|
@@ -3,13 +3,17 @@ package com.ruoyi.system.service.impl;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
import com.ruoyi.common.constant.Constants;
|
|
import com.ruoyi.common.constant.Constants;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
+import com.ruoyi.common.core.domain.entity.SysUser;
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
+import com.ruoyi.common.utils.SendSmsUtils;
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.system.domain.BomanReservatConfigTime;
|
|
import com.ruoyi.system.domain.BomanReservatConfigTime;
|
|
import com.ruoyi.system.mapper.BomanReservatConfigTimeMapper;
|
|
import com.ruoyi.system.mapper.BomanReservatConfigTimeMapper;
|
|
|
|
+import com.ruoyi.system.mapper.SysUserMapper;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -34,6 +38,9 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
@Autowired
|
|
@Autowired
|
|
private RedisCache redisCache;
|
|
private RedisCache redisCache;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysUserMapper userMapper;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询陵园预约
|
|
* 查询陵园预约
|
|
*
|
|
*
|
|
@@ -95,10 +102,28 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
//新增预约往redis中存放数据
|
|
//新增预约往redis中存放数据
|
|
redisCache.setCacheObject(key, numNew);
|
|
redisCache.setCacheObject(key, numNew);
|
|
bomanReservat.setCreateTime(DateUtils.getNowDate());
|
|
bomanReservat.setCreateTime(DateUtils.getNowDate());
|
|
- if ("2".equals(bomanReservat.getReservatType())) {
|
|
|
|
|
|
+ String reservatType = bomanReservat.getReservatType();
|
|
|
|
+ if ("2".equals(reservatType)) {
|
|
bomanReservat.setVisitType("3");
|
|
bomanReservat.setVisitType("3");
|
|
|
|
+ } else {
|
|
|
|
+ //获取管理员账户
|
|
|
|
+ SysUser sysUser = new SysUser();
|
|
|
|
+ sysUser.setUserType("lyManage");
|
|
|
|
+ List<SysUser> sysUsers = userMapper.selectUserList(sysUser);
|
|
|
|
+ if (sysUsers != null && sysUsers.size() > 0) {
|
|
|
|
+ String phonenumber = sysUsers.get(0).getPhonenumber();
|
|
|
|
+ //团队预约,给管理员发送短信
|
|
|
|
+ //陵园预约通知 = SMS_464376020
|
|
|
|
+ SendSmsUtils.sendSms(phonenumber, "SMS_464376020", null);
|
|
|
|
+ System.out.println("给(" + phonenumber + ")陵园管理员发送了("+bomanReservat.getVisitPhone()+")申请预约的短信");
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- return bomanReservatMapper.insertBomanReservat(bomanReservat);
|
|
|
|
|
|
+ int i = bomanReservatMapper.insertBomanReservat(bomanReservat);
|
|
|
|
+ if (i > 0) {
|
|
|
|
+ i = Math.toIntExact(bomanReservat.getReservatId());
|
|
|
|
+ }
|
|
|
|
+ return i;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -160,17 +185,28 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
return AjaxResult.error("请先分配接待人员");
|
|
return AjaxResult.error("请先分配接待人员");
|
|
}
|
|
}
|
|
//拒绝,释放名额
|
|
//拒绝,释放名额
|
|
- if ("2".equals(bomanReservat.getVisitType())){
|
|
|
|
|
|
+ if ("2".equals(bomanReservat.getVisitType())) {
|
|
Long reservatConfigTimeId = reservat.getReservatConfigTimeId();
|
|
Long reservatConfigTimeId = reservat.getReservatConfigTimeId();
|
|
String visitNum = reservat.getVisitNum();
|
|
String visitNum = reservat.getVisitNum();
|
|
//去redis找对应日期,对应时段id的预约数量 reservat_num:2023-10-10_1
|
|
//去redis找对应日期,对应时段id的预约数量 reservat_num:2023-10-10_1
|
|
String key = Constants.RESERVAT_NUM + reservat.getVisitDate() + "_" + reservatConfigTimeId;
|
|
String key = Constants.RESERVAT_NUM + reservat.getVisitDate() + "_" + reservatConfigTimeId;
|
|
- Object num = redisCache.getCacheObject(key);
|
|
|
|
- redisCache.setCacheObject(key,(long)num - Long.parseLong(visitNum));
|
|
|
|
|
|
+ Object numString = redisCache.getCacheObject(key);
|
|
|
|
+ long num = (long) numString - Long.parseLong(visitNum);
|
|
|
|
+ redisCache.setCacheObject(key, num < 0 ? 0 : num);
|
|
}
|
|
}
|
|
bomanReservat.setUpdateTime(DateUtils.getNowDate());
|
|
bomanReservat.setUpdateTime(DateUtils.getNowDate());
|
|
int i = bomanReservatMapper.updateBomanReservat(bomanReservat);
|
|
int i = bomanReservatMapper.updateBomanReservat(bomanReservat);
|
|
|
|
|
|
|
|
+ //审核通过给团队发送通过短信
|
|
|
|
+ if ("3".equals(bomanReservat.getVisitType())) {
|
|
|
|
+ String visitPhone = bomanReservat.getVisitPhone();
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+
|
|
|
|
+ jsonObject.put("code", bomanReservat.getReservatId());
|
|
|
|
+ //陵园预约通过通知 = SMS_464336030
|
|
|
|
+ SendSmsUtils.sendSms(visitPhone, "SMS_464336030", jsonObject.toString());
|
|
|
|
+ System.out.println("给(" + visitPhone + ")团队发送了审核通过的短信");
|
|
|
|
+ }
|
|
return i > 0 ? AjaxResult.success() : AjaxResult.error();
|
|
return i > 0 ? AjaxResult.success() : AjaxResult.error();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -183,20 +219,20 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
@Override
|
|
@Override
|
|
public AjaxResult indexStatistics(BomanReservat bomanReservat) {
|
|
public AjaxResult indexStatistics(BomanReservat bomanReservat) {
|
|
Map<String, Object> map = new HashMap<>(4);
|
|
Map<String, Object> map = new HashMap<>(4);
|
|
- map.put("canGuan" , 0);
|
|
|
|
- map.put("yuYue" , 0);
|
|
|
|
- map.put("todayYuYue" , 0);
|
|
|
|
- map.put("todayCanGuan" , 0);
|
|
|
|
|
|
+ map.put("canGuan", 0);
|
|
|
|
+ map.put("yuYue", 0);
|
|
|
|
+ map.put("todayYuYue", 0);
|
|
|
|
+ map.put("todayCanGuan", 0);
|
|
List<BomanReservat> bomanReservats = bomanReservatMapper.selectBomanReservatList(bomanReservat);
|
|
List<BomanReservat> bomanReservats = bomanReservatMapper.selectBomanReservatList(bomanReservat);
|
|
if (bomanReservats != null && bomanReservats.size() > 0) {
|
|
if (bomanReservats != null && bomanReservats.size() > 0) {
|
|
//来访数
|
|
//来访数
|
|
long canGuan = bomanReservats.stream().filter(s -> "2".equals(s.getVisitStatus())).count();
|
|
long canGuan = bomanReservats.stream().filter(s -> "2".equals(s.getVisitStatus())).count();
|
|
long todayYuYue = bomanReservats.stream().filter(s -> DateUtils.getDate().equals(s.getVisitDate())).count();
|
|
long todayYuYue = bomanReservats.stream().filter(s -> DateUtils.getDate().equals(s.getVisitDate())).count();
|
|
long todayCanGuan = bomanReservats.stream().filter(s -> DateUtils.getDate().equals(s.getVisitDate())).filter(s -> "2".equals(s.getVisitStatus())).count();
|
|
long todayCanGuan = bomanReservats.stream().filter(s -> DateUtils.getDate().equals(s.getVisitDate())).filter(s -> "2".equals(s.getVisitStatus())).count();
|
|
- map.put("canGuan" , canGuan);
|
|
|
|
- map.put("yuYue" , bomanReservats.size());
|
|
|
|
- map.put("todayYuYue" , todayYuYue);
|
|
|
|
- map.put("todayCanGuan" , todayCanGuan);
|
|
|
|
|
|
+ map.put("canGuan", canGuan);
|
|
|
|
+ map.put("yuYue", bomanReservats.size());
|
|
|
|
+ map.put("todayYuYue", todayYuYue);
|
|
|
|
+ map.put("todayCanGuan", todayCanGuan);
|
|
}
|
|
}
|
|
return AjaxResult.success(map);
|
|
return AjaxResult.success(map);
|
|
}
|
|
}
|
|
@@ -223,9 +259,9 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
// todo
|
|
// todo
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
|
- resultMap.put("scale" , "50%");
|
|
|
|
- resultMap.put("current" , 5);
|
|
|
|
- resultMap.put("total" , 10);
|
|
|
|
|
|
+ resultMap.put("scale", "50%");
|
|
|
|
+ resultMap.put("current", 5);
|
|
|
|
+ resultMap.put("total", 10);
|
|
return AjaxResult.success(resultMap);
|
|
return AjaxResult.success(resultMap);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -245,18 +281,18 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
long todayYy = 0;
|
|
long todayYy = 0;
|
|
for (BomanReservat bomanReservat : bomanReservatYearList) {
|
|
for (BomanReservat bomanReservat : bomanReservatYearList) {
|
|
yearYy = yearYy + Long.parseLong(bomanReservat.getVisitNum());
|
|
yearYy = yearYy + Long.parseLong(bomanReservat.getVisitNum());
|
|
- if(bomanReservat.getVisitDate().contains(time.substring(0,time.lastIndexOf("-")))){
|
|
|
|
|
|
+ if (bomanReservat.getVisitDate().contains(time.substring(0, time.lastIndexOf("-")))) {
|
|
monthYy = monthYy + Long.parseLong(bomanReservat.getVisitNum());
|
|
monthYy = monthYy + Long.parseLong(bomanReservat.getVisitNum());
|
|
}
|
|
}
|
|
if (bomanReservat.getVisitDate().equals(time)) {
|
|
if (bomanReservat.getVisitDate().equals(time)) {
|
|
todayYy = todayYy + Long.parseLong(bomanReservat.getVisitNum());
|
|
todayYy = todayYy + Long.parseLong(bomanReservat.getVisitNum());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- map.put("yearYy" , yearYy);
|
|
|
|
- map.put("monthYy" , monthYy);
|
|
|
|
- map.put("todayYy" , todayYy);
|
|
|
|
|
|
+ map.put("yearYy", yearYy);
|
|
|
|
+ map.put("monthYy", monthYy);
|
|
|
|
+ map.put("todayYy", todayYy);
|
|
//todo 今日参观人数
|
|
//todo 今日参观人数
|
|
- map.put("todayVisit" , 10);
|
|
|
|
|
|
+ map.put("todayVisit", 10);
|
|
|
|
|
|
Map<String, Object> sevenMap = new HashMap<>();
|
|
Map<String, Object> sevenMap = new HashMap<>();
|
|
//获取近7天的数组
|
|
//获取近7天的数组
|
|
@@ -291,12 +327,12 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
td = 0L;
|
|
td = 0L;
|
|
}
|
|
}
|
|
|
|
|
|
- sevenMap.put("date" , sevenDate);
|
|
|
|
- sevenMap.put("zrs" , zrsList);
|
|
|
|
- sevenMap.put("sk" , skList);
|
|
|
|
- sevenMap.put("td" , tdList);
|
|
|
|
|
|
+ sevenMap.put("date", sevenDate);
|
|
|
|
+ sevenMap.put("zrs", zrsList);
|
|
|
|
+ sevenMap.put("sk", skList);
|
|
|
|
+ sevenMap.put("td", tdList);
|
|
|
|
|
|
- map.put("sevenMap" , sevenMap);
|
|
|
|
|
|
+ map.put("sevenMap", sevenMap);
|
|
return AjaxResult.success(map);
|
|
return AjaxResult.success(map);
|
|
}
|
|
}
|
|
|
|
|