|
|
@ -27,6 +27,7 @@ import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.ServiceConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.OptionResultDTO; |
|
|
|
import com.epmet.commons.tools.enums.GenderEnum; |
|
|
|
import com.epmet.commons.tools.enums.HouseTypeEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
@ -38,12 +39,13 @@ import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.UserConstant; |
|
|
|
import com.epmet.dao.IcResiUserDao; |
|
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
|
import com.epmet.dto.IcResiUserDTO; |
|
|
|
import com.epmet.dto.*; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.IcResiUserEntity; |
|
|
|
import com.epmet.excel.handler.DynamicEasyExcelListener; |
|
|
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.feign.OperCustomizeOpenFeignClient; |
|
|
|
import com.epmet.redis.IcResiUserRedis; |
|
|
@ -82,7 +84,11 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi |
|
|
|
@Autowired |
|
|
|
private OperCustomizeOpenFeignClient operCustomizeOpenFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpmetAdminOpenFeignClient adminOpenFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IcResiUserDTO> page(Map<String, Object> params) { |
|
|
@ -422,9 +428,21 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object importExcel() { |
|
|
|
public Object importExcel(String currUserAgencyId) { |
|
|
|
return imporExcel(0, 3, currUserAgencyId); |
|
|
|
// imporExcel(1, 1);
|
|
|
|
// imporExcel(2, 1);
|
|
|
|
// imporExcel(3, 1);
|
|
|
|
// imporExcel(4, 1);
|
|
|
|
// imporExcel(5, 1);
|
|
|
|
// imporExcel(6, 2);
|
|
|
|
// imporExcel(7, 1);
|
|
|
|
// imporExcel(8, 1);
|
|
|
|
} |
|
|
|
|
|
|
|
private Object imporExcel(int sheetNo, int headRowNumber, String currUserAgencyId) { |
|
|
|
DynamicEasyExcelListener readListener = new DynamicEasyExcelListener(); |
|
|
|
EasyExcelFactory.read(new File("/opt/test/基础信息表/resi_info.xls")).registerReadListener(readListener).headRowNumber(3).sheet(0).doRead(); |
|
|
|
EasyExcelFactory.read(new File("/opt/test/基础信息表/resi_info.xls")).registerReadListener(readListener).headRowNumber(3).sheet(sheetNo).doRead(); |
|
|
|
|
|
|
|
List<Map<Integer, String>> headList = readListener.getHeadList(); |
|
|
|
List<Map<Integer, String>> dataList = readListener.getDataList(); |
|
|
@ -455,11 +473,69 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi |
|
|
|
} |
|
|
|
}, formItem -> formItem) |
|
|
|
); |
|
|
|
HashMap<String, List<ColumnWrapper>> headerColumnWrapper = integrate(formItemMap, combinedHeaders, dataList, abandonedHeaders); |
|
|
|
Map<String, ColumnWrapper> headerColumnWrapper = integrate(formItemMap, combinedHeaders, dataList, abandonedHeaders); |
|
|
|
|
|
|
|
// 持久化
|
|
|
|
persist(headerColumnWrapper, dataList, currUserAgencyId, abandonedHeaders); |
|
|
|
|
|
|
|
return headerColumnWrapper; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 持久化 |
|
|
|
* @param headerColumnWrapper 数据库列包装信息 |
|
|
|
* @param dataRows 数据行集合 |
|
|
|
* @param currUserAgencyId 当前用户的组织id |
|
|
|
* @param checkBoxOptionColumnIdxAndLabel 复选框的列号&label中文 |
|
|
|
*/ |
|
|
|
private void persist(Map<String, ColumnWrapper> headerColumnWrapper, List<Map<Integer, String>> dataRows, String currUserAgencyId, Map<Integer, String> checkBoxOptionColumnIdxAndLabel) { |
|
|
|
for (Map<Integer, String> row : dataRows) { |
|
|
|
|
|
|
|
for (Map.Entry<String, ColumnWrapper> columnWrapperEntry : headerColumnWrapper.entrySet()) { |
|
|
|
|
|
|
|
String itemId = columnWrapperEntry.getKey(); |
|
|
|
ColumnWrapper columnWrapper = columnWrapperEntry.getValue(); |
|
|
|
if ("input".equals(columnWrapper.getItemType()) |
|
|
|
|| "textarea".equals(columnWrapper.getItemType()) |
|
|
|
|| "datepicker".equals(columnWrapper.getItemType()) |
|
|
|
|| "timerange".equals(columnWrapper.getItemType()) |
|
|
|
) { |
|
|
|
|
|
|
|
String cellContent = row.get(columnWrapper.getColIndexs().get(0)); |
|
|
|
columnWrapper.setCellContent(cellContent); |
|
|
|
columnWrapper.setColValue(cellContent); |
|
|
|
|
|
|
|
} else if ("select".equals(columnWrapper.getItemType()) |
|
|
|
|| "radio".equals(columnWrapper.getItemType())){ |
|
|
|
|
|
|
|
String optionSourceType = columnWrapper.getOptionSourceType(); |
|
|
|
// 取单元格的内容
|
|
|
|
String cellContent = row.get(columnWrapper.getColIndexs().get(0)); |
|
|
|
columnWrapper.setCellContent(cellContent); |
|
|
|
|
|
|
|
if ("local".equals(optionSourceType)) { |
|
|
|
// 根据单元格内容,取到指定的option
|
|
|
|
Map<String, String> options = columnWrapper.getOptions(); |
|
|
|
String colValue = options.get(cellContent); |
|
|
|
columnWrapper.setColValue(colValue); |
|
|
|
} else { |
|
|
|
// remote类型
|
|
|
|
|
|
|
|
Map<String, String> options = listRemoteOptions(headerColumnWrapper, columnWrapper.getOptionSourceValue(), currUserAgencyId); |
|
|
|
String colValue = options.get(cellContent); |
|
|
|
columnWrapper.setColValue(colValue); |
|
|
|
} |
|
|
|
} else if ("checkbox".equals(columnWrapper.getItemType())) { |
|
|
|
String checkBoxColValue = getCheckBoxColValue(columnWrapper, row, checkBoxOptionColumnIdxAndLabel); |
|
|
|
columnWrapper.setColValue(checkBoxColValue); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @description 合并头 |
|
|
|
* |
|
|
@ -509,9 +585,6 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi |
|
|
|
} |
|
|
|
|
|
|
|
return abandonedHeaders; |
|
|
|
//headers.forEach((k, v) -> {
|
|
|
|
//
|
|
|
|
//});
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -521,9 +594,11 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi |
|
|
|
* @author wxz |
|
|
|
* @date 2021.10.28 17:08:51 |
|
|
|
*/ |
|
|
|
private HashMap<String, List<ColumnWrapper>> integrate(Map<String, FormItem> formItemMap, Map<String, List<Integer>> combinedHeaders, |
|
|
|
private Map<String, ColumnWrapper> integrate(Map<String, FormItem> formItemMap, Map<String, List<Integer>> combinedHeaders, |
|
|
|
List<Map<Integer, String>> datas, Map<Integer, String> abandonedHeaders) { |
|
|
|
HashMap<String, List<ColumnWrapper>> data = new HashMap<>(); |
|
|
|
|
|
|
|
// HashMap<String, List<ColumnWrapper>> tables = new HashMap<>();
|
|
|
|
Map<String, ColumnWrapper> columns = new HashMap<>(combinedHeaders.size()); |
|
|
|
|
|
|
|
for (Map.Entry<String, List<Integer>> entry : combinedHeaders.entrySet()) { |
|
|
|
String combinedHeader = entry.getKey(); |
|
|
@ -539,49 +614,41 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi |
|
|
|
|
|
|
|
// 填充options
|
|
|
|
columnWrapper.setItemType(item.getItemType()); |
|
|
|
columnWrapper.setItemId(item.getItemId()); |
|
|
|
String groupLabel = item.getGroupLabel(); |
|
|
|
String combinedLabel = StringUtils.isBlank(groupLabel) ? item.getLabel() : groupLabel.concat(":").concat(item.getLabel()); |
|
|
|
columnWrapper.setCombinedLabel(combinedLabel); |
|
|
|
columnWrapper.setColumnName(item.getColumnName()); |
|
|
|
columnWrapper.setColIndexs(entry.getValue()); |
|
|
|
|
|
|
|
if ("remote".equals(item.getOptionSourceType())) { |
|
|
|
Map<String, String> options = listRemoteOptions(item.getOptionSourceValue()); |
|
|
|
columnWrapper.setOptions(options); |
|
|
|
} else { |
|
|
|
Map<String, String> options = item.getOptions().stream().collect(Collectors.toMap(OptionDTO::getLabel, OptionDTO::getValue)); |
|
|
|
columnWrapper.setOptions(options); |
|
|
|
} |
|
|
|
|
|
|
|
/*switch (item.getItemType()) { |
|
|
|
case "input": |
|
|
|
case "textarea": |
|
|
|
case "datepicker": |
|
|
|
case "timerange": |
|
|
|
//输入性的
|
|
|
|
break; |
|
|
|
case "checkbox": |
|
|
|
break; |
|
|
|
}*/ |
|
|
|
columnWrapper.setOptionSourceType(item.getOptionSourceType()); |
|
|
|
columnWrapper.setOptionSourceValue(item.getOptionSourceValue()); |
|
|
|
columnWrapper.setOptions(item.getOptions().stream().collect(Collectors.toMap(OptionDTO::getLabel, OptionDTO::getValue))); |
|
|
|
|
|
|
|
columns.put(item.getItemId(), columnWrapper); |
|
|
|
} |
|
|
|
return data; |
|
|
|
return columns; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取checkbox列值 |
|
|
|
* @param options |
|
|
|
* @param writedColIdxs |
|
|
|
* @param abandonedHeaders |
|
|
|
* @param columnWrapper 数据库列包装信息,每一列跳数据对应数据库的一个列 |
|
|
|
* @param dataRow 数据行,每一条都是一行中的一个单元格 |
|
|
|
* @param checkboxOptions 复选框的选项。k: 列号, value: checkboxlabel中文 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String getCheckBoxColValue(List<OptionDTO> options, List<Integer> writedColIdxs, Map<Integer, String> abandonedHeaders) { |
|
|
|
|
|
|
|
Map<String, String> optionMap = options.stream().collect(Collectors.toMap(OptionDTO::getLabel, OptionDTO::getValue)); |
|
|
|
|
|
|
|
List<String> optionValues = writedColIdxs.stream().map(i -> { |
|
|
|
String optionName = abandonedHeaders.get(i); |
|
|
|
return optionMap.get(optionName); |
|
|
|
private String getCheckBoxColValue(ColumnWrapper columnWrapper, Map<Integer, String> dataRow, Map<Integer, String> checkboxOptions) { |
|
|
|
|
|
|
|
Map<String, String> options = columnWrapper.getOptions(); |
|
|
|
List<Integer> colIndexs = columnWrapper.getColIndexs(); |
|
|
|
|
|
|
|
List<String> optionValues = colIndexs.stream().filter(i -> { |
|
|
|
String cellContent = dataRow.get(i); |
|
|
|
if (StringUtils.isNotBlank(cellContent) && cellContent.equals("是")) return true; |
|
|
|
return false; |
|
|
|
}).map(i -> { |
|
|
|
String checkboxOptionLabel = checkboxOptions.get(i); |
|
|
|
return options.get(checkboxOptionLabel); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
return String.join(",", optionValues); |
|
|
@ -589,12 +656,86 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi |
|
|
|
|
|
|
|
/** |
|
|
|
* 远程获取options |
|
|
|
* @param uri |
|
|
|
* @param fullUri |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private Map<String, String> listRemoteOptions(String uri) { |
|
|
|
private Map<String, String> listRemoteOptions(Map<String, ColumnWrapper> columnWrappers, String fullUri, String currUserAgencyId) { |
|
|
|
String pureUri = null; |
|
|
|
String cascadeItemId = null; |
|
|
|
String cascadeItemColumnValue = null; |
|
|
|
|
|
|
|
if (fullUri.indexOf("?") != -1) { |
|
|
|
String[] uriParts = fullUri.split("\\?"); |
|
|
|
pureUri = uriParts[0]; |
|
|
|
cascadeItemId = uriParts[1]; |
|
|
|
|
|
|
|
// 根据uri上的id,找到关联的itemid,从而找到关联的item的值
|
|
|
|
ColumnWrapper cascadeItemColumnWrapper = columnWrappers.get(cascadeItemId); |
|
|
|
cascadeItemColumnValue = cascadeItemColumnWrapper.getColValue(); |
|
|
|
} else { |
|
|
|
pureUri = fullUri; |
|
|
|
} |
|
|
|
|
|
|
|
List<OptionResultDTO> options = null; |
|
|
|
|
|
|
|
switch (pureUri) { |
|
|
|
case "/epmetuser/icresidemanddict/demandoption": |
|
|
|
options = getResultDataOrThrowsException(epmetUserOpenFeignClient.getDemandOptions(), ServiceConstant.EPMET_USER_SERVER, |
|
|
|
EpmetErrorCode.SERVER_ERROR.getCode(), null); |
|
|
|
break; |
|
|
|
case "/gov/org/customergrid/gridoption": |
|
|
|
AgencyIdFormDTO form = new AgencyIdFormDTO(); |
|
|
|
form.setAgencyId(currUserAgencyId); |
|
|
|
options = getResultDataOrThrowsException(govOrgOpenFeignClient.getGridOption(form), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); |
|
|
|
break; |
|
|
|
case "/gov/org/customerpartybranch/branchoption": |
|
|
|
|
|
|
|
CustomerPartyBranchDTO bform = new CustomerPartyBranchDTO(); |
|
|
|
bform.setGridId(cascadeItemColumnValue); |
|
|
|
options = getResultDataOrThrowsException(govOrgOpenFeignClient.getBranchOption(bform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); |
|
|
|
break; |
|
|
|
case "/gov/org/icbuilding/buildingoption": |
|
|
|
IcBuildingDTO buildingform = new IcBuildingDTO(); |
|
|
|
buildingform.setNeighborHoodId(cascadeItemColumnValue); |
|
|
|
options = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingOptions(buildingform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); |
|
|
|
break; |
|
|
|
case "/gov/org/icbuildingunit/unitoption": |
|
|
|
IcBuildingUnitDTO buForm = new IcBuildingUnitDTO(); |
|
|
|
buForm.setBuildingId(cascadeItemColumnValue); |
|
|
|
options = getResultDataOrThrowsException(govOrgOpenFeignClient.getUnitOptions(buForm), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); |
|
|
|
break; |
|
|
|
case "/gov/org/ichouse/houseoption": |
|
|
|
HouseFormDTO hform = new HouseFormDTO(); |
|
|
|
hform.setUnitId(cascadeItemColumnValue); |
|
|
|
options = getResultDataOrThrowsException(govOrgOpenFeignClient.getHouseOption(hform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); |
|
|
|
break; |
|
|
|
case "/gov/org/icneighborhood/neighborhoodoption": |
|
|
|
IcNeighborHoodDTO nform = new IcNeighborHoodDTO(); |
|
|
|
nform.setAgencyId(currUserAgencyId); |
|
|
|
nform.setGridId(cascadeItemId); |
|
|
|
options = getResultDataOrThrowsException(govOrgOpenFeignClient.getNeighborHoodOptions(nform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); |
|
|
|
break; |
|
|
|
case "/sys/dict/data/education": |
|
|
|
options = getResultDataOrThrowsException(adminOpenFeignClient.getEducationOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); |
|
|
|
break; |
|
|
|
case "/sys/dict/data/house": |
|
|
|
options = getResultDataOrThrowsException(adminOpenFeignClient.getHouseOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); |
|
|
|
break; |
|
|
|
case "/sys/dict/data/nation": |
|
|
|
options = getResultDataOrThrowsException(adminOpenFeignClient.getNationOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); |
|
|
|
break; |
|
|
|
case "/sys/dict/data/ninesmallplaces": |
|
|
|
options = getResultDataOrThrowsException(adminOpenFeignClient.getNineSmallPlacesOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); |
|
|
|
break; |
|
|
|
case "/sys/dict/data/relationship": |
|
|
|
options = getResultDataOrThrowsException(adminOpenFeignClient.getRelationshipOption(), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null); |
|
|
|
break; |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
if (options == null) return null; |
|
|
|
|
|
|
|
return options.stream().collect(Collectors.toMap(OptionResultDTO::getLabel, OptionResultDTO::getValue)); |
|
|
|
|
|
|
|
// 通用api调用,无法实现
|
|
|
|
/*if (!uri.startsWith("/api")) uri = "/api".concat(uri); |
|
|
@ -711,11 +852,25 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi |
|
|
|
private String combinedLabel; |
|
|
|
private String columnName; |
|
|
|
private String itemType; |
|
|
|
private String itemId; |
|
|
|
private List<Integer> colIndexs; |
|
|
|
//private List<String> colContents;
|
|
|
|
// 单元格内容
|
|
|
|
private String cellContent; |
|
|
|
// 数据库中列的值
|
|
|
|
private String colValue; |
|
|
|
|
|
|
|
// key:label,value:value
|
|
|
|
private Map<String, String> options; |
|
|
|
|
|
|
|
/** |
|
|
|
* 选项来源,REMOTE;LOCAL;如果是动态加载的下拉框或者CHECKBOX等的情况下使用。URL:接口获取(LABEL,VALUE);JSON:直接从JSON中取 |
|
|
|
*/ |
|
|
|
private String optionSourceType; |
|
|
|
|
|
|
|
/** |
|
|
|
* 来源地址,REMOTE才有,固定格式;如果OPTIONS_SOURCE是URL,则此处填写要调用的接口的URL相对路径,例如:/API/GOV/ORG/XXXX。此处不应设置参数,若需要参数应当完全由后端,通过TOKEN信息来获取 |
|
|
|
*/ |
|
|
|
private String optionSourceValue; |
|
|
|
} |
|
|
|
} |