Commit 132b828f authored by Carit Zhu's avatar Carit Zhu 🎱

Add offset configuration for temperature and humidity in TDL data.

parent 69394920
Pipeline #413 passed with stage
in 0 seconds
......@@ -12,6 +12,8 @@ public class AlarmRuleVo {
private Double lowerval;
private Double offset;
private String mode;
private String priority;
......@@ -56,6 +58,14 @@ public class AlarmRuleVo {
this.lowerval = lowerval;
}
public Double getOffset() {
return offset;
}
public void setOffset(Double offset) {
this.offset = offset;
}
public String getMode() {
return mode;
}
......
......@@ -23,6 +23,8 @@ public class ResultTDLDeviceVo {
private String companyName;
private String offsetJson;
public String getCompanyName() {
return companyName;
}
......@@ -110,4 +112,12 @@ public class ResultTDLDeviceVo {
public void setGatewayType(String gatewayType) {
this.gatewayType = gatewayType;
}
public String getOffsetJson() {
return offsetJson;
}
public void setOffsetJson(String offsetJson) {
this.offsetJson = offsetJson;
}
}
......@@ -13,6 +13,8 @@ public class TDLDeviceDetailVo {
private String gatewaySN;
private String offsetJson;
public String getTDLSN() {
return TDLSN;
}
......@@ -60,4 +62,12 @@ public class TDLDeviceDetailVo {
public void setGatewaySN(String gatewaySN) {
this.gatewaySN = gatewaySN;
}
public String getOffsetJson() {
return offsetJson;
}
public void setOffsetJson(String offsetJson) {
this.offsetJson = offsetJson;
}
}
package com.example.tdl.domain.vo;
public class TDLDeviceVo {
private String TDLSN;
private String offsetJson;
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getOffsetJson() {
return offsetJson;
}
public void setOffsetJson(String offsetJson) {
this.offsetJson = offsetJson;
}
}
package com.example.tdl.domain.vo;
import com.example.tdl.entity.TDLDataOffset;
public class UpdateTDLOffsetVo {
String tdlSN;
TDLDataOffset offset;
public String getTdlSN() {
return tdlSN;
}
public void setTdlSN(String tdlSN) {
this.tdlSN = tdlSN;
}
public TDLDataOffset getOffset() {
return offset;
}
public void setOffset(TDLDataOffset offset) {
this.offset = offset;
}
}
package com.example.tdl.entity;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
public class TDLDataOffset {
private Double tempOffset;//温度校准值
private Double humidityOffset;//湿度校准值
public Double getTempOffset() {
return tempOffset;
}
public void setTempOffset(Double tempOffset) {
this.tempOffset = tempOffset;
}
public Double getHumidityOffset() {
return humidityOffset;
}
public void setHumidityOffset(Double humidityOffset) {
this.humidityOffset = humidityOffset;
}
public static TDLDataOffset parse(String offsetString) {
TDLDataOffset offset;
try {
offset = new Gson().fromJson(offsetString, TDLDataOffset.class);
} catch (JsonSyntaxException e) {
offset = new TDLDataOffset();
offset.setHumidityOffset(0.0);
offset.setTempOffset(0.0);
}
return offset;
}
}
......@@ -2,6 +2,7 @@ package com.example.tdl.mapper;
import com.example.tdl.domain.vo.*;
import com.example.tdl.entity.TDLDataOffset;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -27,10 +28,13 @@ public interface TDLDeviceMapper {
String getTdl(@Param("SN") String SN, @Param("type") String type);
List<TDLDeviceVo> getTdlByGatewaySN(@Param("SN") String SN, @Param("type") String type);
List<TdlSNVo> getUnusedTDL(@Param("TDLSN") String TDLSN,@Param("companyNo") String companyNo);
ResultTDLDeviceVo getByTransportationNo(String transportationNo);
int updateCompany(@Param("TDLSN") String TDLSN,@Param("companyNo") String companyNo);
int updateTDLOffset(@Param("TDLSN") String TDLSN,@Param("offset") String offset);
}
package com.example.tdl.service;
import com.example.tdl.domain.vo.*;
import com.example.tdl.entity.TDLDataOffset;
import com.example.tdl.mapper.TDLDeviceMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -48,6 +50,10 @@ public class TDLDeviceService {
return tdlDeviceMapper.getTdl(SN,type);
}
public List<TDLDeviceVo> getTdlByGatewaySN(String SN, String type) {
return tdlDeviceMapper.getTdlByGatewaySN(SN, type);
}
public List<TdlSNVo> getUnusedTDL(String TDLSN,String companyNo){
return tdlDeviceMapper.getUnusedTDL(TDLSN,companyNo);
}
......@@ -61,4 +67,7 @@ public class TDLDeviceService {
return tdlDeviceMapper.updateCompany(TDLSN,companyNo);
}
public int updateTDLOffset(String TDLSN, String offset) {
return tdlDeviceMapper.updateTDLOffset(TDLSN, offset);
}
}
......@@ -3,6 +3,7 @@ package com.example.tdl.util;
import com.example.tdl.domain.vo.AlarmRuleVo;
import com.example.tdl.domain.vo.ResultAlarmVo;
import com.example.tdl.domain.vo.ResultBoschAlarmVo;
import com.example.tdl.entity.TDLDataOffset;
import com.example.tdl.service.AlarmService;
import com.example.tdl.service.BoschAlarmService;
import com.example.tdl.service.redis.AlarmRedisService;
......@@ -22,7 +23,9 @@ public class AlarmRule {
add("ta");
}};
public static void saveAlarmRule(String topic, String TDLSN, String alarmType, String companyNo, BoschAlarmService alarmService, AlarmRedisService alarmRedisService){
public static void saveAlarmRule(String topic, String TDLSN, TDLDataOffset offset,
String alarmType, String companyNo,
BoschAlarmService alarmService, AlarmRedisService alarmRedisService){
ResultBoschAlarmVo alarmVo = alarmService.getByType(alarmType,companyNo);
for(String alias :list){
List<AlarmRuleVo> alarmRuleVos = new ArrayList<>();
......@@ -41,6 +44,11 @@ public class AlarmRule {
alarmRuleVo.setMinval(alarmVo.getTemMin());
alarmRuleVo.setMode("twoway");
}
if (offset.getTempOffset() != null) {
alarmRuleVo.setOffset(offset.getTempOffset());
} else {
alarmRuleVo.setOffset(0.0);
}
break;
case "h":
if(alarmVo.getHumidityLower() !=null && alarmVo.getHumidityUpper() !=null){
......@@ -54,6 +62,11 @@ public class AlarmRule {
alarmRuleVo.setMinval(alarmVo.getHumidityMin());
alarmRuleVo.setMode("twoway");
}
if (offset.getHumidityOffset() != null) {
alarmRuleVo.setOffset(offset.getHumidityOffset());
} else {
alarmRuleVo.setOffset(0.0);
}
break;
case "ta":
if(alarmVo.getTiltUpper() !=null ){
......
package com.example.tdl.util;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
public class JsonUtils {
public static JsonElement getJsonElement(String jsonString) {
JsonElement jsonElement;
try {
jsonElement = new JsonParser().parse(jsonString);
} catch (JsonSyntaxException ex) {
return null;
}
return jsonElement;
}
public static JsonObject getJsonObject(String jsonString) {
JsonElement jsonElement = getJsonElement(jsonString);
try {
return jsonElement != null ? jsonElement.getAsJsonObject() : null;
} catch (IllegalStateException e) {
return null;
}
}
public static boolean isJson(String jsonString) {
JsonElement jsonElement = getJsonElement(jsonString);
return jsonElement != null;
}
public static boolean isJsonObject(String jsonString) {
JsonElement jsonElement = getJsonElement(jsonString);
if (jsonElement == null) {
return false;
} else {
return jsonElement.isJsonObject();
}
}
public static boolean isJsonArray(String jsonString) {
JsonElement jsonElement = getJsonElement(jsonString);
if (jsonElement == null) {
return false;
} else {
return jsonElement.isJsonArray();
}
}
public static JsonObject changeJsonKey(JsonObject jsonObject, String oldKey, String newKey) {
if (jsonObject.has(oldKey)) {
JsonElement value = jsonObject.get(oldKey);
jsonObject.remove(oldKey);
jsonObject.add(newKey, value);
}
return jsonObject;
}
}
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*;
import com.example.tdl.entity.TDLDataOffset;
import com.example.tdl.service.*;
import com.example.tdl.service.redis.AlarmRedisService;
import com.example.tdl.service.redis.InfoRedisService;
......@@ -895,7 +896,11 @@ public class CircuitController {
alarmTypeVar =alarmTypeVar + addCircuitVo.getTdlAlarmList().get(j).getAlarmType() +"&";
TDLSNVar =TDLSNVar + addCircuitVo.getTdlAlarmList().get(j).getTDLSN() +"&";
devList.add("TDL-"+addCircuitVo.getTdlAlarmList().get(j).getTDLSN());
AlarmRule.saveAlarmRule("TDL/"+type+"/" +addCircuitVo.getSN()+"/Data",addCircuitVo.getTdlAlarmList().get(j).getTDLSN(),addCircuitVo.getTdlAlarmList().get(j).getAlarmType(),user.getCompanyNo(),boschAlarmService,alarmRedisService);
TDLDataOffset offset = TDLDataOffset.parse(tdlDeviceVo.getOffsetJson());
AlarmRule.saveAlarmRule("TDL/"+type+"/" +addCircuitVo.getSN()+"/Data",
addCircuitVo.getTdlAlarmList().get(j).getTDLSN(), offset,
addCircuitVo.getTdlAlarmList().get(j).getAlarmType(),
user.getCompanyNo(),boschAlarmService,alarmRedisService);
}
if(StringUtils.isEmpty(addCircuitVo.getCargoNo())){
fb.setCode(0);
......@@ -919,7 +924,9 @@ public class CircuitController {
return gson.toJson(fb);
}
//根据sn获取type
ConfigCMDVo configCMDVo = new ConfigCMDVo("config",5,15,devList,tempL,tempH,humiL,humiH,pressL,pressH,sugEnergy,accThreshold,timeThreshold,tiltThreshold,1,System.currentTimeMillis()/1000l);
ConfigCMDVo configCMDVo = new ConfigCMDVo("config",5,15,devList,
tempL,tempH,humiL,humiH,pressL,pressH,sugEnergy,accThreshold,timeThreshold,tiltThreshold,
1,System.currentTimeMillis()/1000L);
Map<Object,Object> map=new HashMap<>();
String transportation = "公路";
String transportationType="本地运输";
......
......@@ -5,12 +5,15 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*;
import com.example.tdl.entity.TDLDataOffset;
import com.example.tdl.service.*;
import com.example.tdl.service.redis.AlarmRedisService;
import com.example.tdl.service.redis.InfoRedisService;
import com.example.tdl.service.redis.TokenRedisService;
import com.example.tdl.util.AlarmRule;
import com.example.tdl.util.JsonUtils;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
......@@ -160,7 +163,7 @@ public class EquipmentBindingController {
gpsPeriod=5;
gprsPeriod=15;
}
ConfigVo configVo =configService.getConfig(bindingVo.getgSN(),bindingVo.getType());
ConfigVo configVo = configService.getConfig(bindingVo.getgSN(),bindingVo.getType());
List<Float> tempL = new ArrayList<>();
List<Float> tempH = new ArrayList<>();
List<Float> humiL = new ArrayList<>();
......@@ -173,6 +176,11 @@ public class EquipmentBindingController {
List<Integer> tiltThreshold = new ArrayList<>();
List<String> devList = new ArrayList<>();
ResultAlarmVo alarmVo = alarmService.getByType(bindingVo.getAlarmType(),user.getCompanyNo());
if (alarmVo == null) {
fb.setCode(0);
fb.setMessage("该预警类型不存在");
return gson.toJson(fb);
}
if(!StringUtils.isEmpty(configVo.getMessage())){
ConfigCMDVo config = gson.fromJson(configVo.getMessage(),ConfigCMDVo.class);
tempL.addAll(config.getTempL());
......@@ -223,7 +231,10 @@ public class EquipmentBindingController {
fb.setCode(1);
fb.setMessage("配置网关成功");
//根据报警类型货报警信息
AlarmRule.saveAlarmRule("TDL/"+bindingVo.getType()+"/" +bindingVo.getgSN()+"/Data",bindingVo.getTDLSN(),bindingVo.getAlarmType(),user.getCompanyNo(),boschAlarmService,alarmRedisService);
TDLDataOffset offset = TDLDataOffset.parse(resultTDLDeviceVo.getOffsetJson());
AlarmRule.saveAlarmRule("TDL/"+bindingVo.getType()+"/" +bindingVo.getgSN()+"/Data",
bindingVo.getTDLSN(), offset, bindingVo.getAlarmType(),user.getCompanyNo(),
boschAlarmService,alarmRedisService);
List<ResultTopicVo> topicList = topicService.getByGateway(new GatewaySNAndTypeVo(bindingVo.getgSN(),bindingVo.getType()));
for (ResultTopicVo topic : topicList) {
infoRedisService.delHashKey("TopicConfig", topic.getTopicName());
......
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*;
import com.example.tdl.entity.TDLDataOffset;
import com.example.tdl.service.TDLDeviceService;
import com.example.tdl.service.redis.TokenRedisService;
import com.google.gson.Gson;
......@@ -164,8 +165,6 @@ public class TDLDeviceController {
return gson.toJson(fb);
}
//删除TDL信息
@ApiOperation(value = "删除TDL信息",notes = "删除TDL信息,传值说明:" +
" TDLSN:需要删除的TDL序列号")
......@@ -253,4 +252,52 @@ public class TDLDeviceController {
}
return gson.toJson(fb);
}
//根据TDL序列号修改TDL误差校准值
@ApiOperation(value = "根据TDL序列号修改TDL误差校准值",notes = "根据TDL序列号修改TDL误差校准值,传值说明:" +
" {" +
" tdlSN: TDL序列号," +
" offset: {" +
" tempOffset: 温度校准值," +
" humidityOffset: humidityOffset," +
" }" +
" }"
)
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value="/updateTDLOffset",method = RequestMethod.POST)
public Object updateTDLOffset(@RequestBody UpdateTDLOffsetVo updateTDLOffsetVo, HttpServletRequest request) {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum, UserRedisVo.class);
/* 参数合法性判断 */
if(StringUtils.isBlank(updateTDLOffsetVo.getTdlSN())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"TDLSN"));
return gson.toJson(fb);
}
if (updateTDLOffsetVo.getOffset() == null) {
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"wrongTDLOffset"));
return gson.toJson(fb);
}
/* 查找该TDL是否存在 */
if (tdlDeviceService.getByTDLSN(updateTDLOffsetVo.getTdlSN()) == null) {
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"tdlExist"));
return gson.toJson(fb);
}
String offset = gson.toJson(updateTDLOffsetVo.getOffset(), TDLDataOffset.class);
int a = tdlDeviceService.updateTDLOffset(updateTDLOffsetVo.getTdlSN(), offset);
if (a>=0){
fb.setCode(1);
fb.setMessage(i18n.getMessage(request,"updateTDLOffsetSuccess"));
}else{
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"updateTDLOffsetFailure"));
}
return gson.toJson(fb);
}
}
package com.example.tdl.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.OSSClient;
import com.example.tdl.common.WarehouseExcel;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*;
import com.example.tdl.entity.Alarm;
import com.example.tdl.entity.Gateway;
import com.example.tdl.service.*;
import com.example.tdl.service.redis.InfoRedisService;
import com.example.tdl.service.redis.TokenRedisService;
import com.example.tdl.util.AliyunOSSClientUtil;
import com.example.tdl.util.DataUtil;
import com.example.tdl.util.ZipCompressUtil;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.slf4j.Logger;
......@@ -28,15 +20,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.influxdb.InfluxDBTemplate;
import org.springframework.expression.spel.ast.NullLiteral;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.crypto.Data;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
......@@ -291,6 +277,7 @@ public class WarehouseController {
" time: 时间," +
" tdlsn: TDL编号" +
" gatewaySN:网关编号" +
" offsetJson: 校准JSON(若为空则视为全零)" +
" }" +
" ]," +
" sn: 设备编号" +
......@@ -357,12 +344,13 @@ public class WarehouseController {
}else {
gatewayOnLineVo.setBattery("NA");
}
List<String> tdls=tdlDeviceService.getByGatewaySN(list.get(a).getSN(),list.get(a).getType());
List<TDLDeviceVo> tdlDeviceVos = tdlDeviceService.getTdlByGatewaySN(list.get(a).getSN(),list.get(a).getType());
List<TDLDeviceDetailVo> tdlDeviceDetailVos=new ArrayList<>();
for (int b=0;b<tdls.size();b++){
TDLDeviceDetailVo tdlDeviceDetailVo=new TDLDeviceDetailVo();
for (TDLDeviceVo tdlDeviceVo : tdlDeviceVos) {
TDLDeviceDetailVo tdlDeviceDetailVo = new TDLDeviceDetailVo();
tdlDeviceDetailVo.setGatewaySN(list.get(a).getSN());
String sqls ="SELECT \"b\", \"T\", \"h\" FROM \"tdl_policy\".\""+list.get(a).getDevice() +"\" WHERE (\"tdl\" = '"+tdls.get(b)+"') and time>="+startTime*1000000l+" ORDER BY time DESC LIMIT 1";
String sqls ="SELECT \"b\", \"T\", \"h\" FROM \"tdl_policy\".\""+list.get(a).getDevice() +"\" WHERE (\"tdl\" = '"+tdlDeviceVo.getTDLSN()+"') and time>="+startTime*1000000L+" ORDER BY time DESC LIMIT 1";
QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database));
if (queryResults.getResults().get(0).getSeries() != null) {
tdlDeviceDetailVo.setTime(parseTime(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString()));
......@@ -375,7 +363,8 @@ public class WarehouseController {
tdlDeviceDetailVo.setTemperature("NA");
tdlDeviceDetailVo.setHumidity("NA");
}
tdlDeviceDetailVo.setTDLSN(tdls.get(b).replace("TDL-","").trim());
tdlDeviceDetailVo.setTDLSN(tdlDeviceVo.getTDLSN().replace("TDL-","").trim());
tdlDeviceDetailVo.setOffsetJson(tdlDeviceVo.getOffsetJson());
tdlDeviceDetailVos.add(tdlDeviceDetailVo);
}
gatewayOnLineVo.setTdlDeviceDetailVos(tdlDeviceDetailVos);
......@@ -1155,8 +1144,6 @@ public class WarehouseController {
return tdlDataVo;
}
//模糊查询所有的仓库名
@ApiOperation(value="模糊查询所有的仓库名",notes = "模糊查询所有的仓库名,传值:" +
"warehouseName:仓库名称")
......@@ -1164,7 +1151,7 @@ public class WarehouseController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@PostMapping("/getWarehouseName")
public Object getWarehouseName(@RequestBody String warehouseName ,HttpServletRequest request){
public Object getWarehouseName(@RequestBody String warehouseName, HttpServletRequest request){
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
......
......@@ -205,10 +205,13 @@ TDLSN=Sensor's serial number must not be null
TDLName=Sensor's name must not be null
updateTDLSuccess=Modified the sensor successfully
updateTDLFailure=Failed to modify the sensor
deleteTDLSuccess=Deleted the gateway successfully
deleteTDLFailure=
deleteTDLSuccess=Delete the TDL sensor successfully
deleteTDLFailure=Delete the TDL sensor failed
updateTDLCompanySuccess=Allocate sensor to the company successfully
updateTDLCompanyFailure=Failed to allocate the sensor to the company
wrongTDLOffset=Offset of sensor cannot be empty
updateTDLOffsetSuccess=Update TDL offset successfully
updateTDLOffsetFailure=Update TDL offset failed
warehouseName=Warehouse's name must not be null
property=Warehouse's property must not be null
wrongProperty=Please enter the correct property
......
......@@ -237,6 +237,9 @@ deleteTDLSuccess=\u5220\u9664\u4F20\u611F\u5668\u6210\u529F
deleteTDLFailure=\u5220\u9664\u4F20\u611F\u5668\u5931\u8D25
updateTDLCompanySuccess=\u4F20\u611F\u5668\u5206\u914D\u516C\u53F8\u6210\u529F
updateTDLCompanyFailure=\u4F20\u611F\u5668\u5206\u914D\u516C\u53F8\u5931\u8D25
wrongTDLOffset=\u4F20\u611F\u5668\u6821\u51C6\u503C\u4E0D\u80FD\u4E3A\u7A7A
updateTDLOffsetSuccess=\u4F20\u611F\u5668\u4FEE\u6539\u6821\u51C6\u503C\u6210\u529F
updateTDLOffsetFailure=\u4F20\u611F\u5668\u4FEE\u6539\u6821\u51C6\u503C\u5931\u8D25
#\u4ED3\u5E93
warehouseName = \u4ED3\u5E93\u540D\u4E0D\u80FD\u4E3A\u7A7A
property =\u4ED3\u5E93\u5C5E\u6027\u4E0D\u80FD\u4E3A\u7A7A
......
......@@ -60,7 +60,7 @@
<select id="getByTDLSN" 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 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,offsetJson
from tdldevice t INNER JOIN company c ON t.company_id=c.id
WHERE TDLSN=#{TDLSN,jdbcType=VARCHAR}
</select>
......@@ -86,6 +86,13 @@
and g.type=#{type,jdbcType=VARCHAR}
</select>
<select id="getTdlByGatewaySN" parameterType="String" resultType="com.example.tdl.domain.vo.TDLDeviceVo">
select CONCAT("TDL-",TDLSN) TDLSN,offsetJson from tdldevice t,gateway g
where t.gateway_id = g.id
and g.SN =#{SN,jdbcType=VARCHAR}
and g.type=#{type,jdbcType=VARCHAR}
</select>
<select id="getUnusedTDL" resultType="com.example.tdl.domain.vo.TdlSNVo" parameterType="String" >
select TDLSN from tdldevice t INNER JOIN company c ON t.company_id=c.id
where TDLSN like CONCAT(CONCAT('%',#{TDLSN,jdbcType=VARCHAR}), '%')
......@@ -106,5 +113,10 @@
UPDATE tdldevice set company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
WHERE TDLSN=#{TDLSN,jdbcType=VARCHAR}
</update>
<update id="updateTDLOffset" parameterType="String">
UPDATE tdldevice set offsetJson=#{offset,jdbcType=VARCHAR}
WHERE TDLSN=#{TDLSN,jdbcType=VARCHAR}
</update>
</mapper>
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