Merge remote-tracking branch 'origin/mdc' into mdc
This commit is contained in:
commit
e5fbffe637
|
@ -45,4 +45,31 @@ public class DetectorIdFormat {
|
|||
Integer detectorId = Integer.valueOf(prefixFormatResult + suffixFormatResult);
|
||||
return detectorId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化探测器id解析出台站id
|
||||
* @param detectorCode
|
||||
* @return
|
||||
*/
|
||||
public Integer formatDetectorCodeToStationId(String detectorCode){
|
||||
if(!detectorCode.contains(StringConstant.UNDER_LINE)){
|
||||
throw new RuntimeException("The "+detectorCode+" detector code is illegal");
|
||||
}
|
||||
//举例:FRP28_007
|
||||
final String[] arr = detectorCode.split(StringConstant.UNDER_LINE);
|
||||
final String prefix = arr[0];
|
||||
|
||||
Integer stationId = null;
|
||||
//格式化前缀
|
||||
for(int i=prefix.length()-1;i>=0;i--){
|
||||
final String letter = String.valueOf(prefix.charAt(i));
|
||||
if(StringUtils.isAlpha(letter)){
|
||||
final String mapVal = suffixMap.getOrDefault(letter, "-1");
|
||||
stationId = Integer.valueOf(mapVal + prefix.substring(i + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return stationId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
|
|||
detector.setDetectorId(format.formatDetectorCodeToId(detectorCode));
|
||||
detector.setDetectorCode(detectorCode);
|
||||
detector.setStatus(DetectorsStatus.OPERATING.getStatus());
|
||||
detector.setStationId(format.formatDetectorCodeToStationId(detectorCode));
|
||||
this.baseMapper.insert(detector);
|
||||
return detector;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user