Commit 93f564cd authored by chenying's avatar chenying

5.25网关关联公司

parent 07e123ac
......@@ -13,6 +13,16 @@ public class ResultGatewayVo {
private Integer useScene;
private String companyName;
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getSN() {
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;
import com.example.tdl.domain.vo.GatewaySNVo;
import com.example.tdl.domain.vo.GatewayState;
import com.example.tdl.domain.vo.ResultGatewayVo;
import com.example.tdl.domain.vo.UpdateGatewayVo;
import com.example.tdl.domain.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -12,7 +9,9 @@ import java.util.Map;
@Mapper
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);
......@@ -22,15 +21,15 @@ public interface GatewayMapper {
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);
String getBySN(String SN);
Integer updateState(GatewayState gatewayState);
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 {
@Autowired
private GatewayMapper gatewayMapper;
public List<ResultGatewayVo> getAll(){
return gatewayMapper.getAll();
public List<ResultGatewayVo> getAll(String companyNo){
return gatewayMapper.getAll(companyNo);
}
public String getBySN(String SN,String companyNo){
return gatewayMapper.getBySN(SN,companyNo);
}
public int addGateway(Map<Object,Object> map){
......@@ -35,18 +39,14 @@ public class GatewayService {
return gatewayMapper.getBySNAndType(SN,type);
}
public int getIdBySNAndType(String SN,String type){
return gatewayMapper.getIdBySNAndType(SN,type);
public int getIdBySNAndType(String SN,String type,String companyNo){
return gatewayMapper.getIdBySNAndType(SN,type,companyNo);
}
public int deployGateway(Map<Object,Object> map){
return gatewayMapper.deployGateway(map);
}
public String getBySN(String SN){
return gatewayMapper.getBySN(SN);
}
public Boolean updateState(GatewayState gatewayState){
return gatewayMapper.updateState(gatewayState)==1;
}
......@@ -55,7 +55,11 @@ public class GatewayService {
return gatewayMapper.getTransportationNo(SN,type);
}
public List<GatewaySNVo> getUnusedGateway(String SN){
return gatewayMapper.getUnusedGateway(SN);
public List<GatewaySNVo> getUnusedGateway(String SN,String companyNo){
return gatewayMapper.getUnusedGateway(SN,companyNo);
}
public int updateCompany(UpdateGatewayCompanyVo updateGatewayCompanyVo){
return gatewayMapper.updateCompany(updateGatewayCompanyVo);
}
}
......@@ -792,7 +792,7 @@ public class CircuitController {
compTimeVar = compTimeVar +addCircuitVo.getEndAddressVo().getCompTime() +"&";
startTimeVar =startTimeVar + "0&";
arrivalTimeVar = arrivalTimeVar +"0&";
String type =gatewayService.getBySN(addCircuitVo.getSN());
String type =gatewayService.getBySN(addCircuitVo.getSN(),user.getCompanyNo());
//判断当前gateWay是否存在
if(StringUtils.isEmpty(type)){
fb.setCode(0);
......
......@@ -251,6 +251,9 @@ public class EquipmentBindingController {
})
@PostMapping("/untieGateway")
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())){
fb.setCode(0);
fb.setMessage("仓库编号不能为空");
......@@ -266,7 +269,7 @@ public class EquipmentBindingController {
fb.setMessage("网关编号不能为空");
return gson.toJson(fb);
}
if( gatewayService.getBySN(addWarehouseGatewayVo.getSN())==null){
if( gatewayService.getBySN(addWarehouseGatewayVo.getSN(),user.getCompanyNo())==null){
fb.setCode(0);
fb.setMessage("该网关不存在");
return gson.toJson(fb);
......
......@@ -679,7 +679,7 @@ public class WarehouseController {
fb.setMessage("网关编号不能为空");
return gson.toJson(fb);
}
if( gatewayService.getBySN(addWarehouseGatewayVo.getSN())==null){
if( gatewayService.getBySN(addWarehouseGatewayVo.getSN(),user.getCompanyNo())==null){
fb.setCode(0);
fb.setMessage("该网关不存在");
return gson.toJson(fb);
......
......@@ -191,3 +191,20 @@ updateCarSuccess=\u8F66\u8F86\u4FEE\u6539\u6210\u529F
updateCarFailure=\u8F66\u8F86\u4FEE\u6539\u5931\u8D25
deleteCarSuccess=\u8F66\u8F86\u5220\u9664\u6210\u529F
deleteCarFailure=\u8F66\u8F86\u5220\u9664\u5931\u8D25
#\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"?>
<!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">
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultGatewayVo">
SELECT SN,name,type,state,bConfig,useScene
from gateway
<select id="getAll" parameterType="String" resultType="com.example.tdl.domain.vo.ResultGatewayVo">
SELECT SN,name,type,g.state,bConfig,useScene,companyName
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 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>
<insert id="addGateway" parameterType="java.util.Map" statementType="CALLABLE">
......@@ -19,6 +26,7 @@
#{type,mode=IN,jdbcType=VARCHAR},
#{createTime,mode=IN,jdbcType=BIGINT},
#{updateTime,mode=IN,jdbcType=BIGINT},
#{companyNo,mode=IN,jdbcType=VARCHAR},
#{modelName,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
......@@ -47,14 +55,18 @@
</delete>
<select id="getBySNAndType" parameterType="String" resultType="com.example.tdl.domain.vo.ResultGatewayVo">
SELECT SN,name,type,state,bConfig,useScene
from gateway WHERE SN=#{SN,jdbcType=VARCHAR}
SELECT SN,name,type,g.state,bConfig,useScene,companyName
from gateway g INNER JOIN company c on g.company_id=c.id
WHERE SN=#{SN,jdbcType=VARCHAR}
AND type=#{type,jdbcType=VARCHAR}
</select>
<select id="getIdBySNAndType" parameterType="String" resultType="java.lang.Integer">
SELECT id from gateway WHERE SN=#{SN,jdbcType=VARCHAR}
AND type=#{type,jdbcType=VARCHAR}
<if test="companyNo!='TM201803298320'">
AND companyNo=#{companyNo,jdbcType=VARCHAR}
</if>
</select>
<update id="deployGateway" parameterType="java.util.Map" statementType="CALLABLE">
......@@ -77,18 +89,25 @@
</update>
<select id="getTransportationNo" parameterType="String" resultType="String">
select transportationNo from circuit where id = (select circuit_id from tdldevice
select transportationNo from circuit
where id = (select circuit_id from tdldevice
where gateway_id =(SELECT id from gateway where SN=#{SN,jdbcType=VARCHAR}
AND type=#{type,jdbcType=VARCHAR}))
</select>
<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}), '%')
and useScene = 0
and state = 1
and g.state = 1
AND companyNo=#{companyNo,jdbcType=VARCHAR}
</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 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