考勤设备管理
This commit is contained in:
parent
e48e3ba95c
commit
d96580d6b1
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.system.api.equipment;
|
||||
|
||||
import cn.iocoder.yudao.module.system.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 考勤设备")
|
||||
public interface AttendanceMachineApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/attendance-machine";
|
||||
|
||||
@PostMapping(PREFIX + "/update")
|
||||
@Operation(summary = "修改设备状态")
|
||||
@Parameter(name = "deviceNo", description = "设备号", example = "QTB782", required = true)
|
||||
void updateAttendanceMachineStatus(@RequestParam("deviceNo") String deviceNo);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.system.api.equipment;
|
||||
|
||||
import cn.iocoder.yudao.module.system.service.equipment.AttendanceMachineService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class AttendanceMachineApiImpl implements AttendanceMachineApi{
|
||||
|
||||
@Resource
|
||||
private AttendanceMachineService attendanceMachineService;
|
||||
|
||||
@Override
|
||||
public void updateAttendanceMachineStatus(String deviceNo) {
|
||||
|
||||
attendanceMachineService.updateAttendanceMachineStatus(deviceNo);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.equipment;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -14,11 +13,9 @@ import cn.iocoder.yudao.module.system.controller.admin.equipment.vo.userExt.User
|
||||
import cn.iocoder.yudao.module.system.controller.admin.equipment.vo.userExt.UsersExtPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.equipment.vo.userExt.UsersExtRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.equipment.vo.userExt.UsersExtSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserImportExcelVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserImportRespVO;
|
||||
import cn.iocoder.yudao.module.system.convert.equipment.UsersExtConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.equipment.AttendanceMachineDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.equipment.UsersExtDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
@ -28,6 +25,11 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFPictureData;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -37,8 +39,6 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -65,10 +65,11 @@ public class UsersExtController {
|
||||
@RequestMapping(value = "/create",
|
||||
method = {RequestMethod.POST, RequestMethod.PUT}) // 解决 uni-app 不支持 Put 上传文件的问题)
|
||||
@Operation(summary = "上传照片")
|
||||
@Parameter(name = "createReqVO", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:users-ext:create')")
|
||||
public CommonResult<Long> createUsersExt(@Valid UsersExtSaveReqVO createReqVO) throws Exception {
|
||||
public CommonResult<Long> createUsersExt(@ModelAttribute UsersExtSaveReqVO createReqVO, @RequestParam("faceFile") MultipartFile file) throws Exception {
|
||||
|
||||
if (createReqVO.getFaceFile().isEmpty()) {
|
||||
if (file == null || file.isEmpty()) {
|
||||
|
||||
usersExtService.deleteUserFaceImg(getLoginUserId());
|
||||
|
||||
@ -76,7 +77,7 @@ public class UsersExtController {
|
||||
}
|
||||
|
||||
UsersExtDO updateDO = BeanUtils.toBean(createReqVO, UsersExtDO.class);
|
||||
return success(usersExtService.createUsersExt(updateDO, createReqVO.getFaceFile()));
|
||||
return success(usersExtService.createUsersExt(updateDO, file));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ -151,7 +152,7 @@ public class UsersExtController {
|
||||
List<UsersExtRespVO> list = usersExtService.getUsersExtPage(pageReqVO).getList();
|
||||
|
||||
// 输出
|
||||
ExcelUtils.write(response, "用户导入.xlsx", "用户列表", UsersExtRespVO.class, list);
|
||||
ExcelUtils.write(response, "用户导入.xlsx", "用户列表", UserExtImportVO.class, BeanUtils.toBean(list, UserExtImportVO.class));
|
||||
}
|
||||
|
||||
@PostMapping("/import")
|
||||
@ -166,6 +167,19 @@ public class UsersExtController {
|
||||
|
||||
List<UserExtImportVO> list = ExcelUtils.read(file, UserExtImportVO.class);
|
||||
|
||||
Workbook workbook = new XSSFWorkbook(file.getInputStream());
|
||||
for (Sheet sheet : workbook) {
|
||||
if (sheet instanceof XSSFSheet) {
|
||||
XSSFSheet xssfSheet = (XSSFSheet) sheet;
|
||||
List<XSSFPictureData> pictures = xssfSheet.getWorkbook().getAllPictures();
|
||||
for (int i = 0; i < pictures.size(); i++) {
|
||||
|
||||
UserExtImportVO importVO = list.get(i);
|
||||
importVO.setFaceFile(pictures.get(i).getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return success(usersExtService.importUserList(list, updateSupport));
|
||||
}
|
||||
}
|
@ -5,8 +5,6 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 考勤设备 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@ -38,4 +36,6 @@ public class AttendanceMachineRespVO {
|
||||
@ExcelProperty("设备名称")
|
||||
private String deviceName;
|
||||
|
||||
@Schema(description = "是否在线 | 0否 1是")
|
||||
private Integer isOnLine;
|
||||
}
|
@ -1,28 +1,53 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.equipment.vo.userExt;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
|
||||
@ExcelIgnoreUnannotated
|
||||
public class UserExtImportVO {
|
||||
|
||||
@Schema(description = "id", example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户编号", example = "146")
|
||||
@ExcelProperty("用户编号")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户名称", example = "张三")
|
||||
@ExcelProperty("用户名称")
|
||||
private String userName;
|
||||
|
||||
@ExcelProperty("人脸图片")
|
||||
private MultipartFile faceFile;
|
||||
@Schema(description = "部门编号", example = "128")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "部门名称", example = "研发部")
|
||||
@ExcelProperty("部门名称")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "人脸图片地址")
|
||||
@ExcelProperty("人脸图片")
|
||||
private byte[] faceFile;
|
||||
|
||||
@Schema(description = "人脸图片地址")
|
||||
private String faceImg;
|
||||
|
||||
@Schema(description = "绑定的考勤机设备号集合")
|
||||
private List<String> attendanceMachineNos;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.system.controller.admin.equipment.vo.userExt;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
@ -22,9 +21,6 @@ public class UsersExtSaveReqVO {
|
||||
@NotNull(message = "部门编号不能为空")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "人脸图片附件")
|
||||
private MultipartFile faceFile;
|
||||
|
||||
@Schema(description = "绑定的考勤机设备号集合")
|
||||
private List<String> attendanceMachineNos;
|
||||
|
||||
|
@ -1,14 +1,12 @@
|
||||
package cn.iocoder.yudao.module.system.convert.equipment;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.equipment.vo.userExt.UsersExtRespVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.equipment.UsersExtDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -28,6 +26,8 @@ public interface UsersExtConvert {
|
||||
usersExtDO.setDeptName(dept.getName());
|
||||
}
|
||||
|
||||
usersExtDO.setFaceImg(usersExtDO.getFaceImg() + "?time=" + LocalDateTime.now().getSecond());
|
||||
|
||||
return usersExtDO;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 考勤设备 DO
|
||||
*
|
||||
@ -49,4 +51,14 @@ public class AttendanceMachineDO extends BaseDO {
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 设备状态
|
||||
* 0离线 1在线
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 请求时间
|
||||
*/
|
||||
private LocalDateTime requestTime;
|
||||
}
|
@ -1,11 +1,9 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.equipment;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 考勤机下发记录 DO
|
||||
@ -34,6 +32,11 @@ public class DistributeRecordDO extends BaseDO {
|
||||
* 用户编号
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 记录类型
|
||||
* 0删除 1下发
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 下发结果
|
||||
*/
|
||||
|
@ -1,8 +1,6 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.equipment;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.equipment.vo.attendancemachine.AttendanceMachinePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.equipment.vo.attendancemachine.AttendanceMachineRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.equipment.vo.attendancemachine.UserExtPageReqVO;
|
||||
@ -20,7 +18,9 @@ import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface AttendanceMachineMapper extends BaseMapperX<AttendanceMachineDO> {
|
||||
|
||||
IPage<AttendanceMachineRespVO> selectAttendancePage(@Param("page") IPage<AttendanceMachineRespVO> mpPage, @Param("reqVO") AttendanceMachinePageReqVO pageReqVO);
|
||||
IPage<AttendanceMachineRespVO> selectAttendancePage(@Param("page") IPage<AttendanceMachineRespVO> mpPage,
|
||||
@Param("reqVO") AttendanceMachinePageReqVO pageReqVO);
|
||||
// @Param("deviceNos")List<String> deviceNos);
|
||||
|
||||
AttendanceMachineRespVO selectAttendanceByAssetsNo(@Param("assetsNo") String assetsNo);
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.equipment;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.equipment.DistributeRecordDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 考勤机下发记录 Mapper
|
||||
*
|
||||
* @author 符溶馨
|
||||
*/
|
||||
@Mapper
|
||||
public interface DistributeRecordMapper extends BaseMapperX<DistributeRecordDO> {
|
||||
|
||||
}
|
@ -30,6 +30,12 @@ public interface AttendanceMachineService {
|
||||
*/
|
||||
void updateAttendanceMachine(@Valid AttendanceMachineSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 更新考勤设备 状态
|
||||
* @param deviceNo 设备号
|
||||
*/
|
||||
void updateAttendanceMachineStatus(String deviceNo);
|
||||
|
||||
/**
|
||||
* 考勤设备密码修改
|
||||
* @param updateReqVO 更新信息
|
||||
|
@ -10,12 +10,12 @@ import cn.iocoder.yudao.module.system.controller.admin.equipment.vo.userExt.User
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.assets.AssetsTypeDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.equipment.AttendanceMachineDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.equipment.UsersExtDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.equipment.DistributeRecordDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.equipment.AttendanceMachineMapper;
|
||||
import cn.iocoder.yudao.module.system.service.assets.AssetsTypeService;
|
||||
import cn.iocoder.yudao.module.system.service.assets.DeptAssetsInOutStockService;
|
||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -23,8 +23,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
@ -59,9 +63,24 @@ public class AttendanceMachineServiceImpl implements AttendanceMachineService {
|
||||
private UsersExtService usersExtService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createAttendanceMachine(AttendanceMachineSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
AttendanceMachineDO attendanceMachine = BeanUtils.toBean(createReqVO, AttendanceMachineDO.class);
|
||||
|
||||
//如果分配机构的情况, 则调用资产分配方法
|
||||
if (createReqVO.getDeptId() != null) {
|
||||
|
||||
DeptAssetsInOutStockSaveReqVO vos = new DeptAssetsInOutStockSaveReqVO();
|
||||
vos.setInDeptId(createReqVO.getDeptId());
|
||||
vos.setAssetsId(createReqVO.getAssetsId());
|
||||
vos.setNum(1);
|
||||
|
||||
deptAssetsInOutStockService.createDeptAssetsInOutStock(-1L, Collections.singletonList(vos));
|
||||
}
|
||||
|
||||
//设置设备初始密码
|
||||
attendanceMachine.setPassword(passwordEncoder.encode("123456"));
|
||||
attendanceMachineMapper.insert(attendanceMachine);
|
||||
// 返回
|
||||
return attendanceMachine.getId();
|
||||
@ -75,7 +94,7 @@ public class AttendanceMachineServiceImpl implements AttendanceMachineService {
|
||||
validateAttendanceMachineExists(updateReqVO.getId());
|
||||
|
||||
//如果分配机构的情况, 则调用资产分配方法
|
||||
if (updateReqVO.getId() != null) {
|
||||
if (updateReqVO.getDeptId() != null) {
|
||||
|
||||
DeptAssetsInOutStockSaveReqVO vos = new DeptAssetsInOutStockSaveReqVO();
|
||||
vos.setInDeptId(updateReqVO.getDeptId());
|
||||
@ -90,6 +109,13 @@ public class AttendanceMachineServiceImpl implements AttendanceMachineService {
|
||||
attendanceMachineMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAttendanceMachineStatus(String deviceNo) {
|
||||
|
||||
attendanceMachineMapper.update(new AttendanceMachineDO().setStatus(1).setRequestTime(LocalDateTime.now()),
|
||||
new LambdaUpdateWrapper<AttendanceMachineDO>().eq(AttendanceMachineDO::getDeviceNo, deviceNo));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePassword(AttendanceMachinePasswordVO updateReqVO) {
|
||||
|
||||
@ -149,7 +175,7 @@ public class AttendanceMachineServiceImpl implements AttendanceMachineService {
|
||||
Map<Long, DeptDO> deptDOMap = deptService.getDeptMap(convertList(page.getRecords(), AttendanceMachineRespVO::getDeptId));
|
||||
|
||||
return new PageResult<>(
|
||||
CollectionUtils.convertList(page.getRecords(), data -> data.setDeptName(deptDOMap.isEmpty() ? null : deptDOMap.get(data.getDeptId()).getName())),
|
||||
CollectionUtils.convertList(page.getRecords(), data -> data.setDeptName(deptDOMap.isEmpty() || deptDOMap.get(data.getDeptId()) == null ? null : deptDOMap.get(data.getDeptId()).getName())),
|
||||
page.getTotal());
|
||||
}
|
||||
|
||||
@ -163,13 +189,15 @@ public class AttendanceMachineServiceImpl implements AttendanceMachineService {
|
||||
Map<Long, DeptDO> deptDOMap = deptService.getDeptMap(convertList(page.getRecords(), UsersExtRespVO::getDeptId));
|
||||
|
||||
return new PageResult<>(
|
||||
CollectionUtils.convertList(page.getRecords(), data -> data.setDeptName(deptDOMap.isEmpty() ? null : deptDOMap.get(data.getDeptId()).getName())),
|
||||
CollectionUtils.convertList(page.getRecords(), data -> data.setDeptName(deptDOMap.isEmpty() || deptDOMap.get(data.getDeptId()) == null ? null : deptDOMap.get(data.getDeptId()).getName())),
|
||||
page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addUserToAttendanceMachine(AddUserToAttendanceMachineVO addReqVO) {
|
||||
|
||||
List<DistributeRecordDO> recordDOS = new ArrayList<>();
|
||||
|
||||
// 更新用户已下发设备列表
|
||||
List<UsersExtRespVO> userInfo = addReqVO.getUserInfo();
|
||||
if (addReqVO.getMethod() == 0) {
|
||||
@ -177,8 +205,9 @@ public class AttendanceMachineServiceImpl implements AttendanceMachineService {
|
||||
userInfo.forEach(data -> {
|
||||
|
||||
List<String> deviceNo = data.getAttendanceMachineNos();
|
||||
// 添加设备号
|
||||
deviceNo.addAll(addReqVO.getDeviceNos());
|
||||
|
||||
// 添加不重复的设备号
|
||||
deviceNo.addAll(addReqVO.getDeviceNos().stream().filter(var -> !deviceNo.contains(var)).collect(Collectors.toList()));
|
||||
|
||||
//设备 用户绑定设备
|
||||
data.setAttendanceMachineNos(deviceNo);
|
||||
@ -199,5 +228,7 @@ public class AttendanceMachineServiceImpl implements AttendanceMachineService {
|
||||
// 更新 用户信息
|
||||
usersExtService.updateListUsersExt(userInfo);
|
||||
|
||||
//同步 插入 下发记录
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.system.service.equipment;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.equipment.DistributeRecordDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 考勤机下发记录 Service 接口
|
||||
*
|
||||
* @author 符溶馨
|
||||
*/
|
||||
public interface DistributeRecordService {
|
||||
|
||||
/**
|
||||
* 创建考勤机下发记录
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDistributeRecord(@Valid DistributeRecordDO createReqVO);
|
||||
|
||||
/**
|
||||
* 获得考勤机下发记录
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 考勤机下发记录
|
||||
*/
|
||||
DistributeRecordDO getDistributeRecord(Long id);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.system.service.equipment;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.equipment.DistributeRecordDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.equipment.DistributeRecordMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 考勤机下发记录 Service 实现类
|
||||
*
|
||||
* @author 符溶馨
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class DistributeRecordServiceImpl implements DistributeRecordService {
|
||||
|
||||
@Resource
|
||||
private DistributeRecordMapper distributeRecordMapper;
|
||||
|
||||
@Override
|
||||
public Long createDistributeRecord(DistributeRecordDO createReqVO) {
|
||||
|
||||
// 插入
|
||||
distributeRecordMapper.insert(createReqVO);
|
||||
// 返回
|
||||
return createReqVO.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributeRecordDO getDistributeRecord(Long id) {
|
||||
return distributeRecordMapper.selectById(id);
|
||||
}
|
||||
|
||||
}
|
@ -23,7 +23,7 @@ public interface UsersExtService {
|
||||
/**
|
||||
* 创建用户信息拓展
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @param updateDO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createUsersExt(UsersExtDO updateDO, MultipartFile file) throws IOException;
|
||||
|
@ -11,7 +11,6 @@ import cn.iocoder.yudao.module.system.controller.admin.equipment.vo.userExt.User
|
||||
import cn.iocoder.yudao.module.system.controller.admin.equipment.vo.userExt.UsersExtRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.equipment.vo.userExt.UsersExtSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserImportRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.upload.UploadUserFile;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.equipment.UsersExtDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
@ -180,56 +179,47 @@ public class UsersExtServiceImpl implements UsersExtService {
|
||||
|
||||
importUsers.forEach(importUser -> {
|
||||
|
||||
try {
|
||||
//获得 更新信息
|
||||
UsersExtDO updateDO = BeanUtils.toBean(importUser, UsersExtDO.class);
|
||||
//设备部门编号
|
||||
updateDO.setDeptId(userDOMap.get(updateDO.getUserId()).getDeptId());
|
||||
if (importUser.getFaceFile() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String url = null;
|
||||
String name = null;
|
||||
String fileName = importUser.getFaceFile().getOriginalFilename();
|
||||
if (fileName == null || fileName.isEmpty()) {
|
||||
//获得 更新信息
|
||||
UsersExtDO updateDO = BeanUtils.toBean(importUser, UsersExtDO.class);
|
||||
//设备部门编号
|
||||
updateDO.setDeptId(userDOMap.get(updateDO.getUserId()).getDeptId());
|
||||
|
||||
name = importUser.getUserId() + "_faceImg.jpg";
|
||||
}else {
|
||||
String url = null;
|
||||
String name = null;
|
||||
name = importUser.getUserId() + "_faceImg.jpg";
|
||||
|
||||
name = importUser.getUserId() + "_faceImg." + fileName.split("\\.")[1];
|
||||
}
|
||||
byte[] content = IoUtil.readBytes(importUser.getFaceFile().getInputStream());
|
||||
//校验 当前用户人脸信息是否已存在
|
||||
UsersExtDO usersExtDO = usersExtMapper.selectOne(UsersExtDO::getUserId, importUser.getUserId());
|
||||
if (usersExtDO == null) {
|
||||
|
||||
//校验 当前用户人脸信息是否已存在
|
||||
UsersExtDO usersExtDO = usersExtMapper.selectOne(UsersExtDO::getUserId, importUser.getUserId());
|
||||
if (usersExtDO == null) {
|
||||
// 同步 把人脸图片插入 BusinessFile中 存储文件
|
||||
url = fileApi.createBusinessFile(6L, name, importUser.getFaceFile());
|
||||
|
||||
// 同步 把人脸图片插入 BusinessFile中 存储文件
|
||||
url = fileApi.createBusinessFile(6L, name, content);
|
||||
updateDO.setFaceImg(url);
|
||||
usersExtMapper.insert(updateDO);
|
||||
|
||||
respVO.getCreateUsernames().add(importUser.getUserName());
|
||||
} else {
|
||||
|
||||
if (!isUpdateSupport) {
|
||||
|
||||
respVO.getFailureUsernames().put(importUser.getUserName(), USERS_FACE_EXISTS.getMsg());
|
||||
} else {
|
||||
|
||||
// 变更business_file的content字段内容
|
||||
url = fileApi.updateBusinessFileContent(usersExtDO.getFaceImg(), 6L, name, importUser.getFaceFile());
|
||||
|
||||
//更新人脸图片
|
||||
updateDO.setId(usersExtDO.getId());
|
||||
updateDO.setFaceImg(url);
|
||||
usersExtMapper.insert(updateDO);
|
||||
usersExtMapper.updateById(updateDO);
|
||||
|
||||
respVO.getCreateUsernames().add(importUser.getUserName());
|
||||
}else {
|
||||
|
||||
if (!isUpdateSupport) {
|
||||
|
||||
respVO.getFailureUsernames().put(importUser.getUserName(), USERS_FACE_EXISTS.getMsg());
|
||||
}else {
|
||||
|
||||
// 变更business_file的content字段内容
|
||||
url = fileApi.updateBusinessFileContent(usersExtDO.getFaceImg(), 6L, name, content);
|
||||
|
||||
//更新人脸图片
|
||||
updateDO.setId(usersExtDO.getId());
|
||||
updateDO.setFaceImg(url);
|
||||
usersExtMapper.updateById(updateDO);
|
||||
|
||||
respVO.getUpdateUsernames().add(importUser.getUserName());
|
||||
}
|
||||
respVO.getUpdateUsernames().add(importUser.getUserName());
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
<select id="selectAttendancePage" resultType="cn.iocoder.yudao.module.system.controller.admin.equipment.vo.attendancemachine.AttendanceMachineRespVO">
|
||||
SELECT
|
||||
b.id,
|
||||
a.id AS assetsId,
|
||||
a.assets_no AS assetsNo,
|
||||
b.device_no AS deviceNo,
|
||||
c.dept_id AS deptId,
|
||||
@ -28,10 +29,17 @@
|
||||
<if test="reqVO.deviceName != null and reqVO.deviceName != ''">
|
||||
AND b.device_name LIKE CONCAT('%', #{reqVO.deviceName}, '%')
|
||||
</if>
|
||||
<!-- <if test="deviceNos != null and deviceNos.size() > 0">-->
|
||||
<!-- AND b.device_no IN-->
|
||||
<!-- <foreach collection="deviceNos" item="deviceNos" open="(" separator="," close=")">-->
|
||||
<!-- #{deviceNos}-->
|
||||
<!-- </foreach>-->
|
||||
<!-- </if>-->
|
||||
</select>
|
||||
|
||||
<select id="selectAttendanceByAssetsNo" resultType="cn.iocoder.yudao.module.system.controller.admin.equipment.vo.attendancemachine.AttendanceMachineRespVO">
|
||||
SELECT
|
||||
a.id AS id,
|
||||
a.assets_id AS assetsId,
|
||||
a.device_no AS deviceNo,
|
||||
b.dept_id AS deptId,
|
||||
@ -49,7 +57,7 @@
|
||||
a.id AS id,
|
||||
a.user_id AS userId,
|
||||
d.nickname AS userName,
|
||||
b.dept_id AS dpetId,
|
||||
b.dept_id AS deptId,
|
||||
a.face_img AS faceImg,
|
||||
c.create_time AS createTime
|
||||
FROM
|
||||
@ -57,10 +65,10 @@
|
||||
LEFT JOIN kq_distribute_record c ON c.device_no = b.device_no AND c.user_id = a.user_id
|
||||
LEFT JOIN system_users d ON a.user_id = d.id
|
||||
WHERE
|
||||
b.device_no LIKE CONCAT( '%', a.attendance_machine_nos '%' )
|
||||
a.attendance_machine_nos LIKE CONCAT( '%', b.device_no, '%' )
|
||||
AND b.device_no = #{reqVO.deviceNo}
|
||||
<if test="reqVO.userName != null and reqVO.userName != ''">
|
||||
AND d.nickname LIKE CONCAT( '%', #{reqVO.userName} '%' )
|
||||
AND d.nickname LIKE CONCAT( '%', #{reqVO.userName}, '%' )
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user