Commit 9262ae96 authored by 刘林's avatar 刘林

fix(jg):场车单位变更bug修改

parent 9f64e901
......@@ -358,6 +358,7 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
String city = Objects.toString(noticeDto.getCity(), "");
String userCity = Optional.ofNullable(city).map(c -> c.split("_")[0]).orElseThrow(() -> new BadRequest("请选择地市后暂存!"));
this.validateDeviceCity(deviceList, userCity, "0".equals(noticeDto.getChangeType()));
this.setEquAddress(noticeDto);
}
ArrayList<String> roleListAll = new ArrayList<>();
ArrayList<String> roleListNext = new ArrayList<>();
......@@ -913,7 +914,7 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
model.setCreateUserName(reginParams.getUserModel().getRealName());
model.setUseRegistCode(String.join(",", registrationNoList));
model.setEquList(registrationList.get(0).get("equList").toString());
this.setEquAddress(tableData, model);
this.setEquAddress(model);
JgChangeRegistrationUnit registrationUnit = new JgChangeRegistrationUnit();
BeanUtils.copyProperties(model, registrationUnit);
setNewUnitInfo(reginParams, registrationUnit);
......@@ -996,30 +997,31 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
return Collections.singletonList(model);
}
public void setEquAddress(Map<String, Object> tableData, JgChangeRegistrationUnitDto model) {
tableData.put("region", tableData.get("county"));
String address = Stream.of("province", "city", "region", "street")
.map(key -> getRegionName(key, tableData))
.filter(s -> !s.isEmpty())
public void setEquAddress(JgChangeRegistrationUnitDto model) {
String address = Stream.of(getRegionNameByCode("province", model.getProvince()),
getRegionNameByCode("city", model.getCity()),
getRegionNameByCode("region", model.getCounty()),
getRegionNameByCode("street", model.getStreet()))
.filter(s -> s != null && !s.isEmpty())
.collect(Collectors.joining())
+ Objects.toString(tableData.get("fullAddress"), "");
+ Objects.toString(model.getFullAddress(), "");
model.setEquAddress(address);
model.setFullAddress(Objects.toString(tableData.get("fullAddress"), ""));
model.setFullAddress(Objects.toString(model.getFullAddress(), ""));
}
/**
* 根据code获取市区县名字
*
* @param codeKey codeKey
* @param type type
* @return name
*/
private String getRegionName(String codeKey, Map<String, Object> tableData) {
List<LinkedHashMap<String, Object>> regions =
(List<LinkedHashMap<String, Object>>) redisUtils.get(codeKey.toUpperCase());
private String getRegionNameByCode(String type, String code) {
List<LinkedHashMap<String, Object>> regions = (List<LinkedHashMap<String, Object>>) redisUtils.get(type.toUpperCase());
return regions.stream()
.filter(item -> String.valueOf(item.get("regionCode")).equals(String.valueOf(tableData.get(codeKey))))
.filter(item -> code.equals(String.valueOf(item.get("regionCode"))))
.map(item -> (String) item.get("regionName"))
.collect(Collectors.joining(""));
.findFirst()
.orElse("");
}
// 获取设备的地市编码
......@@ -1519,15 +1521,10 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
useInfo.setCounty(registration.getCounty());
useInfo.setFactoryUseSiteStreet(registration.getStreet());
useInfo.setAddress(registration.getFullAddress());
Map<String, Object> tableData = new HashMap<>();
tableData.put("province", registration.getProvince());
tableData.put("city", registration.getCity());
tableData.put("region", registration.getCounty());
tableData.put("street", registration.getStreet());
useInfo.setProvinceName(getRegionName("province", tableData));
useInfo.setCityName(getRegionName("city", tableData));
useInfo.setCountyName(getRegionName("region", tableData));
useInfo.setStreetName(getRegionName("street", tableData));
useInfo.setProvinceName(getRegionNameByCode("province", useInfo.getProvince()));
useInfo.setCityName(getRegionNameByCode("city", useInfo.getCity()));
useInfo.setCountyName(getRegionNameByCode("region", useInfo.getCounty()));
useInfo.setStreetName(getRegionNameByCode("street", useInfo.getFactoryUseSiteStreet()));
}
private String joinWithSeparator(String separator, String... values) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment