处理网格编码问题

This commit is contained in:
wanggeng 2022-09-27 11:31:34 +08:00
parent 9501db8495
commit 260a7c7aeb

View File

@ -577,7 +577,11 @@ public class GridServiceImpl extends BaseService implements IGridService {
*/
private String getSaveGridCode(String areaCode) {
GridPO areaLastPO = getAreaLastPO(areaCode);
return areaLastPO == null ? String.format("%s001", areaCode.substring(0, 12)) : String.valueOf(Long.valueOf(areaLastPO.getGridCode()) + 1);
if (areaLastPO == null) {
return String.format("%s001", areaCode);
}
String gridCode = areaLastPO.getGridCode().substring(areaLastPO.getGridCode().length() - 3);
return areaCode + String.format("%03d", (Integer.parseInt(gridCode) + 1));
}
/**
@ -594,7 +598,7 @@ public class GridServiceImpl extends BaseService implements IGridService {
}
// 网格为空递增
if (StringUtils.isBlank(gridCode)) {
return areaCode + String.format("%03d", Integer.parseInt(areaLastPO.getGridCode().substring(areaLastPO.getGridCode().length() - 4)) + 1);
return areaCode + String.format("%03d", Integer.parseInt(areaLastPO.getGridCode().substring(areaLastPO.getGridCode().length() - 3)) + 1);
}
// 网格编码存在不更改
return areaCode + String.format("%03d", Integer.parseInt(gridCode.substring(gridCode.length() - 3)));