Commit 93f564cd authored by chenying's avatar chenying

5.25网关关联公司

parent 07e123ac
...@@ -13,6 +13,16 @@ public class ResultGatewayVo { ...@@ -13,6 +13,16 @@ public class ResultGatewayVo {
private Integer useScene; private Integer useScene;
private String companyName;
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getSN() { public String getSN() {
return SN; return SN;
} }
......
package com.example.tdl.domain.vo;
public class UpdateGatewayCompanyVo {
private String SN;
private String type;
private String companyNo;
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCompanyNo() {
return companyNo;
}
public void setCompanyNo(String companyNo) {
this.companyNo = companyNo;
}
}
package com.example.tdl.mapper; package com.example.tdl.mapper;
import com.example.tdl.domain.vo.GatewaySNVo; import com.example.tdl.domain.vo.*;
import com.example.tdl.domain.vo.GatewayState;
import com.example.tdl.domain.vo.ResultGatewayVo;
import com.example.tdl.domain.vo.UpdateGatewayVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -12,7 +9,9 @@ import java.util.Map; ...@@ -12,7 +9,9 @@ import java.util.Map;
@Mapper @Mapper
public interface GatewayMapper { public interface GatewayMapper {
List<ResultGatewayVo> getAll(); List<ResultGatewayVo> getAll(@Param("companyNo") String companyNo);
String getBySN(@Param("SN") String SN,@Param("companyNo") String companyNo);
int addGateway(Map<Object,Object> map); int addGateway(Map<Object,Object> map);
...@@ -22,15 +21,15 @@ public interface GatewayMapper { ...@@ -22,15 +21,15 @@ public interface GatewayMapper {
ResultGatewayVo getBySNAndType(@Param("SN") String SN,@Param("type") String type); ResultGatewayVo getBySNAndType(@Param("SN") String SN,@Param("type") String type);
int getIdBySNAndType(@Param("SN") String SN,@Param("type") String type); int getIdBySNAndType(@Param("SN") String SN,@Param("type") String type,@Param("companyNo") String companyNo);
int deployGateway(Map<Object,Object> map); int deployGateway(Map<Object,Object> map);
String getBySN(String SN);
Integer updateState(GatewayState gatewayState); Integer updateState(GatewayState gatewayState);
String getTransportationNo(@Param("SN") String SN,@Param("type") String type); String getTransportationNo(@Param("SN") String SN,@Param("type") String type);
List<GatewaySNVo> getUnusedGateway(String SN); List<GatewaySNVo> getUnusedGateway(@Param("SN") String SN,@Param("companyNo") String companyNo);
int updateCompany(UpdateGatewayCompanyVo updateGatewayCompanyVo);
} }
...@@ -15,8 +15,12 @@ public class GatewayService { ...@@ -15,8 +15,12 @@ public class GatewayService {
@Autowired @Autowired
private GatewayMapper gatewayMapper; private GatewayMapper gatewayMapper;
public List<ResultGatewayVo> getAll(){ public List<ResultGatewayVo> getAll(String companyNo){
return gatewayMapper.getAll(); return gatewayMapper.getAll(companyNo);
}
public String getBySN(String SN,String companyNo){
return gatewayMapper.getBySN(SN,companyNo);
} }
public int addGateway(Map<Object,Object> map){ public int addGateway(Map<Object,Object> map){
...@@ -35,18 +39,14 @@ public class GatewayService { ...@@ -35,18 +39,14 @@ public class GatewayService {
return gatewayMapper.getBySNAndType(SN,type); return gatewayMapper.getBySNAndType(SN,type);
} }
public int getIdBySNAndType(String SN,String type){ public int getIdBySNAndType(String SN,String type,String companyNo){
return gatewayMapper.getIdBySNAndType(SN,type); return gatewayMapper.getIdBySNAndType(SN,type,companyNo);
} }
public int deployGateway(Map<Object,Object> map){ public int deployGateway(Map<Object,Object> map){
return gatewayMapper.deployGateway(map); return gatewayMapper.deployGateway(map);
} }
public String getBySN(String SN){
return gatewayMapper.getBySN(SN);
}
public Boolean updateState(GatewayState gatewayState){ public Boolean updateState(GatewayState gatewayState){
return gatewayMapper.updateState(gatewayState)==1; return gatewayMapper.updateState(gatewayState)==1;
} }
...@@ -55,7 +55,11 @@ public class GatewayService { ...@@ -55,7 +55,11 @@ public class GatewayService {
return gatewayMapper.getTransportationNo(SN,type); return gatewayMapper.getTransportationNo(SN,type);
} }
public List<GatewaySNVo> getUnusedGateway(String SN){ public List<GatewaySNVo> getUnusedGateway(String SN,String companyNo){
return gatewayMapper.getUnusedGateway(SN); return gatewayMapper.getUnusedGateway(SN,companyNo);
}
public int updateCompany(UpdateGatewayCompanyVo updateGatewayCompanyVo){
return gatewayMapper.updateCompany(updateGatewayCompanyVo);
} }
} }
...@@ -792,7 +792,7 @@ public class CircuitController { ...@@ -792,7 +792,7 @@ public class CircuitController {
compTimeVar = compTimeVar +addCircuitVo.getEndAddressVo().getCompTime() +"&"; compTimeVar = compTimeVar +addCircuitVo.getEndAddressVo().getCompTime() +"&";
startTimeVar =startTimeVar + "0&"; startTimeVar =startTimeVar + "0&";
arrivalTimeVar = arrivalTimeVar +"0&"; arrivalTimeVar = arrivalTimeVar +"0&";
String type =gatewayService.getBySN(addCircuitVo.getSN()); String type =gatewayService.getBySN(addCircuitVo.getSN(),user.getCompanyNo());
//判断当前gateWay是否存在 //判断当前gateWay是否存在
if(StringUtils.isEmpty(type)){ if(StringUtils.isEmpty(type)){
fb.setCode(0); fb.setCode(0);
......
...@@ -251,6 +251,9 @@ public class EquipmentBindingController { ...@@ -251,6 +251,9 @@ public class EquipmentBindingController {
}) })
@PostMapping("/untieGateway") @PostMapping("/untieGateway")
public Object untieGateway(@RequestBody AddWarehouseGatewayVo addWarehouseGatewayVo,HttpServletRequest request){ public Object untieGateway(@RequestBody AddWarehouseGatewayVo addWarehouseGatewayVo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(StringUtils.isEmpty(addWarehouseGatewayVo.getWarehouseNo())){ if(StringUtils.isEmpty(addWarehouseGatewayVo.getWarehouseNo())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("仓库编号不能为空"); fb.setMessage("仓库编号不能为空");
...@@ -266,7 +269,7 @@ public class EquipmentBindingController { ...@@ -266,7 +269,7 @@ public class EquipmentBindingController {
fb.setMessage("网关编号不能为空"); fb.setMessage("网关编号不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if( gatewayService.getBySN(addWarehouseGatewayVo.getSN())==null){ if( gatewayService.getBySN(addWarehouseGatewayVo.getSN(),user.getCompanyNo())==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该网关不存在"); fb.setMessage("该网关不存在");
return gson.toJson(fb); return gson.toJson(fb);
......
...@@ -7,6 +7,7 @@ import com.example.tdl.domain.dto.CommFeedback; ...@@ -7,6 +7,7 @@ import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*; import com.example.tdl.domain.vo.*;
import com.example.tdl.service.*; import com.example.tdl.service.*;
import com.example.tdl.service.redis.InfoRedisService; import com.example.tdl.service.redis.InfoRedisService;
import com.example.tdl.service.redis.TokenRedisService;
import com.example.tdl.util.HttpRequester; import com.example.tdl.util.HttpRequester;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -57,6 +58,9 @@ public class GatewayController { ...@@ -57,6 +58,9 @@ public class GatewayController {
@Autowired @Autowired
private TopicConfigService topicConfigService; private TopicConfigService topicConfigService;
@Autowired
private TokenRedisService tokenRedisService;
@Autowired @Autowired
private I18nController i18n; private I18nController i18n;
...@@ -73,8 +77,11 @@ public class GatewayController { ...@@ -73,8 +77,11 @@ public class GatewayController {
@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="/getAll",method = RequestMethod.GET) @RequestMapping(value="/getAll",method = RequestMethod.GET)
public Object getAll(){ public Object getAll(HttpServletRequest request){
return gatewayService.getAll(); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
return gatewayService.getAll(user.getCompanyNo());
} }
//添加网关信息 //添加网关信息
...@@ -86,40 +93,43 @@ public class GatewayController { ...@@ -86,40 +93,43 @@ public class GatewayController {
@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="/addGateway",method = RequestMethod.POST) @RequestMapping(value="/addGateway",method = RequestMethod.POST)
public Object addGateway(@RequestBody AddGatewayVo addGatewayVo){ public Object addGateway(@RequestBody AddGatewayVo addGatewayVo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if (StringUtils.isEmpty(addGatewayVo.getSN())){ if (StringUtils.isEmpty(addGatewayVo.getSN())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("gateway编号不能为空"); fb.setMessage(i18n.getMessage(request,"gatewaySN"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if(!addGatewayVo.getSN().matches("^[0-9]{8}$")){ if(!addGatewayVo.getSN().matches("^[0-9]{8}$")){
fb.setCode(0); fb.setCode(0);
fb.setMessage("gateway编号必须是8位数字"); fb.setMessage(i18n.getMessage(request,"gatewaySNRule"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (StringUtils.isEmpty(addGatewayVo.getName())){ if (StringUtils.isEmpty(addGatewayVo.getName())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("gateway名字不能为空"); fb.setMessage(i18n.getMessage(request,"gatewayName"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (StringUtils.isEmpty(addGatewayVo.getType())){ if (StringUtils.isEmpty(addGatewayVo.getType())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("gateway类型不能为空"); fb.setMessage(i18n.getMessage(request,"gatewayType"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (StringUtils.isEmpty(addGatewayVo.getModelName())){ if (StringUtils.isEmpty(addGatewayVo.getModelName())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("gateway模板名不能为空"); fb.setMessage(i18n.getMessage(request,"gatewayModelName"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (modelService.getByModelName(addGatewayVo.getModelName())==null){ if (modelService.getByModelName(addGatewayVo.getModelName())==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该模板不存在"); fb.setMessage(i18n.getMessage(request,"existModelName"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (gatewayService.getBySNAndType(addGatewayVo.getSN(),addGatewayVo.getType())!=null){ if (gatewayService.getBySNAndType(addGatewayVo.getSN(),addGatewayVo.getType())!=null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("添加的网关已存在"); fb.setMessage(i18n.getMessage(request,"repeatedSN"));
return gson.toJson(fb); return gson.toJson(fb);
} }
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
...@@ -128,13 +138,14 @@ public class GatewayController { ...@@ -128,13 +138,14 @@ public class GatewayController {
map.put("type",addGatewayVo.getType()); map.put("type",addGatewayVo.getType());
map.put("createTime",System.currentTimeMillis()); map.put("createTime",System.currentTimeMillis());
map.put("updateTime",System.currentTimeMillis()); map.put("updateTime",System.currentTimeMillis());
map.put("companyNo",user.getCompanyNo());
map.put("modelName",addGatewayVo.getModelName()); map.put("modelName",addGatewayVo.getModelName());
gatewayService.addGateway(map); gatewayService.addGateway(map);
Map<Object,Object> msg=new HashMap<>(); Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg")); msg.put("msg",map.get("msg"));
if (msg.get("msg").equals("添加网关成功")){ if (msg.get("msg").equals("添加网关成功")){
fb.setCode(1); fb.setCode(1);
fb.setMessage("添加网关成功"); fb.setMessage(i18n.getMessage(request,"addGatewaySuccess"));
}else{ }else{
fb.setCode(0); fb.setCode(0);
fb.setMessage(msg.get("msg").toString()); fb.setMessage(msg.get("msg").toString());
...@@ -152,42 +163,36 @@ public class GatewayController { ...@@ -152,42 +163,36 @@ public class GatewayController {
@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="/updateGateway",method = RequestMethod.POST) @RequestMapping(value="/updateGateway",method = RequestMethod.POST)
public Object updateGateway(@RequestBody UpdateGatewayVo updateGatewayVo){ public Object updateGateway(@RequestBody UpdateGatewayVo updateGatewayVo,HttpServletRequest request){
if (StringUtils.isEmpty(updateGatewayVo.getSN())){ if (StringUtils.isEmpty(updateGatewayVo.getSN())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("编号不能为空"); fb.setMessage(i18n.getMessage(request,"gatewaySN"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (StringUtils.isEmpty(updateGatewayVo.getName())){ if (StringUtils.isEmpty(updateGatewayVo.getName())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("名字不能为空"); fb.setMessage(i18n.getMessage(request,"gatewayName"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (StringUtils.isEmpty(updateGatewayVo.getType())){ if (StringUtils.isEmpty(updateGatewayVo.getType())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("类型不能为空"); fb.setMessage(i18n.getMessage(request,"gatewayType"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (gatewayService.getBySNAndType(updateGatewayVo.getSN(),updateGatewayVo.getType())==null){ if (gatewayService.getBySNAndType(updateGatewayVo.getSN(),updateGatewayVo.getType())==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该网关不存在"); fb.setMessage(i18n.getMessage(request,"existGateway"));
return gson.toJson(fb); return gson.toJson(fb);
} }
// ResultGatewayVo resultGatewayVo=gatewayService.getBySNAndType(updateGatewayVo.getSN(),updateGatewayVo.getType());
// if (resultGatewayVo!=null&&updateGatewayVo.getSN().equals(updateGatewayVo.getOldSN())){
// fb.setCode(0);
// fb.setMessage("修改的设备已存在");
// return gson.toJson(fb);
// }
if (StringUtils.isEmpty(updateGatewayVo.getModelName())){ if (StringUtils.isEmpty(updateGatewayVo.getModelName())){
updateGatewayVo.setUpdateTime(System.currentTimeMillis()); updateGatewayVo.setUpdateTime(System.currentTimeMillis());
int a=gatewayService.updateGateway(updateGatewayVo); int a=gatewayService.updateGateway(updateGatewayVo);
if (a>0){ if (a>0){
fb.setCode(1); fb.setCode(1);
fb.setMessage("修改网关成功"); fb.setMessage(i18n.getMessage(request,"updateGatewaySuccess"));
}else{ }else{
fb.setCode(0); fb.setCode(0);
fb.setMessage("修改网关失败"); fb.setMessage(i18n.getMessage(request,"updateGatewayFailure"));
} }
}else { }else {
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
...@@ -199,7 +204,7 @@ public class GatewayController { ...@@ -199,7 +204,7 @@ public class GatewayController {
msg.put("msg",map.get("msg")); msg.put("msg",map.get("msg"));
if (msg.get("msg").equals("通过模板修改设备成功")){ if (msg.get("msg").equals("通过模板修改设备成功")){
fb.setCode(1); fb.setCode(1);
fb.setMessage("通过模板修改设备成功"); fb.setMessage(i18n.getMessage(request,"updateGatewayByModelSuccess"));
}else{ }else{
fb.setCode(0); fb.setCode(0);
fb.setMessage(msg.get("msg").toString()); fb.setMessage(msg.get("msg").toString());
...@@ -217,20 +222,20 @@ public class GatewayController { ...@@ -217,20 +222,20 @@ public class GatewayController {
@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="/delGateway",method = RequestMethod.POST) @RequestMapping(value="/delGateway",method = RequestMethod.POST)
public Object delGateway(@RequestBody DelGatewayVo delGatewayVo){ public Object delGateway(@RequestBody DelGatewayVo delGatewayVo,HttpServletRequest request){
if (StringUtils.isEmpty(delGatewayVo.getSN())){ if (StringUtils.isEmpty(delGatewayVo.getSN())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("删除的SN不能为空"); fb.setMessage(i18n.getMessage(request,"gatewaySN"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (StringUtils.isEmpty(delGatewayVo.getType())){ if (StringUtils.isEmpty(delGatewayVo.getType())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("删除的类型不能为空"); fb.setMessage(i18n.getMessage(request,"gatewayType"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (gatewayService.getBySNAndType(delGatewayVo.getSN(),delGatewayVo.getType())==null){ if (gatewayService.getBySNAndType(delGatewayVo.getSN(),delGatewayVo.getType())==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("删除的网关不存在"); fb.setMessage(i18n.getMessage(request,"existGateway"));
return gson.toJson(fb); return gson.toJson(fb);
} }
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
...@@ -241,7 +246,7 @@ public class GatewayController { ...@@ -241,7 +246,7 @@ public class GatewayController {
msg.put("msg",map.get("msg")); msg.put("msg",map.get("msg"));
if (msg.get("msg").equals("删除网关成功")){ if (msg.get("msg").equals("删除网关成功")){
fb.setCode(1); fb.setCode(1);
fb.setMessage("删除网关成功"); fb.setMessage(i18n.getMessage(request,"deleteGatewaySuccess"));
}else{ }else{
fb.setCode(0); fb.setCode(0);
fb.setMessage(msg.get("msg").toString()); fb.setMessage(msg.get("msg").toString());
...@@ -257,32 +262,32 @@ public class GatewayController { ...@@ -257,32 +262,32 @@ public class GatewayController {
@ApiImplicitParams({ @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"),
}) })
public String deployProbes(@RequestBody DeployProbesVo deployProbesVo){ public String deployProbes(@RequestBody DeployProbesVo deployProbesVo,HttpServletRequest request){
if(StringUtils.isEmpty(deployProbesVo.getModelName())){ if(StringUtils.isEmpty(deployProbesVo.getModelName())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("模板名不能为空"); fb.setMessage(i18n.getMessage(request,"gatewayModelName"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if(StringUtils.isEmpty(deployProbesVo.getSN())){ if(StringUtils.isEmpty(deployProbesVo.getSN())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("网关序列号不能为空"); fb.setMessage(i18n.getMessage(request,"gatewaySN"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if(StringUtils.isEmpty(deployProbesVo.getType())){ if(StringUtils.isEmpty(deployProbesVo.getType())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("网关类型不能为空"); fb.setMessage(i18n.getMessage(request,"gatewayType"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if(gatewayService.getBySNAndType(deployProbesVo.getSN(),deployProbesVo.getType())==null){ if(gatewayService.getBySNAndType(deployProbesVo.getSN(),deployProbesVo.getType())==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该网关不存在"); fb.setMessage(i18n.getMessage(request,"existGateway"));
return gson.toJson(fb); return gson.toJson(fb);
} }
//根据SN,type获取设备状态 //根据SN,type获取设备状态
boolean state = gatewayService.getBySNAndType(deployProbesVo.getSN(),deployProbesVo.getType()).getState(); boolean state = gatewayService.getBySNAndType(deployProbesVo.getSN(),deployProbesVo.getType()).getState();
if(state){ if(state){
fb.setCode(0); fb.setCode(0);
fb.setMessage("设备在挂载"); fb.setMessage(i18n.getMessage(request,"isUseing"));
return gson.toJson(fb); return gson.toJson(fb);
} }
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
...@@ -403,14 +408,56 @@ public class GatewayController { ...@@ -403,14 +408,56 @@ public class GatewayController {
}) })
@RequestMapping(value = "/getUnusedGateway",method = RequestMethod.POST) @RequestMapping(value = "/getUnusedGateway",method = RequestMethod.POST)
public Object getUnusedGateway(@RequestBody String gSN, HttpServletRequest request){ public Object getUnusedGateway(@RequestBody String gSN, HttpServletRequest request){
if(StringUtils.isEmpty(gSN)){ String token = request.getHeader("Account_token");
fb.setCode(0); String datum = tokenRedisService.get("TOKEN_" +token);
fb.setMessage(i18n.getMessage(request,"gateway")); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
return gson.toJson(fb); if(StringUtils.isEmpty(gSN)){
} fb.setCode(0);
JSONObject jsonObject= JSON.parseObject(gSN); fb.setMessage(i18n.getMessage(request,"gateway"));
gSN=(String)jsonObject.get("gSN"); return gson.toJson(fb);
return gatewayService.getUnusedGateway(gSN); }
JSONObject jsonObject= JSON.parseObject(gSN);
gSN=(String)jsonObject.get("gSN");
return gatewayService.getUnusedGateway(gSN,user.getCompanyNo());
}
//分配网关
@ApiOperation(value = "分配网关",notes = "分配网关,传值说明:" +
" SN:需要分配的网关序列号," +
" type:需要分配的网关类型," +
" companyNo:分配的公司编号。")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value = "/updateCompany",method = RequestMethod.POST)
public Object updateCompany(@RequestBody UpdateGatewayCompanyVo updateGatewayCompanyVo, HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if(StringUtils.isEmpty(updateGatewayCompanyVo.getCompanyNo())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"companyNo"));
return gson.toJson(fb);
}
if(StringUtils.isEmpty(updateGatewayCompanyVo.getSN())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"gatewaySN"));
return gson.toJson(fb);
}
if(StringUtils.isEmpty(updateGatewayCompanyVo.getType())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"gatewayType"));
return gson.toJson(fb);
}
int a=gatewayService.updateCompany(updateGatewayCompanyVo);
if (a>=0){
fb.setCode(1);
fb.setMessage(i18n.getMessage(request,"updateGatewayCompanySuccess"));
}else{
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"updateGatewayCompanyFailure"));
}
return gson.toJson(fb);
} }
} }
...@@ -679,7 +679,7 @@ public class WarehouseController { ...@@ -679,7 +679,7 @@ public class WarehouseController {
fb.setMessage("网关编号不能为空"); fb.setMessage("网关编号不能为空");
return gson.toJson(fb); return gson.toJson(fb);
} }
if( gatewayService.getBySN(addWarehouseGatewayVo.getSN())==null){ if( gatewayService.getBySN(addWarehouseGatewayVo.getSN(),user.getCompanyNo())==null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该网关不存在"); fb.setMessage("该网关不存在");
return gson.toJson(fb); return gson.toJson(fb);
......
...@@ -190,4 +190,21 @@ addCarFailure=\u8F66\u8F86\u6DFB\u52A0\u5931\u8D25 ...@@ -190,4 +190,21 @@ addCarFailure=\u8F66\u8F86\u6DFB\u52A0\u5931\u8D25
updateCarSuccess=\u8F66\u8F86\u4FEE\u6539\u6210\u529F updateCarSuccess=\u8F66\u8F86\u4FEE\u6539\u6210\u529F
updateCarFailure=\u8F66\u8F86\u4FEE\u6539\u5931\u8D25 updateCarFailure=\u8F66\u8F86\u4FEE\u6539\u5931\u8D25
deleteCarSuccess=\u8F66\u8F86\u5220\u9664\u6210\u529F deleteCarSuccess=\u8F66\u8F86\u5220\u9664\u6210\u529F
deleteCarFailure=\u8F66\u8F86\u5220\u9664\u5931\u8D25 deleteCarFailure=\u8F66\u8F86\u5220\u9664\u5931\u8D25
\ No newline at end of file #\u7F51\u5173
gatewaySN=\u7F51\u5173\u5E8F\u5217\u53F7\u4E0D\u80FD\u4E3A\u7A7A
gatewaySNRule=gateway\u7F16\u53F7\u5FC5\u987B\u662F8\u4F4D\u6570\u5B57
gatewayName=\u7F51\u5173\u540D\u4E0D\u80FD\u4E3A\u7A7A
gatewayType=\u7F51\u5173\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
gatewayModelName=\u7F51\u5173\u6A21\u677F\u540D\u4E0D\u80FD\u4E3A\u7A7A
existModelName=\u8BE5\u6A21\u677F\u4E0D\u5B58\u5728
repeatedSN=\u6DFB\u52A0\u7684\u7F51\u5173\u5DF2\u5B58\u5728
existGateway=\u8BE5\u7F51\u5173\u4E0D\u5B58\u5728
addGatewaySuccess=\u6DFB\u52A0\u7F51\u5173\u6210\u529F
updateGatewaySuccess=\u4FEE\u6539\u7F51\u5173\u6210\u529F
updateGatewayFailure=\u4FEE\u6539\u7F51\u5173\u5931\u8D25
updateGatewayByModelSuccess=\u901A\u8FC7\u6A21\u677F\u4FEE\u6539\u8BBE\u5907\u6210\u529F
deleteGatewaySuccess=\u5220\u9664\u7F51\u5173\u6210\u529F
isUseing=\u8BBE\u5907\u5728\u6302\u8F7D
updateGatewayCompanySuccess=\u7F51\u5173\u5206\u914D\u516C\u53F8\u6210\u529F
updateGatewayCompanyFailure=\u7F51\u5173\u5206\u914D\u516C\u53F8\u5931\u8D25
<?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.example.tdl.mapper.GatewayMapper"> <mapper namespace="com.example.tdl.mapper.GatewayMapper">
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultGatewayVo"> <select id="getAll" parameterType="String" resultType="com.example.tdl.domain.vo.ResultGatewayVo">
SELECT SN,name,type,state,bConfig,useScene SELECT SN,name,type,g.state,bConfig,useScene,companyName
from gateway from gateway g INNER JOIN company c on g.company_id=c.id
<if test="companyNo!='TM201803298320'">
WHERE companyNo=#{companyNo,jdbcType=VARCHAR}
</if>
</select> </select>
<select id="getBySN" resultType="String" parameterType="String"> <select id="getBySN" resultType="String" parameterType="String">
SELECT type from gateway where SN=#{SN,jdbcType=VARCHAR} SELECT type from gateway g INNER JOIN company c on g.company_id=c.id
where SN=#{SN,jdbcType=VARCHAR}
<if test="companyNo!='TM201803298320'">
WHERE companyNo=#{companyNo,jdbcType=VARCHAR}
</if>
</select> </select>
<insert id="addGateway" parameterType="java.util.Map" statementType="CALLABLE"> <insert id="addGateway" parameterType="java.util.Map" statementType="CALLABLE">
...@@ -19,6 +26,7 @@ ...@@ -19,6 +26,7 @@
#{type,mode=IN,jdbcType=VARCHAR}, #{type,mode=IN,jdbcType=VARCHAR},
#{createTime,mode=IN,jdbcType=BIGINT}, #{createTime,mode=IN,jdbcType=BIGINT},
#{updateTime,mode=IN,jdbcType=BIGINT}, #{updateTime,mode=IN,jdbcType=BIGINT},
#{companyNo,mode=IN,jdbcType=VARCHAR},
#{modelName,mode=IN,jdbcType=VARCHAR}, #{modelName,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR} #{msg,mode=OUT,jdbcType=VARCHAR}
) )
...@@ -47,14 +55,18 @@ ...@@ -47,14 +55,18 @@
</delete> </delete>
<select id="getBySNAndType" parameterType="String" resultType="com.example.tdl.domain.vo.ResultGatewayVo"> <select id="getBySNAndType" parameterType="String" resultType="com.example.tdl.domain.vo.ResultGatewayVo">
SELECT SN,name,type,state,bConfig,useScene SELECT SN,name,type,g.state,bConfig,useScene,companyName
from gateway WHERE SN=#{SN,jdbcType=VARCHAR} from gateway g INNER JOIN company c on g.company_id=c.id
WHERE SN=#{SN,jdbcType=VARCHAR}
AND type=#{type,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR}
</select> </select>
<select id="getIdBySNAndType" parameterType="String" resultType="java.lang.Integer"> <select id="getIdBySNAndType" parameterType="String" resultType="java.lang.Integer">
SELECT id from gateway WHERE SN=#{SN,jdbcType=VARCHAR} SELECT id from gateway WHERE SN=#{SN,jdbcType=VARCHAR}
AND type=#{type,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR}
<if test="companyNo!='TM201803298320'">
AND companyNo=#{companyNo,jdbcType=VARCHAR}
</if>
</select> </select>
<update id="deployGateway" parameterType="java.util.Map" statementType="CALLABLE"> <update id="deployGateway" parameterType="java.util.Map" statementType="CALLABLE">
...@@ -77,18 +89,25 @@ ...@@ -77,18 +89,25 @@
</update> </update>
<select id="getTransportationNo" parameterType="String" resultType="String"> <select id="getTransportationNo" parameterType="String" resultType="String">
select transportationNo from circuit where id = (select circuit_id from tdldevice select transportationNo from circuit
where gateway_id =(SELECT id from gateway where SN=#{SN,jdbcType=VARCHAR} where id = (select circuit_id from tdldevice
AND type=#{type,jdbcType=VARCHAR})) where gateway_id =(SELECT id from gateway where SN=#{SN,jdbcType=VARCHAR}
AND type=#{type,jdbcType=VARCHAR}))
</select> </select>
<select id="getUnusedGateway" parameterType="String" resultType="com.example.tdl.domain.vo.GatewaySNVo"> <select id="getUnusedGateway" parameterType="String" resultType="com.example.tdl.domain.vo.GatewaySNVo">
select SN from gateway select SN from gateway g INNER JOIN company c ON g.company_id=c.id
where SN like CONCAT(CONCAT('%',#{SN,jdbcType=VARCHAR}), '%') where SN like CONCAT(CONCAT('%',#{SN,jdbcType=VARCHAR}), '%')
and useScene = 0 and useScene = 0
and state = 1 and g.state = 1
AND companyNo=#{companyNo,jdbcType=VARCHAR}
</select> </select>
<update id="updateCompany" parameterType="com.example.tdl.domain.vo.UpdateGatewayCompanyVo">
UPDATE gateway set company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
WHERE SN=#{SN,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR}
</update>
<!-- <insert id="addGateway" parameterType="com.example.tdl.domain.vo.AddGatewayVo"> <!-- <insert id="addGateway" parameterType="com.example.tdl.domain.vo.AddGatewayVo">
INSERT into gateway VALUES ( INSERT into gateway VALUES (
......
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