Browse Source

Merge remote-tracking branch 'origin/dev_5big_coverage' into dev_5big_coverage

feature/teamB_zz_wgh
yinzuomei 3 years ago
parent
commit
2f3c81ace8
  1. 10
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
  2. 8
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/IcEnterpriseExcelImportListener.java
  3. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java
  4. 45
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
  5. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcEnterpriseServiceImpl.java

10
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java

@ -569,4 +569,14 @@ public class HouseController implements ResultDataResolver {
return houseService.getHomeInfoByHouseCode(dto);
}
/**
* 初始化房屋的组织ID路径
* @return
*/
@PostMapping("orgIdPathInit")
public Result orgIdPathInit() {
houseService.orgIdPathInit();
return new Result();
}
}

8
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/IcEnterpriseExcelImportListener.java

@ -12,7 +12,6 @@ import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.entity.IcEnterpriseEntity;
import com.epmet.excel.EnterpriseImportExcelDTO;
import com.epmet.service.impl.IcEnterpriseServiceImpl;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
@ -57,19 +56,20 @@ public class IcEnterpriseExcelImportListener implements ReadListener<EnterpriseI
public void invoke(EnterpriseImportExcelDTO data, AnalysisContext context) {
try {
// log.warn("有数据吗?"+JSON.toJSONString(data));
// 不能为空先校验数据
ValidatorUtils.validateEntity(data);
// 去除空格
ObjectUtil.objectToTrim(data);
// 根据网格名是否能找到网格id
if (!gridMap.containsKey(data.getGridName())) {
throw new ValidateException(String.format("您所在的组织,%s不存在", data.getGridName()));
throw new ValidateException(String.format("您所在的组织,不存在【%s】", data.getGridName()));
}
if(!placeTypeMap.containsKey(data.getPlaceTypeName())){
throw new ValidateException(String.format("%s场所类型不存在",data.getPlaceTypeName()));
throw new ValidateException(String.format("%s场所类型不存在",data.getPlaceTypeName()));
}
if(!scaleMap.containsKey(data.getScaleName())){
throw new ValidateException(String.format("%s规模不存在",data.getScaleName()));
throw new ValidateException(String.format("%s规模不存在",data.getScaleName()));
}
IcEnterpriseEntity enterpriseEntity = ConvertUtils.sourceToTarget(data, IcEnterpriseEntity.class);
enterpriseEntity.setCustomerId(currentCustomerId);

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java

@ -173,4 +173,6 @@ public interface HouseService {
* @return com.epmet.commons.tools.utils.Result
*/
Result getHomeInfoByHouseCode(HouseInfoFormDTO dto);
void orgIdPathInit();
}

45
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java

@ -5,6 +5,7 @@ import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
@ -1082,5 +1083,49 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver {
return new Result().ok(house);
}
@Override
public void orgIdPathInit() {
// 循环查询所有没有fullname字段的数据
LambdaQueryWrapper<IcHouseEntity> query = new LambdaQueryWrapper<>();
query.eq(IcHouseEntity::getId, "1508686441788137474");
//query.isNull(IcHouseEntity::getOrgIdPath);
//query.last(" limit 1000 ");
while (true) {
List<IcHouseEntity> houses2Dispose = icHouseDao.selectList(query);
if (org.apache.commons.collections4.CollectionUtils.isEmpty(houses2Dispose)) {
break;
}
houses2Dispose.stream().forEach(h -> {
IcNeighborHoodDTO neighborhood = neighborHoodService.get(h.getNeighborHoodId());
ArrayList<String> pidList = new ArrayList<>();
recureAppendParentAgencyId(neighborhood.getAgencyId(), pidList);
String orgIdPath = String.join(":", pidList);
// 更新
IcHouseEntity house = new IcHouseEntity();
house.setId(h.getId());
house.setOrgIdPath(orgIdPath);
icHouseDao.updateById(house);
});
}
}
/**
* 递归拼接orgIdPath
* @param agencyId
* @param result
*/
private void recureAppendParentAgencyId(String agencyId, List result) {
result.add(0, agencyId);
CustomerAgencyEntity agency = customerAgencyDao.selectById(agencyId);
String pid = agency.getPid();
if (StringUtils.isBlank(pid) || "0".equals(pid)) {
return;
}
recureAppendParentAgencyId(pid, result);
}
}

4
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcEnterpriseServiceImpl.java

@ -300,9 +300,9 @@ public class IcEnterpriseServiceImpl extends BaseServiceImpl<IcEnterpriseDao, Ic
}
Map<String,String> gridMap=gridList.stream().collect(Collectors.toMap(GridListResultDTO::getGridName,GridListResultDTO::getGridId));
IcEnterpriseExcelImportListener listener = new IcEnterpriseExcelImportListener(customerId,staffInfo, this,placeTypeMap,scaleMap,gridMap);
EasyExcel.read(filePath.toFile(), EnterpriseImportExcelDTO.class, listener).headRowNumber(2).sheet(0).doRead();
IcEnterpriseExcelImportListener listener = new IcEnterpriseExcelImportListener(customerId,staffInfo, this,placeTypeMap,scaleMap,gridMap);
EasyExcel.read(filePath.toFile(), EnterpriseImportExcelDTO.class, listener).headRowNumber(1).sheet(0).doRead();
Path errorDescFile = null;
String errorDesFileUrl = null;

Loading…
Cancel
Save