From cc45b945d86a6c3c7cc99f17fedc0343f49a14b1 Mon Sep 17 00:00:00 2001
From: sgj <1442489573@qq.com>
Date: 星期二, 24 三月 2026 10:08:11 +0800
Subject: [PATCH] 数量监测按钮修复
---
fzzy-igdss-web/src/main/java/com/fzzy/security/manager/SecManager.java | 280 +++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 246 insertions(+), 34 deletions(-)
diff --git a/fzzy-igdss-web/src/main/java/com/fzzy/security/manager/SecManager.java b/fzzy-igdss-web/src/main/java/com/fzzy/security/manager/SecManager.java
index 0c663cd..7433680 100644
--- a/fzzy-igdss-web/src/main/java/com/fzzy/security/manager/SecManager.java
+++ b/fzzy-igdss-web/src/main/java/com/fzzy/security/manager/SecManager.java
@@ -4,26 +4,29 @@
import com.fzzy.igds.camera.ApiCameraManager;
import com.fzzy.igds.camera.data.ApiCameraData;
import com.fzzy.igds.camera.data.ApiCameraResp;
+import com.fzzy.igds.constant.DepotType;
+import com.fzzy.igds.constant.OrderRespEnum;
import com.fzzy.igds.constant.RespCodeEnum;
+import com.fzzy.igds.data.GroupIndexData;
+import com.fzzy.igds.data.IgdsBaseParam;
import com.fzzy.igds.data.PageResponse;
import com.fzzy.igds.data.PatrolSuperData;
-import com.fzzy.igds.domain.Camera;
-import com.fzzy.igds.domain.Dept;
-import com.fzzy.igds.domain.Patrol;
-import com.fzzy.igds.domain.PatrolRecord;
-import com.fzzy.igds.service.CoreDeptService;
-import com.fzzy.igds.service.PatrolService;
-import com.fzzy.igds.service.SecCameraService;
+import com.fzzy.igds.domain.*;
+import com.fzzy.igds.io.manager.QuantityRemoteManager;
+import com.fzzy.igds.io.service.RemoteQuantityService;
+import com.fzzy.igds.request.QuantityRequest;
+import com.fzzy.igds.response.BaseResponse;
+import com.fzzy.igds.service.*;
import com.fzzy.igds.utils.ContextUtil;
import com.fzzy.igds.utils.DateUtil;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
+
import javax.annotation.Resource;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* @Description
@@ -35,6 +38,10 @@
public class SecManager {
@Resource
+ private CommonManager commonManager;
+ @Resource
+ private QuantityRemoteManager remoteManager;
+ @Resource
private SecCameraService secCameraService;
@Resource
private ApiCameraManager apiCameraManager;
@@ -43,22 +50,23 @@
@Resource
private CoreDeptService coreDeptService;
@Resource
- private CommonManager commonManager;
+ private QuantityService quantityService;
+ @Resource
+ private FileService fileService;
/**
- *
* @param deptId
* @param companyId
* @return
*/
public List<Camera> listCamera(String deptId, String companyId) {
- if (null == deptId){
+ if (null == deptId) {
return null;
}
List<Camera> list = secCameraService.getCameraByDeptId(companyId, deptId);
- if (null == list || list.isEmpty()){
+ if (null == list || list.isEmpty()) {
return null;
}
@@ -67,6 +75,7 @@
/**
* 鏍规嵁鐩戞帶ID鑾峰彇鐩戞帶淇℃伅
+ *
* @param companyId
* @param cameraId
* @return
@@ -75,7 +84,7 @@
if (StringUtils.isEmpty(companyId)) {
companyId = ContextUtil.getCompanyId();
}
- if (StringUtils.isEmpty(cameraId)){
+ if (StringUtils.isEmpty(cameraId)) {
return null;
}
return secCameraService.getCameraById(companyId, cameraId);
@@ -83,20 +92,21 @@
/**
* 鑾峰彇鎾斁淇℃伅
+ *
* @param param
* @return
*/
public ApiCameraResp getPlayAddr(Camera param, String requireIp) {
- if (StringUtils.isEmpty(param.getId())) {
+ if (StringUtils.isEmpty(param.getId()) || StringUtils.isEmpty(param.getPlayType())) {
log.error("娌℃湁鑾峰彇鍒扮洃鎺т俊鎭紒");
return new ApiCameraResp("ERROR", "娌℃湁鑾峰彇鍒扮洃鎺т俊鎭紒");
}
// 鏍规嵁id鑾峰彇璁惧淇℃伅
Camera camera = secCameraService.getCameraById(ContextUtil.getCompanyId(), param.getId());
- if(null == camera){
- log.error("缂撳瓨涓病鏈夎幏鍙栧埌鎽勫儚澶翠俊鎭�"+ param.toString());
+ if (null == camera) {
+ log.error("缂撳瓨涓病鏈夎幏鍙栧埌鎽勫儚澶翠俊鎭�" + param.toString());
return new ApiCameraResp("ERROR", "缂撳瓨涓病鏈夎幏鍙栧埌鎽勫儚澶翠俊鎭紒");
}
@@ -108,7 +118,7 @@
apiCameraData.setIp(camera.getIp());
apiCameraData.setCtrlPort(camera.getControlPort());
apiCameraData.setWebPort(camera.getWebPort());
- apiCameraData.setPlayType(camera.getPlayType());
+ apiCameraData.setPlayType(param.getPlayType());
apiCameraData.setSnapType(camera.getSnapType());
apiCameraData.setSn(camera.getSn());
apiCameraData.setChannel(camera.getChanNum());
@@ -119,18 +129,19 @@
apiCameraData.setMediaAddr(camera.getMediaAddr());
//鏍规嵁鎾斁鏂瑰紡鑾峰彇瀵瑰簲鐨勬挱鏀惧湴鍧�
- ApiCameraResp resp = apiCameraManager.getApiCameraService(camera.getPlayType()).getPlayAddr(apiCameraData);
+ ApiCameraResp resp = apiCameraManager.getApiCameraService(apiCameraData.getPlayType()).getPlayAddr(apiCameraData);
return resp;
}
/**
* 浜戝彴鎺у埗
+ *
* @param param
* @return
*/
public ApiCameraResp ptzMedia(ApiCameraData param) {
- if(StringUtils.isEmpty(param.getCompanyId())){
+ if (StringUtils.isEmpty(param.getCompanyId())) {
param.setCompanyId(ContextUtil.getCompanyId());
}
return apiCameraManager.getApiCameraService(param.getPtzType()).ptzMedia(param);
@@ -138,6 +149,7 @@
/**
* 棰勭疆浣嶈缃�
+ *
* @param param
* @return
*/
@@ -146,7 +158,6 @@
}
/**
- *
* @param params
* @return
*/
@@ -162,19 +173,20 @@
}
secCameraService.refreshCache(ContextUtil.getCompanyId());
- return new PageResponse<>(RespCodeEnum.CODE_0000, "鎵ц鎴愬姛锛侊紒");
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛锛侊紒");
}
/**
* 宸℃缁熻
+ *
* @return
*/
public PatrolSuperData patrolTrack() {
PatrolSuperData patrolSuperData = new PatrolSuperData();
List<Dept> deptList = coreDeptService.getDeptData();
- if(null == deptList || deptList.isEmpty()){
- return patrolSuperData;
+ if (null == deptList || deptList.isEmpty()) {
+ return patrolSuperData;
}
//搴撳尯杞崲
@@ -185,7 +197,7 @@
List<Patrol> weekList = patrolService.getWeekList();
- if(null != weekList && weekList.size() > 0){
+ if (null != weekList && weekList.size() > 0) {
Date start = DateUtil.getCurZero(DateUtil.getNewByDay(new Date(), -1)); //鏄ㄥぉ闆剁偣闆跺垎
Date end = DateUtil.getCurZero(new Date()); //浠婂ぉ闆剁偣闆跺垎
for (Patrol patrol : weekList) {
@@ -193,13 +205,13 @@
patrolSuperData.setWeekSum(patrolSuperData.getWeekSum() + 1);
//鏄ㄥぉ浜烘
- if(patrol.getCreateTime().after(start) && patrol.getCreateTime().before(end)){
+ if (patrol.getCreateTime().after(start) && patrol.getCreateTime().before(end)) {
patrolSuperData.setYesterdaySum(patrolSuperData.getYesterdaySum() + 1);
}
//褰撳ぉ缁熻
- if(patrol.getCreateTime().after(end)){
- if(map.get(patrol.getDeptId()) == 0){
+ if (patrol.getCreateTime().after(end)) {
+ if (map.get(patrol.getDeptId()) == 0) {
patrolSuperData.setIsDeptNum(patrolSuperData.getIsDeptNum() + 1);
map.put(patrol.getDeptId(), map.get(patrol.getDeptId()) + 1);
}
@@ -217,17 +229,217 @@
* @param patrolId
* @return
*/
- public List<PatrolRecord> getRecordByPatrolId(String patrolId) {
+ public List<PatrolRecord> getRecordByPatrolId(String patrolId,String userId,String confId) {
- List<PatrolRecord> patrolRecords = patrolService.getRecordByPatrolId(patrolId);
+ List<PatrolRecord> patrolRecords = patrolService.getRecordByPatrolId(patrolId,userId,confId);
- if(null != patrolRecords && !patrolRecords.isEmpty()){
+ if (null != patrolRecords && !patrolRecords.isEmpty()) {
//鍒ゆ柇鏂囦欢鏄惁瀛樺湪
for (PatrolRecord record : patrolRecords) {
- record.setImgName(commonManager.isImgExit( record.getImgName(), null));
+ record.setImgName(commonManager.isImgExit(record.getImgName(), null));
}
}
return patrolRecords;
}
+
+ /**
+ * 鑾峰彇鏁伴噺妫�娴嬮厤缃俊鎭�
+ *
+ * @param deptId
+ * @return
+ */
+ public List<QuantityConf> getQuantityConfByDeptId(String deptId) {
+
+ return quantityService.getConfList(ContextUtil.getCompanyId(), deptId);
+ }
+
+ /**
+ * 鏌ヨ鏁伴噺妫�娴嬭褰曪紝榛樿鏌ヨ4鏉�
+ *
+ * @param param
+ * @return
+ */
+ public PageResponse<List<Quantity>> quantityList(IgdsBaseParam param) {
+
+ if (StringUtils.isEmpty(param.getDepotId())) {
+ return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(), "鍙傛暟涓虹┖锛侊紒");
+ }
+
+ List<Quantity> quantityList = quantityService.getQuantityList(param.getDepotId(), 4);
+ if (null == quantityList || quantityList.isEmpty()) {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), "鏁版嵁涓虹┖锛侊紒");
+ }
+
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛锛侊紒", quantityList);
+ }
+
+ /**
+ * 鏌ヨ鏁伴噺妫�娴嬭褰曪紝榛樿鏌ヨ7鏉★紝灏佽鎴愬浘琛ㄤ俊鎭�
+ *
+ * @param param
+ * @return
+ */
+ public PageResponse<GroupIndexData> getQuantityChart(IgdsBaseParam param) {
+
+ if (StringUtils.isEmpty(param.getDepotId())) {
+ return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(), "鍙傛暟涓虹┖锛侊紒");
+ }
+
+
+ List<Quantity> quantityList = quantityService.getQuantityList(param.getDepotId(), 7);
+ if (null == quantityList || quantityList.isEmpty()) {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), "鏁版嵁涓虹┖锛侊紒");
+ }
+
+ GroupIndexData data = new GroupIndexData();
+
+ for (int i = (quantityList.size() - 1); i >= 0; i--) {
+ data.getXaxis().add(DateFormatUtils.format(quantityList.get(i).getReceiveDate(), "MM-dd HH:mm"));
+ data.getSeriesData().add(quantityList.get(i).getWeight() + "");
+ }
+
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛锛侊紒", data);
+ }
+
+ /**
+ * 鏌ヨ妫�娴嬫暟鎹搴旀姄鍥�
+ * @param param
+ * @return
+ */
+ public PageResponse<List<FileInfo>> getQuantityFiles(IgdsBaseParam param) {
+
+ if (StringUtils.isEmpty(param.getKey())) {
+ return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(), "鍙傛暟涓虹┖锛侊紒");
+ }
+
+ List<FileInfo> fileList = fileService.listFile(null, param.getKey());
+ if (null == fileList || fileList.isEmpty()) {
+ return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), "鏁版嵁涓虹┖锛侊紒");
+ }
+
+ //鍒ゆ柇鏂囦欢鏄惁瀛樺湪
+ for (FileInfo fileInfo : fileList) {
+ fileInfo.setFilePath(commonManager.isImgExit(fileInfo.getFilePath(), null));
+ }
+
+ return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "鎵ц鎴愬姛锛侊紒", fileList);
+ }
+
+ /**
+ * 鍗曚粨妫�娴�
+ *
+ * @param param
+ * @return
+ */
+ public BaseResponse checkSingle(IgdsBaseParam param) {
+ if (null == param || StringUtils.isBlank(param.getDepotId())) {
+ return new BaseResponse(RespCodeEnum.CODE_1007.getCode(), RespCodeEnum.CODE_1007.getMsg());
+ }
+
+ if (StringUtils.isBlank(param.getCompanyId())) {
+ param.setCompanyId(ContextUtil.getCompanyId());
+ }
+
+ QuantityConf conf = quantityService.getCacheQuantityConf(param.getCompanyId(), param.getDepotId());
+ if (conf == null) {
+ return new BaseResponse(RespCodeEnum.CODE_1007.getCode(), RespCodeEnum.CODE_1007.getMsg());
+ }
+
+ RemoteQuantityService remoteQuantityService = remoteManager.getRemoteQuantityService(conf.getProtocol());
+
+ if (null == remoteQuantityService) {
+ return new BaseResponse(OrderRespEnum.ORDER_ERROR.getCode(),
+ "绯荤粺娌℃湁" + conf.getProtocol() + "鐨勫崗璁疄鐜帮紝鎵ц琚嫆缁濓紒");
+ }
+
+ QuantityRequest request = new QuantityRequest();
+ BeanUtils.copyProperties(conf, request);
+ request.setDepotId(conf.getDepotId());
+ request.setYtIp(conf.getYtIp());
+ request.setCompanyId(conf.getCompanyId());
+ request.setDeptId(conf.getDeptId());
+ request.setSn(conf.getSn());
+ request.setLength(conf.getLength());
+ request.setExeUser(ContextUtil.getLoginUserName());
+
+ request.setBatchId(conf.getDepotId() + "_" + DateFormatUtils.format(new Date(), "yyyyMMddHHmm"));
+
+ return remoteQuantityService.checkStart(request);
+ }
+
+ /**
+ * 鍋滄妫�娴�
+ * @param param
+ * @return
+ */
+ public BaseResponse checkStop(IgdsBaseParam param) {
+ if (param == null || StringUtils.isEmpty(param.getDepotId())) {
+ return new BaseResponse(RespCodeEnum.CODE_1007.getCode(), RespCodeEnum.CODE_1007.getMsg());
+ }
+
+ if (StringUtils.isEmpty(param.getCompanyId())) {
+ param.setCompanyId(ContextUtil.getCompanyId());
+ }
+
+ QuantityConf conf = quantityService.getCacheQuantityConf(param.getCompanyId(), param.getDepotId());
+ if (conf == null) {
+ return new BaseResponse(RespCodeEnum.CODE_1007.getCode(), RespCodeEnum.CODE_1007.getMsg());
+ }
+
+ RemoteQuantityService remoteQuantityService = remoteManager.getRemoteQuantityService(conf.getProtocol());
+
+ if (null == remoteQuantityService) {
+ return new BaseResponse(OrderRespEnum.ORDER_ERROR.getCode(),
+ "绯荤粺娌℃湁" + conf.getProtocol() + "鐨勫崗璁疄鐜帮紝鎵ц琚嫆缁濓紒");
+ }
+
+ QuantityRequest request = new QuantityRequest();
+ BeanUtils.copyProperties(conf, request);
+ request.setCompanyId(conf.getCompanyId());
+ request.setYtIp(conf.getYtIp());
+ request.setSn(conf.getSn());
+ request.setDeptId(conf.getDeptId());
+ request.setDepotId(conf.getDepotId());
+
+ return remoteQuantityService.checkStop(request);
+ }
+
+
+ /**
+ * 鑾峰彇娌圭綈娌规儏鍙婃恫浣嶄俊鎭�
+ *
+ * @param deptId
+ * @return
+ */
+ public List<Quantity> getHeightList(String deptId) {
+
+ if (StringUtils.isEmpty(deptId)) {
+ deptId = ContextUtil.subDeptId(null);
+ }
+ //鑾峰彇鎵�鏈夌瓛浠撳強娴呭渾浠�
+ List<Depot> depotList = commonManager.listAllDepot(deptId, DepotType.TYPE_02.getCode() + "," + DepotType.TYPE_04.getCode());
+ if (null == depotList || depotList.isEmpty()) {
+ return null;
+ }
+
+ List<Quantity> list = new ArrayList<>();
+ List<Quantity> quantityList;
+ Quantity quantity;
+ for (Depot depot : depotList) {
+
+ quantityList = quantityService.getQuantityList(depot.getId(), 1);
+ if (null == quantityList || quantityList.isEmpty()) {
+ quantity = new Quantity();
+ quantity.setDepotId(depot.getId());
+ }else {
+ quantity = quantityList.get(0);
+ }
+ quantity.setDepotData(depot);
+
+ list.add(quantity);
+ }
+
+ return list;
+ }
}
--
Gitblit v1.9.3