考勤机下发管理

This commit is contained in:
方亮 2025-12-01 18:11:01 +08:00
parent 7231d3036a
commit 56f46c4570
4 changed files with 107 additions and 78 deletions

View File

@ -61,14 +61,22 @@ public class KqCmdBean {
private String teamName;
private String workerId;
private String[] workerIds;
private String workerName;
private String phone;
private String createTime;
public KqCmdBean(String deviceCode, String subName, String teamName) {
public KqCmdBean() {
}
public KqCmdBean(String deviceCode, String subName, String teamName,Integer proId, Integer subId, Integer teamId) {
this.deviceCode = deviceCode;
this.subName = subName;
this.teamName = teamName;
this.proId = proId;
this.subId = subId;
this.teamId = teamId;
}
}

View File

@ -12,6 +12,9 @@ public class TreeNode {
private String id;
private String name;
private String type;
private Integer proId;
private Integer subId;
private Integer teamId;
private List<TreeNode> children;
public TreeNode(String id, String name, String type) {
@ -21,5 +24,15 @@ public class TreeNode {
this.children = new ArrayList<>();
}
public TreeNode(String id, String name, String type,Integer proId, Integer subId, Integer teamId) {
this.id = id;
this.name = name;
this.type = type;
this.proId = proId;
this.subId = subId;
this.teamId = teamId;
this.children = new ArrayList<>();
}
public void addChild(TreeNode child) { this.children.add(child); }
}

View File

@ -4,15 +4,12 @@ import com.bonus.bmw.domain.vo.KqCmdBean;
import com.bonus.bmw.domain.vo.TreeNode;
import com.bonus.bmw.mapper.KqCmdMapper;
import com.bonus.bmw.service.KqCmdService;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Service
public class KqCmdServiceImpl implements KqCmdService {
@ -34,8 +31,12 @@ public class KqCmdServiceImpl implements KqCmdService {
@Override
public AjaxResult refreshDevice(KqCmdBean o) {
// urkSendServiceImpl.refreshDevice(o.getDeviceCode(),o.getProId(),o.getSupId(),o.getTeamId());
return null;
try {
urkSendServiceImpl.getDevUserList(o.getDeviceCode());
} catch (Exception e) {
throw new RuntimeException(e);
}
return AjaxResult.success();
}
@Override
@ -47,8 +48,12 @@ public class KqCmdServiceImpl implements KqCmdService {
@Override
public AjaxResult restartDevice(KqCmdBean o) {
// urkSendServiceImpl.refreshDevice(o.getDeviceCode(),o.getProId(),o.getSupId(),o.getTeamId());
return null;
try {
urkSendServiceImpl.reloadDevice(o.getDeviceCode());
} catch (Exception e) {
throw new RuntimeException(e);
}
return AjaxResult.success();
}
@Override
@ -60,16 +65,23 @@ public class KqCmdServiceImpl implements KqCmdService {
@Override
public AjaxResult pushWorkerByDevice(KqCmdBean o) {
//先删除在下发
//deviceCode,workerId(可以多个),pro_id
// urkSendServiceImpl.refreshDevice(o.getDeviceCode(),o.getProId(),o.getSupId(),o.getTeamId());
return null;
try {
urkSendServiceImpl.delDevUser(o.getDeviceCode(), Arrays.asList(o.getWorkerIds()));
urkSendServiceImpl.addUserList(o.getDeviceCode(), Arrays.asList(o.getWorkerIds()));
} catch (Exception e) {
throw new RuntimeException(e);
}
return AjaxResult.success();
}
@Override
public AjaxResult delWorkerByDevice(KqCmdBean o) {
//deviceCode,workerId(可以多个),pro_id
// urkSendServiceImpl.refreshDevice(o.getDeviceCode(),o.getProId(),o.getSupId(),o.getTeamId());
return null;
try {
urkSendServiceImpl.delDevUser(o.getDeviceCode(), Arrays.asList(o.getWorkerIds()));
} catch (Exception e) {
throw new RuntimeException(e);
}
return AjaxResult.success();
}
@Override
@ -89,10 +101,7 @@ public class KqCmdServiceImpl implements KqCmdService {
// 遍历数据建立映射关系
for (KqCmdBean item : data) {
String proName = item.getProName();
String deviceCode = item.getDeviceCode();
String subName = item.getSubName();
String teamName = item.getTeamName();
proToDeviceMap.computeIfAbsent(proName, k -> new ArrayList<>()).add(new KqCmdBean(deviceCode, subName, teamName));
proToDeviceMap.computeIfAbsent(proName, k -> new ArrayList<>()).add(new KqCmdBean(item.getDeviceCode(), item.getSubName(), item.getTeamName(), item.getProId(), item.getSubId(), item.getTeamId()));
}
// 构建树形结构
List<TreeNode> result = new ArrayList<>();
@ -103,15 +112,7 @@ public class KqCmdServiceImpl implements KqCmdService {
TreeNode projectNode = new TreeNode(proName, "工程-" + proName, "project");
// 为每个设备码创建子节点
for (KqCmdBean bean : deviceCodes) {
String deviceCode = bean.getDeviceCode();
String deviceName = "设备-" + deviceCode;
if(StringUtils.isNotEmpty(bean.getSubName())){
deviceName += "|分包-" + bean.getSubName();
if(StringUtils.isNotEmpty(bean.getTeamName())){
deviceName += "|班组-" + bean.getTeamName();
}
}
TreeNode deviceNode = new TreeNode(deviceCode, deviceName, "device");
TreeNode deviceNode = getTreeNode(bean);
projectNode.addChild(deviceNode);
}
result.add(projectNode);
@ -119,4 +120,17 @@ public class KqCmdServiceImpl implements KqCmdService {
return result;
}
@NotNull
private static TreeNode getTreeNode(KqCmdBean bean) {
String deviceCode = bean.getDeviceCode();
String deviceName = "设备-" + deviceCode;
if(bean.getSubId()!= null && bean.getSubId() !=0){
deviceName += "|分包-" + bean.getSubName();
if(bean.getTeamId()!= null && bean.getTeamId() !=0){
deviceName += "|班组-" + bean.getTeamName();
}
}
return new TreeNode(deviceCode, deviceName, "device", bean.getProId(), bean.getSubId(), bean.getTeamId());
}
}

View File

@ -1,63 +1,57 @@
<?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="com.bonus.bmw.mapper.KqCmdMapper">
<resultMap id="BaseResultMap" type="com.bonus.bmw.domain.vo.KqCmdBean">
<result column="device_code" property="deviceCode"/>
<result column="phone" property="phone"/>
<result column="worker_id" property="workerId"/>
<result column="worker_name" property="workerName"/>
<result column="pro_id" property="proId"/>
<result column="workerName" property="workerName"/>
<result column="cmd_code" property="cmdCode"/>
<result column="cmd_param" property="cmdParam"/>
<result column="create_time" property="createTime"/>
<result column="msg" property="msg"/>
<result column="trans_status" property="transStatus"/>
</resultMap>
<select id="getProKqjTree" resultType="com.bonus.bmw.domain.vo.KqCmdBean">
select
pp.pro_name,device_code,ps.sub_name,pst.team_name,pp.id as proId,ps.id as subId,pst.id as teamId
from pm_att_device pad
inner join pm_project pp on pad.pro_id = pp.id
left join pm_sub ps on ps.id = pad.sub_id
left join pm_sub_team pst on pst.id = pad.team_id
</select>
<select id="getUserByDeviceId" resultMap="BaseResultMap">
select
user_id as worker_id,
user_name as worker_name,
user_phone as phone,
dev_code as device_code
from kq_user_list
where dev_code = #{deviceCode}
<select id="getUserByDeviceId" resultType="com.bonus.bmw.domain.vo.KqCmdBean">
select
user_id as worker_id,
user_name as worker_name,
user_phone as phone,
dev_code as device_code
from kq_user_list
where dev_code = #{deviceCode}
</select>
<select id="getProDeviceWorker" resultMap="BaseResultMap">
select
<select id="getProDeviceWorker" resultType="com.bonus.bmw.domain.vo.KqCmdBean">
select
bwem.worker_id,
pw.name as workerName,
bwem.pro_id
from bm_worker_ein_msg bwem
left join pm_worker pw on pw.id = bwem.worker_id
where pro_id = #{proId}
<if test="teamId != null">
and team_id = #{teamId}
</if>
<if test="subId != null">
and sub_id = #{subId}
</if>
</select>
from bm_worker_ein_msg bwem
left join pm_worker pw on pw.id = bwem.worker_id
where pro_id = #{proId}
<if test="teamId != null">
and team_id = #{teamId}
</if>
<if test="subId != null">
and sub_id = #{subId}
</if>
</select>
<select id="getDeviceTask" resultMap="BaseResultMap">
<select id="getDeviceTask" resultType="com.bonus.bmw.domain.vo.KqCmdBean">
select
cmd_code,
cmd_param,
trans_status,
create_time,
msg
cmd_code,
cmd_param,
trans_status,
create_time,
msg
from kq_cmd_task
where device_code = #{deviceCode}
</select>
</select>
<select id="getProKqjTree" resultType="com.bonus.bmw.domain.vo.KqCmdBean">
SELECT
pp.id as pro_id,
pp.pro_name,
pad.device_code,
ps.id as sub_id,
ps.sub_name,
pst.id as team_id
,pst.team_name
FROM
pm_att_device pad
INNER JOIN pm_project pp ON pad.pro_id = pp.id
LEFT JOIN pm_sub ps ON ps.id = pad.sub_id
LEFT JOIN pm_sub_team pst ON pst.id = pad.team_id
</select>
</mapper>