|
@@ -16,7 +16,7 @@ import com.ningdatech.basic.model.PageVo; |
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
import com.ningdatech.basic.util.ValidUtil; |
|
|
import com.ningdatech.basic.util.ValidUtil; |
|
|
import com.ningdatech.kqapi.admin.mapper.ZoneMapper; |
|
|
import com.ningdatech.kqapi.admin.mapper.ZoneMapper; |
|
|
import com.ningdatech.kqapi.admin.model.dto.GovServiceMatterImportDTO; |
|
|
|
|
|
|
|
|
import com.ningdatech.kqapi.admin.model.dto.MatterImportDTO; |
|
|
import com.ningdatech.kqapi.admin.model.entity.Window; |
|
|
import com.ningdatech.kqapi.admin.model.entity.Window; |
|
|
import com.ningdatech.kqapi.admin.model.entity.Zone; |
|
|
import com.ningdatech.kqapi.admin.model.entity.Zone; |
|
|
import com.ningdatech.kqapi.admin.model.enumerization.HandleChannelEnum; |
|
|
import com.ningdatech.kqapi.admin.model.enumerization.HandleChannelEnum; |
|
@@ -156,34 +156,14 @@ public class AdminMatterManage { |
|
|
ItemTypeEnum type = IEnum.getNoNull(ItemTypeEnum.class, matterType); |
|
|
ItemTypeEnum type = IEnum.getNoNull(ItemTypeEnum.class, matterType); |
|
|
Assert.isTrue(!type.equals(ItemTypeEnum.SPECIAL), "不支持的导入类型"); |
|
|
Assert.isTrue(!type.equals(ItemTypeEnum.SPECIAL), "不支持的导入类型"); |
|
|
try (InputStream is = file.getInputStream()) { |
|
|
try (InputStream is = file.getInputStream()) { |
|
|
List<GovServiceMatterImportDTO> imports = EasyExcel.read(is, |
|
|
|
|
|
new AnalysisEventListener<GovServiceMatterImportDTO>() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void invoke(GovServiceMatterImportDTO data, AnalysisContext context) { |
|
|
|
|
|
String errMsg = ValidUtil.validFast(data); |
|
|
|
|
|
if (errMsg != null) { |
|
|
|
|
|
throw BizException.wrap(errMsg); |
|
|
|
|
|
} |
|
|
|
|
|
Optional<HandleChannelEnum> handleChannel = IEnum.getByDesc(HandleChannelEnum.class, data.getHandleChannel()); |
|
|
|
|
|
if (handleChannel.isPresent()) { |
|
|
|
|
|
data.setHandleChannelEnum(handleChannel.get()); |
|
|
|
|
|
} else { |
|
|
|
|
|
throw BizException.wrap("不支持的办理渠道"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void doAfterAllAnalysed(AnalysisContext context) { |
|
|
|
|
|
// do nothing |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
List<MatterImportDTO> imports = EasyExcel.read(is, buildImportEventListener(type)) |
|
|
.headRowNumber(1) |
|
|
.headRowNumber(1) |
|
|
.head(GovServiceMatterImportDTO.class) |
|
|
|
|
|
|
|
|
.head(MatterImportDTO.class) |
|
|
.excelType(ExcelTypeEnum.XLSX) |
|
|
.excelType(ExcelTypeEnum.XLSX) |
|
|
.ignoreEmptyRow(true) |
|
|
.ignoreEmptyRow(true) |
|
|
.autoCloseStream(true) |
|
|
.autoCloseStream(true) |
|
|
.doReadAllSync(); |
|
|
.doReadAllSync(); |
|
|
Map<String, List<GovServiceMatterImportDTO>> mattersByZone = CollUtils.group(imports, GovServiceMatterImportDTO::getZoneName); |
|
|
|
|
|
|
|
|
Map<String, List<MatterImportDTO>> mattersByZone = CollUtils.group(imports, MatterImportDTO::getZoneName); |
|
|
Wrapper<Zone> zoneQuery = Wrappers.lambdaQuery(Zone.class) |
|
|
Wrapper<Zone> zoneQuery = Wrappers.lambdaQuery(Zone.class) |
|
|
.in(Zone::getZoneName, mattersByZone.keySet()); |
|
|
.in(Zone::getZoneName, mattersByZone.keySet()); |
|
|
List<Zone> zones = zoneMapper.selectList(zoneQuery); |
|
|
List<Zone> zones = zoneMapper.selectList(zoneQuery); |
|
@@ -195,7 +175,7 @@ public class AdminMatterManage { |
|
|
mattersByZone.forEach((zoneName, matters) -> { |
|
|
mattersByZone.forEach((zoneName, matters) -> { |
|
|
Zone zone = zoneMap.get(zoneName); |
|
|
Zone zone = zoneMap.get(zoneName); |
|
|
Assert.notNull(zone, "服务专区不存在"); |
|
|
Assert.notNull(zone, "服务专区不存在"); |
|
|
Map<String, List<GovServiceMatterImportDTO>> mattersByWin = CollUtils.group(matters, GovServiceMatterImportDTO::getWindowName); |
|
|
|
|
|
|
|
|
Map<String, List<MatterImportDTO>> mattersByWin = CollUtils.group(matters, MatterImportDTO::getWindowName); |
|
|
Wrapper<Window> windowQuery = Wrappers.lambdaQuery(Window.class) |
|
|
Wrapper<Window> windowQuery = Wrappers.lambdaQuery(Window.class) |
|
|
.eq(Window::getZoneId, zone.getId()) |
|
|
.eq(Window::getZoneId, zone.getId()) |
|
|
.in(Window::getWindowName, mattersByWin.keySet()); |
|
|
.in(Window::getWindowName, mattersByWin.keySet()); |
|
@@ -204,7 +184,7 @@ public class AdminMatterManage { |
|
|
throw BizException.wrap("导入失败:服务窗口不存在"); |
|
|
throw BizException.wrap("导入失败:服务窗口不存在"); |
|
|
} |
|
|
} |
|
|
Map<String, Window> windowMap = CollUtils.listToMap(windows, Window::getWindowName); |
|
|
Map<String, Window> windowMap = CollUtils.listToMap(windows, Window::getWindowName); |
|
|
for (GovServiceMatterImportDTO matter : matters) { |
|
|
|
|
|
|
|
|
for (MatterImportDTO matter : matters) { |
|
|
Window window = windowMap.get(matter.getWindowName()); |
|
|
Window window = windowMap.get(matter.getWindowName()); |
|
|
Assert.notNull(window, "服务窗口不存在"); |
|
|
Assert.notNull(window, "服务窗口不存在"); |
|
|
KqZzsfwMenu menu = new KqZzsfwMenu(); |
|
|
KqZzsfwMenu menu = new KqZzsfwMenu(); |
|
@@ -216,6 +196,9 @@ public class AdminMatterManage { |
|
|
menu.setZoneName(zone.getZoneName()); |
|
|
menu.setZoneName(zone.getZoneName()); |
|
|
menu.setDepartment(matter.getDepartment()); |
|
|
menu.setDepartment(matter.getDepartment()); |
|
|
menu.setHandleChannel(matter.getHandleChannelEnum().getCode()); |
|
|
menu.setHandleChannel(matter.getHandleChannelEnum().getCode()); |
|
|
|
|
|
menu.setServiceContent(matter.getServiceContent()); |
|
|
|
|
|
menu.setServiceProcess(matter.getServiceProcess()); |
|
|
|
|
|
menu.setTelephone(matter.getTelephone()); |
|
|
menu.setSort(99); |
|
|
menu.setSort(99); |
|
|
menu.setType(type.getCode()); |
|
|
menu.setType(type.getCode()); |
|
|
newMatters.add(menu); |
|
|
newMatters.add(menu); |
|
@@ -228,8 +211,37 @@ public class AdminMatterManage { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void downloadGovServiceMatterTemplate(HttpServletResponse response) { |
|
|
|
|
|
final ClassPathResource resource = new ClassPathResource("/template/政策服务事项配置模板.xlsx"); |
|
|
|
|
|
|
|
|
private static AnalysisEventListener<MatterImportDTO> buildImportEventListener(ItemTypeEnum type) { |
|
|
|
|
|
return new AnalysisEventListener<MatterImportDTO>() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void invoke(MatterImportDTO data, AnalysisContext context) { |
|
|
|
|
|
String errMsg = ValidUtil.validFast(data, type.getParamValidGroup()); |
|
|
|
|
|
if (errMsg != null) { |
|
|
|
|
|
throw BizException.wrap(errMsg); |
|
|
|
|
|
} |
|
|
|
|
|
if (StrUtil.isNotBlank(data.getHandleChannel())) { |
|
|
|
|
|
Optional<HandleChannelEnum> channel = IEnum.getByDesc(HandleChannelEnum.class, data.getHandleChannel()); |
|
|
|
|
|
if (channel.isPresent()) { |
|
|
|
|
|
data.setHandleChannelEnum(channel.get()); |
|
|
|
|
|
} else { |
|
|
|
|
|
throw BizException.wrap("不支持的办理渠道"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void doAfterAllAnalysed(AnalysisContext context) { |
|
|
|
|
|
// do nothing |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void downloadMatterImportTemplate(HttpServletResponse response, Integer matterType) { |
|
|
|
|
|
ItemTypeEnum matterTypeEnum = ItemTypeEnum.match(matterType); |
|
|
|
|
|
Assert.notNull(matterTypeEnum, "参数缺失"); |
|
|
|
|
|
String templatePath = matterTypeEnum.getImportTemplatePath(); |
|
|
|
|
|
Assert.notEmpty(templatePath, "不支持的事项模版类型"); |
|
|
|
|
|
ClassPathResource resource = new ClassPathResource(templatePath); |
|
|
try (ServletOutputStream os = response.getOutputStream()) { |
|
|
try (ServletOutputStream os = response.getOutputStream()) { |
|
|
response.setContentType(ExcelUtil.XLSX_CONTENT_TYPE); |
|
|
response.setContentType(ExcelUtil.XLSX_CONTENT_TYPE); |
|
|
String fileName = URLEncoder.encode(resource.getName(), "UTF-8"); |
|
|
String fileName = URLEncoder.encode(resource.getName(), "UTF-8"); |
|
@@ -238,7 +250,7 @@ public class AdminMatterManage { |
|
|
os.flush(); |
|
|
os.flush(); |
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
log.error("下载失败:", e); |
|
|
log.error("下载失败:", e); |
|
|
throw BizException.wrap("政策服务事项配置模板下载失败"); |
|
|
|
|
|
|
|
|
throw BizException.wrap("事项配置模板下载失败"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|