|
@@ -4,6 +4,7 @@ import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
@@ -16,6 +17,7 @@ import com.ruoyi.common.utils.SendSmsUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.system.domain.BomanReservatConfigTime;
|
|
|
import com.ruoyi.system.mapper.BomanReservatConfigTimeMapper;
|
|
|
+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;
|
|
@@ -25,6 +27,8 @@ import com.ruoyi.system.mapper.BomanReservatMapper;
|
|
|
import com.ruoyi.system.domain.BomanReservat;
|
|
|
import com.ruoyi.system.service.IBomanReservatService;
|
|
|
|
|
|
+import static com.ruoyi.common.constant.Constants.RESERVAT_PERSONNEL_NUM;
|
|
|
+
|
|
|
/**
|
|
|
* 陵园预约Service业务层处理
|
|
|
*
|
|
@@ -44,6 +48,9 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
|
@Autowired
|
|
|
private SysUserMapper userMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ReceptionPersonnelMapper receptionPersonnelMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询陵园预约
|
|
|
*
|
|
@@ -102,13 +109,33 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- //新增预约往redis中存放数据
|
|
|
- redisCache.setCacheObject(key, numNew);
|
|
|
+
|
|
|
bomanReservat.setCreateTime(DateUtils.getNowDate());
|
|
|
String reservatType = bomanReservat.getReservatType();
|
|
|
if ("2".equals(reservatType)) {
|
|
|
bomanReservat.setVisitType("3");
|
|
|
} else {
|
|
|
+ //如果是团队,判断是否需要接待
|
|
|
+ if ("Y".equals(bomanReservat.getIsReception())){
|
|
|
+ BomanReservat br = new BomanReservat();
|
|
|
+ br.setReservatConfigTimeId(bomanReservat.getReservatConfigTimeId());
|
|
|
+ br.setVisitType("3");
|
|
|
+ br.setVisitDate(bomanReservat.getVisitDate());
|
|
|
+ //查询一下,该时段接待人员是否已满
|
|
|
+ List<BomanReservat> bomanReservats = bomanReservatMapper.selectBomanReservatList(br);
|
|
|
+ //再去查询接待人员数量
|
|
|
+ int i = receptionPersonnelMapper.selectReceptionPersonnelCount();
|
|
|
+ if (bomanReservats != null){
|
|
|
+ if (bomanReservats.size() >= i ){
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ if (bomanReservats.size() + 1 == i){
|
|
|
+ //插入redis该时段接待人员已满
|
|
|
+ String keyPersonnel = Constants.RESERVAT_PERSONNEL_NUM + bomanReservat.getVisitDate() + "_" + reservatConfigTimeId;
|
|
|
+ redisCache.setCacheObject(keyPersonnel,"Y",24, TimeUnit.HOURS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//获取管理员账户
|
|
|
SysUser sysUser = new SysUser();
|
|
|
sysUser.setUserType("lyManage");
|
|
@@ -119,13 +146,15 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
|
//陵园预约通知 = SMS_464376020
|
|
|
SendSmsUtils.sendSms(phonenumber, "SMS_464376020", null);
|
|
|
System.out.println("给(" + phonenumber + ")陵园管理员发送了("+bomanReservat.getVisitPhone()+")申请预约的短信");
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
int i = bomanReservatMapper.insertBomanReservat(bomanReservat);
|
|
|
if (i > 0) {
|
|
|
i = Math.toIntExact(bomanReservat.getReservatId());
|
|
|
}
|
|
|
+ //新增预约往redis中存放数据
|
|
|
+ redisCache.setCacheObject(key, numNew,24, TimeUnit.HOURS);
|
|
|
return i;
|
|
|
}
|
|
|
|
|
@@ -162,7 +191,12 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
|
if (reservatNumNew < 0) {
|
|
|
reservatNumNew = 0;
|
|
|
}
|
|
|
- redisCache.setCacheObject(key, reservatNumNew);
|
|
|
+ redisCache.setCacheObject(key, reservatNumNew,24, TimeUnit.HOURS);
|
|
|
+ }
|
|
|
+ //判断是不是团队需要接待的续约
|
|
|
+ if ("1".equals(bomanReservat.getReservatType()) && "Y".equals(bomanReservat.getIsReception())){
|
|
|
+ String keyPersonnel = Constants.RESERVAT_PERSONNEL_NUM + bomanReservat.getVisitDate() + "_" + reservatConfigTimeId;
|
|
|
+ redisCache.deleteObject(keyPersonnel);
|
|
|
}
|
|
|
}
|
|
|
return bomanReservatMapper.deleteBomanReservatByReservatIds(reservatIds);
|
|
@@ -184,18 +218,43 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
|
|
|
|
BomanReservat reservat = bomanReservatMapper.selectBomanReservatByReservatId(bomanReservat.getReservatId());
|
|
|
|
|
|
+ Long reservatConfigTimeId = reservat.getReservatConfigTimeId();
|
|
|
+
|
|
|
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())) {
|
|
|
- Long reservatConfigTimeId = reservat.getReservatConfigTimeId();
|
|
|
String visitNum = reservat.getVisitNum();
|
|
|
//去redis找对应日期,对应时段id的预约数量 reservat_num:2023-10-10_1
|
|
|
String key = Constants.RESERVAT_NUM + reservat.getVisitDate() + "_" + reservatConfigTimeId;
|
|
|
Object numString = redisCache.getCacheObject(key);
|
|
|
long num = (long) numString - Long.parseLong(visitNum);
|
|
|
- redisCache.setCacheObject(key, num < 0 ? 0 : num);
|
|
|
+ redisCache.setCacheObject(key, num < 0 ? 0 : num,24, TimeUnit.HOURS);
|
|
|
+ String keyPersonnel = Constants.RESERVAT_PERSONNEL_NUM + reservat.getVisitDate() + "_" + reservatConfigTimeId;
|
|
|
+ redisCache.deleteObject(keyPersonnel);
|
|
|
}
|
|
|
bomanReservat.setUpdateTime(DateUtils.getNowDate());
|
|
|
int i = bomanReservatMapper.updateBomanReservat(bomanReservat);
|
|
@@ -210,6 +269,7 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
|
SendSmsUtils.sendSms(visitPhone, "SMS_464336030", jsonObject.toString());
|
|
|
System.out.println("给(" + visitPhone + ")团队发送了审核通过的短信");
|
|
|
}
|
|
|
+
|
|
|
return i > 0 ? AjaxResult.success() : AjaxResult.error();
|
|
|
}
|
|
|
|
|
@@ -243,6 +303,9 @@ public class BomanReservatServiceImpl implements IBomanReservatService {
|
|
|
@Override
|
|
|
public AjaxResult verification(Long reservatId) {
|
|
|
BomanReservat reservat = bomanReservatMapper.selectBomanReservatByReservatId(reservatId);
|
|
|
+ if (!"3".equals(reservat.getVisitType())){
|
|
|
+ return AjaxResult.error("当前预约未通过,禁止核销");
|
|
|
+ }
|
|
|
if ("2".equals(reservat.getVisitStatus())) {
|
|
|
return AjaxResult.error("当前预约已核销,请勿重复操作。");
|
|
|
}
|