update code

dev_xd
lijun 2024-10-13 15:10:30 +08:00
parent 3fe8f4c6c3
commit 098dda6c65
13 changed files with 583 additions and 78 deletions

View File

@ -103,6 +103,25 @@ public class AttendanceUbiDevice extends BaseEntity
private String compName;
private String projectName;
private int direction;
private String channel;
public int getDirection() {
return direction;
}
public void setDirection(int direction) {
this.direction = direction;
}
public String getChannel() {
return channel;
}
public void setChannel(String channel) {
this.channel = channel;
}
public String getCompName() {
return compName;
}

View File

@ -58,4 +58,6 @@ public interface AttendanceUbiDeviceMapper
* @return
*/
public int deleteAttendanceUbiDeviceByIds(Long[] ids);
public AttendanceUbiDevice selectAttendanceUbiDeviceByNo(String no);
}

View File

@ -27,6 +27,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="state" column="state" />
<result property="remark" column="remark" />
<result property="isDel" column="is_del" />
<result property="direction" column="direction" />
<result property="channel" column="channel" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
@ -38,6 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectAttendanceUbiDeviceVo">
select ud.id, ud.com_id, ud.project_id, ud.name, ud.tag, ud.scene_guid, ud.source, ud.device_no, ud.addition, ud.bind_default_scene, ud.force_empty_device,
ud.direction,ud.channel,
ud.device_model, ud.device_state, ud.rec_type, ud.online_state, ud.version_no, ud.last_active_time, ud.has_register, ud.state, ud.remark, ud.is_del,
ud.create_by, ud.create_time, ud.update_by, ud.update_time ,dp.`dept_name` comp_name,pp.`project_name`,dic.`dict_label` souce_name
from attendance_ubi_device ud
@ -75,7 +78,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectAttendanceUbiDeviceVo"/>
where ud.id = #{id}
</select>
<select id="selectAttendanceUbiDeviceByNo" parameterType="String" resultMap="AttendanceUbiDeviceResult">
<include refid="selectAttendanceUbiDeviceVo"/>
where ud.device_no = #{no}
</select>
<insert id="insertAttendanceUbiDevice" parameterType="AttendanceUbiDevice" useGeneratedKeys="true" keyProperty="id">
insert into attendance_ubi_device
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -101,6 +108,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="state != null">state,</if>
<if test="remark != null">remark,</if>
<if test="isDel != null">is_del,</if>
<if test="direction != null">direction,</if>
<if test="channel != null">channel,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
@ -129,6 +138,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="state != null">#{state},</if>
<if test="remark != null">#{remark},</if>
<if test="isDel != null">#{isDel},</if>
<if test="direction != null">#{direction},</if>
<if test="channel != null">#{channel},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
@ -160,6 +171,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="state != null">state = #{state},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="direction != null">direction = #{direction},</if>
<if test="channel != null">channel = #{channel},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>

View File

@ -24,13 +24,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="useStatus" column="use_status" />
<result property="subStep" column="sub_step" />
<result property="illnessStatus" column="illness_status" />
<result property="admitGuid" column="admitGuid"/>
<result property="supIllnessStatus" column="sup_illness_status" />
<result property="isDel" column="is_del" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="admitGuid" column="admitGuid"/>
<result property="remark" column="remark" />
<association property="user" javaType="com.yanzhu.system.api.domain.SysUser" resultMap="ProSysUserResult"></association>
</resultMap>
@ -40,6 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="userType" column="user_type" />
<result property="cardType" column="card_type" />
<result property="cardCode" column="card_code" />
<result property="admitGuid" column="usAdmitGuid"/>
<result property="userPicture" column="user_picture" />
<result property="cardImgPos" column="card_img_pos" />
<result property="cardImgInv" column="card_img_inv" />
@ -58,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT pi.project_name, psu.id, psu.com_id, psu.project_id, psu.sub_dept_id, psu.sub_dept_type, psu.sub_dept_name, psu.user_id, psu.sub_dept_group,
psu.sub_dept_group_name, psu.craft_type, psu.craft_post, psu.edu_status, psu.edu_file_path, psu.edu_sign_path, psu.edu_date, psu.approve_status,
psu.use_status, psu.sub_step, psu.illness_status, psu.sup_illness_status, psu.is_del, psu.create_by, psu.create_time, psu.update_by, psu.update_time,
psu.remark,su.`user_name`,su.`nick_name`,su.`user_type`,su.`card_type`,su.`card_code`,
psu.remark,su.`user_name`,su.`nick_name`,su.`user_type`,su.`card_type`,su.`card_code`,su.admitGuid,su.admitGuid usAdmitGuid,
su.`user_picture`, su.`card_img_inv`,su.`card_img_pos`,su.`user_infos`,su.`email`,su.`phonenumber`,su.`sex`,su.`avatar`,su.`login_ip`,su.`login_date`
FROM pro_project_info_subdepts_users psu
LEFT JOIN sys_user su ON psu.user_id=su.user_id

View File

@ -2,10 +2,14 @@ package com.yanzhu.manage.controller;
import com.alibaba.fastjson2.JSONObject;
import com.yanzhu.common.core.utils.DateUtils;
import com.yanzhu.common.core.utils.StringUtils;
import com.yanzhu.common.core.web.domain.AjaxResult;
import com.yanzhu.manage.domain.AttendanceUbiData;
import com.yanzhu.manage.domain.AttendanceUbiDevice;
import com.yanzhu.manage.domain.ProProjectInfoSubdeptsUsers;
import com.yanzhu.manage.service.IAttendanceUbiDataService;
import com.yanzhu.manage.service.IAttendanceUbiDeviceService;
import com.yanzhu.manage.service.IProProjectInfoDeptsService;
import com.yanzhu.manage.service.IProProjectInfoSubdeptsUsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -24,6 +28,9 @@ public class UniCallBackController {
@Autowired
private IProProjectInfoSubdeptsUsersService proProjectInfoSubdeptsUsersService;
@Autowired
private IAttendanceUbiDeviceService attendanceUbiDeviceService;
/**
*
* @param jo
@ -31,11 +38,71 @@ public class UniCallBackController {
*/
@PostMapping("/recognize")
public AjaxResult recognize(HttpServletRequest request){
String eventCode=request.getParameter("eventCode");
String eventGuid=request.getParameter("eventGuid");
String data=request.getParameter("eventMsg");
switch (eventCode){
case "101004"://上报识别记录
return doAddAttendance(eventGuid,data);
case "100002"://设备上线
return doDeviceOnLine(eventGuid,data);
case "100003"://设备下线
return doDeviceOffLine(eventGuid,data);
}
return AjaxResult.success();
}
/**
* 线
* @param eventGuid
* @param data
* @return
*/
private AjaxResult doDeviceOnLine(String eventGuid,String data){
JSONObject json=JSONObject.parseObject(data);
String deviceNo= json.getString("deviceNo");
if(StringUtils.isNotEmpty(deviceNo)){
AttendanceUbiDevice device=attendanceUbiDeviceService.selectAttendanceUbiDeviceByNo(deviceNo);
if(device!=null){
device.setOnlineState(1l);
attendanceUbiDeviceService.updateAttendanceUbiDevice(device);
return AjaxResult.success("同步成功");
}
}
return AjaxResult.error("同步失败");
}
/**
* 线
* @param eventGuid
* @param data
* @return
*/
private AjaxResult doDeviceOffLine(String eventGuid,String data){
JSONObject json=JSONObject.parseObject(data);
String deviceNo= json.getString("deviceNo");
if(StringUtils.isNotEmpty(deviceNo)){
AttendanceUbiDevice device=attendanceUbiDeviceService.selectAttendanceUbiDeviceByNo(deviceNo);
if(device!=null){
device.setOnlineState(0l);
attendanceUbiDeviceService.updateAttendanceUbiDevice(device);
return AjaxResult.success("同步成功");
}
}
return AjaxResult.error("同步失败");
}
/**
*
* @param eventGuid
* @param data
* @return
*/
private AjaxResult doAddAttendance(String eventGuid,String data){
JSONObject json=JSONObject.parseObject(data);
int type=json.getInteger("type");
if(type==1){// 人员比对结果,1:比对成功 2:比对失败
String eventGuid=request.getParameter("eventGuid");
String admitGuid=json.getString("admitGuid");
long projectId=Long.parseLong(json.getString("cardNo"));
String deviceNo=json.getString("deviceNo");
@ -45,6 +112,10 @@ public class UniCallBackController {
where.setAdmitGuid(admitGuid);
where.setInTime(showTime);
List<AttendanceUbiData> list= attendanceUbiDataService.queryAttendaceInfo(where);
AttendanceUbiDevice device=attendanceUbiDeviceService.selectAttendanceUbiDeviceByNo(deviceNo);
if(device==null){
return AjaxResult.error("没有查询到设备No");
}
if(list.size()==0){
//增加操作
ProProjectInfoSubdeptsUsers userWhere=new ProProjectInfoSubdeptsUsers();
@ -67,9 +138,15 @@ public class UniCallBackController {
addData.setSubDeptGroupName(proUser.getSubDeptGroupName());
addData.setCraftPost(proUser.getCraftPost());
addData.setCraftType(proUser.getCraftType());
addData.setInTime(showTime);
addData.setInData(data);
addData.setInPhoto(filePath);
if(device.getDirection()==0) {
addData.setInTime(showTime);
addData.setInData(data);
addData.setInPhoto(filePath);
}else{
addData.setOutPhoto(filePath);
addData.setOutData(data);
addData.setOutTime(showTime);
}
addData.setDeviceNo(deviceNo);
attendanceUbiDataService.insertAttendanceUbiData(addData);
return AjaxResult.success("增加成功");
@ -83,30 +160,23 @@ public class UniCallBackController {
}
Date dt1=upData.getInTime();
Date dt2=upData.getOutTime();
if(dt1!=null && dt2!=null){
if(showTime.getTime()<dt1.getTime()){
if(device.getDirection()==0){
//入
if(dt1==null || showTime.getTime()<dt1.getTime()){
upData.setInPhoto(filePath);
upData.setInData(data);
upData.setInTime(showTime);
}
if(showTime.getTime()>dt2.getTime()){
upData.setOutData(data);
upData.setOutPhoto(filePath);
upData.setOutTime(showTime);
}else{
return AjaxResult.success();
}
}else{
if(showTime.getTime()<dt1.getTime()){
upData.setOutTime(upData.getInTime());
upData.setOutData(upData.getInData());
upData.setOutPhoto(upData.getInPhoto());
upData.setInPhoto(filePath);
upData.setInData(data);
upData.setInTime(showTime);
}
if(showTime.getTime()>dt1.getTime()){
//出
if(dt2==null || showTime.getTime()>dt2.getTime()){
upData.setOutData(data);
upData.setOutPhoto(filePath);
upData.setOutTime(showTime);
}else {
return AjaxResult.success();
}
}
attendanceUbiDataService.updateAttendanceUbiData(upData);
@ -116,44 +186,4 @@ public class UniCallBackController {
}
return AjaxResult.error("同步失败");
}
/**
*
* @param jo
* @return
*/
@PostMapping("/auth")
public AjaxResult auth(@RequestBody JSONObject jo){
return AjaxResult.success("--ok--");
}
/**
*
* @param jo
* @return
*/
@PostMapping("/unauth")
public AjaxResult unauth(@RequestBody JSONObject jo){
return AjaxResult.success("--ok--");
}
/**
*
* @param jo
* @return
*/
@PostMapping("/alarm")
public AjaxResult alarm(@RequestBody JSONObject jo){
return AjaxResult.success("--ok--");
}
/**
*
* @param jo
* @return
*/
@PostMapping("/deviceDelete")
public AjaxResult deviceDelete(@RequestBody JSONObject jo){
return AjaxResult.success("--ok--");
}
}

View File

@ -18,7 +18,7 @@ public interface IAttendanceUbiDeviceService
* @return
*/
public AttendanceUbiDevice selectAttendanceUbiDeviceById(Long id);
public AttendanceUbiDevice selectAttendanceUbiDeviceByNo(String no);
/**
*
*

View File

@ -125,7 +125,7 @@ public interface IUniService {
* @param data
* @return
*/
public JSONObject authDeviceRevoke(JSONObject data);
public String authDeviceRevoke(JSONObject data);
/**
@ -150,4 +150,6 @@ public interface IUniService {
* @return
*/
public Long syncUniDeviceUser(Long deviceId,Long projectId);
public long syncUniDeviceDelete(Long[] ids);
}

View File

@ -37,6 +37,11 @@ public class AttendanceUbiDeviceServiceImpl implements IAttendanceUbiDeviceServi
return attendanceUbiDeviceMapper.selectAttendanceUbiDeviceById(id);
}
@Override
public AttendanceUbiDevice selectAttendanceUbiDeviceByNo(String no) {
return attendanceUbiDeviceMapper.selectAttendanceUbiDeviceByNo(no);
}
/**
*
*
@ -91,6 +96,7 @@ public class AttendanceUbiDeviceServiceImpl implements IAttendanceUbiDeviceServi
@Override
public int deleteAttendanceUbiDeviceByIds(Long[] ids)
{
uniService.syncUniDeviceDelete(ids);
return attendanceUbiDeviceMapper.deleteAttendanceUbiDeviceByIds(ids);
}

View File

@ -236,6 +236,21 @@ public class UniServiceImpl implements IUniService{
@Override
public JSONObject deviceDelete(JSONObject data) {
long projectId=data.getLong("projectId");
Request request=new Request.Builder()
.url(UniUtils.DEVICEDELETE)
.post(UniUtils.toJsonBody(data))
.headers(UniUtils.setHeaderParams(auth(projectId)))
.build();
String res=UniUtils.getResult(request);
JSONObject jo=JSON.parseObject(res);
if(jo.getLong("result").intValue()==1){
return jo.getJSONObject("data");
}
if("token is illegal".equals(jo.getString("msg"))){
clearAuthCache(projectId);
return deviceDelete(data);
}
return null;
}
@ -285,8 +300,23 @@ public class UniServiceImpl implements IUniService{
}
@Override
public JSONObject authDeviceRevoke(JSONObject data) {
return null;
public String authDeviceRevoke(JSONObject data) {
long projectId=data.getLong("projectId");
Request request=new Request.Builder()
.url(UniUtils.AUTHDEVICEREVOKE)
.post(UniUtils.toJsonBody(data))
.headers(UniUtils.setHeaderParams(auth(projectId)))
.build();
String res=UniUtils.getResult(request);
JSONObject jo=JSON.parseObject(res);
if(jo.getLong("result").intValue()==1){
return "success";
}
if("token is illegal".equals(jo.getString("msg"))){
clearAuthCache(projectId);
return authDeviceRevoke(data);
}
return jo.getString("msg");
}
@Override
public Long syncUniDeviceUser(Long deviceId,Long projectId){
@ -299,8 +329,7 @@ public class UniServiceImpl implements IUniService{
jo.put("deviceNo",device.getDeviceNo());
List<String> admitGuidList=new ArrayList<>();
for(ProProjectInfoSubdeptsUsers u :userList){
JSONObject json=JSON.parseObject(u.getUser().getUserInfos());
String admitGuid=json.getString("admitGuid");
String admitGuid=u.getAdmitGuid();
if(StringUtils.isNotEmpty(admitGuid)){
admitGuidList.add(admitGuid);
}
@ -318,6 +347,57 @@ public class UniServiceImpl implements IUniService{
}
return 1l;
}
/**
* 1. 2.
* @param ids
* @return
*/
@Override
public long syncUniDeviceDelete(Long[] ids) {
long cnt=0;
for(Long id :ids){
cnt+=deletDevice(id);
}
return cnt;
}
private Long deletDevice(Long id) {
AttendanceUbiDevice device=attendanceUbiDeviceMapper.selectAttendanceUbiDeviceById(id);
if(device==null){
return 0l;
}
Long projectId=device.getProjectId();
ProProjectInfoSubdeptsUsers userWhere=new ProProjectInfoSubdeptsUsers();
userWhere.setProjectId(projectId);
List<ProProjectInfoSubdeptsUsers> userList=proProjectInfoSubdeptsUsersMapper.selectProProjectInfoSubdeptsUsersList(userWhere);
JSONObject jo=new JSONObject();
jo.put("projectId",projectId);
jo.put("deviceNo",device.getDeviceNo());
jo.put("source",device.getSource());
List<String> admitGuidList=new ArrayList<>();
for(ProProjectInfoSubdeptsUsers u :userList){
String admitGuid=u.getAdmitGuid();
if(StringUtils.isNotEmpty(admitGuid)){
admitGuidList.add(admitGuid);
}
}
for(int i=0;i<admitGuidList.size();i+=50){
String admitGuids="";
for(int j=0;j<50 && j+i<admitGuidList.size();j++){
admitGuids+=admitGuidList.get((i+j))+",";
}
if(admitGuids.length()>0){
admitGuids=admitGuids.substring(0,admitGuids.length()-1);
}
jo.put("admitGuids",admitGuids);
authDeviceRevoke(jo);
}
deviceDelete(jo);
return 1l;
}
@Override
public Long syncUniDevice(Long deviceId,Long projectId){
AttendanceUbiDevice device=attendanceUbiDeviceMapper.selectAttendanceUbiDeviceById(deviceId);
@ -366,6 +446,7 @@ public class UniServiceImpl implements IUniService{
if(StringUtils.isEmpty(admitGuid)){
//未注册人员
admitGuid=admitCreate(userJo);
user.setAdmitGuid(admitGuid);
jo.put("admitGuid",admitGuid);
hasUpdate=true;
}else{

View File

@ -25,6 +25,7 @@ public class UniUtils {
public static final String AUTHDEVICE=UNIBASE+"v2/auth/device";
public static final String AUTHDEVICEUPDATE=UNIBASE+"v2/auth/device/update";
public static final String AUTHDEVICEREVOKE=UNIBASE+"v2/auth/device/revoke";
public static String getAuthUrl(String projectGuid){
return UNIBASE+ "/v1/"+projectGuid+"/auth";
}

View File

@ -55,14 +55,29 @@
<el-table-column label="NO." align="center" prop="id" />
<el-table-column label="所属公司" align="center" prop="compName" />
<el-table-column label="所属项目" align="center" prop="projectName" />
<el-table-column label="考勤厂商" align="center" prop="vendorsName" />
<el-table-column label="考勤厂商" align="center" prop="vendorsName">
<template #default="scope">
<span style="color: var(--el-color-warning);">{{scope.row.vendorsName }}</span>
</template>
</el-table-column>
<el-table-column label="实名制项目ID" align="center" prop="info.projectGuid" />
<el-table-column label="应用KEY" align="center" prop="info.AppKey" />
<el-table-column label="应用Secret" align="center" prop="info.AppSecret" />
<el-table-column label="是否启用" align="center" prop="enabled">
<template #default="scope">
<el-switch v-model="scope.row.enabled" :active-value="1" @change="doUpdateRow(scope.row)" :inactive-value="0"></el-switch>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="添加用户" align="center" prop="createBy" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="240">
<template #default="scope">
<el-button link type="primary" icon="Football" @click="handleDeviceList(scope.row)"
v-hasPermi="['manage:attendance_cfg:edit']">设备列表</el-button>
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
v-hasPermi="['manage:attendance_cfg:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
@ -97,7 +112,7 @@
<el-form-item label="应用Secret" prop="AppSecret">
<el-input v-model="form.AppSecret" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="项目Guid" prop="projectGuid">
<el-form-item label="项目ID" prop="projectGuid">
<el-input v-model="form.projectGuid" placeholder="请输入内容" />
</el-form-item>
</template>
@ -113,6 +128,7 @@
</div>
</template>
</el-dialog>
<ubiDeviceDrawer ref="deviceDrawer"></ubiDeviceDrawer>
</div>
</template>
@ -120,6 +136,7 @@
import { listAttendance_cfg, getAttendance_cfg, delAttendance_cfg, addAttendance_cfg, updateAttendance_cfg } from "@/api/manage/attendanceCfg";
import { findMyProjectList } from "@/api/publics";
import useUserStore from '@/store/modules/user'
import ubiDeviceDrawer from '../attendance_ubi_device/ubiDeviceDrawer.vue'
const userStore = useUserStore()
const { proxy } = getCurrentInstance();
const { attendance_vendors } = proxy.useDict('attendance_vendors');
@ -134,7 +151,7 @@ const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const deviceDrawer=ref();
const data = reactive({
form: {},
queryParams: {
@ -167,6 +184,11 @@ function doUpdateRow(row){
proxy.$modal.msgSuccess("修改成功");
});
}
/**设备列表 */
function handleDeviceList(row){
deviceDrawer.value.showDrawer(row);
}
/** 查询项目列表 */
function getProjectList() {
findMyProjectList({ pageNum: 1, pageSize: 100 }).then(response => {
@ -182,7 +204,10 @@ function getProjectList() {
function getList() {
loading.value = true;
listAttendance_cfg(queryParams.value).then(response => {
attendance_cfgList.value = response.rows;
attendance_cfgList.value = (response.rows||[]).map(it=>{
it.info=proxy.$tryToJson(it.vendorsParameter);
return it;
});
total.value = response.total;
loading.value = false;
});
@ -265,6 +290,8 @@ function handleUpdate(row) {
function submitForm() {
proxy.$refs["attendance_cfgRef"].validate(valid => {
if (valid) {
let objs=data.projects.filter(d=>d.id==form.value.projectId);
form.value.comId=objs.length>0?objs[0].comId:userStore.currentComId;
form.value.vendorsParameter = JSON.stringify({
AppKey: form.value.AppKey,
AppSecret: form.value.AppSecret,

View File

@ -0,0 +1,315 @@
<template>
<el-drawer v-model="data.show" title="人脸机设备管理" size="960px" class="ubi-device-drawer">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd"
v-hasPermi="['manage:attendance_ubi_device:add']">新增</el-button>
</el-col>
</el-row>
<el-table v-loading="loading" :data="attendance_ubi_deviceList" @selection-change="handleSelectionChange">
<el-table-column type="index" width="50" label="序号"/>
<el-table-column label="公司" align="center" prop="compName" v-if="1==2"/>
<el-table-column label="所属项目" align="center" prop="projectName" />
<el-table-column label="设备序列号" align="center" prop="deviceNo">
<template #default="scope"><span style="color: var(--el-color-warning);">{{scope.row.deviceNo}}</span></template>
</el-table-column>
<el-table-column label="通道编号" align="center" prop="channel" />
<el-table-column label="方向" align="center" prop="direction">
<template #default="scope">
{{ scope.row.direction==0?'进':'出' }}
</template>
</el-table-column>
<el-table-column label="用途" align="center" prop="tag" />
<el-table-column label="设备模式" align="center" prop="deviceModel" v-if="false" />
<el-table-column label="设备状态" align="center" prop="deviceState" v-if="false" >
<template #default="scope">
<span v-if="scope.row.deviceState == 1"></span>
<span v-if="scope.row.deviceState == 2"></span>
<span v-if="scope.row.deviceState == 3"></span>
</template>
</el-table-column>
<el-table-column label="比对模式" align="center" prop="recType" v-if="false" >
<template #default="scope">
<span v-if="scope.row.recType == 1"></span>
<span v-if="scope.row.recType == 2"></span>
</template>
</el-table-column>
<el-table-column label="在线状态" align="center" prop="onlineState">
<template #default="scope">
<span v-if="scope.row.onlineState == 1" style="color:green;">
<el-icon style="vertical-align: middle;"><SuccessFilled /></el-icon>
在线</span>
<span v-if="scope.row.onlineState == 2" style="color: red;">
<el-icon style="vertical-align: middle;"><CircleCloseFilled /></el-icon>线</span>
</template>
</el-table-column>
<el-table-column label="版本号" align="center" prop="versionNo" v-if="false" />
<el-table-column label="最后激活时间" align="center" prop="lastActiveTime" width="180" v-if="false" >
<template #default="scope">
<span>{{ parseTime(scope.row.lastActiveTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="注册状态" align="center" prop="hasRegister" v-if="false" >
<template #default="scope">
<span v-if="scope.row.onlineState == 1"></span>
<span v-else></span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150">
<template #default="scope">
<el-button link type="primary" icon="ChromeFilled" @click="handleAuth(scope.row)" v-if="1==2"
v-hasPermi="['manage:attendance_ubi_device:edit']">同步</el-button>
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
v-hasPermi="['manage:attendance_ubi_device:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
v-hasPermi="['manage:attendance_ubi_device:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改宇泛的设备信息对话框 -->
<el-dialog :title="title" v-model="open" width="600px" append-to-body :close-on-click-modal="false"
:close-on-press-escape="false">
<el-form ref="attendance_ubi_deviceRef" :model="form" :rules="rules" label-width="100px">
<el-form-item label="所属项目">
<el-tag effect="plain">{{ form.projectName }}</el-tag>
</el-form-item>
<el-form-item label="设备序列号" prop="deviceNo">
<el-input v-model="form.deviceNo" placeholder="请输入设备序列号" />
</el-form-item>
<el-form-item label="通道编号" prop="channel">
<el-input v-model="form.channel" placeholder="请输入通道编号" />
</el-form-item>
<el-form-item label="设备用途" prop="tag">
<el-select v-model="form.tag" placeholder="请选择设备用途" clearable>
<el-option v-for="(dict,idx) in ['','']" :key="idx" :label="dict"
:value="dict" />
</el-select>
</el-form-item>
<el-form-item label="方向设置" prop="direction">
<el-radio-group v-model="form.direction">
<el-radio :value="0" :label="0"></el-radio>
<el-radio :value="1" :label="1"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="设备来源" prop="source" v-if="1==2">
<el-select v-model="form.source" placeholder="请选择设备来源" clearable>
<el-option v-for="dict in ubi_device_source" :key="dict.value" :label="dict.label"
:value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark" v-if="false">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</el-drawer>
</template>
<script setup name="DeviceDrawer">
import { listAttendance_ubi_device, getAttendance_ubi_device, delAttendance_ubi_device, addAttendance_ubi_device, updateAttendance_ubi_device, authAttendance_ubi_device } from "@/api/manage/attendanceUbiDevice";
import { findMyProjectList } from "@/api/publics";
const { proxy } = getCurrentInstance();
const { ubi_device_source } = proxy.useDict('ubi_device_source');
const attendance_ubi_deviceList = ref([]);
const open = ref(false);
const loading = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
projectId: null,
},
rules: {
direction: [{ required: true, trigger: ['blur', 'change'], message: "请选择方向设置" }],
tag: [{ required: true, trigger: ['blur', 'change'], message: "请选择设备用途" }],
channel: [{ required: true, trigger: ['blur', 'change'], message: "请选择通道编号" }],
deviceNo: [{ required: true, trigger: ['blur', 'change'], message: "请输入设备序列号" }],
},
projects: [],
currentProId: '',
mode: '',
show: false,
row: null
})
const { queryParams, form, rules } = toRefs(data);
/**
* 设备人员同步
*/
function handleAuth(row){
authAttendance_ubi_device(row).then(d=>{
if(d.code==200){
proxy.$modal.msgSuccess("同步成功!");
}else{
proxy.$modal.msgError("同步失败!");
}
});
}
/** 查询宇泛的设备信息列表 */
function getList() {
queryParams.value.projectId=data.row.projectId
loading.value = true;
listAttendance_ubi_device(queryParams.value).then(response => {
attendance_ubi_deviceList.value = response.rows;
total.value = response.total;
loading.value = false;
});
}
//
function cancel() {
open.value = false;
reset();
}
//
function reset() {
form.value = {
id: null,
comId: null,
projectId: null,
name: null,
tag: '考勤',
direction:0,
channel:'',
sceneGuid: "",
source: null,
deviceNo: null,
addition: null,
bindDefaultScene: null,
forceEmptyDevice: null,
password: null,
deviceModel: null,
deviceState: null,
recType: null,
onlineState: null,
versionNo: null,
lastActiveTime: null,
hasRegister: null,
state: null,
remark: null,
isDel: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null
};
proxy.resetForm("attendance_ubi_deviceRef");
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1;
getList();
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm("queryRef");
handleQuery();
}
//
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
}
/** 新增按钮操作 */
function handleAdd() {
reset();
form.value.projectId = data.row.projectId;
form.value.projectName = data.row.projectName;
form.value.source=ubi_device_source.value[0].value;
open.value = true;
title.value = "添加宇泛的设备信息";
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset();
const _id = row.id || ids.value
getAttendance_ubi_device(_id).then(response => {
form.value = response.data;
open.value = true;
title.value = "修改宇泛的设备信息";
});
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["attendance_ubi_deviceRef"].validate(valid => {
if (valid) {
form.value.comId=data.row.comId;
form.value.name=form.value.deviceNo;
if (form.value.id != null) {
updateAttendance_ubi_device(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
addAttendance_ubi_device(form.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
open.value = false;
getList();
});
}
}
});
}
/** 删除按钮操作 */
function handleDelete(row) {
const _ids = row.id || ids.value;
proxy.$modal.confirm('是否确认删除宇泛的设备信息编号为"' + _ids + '"的数据项?').then(function () {
return delAttendance_ubi_device(_ids);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => { });
}
function showDrawer(row) {
data.row = row;
data.show = true;
getList();
}
defineExpose({
showDrawer
})
</script>
<style lang="scss">
.ubi-device-drawer{
.el-drawer__header{
margin-bottom: 0px;
}
}</style>

View File

@ -41,19 +41,27 @@
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd"
v-hasPermi="['manage:proProjectInfoSubdeptsUsers:add']">新增</el-button>
v-hasPermi="['manage:proProjectInfoSubdeptsUsers:add']">新增人员</el-button>
</el-col>
<el-col :span="1.5">
<el-col :span="1.5" v-if="false">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
v-hasPermi="['manage:proProjectInfoSubdeptsUsers:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-col :span="1.5" v-if="false">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
v-hasPermi="['manage:proProjectInfoSubdeptsUsers:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport"
v-hasPermi="['manage:proProjectInfoSubdeptsUsers:export']">导出</el-button>
v-hasPermi="['manage:proProjectInfoSubdeptsUsers:export']">导出花名册</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Download" @click="handleExport"
v-hasPermi="['manage:proProjectInfoSubdeptsUsers:export']">批量离场</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Download" @click="handleExport"
v-hasPermi="['manage:proProjectInfoSubdeptsUsers:export']">批量入场</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>