src/main/java/org/springblade/common/utils/ComplexNumberStringComparator.java
New file @@ -0,0 +1,41 @@ package org.springblade.common.utils; public class ComplexNumberStringComparator{ public static int compare(String s1, String s2) { int i1 = 0, i2 = 0; while (i1 < s1.length() && i2 < s2.length()) { char c1 = s1.charAt(i1); char c2 = s1.charAt(i2); if (Character.isDigit(c1) && Character.isDigit(c2)) { //比较数字大小 int num1 = getNumber(s1, i1); int num2 = getNumber(s2, i2); if (num1 != num2) { return Integer.compare(num1, num2); } //相同数字时继续比较下一位 i1 += Integer.toString(num1).length(); i2 += Integer.toString(num2).length(); } else { //普通字符按照字典排序 if (c1 != c2) { return Character.compare(c1, c2); } i1++; i2++; } } //如果前缀相同,则长度短的字符串排在前面 return Integer.compare(s1.length(), s2.length()); } private static int getNumber(String s, int start) { int end = start; while (end < s.length() && Character.isDigit(s.charAt(end))) { end++; } return Integer.parseInt(s.substring(start, end)); } } src/main/java/org/springblade/modules/doorplateAddress/service/impl/DoorplateAddressServiceImpl.java
@@ -24,6 +24,7 @@ import org.apache.logging.log4j.util.Strings; import org.springblade.common.constant.DictConstant; import org.springblade.common.node.TreeStringNode; import org.springblade.common.utils.ComplexNumberStringComparator; import org.springblade.common.utils.NodeTreeUtil; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.modules.category.dto.CategoryLabelDTO; @@ -37,7 +38,9 @@ import org.springblade.modules.doorplateAddress.vo.DoorplateAddressVOTree; import org.springblade.modules.doorplateAddress.vo.FuncNode; import org.springblade.modules.grid.entity.GridEntity; import org.springblade.modules.grid.entity.GridmanEntity; import org.springblade.modules.grid.service.IGridService; import org.springblade.modules.grid.service.IGridmanService; import org.springblade.modules.house.entity.HouseEntity; import org.springblade.modules.house.service.IHouseRentalService; import org.springblade.modules.house.service.IHouseService; @@ -47,6 +50,8 @@ import org.springblade.modules.house.vo.HouseholdVO; import org.springblade.modules.place.entity.PlaceEntity; import org.springblade.modules.place.service.IPlaceService; import org.springblade.modules.system.entity.Region; import org.springblade.modules.system.service.IRegionService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -77,6 +82,12 @@ @Autowired private IGridService gridService; @Autowired private IGridmanService gridmanService; @Autowired private IRegionService regionService; @Autowired private IDistrictService districtService; @@ -236,14 +247,17 @@ */ private void getGridInfoByGridman(HouseParam houseParam) { if (houseParam.getRoleName().equals("网格员")) { QueryWrapper<GridEntity> wrapper = new QueryWrapper<>(); QueryWrapper<GridmanEntity> wrapper = new QueryWrapper<>(); wrapper.eq("is_deleted", 0) .eq("user_id", AuthUtil.getUserId()); List<GridEntity> list = gridService.list(wrapper); List<GridmanEntity> list = gridmanService.list(wrapper); if (list.size() > 0) { GridEntity gridEntity = list.get(0); if (!Strings.isBlank(gridEntity.getCommunityName())) { houseParam.setCommunityName(gridEntity.getCommunityName().split("居民委员会")[0]); GridmanEntity gridmanEntity = list.get(0); GridEntity gridEntity = gridService.getById(gridmanEntity.getGridId()); // 查询居委会 Region region = regionService.getById(gridEntity.getCommunityCode()); if (null != region) { houseParam.setCommunityName(region.getName()); } if (!Strings.isBlank(gridEntity.getGridName())) { houseParam.setGridName(gridEntity.getGridName()); @@ -325,10 +339,15 @@ List<TreeStringNode> aoiList = new ArrayList<>(); List<TreeStringNode> shopList = new ArrayList<>(); // 根据社区名称查询楼栋或者商铺的集合 List<TreeStringNode> list = baseMapper.getBuildingList(houseParam, stringList); // 排序 StringUtils.getDigits(X.getName()) 取出数字排序 List<TreeStringNode> sortList = list.stream().sorted(Comparator.comparing(X -> StringUtils.getDigits(X.getName()))).collect(Collectors.toList()); List<TreeStringNode> sortList = list.stream(). sorted(new Comparator<TreeStringNode>() { @Override public int compare(TreeStringNode o1, TreeStringNode o2) { return ComplexNumberStringComparator.compare(o1.getName(),o2.getName()); } }).collect(Collectors.toList()); if (list.size() > 0) { for (TreeStringNode treeNode : sortList) { if (treeNode.getAddressType() == 1) { src/main/java/org/springblade/modules/grid/entity/GridEntity.java
@@ -53,6 +53,11 @@ @TableId(value = "id", type = IdType.AUTO) private Integer id; /** * 网格编号 */ @ApiModelProperty(value = "网格编号") private String gridCode; /** * 机构id */ @ApiModelProperty(value = "机构id") @@ -72,11 +77,6 @@ */ @ApiModelProperty(value = "网格名称") private String gridName; /** * 负责人ID */ @ApiModelProperty(value = "负责人ID") private Long userId; /** * 负责人名称 */ src/main/java/org/springblade/modules/grid/excel/GridExcel.java
@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.alibaba.excel.annotation.write.style.ContentRowHeight; import com.alibaba.excel.annotation.write.style.HeadRowHeight; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; @@ -24,6 +25,10 @@ @ExcelProperty("社区网格名称") private String gridName; @ColumnWidth(15) @ExcelProperty("网格编号") private String gridCode; @ColumnWidth(100) @ExcelProperty("区域") private String geom; src/main/java/org/springblade/modules/grid/service/impl/GridServiceImpl.java
@@ -95,13 +95,31 @@ if (null!=region){ gridEntity.setCommunityCode(region.getCode()); } gridEntity.setGridName(split[1]); gridEntity.setGeom(gridExcel.getGeom()); gridEntity.setCreateUser(AuthUtil.getUserId()); gridEntity.setCreateTime(new Date()); gridEntity.setUpdateUser(AuthUtil.getUserId()); gridEntity.setUpdateTime(new Date()); list.add(gridEntity); // 比对网格是否存在,如果已存在则更新,否则则新增 QueryWrapper<GridEntity> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("is_deleted",0) .eq("grid_name",split[1]) .eq("community_code",region.getCode()); GridEntity one = getOne(queryWrapper); if (null!=one){ one.setGridCode(gridExcel.getGridCode()); one.setGridName(split[1]); one.setGeom(gridExcel.getGeom()); one.setUpdateUser(AuthUtil.getUserId()); one.setUpdateTime(new Date()); // 更新 updateById(one); }else { // 设置网格数据 gridEntity.setGridCode(gridExcel.getGridCode()); gridEntity.setGridName(split[1]); gridEntity.setGeom(gridExcel.getGeom()); gridEntity.setCreateUser(AuthUtil.getUserId()); gridEntity.setCreateTime(new Date()); gridEntity.setUpdateUser(AuthUtil.getUserId()); gridEntity.setUpdateTime(new Date()); list.add(gridEntity); } } // 批量导入 saveBatch(list);