Commit 04d68aef authored by 王夏晖's avatar 王夏晖

1.ZnksServer完成,接受客户端解码未完成

parent 207cf28d
...@@ -38,6 +38,7 @@ public class DeviceController extends BaseController<Device> { ...@@ -38,6 +38,7 @@ public class DeviceController extends BaseController<Device> {
try { try {
deviceVO.setId(UUID.randomUUID()); deviceVO.setId(UUID.randomUUID());
deviceVO.setUserId(user.getId()); deviceVO.setUserId(user.getId());
deviceVO.setMacAddress(deviceService.getMacByPhone(deviceVO.getPhoneNumber()));
deviceService.insertSelective(deviceVO); deviceService.insertSelective(deviceVO);
return GenResponse.success(); return GenResponse.success();
} catch (Exception e) { } catch (Exception e) {
......
...@@ -61,8 +61,8 @@ public class GatewayController extends BaseController<Gateway> { ...@@ -61,8 +61,8 @@ public class GatewayController extends BaseController<Gateway> {
} }
@PostMapping("/udpate") @PostMapping("/update")
public ResponseEntity udpate(String phoneNumber,String macAddress) { public ResponseEntity update(String phoneNumber,String macAddress) {
User user = userService.getByPhoneNumber(phoneNumber); User user = userService.getByPhoneNumber(phoneNumber);
if(user!=null){ if(user!=null){
if(gatewayService.updateMac(user.getId(),macAddress.toUpperCase())){ if(gatewayService.updateMac(user.getId(),macAddress.toUpperCase())){
......
...@@ -6,8 +6,11 @@ import com.adc.da.znks.service.UserService; ...@@ -6,8 +6,11 @@ import com.adc.da.znks.service.UserService;
import com.adc.da.znks.util.GenResponse; import com.adc.da.znks.util.GenResponse;
import com.adc.da.znks.util.SocketUtils; import com.adc.da.znks.util.SocketUtils;
import com.adc.da.znks.util.SystemValue; import com.adc.da.znks.util.SystemValue;
import com.adc.da.znks.util.netty.ServerHandler;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -28,6 +31,8 @@ public class InstructionsController { ...@@ -28,6 +31,8 @@ public class InstructionsController {
@Autowired @Autowired
private UserService userService; private UserService userService;
private static final Logger logger = LoggerFactory.getLogger(InstructionsController.class);
@GetMapping("/loginGateway") @GetMapping("/loginGateway")
public ResponseEntity<Boolean> loginGateway(String phoneNumber) { public ResponseEntity<Boolean> loginGateway(String phoneNumber) {
User user = userService.getByPhoneNumber(phoneNumber); User user = userService.getByPhoneNumber(phoneNumber);
...@@ -76,6 +81,7 @@ public class InstructionsController { ...@@ -76,6 +81,7 @@ public class InstructionsController {
open[5] = 0x00; open[5] = 0x00;
open[6] = (byte)number; open[6] = (byte)number;
open[7] = 0x2d; open[7] = 0x2d;
logger.info("设备吗学习指令发送:++++++++++++++++++++++++++++++++"+SocketUtils.bytesToHex(open,0,open.length));
String mac = getMacByPhone(phoneNumber); String mac = getMacByPhone(phoneNumber);
if(mac==null){ if(mac==null){
return GenResponse.fail("网关mac获取失败"); return GenResponse.fail("网关mac获取失败");
...@@ -84,7 +90,7 @@ public class InstructionsController { ...@@ -84,7 +90,7 @@ public class InstructionsController {
System.out.println("open status : " + ch.isOpen()); System.out.println("open status : " + ch.isOpen());
System.out.println("active status : " + ch.isActive()); System.out.println("active status : " + ch.isActive());
ch.writeAndFlush(open); ch.writeAndFlush(open);
return GenResponse.fail("开锁成功"); return GenResponse.success();
} else { } else {
return GenResponse.fail("开锁异常"); return GenResponse.fail("开锁异常");
} }
...@@ -112,7 +118,7 @@ public class InstructionsController { ...@@ -112,7 +118,7 @@ public class InstructionsController {
System.out.println("open status : " + ch.isOpen()); System.out.println("open status : " + ch.isOpen());
System.out.println("active status : " + ch.isActive()); System.out.println("active status : " + ch.isActive());
ch.writeAndFlush(open); ch.writeAndFlush(open);
return GenResponse.fail("安防码学习成功"); return GenResponse.success();
} else { } else {
return GenResponse.fail("安防码学习异常"); return GenResponse.fail("安防码学习异常");
} }
...@@ -145,7 +151,7 @@ public class InstructionsController { ...@@ -145,7 +151,7 @@ public class InstructionsController {
System.out.println("open status : " + ch.isOpen()); System.out.println("open status : " + ch.isOpen());
System.out.println("active status : " + ch.isActive()); System.out.println("active status : " + ch.isActive());
ch.writeAndFlush(open); ch.writeAndFlush(open);
return GenResponse.fail("布防成功"); return GenResponse.success();
} else { } else {
return GenResponse.fail("布防失败"); return GenResponse.fail("布防失败");
} }
...@@ -178,7 +184,7 @@ public class InstructionsController { ...@@ -178,7 +184,7 @@ public class InstructionsController {
System.out.println("open status : " + ch.isOpen()); System.out.println("open status : " + ch.isOpen());
System.out.println("active status : " + ch.isActive()); System.out.println("active status : " + ch.isActive());
ch.writeAndFlush(open); ch.writeAndFlush(open);
return GenResponse.fail("撤防成功"); return GenResponse.success();
} else { } else {
return GenResponse.fail("撤防失败"); return GenResponse.fail("撤防失败");
} }
...@@ -209,7 +215,7 @@ public class InstructionsController { ...@@ -209,7 +215,7 @@ public class InstructionsController {
System.out.println("open status : " + ch.isOpen()); System.out.println("open status : " + ch.isOpen());
System.out.println("active status : " + ch.isActive()); System.out.println("active status : " + ch.isActive());
ch.writeAndFlush(open); ch.writeAndFlush(open);
return GenResponse.fail("进入组网成功"); return GenResponse.success();
} else { } else {
return GenResponse.fail("进入组网失败"); return GenResponse.fail("进入组网失败");
} }
...@@ -240,7 +246,7 @@ public class InstructionsController { ...@@ -240,7 +246,7 @@ public class InstructionsController {
System.out.println("open status : " + ch.isOpen()); System.out.println("open status : " + ch.isOpen());
System.out.println("active status : " + ch.isActive()); System.out.println("active status : " + ch.isActive());
ch.writeAndFlush(open); ch.writeAndFlush(open);
return GenResponse.fail("退出组网成功"); return GenResponse.success();
} else { } else {
return GenResponse.fail("退出组网失败"); return GenResponse.fail("退出组网失败");
} }
...@@ -271,7 +277,7 @@ public class InstructionsController { ...@@ -271,7 +277,7 @@ public class InstructionsController {
System.out.println("open status : " + ch.isOpen()); System.out.println("open status : " + ch.isOpen());
System.out.println("active status : " + ch.isActive()); System.out.println("active status : " + ch.isActive());
ch.writeAndFlush(open); ch.writeAndFlush(open);
return GenResponse.fail("ZigBee恢复出厂成功"); return GenResponse.success();
} else { } else {
return GenResponse.fail("zigBee恢复出厂失败"); return GenResponse.fail("zigBee恢复出厂失败");
} }
...@@ -302,7 +308,7 @@ public class InstructionsController { ...@@ -302,7 +308,7 @@ public class InstructionsController {
System.out.println("open status : " + ch.isOpen()); System.out.println("open status : " + ch.isOpen());
System.out.println("active status : " + ch.isActive()); System.out.println("active status : " + ch.isActive());
ch.writeAndFlush(open); ch.writeAndFlush(open);
return GenResponse.fail("Wifi恢复出厂成功"); return GenResponse.success();
} else { } else {
return GenResponse.fail("wifi恢复出厂失败"); return GenResponse.fail("wifi恢复出厂失败");
} }
......
...@@ -24,7 +24,17 @@ public interface DeviceDao extends BaseDao<Device> { ...@@ -24,7 +24,17 @@ public interface DeviceDao extends BaseDao<Device> {
void deleteDeviceById(@Param("id") String id); void deleteDeviceById(@Param("id") String id);
@Select("select t.* from tb_device t,tb_gateway g where t.user_id = g.user_id and g.mac_address = #{macAddress} and t.code = #{deviceCode} ") @Select("select t.* from tb_device t where t.mac_address = #{macAddress} and t.code = #{deviceCode} ")
List<Map<String,Object>> getDeviceId(@Param("macAddress") String macAddress,@Param("deviceCode") String deviceCode); List<Map<String,Object>> getDeviceId(@Param("macAddress") String macAddress,@Param("deviceCode") String deviceCode);
@Select("SELECT\n" +
" g.mac_address\n" +
" FROM\n" +
" tb_user t,\n" +
" tb_gateway g\n" +
" WHERE\n" +
" t.id = g.user_id\n" +
" AND t.temphone = #{phone}")
List<Map<String,Object>> getMacByPhone(@Param("phone") String phone);
} }
...@@ -17,6 +17,6 @@ public interface LockRecordDao extends BaseDao<LockRecord> { ...@@ -17,6 +17,6 @@ public interface LockRecordDao extends BaseDao<LockRecord> {
void insertLockRecord(LockRecord lockRecord); void insertLockRecord(LockRecord lockRecord);
List<Map<String,Object>> selectLockRecord(@Param("phone") String phone,@Param("deviceCode") String deviceCode); List<Map<String,Object>> selectLockRecord(@Param("mac") String mac,@Param("deviceCode") String deviceCode);
} }
...@@ -23,6 +23,8 @@ public class Device extends BaseEntity { ...@@ -23,6 +23,8 @@ public class Device extends BaseEntity {
private String uid; private String uid;
private String macAddress;
public String getId() { public String getId() {
return id; return id;
} }
...@@ -86,4 +88,12 @@ public class Device extends BaseEntity { ...@@ -86,4 +88,12 @@ public class Device extends BaseEntity {
public void setUid(String uid) { public void setUid(String uid) {
this.uid = uid; this.uid = uid;
} }
public String getMacAddress() {
return macAddress;
}
public void setMacAddress(String macAddress) {
this.macAddress = macAddress;
}
} }
...@@ -37,10 +37,12 @@ public class DeviceService extends BaseService<Device, String> { ...@@ -37,10 +37,12 @@ public class DeviceService extends BaseService<Device, String> {
} }
public String getDeviceId(String macAddress,String deviceCode){ public String getDeviceId(String macAddress,String deviceCode){
List<Map<String,Object>> list = dao.getDeviceId(macAddress,deviceCode); List<Map<String,Object>> list = dao.getDeviceId(macAddress,deviceCode);
if(list != null && list.size()>0){ return list.get(0)!=null?list.get(0).get("id").toString():"";
return list.get(0).get("id")!=null?list.get(0).get("id").toString():"";
} }
return "";
public String getMacByPhone(String phone){
return dao.getMacByPhone(phone)!=null?dao.getMacByPhone(phone).get(0).get("mac_address").toString():"";
} }
} }
...@@ -27,6 +27,9 @@ public class LockRecordService extends BaseService<LockRecord, String> { ...@@ -27,6 +27,9 @@ public class LockRecordService extends BaseService<LockRecord, String> {
@Autowired(required = false) @Autowired(required = false)
private LockRecordDao dao; private LockRecordDao dao;
@Autowired
private DeviceDao deviceDao;
@Override @Override
public BaseDao<LockRecord> getDao() { public BaseDao<LockRecord> getDao() {
return dao; return dao;
...@@ -38,7 +41,8 @@ public class LockRecordService extends BaseService<LockRecord, String> { ...@@ -38,7 +41,8 @@ public class LockRecordService extends BaseService<LockRecord, String> {
public List<Map<String,Object>> selectLockRecord(String phone,String deviceCode){ public List<Map<String,Object>> selectLockRecord(String phone,String deviceCode){
List<Map<String,Object>> result = new ArrayList<>(); List<Map<String,Object>> result = new ArrayList<>();
List<Map<String,Object>> list = dao.selectLockRecord(phone,deviceCode); String mac = deviceDao.getMacByPhone(phone)!=null?deviceDao.getMacByPhone(phone).get(0).get("mac_address").toString():"";
List<Map<String,Object>> list = dao.selectLockRecord(mac,deviceCode);
List<String> dayList = new ArrayList<>(); List<String> dayList = new ArrayList<>();
for(Map<String,Object> tmap : list){ for(Map<String,Object> tmap : list){
if(!dayList.contains(tmap.get("day"))){ if(!dayList.contains(tmap.get("day"))){
......
...@@ -116,7 +116,7 @@ public class AppPushUtils { ...@@ -116,7 +116,7 @@ public class AppPushUtils {
public static void main(String[] args) { public static void main(String[] args) {
try { try {
pushTc("提示", "测试推送", "c3d2cb373109db849b7ecfb22a4fd93d"); push("提示", "测试推送", "c3d2cb373109db849b7ecfb22a4fd93d");
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -10,6 +10,11 @@ import java.math.BigInteger; ...@@ -10,6 +10,11 @@ import java.math.BigInteger;
**/ **/
public class Test { public class Test {
public static void main(String[] args)throws Exception{ public static void main(String[] args)throws Exception{
byte a = 0x32;
System.out.println(String.valueOf(a));
/* List<Map<String,Object>> list = new ArrayList<>(); /* List<Map<String,Object>> list = new ArrayList<>();
Map<String,Object> map1 = new HashMap<>(); Map<String,Object> map1 = new HashMap<>();
map1.put("component","盖子"); map1.put("component","盖子");
...@@ -55,8 +60,8 @@ public class Test { ...@@ -55,8 +60,8 @@ public class Test {
System.out.println(list);*/ System.out.println(list);*/
/*byte[] b = {0x54,0x59}; /*byte[] b = {0x54,0x59};
System.out.println(SocketUtils.bytesToHex(b,0,b.length).split(" ").length);*/ System.out.println(SocketUtils.bytesToHex(b,0,b.length).split(" ").length);*/
System.out.println("54 59 54 01 01 00".replace(" ","")); //System.out.println("54 59 54 01 01 00".replace(" ",""));
AppPushUtils.pushTc("主题","消息","c3d2cb373109db849b7ecfb22a4fd93d"); //AppPushUtils.pushTc("主题","消息","c3d2cb373109db849b7ecfb22a4fd93d");
//AppPushUtils.push("主题","消息","c3d2cb373109db849b7ecfb22a4fd93d"); //AppPushUtils.push("主题","消息","c3d2cb373109db849b7ecfb22a4fd93d");
} }
......
...@@ -52,6 +52,7 @@ public class ServerHandler extends ChannelInboundHandlerAdapter { ...@@ -52,6 +52,7 @@ public class ServerHandler extends ChannelInboundHandlerAdapter {
serverHandler.gatewayService = this.gatewayService; serverHandler.gatewayService = this.gatewayService;
serverHandler.lockRecordService = this.lockRecordService; serverHandler.lockRecordService = this.lockRecordService;
serverHandler.userService = this.userService; serverHandler.userService = this.userService;
serverHandler.deviceService = this.deviceService;
} }
@Override @Override
...@@ -60,14 +61,18 @@ public class ServerHandler extends ChannelInboundHandlerAdapter { ...@@ -60,14 +61,18 @@ public class ServerHandler extends ChannelInboundHandlerAdapter {
String remoteAddress = ctx.channel().remoteAddress().toString(); String remoteAddress = ctx.channel().remoteAddress().toString();
String host = remoteAddress.substring(1,remoteAddress.lastIndexOf(":")); String host = remoteAddress.substring(1,remoteAddress.lastIndexOf(":"));
System.out.println("网关IP地址:" + host); System.out.println("网关IP地址:" + host);
logger.info("server channelRead...; received:" + msg);
byte[] result = (byte[])msg; byte[] result = (byte[])msg;
System.out.println(SocketUtils.bytesToHex(result,0,result.length)); String resultStr = SocketUtils.bytesToHex(result,0,result.length);
logger.info(SocketUtils.bytesToHex(result,0,result.length));
String mac = SocketUtils.bytesToHex(result,0,6); String mac = SocketUtils.bytesToHex(result,0,6);
String macR = mac.trim().replace(" ",""); String macR = mac.trim().replace(" ","");
// 在此处需要分别解析 // 在此处需要分别解析
// 1.上报MAC地址信息 6位mac地址+10位的(MAC-UPLOAD) // 1.上报MAC地址信息 6位mac地址+10位的(MAC-UPLOAD)
try{ try{
String[] resultArr = resultStr.split(" ");
int len = SocketUtils.bytesToHex(result,0,result.length).split(" ").length; int len = SocketUtils.bytesToHex(result,0,result.length).split(" ").length;
System.out.println("字符串"+SocketUtils.bytesToHex(result,0,result.length));
if(String.valueOf(len).equals("16")){ if(String.valueOf(len).equals("16")){
SystemValue.channelMap.put(macR,ctx.channel()); SystemValue.channelMap.put(macR,ctx.channel());
...@@ -80,16 +85,16 @@ public class ServerHandler extends ChannelInboundHandlerAdapter { ...@@ -80,16 +85,16 @@ public class ServerHandler extends ChannelInboundHandlerAdapter {
// 前6位不用管,第七位是设备编号,第八位是功能码0x05代表开锁,0x06代表关锁,最后两位代表用户ID,1-300 // 前6位不用管,第七位是设备编号,第八位是功能码0x05代表开锁,0x06代表关锁,最后两位代表用户ID,1-300
// 3.安防信息,需要根据安防信息做不同的处理,安防信息有 0x60(非法开门警报),0x61(非法尝试开锁警报),0x80(远程开锁触发),0x28(电池低电量警报) // 3.安防信息,需要根据安防信息做不同的处理,安防信息有 0x60(非法开门警报),0x61(非法尝试开锁警报),0x80(远程开锁触发),0x28(电池低电量警报)
byte device = result[13]; byte device = result[12];
byte user = 0; byte user = 0;
String device_code = String.valueOf(device); String device_code = String.valueOf(device);
String deviceId = deviceService.getDeviceId(macR,device_code); String deviceId = serverHandler.deviceService.getDeviceId(macR,device_code);
byte instruct = 0; String instruct = "";
if(result.length == 17){//开关门信息,6位mac + 11位指令 if(result.length == 17){//开关门信息,6位mac + 11位指令
instruct = result[14]; instruct = resultArr[14];
user = result[16]; user = result[16];
}else{//安防信息,6位mac + 8位指令 }else{//安防信息,6位mac + 8位指令
instruct = result[9]; instruct = resultArr[9];
} }
int user_id = Integer.parseInt(String.valueOf(user)); int user_id = Integer.parseInt(String.valueOf(user));
String lockType = getLockType(instruct); String lockType = getLockType(instruct);
...@@ -103,13 +108,26 @@ public class ServerHandler extends ChannelInboundHandlerAdapter { ...@@ -103,13 +108,26 @@ public class ServerHandler extends ChannelInboundHandlerAdapter {
System.out.println(lockType); System.out.println(lockType);
serverHandler.lockRecordService.insertLockRecord(lockRecord); serverHandler.lockRecordService.insertLockRecord(lockRecord);
if(list != null){ if(list != null){
clientId = list.get(0).get("client_id")!=null?list.get(0).get("client_id").toString():""; if("80".equals(instruct)){ // 远程开锁触发请求,发送透传
for(int i=0;i<list.size();i++){
clientId = list.get(i).get("client_id")!=null?list.get(i).get("client_id").toString():"";
if(!"".equals(clientId)){ if(!"".equals(clientId)){
if(instruct == 0x80){ // 远程开锁触发请求,发送透传
AppPushUtils.pushTc(title,message,clientId); AppPushUtils.pushTc(title,message,clientId);
AppPushUtils.push(title,message,clientId); AppPushUtils.push(title,message,clientId);
}else{ }else{
logger.info("clientId为空");
}
}
}else{
for(int i=0;i<list.size();i++){
clientId = list.get(i).get("client_id")!=null?list.get(i).get("client_id").toString():"";
if(!"".equals(clientId)){
AppPushUtils.push(title,message,clientId); AppPushUtils.push(title,message,clientId);
}else{
logger.info("clientId为空");
}
} }
} }
...@@ -182,35 +200,35 @@ public class ServerHandler extends ChannelInboundHandlerAdapter { ...@@ -182,35 +200,35 @@ public class ServerHandler extends ChannelInboundHandlerAdapter {
return true; return true;
} }
public String getLockType(byte b){ public String getLockType(String b){
if(b == 0x05){return "开锁";} if("05".equals(b)){return "开锁";}
else if(b == 0x06){return "关锁";} else if("06".equals(b)){return "关锁";}
else if(b == 0x60){return "非法开门警报";} else if("60".equals(b)){return "非法开门警报";}
else if(b == 0x61){return "非法尝试开锁警报";} else if("61".equals(b)){return "非法尝试开锁警报";}
else if(b == 0x80){return "远程开锁触发";} else if("80".equals(b)){return "远程开锁触发";}
else if(b == 0x28){return "电池低电量警报";} else if("28".equals(b)){return "电池低电量警报";}
return ""; return "";
} }
public String getTitle(byte b){ public String getTitle(String b){
String title = ""; String title = "";
if(b == 0x05){title = "开锁";} if("05".equals(b)){title = "开锁";}
else if(b == 0x06){title = "关锁";} else if("06".equals(b)){title = "关锁";}
else if(b == 0x60){title = "非法开门警报";} else if("60".equals(b)){title = "非法开门警报";}
else if(b == 0x61){title = "非法尝试开锁警报";} else if("61".equals(b)){title = "非法尝试开锁警报";}
else if(b == 0x80){title = "远程开锁触发";} else if("80".equals(b)){title = "远程开锁触发";}
else if(b == 0x28){title = "电池低电量警报";} else if("28".equals(b)){title = "电池低电量警报";}
return title; return title;
} }
public String getMessage(byte b){ public String getMessage(String b){
String msg = ""; String msg = "";
if(b == 0x05){msg = "开锁";} if("05".equals(b)){msg = "开锁";}
else if(b == 0x06){msg = "关锁";} else if("06".equals(b)){msg = "关锁";}
else if(b == 0x60){msg = "非法开门警报";} else if("60".equals(b)){msg = "非法开门警报";}
else if(b == 0x61){msg = "非法尝试开锁警报";} else if("61".equals(b)){msg = "非法尝试开锁警报";}
else if(b == 0x80){msg = "远程开锁触发";} else if("80".equals(b)){msg = "远程开锁触发";}
else if(b == 0x28){msg = "电池低电量警报";} else if("28".equals(b)){msg = "电池低电量警报";}
SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return simple.format(new Date()) + " 触发 " + msg; return simple.format(new Date()) + " 触发 " + msg;
} }
......
...@@ -12,9 +12,21 @@ ...@@ -12,9 +12,21 @@
<result column="uid" property="uid"/> <result column="uid" property="uid"/>
</resultMap> </resultMap>
<select id="listByPhoneNumber" resultMap="BaseResultMap"> <select id="listByPhoneNumber" resultMap="BaseResultMap">
select * from tb_device,tb_user SELECT
where tb_device.user_id = tb_user.id t.*
and tb_user.temphone = #{phoneNumber} FROM
tb_device t
WHERE
t.mac_Address = (
SELECT
g.mac_address
FROM
tb_user t,
tb_gateway g
WHERE
t.id = g.user_id
AND t.temphone = #{phone})
order by t.code
</select> </select>
<!-- 动态插入记录 主键是序列 --> <!-- 动态插入记录 主键是序列 -->
...@@ -29,6 +41,7 @@ ...@@ -29,6 +41,7 @@
<if test="userPassword != null">user_password,</if> <if test="userPassword != null">user_password,</if>
<if test="uid != null">uid,</if> <if test="uid != null">uid,</if>
<if test="userId != null">user_id,</if> <if test="userId != null">user_id,</if>
<if test="macAddress != null">mac_address,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id, jdbcType=VARCHAR},</if> <if test="id != null">#{id, jdbcType=VARCHAR},</if>
...@@ -39,6 +52,7 @@ ...@@ -39,6 +52,7 @@
<if test="userPassword != null">#{userPassword, jdbcType=VARCHAR},</if> <if test="userPassword != null">#{userPassword, jdbcType=VARCHAR},</if>
<if test="uid != null">#{uid, jdbcType=VARCHAR},</if> <if test="uid != null">#{uid, jdbcType=VARCHAR},</if>
<if test="userId != null">#{userId, jdbcType=VARCHAR},</if> <if test="userId != null">#{userId, jdbcType=VARCHAR},</if>
<if test="macAddress != null">#{macAddress, jdbcType=VARCHAR},</if>
</trim> </trim>
</insert> </insert>
......
...@@ -15,17 +15,11 @@ ...@@ -15,17 +15,11 @@
<select id="selectLockRecord" resultType="java.util.Map" parameterType="java.util.Map"> <select id="selectLockRecord" resultType="java.util.Map" parameterType="java.util.Map">
SELECT SELECT
loc.*, DATE_FORMAT(loc.time, '%Y-%m-%d') day, loc.*, DATE_FORMAT(loc.time, '%Y-%m-%d') day,
DATE_FORMAT(loc.time,'%Y-%m-%d %h:%i:%s') htime DATE_FORMAT(loc.time,'%Y-%m-%d %T') htime
FROM FROM
tb_lock_record loc, tb_lock_record loc
tb_device dev,
tb_user u
WHERE WHERE
u.id = dev.user_id loc.device_id = (select dev.id from tb_device dev where dev.mac_address = #{mac} and dev.code = #{deviceCode} limit 1)
AND dev.code = loc.device_id
AND u.temphone = #{phone}
AND dev. CODE = #{deviceCode}
AND dev.type = 1
AND DATE_SUB(now(), INTERVAL 10 DAY) &lt;= loc.time AND DATE_SUB(now(), INTERVAL 10 DAY) &lt;= loc.time
order by loc.time desc order by loc.time desc
</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