Commit d914c49e authored by chenying's avatar chenying

5.25tdl关联公司

parent 93f564cd
...@@ -5,6 +5,16 @@ public class AddTDLDeviceVo { ...@@ -5,6 +5,16 @@ public class AddTDLDeviceVo {
private String TDLSN; private String TDLSN;
private String companyNo;
public String getCompanyNo() {
return companyNo;
}
public void setCompanyNo(String companyNo) {
this.companyNo = companyNo;
}
public String getTDLName() { public String getTDLName() {
return TDLName; return TDLName;
} }
......
...@@ -7,6 +7,16 @@ public class TDLDeviceTermVo { ...@@ -7,6 +7,16 @@ public class TDLDeviceTermVo {
private Integer useScene; private Integer useScene;
private String companyNo;
public String getCompanyNo() {
return companyNo;
}
public void setCompanyNo(String companyNo) {
this.companyNo = companyNo;
}
public String getTDLName() { public String getTDLName() {
return TDLName; return TDLName;
} }
......
...@@ -9,7 +9,7 @@ import java.util.List; ...@@ -9,7 +9,7 @@ import java.util.List;
@Mapper @Mapper
public interface TDLDeviceMapper { public interface TDLDeviceMapper {
List<ResultTDLDeviceVo> getAll(); List<ResultTDLDeviceVo> getAll(@Param("companyNo") String companyNo);
List<ResultTDLDeviceVo> getByTerm(TDLDeviceTermVo tdlDeviceTermVo); List<ResultTDLDeviceVo> getByTerm(TDLDeviceTermVo tdlDeviceTermVo);
...@@ -27,7 +27,9 @@ public interface TDLDeviceMapper { ...@@ -27,7 +27,9 @@ public interface TDLDeviceMapper {
String getTdl(@Param("SN") String SN, @Param("type") String type); String getTdl(@Param("SN") String SN, @Param("type") String type);
List<TdlSNVo> getUnusedTDL(String TDLSN); List<TdlSNVo> getUnusedTDL(@Param("TDLSN") String TDLSN,@Param("companyNo") String companyNo);
ResultTDLDeviceVo getByTransportationNo(String transportationNo); ResultTDLDeviceVo getByTransportationNo(String transportationNo);
int updateCompany(@Param("TDLSN") String TDLSN,@Param("companyNo") String companyNo);
} }
...@@ -12,8 +12,8 @@ public class TDLDeviceService { ...@@ -12,8 +12,8 @@ public class TDLDeviceService {
@Autowired @Autowired
private TDLDeviceMapper tdlDeviceMapper; private TDLDeviceMapper tdlDeviceMapper;
public List<ResultTDLDeviceVo> getAll(){ public List<ResultTDLDeviceVo> getAll(String companyNo){
return tdlDeviceMapper.getAll(); return tdlDeviceMapper.getAll(companyNo);
} }
public List<ResultTDLDeviceVo> getByTerm(TDLDeviceTermVo tdlDeviceTermVo){ public List<ResultTDLDeviceVo> getByTerm(TDLDeviceTermVo tdlDeviceTermVo){
...@@ -48,12 +48,16 @@ public class TDLDeviceService { ...@@ -48,12 +48,16 @@ public class TDLDeviceService {
return tdlDeviceMapper.getTdl(SN,type); return tdlDeviceMapper.getTdl(SN,type);
} }
public List<TdlSNVo> getUnusedTDL(String TDLSN){ public List<TdlSNVo> getUnusedTDL(String TDLSN,String companyNo){
return tdlDeviceMapper.getUnusedTDL(TDLSN); return tdlDeviceMapper.getUnusedTDL(TDLSN,companyNo);
} }
public ResultTDLDeviceVo getByTransportationNo(String transportationNo){ public ResultTDLDeviceVo getByTransportationNo(String transportationNo){
return tdlDeviceMapper.getByTransportationNo(transportationNo); return tdlDeviceMapper.getByTransportationNo(transportationNo);
} }
public int updateCompany(String TDLSN,String companyNo){
return tdlDeviceMapper.updateCompany(TDLSN,companyNo);
}
} }
...@@ -54,17 +54,21 @@ public class TDLDeviceController { ...@@ -54,17 +54,21 @@ public class TDLDeviceController {
" warehouseName:仓库名," + " warehouseName:仓库名," +
" transportationNo:运输编号," + " transportationNo:运输编号," +
" gatewaySN:网关序列号," + " gatewaySN:网关序列号," +
" gatewayType:网关类型。" ) " gatewayType:网关类型," +
" companyName:公司名。" )
@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"),
}) })
@RequestMapping(value="/getAll",method = RequestMethod.GET) @RequestMapping(value="/getAll",method = RequestMethod.GET)
public Object getAll(){ public Object getAll(HttpServletRequest request){
return tdlDeviceService.getAll(); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
return tdlDeviceService.getAll(user.getCompanyNo());
} }
//根据条件查询TDL信息 //根据条件查询TDL信息
@ApiOperation(value = "根据条件查询TDL信息",notes = "根据条件查询TDL信息,传值说明:" + @ApiOperation(value = "根据条件查询TDL信息",notes = "根据条件查询TDL信息,companyNo不用传,传值说明:" +
" TDLName:TDL名字," + " TDLName:TDL名字," +
" TDLSN:TDL序列号," + " TDLSN:TDL序列号," +
" useScene:使用场景(0为空闲,1为仓库,2为运输)。" + " useScene:使用场景(0为空闲,1为仓库,2为运输)。" +
...@@ -82,19 +86,26 @@ public class TDLDeviceController { ...@@ -82,19 +86,26 @@ public class TDLDeviceController {
@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="/getByTerm",method = RequestMethod.POST) @RequestMapping(value="/getByTerm",method = RequestMethod.POST)
public Object getByTerm(@RequestBody TDLDeviceTermVo tdlDeviceTermVo){ public Object getByTerm(@RequestBody TDLDeviceTermVo tdlDeviceTermVo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
tdlDeviceTermVo.setCompanyNo(user.getCompanyNo());
return tdlDeviceService.getByTerm(tdlDeviceTermVo); return tdlDeviceService.getByTerm(tdlDeviceTermVo);
} }
//添加TDL信息 //添加TDL信息
@ApiOperation(value = "添加TDL信息",notes = "添加TDL信息,传值说明:" + @ApiOperation(value = "添加TDL信息",notes = "添加TDL信息,companyNo不用传,传值说明:" +
" TDLName:TDL名字," + " TDLName:TDL名字," +
" TDLSN:TDL序列号") " TDLSN:TDL序列号")
@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"),
}) })
@RequestMapping(value="/addTDLDevice",method = RequestMethod.POST) @RequestMapping(value="/addTDLDevice",method = RequestMethod.POST)
public Object addTDLDevice(@RequestBody AddTDLDeviceVo addTDLDeviceVo){ public Object addTDLDevice(@RequestBody AddTDLDeviceVo addTDLDeviceVo,HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if (StringUtils.isEmpty(addTDLDeviceVo.getTDLName())){ if (StringUtils.isEmpty(addTDLDeviceVo.getTDLName())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("TDL名称不能为空"); fb.setMessage("TDL名称不能为空");
...@@ -110,6 +121,7 @@ public class TDLDeviceController { ...@@ -110,6 +121,7 @@ public class TDLDeviceController {
fb.setMessage("添加的TDL序列号已存在"); fb.setMessage("添加的TDL序列号已存在");
return gson.toJson(fb); return gson.toJson(fb);
} }
addTDLDeviceVo.setCompanyNo(user.getCompanyNo());
int a = tdlDeviceService.addTDLDevice(addTDLDeviceVo); int a = tdlDeviceService.addTDLDevice(addTDLDeviceVo);
if (a>0){ if (a>0){
fb.setCode(1); fb.setCode(1);
...@@ -129,25 +141,25 @@ public class TDLDeviceController { ...@@ -129,25 +141,25 @@ public class TDLDeviceController {
@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="/updateTDLDevice",method = RequestMethod.POST) @RequestMapping(value="/updateTDLDevice",method = RequestMethod.POST)
public Object updateTDLDevice(@RequestBody UpdateTDLDeviceVo updateTDLDeviceVo){ public Object updateTDLDevice(@RequestBody UpdateTDLDeviceVo updateTDLDeviceVo,HttpServletRequest request){
if (StringUtils.isEmpty(updateTDLDeviceVo.getTDLName())){ if (StringUtils.isEmpty(updateTDLDeviceVo.getTDLName())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("TDL名称不能为空"); fb.setMessage(i18n.getMessage(request,"TDLName"));
return gson.toJson(fb); return gson.toJson(fb);
} }
if (StringUtils.isEmpty(updateTDLDeviceVo.getTDLSN())){ if (StringUtils.isEmpty(updateTDLDeviceVo.getTDLSN())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("需要修改的TDL序列号不能为空"); fb.setMessage(i18n.getMessage(request,"TDLSN"));
return gson.toJson(fb); return gson.toJson(fb);
} }
int a = tdlDeviceService.updateTDLDevice(updateTDLDeviceVo); int a = tdlDeviceService.updateTDLDevice(updateTDLDeviceVo);
if (a>0){ if (a>0){
fb.setCode(1); fb.setCode(1);
fb.setMessage("修改TDL信息成功"); fb.setMessage(i18n.getMessage(request,"updateTDLSuccess"));
}else{ }else{
fb.setCode(0); fb.setCode(0);
fb.setMessage("修改TDL信息失败"); fb.setMessage(i18n.getMessage(request,"updateTDLFailure"));
} }
return gson.toJson(fb); return gson.toJson(fb);
} }
...@@ -159,21 +171,21 @@ public class TDLDeviceController { ...@@ -159,21 +171,21 @@ public class TDLDeviceController {
@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="/delTDLDevice",method = RequestMethod.POST) @RequestMapping(value="/delTDLDevice",method = RequestMethod.POST)
public Object delTDLDevice(@RequestBody String TDLSN){ public Object delTDLDevice(@RequestBody String TDLSN,HttpServletRequest request){
JSONObject jsonObject=JSON.parseObject(TDLSN); JSONObject jsonObject=JSON.parseObject(TDLSN);
TDLSN=(String)jsonObject.get("TDLSN"); TDLSN=(String)jsonObject.get("TDLSN");
if (StringUtils.isEmpty(TDLSN)){ if (StringUtils.isEmpty(TDLSN)){
fb.setCode(0); fb.setCode(0);
fb.setMessage("需要删除的TDL序列号不能为空"); fb.setMessage(i18n.getMessage(request,"TDLSN"));
return gson.toJson(fb); return gson.toJson(fb);
} }
int a = tdlDeviceService.delTDLDevice(TDLSN); int a = tdlDeviceService.delTDLDevice(TDLSN);
if (a>0){ if (a>0){
fb.setCode(1); fb.setCode(1);
fb.setMessage("删除TDL信息成功"); fb.setMessage(i18n.getMessage(request,"deleteTDLSuccess"));
}else{ }else{
fb.setCode(0); fb.setCode(0);
fb.setMessage("删除TDL信息失败"); fb.setMessage(i18n.getMessage(request,"deleteTDLFailure"));
} }
return gson.toJson(fb); return gson.toJson(fb);
...@@ -186,6 +198,9 @@ public class TDLDeviceController { ...@@ -186,6 +198,9 @@ public class TDLDeviceController {
}) })
@RequestMapping(value = "/getUnusedTDL",method = RequestMethod.POST) @RequestMapping(value = "/getUnusedTDL",method = RequestMethod.POST)
public Object getUnusedTDL(@RequestBody String TDLSN, HttpServletRequest request){ public Object getUnusedTDL(@RequestBody String TDLSN, HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
if (StringUtils.isEmpty(TDLSN)){ if (StringUtils.isEmpty(TDLSN)){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"tdl")); fb.setMessage(i18n.getMessage(request,"tdl"));
...@@ -193,6 +208,36 @@ public class TDLDeviceController { ...@@ -193,6 +208,36 @@ public class TDLDeviceController {
} }
JSONObject jsonObject=JSON.parseObject(TDLSN); JSONObject jsonObject=JSON.parseObject(TDLSN);
TDLSN=(String)jsonObject.get("TDLSN"); TDLSN=(String)jsonObject.get("TDLSN");
return tdlDeviceService.getUnusedTDL(TDLSN); return tdlDeviceService.getUnusedTDL(TDLSN,user.getCompanyNo());
}
//分配TDL
@ApiOperation(value = "分配TDL",notes = "分配TDL,传值说明:" +
" TDLSN:需要分配的网关序列号," +
" companyNo:分配的公司编号。")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value = "/updateCompany",method = RequestMethod.POST)
public Object updateCompany(@RequestBody String TDLSN, HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject=JSON.parseObject(TDLSN);
TDLSN=(String) jsonObject.get("TDLSN");
if(StringUtils.isEmpty(TDLSN)){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"TDLSN"));
return gson.toJson(fb);
}
int a=tdlDeviceService.updateCompany(TDLSN,user.getCompanyNo());
if (a>=0){
fb.setCode(1);
fb.setMessage(i18n.getMessage(request,"updateTDLCompanySuccess"));
}else{
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"updateTDLCompanyFailure"));
}
return gson.toJson(fb);
} }
} }
...@@ -208,3 +208,12 @@ deleteGatewaySuccess=\u5220\u9664\u7F51\u5173\u6210\u529F ...@@ -208,3 +208,12 @@ deleteGatewaySuccess=\u5220\u9664\u7F51\u5173\u6210\u529F
isUseing=\u8BBE\u5907\u5728\u6302\u8F7D isUseing=\u8BBE\u5907\u5728\u6302\u8F7D
updateGatewayCompanySuccess=\u7F51\u5173\u5206\u914D\u516C\u53F8\u6210\u529F updateGatewayCompanySuccess=\u7F51\u5173\u5206\u914D\u516C\u53F8\u6210\u529F
updateGatewayCompanyFailure=\u7F51\u5173\u5206\u914D\u516C\u53F8\u5931\u8D25 updateGatewayCompanyFailure=\u7F51\u5173\u5206\u914D\u516C\u53F8\u5931\u8D25
#TDL
TDLSN=TDL\u7F16\u53F7\u4E0D\u80FD\u4E3A\u7A7A
TDLName=TDL\u540D\u5B57\u4E0D\u80FD\u4E3A\u7A7A
updateTDLSuccess=\u4FEE\u6539\u7F51\u5173\u6210\u529F
updateTDLFailure=\u4FEE\u6539\u7F51\u5173\u5931\u8D25
deleteTDLSuccess=\u5220\u9664\u7F51\u5173\u6210\u529F
deleteTDLFailure=\u5220\u9664\u7F51\u5173\u5931\u8D25
updateTDLCompanySuccess=\u7F51\u5173\u5206\u914D\u516C\u53F8\u6210\u529F
updateTDLCompanyFailure=\u7F51\u5173\u5206\u914D\u516C\u53F8\u5931\u8D25
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
<!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.TDLDeviceMapper"> <mapper namespace="com.example.tdl.mapper.TDLDeviceMapper">
<!--查询所有TDL信息--> <!--查询所有TDL信息-->
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultTDLDeviceVo"> <select id="getAll" parameterType="String" resultType="com.example.tdl.domain.vo.ResultTDLDeviceVo">
SELECT TDLName,TDLSN,counts,lastTime,useScene,(SELECT warehouseName from warehouse WHERE id=t.warehouse_id) warehouseName, SELECT TDLName,TDLSN,counts,lastTime,useScene,(SELECT warehouseName from warehouse WHERE id=t.warehouse_id) warehouseName,
(SELECT transportationNo from circuit WHERE id=t.circuit_id) transportationNo,(SELECT SN from gateway WHERE id=t.gateway_id) gatewaySN, (SELECT transportationNo from circuit WHERE id=t.circuit_id) transportationNo,(SELECT SN from gateway WHERE id=t.gateway_id) gatewaySN,
(SELECT type from gateway WHERE id=t.gateway_id) gatewayType,companyName (SELECT type from gateway WHERE id=t.gateway_id) gatewayType,companyName
from tdldevice t INNER JOIN company c ON t.company_id=c.id from tdldevice t INNER JOIN company c ON t.company_id=c.id
AND companyName=#{companyName,jdbcType=VARCHAR} <if test="companyNo!='TM201803298320'">
AND companyNo=#{companyNo,jdbcType=VARCHAR}
</if>
</select> </select>
<!--根据条件查询--> <!--根据条件查询-->
...@@ -25,7 +27,9 @@ ...@@ -25,7 +27,9 @@
<if test="useScene!=null"> <if test="useScene!=null">
AND useScene=#{useScene,jdbcType=INTEGER} AND useScene=#{useScene,jdbcType=INTEGER}
</if> </if>
AND companyName=#{companyName,jdbcType=VARCHAR} <if test="companyNo!='TM201803298320'">
AND companyNo=#{companyNo,jdbcType=VARCHAR}
</if>
</select> </select>
<insert id="addTDLDevice" parameterType="com.example.tdl.domain.vo.AddTDLDeviceVo"> <insert id="addTDLDevice" parameterType="com.example.tdl.domain.vo.AddTDLDeviceVo">
...@@ -47,7 +51,6 @@ ...@@ -47,7 +51,6 @@
UPDATE TDLDevice SET UPDATE TDLDevice SET
TDLName=#{TDLName,jdbcType=VARCHAR} TDLName=#{TDLName,jdbcType=VARCHAR}
WHERE TDLSN=#{TDLSN,jdbcType=VARCHAR} WHERE TDLSN=#{TDLSN,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
</update> </update>
<delete id="delTDLDevice" parameterType="String"> <delete id="delTDLDevice" parameterType="String">
...@@ -84,9 +87,10 @@ ...@@ -84,9 +87,10 @@
</select> </select>
<select id="getUnusedTDL" resultType="com.example.tdl.domain.vo.TdlSNVo" parameterType="String" > <select id="getUnusedTDL" resultType="com.example.tdl.domain.vo.TdlSNVo" parameterType="String" >
select TDLSN from tdldevice select TDLSN from tdldevice t INNER JOIN company c ON t.company_id=c.id
where TDLSN like CONCAT(CONCAT('%',#{TDLSN,jdbcType=VARCHAR}), '%') where TDLSN like CONCAT(CONCAT('%',#{TDLSN,jdbcType=VARCHAR}), '%')
and useScene = 0 and useScene = 0
AND companyNo=#{companyNo,jdbcType=VARCHAR}
</select> </select>
<select id="getByTransportationNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultTDLDeviceVo"> <select id="getByTransportationNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultTDLDeviceVo">
...@@ -97,4 +101,9 @@ ...@@ -97,4 +101,9 @@
and t.circuit_id = c.id and t.circuit_id = c.id
and c.transportationNo=#{transportationNo,jdbcType=VARCHAR} and c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
</select> </select>
<update id="updateCompany" parameterType="String">
UPDATE tdldevice set company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
WHERE TDLSN=#{TDLSN,jdbcType=VARCHAR}
</update>
</mapper> </mapper>
\ No newline at end of file
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