瀏覽代碼

终端关联,终端解绑等接口

wangchao 4 年之前
父節點
當前提交
8bd1ff2323

+ 15 - 71
ebc-sea-platform/src/main/java/com/ai/ipu/server/controller/DeviceManageController.java

122
	}
122
	}
123
123
124
	/**
124
	/**
125
	 * 关联终端
125
	 * 关联终端(关联用户或者船舶的保存功能)
126
	 *
126
	 */
127
	 */
127
	@ResponseBody
128
	@ResponseBody
128
	@RequestMapping("/bindDevice")
129
	@RequestMapping("/bindDevice")
129
	public JMap bindDevice(JMap params) throws Exception {
130
	public JMap bindDevice(JMap params) throws Exception {
130
		JMap result = new JsonMap(); // 返回值
131
		JMap result = new JsonMap(); // 返回值
131
		if (params.get("deviceId") != null && "".equals(params.get("deviceId"))) {
132
		if (params.get("DEVICE_ID") != null && !"".equals(params.get("DEVICE_ID"))) {
132
			boolean flag = false;
133
			boolean flag = false;
133
			flag = deviceManageService.bindDevice(params);
134
			flag = deviceManageService.bindDevice(params);
134
			result.put("result", flag);
135
			result.put("result", flag);
138
			result.put("errMsg", "关联终端失败");
139
			result.put("errMsg", "关联终端失败");
139
		}
140
		}
140
		return result;
141
		return result;
141
142
	}
142
	}
143
143
144
	/**
144
	/**
149
	public JMap unbindDevice(JMap params) throws Exception {
149
	public JMap unbindDevice(JMap params) throws Exception {
150
		JMap result = new JsonMap(); // 返回值
150
		JMap result = new JsonMap(); // 返回值
151
		boolean flag = false;
151
		boolean flag = false;
152
		if (params.get("deviceId") != null && "".equals(params.get("deviceId"))) {
152
		if (params.get("DEVICE_ID") != null && !"".equals(params.get("DEVICE_ID"))) {
153
			flag = deviceManageService.unbindDevice(params);
153
			flag = deviceManageService.unbindDevice(params);
154
		} else {
154
		} else {
155
			logger.error("解绑终端失败:设备id为空");
155
			logger.error("解绑终端失败:设备id为空");
172
		return result;
172
		return result;
173
	}
173
	}
174
174
175
    /**
176
     * 关联用户的用户列表信息查询
177
     */
178
    @ResponseBody
179
    @RequestMapping("/queryAssociatUserInfo")
180
    public JMap queryAssociatUserInfo(JMap params) throws Exception {
181
        List<Map<String, Object>> userList=  deviceManageService.queryAssociatUserInfo(params);
182
        JMap result = new JsonMap();
183
        result.put("result", userList);
184
        return result;
185
    }
186
187
188
    /**
189
     * 关联用户的船舶列表信息查询
190
     */
191
    @ResponseBody
192
    @RequestMapping("/queryAssociatBoatInfo")
193
    public JMap queryAssociatBoatInfo(JMap params) throws Exception {
194
        List<Map<String, Object>> boatList=  deviceManageService.queryAssociatBoatInfo(params);
195
        JMap result = new JsonMap();
196
        result.put("result", boatList);
197
        return result;
198
    }
199
200
    /**
201
     * 关联用户的保存功能
202
     */
203
    @ResponseBody
204
    @RequestMapping("/associatUserSave")
205
    public JMap associatUserSave(JMap params) throws Exception {
206
207
        int num=deviceManageService.associatUserSave(params);
208
209
        JMap result = new JsonMap();
210
        result.put("result", num);
211
        return result;
212
    }
213
214
    /**
215
     * 关联船舶的保存功能
216
     */
217
    @ResponseBody
218
    @RequestMapping("/associatBoatSave")
219
    public JMap associatBoatSave(JMap params) throws Exception {
220
221
        int num=deviceManageService.associatBoatSave(params);
222
223
        JMap result = new JsonMap();
224
        result.put("result", num);
225
        return result;
226
    }
175
	/**
176
	 * 验证用户或者船舶是否有终端关联
177
	 */
178
	@ResponseBody
179
	@RequestMapping("/verifyUserOrBoatAssociatInfo")
180
	public JMap  verifyUserOrBoatAssociatInfo(JMap params) throws Exception {
181
		Map<String, Object> associatMap=  deviceManageService.verifyUserOrBoatAssociatInfo(params);
182
		JMap result = new JsonMap();
183
		result.put("result", associatMap);
184
		return result;
185
	}
227
186
228
	/**
187
	/**
229
	 * 导入终端信息
188
	 * 导入终端信息
239
		result.put("result", flag);
198
		result.put("result", flag);
240
		return result;
199
		return result;
241
	}
200
	}
242
243
    /**
244
     * 解绑用户
245
     */
246
    @ResponseBody
247
    @RequestMapping("/unbundUser")
248
    public JMap unbundUser(JMap params) throws Exception {
249
        boolean flag=false;
250
        if(params.getInt("MAP_TAG_ID")!=0){
251
            //flag=  userManageService.unbundTerminal(params);
252
        }
253
        JMap result = new JsonMap();
254
        result.put("result", flag);
255
        return result;
256
    }
257
}
201
}

+ 17 - 0
ebc-sea-platform/src/main/java/com/ai/ipu/server/controller/EquipmentManageController.java

42
        return result;
42
        return result;
43
    }
43
    }
44
44
45
    /**
46
     * 查询设备信息增加时效验重复
47
     */
48
    @ResponseBody
49
    @RequestMapping("/verifyEquipmentInfoRepetition")
50
    public JMap verifyEquipmentInfoRepetition(JMap params) throws Exception {
51
        Map<String, Object> equipmentMap= equipmentManageService.verifyEquipmentInfoRepetition(params);
52
        JMap result = new JsonMap();
53
        if(equipmentMap.isEmpty()){
54
            result.put("result", false);
55
        }else{
56
            result.put("result", true);
57
        }
58
59
        return result;
60
    }
61
45
62
46
    /**
63
    /**
47
     * 编辑设备信息、新增设备信息
64
     * 编辑设备信息、新增设备信息

+ 25 - 27
ebc-sea-platform/src/main/java/com/ai/ipu/server/dao/impl/DeviceManageDaoImpl.java

37
    @Override
37
    @Override
38
    public List<Map<String, Object>> queryAssociatBoatInfo(JMap params) throws Exception {
38
    public List<Map<String, Object>> queryAssociatBoatInfo(JMap params) throws Exception {
39
        HashMap<String, Object> paramMap = new HashMap<>();
39
        HashMap<String, Object> paramMap = new HashMap<>();
40
        paramMap.put("FACILITY_NAME","船舶");
40
        paramMap.put("FACILITY_TYPE","3");
41
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
41
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
42
        List<Map<String, Object>> boatList = dao.selectByCond(equipmentTableName, paramMap);
42
        List<Map<String, Object>> boatList = dao.selectByCond(equipmentTableName, paramMap);
43
        return boatList;
43
        return boatList;
51
		return map;
51
		return map;
52
	}
52
	}
53
    @Override
53
    @Override
54
    public List<Map<String, Object>> queryAssociatUser () throws Exception  {
55
        HashMap<String, Object> paramMap = new HashMap<>();
54
    public Map<String, Object> queryAssociatUser (JMap params) throws Exception  {
56
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
55
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
57
        List<Map<String, Object>> userAndDeviceList = dao.selectByCond(userAndDevicetableName, paramMap);
58
        return userAndDeviceList;
56
		List<Map<String, Object>> userAndDeviceList = dao.selectByCond(userAndDevicetableName, params);
57
		if(userAndDeviceList.isEmpty()){
58
			return null;
59
		}else {
60
			return userAndDeviceList.get(0);
61
		}
59
    }
62
    }
60
63
61
	@Override
64
	@Override
65
		Map map = HttpURLConnectionUtil.iotCallMothod(url, paramsMap);
68
		Map map = HttpURLConnectionUtil.iotCallMothod(url, paramsMap);
66
		return map;
69
		return map;
67
	}
70
	}
68
    @Override
69
    public int associatUserSave(JMap params) throws Exception {
70
        HashMap<String, Object> paramMap = new HashMap<>();
71
        //参数
72
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
73
        int i = dao.insert(userAndDevicetableName, paramMap);
74
        return i;
75
    }
76
71
77
	@Override
72
	@Override
78
	public Map<String, String> deleteDeviceInfo(Map<String, String> paramsMap) throws Exception {
73
	public Map<String, String> deleteDeviceInfo(Map<String, String> paramsMap) throws Exception {
84
79
85
	@Override
80
	@Override
86
	public int bindDevice(Map params, String type) throws Exception {
81
	public int bindDevice(Map params, String type) throws Exception {
82
		HashMap<String, Object> paramsHashMap = new HashMap<>();
87
		if (EbcConstant.bind_device_type_user.equals(type)) {
83
		if (EbcConstant.bind_device_type_user.equals(type)) {
88
			return dao.insert("LR_PARTY_TERMINAL", params);
84
			if(params.get("PARTY_TERMINAL_ID")!=null){
85
				//将之前终端与用户关联数据删除
86
				paramsHashMap.put("PARTY_TERMINAL_ID",params.get("PARTY_TERMINAL_ID"));
87
				dao.delete(userAndDevicetableName, paramsHashMap);
88
			}
89
			//插入一条新的关联数据
90
			return dao.insert(userAndDevicetableName, params);
89
		} else if (EbcConstant.bind_device_type_ship.equals(type)) {
91
		} else if (EbcConstant.bind_device_type_ship.equals(type)) {
90
			return dao.update("LR_FACILITY", params);
92
			paramsHashMap.put("FACILITY_ID",params.get("FACILITY_ID"));
93
			paramsHashMap.put("DEVICE_ID",params.get("DEVICE_ID"));
94
			return dao.update(equipmentTableName, paramsHashMap);
91
		}
95
		}
92
		return 0;
96
		return 0;
93
	}
97
	}
94
98
95
	@Override
99
	@Override
96
	public int unbindDevice(Map params, String type) throws Exception {
100
	public int unbindDevice(Map params, String type) throws Exception {
101
		HashMap<String, Object> paramsHashMap = new HashMap<>();
97
		if (EbcConstant.bind_device_type_user.equals(type)) {
102
		if (EbcConstant.bind_device_type_user.equals(type)) {
98
			return dao.delete("LR_PARTY_TERMINAL", params);
103
			paramsHashMap.put("DEVICE_ID",params.get("DEVICE_ID"));
104
			return dao.delete(userAndDevicetableName, paramsHashMap,false);
99
		} else if (EbcConstant.bind_device_type_ship.equals(type)) {
105
		} else if (EbcConstant.bind_device_type_ship.equals(type)) {
100
			return dao.update("LR_FACILITY", params);
106
			paramsHashMap.put("FACILITY_ID",params.get("FACILITY_ID"));
107
			paramsHashMap.put("DEVICE_ID",null);
108
			return dao.update(equipmentTableName, paramsHashMap);
101
		}
109
		}
102
		return 0;
110
		return 0;
103
	}
111
	}
104
    @Override
105
    public int associatBoatSave(JMap params) throws Exception {
106
        HashMap<String, Object> paramMap = new HashMap<>();
107
        //参数
108
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
109
        int i = dao.update(equipmentTableName, paramMap);
110
        return i;
111
    }
112
113
114
}
112
}

+ 7 - 3
ebc-sea-platform/src/main/java/com/ai/ipu/server/dao/impl/EquipmentManageDaoImpl.java

60
    }
60
    }
61
61
62
    @Override
62
    @Override
63
    public boolean deleteEquipmentsInfo(List<Map<String, Object>> paramsList) {
63
    public boolean deleteEquipmentsInfo(List<Map<String, Object>> paramsList) throws Exception{
64
        return false;
64
        return false;
65
    }
65
    }
66
66
67
    @Override
67
    @Override
68
    public boolean importEquipmentInfo(List<Map<String, Object>> paramsList) {
68
    public boolean importEquipmentInfo(List<Map<String, Object>> paramsList) throws Exception{
69
        return false;
69
        return false;
70
    }
70
    }
71
71
72
72
    @Override
73
    public Map<String, Object> verifyEquipmentInfoRepetition(JMap params) throws Exception {
74
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
75
        return dao.select(equipmentTableName, params);
76
    }
73
}
77
}

+ 3 - 3
ebc-sea-platform/src/main/java/com/ai/ipu/server/dao/interfaces/DeviceManageDao.java

11
	Map<String, String> queryDeviceInfo(JMap params) throws Exception;
11
	Map<String, String> queryDeviceInfo(JMap params) throws Exception;
12
12
13
	Map<String, String> addDeviceInfo(Map<String, String> paramsMap) throws Exception;
13
	Map<String, String> addDeviceInfo(Map<String, String> paramsMap) throws Exception;
14
14
    List<Map<String, Object>> queryAssociatBoatInfo(JMap params) throws Exception;
15
    List<Map<String, Object>> queryAssociatBoatInfo(JMap params) throws Exception;
15
16
16
	Map<String, String> modifyDeviceInfo(Map<String, String> paramsMap) throws Exception;
17
	Map<String, String> modifyDeviceInfo(Map<String, String> paramsMap) throws Exception;
17
    List<Map<String, Object>> queryAssociatUser() throws Exception ;
18
19
    Map<String, Object> queryAssociatUser(JMap params ) throws Exception ;
18
20
19
	Map<String, String> deleteDeviceInfo(Map<String, String> paramsMap) throws Exception;
21
	Map<String, String> deleteDeviceInfo(Map<String, String> paramsMap) throws Exception;
20
    int associatUserSave(JMap params) throws Exception ;
21
22
22
	int bindDevice(Map params,String type) throws Exception;
23
	int bindDevice(Map params,String type) throws Exception;
23
24
24
	int unbindDevice(Map params,String type) throws Exception;
25
	int unbindDevice(Map params,String type) throws Exception;
25
    int associatBoatSave(JMap params) throws Exception ;
26
}
26
}

+ 4 - 2
ebc-sea-platform/src/main/java/com/ai/ipu/server/dao/interfaces/EquipmentManageDao.java

16
16
17
    boolean deleteEquipmentInfo(JMap params) throws Exception;
17
    boolean deleteEquipmentInfo(JMap params) throws Exception;
18
18
19
    boolean deleteEquipmentsInfo(List<Map<String, Object>> paramsList);
19
    boolean deleteEquipmentsInfo(List<Map<String, Object>> paramsList) throws Exception;
20
20
21
    boolean importEquipmentInfo(List<Map<String, Object>> paramsList);
21
    boolean importEquipmentInfo(List<Map<String, Object>> paramsList) throws Exception;
22
23
    Map<String, Object> verifyEquipmentInfoRepetition(JMap params) throws Exception;
22
}
24
}

+ 16 - 39
ebc-sea-platform/src/main/java/com/ai/ipu/server/service/impl/DeviceManageServiceImpl.java

13
import org.springframework.beans.factory.annotation.Autowired;
13
import org.springframework.beans.factory.annotation.Autowired;
14
import org.springframework.stereotype.Service;
14
import org.springframework.stereotype.Service;
15
15
16
import java.util.Iterator;
17
import java.util.List;
16
import java.util.List;
18
import com.ai.ipu.server.util.EbcConstant;
17
import com.ai.ipu.server.util.EbcConstant;
19
18
62
61
63
	@Override
62
	@Override
64
	public List<Map<String, Object>> queryAssociatInfo(JMap params) throws Exception {
63
	public List<Map<String, Object>> queryAssociatInfo(JMap params) throws Exception {
64
		if (EbcConstant.bind_device_type_user.equals(params.get("type"))) {
65
			//类型是用户,查询用户列表
66
			//调用uspa接口获取人员信息 暂时用枚举
67
			List<Map<String, Object>> userList = UserEnums.getUserList();
68
			return userList;
69
		} else if (EbcConstant.bind_device_type_ship.equals(params.get("type"))){
70
			//类型是船舶,查询船舶列表
71
			return deviceManageDao.queryAssociatBoatInfo(params);
72
		}
65
		return null;
73
		return null;
66
	}
74
	}
67
75
68
    @Override
69
    public List<Map<String, Object>> queryAssociatUserInfo(JMap params) throws Exception{
70
        //调用uspa接口获取人员信息 暂时用枚举
71
        List<Map<String, Object>> userList = UserEnums.getUserList();
72
73
        //查询关联表,如果已关联人员剔除
74
        List<Map<String, Object>> userAndDeviceList=  deviceManageDao.queryAssociatUser();
75
76
        Iterator<Map<String, Object>> iterator = userList.iterator();
77
        while (iterator.hasNext()){
78
            Map<String, Object> next = iterator.next();
79
            for (Map<String, Object> userAndDevice : userAndDeviceList) {
80
                if (userAndDevice.get("PARTY_NAME").equals(next.get("userName"))) {
81
                    iterator.remove();
82
                    break;
83
                }
84
            }
85
        }
86
        return userList;
87
    }
88
89
    @Override
90
    public List<Map<String, Object>> queryAssociatBoatInfo(JMap params) throws Exception {
91
        return deviceManageDao.queryAssociatBoatInfo(params);
92
    }
93
94
    @Override
95
    public int associatUserSave(JMap params) throws Exception {
96
        return deviceManageDao.associatUserSave(params);
97
    }
98
99
    @Override
100
    public int associatBoatSave(JMap params) throws Exception {
101
        return deviceManageDao.associatBoatSave(params);
102
    }
103
104
76
	@Override
77
	public Map<String, Object> verifyUserOrBoatAssociatInfo(JMap params) throws Exception {
78
		//查询用户与终端关联表,如果有数据返回,无数据返回空
79
		Map<String, Object> userAndDeviceMap=  deviceManageDao.queryAssociatUser(params);
80
		return userAndDeviceMap;
81
	}
105
82
106
	@Override
83
	@Override
107
	public Map<String, String> deleteDeviceInfo(JMap params) throws Exception {
84
	public Map<String, String> deleteDeviceInfo(JMap params) throws Exception {
121
98
122
	@Override
99
	@Override
123
	public boolean unbindDevice(JMap params) throws Exception {
100
	public boolean unbindDevice(JMap params) throws Exception {
124
		int num = deviceManageDao.bindDevice(params, params.getString("type"));
101
		int num = deviceManageDao.unbindDevice(params, params.getString("type"));
125
		return num > 0;
102
		return num > 0;
126
	}
103
	}
127
}
104
}

+ 5 - 0
ebc-sea-platform/src/main/java/com/ai/ipu/server/service/impl/EquipmentManageServiceImpl.java

57
        return equipmentManageDao.importEquipmentInfo(paramsList);
57
        return equipmentManageDao.importEquipmentInfo(paramsList);
58
    }
58
    }
59
59
60
    @Override
61
    public Map<String, Object> verifyEquipmentInfoRepetition(JMap params) throws Exception{
62
        return equipmentManageDao.verifyEquipmentInfoRepetition(params);
63
    }
64
60
65
61
}
66
}

+ 2 - 8
ebc-sea-platform/src/main/java/com/ai/ipu/server/service/interfaces/DeviceManageService.java

21
21
22
	boolean unbindDevice(JMap params) throws Exception;
22
	boolean unbindDevice(JMap params) throws Exception;
23
23
24
    List<Map<String, Object>> queryAssociatUserInfo(JMap params) throws Exception;
25
26
    List<Map<String, Object>> queryAssociatBoatInfo(JMap params) throws Exception;
27
28
    int associatUserSave(JMap params) throws Exception;
29
30
    int associatBoatSave(JMap params) throws Exception;
31
32
	List<Map<String, Object>> queryAssociatInfo(JMap params) throws Exception;
24
	List<Map<String, Object>> queryAssociatInfo(JMap params) throws Exception;
25
26
	Map<String, Object> verifyUserOrBoatAssociatInfo(JMap params) throws Exception;
33
}
27
}

+ 2 - 0
ebc-sea-platform/src/main/java/com/ai/ipu/server/service/interfaces/EquipmentManageService.java

19
    boolean deleteEquipmentsInfo(List<Map<String,Object>> paramsList) throws Exception;
19
    boolean deleteEquipmentsInfo(List<Map<String,Object>> paramsList) throws Exception;
20
20
21
    boolean importEquipmentInfo(List<Map<String,Object>> paramsList) throws Exception;
21
    boolean importEquipmentInfo(List<Map<String,Object>> paramsList) throws Exception;
22
23
    Map<String, Object> verifyEquipmentInfoRepetition(JMap params) throws Exception;
22
}
24
}

+ 5 - 64
ebc-sea-platform/src/main/resources/sql/ipu/EquipmentManageDao.xml

14
			FROM
14
			FROM
15
				LR_FACILITY
15
				LR_FACILITY
16
	        <where>
16
	        <where>
17
	        	<if test="FACILITY_CODE!=null">
17
	        	<if test="FACILITY_CODE!=null and FACILITY_CODE != ''">
18
               		 and FACILITY_CODE like concat(concat("%",#{FACILITY_CODE}),"%")
18
               		 and FACILITY_CODE like concat(concat("%",#{FACILITY_CODE}),"%")
19
            	</if>
19
            	</if>
20
            	<if test="FACILITY_NAME!=null">
20
            	<if test="FACILITY_NAME!=null and FACILITY_NAME != ''">
21
               		 and FACILITY_NAME like concat(concat("%",#{FACILITY_NAME}),"%")
21
               		 and FACILITY_NAME like concat(concat("%",#{FACILITY_NAME}),"%")
22
            	</if>
22
            	</if>
23
            	<if test="FACILITY_TYPE!=null and FACILITY_TYPE != ''">
24
               		 and FACILITY_TYPE = #{FACILITY_TYPE}
25
            	</if>
23
	        </where>
26
	        </where>
24
		</select>
27
		</select>
25
		]]>
28
		]]>
26
	</sql>
29
	</sql>
27
28
	<sql name="queryMapTagXyInfo">
29
		<![CDATA[
30
		<select id="queryMapTagXyInfo" resultType="java.util.Map" >
31
	        SELECT
32
				MAP_TAG_ID,
33
				MAP_TAG_XY_ID,
34
				XY_NAME,
35
				LATITUDE,
36
				LONGITUDE
37
			FROM
38
				ebc_map_tag_xy
39
		</select>
40
41
42
		]]>
43
	</sql>
44
45
	<sql name="addMapTagInfo">
46
		<![CDATA[
47
		<insert id="addMapTagInfo" resultType="java.util.Map" useGeneratedKeys="true" keyProperty="MAP_TAG_ID">
48
		   INSERT INTO  ebc_map_tag(
49
			MAP_TAG_NAME,MAP_TAG_TYPE,MAP_TAG_CONTENT,CREATE_DATE
50
			)VALUES (
51
			  #{MAP_TAG_NAME},
52
			  #{MAP_TAG_TYPE},
53
			  #{MAP_TAG_CONTENT},
54
			  #{CREATE_DATE}
55
			)
56
			</insert>
57
			]]>
58
	</sql>
59
60
	<sql name="addMapTagxyInfo">
61
		<![CDATA[<insert id="addMapTagxyInfo">
62
			INSERT INTO ebc_map_tag_xy
63
			(MAP_TAG_ID,XY_NAME,LONGITUDE,LATITUDE)
64
			VALUES
65
			<foreach collection ="paramsList" item="itemParams" index= "index" separator =",">
66
			(#{itemParams.MAP_TAG_ID},#{itemParams.XY_NAME},#{itemParams.LONGITUDE},#{itemParams.LATITUDE})
67
			</foreach>
68
		</insert>
69
		]]>
70
	</sql>
71
72
73
74
	<sql name="deleteMapTagXyInfo">
75
		<![CDATA[
76
			<delete id="deleteMapTagXyInfo">
77
				delete FROM ebc_map_tag_xy where MAP_TAG_ID=#{MAP_TAG_ID}
78
			</delete>
79
		]]>
80
	</sql>
81
82
	<sql name="deleteMapTagInfo">
83
		<![CDATA[
84
			<delete id="deleteMapTagInfo">
85
				delete FROM ebc_map_tag where MAP_TAG_ID=#{MAP_TAG_ID}
86
			</delete>
87
		]]>
88
	</sql>
89
</sqls>
30
</sqls>