Browse Source

园区设备增加摄像头地址字段

logistics
ma 4 years ago
parent
commit
ad3fa87564
  1. 32
      logistics/src/main/java/com/ccsens/logistics/api/DebugController.java
  2. 22
      logistics/src/main/java/com/ccsens/logistics/bean/dto/HttpDto.java
  3. 11
      logistics/src/main/java/com/ccsens/logistics/bean/po/LogisticsParkEquipment.java
  4. 70
      logistics/src/main/java/com/ccsens/logistics/bean/po/LogisticsParkEquipmentExample.java
  5. 106
      logistics/src/main/java/com/ccsens/logistics/service/HttpService.java
  6. 13
      logistics/src/main/java/com/ccsens/logistics/service/IHttpService.java
  7. 28
      logistics/src/main/resources/mapper_raw/LogisticsParkEquipmentMapper.xml

32
logistics/src/main/java/com/ccsens/logistics/api/DebugController.java

@ -5,6 +5,8 @@ import com.ccsens.logistics.bean.po.LogisticsCarRecord;
import com.ccsens.logistics.bean.po.LogisticsEnvironmentRecord; import com.ccsens.logistics.bean.po.LogisticsEnvironmentRecord;
import com.ccsens.logistics.persist.dao.LogisticsCarRecordDao; import com.ccsens.logistics.persist.dao.LogisticsCarRecordDao;
import com.ccsens.logistics.persist.dao.LogisticsEnvironmentRecordDao; import com.ccsens.logistics.persist.dao.LogisticsEnvironmentRecordDao;
import com.ccsens.logistics.service.HttpService;
import com.ccsens.logistics.service.IHttpService;
import com.ccsens.util.JsonResponse; import com.ccsens.util.JsonResponse;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
@ -27,26 +29,28 @@ public class DebugController {
private LogisticsCarRecordDao carRecordDao; private LogisticsCarRecordDao carRecordDao;
@Resource @Resource
private Snowflake snowflake; private Snowflake snowflake;
@Resource
private IHttpService iHttpService;
@ApiOperation(value = "/测试添加假数据",notes = "") @ApiOperation(value = "/测试添加假数据",notes = "")
@ApiImplicitParams({ @ApiImplicitParams({
}) })
@RequestMapping(value="",produces = {"application/json;charset=UTF-8"}) @RequestMapping(value="",produces = {"application/json;charset=UTF-8"})
public JsonResponse getSmsCode(HttpServletRequest request) throws Exception { public JsonResponse getSmsCode(HttpServletRequest request) throws Exception {
Long currentTime = 1620632535000L; // Long currentTime = 1620632535000L;
for (int i = 0; i < 100; i++) { // for (int i = 0; i < 100; i++) {
Byte carType = Math.random()*10 < 5 ? (byte)0 :(byte) 1; // Byte carType = Math.random()*10 < 5 ? (byte)0 :(byte) 1;
LogisticsCarRecord logisticsCarRecord = new LogisticsCarRecord(); // LogisticsCarRecord logisticsCarRecord = new LogisticsCarRecord();
logisticsCarRecord.setId(snowflake.nextId()); // logisticsCarRecord.setId(snowflake.nextId());
logisticsCarRecord.setCarWeight(RandomUtils.nextLong(1,9)); // logisticsCarRecord.setCarWeight(RandomUtils.nextLong(1,9));
logisticsCarRecord.setLicensePlate("未知"); // logisticsCarRecord.setLicensePlate("未知");
logisticsCarRecord.setCarType(carType); // logisticsCarRecord.setCarType(carType);
logisticsCarRecord.setInOut(carType); // logisticsCarRecord.setInOut(carType);
logisticsCarRecord.setRecordTime(currentTime); // logisticsCarRecord.setRecordTime(currentTime);
currentTime = currentTime-86400000; // currentTime = currentTime-86400000;
carRecordDao.insertSelective(logisticsCarRecord); // carRecordDao.insertSelective(logisticsCarRecord);
} // }
iHttpService.getTemperatureAndHumidity();
return JsonResponse.newInstance().ok("测试"); return JsonResponse.newInstance().ok("测试");
} }

22
logistics/src/main/java/com/ccsens/logistics/bean/dto/HttpDto.java

@ -0,0 +1,22 @@
package com.ccsens.logistics.bean.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author
*/
@Data
public class HttpDto {
@Data
@ApiModel("温湿度登录接口")
public static class Login{
@ApiModelProperty("账号")
private String loginName;
@ApiModelProperty("密码")
private String password;
}
}

11
logistics/src/main/java/com/ccsens/logistics/bean/po/LogisticsParkEquipment.java

@ -14,6 +14,8 @@ public class LogisticsParkEquipment implements Serializable {
private Long parkId; private Long parkId;
private String equipmentLocation;
private Date createdAt; private Date createdAt;
private Date updatedAt; private Date updatedAt;
@ -62,6 +64,14 @@ public class LogisticsParkEquipment implements Serializable {
this.parkId = parkId; this.parkId = parkId;
} }
public String getEquipmentLocation() {
return equipmentLocation;
}
public void setEquipmentLocation(String equipmentLocation) {
this.equipmentLocation = equipmentLocation == null ? null : equipmentLocation.trim();
}
public Date getCreatedAt() { public Date getCreatedAt() {
return createdAt; return createdAt;
} }
@ -97,6 +107,7 @@ public class LogisticsParkEquipment implements Serializable {
sb.append(", equipmentNumber=").append(equipmentNumber); sb.append(", equipmentNumber=").append(equipmentNumber);
sb.append(", equipmentType=").append(equipmentType); sb.append(", equipmentType=").append(equipmentType);
sb.append(", parkId=").append(parkId); sb.append(", parkId=").append(parkId);
sb.append(", equipmentLocation=").append(equipmentLocation);
sb.append(", createdAt=").append(createdAt); sb.append(", createdAt=").append(createdAt);
sb.append(", updatedAt=").append(updatedAt); sb.append(", updatedAt=").append(updatedAt);
sb.append(", recStatus=").append(recStatus); sb.append(", recStatus=").append(recStatus);

70
logistics/src/main/java/com/ccsens/logistics/bean/po/LogisticsParkEquipmentExample.java

@ -425,6 +425,76 @@ public class LogisticsParkEquipmentExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andEquipmentLocationIsNull() {
addCriterion("equipment_location is null");
return (Criteria) this;
}
public Criteria andEquipmentLocationIsNotNull() {
addCriterion("equipment_location is not null");
return (Criteria) this;
}
public Criteria andEquipmentLocationEqualTo(String value) {
addCriterion("equipment_location =", value, "equipmentLocation");
return (Criteria) this;
}
public Criteria andEquipmentLocationNotEqualTo(String value) {
addCriterion("equipment_location <>", value, "equipmentLocation");
return (Criteria) this;
}
public Criteria andEquipmentLocationGreaterThan(String value) {
addCriterion("equipment_location >", value, "equipmentLocation");
return (Criteria) this;
}
public Criteria andEquipmentLocationGreaterThanOrEqualTo(String value) {
addCriterion("equipment_location >=", value, "equipmentLocation");
return (Criteria) this;
}
public Criteria andEquipmentLocationLessThan(String value) {
addCriterion("equipment_location <", value, "equipmentLocation");
return (Criteria) this;
}
public Criteria andEquipmentLocationLessThanOrEqualTo(String value) {
addCriterion("equipment_location <=", value, "equipmentLocation");
return (Criteria) this;
}
public Criteria andEquipmentLocationLike(String value) {
addCriterion("equipment_location like", value, "equipmentLocation");
return (Criteria) this;
}
public Criteria andEquipmentLocationNotLike(String value) {
addCriterion("equipment_location not like", value, "equipmentLocation");
return (Criteria) this;
}
public Criteria andEquipmentLocationIn(List<String> values) {
addCriterion("equipment_location in", values, "equipmentLocation");
return (Criteria) this;
}
public Criteria andEquipmentLocationNotIn(List<String> values) {
addCriterion("equipment_location not in", values, "equipmentLocation");
return (Criteria) this;
}
public Criteria andEquipmentLocationBetween(String value1, String value2) {
addCriterion("equipment_location between", value1, value2, "equipmentLocation");
return (Criteria) this;
}
public Criteria andEquipmentLocationNotBetween(String value1, String value2) {
addCriterion("equipment_location not between", value1, value2, "equipmentLocation");
return (Criteria) this;
}
public Criteria andCreatedAtIsNull() { public Criteria andCreatedAtIsNull() {
addCriterion("created_at is null"); addCriterion("created_at is null");
return (Criteria) this; return (Criteria) this;

106
logistics/src/main/java/com/ccsens/logistics/service/HttpService.java

@ -0,0 +1,106 @@
package com.ccsens.logistics.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.logistics.bean.dto.HttpDto;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.PropUtil;
import com.ccsens.util.RestTemplateUtil;
import com.ccsens.util.exception.BaseException;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Map;
/**
* @author
*/
@Slf4j
@Service
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
public class HttpService implements IHttpService{
@Override
public void getTemperatureAndHumidity() {
try {
HttpDto.Login login = new HttpDto.Login();
login.setLoginName("jnrstest");
login.setPassword("jnrstest321");
//调取登录接口 获取userId
String userId = getUserId(login);
String body = getBody(userId);
}catch (Exception e){
e.printStackTrace();
}
}
/**
* 温湿度登录接口 获取设备的userId 调用其他接口
* @param login 账号密码
* @return userId
*/
public String getUserId(HttpDto.Login login){
String requestUrl = "http://www.0531yun.cn/wsjc/app/Login";
String s = RestTemplateUtil.postBody(requestUrl, login);
JsonResponse<JSONObject> a = JSONObject.parseObject(s, JsonResponse.class);
JSONObject data = a.getData();
String userId = data.getString("userId");
return userId;
}
public static String getBody(String userId) throws IOException {
try {
String url = "http://www.0531yun.cn/app/GetUserDeviceGroups";
HttpGet get = new HttpGet(url);
get.setHeader("userId",userId);
HttpClient httpClient = HttpClients.createDefault();
HttpResponse response = httpClient.execute(get);
return getResult(response);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static String getResult(HttpResponse response) throws IOException {
// 获取状态码
int code = response.getStatusLine().getStatusCode();
System.out.println(code);
// 获取body
HttpEntity entity = response.getEntity();
String body = EntityUtils.toString(entity);
System.out.println(body);
// 获取头信息
Header[] allHeaders = response.getAllHeaders();
String headers = Arrays.toString(allHeaders);
System.out.println(headers);
// 返回body
return body;
}
}

13
logistics/src/main/java/com/ccsens/logistics/service/IHttpService.java

@ -0,0 +1,13 @@
package com.ccsens.logistics.service;
/**
* @author
*/
public interface IHttpService {
/**
* 获取温度和湿度
*/
void getTemperatureAndHumidity();
}

28
logistics/src/main/resources/mapper_raw/LogisticsParkEquipmentMapper.xml

@ -7,6 +7,7 @@
<result column="equipment_number" jdbcType="VARCHAR" property="equipmentNumber" /> <result column="equipment_number" jdbcType="VARCHAR" property="equipmentNumber" />
<result column="equipment_type" jdbcType="TINYINT" property="equipmentType" /> <result column="equipment_type" jdbcType="TINYINT" property="equipmentType" />
<result column="park_id" jdbcType="BIGINT" property="parkId" /> <result column="park_id" jdbcType="BIGINT" property="parkId" />
<result column="equipment_location" jdbcType="VARCHAR" property="equipmentLocation" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" /> <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" /> <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" /> <result column="rec_status" jdbcType="TINYINT" property="recStatus" />
@ -70,7 +71,8 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, name, equipment_number, equipment_type, park_id, created_at, updated_at, rec_status id, name, equipment_number, equipment_type, park_id, equipment_location, created_at,
updated_at, rec_status
</sql> </sql>
<select id="selectByExample" parameterType="com.ccsens.logistics.bean.po.LogisticsParkEquipmentExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.ccsens.logistics.bean.po.LogisticsParkEquipmentExample" resultMap="BaseResultMap">
select select
@ -104,11 +106,13 @@
</delete> </delete>
<insert id="insert" parameterType="com.ccsens.logistics.bean.po.LogisticsParkEquipment"> <insert id="insert" parameterType="com.ccsens.logistics.bean.po.LogisticsParkEquipment">
insert into t_logistics_park_equipment (id, name, equipment_number, insert into t_logistics_park_equipment (id, name, equipment_number,
equipment_type, park_id, created_at, equipment_type, park_id, equipment_location,
updated_at, rec_status) created_at, updated_at, rec_status
)
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{equipmentNumber,jdbcType=VARCHAR}, values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{equipmentNumber,jdbcType=VARCHAR},
#{equipmentType,jdbcType=TINYINT}, #{parkId,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, #{equipmentType,jdbcType=TINYINT}, #{parkId,jdbcType=BIGINT}, #{equipmentLocation,jdbcType=VARCHAR},
#{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}) #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}
)
</insert> </insert>
<insert id="insertSelective" parameterType="com.ccsens.logistics.bean.po.LogisticsParkEquipment"> <insert id="insertSelective" parameterType="com.ccsens.logistics.bean.po.LogisticsParkEquipment">
insert into t_logistics_park_equipment insert into t_logistics_park_equipment
@ -128,6 +132,9 @@
<if test="parkId != null"> <if test="parkId != null">
park_id, park_id,
</if> </if>
<if test="equipmentLocation != null">
equipment_location,
</if>
<if test="createdAt != null"> <if test="createdAt != null">
created_at, created_at,
</if> </if>
@ -154,6 +161,9 @@
<if test="parkId != null"> <if test="parkId != null">
#{parkId,jdbcType=BIGINT}, #{parkId,jdbcType=BIGINT},
</if> </if>
<if test="equipmentLocation != null">
#{equipmentLocation,jdbcType=VARCHAR},
</if>
<if test="createdAt != null"> <if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP}, #{createdAt,jdbcType=TIMESTAMP},
</if> </if>
@ -189,6 +199,9 @@
<if test="record.parkId != null"> <if test="record.parkId != null">
park_id = #{record.parkId,jdbcType=BIGINT}, park_id = #{record.parkId,jdbcType=BIGINT},
</if> </if>
<if test="record.equipmentLocation != null">
equipment_location = #{record.equipmentLocation,jdbcType=VARCHAR},
</if>
<if test="record.createdAt != null"> <if test="record.createdAt != null">
created_at = #{record.createdAt,jdbcType=TIMESTAMP}, created_at = #{record.createdAt,jdbcType=TIMESTAMP},
</if> </if>
@ -210,6 +223,7 @@
equipment_number = #{record.equipmentNumber,jdbcType=VARCHAR}, equipment_number = #{record.equipmentNumber,jdbcType=VARCHAR},
equipment_type = #{record.equipmentType,jdbcType=TINYINT}, equipment_type = #{record.equipmentType,jdbcType=TINYINT},
park_id = #{record.parkId,jdbcType=BIGINT}, park_id = #{record.parkId,jdbcType=BIGINT},
equipment_location = #{record.equipmentLocation,jdbcType=VARCHAR},
created_at = #{record.createdAt,jdbcType=TIMESTAMP}, created_at = #{record.createdAt,jdbcType=TIMESTAMP},
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
rec_status = #{record.recStatus,jdbcType=TINYINT} rec_status = #{record.recStatus,jdbcType=TINYINT}
@ -232,6 +246,9 @@
<if test="parkId != null"> <if test="parkId != null">
park_id = #{parkId,jdbcType=BIGINT}, park_id = #{parkId,jdbcType=BIGINT},
</if> </if>
<if test="equipmentLocation != null">
equipment_location = #{equipmentLocation,jdbcType=VARCHAR},
</if>
<if test="createdAt != null"> <if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP}, created_at = #{createdAt,jdbcType=TIMESTAMP},
</if> </if>
@ -250,6 +267,7 @@
equipment_number = #{equipmentNumber,jdbcType=VARCHAR}, equipment_number = #{equipmentNumber,jdbcType=VARCHAR},
equipment_type = #{equipmentType,jdbcType=TINYINT}, equipment_type = #{equipmentType,jdbcType=TINYINT},
park_id = #{parkId,jdbcType=BIGINT}, park_id = #{parkId,jdbcType=BIGINT},
equipment_location = #{equipmentLocation,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP}, created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP}, updated_at = #{updatedAt,jdbcType=TIMESTAMP},
rec_status = #{recStatus,jdbcType=TINYINT} rec_status = #{recStatus,jdbcType=TINYINT}

Loading…
Cancel
Save