| | |
| | | import com.fzzy.igds.domain.Camera; |
| | | import com.fzzy.igds.service.SecCameraService; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.PageRequest; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.jpa.domain.Specification; |
| | | import org.springframework.stereotype.Component; |
| | | import javax.persistence.criteria.CriteriaBuilder; |
| | | import javax.persistence.criteria.CriteriaQuery; |
| | | import javax.persistence.criteria.Predicate; |
| | | import javax.persistence.criteria.Root; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description |
| | |
| | | * @param param |
| | | */ |
| | | @DataProvider |
| | | public void listPageCamera(Page<Camera> page, Map<String, Object> param) { |
| | | org.springframework.data.domain.Page<Camera> japPage = pageCamera(page, param); |
| | | page.setEntityCount((int) japPage.getTotalElements()); |
| | | page.setEntities(japPage.getContent()); |
| | | } |
| | | public void listPageCamera(Page<Camera> page, Camera param) { |
| | | com.baomidou.mybatisplus.extension.plugins.pagination.Page<Camera> corePage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page.getPageNo(), page.getPageSize()); |
| | | |
| | | public org.springframework.data.domain.Page<Camera> pageCamera(Page<Camera> page, Map<String, Object> param) { |
| | | if (null == param) { |
| | | param = new HashMap<>(); |
| | | if(null == param) { |
| | | param = new Camera(); |
| | | } |
| | | Map<String, Object> finalParam = param; |
| | | Camera camera = new Camera(); |
| | | BeanUtils.copyProperties(param, camera); |
| | | secCameraService.listPageCamera(corePage, camera); |
| | | |
| | | //多参数分页查询 |
| | | Pageable pageable = PageRequest.of(page.getPageNo() - 1, page.getPageSize(), Sort.Direction.ASC, Camera.SORT_PROP); |
| | | Specification<Camera> specification = new Specification<Camera>() { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public Predicate toPredicate(Root<Camera> root, CriteriaQuery<?> query, CriteriaBuilder cb) { |
| | | List<Predicate> predicates = new ArrayList<Predicate>(); //所有的断言 |
| | | |
| | | Predicate predicate1 = cb.equal(root.get("companyId"), ContextUtil.getCompanyId()); |
| | | predicates.add(predicate1); |
| | | Predicate predicate2 = cb.equal(root.get("deptId"), ContextUtil.subDeptId(null)); |
| | | predicates.add(predicate2); |
| | | |
| | | String key = (String) finalParam.get("bizType"); |
| | | if (StringUtils.isNotEmpty(key)) { |
| | | Predicate predicate3 = cb.equal(root.get("bizType"), key); |
| | | predicates.add(predicate3); |
| | | } |
| | | key = (String) finalParam.get("name"); |
| | | if (StringUtils.isNotEmpty(key)) { |
| | | Predicate predicate4 = cb.like(root.get("name"), "%" + key + "%"); |
| | | predicates.add(predicate4); |
| | | } |
| | | key = (String) finalParam.get("brand"); |
| | | if (StringUtils.isNotEmpty(key)) { |
| | | Predicate predicate5 = cb.equal(root.get("brand"), key); |
| | | predicates.add(predicate5); |
| | | } |
| | | key = (String) finalParam.get("spjklx"); |
| | | if (StringUtils.isNotEmpty(key)) { |
| | | Predicate predicate5 = cb.equal(root.get("spjklx"), key); |
| | | predicates.add(predicate5); |
| | | } |
| | | key = (String) finalParam.get("spdwlx"); |
| | | if (StringUtils.isNotEmpty(key)) { |
| | | Predicate predicate5 = cb.equal(root.get("spdwlx"), key); |
| | | predicates.add(predicate5); |
| | | } |
| | | return cb.and(predicates.toArray(new Predicate[0])); |
| | | } |
| | | }; |
| | | org.springframework.data.domain.Page<Camera> japPage = secCameraService.findAll(specification, pageable); |
| | | return japPage; |
| | | // 重新封装 |
| | | page.setEntities(corePage.getRecords()); |
| | | page.setEntityCount(Integer.parseInt(String.valueOf(corePage.getTotal()))); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @DataProvider |
| | | public List<Camera> listCamera() { |
| | | return secCameraService.listCamera(); |
| | | return secCameraService.listCamera(ContextUtil.getCompanyId(),ContextUtil.subDeptId(null)); |
| | | } |
| | | |
| | | /** |
| | |
| | | public String refreshCache() { |
| | | secCameraService.refreshCache(ContextUtil.getCompanyId()); |
| | | return null; |
| | | } |
| | | |
| | | /*** |
| | | * securityPR#flushByMedia |
| | | * |
| | | * 获取摄像头列表信息 |
| | | * @return |
| | | */ |
| | | @Expose |
| | | public String flushByMedia(String playType) { |
| | | |
| | | if (null == playType){ |
| | | return "没有选择播放方式,执行失败"; |
| | | } |
| | | |
| | | // try { |
| | | // if (CameraUtil.PLAY_TYPE_MEDIA_HIK.equals(playType)) { |
| | | // ApiCameraData apiCameraData = new ApiCameraData(); |
| | | // apiCameraData.setCompanyId(ContextUtil.getCompanyId()); |
| | | // apiCameraData.setDeptId(ContextUtil.subDeptId(null)); |
| | | // apiCameraData.setPlayType(playType); |
| | | // List<SecCameraDto> list = apiCameraManager.getApiCameraService(playType).searchCamera(apiCameraData); |
| | | // if(list == null){ |
| | | // return "同步失败!"; |
| | | // }else { |
| | | // return "同步成功!"; |
| | | // } |
| | | // } |
| | | return "当前播放方式没有此功能!"; |
| | | // |
| | | // }catch (Exception e){ |
| | | // log.error("-----同步摄像头列表失败-----原因={}", e.toString()); |
| | | // return "远程接口服务异常,请核查后重试!"; |
| | | // } |
| | | |
| | | } |
| | | |
| | | } |