ycl-pojo/src/main/java/com/ycl/platform/domain/result/OSDResult.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/OsdCheckResult.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-server/src/main/java/com/ycl/api/DH/module/LoginModule.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-server/src/main/java/com/ycl/api/HK/HKApi.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-server/src/main/java/com/ycl/api/YS/YSApi.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-server/src/main/java/com/ycl/platform/controller/CheckScoreController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-server/src/main/java/com/ycl/task/MonitorTask.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-server/src/main/java/com/ycl/task/OsdTask.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
ycl-pojo/src/main/java/com/ycl/platform/domain/result/OSDResult.java
@@ -41,4 +41,6 @@ * 固、枪、路、西北 */ private String OSD4; private Integer deviceBrand; } ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/OsdCheckResult.java
@@ -23,6 +23,10 @@ private String deviceNo; /** * 摄像机品牌 */ private Integer deviceBrand; /** * 设备类型 */ private String deviceType; ycl-server/src/main/java/com/ycl/api/DH/module/LoginModule.java
@@ -11,6 +11,7 @@ import com.ycl.api.DH.lib.structure.*; import com.ycl.platform.domain.result.OSDResult; import com.ycl.utils.StringUtils; import enumeration.DeviceType; import lombok.extern.slf4j.Slf4j; import java.io.File; @@ -215,6 +216,7 @@ } } } osdResult.setDeviceBrand(DeviceType.DH.getType()); return osdResult; } ycl-server/src/main/java/com/ycl/api/HK/HKApi.java
@@ -3,6 +3,7 @@ import com.ycl.platform.domain.result.OSDResult; import com.ycl.utils.StringUtils; import constant.ApiConstants; import enumeration.DeviceType; import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpResponse; import org.apache.http.auth.AuthScope; @@ -49,6 +50,7 @@ Date date = new Date(); //解析xml parseXMl(timeString, "Time", "localTime", osdResult, date, ip); osdResult.setDeviceBrand(DeviceType.HK.getType()); } catch (Exception e) { return null; } ycl-server/src/main/java/com/ycl/api/YS/YSApi.java
@@ -6,6 +6,7 @@ import com.ycl.api.YS.lib.NetDEVSDKLib; import com.ycl.api.YS.login.Login; import com.ycl.platform.domain.result.OSDResult; import enumeration.DeviceType; import lombok.extern.slf4j.Slf4j; import java.nio.charset.StandardCharsets; @@ -109,6 +110,7 @@ } //登出 YSInit.netdevsdk.NETDEV_Logout(lpUserID); osdResult.setDeviceBrand(DeviceType.YS.getType()); return osdResult; } else { // log.error("ip:"+ip+",error code" + YSInit.netdevsdk.NETDEV_GetLastError()); ycl-server/src/main/java/com/ycl/platform/controller/CheckScoreController.java
@@ -73,7 +73,6 @@ @GetMapping(value = "/detail/index") public AjaxResult getIndex(CheckScoreIndexDTO checkScoreIndexDTO) { return success(checkScoreService.selectCheckScoreById(checkScoreIndexDTO)); } ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java
@@ -17,6 +17,7 @@ import com.ycl.platform.service.ICheckIndexVideoService; import com.ycl.platform.service.ICheckScoreService; import com.ycl.system.entity.SysRole; import com.ycl.system.entity.SysUser; import com.ycl.system.service.ISysDeptService; import com.ycl.utils.DateUtils; import com.ycl.utils.SecurityUtils; @@ -44,8 +45,7 @@ */ @Service @Slf4j public class CheckScoreServiceImpl extends ServiceImpl<CheckScoreMapper, CheckScore> implements ICheckScoreService { public class CheckScoreServiceImpl extends ServiceImpl<CheckScoreMapper, CheckScore> implements ICheckScoreService { @Autowired private CheckScoreMapper scoreMapper; @Autowired @@ -62,6 +62,7 @@ private ICheckIndexVideoService indexVideoService; @Autowired private ISysDeptService deptService; /** * 查询考核积分指标 * @@ -69,9 +70,8 @@ * @return 考核积分 */ @Override @DataScope(deptAlias = "d",userAlias = "u") public CheckScoreDetailVO selectCheckScoreById(CheckScoreIndexDTO checkScoreIndexDTO) { @DataScope(deptAlias = "d", userAlias = "u") public CheckScoreDetailVO selectCheckScoreById(CheckScoreIndexDTO checkScoreIndexDTO) { Long checkScoreId = checkScoreIndexDTO.getId(); CheckScoreDetailVO checkScoreDetailVO = new CheckScoreDetailVO(); @@ -82,7 +82,7 @@ List<CheckRule> checkRules = new ArrayList<>(); //读取模板对应所有规则 Map<String,Object> scoreMap = new HashMap<>(); Map<String, Object> scoreMap = new HashMap<>(); List<Integer> ruleIds = templateRuleList.stream().map(checkTemplateRule -> checkTemplateRule.getCheckRuleId()) .collect(Collectors.toList()); List<CheckRule> ruleIndex = ruleMapper.selectBatchIds(ruleIds); @@ -90,7 +90,7 @@ checkRules.addAll(ruleIndex); //根据examineCategory 读取不同index表 Short examineCategory = checkScore.getExamineCategory(); String[] indexTableArr ={"","t_check_index_video","t_check_index_car","t_check_index_face"}; String[] indexTableArr = {"", "t_check_index_video", "t_check_index_car", "t_check_index_face"}; String tableName = indexTableArr[examineCategory]; ScoreIndexDTO scoreIndexDTO = new ScoreIndexDTO() @@ -101,7 +101,7 @@ scoreIndexDTO.setParams(checkScoreIndexDTO.getParams()); scoreIndexDTO.setExamineTag(checkScore.getExamineTag()); //获当月份 if(StringUtils.isEmpty(scoreIndexDTO.getDate()) && CollectionUtils.isEmpty(checkScoreIndexDTO.getQuarter())){ if (StringUtils.isEmpty(scoreIndexDTO.getDate()) && CollectionUtils.isEmpty(checkScoreIndexDTO.getQuarter())) { //如果查询条件不含参数,查询积分对应创建时间 Date createTime = checkScore.getCreateTime(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); @@ -110,8 +110,8 @@ List<Map> map = scoreMapper.selectScoreIndex(scoreIndexDTO); scoreMap.put("tableData",checkRules); scoreMap.put("dataMap",map); scoreMap.put("tableData", checkRules); scoreMap.put("dataMap", map); checkScoreDetailVO.setCheckRuleList(templateRuleList); checkScoreDetailVO.setScoreMap(scoreMap); @@ -126,9 +126,8 @@ * @return 考核积分 */ @Override @DataScope(deptAlias = "d",userAlias = "u") public Map<Long, List<CheckScore>> selectCheckScoreList(CheckScore checkScore) { @DataScope(deptAlias = "d", userAlias = "u") public Map<Long, List<CheckScore>> selectCheckScoreList(CheckScore checkScore) { //区县只能看已发布 roleControl(checkScore); @@ -137,7 +136,9 @@ getCheckScore(checkScore, calendar); // 一号查询之前的数据 if (LocalDateTime.now().getDayOfMonth() == 1) { calendar.add(Calendar.DAY_OF_MONTH, -1); } if (LocalDateTime.now().getDayOfMonth() == 1) { calendar.add(Calendar.DAY_OF_MONTH, -1); } List<CheckScore> checkScores = scoreMapper.selectCheckScoreMap(checkScore); @@ -153,8 +154,7 @@ return checkScores.stream().collect(Collectors.groupingBy(CheckScore::getDeptId)); } private void getCheckScore(CheckScore checkScore, Calendar calendar) { private void getCheckScore(CheckScore checkScore, Calendar calendar) { // 0 省厅月度 1 市局月度 2 省厅季度 3 市局季度 switch (checkScore.getExamineTag()) { case 0, 1: @@ -177,15 +177,14 @@ * @return 考核积分 */ @Override @DataScope(deptAlias = "d",userAlias = "u") public Map<Long, List<CheckScore>> selectCheckScoreChart(CheckScore checkScore) { @DataScope(deptAlias = "d", userAlias = "u") public Map<Long, List<CheckScore>> selectCheckScoreChart(CheckScore checkScore) { //区县只能看已发布 roleControl(checkScore); //查询成绩 String date = checkScore.getDate(); if(StringUtils.isEmpty(date)){ if (StringUtils.isEmpty(date)) { //如果为空查本月的数据 Calendar now = Calendar.getInstance(); //取昨天 @@ -206,7 +205,7 @@ * @return 考核积分 */ @Override @DataScope(deptAlias = "d",userAlias = "u") @DataScope(deptAlias = "d", userAlias = "u") public List<CheckScore> page(CheckScore checkScore) { //区县只能看已发布 roleControl(checkScore); @@ -221,7 +220,7 @@ */ @Override public int publishCheckScore(CheckScoreDTO checkScoreDTO) { if(CollectionUtils.isEmpty(checkScoreDTO.getId())){ if (CollectionUtils.isEmpty(checkScoreDTO.getId())) { return 0; } PublishType publishType = null; @@ -243,11 +242,11 @@ * @return 考核积分 */ @Override public void exportIndex(HttpServletResponse response,CheckScore checkScoreDTO) throws IOException { public void exportIndex(HttpServletResponse response, CheckScore checkScoreDTO) throws IOException { String date = checkScoreDTO.getDate(); Integer examineTag = null; //如果请求参数时间为空,查这条记录的时间 if(StringUtils.isEmpty(checkScoreDTO.getDate()) && CollectionUtils.isEmpty(checkScoreDTO.getQuarter())){ if (StringUtils.isEmpty(checkScoreDTO.getDate()) && CollectionUtils.isEmpty(checkScoreDTO.getQuarter())) { CheckScore checkScore = getById(checkScoreDTO.getId()); Date createTime = checkScore.getCreateTime(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); @@ -260,45 +259,49 @@ CheckIndexCar checkIndexCar = new CheckIndexCar(); checkIndexCar.setDate(date); checkIndexCar.setQuarter(checkScoreDTO.getQuarter()); if(examineTag!=null) { if (examineTag != null) { checkIndexCar.setExamineTag(Short.parseShort(examineTag + "")); } List<CheckIndexCar> checkIndexCars = indexCarService.selectCheckIndexCarList(checkIndexCar); ExcelExp e1 = new ExcelExp("车辆考核指标数据",checkIndexCars,CheckIndexCar.class); ExcelExp e1 = new ExcelExp("车辆考核指标数据", checkIndexCars, CheckIndexCar.class); //人脸 CheckIndexFace checkIndexFace = new CheckIndexFace(); checkIndexFace.setDate(date); checkIndexFace.setQuarter(checkScoreDTO.getQuarter()); if(examineTag!=null) { if (examineTag != null) { checkIndexFace.setExamineTag(Short.parseShort(examineTag + "")); } List<CheckIndexFace> checkIndexFaces = indexFaceService.selectCheckIndexFaceList(checkIndexFace); ExcelExp e2 = new ExcelExp("人脸考核指标数据",checkIndexFaces,CheckIndexFace.class); ExcelExp e2 = new ExcelExp("人脸考核指标数据", checkIndexFaces, CheckIndexFace.class); //视频 CheckIndexVideo checkIndexVideo = new CheckIndexVideo(); checkIndexVideo.setDate(date); checkIndexVideo.setQuarter(checkScoreDTO.getQuarter()); if(examineTag!=null) { if (examineTag != null) { checkIndexVideo.setExamineTag(Short.parseShort(examineTag + "")); } List<CheckIndexVideo> checkIndexVideos = indexVideoService.selectCheckIndexVideoList(checkIndexVideo); ExcelExp e3 = new ExcelExp("视频考核指标数据",checkIndexVideos,CheckIndexVideo.class); ExcelExp e3 = new ExcelExp("视频考核指标数据", checkIndexVideos, CheckIndexVideo.class); List<ExcelExp> mysheet = new ArrayList<>(); mysheet.add(e1); mysheet.add(e2); mysheet.add(e3); ExcelUtilManySheet<List<ExcelExp>> util = new ExcelUtilManySheet<>(mysheet); util.exportExcelManySheet(response,mysheet); util.exportExcelManySheet(response, mysheet); } private void roleControl(CheckScore checkScore) { List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles(); SysRole sysRole = roles.get(0); if("zg_province".equals(sysRole.getRoleKey())){ Map<String, Object> params = checkScore.getParams(); params.put("publish",PublishType.PUBLISHED.getCode()); SysUser user = SecurityUtils.getLoginUser().getUser(); if (!user.isAdmin()) { for (SysRole role : roles) { if (role.getPermissions().contains("check:score:publish")) { Map<String, Object> params = checkScore.getParams(); params.put("publish", PublishType.PUBLISHED.getCode()); } } } } ycl-server/src/main/java/com/ycl/task/MonitorTask.java
@@ -8,6 +8,7 @@ import com.ycl.platform.domain.entity.YwPoint; import com.ycl.platform.domain.result.UY.MonitorQualifyResult; import com.ycl.platform.domain.result.UY.OneMachineFileResult; import com.ycl.platform.domain.result.UY.OsdCheckResult; import com.ycl.platform.domain.vo.TMonitorVO; import com.ycl.platform.mapper.TMonitorMapper; import com.ycl.platform.mapper.YwPointMapper; @@ -59,8 +60,12 @@ //同步mongodb一机一档到数据库 public void synchronize() { log.info("开始同步mongodb一机一档到数据库"); Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); Date yesterday = DateUtils.addDays(new Date(), -1); Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); List<MonitorQualifyResult> oneMachineFileResults = mongoTemplate.find(query, MonitorQualifyResult.class); //mongo品牌数据 Query OSDQuery = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); Map<String, OsdCheckResult> osdMap = mongoTemplate.find(query, OsdCheckResult.class).stream().collect(Collectors.toMap(OsdCheckResult::getDeviceNo, Function.identity())); //数据库monitor表数据 Map<String, TMonitorVO> monitorVOMap = monitorMapper.selectMonitorVOList().stream().collect(Collectors.toMap(TMonitorVO::getSerialNumber, Function.identity())); //点位数据 @@ -82,7 +87,7 @@ //全年留存 for (MonitorQualifyResult result : oneMachineFileResults) { TMonitor monitor = getMonitor(result, monitorVOMap); TMonitor monitor = getMonitor(result, monitorVOMap,osdMap); YwPoint point = getPoint(result, pointMap, importantSite); monitorList.add(monitor); ywPointList.add(point); @@ -97,6 +102,11 @@ if (!numbers.contains(key)){ TMonitor monitor = new TMonitor(); BeanUtils.copyProperties(value,monitor); //填补品牌 OsdCheckResult osdCheckResult = osdMap.get(key); if(osdCheckResult!=null) { monitor.setDeviceType(osdCheckResult.getDeviceBrand()); } monitorList.add(monitor); } }); @@ -156,11 +166,15 @@ return ywPoint; } private TMonitor getMonitor(MonitorQualifyResult result, Map<String, TMonitorVO> monitorVOMap) { private TMonitor getMonitor(MonitorQualifyResult result, Map<String, TMonitorVO> monitorVOMap, Map<String, OsdCheckResult> osdMap) { TMonitor monitor = new TMonitor(); if (monitorVOMap.containsKey(result.getSerialNumber().getValue())) { monitor.setId(monitorVOMap.get(result.getSerialNumber().getValue()).getId()); monitor.setDeviceType(monitorVOMap.get(result.getSerialNumber().getValue()).getDeviceType()); //更新品牌 OsdCheckResult osdCheckResult = osdMap.get(result.getSerialNumber().getValue()); if(osdCheckResult!=null) { monitor.setDeviceType(osdCheckResult.getDeviceBrand()); } } monitor.setSerialNumber(result.getSerialNumber().getValue()); ycl-server/src/main/java/com/ycl/task/OsdTask.java
@@ -66,12 +66,6 @@ */ public void getOSD() { log.info("开始获取OSD"); //批量修改海康品牌集合 List<String> hkList = new ArrayList<>(); //批量修改大华品牌集合 List<String> dhList = new ArrayList<>(); //批量修改宇视品牌集合 List<String> ysList = new ArrayList<>(); List<OSDResult> osdResultList = new ArrayList<>(); //查一机一档monitor Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); @@ -114,7 +108,7 @@ } } //未知品牌或者api调用失败,挨个执行所有api OSDResult osd = tryAllApi(monitor, hkList, dhList, ysList); OSDResult osd = tryAllApi(monitor); if (osd != null) { synchronized (osdResultList) { osdResultList.add(osd); @@ -158,16 +152,6 @@ // 工单生成 uyErrorTypeCheckService.osdCheck(checkResults); } //修改数据库品牌 if (!CollectionUtils.isEmpty(hkList)) { monitorMapper.batchUpdateDeviceType(hkList, DeviceType.HK.getType()); } if (!CollectionUtils.isEmpty(dhList)) { monitorMapper.batchUpdateDeviceType(dhList, DeviceType.DH.getType()); } if (!CollectionUtils.isEmpty(ysList)) { monitorMapper.batchUpdateDeviceType(ysList, DeviceType.YS.getType()); } } log.info("结束获取OSD"); } @@ -184,6 +168,7 @@ osdCheckResult.setOsdPart(osdResult.getOSD3()); osdCheckResult.setOsdLB(osdResult.getOSD4()); osdCheckResult.setOsdName(osdResult.getName()); osdCheckResult.setDeviceBrand(osdResult.getDeviceBrand()); return osdCheckResult; } @@ -248,15 +233,12 @@ } } private OSDResult tryAllApi(TMonitor monitor, List<String> hkList, List<String> dhList, List<String> ysList) { private OSDResult tryAllApi(TMonitor monitor) { //尝试海康的api OSDResult hkosd = HKApi.getOsdByIP(monitor.getIp(), HKUserName, HKPassword); if (hkosd != null) { hkosd.setSerialNumber(monitor.getSerialNumber()); log.info("海康调用成功" + hkosd); synchronized (hkList) { hkList.add(monitor.getSerialNumber()); } return hkosd; } //尝试大华的api @@ -264,9 +246,6 @@ if (dhosd != null) { dhosd.setSerialNumber(monitor.getSerialNumber()); log.info("大华调用成功" + dhosd); synchronized (dhList) { dhList.add(monitor.getSerialNumber()); } return dhosd; } //宇视api @@ -274,9 +253,6 @@ if (ysosd != null) { ysosd.setSerialNumber(monitor.getSerialNumber()); log.info("宇视调用成功" + ysosd); synchronized (ysList) { ysList.add(monitor.getSerialNumber()); } return ysosd; } return null;