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);
......
...@@ -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