Commit 6102b18c authored by chenying's avatar chenying

4.8修改线路的app接口,添加报警信息的下载接口

parent 0bd50c68
...@@ -47,6 +47,8 @@ dependencies { ...@@ -47,6 +47,8 @@ dependencies {
compile ('org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0') compile ('org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0')
compile ('org.influxdb:influxdb-java:2.7') compile ('org.influxdb:influxdb-java:2.7')
compile ('com.github.miwurster:spring-data-influxdb:1.6') compile ('com.github.miwurster:spring-data-influxdb:1.6')
compile('com.aliyun.oss:aliyun-sdk-oss:2.5.0')
compile('org.apache.poi:poi:3.9')
} }
jar { jar {
String someString = '' String someString = ''
......
This diff is collapsed.
...@@ -9,6 +9,16 @@ public class UserTermVo { ...@@ -9,6 +9,16 @@ public class UserTermVo {
private String phone; private String phone;
private String companyName;
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getUserName() { public String getUserName() {
return userName; return userName;
} }
......
...@@ -11,17 +11,17 @@ public interface UserMapper { ...@@ -11,17 +11,17 @@ public interface UserMapper {
int login(LoginUserVo loginUserVo); int login(LoginUserVo loginUserVo);
UserVo getByUserName(String userName); UserVo getByUserName(@Param("userName") String userName);
List<ResultUserVo> getAll(); List<ResultUserVo> getAll(String companyName);
List<ResultUserVo> getByTerm(UserTermVo userTermVo); List<ResultUserVo> getByTerm(UserTermVo userTermVo);
ResultUserVo getByPhone(String phone); ResultUserVo getByPhone(@Param("phone") String phone,@Param("companyName") String companyName);
ResultUserVo getByEmail(String email); ResultUserVo getByEmail(@Param("email") String email,@Param("companyName") String companyName);
ResultUserVo getByUserNumber(String userNumber); ResultUserVo getByUserNumber(@Param("userNumber") String userNumber,@Param("companyName") String companyName);
int addUser(AddUserVo addUserVo); int addUser(AddUserVo addUserVo);
......
...@@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit; ...@@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit;
public class MqttListener implements MqttCallback { public class MqttListener implements MqttCallback {
private static final int INIT_DELAY_DEFAULT = 1000; // unit:ms private static final int INIT_DELAY_DEFAULT = 1000; // unit:ms
private static final int SCH_PERIOD_DEFAULT = 10 * INIT_DELAY_DEFAULT; // unit:ms private static final int SCH_PERIOD_DEFAULT = 10 * INIT_DELAY_DEFAULT; // unit:ms
private static final String CHECKIN_TOPIC = "TDL/+/+/CheckIn"; private static final String CHECKIN_TOPIC = "Witium/+/+/CheckIn";
private MqttTemlateAsync mqttAsyncClient; private MqttTemlateAsync mqttAsyncClient;
...@@ -187,9 +187,12 @@ public class MqttListener implements MqttCallback { ...@@ -187,9 +187,12 @@ public class MqttListener implements MqttCallback {
// 有设备信息 // 有设备信息
ConfigVo configVo = configService.getConfig(SN,Type); ConfigVo configVo = configService.getConfig(SN,Type);
ConfigCMDVo configCMDVo = new Gson().fromJson(configVo.getMessage(),ConfigCMDVo.class); ConfigCMDVo configCMDVo = new Gson().fromJson(configVo.getMessage(),ConfigCMDVo.class);
if(StringUtils.isEmpty(configVo.getMessage())){ if(configVo.getUntie()){
return 2;//解绑 //解绑状态
} else if (configCMDVo.getDevList().containsAll(checkInVo.getDevList()) return 2;//解绑
}
//判断两者的devList是否一致
if (configCMDVo.getDevList().containsAll(checkInVo.getDevList())
&& checkInVo.getDevList().containsAll(configCMDVo.getDevList()) && checkInVo.getDevList().containsAll(configCMDVo.getDevList())
&& checkInVo.getGprsPeriod().equals(configCMDVo.getGprsPeriod()) && checkInVo.getGprsPeriod().equals(configCMDVo.getGprsPeriod())
&& checkInVo.getGpsPeriod().equals(configCMDVo.getGpsPeriod()) && checkInVo.getGpsPeriod().equals(configCMDVo.getGpsPeriod())
......
...@@ -30,24 +30,24 @@ public class UserService { ...@@ -30,24 +30,24 @@ public class UserService {
return userMapper.getByUserName(userName); return userMapper.getByUserName(userName);
} }
public List<ResultUserVo> getAll(){ public List<ResultUserVo> getAll(String companyName){
return userMapper.getAll(); return userMapper.getAll(companyName);
} }
public List<ResultUserVo> getByTerm(UserTermVo userTermVo){ public List<ResultUserVo> getByTerm(UserTermVo userTermVo){
return userMapper.getByTerm(userTermVo); return userMapper.getByTerm(userTermVo);
} }
public ResultUserVo getByPhone(String phone){ public ResultUserVo getByPhone(String phone,String companyName){
return userMapper.getByPhone(phone); return userMapper.getByPhone(phone,companyName);
} }
public ResultUserVo getByEmail(String email){ public ResultUserVo getByEmail(String email,String companyName){
return userMapper.getByEmail(email); return userMapper.getByEmail(email,companyName);
} }
public ResultUserVo getByUserNumber(String userNumber){ public ResultUserVo getByUserNumber(String userNumber,String companyName){
return userMapper.getByUserNumber(userNumber); return userMapper.getByUserNumber(userNumber,companyName);
} }
public int addUser(AddUserVo addUserVo){ public int addUser(AddUserVo addUserVo){
......
This diff is collapsed.
package com.example.tdl.util;
import com.aliyun.oss.model.CannedAccessControlList;
public class OSSClientConstants {
//阿里云API的外网域名
public static final String ENDPOINT = "oss-cn-shanghai.aliyuncs.com";
//阿里云API的密钥Access Key ID
public static final String ACCESS_KEY_ID = "LTAITBRGP5O2x861";
//阿里云API的密钥Access Key Secret
public static final String ACCESS_KEY_SECRET = "JgupdkkFg1Ot1eRsdk6wXU3CJiWdaw";
//阿里云API的bucket名称
public static final String BACKET_NAME = "witcloud-oss";//uploadexcelhltp
//阿里云API的文件夹名称
public static final String FOLDER1="everyData/";//每日设备数据
public static final String FOLDER2="picture/"; //图片上传
public static final String FOLDER3="historyData/probesData/";//探点数据
public static final String FOLDER4="tdlAlarmData/";//探点数据
//公共读写
private static final CannedAccessControlList acl_pub_readwrite = CannedAccessControlList.PublicReadWrite;
}
package com.example.tdl.util;
import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class ZipCompressUtil {
private String zipFileName; // 目的地Zip文件
private String sourceFileName; //源文件(带压缩的文件或文件夹)
public ZipCompressUtil(String zipFileName, String sourceFileName){
this.zipFileName=zipFileName;
this.sourceFileName=sourceFileName;
}
public void zip() throws Exception {
//创建zip输出流
ZipOutputStream out = new ZipOutputStream( new FileOutputStream(zipFileName));
//创建缓冲输出流
BufferedOutputStream bos = new BufferedOutputStream(out);
File sourceFile = new File(sourceFileName);
//调用函数
compress(out,bos,sourceFile,sourceFile.getName());
bos.close();
out.close();
}
public void compress(ZipOutputStream out,BufferedOutputStream bos,File sourceFile,String base) throws Exception {
//如果路径为目录(文件夹)
if(sourceFile.isDirectory()){
//取出文件夹中的文件(或子文件夹)
File[] flist = sourceFile.listFiles();
//如果文件夹为空,则只需在目的地zip文件中写入一个目录进入点
if(flist.length==0){
out.putNextEntry( new ZipEntry(base+"/") );
} else {
//如果文件夹不为空,则递归调用compress,文件夹中的每一个文件(或文件夹)进行压缩
for(int i=0;i<flist.length;i++) {
compress(out,bos,flist[i],base+"/"+flist[i].getName());
}
}
}else {
//如果不是目录(文件夹),即为文件,则先写入目录进入点,之后将文件写入zip文件中
out.putNextEntry(new ZipEntry(base));
FileInputStream fos = new FileInputStream(sourceFile);
BufferedInputStream bis = new BufferedInputStream(fos);
int tag;
//将源文件写入到zip文件中
while ((tag = bis.read()) != -1) {
bos.write(tag);
}
bis.close();
fos.close();
}
}
}
...@@ -132,7 +132,9 @@ public class CircuitController { ...@@ -132,7 +132,9 @@ public class CircuitController {
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class); UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject=JSON.parseObject(transportationNo); JSONObject jsonObject=JSON.parseObject(transportationNo);
transportationNo=(String) jsonObject.get("transportationNo"); transportationNo=(String) jsonObject.get("transportationNo");
return circuitService.getByTransportationNoForApp(transportationNo,user.getCompanyName()); ResultCircuitForAppVo resultCircuitForAppVo=circuitService.getByTransportationNoForApp(transportationNo,user.getCompanyName());
resultCircuitForAppVo.setStartTime(System.currentTimeMillis());
return resultCircuitForAppVo;
} }
//根据条件查询 //根据条件查询
......
...@@ -45,18 +45,42 @@ public class UserController { ...@@ -45,18 +45,42 @@ public class UserController {
private RoleService roleService; private RoleService roleService;
//获取所有用户信息 //获取所有用户信息
@ApiOperation(value = "获取所有用户信息",notes = "获取所有用户信息") @ApiOperation(value = "获取所有用户信息",notes = "获取所有用户信息:" +
" userNumber:用户编号," +
" userName:用户名," +
" nickName:昵称," +
" phone:电话," +
" email:邮箱," +
" roleName:角色名," +
" 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 userService.getAll(); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
return userService.getAll(user.getCompanyName());
} }
//根据条件查询 //根据条件查询
@ApiOperation(value = "根据条件查询",notes = "根据条件查询") @ApiOperation(value = "根据条件查询",notes = "根据条件查询:需要传的值:" +
" email:邮件," +
" phone:电话," +
" roleName:角色名," +
" userName:用户名." +
"返回值说明:" +
" userNumber:," +
" userName:," +
" nickName:," +
" phone:," +
" email:," +
" roleName:," +
" 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"),
}) })
...@@ -119,7 +143,7 @@ public class UserController { ...@@ -119,7 +143,7 @@ public class UserController {
fb.setMessage("手机号不规范"); fb.setMessage("手机号不规范");
return gson.toJson(fb); return gson.toJson(fb);
} }
if ((userService.getByPhone(userVo.getPhone()))!=null){ if ((userService.getByPhone(userVo.getPhone(),userVo.getCompanyName()))!=null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该手机号已被注册"); fb.setMessage("该手机号已被注册");
return gson.toJson(fb); return gson.toJson(fb);
...@@ -134,7 +158,7 @@ public class UserController { ...@@ -134,7 +158,7 @@ public class UserController {
fb.setMessage("邮箱格式不规范"); fb.setMessage("邮箱格式不规范");
return gson.toJson(fb); return gson.toJson(fb);
} }
if ((userService.getByEmail(userVo.getEmail()))!=null){ if ((userService.getByEmail(userVo.getEmail(),userVo.getCompanyName()))!=null){
fb.setCode(0); fb.setCode(0);
fb.setMessage("该邮箱已被注册"); fb.setMessage("该邮箱已被注册");
return gson.toJson(fb); return gson.toJson(fb);
...@@ -176,8 +200,11 @@ public class UserController { ...@@ -176,8 +200,11 @@ public class UserController {
@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="/updateUser",method = RequestMethod.POST) @RequestMapping(value="/updateUser",method = RequestMethod.POST)
public Object updateUser(@RequestBody UpdateUserVo userVo){ public Object updateUser(@RequestBody UpdateUserVo userVo,HttpServletRequest request){
ResultUserVo userInfo=userService.getByUserNumber(userVo.getUserNumber()); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
ResultUserVo userInfo=userService.getByUserNumber(userVo.getUserNumber(),user.getCompanyName());
if (StringUtils.isEmpty(userVo.getNickName())){ if (StringUtils.isEmpty(userVo.getNickName())){
fb.setCode(0); fb.setCode(0);
fb.setMessage("昵称不能为空"); fb.setMessage("昵称不能为空");
......
...@@ -11,23 +11,27 @@ ...@@ -11,23 +11,27 @@
<!--通过用户名查询用户信息--> <!--通过用户名查询用户信息-->
<select id="getByUserName" parameterType="String" resultType="com.example.tdl.domain.vo.UserVo"> <select id="getByUserName" parameterType="String" resultType="com.example.tdl.domain.vo.UserVo">
select userNumber, userName,password,nickName,phone,email,roleName,(SELECT companyName from company WHERE id=u.company_id) companyName select userNumber, userName,password,nickName,phone,email,roleName,c.companyName
from `user` u INNER JOIN role r ON u.role_id=r.id from company c,`user` u INNER JOIN role r ON u.role_id=r.id
WHERE userName=#{userName,jdbcType=VARCHAR} WHERE u.company_id=c.id
AND state=1 AND userName=#{userName,jdbcType=VARCHAR}
AND u.state=1
</select> </select>
<!--获取所有用户信息--> <!--获取该公司所有用户信息-->
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultUserVo"> <select id="getAll" resultType="com.example.tdl.domain.vo.ResultUserVo">
select userNumber, userName,nickName,phone,email,roleName,(SELECT companyName from company WHERE id=u.company_id) companyName select userNumber, userName,password,nickName,phone,email,roleName,c.companyName
from `user` u INNER JOIN role r ON u.role_id=r.id from company c,`user` u INNER JOIN role r ON u.role_id=r.id
WHERE state=1 WHERE u.company_id=c.id
AND c.companyName=#{companyName,jdbcType=VARCHAR}
AND u.state=1
</select> </select>
<!--根据条件查询--> <!--根据条件查询-->
<select id="getByTerm" resultType="com.example.tdl.domain.vo.ResultUserVo" parameterType="com.example.tdl.domain.vo.UserTermVo"> <select id="getByTerm" resultType="com.example.tdl.domain.vo.ResultUserVo" parameterType="com.example.tdl.domain.vo.UserTermVo">
select userNumber, userName,nickName,phone,email,roleName,(SELECT companyName from company WHERE id=u.company_id) companyName select userNumber, userName,password,nickName,phone,email,roleName,c.companyName
from `user` u INNER JOIN role r ON u.role_id=r.id WHERE 1=1 from company c,`user` u INNER JOIN role r ON u.role_id=r.id
WHERE u.company_id=c.id
<if test="userName!=null"> <if test="userName!=null">
AND userName like CONCAT(CONCAT('%',#{userName,jdbcType=VARCHAR}), '%') AND userName like CONCAT(CONCAT('%',#{userName,jdbcType=VARCHAR}), '%')
</if> </if>
...@@ -40,31 +44,38 @@ ...@@ -40,31 +44,38 @@
<if test="phone!=null"> <if test="phone!=null">
AND phone like CONCAT(CONCAT('%',#{phone,jdbcType=VARCHAR}), '%') AND phone like CONCAT(CONCAT('%',#{phone,jdbcType=VARCHAR}), '%')
</if> </if>
AND state=1 AND c.companyName=#{companyName,jdbcType=VARCHAR}
AND u.state=1
</select> </select>
<!--通过手机号查询用户信息--> <!--通过手机号查询用户信息-->
<select id="getByPhone" parameterType="String" resultType="com.example.tdl.domain.vo.ResultUserVo"> <select id="getByPhone" parameterType="String" resultType="com.example.tdl.domain.vo.ResultUserVo">
select userNumber, userName,nickName,phone,email,roleName,(SELECT companyName from company WHERE id=u.company_id) companyName select userNumber, userName,password,nickName,phone,email,roleName,c.companyName
from `user` u INNER JOIN role r ON u.role_id=r.id from company c,`user` u INNER JOIN role r ON u.role_id=r.id
WHERE phone=#{phone,jdbcType=VARCHAR} WHERE u.company_id=c.id
AND state=1 AND c.companyName=#{companyName,jdbcType=VARCHAR}
AND phone=#{phone,jdbcType=VARCHAR}
AND u.state=1
</select> </select>
<!--通过邮箱查询用户信息--> <!--通过邮箱查询用户信息-->
<select id="getByEmail" parameterType="String" resultType="com.example.tdl.domain.vo.ResultUserVo"> <select id="getByEmail" parameterType="String" resultType="com.example.tdl.domain.vo.ResultUserVo">
select userNumber, userName,nickName,phone,email,roleName,(SELECT companyName from company WHERE id=u.company_id) companyName select userNumber, userName,password,nickName,phone,email,roleName,c.companyName
from `user` u INNER JOIN role r ON u.role_id=r.id from company c,`user` u INNER JOIN role r ON u.role_id=r.id
WHERE email=#{email,jdbcType=VARCHAR} WHERE u.company_id=c.id
AND state=1 AND c.companyName=#{companyName,jdbcType=VARCHAR}
AND email=#{email,jdbcType=VARCHAR}
AND u.state=1
</select> </select>
<!--通过用户编号查询用户信息--> <!--通过用户编号查询用户信息-->
<select id="getByUserNumber" parameterType="String" resultType="com.example.tdl.domain.vo.ResultUserVo"> <select id="getByUserNumber" parameterType="String" resultType="com.example.tdl.domain.vo.ResultUserVo">
select userNumber, userName,nickName,phone,email,roleName,(SELECT companyName from company WHERE id=u.company_id) companyName select userNumber, userName,password,nickName,phone,email,roleName,c.companyName
from `user` u INNER JOIN role r ON u.role_id=r.id from company c,`user` u INNER JOIN role r ON u.role_id=r.id
WHERE userNumber=#{userNumber,jdbcType=VARCHAR} WHERE u.company_id=c.id
AND state=1 AND c.companyName=#{companyName,jdbcType=VARCHAR}
AND userNumber=#{userNumber,jdbcType=VARCHAR}
AND u.state=1
</select> </select>
<!--添加用户--> <!--添加用户-->
......
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