| | |
| | | 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.OrderRespEnum; |
| | | import com.fzzy.igds.constant.RespCodeEnum; |
| | | 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.data.*; |
| | | 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.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | |
| | | public class SecManager { |
| | | |
| | | @Resource |
| | | private CommonManager commonManager; |
| | | @Resource |
| | | private QuantityRemoteManager remoteManager; |
| | | @Resource |
| | | private SecCameraService secCameraService; |
| | | @Resource |
| | | private ApiCameraManager apiCameraManager; |
| | |
| | | @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; |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 根据监控ID获取监控信息 |
| | | * |
| | | * @param companyId |
| | | * @param cameraId |
| | | * @return |
| | |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | if (StringUtils.isEmpty(cameraId)){ |
| | | if (StringUtils.isEmpty(cameraId)) { |
| | | return null; |
| | | } |
| | | return secCameraService.getCameraById(companyId, cameraId); |
| | |
| | | |
| | | /** |
| | | * 获取播放信息 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | |
| | | |
| | | // 根据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", "缓存中没有获取到摄像头信息!"); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 云台控制 |
| | | * |
| | | * @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); |
| | |
| | | |
| | | /** |
| | | * 预置位设置 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | //库区转换 |
| | |
| | | |
| | | 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) { |
| | |
| | | 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); |
| | | } |
| | |
| | | |
| | | List<PatrolRecord> patrolRecords = patrolService.getRecordByPatrolId(patrolId); |
| | | |
| | | 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.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); |
| | | } |
| | | } |