|
@@ -5,7 +5,6 @@ import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
@@ -19,9 +18,11 @@ import com.szwl.service.TAdminService;
|
|
import com.szwl.service.TLocationCheckService;
|
|
import com.szwl.service.TLocationCheckService;
|
|
import com.szwl.util.WhoIsUtil;
|
|
import com.szwl.util.WhoIsUtil;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
|
|
@@ -31,7 +32,7 @@ import java.util.Objects;
|
|
* </p>
|
|
* </p>
|
|
*
|
|
*
|
|
* @author wuhs
|
|
* @author wuhs
|
|
- * @since 2023-12-06
|
|
|
|
|
|
+ * @since 2023-12-11
|
|
*/
|
|
*/
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/tLocationCheck")
|
|
@RequestMapping("/tLocationCheck")
|
|
@@ -46,52 +47,26 @@ public class TLocationCheckController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- @ApiOperation(value = "根据ip校验clientId设备位置")
|
|
|
|
- @PostMapping("/ipCheck")
|
|
|
|
- public ResponseModel<?> ipCheck(@RequestParam String clientId, @RequestParam String ip) throws IOException {
|
|
|
|
- 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("生产部未录入改设备的位置信息");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- String s = WhoIsUtil.getLocByIp(ip);
|
|
|
|
-
|
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
- JsonNode jsonNode = objectMapper.readTree(s);
|
|
|
|
- String pro = jsonNode.get("pro").asText();
|
|
|
|
- String proCode = jsonNode.get("proCode").asText();
|
|
|
|
- String city = jsonNode.get("city").asText();
|
|
|
|
- String cityCode = jsonNode.get("cityCode").asText();
|
|
|
|
- String region = jsonNode.get("region").asText();
|
|
|
|
- String regionCode = jsonNode.get("regionCode").asText();
|
|
|
|
- String regionNames = jsonNode.get("regionNames").asText();
|
|
|
|
- String addr = jsonNode.get("addr").asText();
|
|
|
|
- String err = jsonNode.get("err").asText();
|
|
|
|
-
|
|
|
|
- locationCheck.setIp(ip);
|
|
|
|
- locationCheck.setPro(pro);
|
|
|
|
- locationCheck.setProCode(proCode);
|
|
|
|
- locationCheck.setCity(city);
|
|
|
|
- locationCheck.setCityCode(cityCode);
|
|
|
|
- locationCheck.setRegion(region);
|
|
|
|
- locationCheck.setRegionCode(regionCode);
|
|
|
|
- locationCheck.setRegionNames(regionNames);
|
|
|
|
- locationCheck.setAddr(addr);
|
|
|
|
- locationCheck.setErr(err);
|
|
|
|
-
|
|
|
|
- locationCheckService.saveOrUpdate(locationCheck);
|
|
|
|
-
|
|
|
|
- String result = locationCheckService.locCheckMsg(locationCheck, clientId, ip, s);
|
|
|
|
-
|
|
|
|
- return R.ok(result);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+// @ApiOperation(value = "根据ip校验clientId设备位置")
|
|
|
|
+// @PostMapping("/ipCheck")
|
|
|
|
+// public ResponseModel<?> ipCheck(@RequestParam String clientId, @RequestParam String ip) throws IOException {
|
|
|
|
+// 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("生产部未录入改设备的位置信息");
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// String s = WhoIsUtil.getLocByIp(ip);
|
|
|
|
+//
|
|
|
|
+// String result = locationCheckService.locCheckMsg(locationCheck, clientId, ip, s);
|
|
|
|
+//
|
|
|
|
+// return R.ok(result);
|
|
|
|
+// }
|
|
|
|
|
|
@ApiOperation(value = "修改录入的位置信息")
|
|
@ApiOperation(value = "修改录入的位置信息")
|
|
@PostMapping("/updateLocInfo")
|
|
@PostMapping("/updateLocInfo")
|
|
@@ -99,41 +74,60 @@ public class TLocationCheckController {
|
|
if (Objects.isNull(locationCheck)) {
|
|
if (Objects.isNull(locationCheck)) {
|
|
return R.fail("参数不能为空");
|
|
return R.fail("参数不能为空");
|
|
}
|
|
}
|
|
-// String phone = locationCheck.getPhone();
|
|
|
|
-// String username = locationCheck.getUsername();
|
|
|
|
-// String clientId = locationCheck.getClientId();
|
|
|
|
-// String name = locationCheck.getName();
|
|
|
|
-// String location = locationCheck.getLocation();
|
|
|
|
-// String country = locationCheck.getCountry();
|
|
|
|
-//
|
|
|
|
-// if (Objects.isNull(clientId)) {
|
|
|
|
-// return R.fail("设备唯一码不能为空");
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
|
|
+
|
|
|
|
+ // 售后部同事修改的信息:姓名,电话,username,clientId,国家
|
|
|
|
+ String modName = locationCheck.getModName();
|
|
|
|
+// String modUsername = locationCheck.getModUsername();
|
|
|
|
+ String modPhone = locationCheck.getModPhone();
|
|
|
|
+ String clientId = locationCheck.getClientId();
|
|
|
|
+ String location = locationCheck.getLocation();
|
|
|
|
+ String country = locationCheck.getCountry();
|
|
|
|
+
|
|
|
|
+ if (Objects.isNull(clientId)) {
|
|
|
|
+ return R.fail("设备唯一码不能为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (country.equals("中国")) {
|
|
|
|
+ if (StringUtils.isEmpty(location)) {
|
|
|
|
+ return R.fail("国内省市不能为空");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// LambdaQueryWrapper<TAdmin> lqw = Wrappers.lambdaQuery();
|
|
// LambdaQueryWrapper<TAdmin> lqw = Wrappers.lambdaQuery();
|
|
-// lqw.eq(TAdmin::getUsername, username);
|
|
|
|
-// TAdmin admin = adminService.getOne(lqw);
|
|
|
|
-// if (Objects.isNull(admin)) {
|
|
|
|
-// return R.fail("adminId账号不存在");
|
|
|
|
|
|
+// lqw.eq(TAdmin::getUsername, modUsername);
|
|
|
|
+// TAdmin modAdmin = adminService.getOne(lqw);
|
|
|
|
+// if (Objects.isNull(modAdmin)) {
|
|
|
|
+// return R.fail("modAdmin账号不存在");
|
|
// }
|
|
// }
|
|
-//
|
|
|
|
-// LambdaQueryWrapper<TLocationCheck> wrapper = Wrappers.lambdaQuery();
|
|
|
|
-// wrapper.eq(TLocationCheck::getClientId,clientId);
|
|
|
|
-// List<TLocationCheck> checks = locationCheckService.list(wrapper);
|
|
|
|
-// TLocationCheck tLocationCheck = checks.get(0);
|
|
|
|
-//
|
|
|
|
-//
|
|
|
|
-//
|
|
|
|
-// Long adminId = admin.getId();
|
|
|
|
-//// String phone1 = admin.getPhone();
|
|
|
|
-//// if (!Objects.equals(phone1, phone)) {
|
|
|
|
-//// return R.fail("手机号码有误");
|
|
|
|
-//// }
|
|
|
|
-// String name1 = admin.getName();
|
|
|
|
-// if (!Objects.equals(name1, name)) {
|
|
|
|
|
|
+
|
|
|
|
+ LambdaQueryWrapper<TLocationCheck> wrapper = Wrappers.lambdaQuery();
|
|
|
|
+ wrapper.eq(TLocationCheck::getClientId, clientId);
|
|
|
|
+ List<TLocationCheck> checks = locationCheckService.list(wrapper);
|
|
|
|
+ TLocationCheck tLocationCheck = checks.get(0);
|
|
|
|
+
|
|
|
|
+// Long modAdminId = modAdmin.getId();
|
|
|
|
+// String phone1 = modAdmin.getPhone();
|
|
|
|
+// String name1 = modAdmin.getName();
|
|
|
|
+// if (!Objects.equals(phone1, modPhone)) {
|
|
|
|
+// return R.fail("手机号码有误");
|
|
|
|
+// }
|
|
|
|
+// if (!Objects.equals(name1, modName)) {
|
|
// return R.fail("姓名有误");
|
|
// return R.fail("姓名有误");
|
|
// }
|
|
// }
|
|
-return R.ok();
|
|
|
|
|
|
+
|
|
|
|
+ tLocationCheck.setModifyTime(new Date());
|
|
|
|
+ tLocationCheck.setModName(modName);
|
|
|
|
+// tLocationCheck.setModAdminId(modAdminId);
|
|
|
|
+ tLocationCheck.setModPhone(modPhone);
|
|
|
|
+// tLocationCheck.setModUsername(modUsername);
|
|
|
|
+ tLocationCheck.setLocation(location);
|
|
|
|
+ tLocationCheck.setClientId(clientId);
|
|
|
|
+ tLocationCheck.setCountry(country);
|
|
|
|
+
|
|
|
|
+ locationCheckService.updateById(tLocationCheck);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return R.ok("修改成功");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -180,6 +174,7 @@ return R.ok();
|
|
// String uuid = IdUtil.randomUUID();
|
|
// String uuid = IdUtil.randomUUID();
|
|
String uuid = IdUtil.simpleUUID();
|
|
String uuid = IdUtil.simpleUUID();
|
|
tLocationCheck.setId(uuid);
|
|
tLocationCheck.setId(uuid);
|
|
|
|
+ tLocationCheck.setCreateTime(new Date());
|
|
tLocationCheck.setAdminId(adminId);
|
|
tLocationCheck.setAdminId(adminId);
|
|
tLocationCheck.setPhone(phone);
|
|
tLocationCheck.setPhone(phone);
|
|
tLocationCheck.setUsername(username);
|
|
tLocationCheck.setUsername(username);
|