Browse Source

导入桩号修改

develop
lau572 8 months ago
parent
commit
d0ff7a2ca1
  1. 20
      ruoyi-common/src/main/java/com/ruoyi/common/utils/StakeMarkUtils.java
  2. 4
      zc-business/src/main/java/com/zc/business/controller/DcStakeMarkController.java
  3. 2
      zc-business/src/main/java/com/zc/business/service/IDcStakeMarkService.java
  4. 34
      zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java

20
ruoyi-common/src/main/java/com/ruoyi/common/utils/StakeMarkUtils.java

@ -41,9 +41,10 @@ public class StakeMarkUtils {
if (!checkStakeMark(stakeMark)){
return "";
}
return stakeMark.toLowerCase().replace("k","").replace("+",".");
return stakeMark.replace("K","").replace("+",".");
}
/**
* @Description 桩号转米
*
@ -52,11 +53,18 @@ public class StakeMarkUtils {
* @param stakeMark 桩号:"K123+123"
* @return 公里数:123123
*/
public static Long formatMetreLong(String stakeMark){
if (!checkStakeMark(stakeMark)){
return null;
}
return Long.valueOf(stakeMark.replace("K","").replace("+",""));
}
public static String formatMetre(String stakeMark){
if (!checkStakeMark(stakeMark)){
return "";
}
return stakeMark.toLowerCase().replace("k","").replace("+","");
return stakeMark.replace("K","").replace("+","");
}
/**
@ -72,8 +80,8 @@ public class StakeMarkUtils {
if (!checkStakeMark(startStakeMark) || !checkStakeMark(endStakeMark)){
return BigDecimal.ZERO;
}
String start = startStakeMark.toLowerCase().replace("k","").replace("+",".");
String end = endStakeMark.toLowerCase().replace("k","").replace("+",".");
String start = startStakeMark.replace("K","").replace("+",".");
String end = endStakeMark.replace("K","").replace("+",".");
BigDecimal startKilometre = new BigDecimal(start);
BigDecimal endKilometre = new BigDecimal(end);
if (startKilometre.compareTo(endKilometre) > 0){
@ -96,8 +104,8 @@ public class StakeMarkUtils {
if (!checkStakeMark(startStakeMark) || !checkStakeMark(endStakeMark)){
return BigDecimal.ZERO;
}
String start = startStakeMark.toLowerCase().replace("k","").replace("+",".");
String end = endStakeMark.toLowerCase().replace("k","").replace("+",".");
String start = startStakeMark.replace("K","").replace("+",".");
String end = endStakeMark.replace("K","").replace("+",".");
BigDecimal startKilometre = new BigDecimal(start);
BigDecimal endKilometre = new BigDecimal(end);
if (startKilometre.compareTo(endKilometre) > 0){

4
zc-business/src/main/java/com/zc/business/controller/DcStakeMarkController.java

@ -115,8 +115,8 @@ public class DcStakeMarkController extends BaseController {
@ApiOperation("根据json文件路径导入桩号")
@PostMapping("importStakeMarkByJsonFilePath")
public AjaxResult importJsonStakeMark(String filePath) throws IOException {
return dcStakeMarkService.importJsonStakeMark(filePath);
public AjaxResult importJsonStakeMark(String filePath,String direction) throws IOException {
return dcStakeMarkService.importJsonStakeMark(filePath, direction);
}
}

2
zc-business/src/main/java/com/zc/business/service/IDcStakeMarkService.java

@ -70,5 +70,5 @@ public interface IDcStakeMarkService extends IService<DcStakeMark> {
* @param filePath json文件路径
* @return
*/
AjaxResult importJsonStakeMark(String filePath) throws IOException;
AjaxResult importJsonStakeMark(String filePath,String direction) throws IOException;
}

34
zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java

@ -9,7 +9,9 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.StakeMarkUtils;
import com.zc.business.domain.DcRoadSection;
import com.zc.business.domain.DcStakeMark;
import com.zc.business.mapper.DcRoadSectionMapper;
import com.zc.business.mapper.DcStakeMarkMapper;
import com.zc.business.service.IDcStakeMarkService;
import org.springframework.stereotype.Service;
@ -30,6 +32,8 @@ public class DcStakeMarkServiceImpl extends ServiceImpl<DcStakeMarkMapper, DcSta
@Resource
private DcStakeMarkMapper dcStakeMarkMapper;
@Resource
private DcRoadSectionMapper dcRoadSectionMapper;
public LambdaQueryWrapper<DcStakeMark> stakeMarkQueryWrapper(DcStakeMark dcStakeMark) {
@ -142,7 +146,7 @@ public class DcStakeMarkServiceImpl extends ServiceImpl<DcStakeMarkMapper, DcSta
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@Override
public AjaxResult importJsonStakeMark(String filePath) throws IOException {
public AjaxResult importJsonStakeMark(String filePath,String direction) throws IOException {
Date methodStart = new Date();
File file = new File(filePath);
@ -159,6 +163,8 @@ public class DcStakeMarkServiceImpl extends ServiceImpl<DcStakeMarkMapper, DcSta
Map<String, Map<String,Object>> map = JSON.parseObject(jsonStr, new TypeReference<HashMap<String, Map<String,Object>>>() {});
List<DcStakeMark> stakeMarkList = new ArrayList<>();
List<DcRoadSection> dcRoadSectionList = dcRoadSectionMapper.selectDcRoadSectionList(null);
//桩号格式校验
List<String> errorKey = new ArrayList<>();
map.keySet().forEach(key ->{
@ -170,9 +176,11 @@ public class DcStakeMarkServiceImpl extends ServiceImpl<DcStakeMarkMapper, DcSta
dcStakeMark.setLongitude(map.get(key).containsKey("lng") ? map.get(key).get("lng").toString() : "");
dcStakeMark.setLatitude(map.get(key).containsKey("lat") ? map.get(key).get("lat").toString() : "");
dcStakeMark.setDirection("1");
dcStakeMark.setSectionId(1L);
dcStakeMark.setMileage(Long.valueOf(StakeMarkUtils.formatMetre(key)));
dcStakeMark.setDirection(direction);
Long sectionId = getRoadSection(dcRoadSectionList,key);
dcStakeMark.setSectionId(sectionId);
dcStakeMark.setMileage(StakeMarkUtils.formatMetreLong(key));
stakeMarkList.add(dcStakeMark);
});
@ -189,5 +197,23 @@ public class DcStakeMarkServiceImpl extends ServiceImpl<DcStakeMarkMapper, DcSta
return AjaxResult.success();
}
private Long getRoadSection(List<DcRoadSection> roadSectionList,String stakeMark){
if (roadSectionList == null || roadSectionList.size() < 1){
return null;
}
Long metre = StakeMarkUtils.formatMetreLong(stakeMark);
for (DcRoadSection dcRoadSection : roadSectionList) {
Long startStakeMark = StakeMarkUtils.formatMetreLong(dcRoadSection.getStartStakeMark());
Long endStakeMark = StakeMarkUtils.formatMetreLong(dcRoadSection.getEndStakeMark());
if (metre >= startStakeMark && metre < endStakeMark){
return dcRoadSection.getId();
}
}
return null;
}
}

Loading…
Cancel
Save