逻辑完成
This commit is contained in:
@@ -1,10 +1,7 @@
|
|||||||
package com.kkz.kpersonalre.entity;
|
package com.kkz.kpersonalre.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.kkz.kpersonalre.entity.BaseEntity;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
@@ -32,8 +29,8 @@ public class AlarmPersonConfigEntity extends BaseEntity{
|
|||||||
/**
|
/**
|
||||||
* 配置描述
|
* 配置描述
|
||||||
*/
|
*/
|
||||||
@TableField("describe")
|
@TableField("describes")
|
||||||
private String describe;
|
private String describes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* json类型 融合为数组[[personId,localtionId,alarmClockId],[personId,localtionId,alarmClockId]] 单独不为数组,但元素一样,如果融合规则匹配则不匹配单独类型
|
* json类型 融合为数组[[personId,localtionId,alarmClockId],[personId,localtionId,alarmClockId]] 单独不为数组,但元素一样,如果融合规则匹配则不匹配单独类型
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
package com.kkz.kpersonalre.entity;
|
package com.kkz.kpersonalre.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.kkz.kpersonalre.entity.BaseEntity;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 排班配置表
|
* 排班配置表
|
||||||
@@ -37,6 +35,6 @@ public class ForceWeekdayConfigEntity extends BaseEntity{
|
|||||||
* 是否节假日 0否 1是
|
* 是否节假日 0否 1是
|
||||||
*/
|
*/
|
||||||
@TableField("holiday_flag")
|
@TableField("holiday_flag")
|
||||||
private byte[] holidayFlag;
|
private Boolean holidayFlag;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
package com.kkz.kpersonalre.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.time.LocalTime;
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 闹钟时刻配置表
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author auto-generation-by-kcw
|
|
||||||
* @since 2025-03-27
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Builder
|
|
||||||
@TableName("tb_alarm_clock_config")
|
|
||||||
public class TbAlarmClockConfigEntity extends BaseEntity {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 闹钟时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "HH:mm", timezone = "GMT+8")
|
|
||||||
private LocalTime alarmTime;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package com.kkz.kpersonalre.entity;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 闹钟规则配置表
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author auto-generation-by-kcw
|
|
||||||
* @since 2025-03-27
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Builder
|
|
||||||
@TableName("tb_alarm_person_config")
|
|
||||||
public class TbAlarmPersonConfigEntity extends BaseEntity {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类型 1:融合 2:单独 融合的优先级最高
|
|
||||||
*/
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 配置描述
|
|
||||||
*/
|
|
||||||
private String describes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* json类型
|
|
||||||
融合为数组[[personId,localtionId,alarmClockId],[personId,localtionId,alarmClockId]]
|
|
||||||
|
|
||||||
单独不为数组,但元素一样,如果融合规则匹配则不匹配单独类型
|
|
||||||
*/
|
|
||||||
private String config;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package com.kkz.kpersonalre.entity;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 闹钟时刻表
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author auto-generation-by-kcw
|
|
||||||
* @since 2025-03-27
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Builder
|
|
||||||
@TableName("tb_location_upload")
|
|
||||||
public class TbLocationUploadEntity extends BaseEntity {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 地址配置表id
|
|
||||||
*/
|
|
||||||
private Integer locationConfigId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 人员配置表id
|
|
||||||
*/
|
|
||||||
private Integer personConfigId;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -9,19 +9,19 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.kkz.kpersonalre.api.R;
|
import com.kkz.kpersonalre.api.R;
|
||||||
import com.kkz.kpersonalre.entity.TbAlarmClockConfigEntity;
|
import com.kkz.kpersonalre.entity.AlarmClockConfigEntity;
|
||||||
import com.kkz.kpersonalre.entity.TbAlarmPersonConfigEntity;
|
import com.kkz.kpersonalre.entity.AlarmPersonConfigEntity;
|
||||||
import com.kkz.kpersonalre.entity.TbDateWeekdayEntity;
|
import com.kkz.kpersonalre.entity.DateWeekdayEntity;
|
||||||
import com.kkz.kpersonalre.entity.TbLocationConfigEntity;
|
import com.kkz.kpersonalre.entity.LocationConfigEntity;
|
||||||
import com.kkz.kpersonalre.entity.TbLocationUploadEntity;
|
import com.kkz.kpersonalre.entity.LocationUploadEntity;
|
||||||
import com.kkz.kpersonalre.entity.TbPersonConfigEntity;
|
import com.kkz.kpersonalre.entity.PersonConfigEntity;
|
||||||
import com.kkz.kpersonalre.mapper.TbAlarmClockConfigMapper;
|
import com.kkz.kpersonalre.mapper.AlarmClockConfigMapper;
|
||||||
import com.kkz.kpersonalre.mapper.TbAlarmPersonConfigMapper;
|
import com.kkz.kpersonalre.mapper.AlarmPersonConfigMapper;
|
||||||
import com.kkz.kpersonalre.mapper.TbDateWeekdayMapper;
|
import com.kkz.kpersonalre.mapper.DateWeekdayMapper;
|
||||||
import com.kkz.kpersonalre.mapper.TbForceWeekdayConfigMapper;
|
import com.kkz.kpersonalre.mapper.ForceWeekdayConfigMapper;
|
||||||
import com.kkz.kpersonalre.mapper.TbLocationConfigMapper;
|
import com.kkz.kpersonalre.mapper.LocationConfigMapper;
|
||||||
import com.kkz.kpersonalre.mapper.TbLocationUploadMapper;
|
import com.kkz.kpersonalre.mapper.LocationUploadMapper;
|
||||||
import com.kkz.kpersonalre.mapper.TbPersonConfigMapper;
|
import com.kkz.kpersonalre.mapper.PersonConfigMapper;
|
||||||
import com.kkz.kpersonalre.service.AlarmService;
|
import com.kkz.kpersonalre.service.AlarmService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -45,25 +45,25 @@ import java.util.Objects;
|
|||||||
public class AlarmServiceImpl implements AlarmService {
|
public class AlarmServiceImpl implements AlarmService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbAlarmClockConfigMapper alarmClockConfigMapper;
|
private AlarmClockConfigMapper alarmClockConfigMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbAlarmPersonConfigMapper alarmPersonConfigMapper;
|
private AlarmPersonConfigMapper alarmPersonConfigMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbDateWeekdayMapper dateWeekdayMapper;
|
private DateWeekdayMapper dateWeekdayMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbForceWeekdayConfigMapper forceWeekdayConfigMapper;
|
private ForceWeekdayConfigMapper forceWeekdayConfigMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbLocationConfigMapper locationConfigMapper;
|
private LocationConfigMapper locationConfigMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbLocationUploadMapper locationUploadMapper;
|
private LocationUploadMapper locationUploadMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbPersonConfigMapper personConfigMapper;
|
private PersonConfigMapper personConfigMapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,9 +75,9 @@ public class AlarmServiceImpl implements AlarmService {
|
|||||||
@Override
|
@Override
|
||||||
public R<String> uploadLocation(String person, String location) {
|
public R<String> uploadLocation(String person, String location) {
|
||||||
|
|
||||||
TbLocationConfigEntity locationConfigEntity = null;
|
LocationConfigEntity locationConfigEntity = null;
|
||||||
List<TbLocationConfigEntity> tbLocationConfigEntities = locationConfigMapper.selectList(new LambdaQueryWrapper<TbLocationConfigEntity>());
|
List<LocationConfigEntity> tbLocationConfigEntities = locationConfigMapper.selectList(new LambdaQueryWrapper<LocationConfigEntity>());
|
||||||
for (TbLocationConfigEntity tbLocationConfigEntity : tbLocationConfigEntities) {
|
for (LocationConfigEntity tbLocationConfigEntity : tbLocationConfigEntities) {
|
||||||
if (location.contains(tbLocationConfigEntity.getName())) {
|
if (location.contains(tbLocationConfigEntity.getName())) {
|
||||||
locationConfigEntity = tbLocationConfigEntity;
|
locationConfigEntity = tbLocationConfigEntity;
|
||||||
break;
|
break;
|
||||||
@@ -86,11 +86,11 @@ public class AlarmServiceImpl implements AlarmService {
|
|||||||
if (locationConfigEntity == null) {
|
if (locationConfigEntity == null) {
|
||||||
return R.failed("位置不存在");
|
return R.failed("位置不存在");
|
||||||
}
|
}
|
||||||
TbPersonConfigEntity personConfigEntity = personConfigMapper.selectOne(new LambdaQueryWrapper<TbPersonConfigEntity>().eq(TbPersonConfigEntity::getPerson, person));
|
PersonConfigEntity personConfigEntity = personConfigMapper.selectOne(new LambdaQueryWrapper<PersonConfigEntity>().eq(PersonConfigEntity::getPerson, person));
|
||||||
if (BeanUtil.isEmpty(personConfigEntity)) {
|
if (BeanUtil.isEmpty(personConfigEntity)) {
|
||||||
return R.failed("用户不存在");
|
return R.failed("用户不存在");
|
||||||
}
|
}
|
||||||
locationUploadMapper.insert(new TbLocationUploadEntity()
|
locationUploadMapper.insert(new LocationUploadEntity()
|
||||||
.setLocationConfigId(locationConfigEntity.getId().intValue())
|
.setLocationConfigId(locationConfigEntity.getId().intValue())
|
||||||
.setPersonConfigId(personConfigEntity.getId().intValue()));
|
.setPersonConfigId(personConfigEntity.getId().intValue()));
|
||||||
//检查一下工作日信息
|
//检查一下工作日信息
|
||||||
@@ -107,10 +107,10 @@ public class AlarmServiceImpl implements AlarmService {
|
|||||||
String s = HttpUtil.get("https://api.jiejiariapi.com/v1/workdays/" + DateUtil.year(DateUtil.nextWeek()));
|
String s = HttpUtil.get("https://api.jiejiariapi.com/v1/workdays/" + DateUtil.year(DateUtil.nextWeek()));
|
||||||
Map<String, Object> map = JSONUtil.toBean(s, HashMap.class);
|
Map<String, Object> map = JSONUtil.toBean(s, HashMap.class);
|
||||||
for (Map.Entry<String, Object> stringObjectEntry : map.entrySet()) {
|
for (Map.Entry<String, Object> stringObjectEntry : map.entrySet()) {
|
||||||
TbDateWeekdayEntity dateWeekdayEntity = dateWeekdayMapper.selectOne(new LambdaQueryWrapper<TbDateWeekdayEntity>()
|
DateWeekdayEntity dateWeekdayEntity = dateWeekdayMapper.selectOne(new LambdaQueryWrapper<DateWeekdayEntity>()
|
||||||
.eq(TbDateWeekdayEntity::getDate, stringObjectEntry.getKey()));
|
.eq(DateWeekdayEntity::getDate, stringObjectEntry.getKey()));
|
||||||
if (BeanUtil.isEmpty(dateWeekdayEntity)) {
|
if (BeanUtil.isEmpty(dateWeekdayEntity)) {
|
||||||
dateWeekdayMapper.insert(new TbDateWeekdayEntity()
|
dateWeekdayMapper.insert(new DateWeekdayEntity()
|
||||||
.setDate(LocalDateTimeUtil.parseDate(stringObjectEntry.getKey()))
|
.setDate(LocalDateTimeUtil.parseDate(stringObjectEntry.getKey()))
|
||||||
.setHolidayFlag(false));
|
.setHolidayFlag(false));
|
||||||
}
|
}
|
||||||
@@ -121,23 +121,23 @@ public class AlarmServiceImpl implements AlarmService {
|
|||||||
public R<LocalTime> getAlarm(String username) {
|
public R<LocalTime> getAlarm(String username) {
|
||||||
|
|
||||||
//判断今天是不是工作日
|
//判断今天是不是工作日
|
||||||
TbDateWeekdayEntity dateWeekdayEntity = dateWeekdayMapper.selectOne(new LambdaQueryWrapper<TbDateWeekdayEntity>()
|
DateWeekdayEntity dateWeekdayEntity = dateWeekdayMapper.selectOne(new LambdaQueryWrapper<DateWeekdayEntity>()
|
||||||
.eq(TbDateWeekdayEntity::getDate, LocalDate.now()));
|
.eq(DateWeekdayEntity::getDate, LocalDate.now()));
|
||||||
if (BeanUtil.isEmpty(dateWeekdayEntity) || dateWeekdayEntity.getHolidayFlag()) {
|
if (BeanUtil.isEmpty(dateWeekdayEntity) || dateWeekdayEntity.getHolidayFlag()) {
|
||||||
return R.failed("今天放假");
|
return R.failed("今天放假");
|
||||||
}
|
}
|
||||||
//找到人
|
//找到人
|
||||||
TbPersonConfigEntity personConfigEntity = personConfigMapper.selectOne(new LambdaQueryWrapper<TbPersonConfigEntity>()
|
PersonConfigEntity personConfigEntity = personConfigMapper.selectOne(new LambdaQueryWrapper<PersonConfigEntity>()
|
||||||
.eq(TbPersonConfigEntity::getPerson, username));
|
.eq(PersonConfigEntity::getPerson, username));
|
||||||
//找到配置
|
//找到配置
|
||||||
List<TbAlarmPersonConfigEntity> alarmPersonConfigEntities = alarmPersonConfigMapper.selectList(new LambdaQueryWrapper<>());
|
List<AlarmPersonConfigEntity> alarmPersonConfigEntities = alarmPersonConfigMapper.selectList(new LambdaQueryWrapper<>());
|
||||||
List<String> configs = alarmPersonConfigEntities.stream().map(TbAlarmPersonConfigEntity::getConfig).toList();
|
List<String> configs = alarmPersonConfigEntities.stream().map(AlarmPersonConfigEntity::getConfig).toList();
|
||||||
//先判断是不是自己的,不是自己的就没有配置
|
//先判断是不是自己的,不是自己的就没有配置
|
||||||
//personId,localtionId,alarmClockId
|
//personId,localtionId,alarmClockId
|
||||||
for (String configStr : configs) {
|
for (String configStr : configs) {
|
||||||
Integer alarmClockId = findAlarmClockId(configStr, personConfigEntity.getId().intValue());
|
Integer alarmClockId = findAlarmClockId(configStr, personConfigEntity.getId().intValue());
|
||||||
if (alarmClockId != null) {
|
if (alarmClockId != null) {
|
||||||
TbAlarmClockConfigEntity entity = alarmClockConfigMapper.selectById(alarmClockId);
|
AlarmClockConfigEntity entity = alarmClockConfigMapper.selectById(alarmClockId);
|
||||||
if (BeanUtil.isEmpty(entity)){
|
if (BeanUtil.isEmpty(entity)){
|
||||||
return R.failed("不响铃");
|
return R.failed("不响铃");
|
||||||
}
|
}
|
||||||
@@ -190,16 +190,16 @@ public class AlarmServiceImpl implements AlarmService {
|
|||||||
|
|
||||||
private boolean locationExists(Integer personId, Integer locationId) {
|
private boolean locationExists(Integer personId, Integer locationId) {
|
||||||
// MyBatis Plus查询:检查location_config_id是否存在
|
// MyBatis Plus查询:检查location_config_id是否存在
|
||||||
LambdaQueryWrapper<TbLocationUploadEntity> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<LocationUploadEntity> query = new LambdaQueryWrapper<>();
|
||||||
query
|
query
|
||||||
.eq(TbLocationUploadEntity::getLocationConfigId, locationId)
|
.eq(LocationUploadEntity::getLocationConfigId, locationId)
|
||||||
.eq(TbLocationUploadEntity::getPersonConfigId, personId);
|
.eq(LocationUploadEntity::getPersonConfigId, personId);
|
||||||
List<TbLocationUploadEntity> locationUploadEntities = locationUploadMapper.selectList(query);
|
List<LocationUploadEntity> locationUploadEntities = locationUploadMapper.selectList(query);
|
||||||
if (locationUploadEntities.isEmpty()) {
|
if (locationUploadEntities.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//要最新的一条
|
//要最新的一条
|
||||||
TbLocationUploadEntity locationUploadEntity = locationUploadEntities.get(locationUploadEntities.size() - 1);
|
LocationUploadEntity locationUploadEntity = locationUploadEntities.get(locationUploadEntities.size() - 1);
|
||||||
//最新的一条必须符合条件
|
//最新的一条必须符合条件
|
||||||
return Objects.equals(locationUploadEntity.getLocationConfigId(), locationId) && Objects.equals(locationUploadEntity.getPersonConfigId(), personId);
|
return Objects.equals(locationUploadEntity.getLocationConfigId(), locationId) && Objects.equals(locationUploadEntity.getPersonConfigId(), personId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user