contronller
@ApiOperation(value = "车范围不一致") @GetMapping("/carRange") public RespBean carRange() { return otaProcessPreviewService.carRange(); }
service
/** * 车辆范围不一致 */ RespBean carRange();
serviceimpl
/** * 车辆范围不一致 */ @Override public RespBean carRange() { List<CarCorpPo> corpList = carCorpMapper.getCarCorpList(new CarCorpPo()); List<String> selectTableNames = otaProcessLogMapper.selectTableNames(dataBaseConfig.getDatabase()); Map<String, Object> result = new HashMap<>(); //车范围不一致vin码 AtomicInteger diffVinCnt = new AtomicInteger(); //远程升级不及时 AtomicInteger upgradeUntimely = new AtomicInteger(); //安装超时 AtomicInteger installTimeOut = new AtomicInteger(); if (CollectionUtil.isNotEmpty(corpList) && CollectionUtil.isNotEmpty(selectTableNames)) { corpList.forEach(corp -> { String tableName = selectTableNames.stream().filter(selectTableName -> StringUtils.equalsIgnoreCase(selectTableName, "ota_process_log_" + corp.getCorpEname())).findFirst().orElse(null); if (StringUtils.isNotBlank(tableName)) { //获取备案信息中的数据与日志中的数据进行比较列表 List<OtaLogDataComparePo> compareList = otaServicesMapper.getOtaDataAndLogDataCompareList(tableName, new DataQualityAnalysisQuery()); int vinnum = otaServicesMapper.getCarField(tableName, new DataQualityAnalysisQuery()); if (CollectionUtil.isNotEmpty(compareList)) { compareList.forEach(data -> { if (data != null) { //VIN码不一致 diffVinCnt.set(diffVinCnt.get()+vinnum); //远程升级不及时 Calendar ca = Calendar.getInstance(); Date otaUpgradeTime = data.getOtaUpgradeTime(); String deployPeriod = data.getDeployPeriod(); ca.setTime(otaUpgradeTime); if(!StringUtils.isBlank(deployPeriod)){ ca.add(Calendar.DATE,Integer.parseInt(deployPeriod)); } if(DateUtil.compare(ca.getTime(), data.getLogUpgradeEnd()) < 0) { upgradeUntimely.set(upgradeUntimely.get() + 1); } //安装超时 long installtime = 0; if(StringUtils.isBlank(data.getOtaInstallTime()) || data.getLogUpgradeEnd() == null){ installTimeOut.set(installTimeOut.get()+1); }else { switch (data.getOtaInstallTime()){ case "<15": installtime = 15; break; case "15-30": installtime = 30; break; case "30-60": installtime = 60; break; case "60-90": installtime = 90; break; default: break; } Calendar r = Calendar.getInstance(); Date logUpgradeEnd =data.getLogUpgradeEnd(); installtime = installtime*60000; Date logUpgradeStart = data.getLogUpgradeStart(); if((logUpgradeEnd.getTime()-logUpgradeStart.getTime())>installtime){ installTimeOut.set(installTimeOut.get()+1); } // r.setTime(logUpgradeEnd); // r.add(Calendar.MINUTE,installtime); // if(DateUtil.compare(r.getTime(),data.getLogUpgradeStart()) < 0){ // installTimeOut.set(installTimeOut.get()+1); // } } } }); } } }); } result.put("diffVinCnt",diffVinCnt); result.put("upgradeUntimely",upgradeUntimely); result.put("installTimeOut",installTimeOut); return RespBean.ok("获取车范围不一致成功",result ); }
VIN不一致mapper:
//查询车范围不一致数量: int getCarField(@Param("logTableName") String logTableName, @Param("query") DataQualityAnalysisQuery query);
<select id="getCarField" resultType="java.lang.Integer"> select count(*) from car_info as ci INNER join car_identity_num cin on ci.cid = cin.cid INNER join ota_report_flow orf on orf.record_num = ci.record_num INNER join ${logTableName} oplb on ci.record_num = oplb.record_num <where> cin.vin != oplb.vin_num <if test="@com.zhuoqin.common.utils.Ognl@isNotEmpty(query.beginDate) and @com.zhuoqin.common.utils.Ognl@isNotEmpty(query.endDate)"> and orf.report_time between #{query.beginDate} and #{query.endDate} </if> </where> </select>
//获取备案信息中的数据与日志中的数据比较 List<OtaLogDataComparePo> getOtaDataAndLogDataCompareList(@Param("logTableName") String logTableName, @Param("query") DataQualityAnalysisQuery query);
<select id="getOtaDataAndLogDataCompareList" resultType="com.zhuoqin.modules.otapr.po.OtaLogDataComparePo"> select os.deploy_time as otaUpgradeTime, os.deploy_period as deployPeriod, os.ota_push_way as otaPushWay, os.ota_push_way_remark as otaPushWayRemark, op.ota_download_time as otaDownloadTime, op.ota_install_time as otaInstallTime, oplb.upgrade_way as logUpgradeWay, oplb.upgrade_time as logUpgradeTime, oplb.upgrade_start as logUpgradeStart, oplb.upgrade_end as logUpgradeEnd, os.ota_need_confirm_flag as otaNeedConfirm, oplb.is_setup_flag as logSetupFlag, oplb.record_num as logRecordNum from ota_services os inner join ota_packages op on os.record_num = op.record_num inner join ota_report_flow orf on orf.record_num = os.record_num inner join ${logTableName} oplb on op.record_num = oplb.record_num <where> orf.audit_state = 2 <if test="@com.zhuoqin.common.utils.Ognl@isNotEmpty(query.beginDate) and @com.zhuoqin.common.utils.Ognl@isNotEmpty(query.endDate)"> and orf.report_time between #{query.beginDate} and #{query.endDate} </if> </where> </select>