@@ -59,19 +59,19 @@ public class MatterController { | |||
matterManage.saveOrUpdate(req); | |||
} | |||
@PostMapping("/importGovServiceMatter") | |||
@WebLog("导入政务服务事项") | |||
@ApiOperation("导入政务服务事项") | |||
@PostMapping("/importMatter") | |||
@WebLog("导入服务事项") | |||
@ApiOperation("导入服务事项") | |||
public void importMatter(@RequestParam("file") MultipartFile file, | |||
@RequestParam("matterType") Integer matterType) { | |||
@RequestParam("matterType") Integer matterType) { | |||
matterManage.importMatter(file, matterType); | |||
} | |||
@GetMapping("/downloadGovServiceMatterTemplate") | |||
@GetMapping("/downloadMatterImportTemplate/{matterType}") | |||
@WebLog("下载政策服务事项配置模板") | |||
@ApiOperation("下载政策服务事项配置模板") | |||
public void downloadMatterTemplate(HttpServletResponse response) { | |||
matterManage.downloadGovServiceMatterTemplate(response); | |||
public void downloadMatterImportTemplate(HttpServletResponse response, @PathVariable Integer matterType) { | |||
matterManage.downloadMatterImportTemplate(response, matterType); | |||
} | |||
} |
@@ -16,7 +16,7 @@ import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.basic.util.ValidUtil; | |||
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.Zone; | |||
import com.ningdatech.kqapi.admin.model.enumerization.HandleChannelEnum; | |||
@@ -156,34 +156,14 @@ public class AdminMatterManage { | |||
ItemTypeEnum type = IEnum.getNoNull(ItemTypeEnum.class, matterType); | |||
Assert.isTrue(!type.equals(ItemTypeEnum.SPECIAL), "不支持的导入类型"); | |||
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) | |||
.head(GovServiceMatterImportDTO.class) | |||
.head(MatterImportDTO.class) | |||
.excelType(ExcelTypeEnum.XLSX) | |||
.ignoreEmptyRow(true) | |||
.autoCloseStream(true) | |||
.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) | |||
.in(Zone::getZoneName, mattersByZone.keySet()); | |||
List<Zone> zones = zoneMapper.selectList(zoneQuery); | |||
@@ -195,7 +175,7 @@ public class AdminMatterManage { | |||
mattersByZone.forEach((zoneName, matters) -> { | |||
Zone zone = zoneMap.get(zoneName); | |||
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) | |||
.eq(Window::getZoneId, zone.getId()) | |||
.in(Window::getWindowName, mattersByWin.keySet()); | |||
@@ -204,7 +184,7 @@ public class AdminMatterManage { | |||
throw BizException.wrap("导入失败:服务窗口不存在"); | |||
} | |||
Map<String, Window> windowMap = CollUtils.listToMap(windows, Window::getWindowName); | |||
for (GovServiceMatterImportDTO matter : matters) { | |||
for (MatterImportDTO matter : matters) { | |||
Window window = windowMap.get(matter.getWindowName()); | |||
Assert.notNull(window, "服务窗口不存在"); | |||
KqZzsfwMenu menu = new KqZzsfwMenu(); | |||
@@ -216,6 +196,9 @@ public class AdminMatterManage { | |||
menu.setZoneName(zone.getZoneName()); | |||
menu.setDepartment(matter.getDepartment()); | |||
menu.setHandleChannel(matter.getHandleChannelEnum().getCode()); | |||
menu.setServiceContent(matter.getServiceContent()); | |||
menu.setServiceProcess(matter.getServiceProcess()); | |||
menu.setTelephone(matter.getTelephone()); | |||
menu.setSort(99); | |||
menu.setType(type.getCode()); | |||
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()) { | |||
response.setContentType(ExcelUtil.XLSX_CONTENT_TYPE); | |||
String fileName = URLEncoder.encode(resource.getName(), "UTF-8"); | |||
@@ -238,7 +250,7 @@ public class AdminMatterManage { | |||
os.flush(); | |||
} catch (IOException e) { | |||
log.error("下载失败:", e); | |||
throw BizException.wrap("政策服务事项配置模板下载失败"); | |||
throw BizException.wrap("事项配置模板下载失败"); | |||
} | |||
} | |||
@@ -1,52 +0,0 @@ | |||
package com.ningdatech.kqapi.admin.model.dto; | |||
import com.alibaba.excel.annotation.ExcelIgnore; | |||
import com.alibaba.excel.annotation.ExcelProperty; | |||
import com.ningdatech.kqapi.admin.model.enumerization.HandleChannelEnum; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
/** | |||
* <p> | |||
* GovServiceMatterImportDTO | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 15:27 2024/4/23 | |||
*/ | |||
@Data | |||
public class GovServiceMatterImportDTO { | |||
@ExcelProperty(value = "序号") | |||
@ExcelIgnore | |||
private Integer rowNo; | |||
@ExcelProperty(value = "服务专区") | |||
@NotBlank(message = "服务专区不能为空") | |||
private String zoneName; | |||
@ExcelProperty(value = "服务窗口") | |||
@NotBlank(message = "服务窗口不能为空") | |||
private String windowName; | |||
@ExcelProperty(value = "服务事项名称") | |||
@NotBlank(message = "服务事项名称不能为空") | |||
private String matterName; | |||
@ExcelProperty(value = "办理渠道") | |||
@NotBlank(message = "办理渠道不能为空") | |||
private String handleChannel; | |||
@ExcelProperty(value = "政务服务链接") | |||
@NotBlank(message = "政务服务链接不能为空") | |||
private String webApplyUrl; | |||
@ExcelProperty(value = "牵头部门") | |||
@NotBlank(message = "牵头部门不能为空") | |||
private String department; | |||
@ExcelIgnore | |||
private HandleChannelEnum handleChannelEnum; | |||
} |
@@ -0,0 +1,66 @@ | |||
package com.ningdatech.kqapi.admin.model.dto; | |||
import com.alibaba.excel.annotation.ExcelIgnore; | |||
import com.alibaba.excel.annotation.ExcelProperty; | |||
import com.ningdatech.kqapi.admin.model.enumerization.HandleChannelEnum; | |||
import com.ningdatech.kqapi.zzsfw.enumeration.ItemTypeEnum.AddedService; | |||
import com.ningdatech.kqapi.zzsfw.enumeration.ItemTypeEnum.GovService; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
/** | |||
* <p> | |||
* GovServiceMatterImportDTO | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 15:27 2024/4/23 | |||
*/ | |||
@Data | |||
public class MatterImportDTO { | |||
@ExcelProperty(value = "序号") | |||
@ExcelIgnore | |||
private Integer rowNo; | |||
@ExcelProperty(value = "服务专区") | |||
@NotBlank(message = "服务专区不能为空", groups = {GovService.class, AddedService.class}) | |||
private String zoneName; | |||
@ExcelProperty(value = "服务窗口") | |||
@NotBlank(message = "服务窗口不能为空", groups = {GovService.class, AddedService.class}) | |||
private String windowName; | |||
@ExcelProperty(value = "服务事项名称") | |||
@NotBlank(message = "服务事项名称不能为空", groups = {GovService.class, AddedService.class}) | |||
private String matterName; | |||
@ExcelProperty(value = "办理渠道") | |||
@NotBlank(message = "办理渠道不能为空", groups = GovService.class) | |||
private String handleChannel; | |||
@ExcelProperty(value = "政务服务链接") | |||
@NotBlank(message = "政务服务链接不能为空", groups = GovService.class) | |||
private String webApplyUrl; | |||
@ExcelProperty(value = "牵头部门") | |||
@NotBlank(message = "牵头部门不能为空", groups = {GovService.class, AddedService.class}) | |||
private String department; | |||
@ExcelProperty(value = "服务内容") | |||
@NotBlank(message = "服务内容不能为空", groups = AddedService.class) | |||
private String serviceContent; | |||
@ExcelProperty(value = "服务流程") | |||
@NotBlank(message = "服务流程不能为空", groups = AddedService.class) | |||
private String serviceProcess; | |||
@ExcelProperty(value = "咨询电话") | |||
@NotBlank(message = "咨询电话不能为空", groups = AddedService.class) | |||
private String telephone; | |||
@ExcelIgnore | |||
private HandleChannelEnum handleChannelEnum; | |||
} |
@@ -22,15 +22,26 @@ public enum ItemTypeEnum implements IEnum { | |||
/** | |||
* 事项类型 枚举 | |||
*/ | |||
GOV(1, "政府服务"), | |||
ADDED(2, "增值服务"), | |||
SPECIAL(3, "特殊服务"); | |||
GOV(1, "政府服务", GovService.class, "/template/政务服务事项配置模板.xlsx"), | |||
ADDED(2, "增值服务", AddedService.class, "/template/增值服务事项配置模板.xlsx"), | |||
SPECIAL(3, "特殊服务", SpecialService.class, ""); | |||
private final Integer code; | |||
private final String desc; | |||
private final Class<?> paramValidGroup; | |||
private final String importTemplatePath; | |||
public static ItemTypeEnum match(Integer code) { | |||
return IEnum.getByCode(ItemTypeEnum.class, code).orElse(null); | |||
} | |||
public interface GovService { | |||
} | |||
public interface AddedService { | |||
} | |||
public interface SpecialService { | |||
} | |||
} |
@@ -229,6 +229,7 @@ public class MatterManage { | |||
.map(m -> { | |||
WebMatterDetailVO build = new WebMatterDetailVO(); | |||
build.setId(m.getId()); | |||
build.setHandleChannel(m.getHandleChannel()); | |||
build.setMatterName(m.getItemName()); | |||
build.setMatterType(m.getType()); | |||
build.setWindowName(m.getWindow()); | |||