|
@@ -4,6 +4,7 @@ package com.szwl.controller;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.szwl.model.bo.R;
|
|
|
import com.szwl.model.bo.ResponseModel;
|
|
|
import com.szwl.model.entity.TLocationCheck;
|
|
@@ -28,49 +29,50 @@ import java.util.*;
|
|
|
@RequestMapping("/tLocationCheck")
|
|
|
public class TLocationCheckController {
|
|
|
|
|
|
- TLocationCheckService locationCheckService;
|
|
|
- TAdminService adminService;
|
|
|
+ TLocationCheckService locationCheckService;
|
|
|
+ TAdminService adminService;
|
|
|
|
|
|
- public TLocationCheckController(TLocationCheckService locationCheckService, TAdminService adminService) {
|
|
|
- this.locationCheckService = locationCheckService;
|
|
|
- this.adminService = adminService;
|
|
|
- }
|
|
|
+ public TLocationCheckController(TLocationCheckService locationCheckService,
|
|
|
+ TAdminService adminService) {
|
|
|
+ this.locationCheckService = locationCheckService;
|
|
|
+ this.adminService = adminService;
|
|
|
+ }
|
|
|
|
|
|
- @ApiOperation(value = "获取定位信息")
|
|
|
- @GetMapping("/getLocInfo")
|
|
|
- public ResponseModel<?> getLocInfo(String clientId) {
|
|
|
- if (StringUtils.isEmpty(clientId)) {
|
|
|
- return R.fail("设备id不能为空");
|
|
|
- }
|
|
|
- // 根据设备id查询位置信息
|
|
|
- LambdaQueryWrapper<TLocationCheck> lqw = Wrappers.lambdaQuery();
|
|
|
- lqw.eq(TLocationCheck::getClientId, clientId);
|
|
|
- TLocationCheck locationCheck = locationCheckService.getOne(lqw);
|
|
|
- if (Objects.nonNull(locationCheck)) {
|
|
|
- HashMap<String, String> locationMap = new HashMap<>();
|
|
|
- String country = locationCheck.getCountry();
|
|
|
- String username = locationCheck.getUsername();
|
|
|
- String name = locationCheck.getName();
|
|
|
- String phone = locationCheck.getPhone();
|
|
|
- String longitude = locationCheck.getLongitude();
|
|
|
- String latitude = locationCheck.getLatitude();
|
|
|
- String addr = locationCheck.getAddr();
|
|
|
- String modUsername = locationCheck.getModUsername();
|
|
|
- String modName = locationCheck.getModName();
|
|
|
- String modPhone = locationCheck.getModPhone();
|
|
|
- String message = locationCheck.getMessage();
|
|
|
-
|
|
|
- locationMap.put("country", country); // 录入国家
|
|
|
- locationMap.put("username", username); // 账号用户名
|
|
|
- locationMap.put("name", name); // 录入人姓名
|
|
|
- locationMap.put("phone", phone); // 录入人电话
|
|
|
- locationMap.put("longitude", longitude); // 经度
|
|
|
- locationMap.put("latitude", latitude); // 纬度
|
|
|
- locationMap.put("address", addr); // 反编译的地址
|
|
|
- locationMap.put("modUsername", modUsername); // 修改人账号
|
|
|
- locationMap.put("modName", modName); // 修改人姓名
|
|
|
- locationMap.put("modPhone", modPhone); // 修改人电话
|
|
|
- locationMap.put("message", message); // 修改原因
|
|
|
+ @ApiOperation(value = "获取定位信息")
|
|
|
+ @GetMapping("/getLocInfo")
|
|
|
+ public ResponseModel<?> getLocInfo(String clientId) {
|
|
|
+ if (StringUtils.isEmpty(clientId)) {
|
|
|
+ return R.fail("设备id不能为空");
|
|
|
+ }
|
|
|
+ // 根据设备id查询位置信息
|
|
|
+ LambdaQueryWrapper<TLocationCheck> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(TLocationCheck::getClientId, clientId);
|
|
|
+ TLocationCheck locationCheck = locationCheckService.getOne(lqw);
|
|
|
+ if (Objects.nonNull(locationCheck)) {
|
|
|
+ HashMap<String, String> locationMap = new HashMap<>();
|
|
|
+ String country = locationCheck.getCountry();
|
|
|
+ String username = locationCheck.getUsername();
|
|
|
+ String name = locationCheck.getName();
|
|
|
+ String phone = locationCheck.getPhone();
|
|
|
+ String longitude = locationCheck.getLongitude();
|
|
|
+ String latitude = locationCheck.getLatitude();
|
|
|
+ String addr = locationCheck.getAddr();
|
|
|
+ String modUsername = locationCheck.getModUsername();
|
|
|
+ String modName = locationCheck.getModName();
|
|
|
+ String modPhone = locationCheck.getModPhone();
|
|
|
+ String message = locationCheck.getMessage();
|
|
|
+
|
|
|
+ locationMap.put("country", country); // 录入国家
|
|
|
+ locationMap.put("username", username); // 账号用户名
|
|
|
+ locationMap.put("name", name); // 录入人姓名
|
|
|
+ locationMap.put("phone", phone); // 录入人电话
|
|
|
+ locationMap.put("longitude", longitude); // 经度
|
|
|
+ locationMap.put("latitude", latitude); // 纬度
|
|
|
+ locationMap.put("address", addr); // 反编译的地址
|
|
|
+ locationMap.put("modUsername", modUsername); // 修改人账号
|
|
|
+ locationMap.put("modName", modName); // 修改人姓名
|
|
|
+ locationMap.put("modPhone", modPhone); // 修改人电话
|
|
|
+ locationMap.put("message", message); // 修改原因
|
|
|
|
|
|
// if (country.equals("中国")) {
|
|
|
// String location = locationCheck.getLocation();
|
|
@@ -78,133 +80,135 @@ public class TLocationCheckController {
|
|
|
// } else {
|
|
|
// return R.ok(country);
|
|
|
// }
|
|
|
- return R.ok(locationMap);
|
|
|
- }
|
|
|
- return R.fail("地区信息未录入");
|
|
|
+ return R.ok(locationMap);
|
|
|
+ }
|
|
|
+ return R.fail("地区信息未录入");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "根据ip校验clientId设备定位")
|
|
|
+ @PostMapping("/ipCheck")
|
|
|
+ public ResponseModel<?> ipCheck(@RequestParam String clientId, @RequestParam String ip)
|
|
|
+ throws JsonProcessingException {
|
|
|
+ if (StringUtils.isBlank(clientId) || StringUtils.isBlank(ip)) {
|
|
|
+ return R.fail("参数不能为空");
|
|
|
}
|
|
|
+ // 根据 clientId 查设备的 location,country
|
|
|
+ LambdaQueryWrapper<TLocationCheck> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(TLocationCheck::getClientId, clientId);
|
|
|
+ TLocationCheck locationCheck = locationCheckService.getOne(lqw);
|
|
|
+ if (Objects.isNull(locationCheck)) {
|
|
|
+ return R.fail("生产部未录入改设备的位置信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ locationCheck.setIp(ip);
|
|
|
+ locationCheck.setModifyTime(new Date());
|
|
|
|
|
|
- @ApiOperation(value = "根据ip校验clientId设备定位")
|
|
|
- @PostMapping("/ipCheck")
|
|
|
- public ResponseModel<?> ipCheck(@RequestParam String clientId, @RequestParam String ip) {
|
|
|
- if (StringUtils.isBlank(clientId) || StringUtils.isBlank(ip)) {
|
|
|
- return R.fail("参数不能为空");
|
|
|
- }
|
|
|
- // 根据 clientId 查设备的 location,country
|
|
|
- LambdaQueryWrapper<TLocationCheck> lqw = Wrappers.lambdaQuery();
|
|
|
- lqw.eq(TLocationCheck::getClientId, clientId);
|
|
|
- TLocationCheck locationCheck = locationCheckService.getOne(lqw);
|
|
|
- if (Objects.isNull(locationCheck)) {
|
|
|
- return R.fail("生产部未录入改设备的位置信息");
|
|
|
- }
|
|
|
-
|
|
|
- locationCheck.setIp(ip);
|
|
|
- locationCheck.setModifyTime(new Date());
|
|
|
-
|
|
|
- String addr = WhoIsUtil.getLocByIp(ip);
|
|
|
+// String addr = WhoIsUtil.getLocByIp(ip);
|
|
|
+ String addr = WhoIsUtil.getLocByIp2(ip);
|
|
|
|
|
|
// String result = locationCheckService.locCheckMsg(locationCheck, clientId, addr);
|
|
|
- String result = locationCheckService.locCheckNoMsg(locationCheck, clientId, addr);
|
|
|
+ String result = locationCheckService.locCheckNoMsg(locationCheck, clientId, addr);
|
|
|
|
|
|
- if ("fail".equals(result)) {
|
|
|
- locationCheck.setErr("不匹配");
|
|
|
- }
|
|
|
- locationCheckService.updateById(locationCheck);
|
|
|
- return R.ok(result);
|
|
|
+ if ("fail".equals(result)) {
|
|
|
+ locationCheck.setErr("不匹配");
|
|
|
+ }
|
|
|
+ locationCheckService.updateById(locationCheck);
|
|
|
+ return R.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改定位信息")
|
|
|
+ @PostMapping("/updateLocInfo")
|
|
|
+ public ResponseModel<?> updateLocInfo(@RequestBody TLocationCheck locationCheck) {
|
|
|
+ if (Objects.isNull(locationCheck)) {
|
|
|
+ return R.fail("参数不能为空");
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "修改定位信息")
|
|
|
- @PostMapping("/updateLocInfo")
|
|
|
- public ResponseModel<?> updateLocInfo(@RequestBody TLocationCheck locationCheck) {
|
|
|
- if (Objects.isNull(locationCheck)) {
|
|
|
- return R.fail("参数不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- // 售后部同事修改的信息:姓名,电话,username,clientId,国家
|
|
|
- String modUsername = locationCheck.getModUsername();
|
|
|
-
|
|
|
- Set<String> allowedUsernames = new HashSet<>(Arrays.asList("shouhoumi", "sysMgtAcc", "jiang123", "ethan"));
|
|
|
- if (!allowedUsernames.contains(modUsername)) {
|
|
|
- return R.fail("该账号无权修改");
|
|
|
- }
|
|
|
- String modName = locationCheck.getModName();
|
|
|
- String modPhone = locationCheck.getModPhone();
|
|
|
- String clientId = locationCheck.getClientId();
|
|
|
-// String location = locationCheck.getLocation();
|
|
|
- String country = locationCheck.getCountry();
|
|
|
- String message = locationCheck.getMessage();
|
|
|
+ // 售后部同事修改的信息:姓名,电话,username,clientId,国家
|
|
|
+ String modUsername = locationCheck.getModUsername();
|
|
|
|
|
|
- if (Objects.isNull(clientId)) {
|
|
|
- return R.fail("设备唯一码不能为空");
|
|
|
- }
|
|
|
+ Set<String> allowedUsernames = new HashSet<>(
|
|
|
+ Arrays.asList("shouhoumi", "sysMgtAcc", "jiang123", "ethan"));
|
|
|
+ if (!allowedUsernames.contains(modUsername)) {
|
|
|
+ return R.fail("该账号无权修改");
|
|
|
+ }
|
|
|
+ String modName = locationCheck.getModName();
|
|
|
+ String modPhone = locationCheck.getModPhone();
|
|
|
+ String clientId = locationCheck.getClientId();
|
|
|
+// String location = locationCheck.getLocation();
|
|
|
+ String country = locationCheck.getCountry();
|
|
|
+ String message = locationCheck.getMessage();
|
|
|
|
|
|
- LambdaQueryWrapper<TLocationCheck> wrapper = Wrappers.lambdaQuery();
|
|
|
- wrapper.eq(TLocationCheck::getClientId, clientId);
|
|
|
- List<TLocationCheck> checks = locationCheckService.list(wrapper);
|
|
|
- TLocationCheck tLocationCheck = checks.get(0);
|
|
|
+ if (Objects.isNull(clientId)) {
|
|
|
+ return R.fail("设备唯一码不能为空");
|
|
|
+ }
|
|
|
|
|
|
+ LambdaQueryWrapper<TLocationCheck> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(TLocationCheck::getClientId, clientId);
|
|
|
+ List<TLocationCheck> checks = locationCheckService.list(wrapper);
|
|
|
+ TLocationCheck tLocationCheck = checks.get(0);
|
|
|
|
|
|
- tLocationCheck.setModifyTime(new Date());
|
|
|
- tLocationCheck.setModName(modName);
|
|
|
+ tLocationCheck.setModifyTime(new Date());
|
|
|
+ tLocationCheck.setModName(modName);
|
|
|
// tLocationCheck.setModAdminId(modAdminId);
|
|
|
- tLocationCheck.setModPhone(modPhone);
|
|
|
- tLocationCheck.setModUsername(modUsername);
|
|
|
+ tLocationCheck.setModPhone(modPhone);
|
|
|
+ tLocationCheck.setModUsername(modUsername);
|
|
|
// tLocationCheck.setLocation(location);
|
|
|
- tLocationCheck.setClientId(clientId);
|
|
|
- tLocationCheck.setCountry(country);
|
|
|
- tLocationCheck.setMessage(message);
|
|
|
+ tLocationCheck.setClientId(clientId);
|
|
|
+ tLocationCheck.setCountry(country);
|
|
|
+ tLocationCheck.setMessage(message);
|
|
|
+
|
|
|
+ locationCheckService.updateById(tLocationCheck);
|
|
|
|
|
|
- locationCheckService.updateById(tLocationCheck);
|
|
|
+ return R.ok("修改成功");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- return R.ok("修改成功");
|
|
|
+ @ApiOperation(value = "录入定位信息")
|
|
|
+ @PostMapping("/inputLocInfo")
|
|
|
+ public ResponseModel<?> inputLocInfo(@RequestBody TLocationCheck locationCheck) {
|
|
|
+ if (Objects.isNull(locationCheck)) {
|
|
|
+ return R.fail("参数不能为空");
|
|
|
}
|
|
|
|
|
|
+ String name = locationCheck.getName();
|
|
|
+ String phone = locationCheck.getPhone();
|
|
|
+ String username = locationCheck.getUsername();
|
|
|
+ String clientId = locationCheck.getClientId();
|
|
|
+ String country = locationCheck.getCountry(); // 国家
|
|
|
+// String location = locationCheck.getLocation(); // 地区
|
|
|
|
|
|
- @ApiOperation(value = "录入定位信息")
|
|
|
- @PostMapping("/inputLocInfo")
|
|
|
- public ResponseModel<?> inputLocInfo(@RequestBody TLocationCheck locationCheck) {
|
|
|
- if (Objects.isNull(locationCheck)) {
|
|
|
- return R.fail("参数不能为空");
|
|
|
- }
|
|
|
+ if (Objects.isNull(clientId)) {
|
|
|
+ return R.fail("设备唯一码不能为空");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<TLocationCheck> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(TLocationCheck::getClientId, clientId);
|
|
|
+ List<TLocationCheck> checks = locationCheckService.list(wrapper);
|
|
|
+ if (checks.size() > 0) {
|
|
|
+ return R.fail("此设备信息已录入");
|
|
|
+ }
|
|
|
|
|
|
- String name = locationCheck.getName();
|
|
|
- String phone = locationCheck.getPhone();
|
|
|
- String username = locationCheck.getUsername();
|
|
|
- String clientId = locationCheck.getClientId();
|
|
|
- String country = locationCheck.getCountry(); // 国家
|
|
|
-// String location = locationCheck.getLocation(); // 地区
|
|
|
+ Set<String> allowedUsers = new HashSet<>(
|
|
|
+ Arrays.asList("sysMgtAcc", "jiang123", "shouhou121", "shouhou369", "shouhou397",
|
|
|
+ "shouhoumi", "zhl123", "ethan"));
|
|
|
+ if (!allowedUsers.contains(username)) {
|
|
|
+ return R.fail("该账号无权操作");
|
|
|
+ }
|
|
|
|
|
|
- if (Objects.isNull(clientId)) {
|
|
|
- return R.fail("设备唯一码不能为空");
|
|
|
- }
|
|
|
- LambdaQueryWrapper<TLocationCheck> wrapper = Wrappers.lambdaQuery();
|
|
|
- wrapper.eq(TLocationCheck::getClientId, clientId);
|
|
|
- List<TLocationCheck> checks = locationCheckService.list(wrapper);
|
|
|
- if (checks.size() > 0) {
|
|
|
- return R.fail("此设备信息已录入");
|
|
|
- }
|
|
|
-
|
|
|
- Set<String> allowedUsers = new HashSet<>(Arrays.asList("sysMgtAcc", "jiang123", "shouhou121", "shouhou369", "shouhou397", "shouhoumi", "zhl123", "ethan"));
|
|
|
- if (!allowedUsers.contains(username)) {
|
|
|
- return R.fail("该账号无权操作");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- TLocationCheck tLocationCheck = new TLocationCheck();
|
|
|
- String uuid = IdUtil.simpleUUID();
|
|
|
- tLocationCheck.setId(uuid);
|
|
|
- tLocationCheck.setCreateTime(new Date());
|
|
|
- tLocationCheck.setName(name);
|
|
|
- tLocationCheck.setPhone(phone);
|
|
|
- tLocationCheck.setUsername(username);
|
|
|
- tLocationCheck.setClientId(clientId);
|
|
|
- tLocationCheck.setCountry(country);
|
|
|
+ TLocationCheck tLocationCheck = new TLocationCheck();
|
|
|
+ String uuid = IdUtil.simpleUUID();
|
|
|
+ tLocationCheck.setId(uuid);
|
|
|
+ tLocationCheck.setCreateTime(new Date());
|
|
|
+ tLocationCheck.setName(name);
|
|
|
+ tLocationCheck.setPhone(phone);
|
|
|
+ tLocationCheck.setUsername(username);
|
|
|
+ tLocationCheck.setClientId(clientId);
|
|
|
+ tLocationCheck.setCountry(country);
|
|
|
// tLocationCheck.setLocation(location);
|
|
|
|
|
|
- locationCheckService.save(tLocationCheck);
|
|
|
+ locationCheckService.save(tLocationCheck);
|
|
|
|
|
|
- return R.ok("设备出厂信息录入成功");
|
|
|
- }
|
|
|
+ return R.ok("设备出厂信息录入成功");
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|