考勤
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package org.dromara.common.utils;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.utils.MessageUtils;
|
||||
@ -9,6 +10,8 @@ import org.dromara.contractor.domain.SubConstructionUser;
|
||||
import org.dromara.mobileAttendanceMachine.DeviceMessageSender;
|
||||
import org.dromara.mobileAttendanceMachine.KqjEntity;
|
||||
import org.dromara.project.domain.BusAttendanceMachine;
|
||||
import org.dromara.project.domain.BusAttendanceMachineRepeat;
|
||||
import org.dromara.project.service.IBusAttendanceMachineRepeatService;
|
||||
import org.dromara.project.service.IBusAttendanceMachineService;
|
||||
import org.dromara.sms4j.api.SmsBlend;
|
||||
import org.dromara.sms4j.api.entity.SmsResponse;
|
||||
@ -19,6 +22,7 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
@ -36,6 +40,9 @@ public class AsyncUtil {
|
||||
@Lazy
|
||||
private IBusAttendanceMachineService attendanceMachineService;
|
||||
|
||||
@Resource
|
||||
private IBusAttendanceMachineRepeatService busAttendanceMachineRepeatService;
|
||||
|
||||
//发送短信
|
||||
@Async
|
||||
public void sendSms(List<String> mobileList, String config) {
|
||||
@ -63,22 +70,107 @@ public class AsyncUtil {
|
||||
public void sendPersonnel(Long teamId, SubConstructionUser constructionUser) {
|
||||
SysOssVo byId = ossService.getById(Long.valueOf(constructionUser.getFacePic()));
|
||||
List<BusAttendanceMachine> list = attendanceMachineService.lambdaQuery().apply("FIND_IN_SET({0}, teams)", teamId).list();
|
||||
|
||||
ArrayList<BusAttendanceMachineRepeat> repeats = new ArrayList<>();
|
||||
for (BusAttendanceMachine machine : list) {
|
||||
deviceMessageSender.sendPersonnelInformation(machine.getSn(), constructionUser.getSysUserId().toString(), constructionUser.getUserName(), byId.getUrl());
|
||||
Boolean b = deviceMessageSender.sendPersonnelInformation(machine.getSn(),
|
||||
constructionUser.getSysUserId().toString(), constructionUser.getUserName(), byId.getUrl());
|
||||
if (!b) {
|
||||
//记录下来重连时下发
|
||||
BusAttendanceMachineRepeat repeat = new BusAttendanceMachineRepeat();
|
||||
repeat.setSn(machine.getSn());
|
||||
repeat.setUserId(constructionUser.getSysUserId().toString());
|
||||
repeat.setUserName(constructionUser.getUserName());
|
||||
repeat.setUrl(byId.getUrl());
|
||||
repeat.setType("1");
|
||||
repeats.add(repeat);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(repeats)) {
|
||||
busAttendanceMachineRepeatService.saveBatch(repeats);
|
||||
}
|
||||
}
|
||||
|
||||
//删除考勤人员
|
||||
@Async
|
||||
public void deletePersonnel(SubConstructionUser constructionUser) {
|
||||
ArrayList<BusAttendanceMachineRepeat> repeats = new ArrayList<>();
|
||||
List<BusAttendanceMachine> list = attendanceMachineService.lambdaQuery().apply("FIND_IN_SET({0}, teams)", constructionUser.getTeamId()).list();
|
||||
for (BusAttendanceMachine machine : list) {
|
||||
try {
|
||||
deviceMessageSender.deleteUser(machine.getSn(), constructionUser.getSysUserId().toString());
|
||||
KqjEntity.CommonResponse commonResponse = deviceMessageSender.deleteUser(machine.getSn(), constructionUser.getSysUserId().toString());
|
||||
int code = commonResponse.getData().getCode();
|
||||
if (code != 0) {
|
||||
//记录下来重连时下发
|
||||
BusAttendanceMachineRepeat repeat = new BusAttendanceMachineRepeat();
|
||||
repeat.setSn(machine.getSn());
|
||||
repeat.setUserId(constructionUser.getSysUserId().toString());
|
||||
repeat.setUserName(constructionUser.getUserName());
|
||||
repeat.setUrl(null);
|
||||
repeat.setType("2");
|
||||
repeats.add(repeat);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("删除考勤人员异常", e);
|
||||
BusAttendanceMachineRepeat repeat = new BusAttendanceMachineRepeat();
|
||||
repeat.setSn(machine.getSn());
|
||||
repeat.setUserId(constructionUser.getSysUserId().toString());
|
||||
repeat.setUserName(constructionUser.getUserName());
|
||||
repeat.setUrl(null);
|
||||
repeat.setType("2");
|
||||
repeats.add(repeat);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(repeats)) {
|
||||
busAttendanceMachineRepeatService.saveBatch(repeats);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//重新下发人员
|
||||
@Async
|
||||
public void repeatSend(String sn) {
|
||||
List<BusAttendanceMachineRepeat> list = busAttendanceMachineRepeatService.lambdaQuery()
|
||||
.eq(BusAttendanceMachineRepeat::getSn, sn)
|
||||
.eq(BusAttendanceMachineRepeat::getType, "1")
|
||||
.list();
|
||||
List<Long> repeatIds = new ArrayList<>();
|
||||
for (BusAttendanceMachineRepeat repeat : list) {
|
||||
Boolean b = deviceMessageSender.sendPersonnelInformation(repeat.getSn(), repeat.getUserId(), repeat.getUserName(), repeat.getUrl());
|
||||
if (b) {
|
||||
//成功删除记录
|
||||
repeatIds.add(repeat.getId());
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(repeatIds)) {
|
||||
busAttendanceMachineRepeatService.removeByIds(repeatIds);
|
||||
}
|
||||
}
|
||||
|
||||
//重新删除人员
|
||||
@Async
|
||||
public void repeatDelete(String sn) {
|
||||
List<BusAttendanceMachineRepeat> list = busAttendanceMachineRepeatService.lambdaQuery()
|
||||
.eq(BusAttendanceMachineRepeat::getSn, sn)
|
||||
.eq(BusAttendanceMachineRepeat::getType, "2")
|
||||
.list();
|
||||
List<Long> repeatIds = new ArrayList<>();
|
||||
for (BusAttendanceMachineRepeat repeat : list) {
|
||||
try {
|
||||
KqjEntity.CommonResponse commonResponse = deviceMessageSender.deleteUser(repeat.getSn(), repeat.getUserId());
|
||||
int code = commonResponse.getData().getCode();
|
||||
if (code == 0) {
|
||||
//成功删除记录
|
||||
repeatIds.add(repeat.getId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("删除考勤人员异常", e);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(repeatIds)) {
|
||||
busAttendanceMachineRepeatService.removeByIds(repeatIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -257,6 +257,7 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
|
||||
constructionUser.setTypeOfWork(dto.getTypeOfWork());
|
||||
constructionUser.setEntryDate(new Date());
|
||||
constructionUser.setFirstDate(LocalDate.now());
|
||||
constructionUser.setStatus("0");
|
||||
|
||||
int i = baseMapper.updateById(constructionUser);
|
||||
|
||||
|
||||
@ -0,0 +1,105 @@
|
||||
package org.dromara.project.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.project.domain.vo.BusAttendanceMachineRepeatVo;
|
||||
import org.dromara.project.domain.bo.BusAttendanceMachineRepeatBo;
|
||||
import org.dromara.project.service.IBusAttendanceMachineRepeatService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 考勤重新下发
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-11-24
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/project/attendanceMachineRepeat")
|
||||
public class BusAttendanceMachineRepeatController extends BaseController {
|
||||
|
||||
private final IBusAttendanceMachineRepeatService busAttendanceMachineRepeatService;
|
||||
|
||||
/**
|
||||
* 查询考勤重新下发列表
|
||||
*/
|
||||
@SaCheckPermission("project:attendanceMachineRepeat:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<BusAttendanceMachineRepeatVo> list(BusAttendanceMachineRepeatBo bo, PageQuery pageQuery) {
|
||||
return busAttendanceMachineRepeatService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出考勤重新下发列表
|
||||
*/
|
||||
@SaCheckPermission("project:attendanceMachineRepeat:export")
|
||||
@Log(title = "考勤重新下发", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(BusAttendanceMachineRepeatBo bo, HttpServletResponse response) {
|
||||
List<BusAttendanceMachineRepeatVo> list = busAttendanceMachineRepeatService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "考勤重新下发", BusAttendanceMachineRepeatVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取考勤重新下发详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("project:attendanceMachineRepeat:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<BusAttendanceMachineRepeatVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(busAttendanceMachineRepeatService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增考勤重新下发
|
||||
*/
|
||||
@SaCheckPermission("project:attendanceMachineRepeat:add")
|
||||
@Log(title = "考勤重新下发", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody BusAttendanceMachineRepeatBo bo) {
|
||||
return toAjax(busAttendanceMachineRepeatService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改考勤重新下发
|
||||
*/
|
||||
@SaCheckPermission("project:attendanceMachineRepeat:edit")
|
||||
@Log(title = "考勤重新下发", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BusAttendanceMachineRepeatBo bo) {
|
||||
return toAjax(busAttendanceMachineRepeatService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除考勤重新下发
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("project:attendanceMachineRepeat:remove")
|
||||
@Log(title = "考勤重新下发", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(busAttendanceMachineRepeatService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package org.dromara.project.domain;
|
||||
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 考勤重新下发对象 bus_attendance_machine_repeat
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-11-24
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("bus_attendance_machine_repeat")
|
||||
public class BusAttendanceMachineRepeat extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备sn
|
||||
*/
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 人脸地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* (1-新增 2-删除)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package org.dromara.project.domain.bo;
|
||||
|
||||
import org.dromara.project.domain.BusAttendanceMachineRepeat;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 考勤重新下发业务对象 bus_attendance_machine_repeat
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-11-24
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = BusAttendanceMachineRepeat.class, reverseConvertGenerate = false)
|
||||
public class BusAttendanceMachineRepeatBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@NotNull(message = "主键ID不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备sn
|
||||
*/
|
||||
@NotBlank(message = "设备sn不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 人脸地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* (1-新增 2-删除)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
package org.dromara.project.domain.vo;
|
||||
|
||||
import org.dromara.project.domain.BusAttendanceMachineRepeat;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 考勤重新下发视图对象 bus_attendance_machine_repeat
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-11-24
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = BusAttendanceMachineRepeat.class)
|
||||
public class BusAttendanceMachineRepeatVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@ExcelProperty(value = "主键ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备sn
|
||||
*/
|
||||
@ExcelProperty(value = "设备sn")
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@ExcelProperty(value = "用户id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@ExcelProperty(value = "用户名")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 人脸地址
|
||||
*/
|
||||
@ExcelProperty(value = "人脸地址")
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* (1-新增 2-删除)
|
||||
*/
|
||||
@ExcelProperty(value = "", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "1=-新增,2=-删除")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package org.dromara.project.mapper;
|
||||
|
||||
import org.dromara.project.domain.BusAttendanceMachineRepeat;
|
||||
import org.dromara.project.domain.vo.BusAttendanceMachineRepeatVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 考勤重新下发Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-11-24
|
||||
*/
|
||||
public interface BusAttendanceMachineRepeatMapper extends BaseMapperPlus<BusAttendanceMachineRepeat, BusAttendanceMachineRepeatVo> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package org.dromara.project.service;
|
||||
|
||||
import org.dromara.project.domain.vo.BusAttendanceMachineRepeatVo;
|
||||
import org.dromara.project.domain.bo.BusAttendanceMachineRepeatBo;
|
||||
import org.dromara.project.domain.BusAttendanceMachineRepeat;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 考勤重新下发Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-11-24
|
||||
*/
|
||||
public interface IBusAttendanceMachineRepeatService extends IService<BusAttendanceMachineRepeat>{
|
||||
|
||||
/**
|
||||
* 查询考勤重新下发
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 考勤重新下发
|
||||
*/
|
||||
BusAttendanceMachineRepeatVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询考勤重新下发列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 考勤重新下发分页列表
|
||||
*/
|
||||
TableDataInfo<BusAttendanceMachineRepeatVo> queryPageList(BusAttendanceMachineRepeatBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的考勤重新下发列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 考勤重新下发列表
|
||||
*/
|
||||
List<BusAttendanceMachineRepeatVo> queryList(BusAttendanceMachineRepeatBo bo);
|
||||
|
||||
/**
|
||||
* 新增考勤重新下发
|
||||
*
|
||||
* @param bo 考勤重新下发
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(BusAttendanceMachineRepeatBo bo);
|
||||
|
||||
/**
|
||||
* 修改考勤重新下发
|
||||
*
|
||||
* @param bo 考勤重新下发
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(BusAttendanceMachineRepeatBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除考勤重新下发信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -0,0 +1,136 @@
|
||||
package org.dromara.project.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.project.domain.bo.BusAttendanceMachineRepeatBo;
|
||||
import org.dromara.project.domain.vo.BusAttendanceMachineRepeatVo;
|
||||
import org.dromara.project.domain.BusAttendanceMachineRepeat;
|
||||
import org.dromara.project.mapper.BusAttendanceMachineRepeatMapper;
|
||||
import org.dromara.project.service.IBusAttendanceMachineRepeatService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 考勤重新下发Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-11-24
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class BusAttendanceMachineRepeatServiceImpl extends ServiceImpl<BusAttendanceMachineRepeatMapper, BusAttendanceMachineRepeat>
|
||||
implements IBusAttendanceMachineRepeatService {
|
||||
|
||||
private final BusAttendanceMachineRepeatMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询考勤重新下发
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 考勤重新下发
|
||||
*/
|
||||
@Override
|
||||
public BusAttendanceMachineRepeatVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询考勤重新下发列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 考勤重新下发分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<BusAttendanceMachineRepeatVo> queryPageList(BusAttendanceMachineRepeatBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<BusAttendanceMachineRepeat> lqw = buildQueryWrapper(bo);
|
||||
Page<BusAttendanceMachineRepeatVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的考勤重新下发列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 考勤重新下发列表
|
||||
*/
|
||||
@Override
|
||||
public List<BusAttendanceMachineRepeatVo> queryList(BusAttendanceMachineRepeatBo bo) {
|
||||
LambdaQueryWrapper<BusAttendanceMachineRepeat> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<BusAttendanceMachineRepeat> buildQueryWrapper(BusAttendanceMachineRepeatBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<BusAttendanceMachineRepeat> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByDesc(BusAttendanceMachineRepeat::getId);
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getSn()), BusAttendanceMachineRepeat::getSn, bo.getSn());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getUserId()), BusAttendanceMachineRepeat::getUserId, bo.getUserId());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getUserName()), BusAttendanceMachineRepeat::getUserName, bo.getUserName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getUrl()), BusAttendanceMachineRepeat::getUrl, bo.getUrl());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getType()), BusAttendanceMachineRepeat::getType, bo.getType());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增考勤重新下发
|
||||
*
|
||||
* @param bo 考勤重新下发
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(BusAttendanceMachineRepeatBo bo) {
|
||||
BusAttendanceMachineRepeat add = MapstructUtils.convert(bo, BusAttendanceMachineRepeat.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改考勤重新下发
|
||||
*
|
||||
* @param bo 考勤重新下发
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(BusAttendanceMachineRepeatBo bo) {
|
||||
BusAttendanceMachineRepeat update = MapstructUtils.convert(bo, BusAttendanceMachineRepeat.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(BusAttendanceMachineRepeat entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除考勤重新下发信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -478,10 +478,10 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
attendance.setClockStatus(BusAttendanceClockStatusEnum.NORMAL.getValue());
|
||||
}
|
||||
//只要请假,直接归为请假
|
||||
LocalDateTime localDateTime = localDate.atTime(busAttendanceRuleVo.getClockInTime());
|
||||
if (leaveService.isLeave(localDateTime, userId)) {
|
||||
attendance.setClockStatus(BusAttendanceClockStatusEnum.LEAVE.getValue());
|
||||
}
|
||||
//LocalDateTime localDateTime = localDate.atTime(busAttendanceRuleVo.getClockInTime());
|
||||
//if (leaveService.isLeave(localDateTime, userId)) {
|
||||
// attendance.setClockStatus(BusAttendanceClockStatusEnum.LEAVE.getValue());
|
||||
//}
|
||||
|
||||
// 填充信息
|
||||
attendance.setUserId(userId);
|
||||
@ -532,10 +532,10 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
busAttendance.setClockStatus(BusAttendanceClockStatusEnum.NORMAL.getValue());
|
||||
}
|
||||
//只要请假,直接归为请假
|
||||
LocalDateTime localDateTime = localDate.atTime(busAttendanceRuleVo.getClockInTime());
|
||||
if (leaveService.isLeave(localDateTime, userId)) {
|
||||
busAttendance.setClockStatus(BusAttendanceClockStatusEnum.LEAVE.getValue());
|
||||
}
|
||||
//LocalDateTime localDateTime = localDate.atTime(busAttendanceRuleVo.getClockInTime());
|
||||
//if (leaveService.isLeave(localDateTime, userId)) {
|
||||
// busAttendance.setClockStatus(BusAttendanceClockStatusEnum.LEAVE.getValue());
|
||||
//}
|
||||
|
||||
busAttendance.setSource(req.getSource());
|
||||
busAttendance.setSn(req.getSn());
|
||||
@ -576,10 +576,10 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
busAttendance.setMinuteCount(0);
|
||||
}
|
||||
//只要请假,直接归为请假
|
||||
LocalDateTime localDateTime = localDate.atTime(busAttendanceRuleVo.getClockInTime());
|
||||
if (leaveService.isLeave(localDateTime, userId)) {
|
||||
busAttendance.setClockStatus(BusAttendanceClockStatusEnum.LEAVE.getValue());
|
||||
}
|
||||
//LocalDateTime localDateTime = localDate.atTime(busAttendanceRuleVo.getClockInTime());
|
||||
//if (leaveService.isLeave(localDateTime, userId)) {
|
||||
// busAttendance.setClockStatus(BusAttendanceClockStatusEnum.LEAVE.getValue());
|
||||
//}
|
||||
updateById(busAttendance);
|
||||
} else {
|
||||
BusAttendance attendance = new BusAttendance();
|
||||
@ -594,10 +594,10 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
attendance.setClockStatus(BusAttendanceClockStatusEnum.NORMAL.getValue());
|
||||
}
|
||||
//只要请假,直接归为请假
|
||||
LocalDateTime localDateTime = localDate.atTime(busAttendanceRuleVo.getClockInTime());
|
||||
if (leaveService.isLeave(localDateTime, userId)) {
|
||||
attendance.setClockStatus(BusAttendanceClockStatusEnum.LEAVE.getValue());
|
||||
}
|
||||
//LocalDateTime localDateTime = localDate.atTime(busAttendanceRuleVo.getClockInTime());
|
||||
//if (leaveService.isLeave(localDateTime, userId)) {
|
||||
// attendance.setClockStatus(BusAttendanceClockStatusEnum.LEAVE.getValue());
|
||||
//}
|
||||
// 填充信息
|
||||
attendance.setUserId(userId);
|
||||
attendance.setProjectId(req.getProjectId());
|
||||
|
||||
@ -216,6 +216,7 @@ public class BusConstructionUserExitServiceImpl extends ServiceImpl<BusConstruct
|
||||
LambdaUpdateWrapper<SubConstructionUser> constructionUserLuw = Wrappers.lambdaUpdate(SubConstructionUser.class)
|
||||
.eq(SubConstructionUser::getId, constructionUser.getId())
|
||||
.set(SubConstructionUser::getTeamId, null)
|
||||
.set(SubConstructionUser::getStatus, "1")
|
||||
.set(SubConstructionUser::getLeaveDate, new Date());
|
||||
if (StringUtils.isNotBlank(salaryVoucherFile) && StringUtils.isNotBlank(salaryConfirmationFile)) {
|
||||
constructionUserLuw.set(SubConstructionUser::getExitStatus, "2");
|
||||
|
||||
@ -190,6 +190,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
||||
.set(SubConstructionUser::getLeaveDate, null)
|
||||
.set(SubConstructionUser::getExitStatus, "0")
|
||||
.set(SubConstructionUser::getUserRole, "0")
|
||||
.set(SubConstructionUser::getStatus, "0")
|
||||
.set(StrUtil.isNotBlank(req.getTypeOfWork()), SubConstructionUser::getTypeOfWork, req.getTypeOfWork())
|
||||
.set(constructionUser.getFirstDate() == null, SubConstructionUser::getFirstDate, LocalDate.now());
|
||||
constructionUserService.update(constructionUserLuw);
|
||||
@ -366,6 +367,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
||||
.eq(SubConstructionUser::getId, constructionUser.getId())
|
||||
.set(SubConstructionUser::getExitStatus, exitStatus)
|
||||
.set(SubConstructionUser::getTeamId, null)
|
||||
.set(SubConstructionUser::getStatus, "1")
|
||||
.set(SubConstructionUser::getLeaveDate, new Date());
|
||||
constructionUserService.update(constructionUserLuw);
|
||||
|
||||
|
||||
@ -2,11 +2,13 @@ package org.dromara.websocket.websocket.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.websocket.*;
|
||||
import jakarta.websocket.server.ServerEndpoint;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.utils.AsyncUtil;
|
||||
import org.dromara.mobileAttendanceMachine.KqjEntity;
|
||||
import org.dromara.project.service.IBusAttendanceMachineService;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -33,6 +35,9 @@ public class DeviceWebSocketServer {
|
||||
|
||||
private final static IBusAttendanceMachineService attendanceMachineService = SpringUtils.getBean(IBusAttendanceMachineService.class);
|
||||
|
||||
private final static AsyncUtil asyncUtil = SpringUtils.getBean(AsyncUtil.class);
|
||||
|
||||
|
||||
// ------------------------------ 常量定义 ------------------------------
|
||||
public static final String DECLARE = "declare"; // 设备注册消息
|
||||
public static final String PING = "ping"; // 心跳消息
|
||||
@ -388,6 +393,8 @@ public class DeviceWebSocketServer {
|
||||
// 示例:BusAttendanceMachineService.register(sn);
|
||||
if (attendanceMachineService != null) {
|
||||
attendanceMachineService.insertBySn(sn);
|
||||
asyncUtil.repeatSend(sn);
|
||||
asyncUtil.repeatDelete(sn);
|
||||
} else {
|
||||
log.error("IBusAttendanceMachineService 为空,无法进行设备注册");
|
||||
}
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.project.mapper.BusAttendanceMachineRepeatMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user