考勤机下发管理
This commit is contained in:
parent
7231d3036a
commit
56f46c4570
|
|
@ -61,14 +61,22 @@ public class KqCmdBean {
|
||||||
private String teamName;
|
private String teamName;
|
||||||
|
|
||||||
private String workerId;
|
private String workerId;
|
||||||
|
|
||||||
|
private String[] workerIds;
|
||||||
private String workerName;
|
private String workerName;
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
private String createTime;
|
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.deviceCode = deviceCode;
|
||||||
this.subName = subName;
|
this.subName = subName;
|
||||||
this.teamName = teamName;
|
this.teamName = teamName;
|
||||||
|
this.proId = proId;
|
||||||
|
this.subId = subId;
|
||||||
|
this.teamId = teamId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ public class TreeNode {
|
||||||
private String id;
|
private String id;
|
||||||
private String name;
|
private String name;
|
||||||
private String type;
|
private String type;
|
||||||
|
private Integer proId;
|
||||||
|
private Integer subId;
|
||||||
|
private Integer teamId;
|
||||||
private List<TreeNode> children;
|
private List<TreeNode> children;
|
||||||
|
|
||||||
public TreeNode(String id, String name, String type) {
|
public TreeNode(String id, String name, String type) {
|
||||||
|
|
@ -21,5 +24,15 @@ public class TreeNode {
|
||||||
this.children = new ArrayList<>();
|
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); }
|
public void addChild(TreeNode child) { this.children.add(child); }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,12 @@ import com.bonus.bmw.domain.vo.KqCmdBean;
|
||||||
import com.bonus.bmw.domain.vo.TreeNode;
|
import com.bonus.bmw.domain.vo.TreeNode;
|
||||||
import com.bonus.bmw.mapper.KqCmdMapper;
|
import com.bonus.bmw.mapper.KqCmdMapper;
|
||||||
import com.bonus.bmw.service.KqCmdService;
|
import com.bonus.bmw.service.KqCmdService;
|
||||||
import com.bonus.common.core.utils.StringUtils;
|
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class KqCmdServiceImpl implements KqCmdService {
|
public class KqCmdServiceImpl implements KqCmdService {
|
||||||
|
|
@ -34,8 +31,12 @@ public class KqCmdServiceImpl implements KqCmdService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult refreshDevice(KqCmdBean o) {
|
public AjaxResult refreshDevice(KqCmdBean o) {
|
||||||
// urkSendServiceImpl.refreshDevice(o.getDeviceCode(),o.getProId(),o.getSupId(),o.getTeamId());
|
try {
|
||||||
return null;
|
urkSendServiceImpl.getDevUserList(o.getDeviceCode());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -47,8 +48,12 @@ public class KqCmdServiceImpl implements KqCmdService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult restartDevice(KqCmdBean o) {
|
public AjaxResult restartDevice(KqCmdBean o) {
|
||||||
// urkSendServiceImpl.refreshDevice(o.getDeviceCode(),o.getProId(),o.getSupId(),o.getTeamId());
|
try {
|
||||||
return null;
|
urkSendServiceImpl.reloadDevice(o.getDeviceCode());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -60,16 +65,23 @@ public class KqCmdServiceImpl implements KqCmdService {
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult pushWorkerByDevice(KqCmdBean o) {
|
public AjaxResult pushWorkerByDevice(KqCmdBean o) {
|
||||||
//先删除在下发
|
//先删除在下发
|
||||||
//deviceCode,workerId(可以多个),pro_id
|
try {
|
||||||
// urkSendServiceImpl.refreshDevice(o.getDeviceCode(),o.getProId(),o.getSupId(),o.getTeamId());
|
urkSendServiceImpl.delDevUser(o.getDeviceCode(), Arrays.asList(o.getWorkerIds()));
|
||||||
return null;
|
urkSendServiceImpl.addUserList(o.getDeviceCode(), Arrays.asList(o.getWorkerIds()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult delWorkerByDevice(KqCmdBean o) {
|
public AjaxResult delWorkerByDevice(KqCmdBean o) {
|
||||||
//deviceCode,workerId(可以多个),pro_id
|
try {
|
||||||
// urkSendServiceImpl.refreshDevice(o.getDeviceCode(),o.getProId(),o.getSupId(),o.getTeamId());
|
urkSendServiceImpl.delDevUser(o.getDeviceCode(), Arrays.asList(o.getWorkerIds()));
|
||||||
return null;
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -89,10 +101,7 @@ public class KqCmdServiceImpl implements KqCmdService {
|
||||||
// 遍历数据,建立映射关系
|
// 遍历数据,建立映射关系
|
||||||
for (KqCmdBean item : data) {
|
for (KqCmdBean item : data) {
|
||||||
String proName = item.getProName();
|
String proName = item.getProName();
|
||||||
String deviceCode = item.getDeviceCode();
|
proToDeviceMap.computeIfAbsent(proName, k -> new ArrayList<>()).add(new KqCmdBean(item.getDeviceCode(), item.getSubName(), item.getTeamName(), item.getProId(), item.getSubId(), item.getTeamId()));
|
||||||
String subName = item.getSubName();
|
|
||||||
String teamName = item.getTeamName();
|
|
||||||
proToDeviceMap.computeIfAbsent(proName, k -> new ArrayList<>()).add(new KqCmdBean(deviceCode, subName, teamName));
|
|
||||||
}
|
}
|
||||||
// 构建树形结构
|
// 构建树形结构
|
||||||
List<TreeNode> result = new ArrayList<>();
|
List<TreeNode> result = new ArrayList<>();
|
||||||
|
|
@ -103,15 +112,7 @@ public class KqCmdServiceImpl implements KqCmdService {
|
||||||
TreeNode projectNode = new TreeNode(proName, "工程-" + proName, "project");
|
TreeNode projectNode = new TreeNode(proName, "工程-" + proName, "project");
|
||||||
// 为每个设备码创建子节点
|
// 为每个设备码创建子节点
|
||||||
for (KqCmdBean bean : deviceCodes) {
|
for (KqCmdBean bean : deviceCodes) {
|
||||||
String deviceCode = bean.getDeviceCode();
|
TreeNode deviceNode = getTreeNode(bean);
|
||||||
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");
|
|
||||||
projectNode.addChild(deviceNode);
|
projectNode.addChild(deviceNode);
|
||||||
}
|
}
|
||||||
result.add(projectNode);
|
result.add(projectNode);
|
||||||
|
|
@ -119,4 +120,17 @@ public class KqCmdServiceImpl implements KqCmdService {
|
||||||
return result;
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!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">
|
<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 id="getUserByDeviceId" 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
|
select
|
||||||
user_id as worker_id,
|
user_id as worker_id,
|
||||||
user_name as worker_name,
|
user_name as worker_name,
|
||||||
|
|
@ -34,7 +12,7 @@
|
||||||
where dev_code = #{deviceCode}
|
where dev_code = #{deviceCode}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getProDeviceWorker" resultMap="BaseResultMap">
|
<select id="getProDeviceWorker" resultType="com.bonus.bmw.domain.vo.KqCmdBean">
|
||||||
select
|
select
|
||||||
bwem.worker_id,
|
bwem.worker_id,
|
||||||
pw.name as workerName,
|
pw.name as workerName,
|
||||||
|
|
@ -50,7 +28,7 @@
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getDeviceTask" resultMap="BaseResultMap">
|
<select id="getDeviceTask" resultType="com.bonus.bmw.domain.vo.KqCmdBean">
|
||||||
select
|
select
|
||||||
cmd_code,
|
cmd_code,
|
||||||
cmd_param,
|
cmd_param,
|
||||||
|
|
@ -60,4 +38,20 @@
|
||||||
from kq_cmd_task
|
from kq_cmd_task
|
||||||
where device_code = #{deviceCode}
|
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>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue