Commit 3c6b25d7 authored by zhuangzhuang's avatar zhuangzhuang

4.16-增加获取登陆ip接口

parent 162ac3ef
......@@ -6,12 +6,16 @@ public class UserNameVo {
private String time;
private String ipAddress;
public UserNameVo() {
}
public UserNameVo(String userName, String time) {
public UserNameVo(String userName, String time, String ipAddress) {
UserName = userName;
this.time = time;
this.ipAddress = ipAddress;
}
public String getUserName() {
......@@ -29,4 +33,12 @@ public class UserNameVo {
public void setTime(String time) {
this.time = time;
}
public String getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
}
......@@ -943,14 +943,14 @@ public class CircuitController {
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=(String)jsonObject.get("transportationNo");
if (circuitService.getByTransportationNo(transportationNo,user.getCompanyName())==null){
if (StringUtils.isEmpty(transportationNo)){
fb.setCode(0);
fb.setMessage("没有该线路");
fb.setMessage("运输编号不能为空");
return gson.toJson(fb);
}
if (StringUtils.isEmpty(transportationNo)){
if (circuitService.getByTransportationNo(transportationNo,user.getCompanyName())==null){
fb.setCode(0);
fb.setMessage("需要删除的运输编号不能为空");
fb.setMessage("没有该线路");
return gson.toJson(fb);
}
if (circuitService.getByTransportationNo(transportationNo,user.getCompanyName()).getCircuitState()!=0){
......@@ -958,13 +958,50 @@ public class CircuitController {
fb.setMessage("该线路在运输中或已经完成运输");
return gson.toJson(fb);
}
int a = circuitService.delCircuit(transportationNo);
if (a>0){
fb.setCode(1);
fb.setMessage("删除线路成功");
}else{
fb.setCode(0);
fb.setMessage("删除线路失败");
TDLLogVo tdlLogVo = tdlLogService.getByTransportationNo(transportationNo);
if(tdlLogVo != null){
List<String> dev = tdlLogService.getTdlSN(transportationNo);
List<String> devList = tdlDeviceService.getByGatewaySN(tdlLogVo.getgSN(),tdlLogVo.getgType());
String tdl = tdlDeviceService.getTdl(tdlLogVo.getgSN(),tdlLogVo.getgType());
ConfigCMDVo configCMDVo;
ConfigVo configVo =configService.getConfig(tdlLogVo.getgSN(),tdlLogVo.getgType());
ConfigCMDVo config = gson.fromJson(configVo.getMessage(),ConfigCMDVo.class);
if(tdl.equals(tdlLogVo.getTDLSN())){
configCMDVo = new ConfigCMDVo();
}else{
devList.remove(dev);
configCMDVo = new ConfigCMDVo("config",config.getGpsPeriod(),config.getGprsPeriod(),devList,config.getMode(),System.currentTimeMillis()/1000l);
}
//解绑gateway和tdl
Map<Object,Object> map=new HashMap<>();
map.put("gSN",tdlLogVo.getgSN());
map.put("gType",tdlLogVo.getgType());
map.put("message",gson.toJson(configCMDVo));
map.put("untie",true);
map.put("TDLSN",dev.get(0).replace("TDL-","").trim());
map.put("endTime",0);
configService.updateConfig(map);
Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg"));
if (msg.get("msg").equals("解除网关成功")){
fb.setCode(1);
fb.setMessage(msg.get("msg").toString());
String key ="TDL/"+tdlLogVo.getgType()+"/" +tdlLogVo.getgSN() +"/Data";
alarmRedisService.delKey(key);
}else{
fb.setCode(0);
fb.setMessage(msg.get("msg").toString());
}
}else {
int a = circuitService.delCircuit(transportationNo);
if (a > 0) {
fb.setCode(1);
fb.setMessage("删除线路成功");
} else {
fb.setCode(0);
fb.setMessage("删除线路失败");
}
}
return gson.toJson(fb);
}
......
......@@ -21,8 +21,17 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.w3c.dom.NodeList;
import javax.servlet.http.HttpServletRequest;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.Node;
import java.net.URL;
import java.util.List;
......@@ -336,7 +345,7 @@ public class UserController {
//修改密码
@ApiOperation(value = "修改密码",notes = "修改密码")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value="/updatePassword",method = RequestMethod.POST)
public Object updatePassword(@RequestBody UpdatePasswordVo updatePasswordVo){
......@@ -369,10 +378,12 @@ public class UserController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@GetMapping(value="/getUserName")
public Object getUserName(HttpServletRequest request){
public Object getUserName(HttpServletRequest request) {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
return new UserNameVo(gson.fromJson(datum,UserRedisVo.class).getUserName(),System.currentTimeMillis()+"");
String datum = tokenRedisService.get("TOKEN_" + token);
//获取当前登录者的天气
String ip = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getRemoteAddr();
return new UserNameVo(gson.fromJson(datum,UserRedisVo.class).getUserName(),System.currentTimeMillis() +"",ip);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment