格式化代码

This commit is contained in:
duwenyuan 2025-07-15 16:49:14 +08:00
parent 84cb8e45a1
commit b73dc2b9e2
3 changed files with 50 additions and 51 deletions

View File

@ -106,19 +106,19 @@ public class CalculateDataRateThread implements Runnable {
//修改使用efficCalculType判断台站类型 //修改使用efficCalculType判断台站类型
String efficCalculType = calculateDataRate.getMEfficCalculType(); String efficCalculType = calculateDataRate.getMEfficCalculType();
//判断台站编码及台站类型 //判断台站编码及台站类型
if ((StringUtils.isNotBlank(stationCode) && stationCode.substring(2, 3).equals("X")) && (StringUtils.isNotBlank(efficCalculType) && efficCalculType.equals("SAUNA"))) { if ((StringUtils.isNotBlank(stationCode) && stationCode.charAt(2) == 'X') && (StringUtils.isNotBlank(efficCalculType) && efficCalculType.equals("SAUNA"))) {
//切割台站编码 如果 第三个字符是 X 并且 台站类型是 SAUNA //切割台站编码 如果 第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 SAUNA
mRate = saunacalc(calculateDataRate); mRate = saunacalc(calculateDataRate);
} else if ((StringUtils.isNotBlank(stationCode) && stationCode.charAt(2) == 'X') && (StringUtils.isNotBlank(efficCalculType) && efficCalculType.equals("SAUNA2"))) { } else if ((StringUtils.isNotBlank(stationCode) && stationCode.charAt(2) == 'X') && (StringUtils.isNotBlank(efficCalculType) && efficCalculType.equals("SAUNA2"))) {
//切割台站编码 如果 第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 SAUNA2 //切割台站编码 如果 第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 SAUNA2
mRate = saunacalc2(calculateDataRate); mRate = saunacalc2(calculateDataRate);
} else if ((StringUtils.isNotBlank(stationCode) && stationCode.substring(2, 3).equals("X")) && (StringUtils.isNotBlank(efficCalculType) && efficCalculType.equals("SPALAX"))) { } else if ((StringUtils.isNotBlank(stationCode) && stationCode.charAt(2) == 'X') && (StringUtils.isNotBlank(efficCalculType) && efficCalculType.equals("SPALAX"))) {
//切割台站编码 如果 第三个字符是 X 并且 台站类型是 SPALAX //切割台站编码 如果 第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 SPALAX
mRate = spalaxcalc(calculateDataRate); mRate = spalaxcalc(calculateDataRate);
}else if ((StringUtils.isNotBlank(stationCode) && stationCode.charAt(2) == 'X') && (StringUtils.isNotBlank(efficCalculType) && efficCalculType.equals("SPALAX_PLC"))) { } else if ((StringUtils.isNotBlank(stationCode) && stationCode.charAt(2) == 'X') && (StringUtils.isNotBlank(efficCalculType) && efficCalculType.equals("SPALAX_PLC"))) {
//切割台站编码 如果 第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 SPALAX-PLC //切割台站编码 如果 第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 SPALAX-PLC
mRate = spalaxcalcPLC(calculateDataRate); mRate = spalaxcalcPLC(calculateDataRate);
} else if (StringUtils.isNotBlank(stationCode) && stationCode.substring(2, 3).equals("P")) { } else if (StringUtils.isNotBlank(stationCode) && stationCode.charAt(2) == 'P') {
//切割台站编码 如果 第三个字符是 P //切割台站编码 如果 第三个字符是 P
mRate = particulatecalc(calculateDataRate); mRate = particulatecalc(calculateDataRate);
} }
@ -639,8 +639,7 @@ public class CalculateDataRateThread implements Runnable {
collectHigh = param.getPhdf().getCollectHigh(); collectHigh = param.getPhdf().getCollectHigh();
liveQc = param.getPhdf().getLiveQc(); liveQc = param.getPhdf().getLiveQc();
number = param.getPhdf().getNumber(); number = param.getPhdf().getNumber();
} } else {
else {
liveLow = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getLiveLow(); liveLow = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getLiveLow();
liveHigh = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getLiveHigh(); liveHigh = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getLiveHigh();
quantity = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getQuantity(); quantity = calculateDataRate.getMParameter().getPhdfSpalaxPLC().getQuantity();
@ -676,8 +675,7 @@ public class CalculateDataRateThread implements Runnable {
collectHigh = param.getPhd().getCollectHigh(); collectHigh = param.getPhd().getCollectHigh();
liveQc = param.getPhd().getLiveQc(); liveQc = param.getPhd().getLiveQc();
number = param.getPhd().getNumber(); number = param.getPhd().getNumber();
} } else {
else {
liveLow = calculateDataRate.getMParameter().getPhdSpalaxPLC().getLiveLow(); liveLow = calculateDataRate.getMParameter().getPhdSpalaxPLC().getLiveLow();
liveHigh = calculateDataRate.getMParameter().getPhdSpalaxPLC().getLiveHigh(); liveHigh = calculateDataRate.getMParameter().getPhdSpalaxPLC().getLiveHigh();
quantity = calculateDataRate.getMParameter().getPhdSpalaxPLC().getQuantity(); quantity = calculateDataRate.getMParameter().getPhdSpalaxPLC().getQuantity();

View File

@ -194,13 +194,13 @@ public class CalculateStationData {
Node node = childNodes.item(i); Node node = childNodes.item(i);
switch (node.getNodeName()) { switch (node.getNodeName()) {
case "SAUNA": case "SAUNA":
sphdMetSoh.setSaunaEverydaynums(getNodeValue(node,"number")); sphdMetSoh.setSaunaEverydaynums(getNodeValue(node, "number"));
break; break;
case "SPALAX": case "SPALAX":
sphdMetSoh.setSpalaxEverydaynums(getNodeValue(node,"number")); sphdMetSoh.setSpalaxEverydaynums(getNodeValue(node, "number"));
break; break;
case "PARTICULATE": case "PARTICULATE":
sphdMetSoh.setParticulateEverydaynums(getNodeValue(node,"number")); sphdMetSoh.setParticulateEverydaynums(getNodeValue(node, "number"));
break; break;
} }
} }
@ -1319,11 +1319,12 @@ public class CalculateStationData {
/** /**
* 多线程获取台站数据的提供率和有效率 * 多线程获取台站数据的提供率和有效率
*
* @param stationInfos 台站信息列表 * @param stationInfos 台站信息列表
*/ */
public void mutiThreadGetStationInfo(List<StationInfo> stationInfos, RateParam mRateParam) { public void mutiThreadGetStationInfo(List<StationInfo> stationInfos, RateParam mRateParam) {
//声明一个数组用于接收最后的结果情况 //声明一个数组用于接收最后的结果情况
Map<String, StationInfo> finallySta = Objects.nonNull(redisUtil.get("dataStationInfoList"))? (Map<String, StationInfo>) redisUtil.get("dataStationInfoList"):new HashMap<>(); Map<String, StationInfo> finallySta = Objects.nonNull(redisUtil.get("dataStationInfoList")) ? (Map<String, StationInfo>) redisUtil.get("dataStationInfoList") : new HashMap<>();
//声明一个线程池 //声明一个线程池
ThreadPoolExecutor poolExecutor = null; ThreadPoolExecutor poolExecutor = null;
//声明一个CountDownLatch监听是否完成全部线程 //声明一个CountDownLatch监听是否完成全部线程
@ -1334,7 +1335,7 @@ public class CalculateStationData {
int works = stationInfos.size(); int works = stationInfos.size();
threadNum = works; threadNum = works;
// 如果线程数不等于0 // 如果线程数不等于0
if (threadNum != 0){ if (threadNum != 0) {
//获取机器可用核心数 //获取机器可用核心数
int maximumPoolSize = maximumPoolSizeProperties.getStation();//Runtime.getRuntime().availableProcessors(); int maximumPoolSize = maximumPoolSizeProperties.getStation();//Runtime.getRuntime().availableProcessors();
//初始化线程池 //初始化线程池
@ -1347,13 +1348,13 @@ public class CalculateStationData {
return t; return t;
} }
}; };
poolExecutor = new ThreadPoolExecutor(15,maximumPoolSize,10, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(),threadFactory); poolExecutor = new ThreadPoolExecutor(15, maximumPoolSize, 10, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), threadFactory);
} }
// 线程数 等于 需要处理的台站数量 // 线程数 等于 需要处理的台站数量
if( threadNum == works ){ if (threadNum == works) {
countDownLatch = new CountDownLatch(threadNum); countDownLatch = new CountDownLatch(threadNum);
//遍历台站信息 //遍历台站信息
for (int i = 0 ; i < works; i++){ for (int i = 0; i < works; i++) {
//获取台站信息 //获取台站信息
StationInfo stationInfo = stationInfos.get(i); StationInfo stationInfo = stationInfos.get(i);
//声明一个实体类 //声明一个实体类
@ -1370,7 +1371,7 @@ public class CalculateStationData {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {
//关闭线程池 //关闭线程池
if(poolExecutor != null) { if (poolExecutor != null) {
poolExecutor.shutdownNow(); poolExecutor.shutdownNow();
} }
} }

View File

@ -30,74 +30,74 @@ public class StationOperationController {
@GetMapping("findStationType") @GetMapping("findStationType")
@ApiOperation(value = "查询台站/核设施类型", notes = "查询台站/核设施类型") @ApiOperation(value = "查询台站/核设施类型", notes = "查询台站/核设施类型")
public List<String> findStationType(){ public List<String> findStationType() {
List<String> result = stationOperationService.findStationType(); List<String> result = stationOperationService.findStationType();
return result; return result;
} }
@GetMapping("findList") @GetMapping("findList")
@ApiOperation(value = "查询台站/核设施信息", notes = "查询台站/核设施信息") @ApiOperation(value = "查询台站/核设施信息", notes = "查询台站/核设施信息")
public List<StationOperation> findList(String status, String stationType){ public List<StationOperation> findList(String status, String stationType) {
List<StationOperation> result = stationOperationService.findList(status, stationType); List<StationOperation> result = stationOperationService.findList(status, stationType);
return result; return result;
} }
@GetMapping("findListApp") @GetMapping("findListApp")
@ApiOperation(value = "查询台站/核设施信息", notes = "查询台站/核设施信息") @ApiOperation(value = "查询台站/核设施信息", notes = "查询台站/核设施信息")
public List<StationOperation> findListApp(@RequestParam String status,@RequestParam String stationType){ public List<StationOperation> findListApp(@RequestParam String status, @RequestParam String stationType) {
List<StationOperation> result = stationOperationService.findList(status, stationType); List<StationOperation> result = stationOperationService.findList(status, stationType);
return result; return result;
} }
@GetMapping("findInfo") @GetMapping("findInfo")
@ApiOperation(value = "查询台站/核设施详情信息", notes = "查询台站/核设施详情信息") @ApiOperation(value = "查询台站/核设施详情信息", notes = "查询台站/核设施详情信息")
public Result findInfo(String stationId, String type){ public Result findInfo(String stationId, String type) {
Result result = stationOperationService.findInfo(stationId, type); Result result = stationOperationService.findInfo(stationId, type);
return result; return result;
} }
@GetMapping("findInfoApp") @GetMapping("findInfoApp")
@ApiOperation(value = "查询台站/核设施详情信息", notes = "查询台站/核设施详情信息") @ApiOperation(value = "查询台站/核设施详情信息", notes = "查询台站/核设施详情信息")
public Result findInfoApp(@RequestParam String stationId,@RequestParam String type){ public Result findInfoApp(@RequestParam String stationId, @RequestParam String type) {
Result result = stationOperationService.findInfo(stationId, type); Result result = stationOperationService.findInfo(stationId, type);
return result; return result;
} }
@GetMapping("findTree") @GetMapping("findTree")
@ApiOperation(value = "查询台站树形结构", notes = "查询台站树形结构") @ApiOperation(value = "查询台站树形结构", notes = "查询台站树形结构")
public Result findTree(){ public Result findTree() {
Result result = stationOperationService.findTree(); Result result = stationOperationService.findTree();
return result; return result;
} }
@PostMapping("getHitEquList") @PostMapping("getHitEquList")
@ApiOperation(value = "查询半径内核设施信息", notes = "查询半径内核设施信息") @ApiOperation(value = "查询半径内核设施信息", notes = "查询半径内核设施信息")
public Result getHitEquList(@RequestBody PointVo pointVo){ public Result getHitEquList(@RequestBody PointVo pointVo) {
Result result = stationOperationService.getHitEquList(pointVo); Result result = stationOperationService.getHitEquList(pointVo);
return result; return result;
} }
@GetMapping("getDataReceivingStatus") @GetMapping("getDataReceivingStatus")
@ApiOperation(value = "查询台站监测数据信息", notes = "查询台站监测数据信息") @ApiOperation(value = "查询台站监测数据信息", notes = "查询台站监测数据信息")
public Result getDataReceivingStatus(String userId, Double cacheTime, String oneStationId){ public Result getDataReceivingStatus(String userId, Double cacheTime, String oneStationId) {
return stationOperationService.getDataReceivingStatus(userId, cacheTime, oneStationId); return stationOperationService.getDataReceivingStatus(userId, cacheTime, oneStationId);
} }
@GetMapping("getDataReceivingStatusApp") @GetMapping("getDataReceivingStatusApp")
@ApiOperation(value = "查询台站监测数据信息", notes = "查询台站监测数据信息") @ApiOperation(value = "查询台站监测数据信息", notes = "查询台站监测数据信息")
public Result getDataReceivingStatusApp(@RequestParam String userId,@RequestParam Double cacheTime,@RequestParam String oneStationId){ public Result getDataReceivingStatusApp(@RequestParam String userId, @RequestParam Double cacheTime, @RequestParam String oneStationId) {
return stationOperationService.getDataReceivingStatus(userId, cacheTime, oneStationId); return stationOperationService.getDataReceivingStatus(userId, cacheTime, oneStationId);
} }
@GetMapping("getDataProvisionEfficiency") @GetMapping("getDataProvisionEfficiency")
@ApiOperation(value = "查询台站数据提供率及有效率", notes = "查询台站数据提供率及有效率") @ApiOperation(value = "查询台站数据提供率及有效率", notes = "查询台站数据提供率及有效率")
public Result getDataProvisionEfficiency(){ public Result getDataProvisionEfficiency() {
return stationOperationService.getDataProvisionEfficiency(); return stationOperationService.getDataProvisionEfficiency();
} }
@GetMapping("getMapUrl") @GetMapping("getMapUrl")
@ApiOperation(value = "获取地图地址", notes = "获取地图地址") @ApiOperation(value = "获取地图地址", notes = "获取地图地址")
public Result<?> getMapUrl(){ public Result<?> getMapUrl() {
Result<String> result = Result.OK(); Result<String> result = Result.OK();
result.setResult(mapUrl); result.setResult(mapUrl);
return result; return result;