From 52866c212e1f75d05905cec84dec0c2487fca276 Mon Sep 17 00:00:00 2001 From: gaoben Date: Fri, 9 Jul 2021 16:12:50 +0800 Subject: [PATCH] =?UTF-8?q?v2.0.14=201.=E4=BC=98=E5=8C=96=E5=BF=83?= =?UTF-8?q?=E8=B7=B3=E6=9B=B4=E6=96=B0=E8=AE=BE=E5=A4=87=E8=A1=A8sql?= =?UTF-8?q?=E6=85=A2=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E7=94=A8redis?= =?UTF-8?q?=E6=9D=A5=E5=AD=98=E7=8A=B6=E6=80=81=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../modules/job/task/XaImageTask.java | 39 +++++++++++++++++-- .../service/impl/DeviceApiServiceImpl.java | 12 ++++-- .../modules/sys/service/SysDeviceService.java | 1 + .../service/impl/SysDeviceServiceImpl.java | 8 ++++ .../service/impl/TenDeviceServiceImpl.java | 25 +++++++++--- .../service/impl/TenRecordServiceImpl.java | 3 ++ .../modules/xian/service/XaApi.java | 14 ++++++- .../resources/mapper/ten/TenRecordDao.xml | 5 ++- 9 files changed, 94 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index b356257..31eac75 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ 1.3.1 2.5 1.10 - 1.2.58 + 1.2.75 2.9.9 1.18.4 2.7.0 diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/job/task/XaImageTask.java b/shapelight-admin/src/main/java/net/shapelight/modules/job/task/XaImageTask.java index 016cc38..ea25583 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/job/task/XaImageTask.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/job/task/XaImageTask.java @@ -208,6 +208,7 @@ public class XaImageTask implements ITask { if(resJson.contains("ErrorLineParameter")){ JSONObject resJsonObject = JSONObject.parseObject(resJson); String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim(); + JSONArray datas = resJsonObject.getJSONArray("datas"); if(errLine.equals("empty")){ for (TenRecordEntity recordEntity : updateRecords) { recordEntity.setXaSyncImage(1); @@ -226,10 +227,20 @@ public class XaImageTask implements ITask { } } } + if(datas!=null){ + for(int i = 0;i0){ + TenRecordEntity recordEntity = updateRecords.get(i); + recordEntity.setXaSyncImage(1); + tenRecordService.updateById(recordEntity); + } + } + } } } - private void processRecordCarEnterImage(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) { + private void processRecordCarEnterImage(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) { List records = this.tenPackRecordEnterService.getNotSyncImage(cellId); List syncRecords = new ArrayList(); List updateRecords = new ArrayList<>(); @@ -345,6 +356,7 @@ public class XaImageTask implements ITask { if(resJson.contains("ErrorLineParameter")){ JSONObject resJsonObject = JSONObject.parseObject(resJson); String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim(); + JSONArray datas = resJsonObject.getJSONArray("datas"); if(errLine.equals("empty")){ for (TenPackRecordEnterEntity recordEntity : updateRecords) { recordEntity.setXaSyncImage(1); @@ -363,13 +375,23 @@ public class XaImageTask implements ITask { } } } + if(datas!=null){ + for(int i = 0;i0){ + TenPackRecordEnterEntity recordEntity = updateRecords.get(i); + recordEntity.setXaSyncImage(1); + tenPackRecordEnterService.updateById(recordEntity); + } + } + } } } - private void processRecordCarExitImage(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) { + private void processRecordCarExitImage(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) { List records = this.tenPackRecordExitService.getNotSyncImage(cellId); List syncRecords = new ArrayList(); List updateRecords = new ArrayList<>(); @@ -491,6 +513,7 @@ public class XaImageTask implements ITask { if(resJson.contains("ErrorLineParameter")){ JSONObject resJsonObject = JSONObject.parseObject(resJson); String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim(); + JSONArray datas = resJsonObject.getJSONArray("datas"); if(errLine.equals("empty")){ for (TenPackRecordExitEntity recordEntity : updateRecords) { recordEntity.setXaSyncImage(1); @@ -509,11 +532,21 @@ public class XaImageTask implements ITask { } } } + if(datas!=null){ + for(int i = 0;i0){ + TenPackRecordExitEntity recordEntity = updateRecords.get(i); + recordEntity.setXaSyncImage(1); + tenPackRecordExitService.updateById(recordEntity); + } + } + } } } - private void processRealPersonImage(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) { + private void processRealPersonImage(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) { List persons = this.tenPersonService.getNotSyncImage(cellId); List syncPersons = new ArrayList(); List updatePersons = new ArrayList<>(); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/nettyapi/service/impl/DeviceApiServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/nettyapi/service/impl/DeviceApiServiceImpl.java index ebb50d9..c76c3b2 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/nettyapi/service/impl/DeviceApiServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/nettyapi/service/impl/DeviceApiServiceImpl.java @@ -59,6 +59,8 @@ public class DeviceApiServiceImpl implements DeviceApiService { private SysDeviceService sysDeviceService; @Autowired private TenDoorCardService tenDoorCardService; + @Autowired + private RedisUtils redisUtils; /* @@ -384,9 +386,12 @@ public class DeviceApiServiceImpl implements DeviceApiService { } //保存人脸个数 - deviceEntity.setFaceCount(faceCount); - deviceEntity.setLastUpdateTime(new Date()); - tenDeviceService.evictupdateById(deviceEntity); +// deviceEntity.setFaceCount(faceCount); +// deviceEntity.setLastUpdateTime(new Date()); +// tenDeviceService.evictupdateById(deviceEntity); + + //缓存 + redisUtils.set("HearTBeat-"+sn,faceCount+"="+DateUtils.format(new Date(),DateUtils.DATE_TIME_PATTERN),31536000l);//保存一年 TenCellEntity cellEntity = tenCellService.getById(deviceEntity.getCellId()); @@ -521,6 +526,7 @@ public class DeviceApiServiceImpl implements DeviceApiService { SysDeviceEntity sysDeviceEntity = sysDeviceService.getOne(new QueryWrapper() .eq("sn",sn)); +// SysDeviceEntity sysDeviceEntity = sysDeviceService.getBySn(sn); if(sysDeviceEntity.getState() == 0){ Result res = Result.error(202, "Device Is Stop"); String resContent = JSONObject.toJSONString(res); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/SysDeviceService.java b/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/SysDeviceService.java index 368d34d..480eee8 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/SysDeviceService.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/SysDeviceService.java @@ -13,5 +13,6 @@ import java.util.Map; public interface SysDeviceService extends IService { PageUtils queryPage(Map params); + SysDeviceEntity getBySn(String sn); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysDeviceServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysDeviceServiceImpl.java index 9ea4391..3392cee 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysDeviceServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysDeviceServiceImpl.java @@ -15,6 +15,7 @@ import net.shapelight.modules.ten.dao.TenDeviceDao; import net.shapelight.modules.ten.entity.TenDeviceEntity; import net.shapelight.modules.ten.service.*; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -75,4 +76,11 @@ public class SysDeviceServiceImpl extends ServiceImpl() + .eq("sn",sn)); + return sysDeviceEntity; + } } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenDeviceServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenDeviceServiceImpl.java index 0935000..f7367c0 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenDeviceServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenDeviceServiceImpl.java @@ -19,10 +19,7 @@ import org.springframework.stereotype.Service; import java.io.Serializable; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; +import java.util.*; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -120,8 +117,6 @@ public class TenDeviceServiceImpl extends ServiceImpl params) { + + Long tenantId = (Long)params.get("tenantId"); + Page pageParam = new Page(); pageParam.setCurrent(Long.parseLong((String) params.get("page"))); pageParam.setSize(Long.parseLong((String) params.get("limit"))); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/xian/service/XaApi.java b/shapelight-admin/src/main/java/net/shapelight/modules/xian/service/XaApi.java index 4894485..9b9d31e 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/xian/service/XaApi.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/xian/service/XaApi.java @@ -97,10 +97,11 @@ public class XaApi { */ public static String httpPOSTJson(String url, String json, String serviceId, String serviceValue, String appid, String secre, String tranId) { String data = ""; + HttpURLConnection conn = null; try { URL dataurl = new URL(url); - HttpURLConnection conn = (HttpURLConnection) dataurl.openConnection(); + conn = (HttpURLConnection) dataurl.openConnection(); try { conn.setRequestMethod("POST"); String currdate = new SimpleDateFormat("yyyyMMdd").format(new Date()); @@ -121,6 +122,12 @@ public class XaApi { conn.setDoOutput(true); conn.setDoInput(true); + //连接建立超时时间还有读取数据超时时间, + conn.setConnectTimeout(600000); + conn.setReadTimeout(600000); + + conn.connect(); + // String params = "appid=" + URLEncoder.encode(appid, "UTF-8") + "&appsecret=" + URLEncoder.encode(secre, "UTF-8"); // OutputStream outputStream = conn.getOutputStream(); // outputStream.write(params.getBytes()); @@ -146,7 +153,12 @@ public class XaApi { is.close(); dis.close(); } catch (Exception e) { + log.error("请求失败"+url+"\n"+e.getMessage()); data = ""; + } finally { + if(conn!=null){ + conn.disconnect(); + } } return data; } diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenRecordDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenRecordDao.xml index 7bb4f1e..5552c22 100644 --- a/shapelight-admin/src/main/resources/mapper/ten/TenRecordDao.xml +++ b/shapelight-admin/src/main/resources/mapper/ten/TenRecordDao.xml @@ -381,7 +381,9 @@ select r.*,t.name from ten_record_${params.tenantId} r left join ten_person t on r.person_id = t.person_id - where 1=1 + left join ten_device d on r.device_sn = d.sn + where d.tenant_id = #{params.tenantId} + and d.delete_flag = 0 and r.cell_id = #{params.cellId} @@ -398,6 +400,7 @@ and `record_time` < #{params.recordTimeEnd} order by record_time desc +