diff --git a/policeSecurityServer/src/main/java/com/changhu/common/db/enums/EnterprisesUnitType.java b/policeSecurityServer/src/main/java/com/changhu/common/db/enums/EnterprisesUnitType.java index a45370a..bfdd741 100644 --- a/policeSecurityServer/src/main/java/com/changhu/common/db/enums/EnterprisesUnitType.java +++ b/policeSecurityServer/src/main/java/com/changhu/common/db/enums/EnterprisesUnitType.java @@ -5,6 +5,9 @@ import com.changhu.common.db.BaseEnum; import lombok.AllArgsConstructor; import lombok.Getter; +import java.util.Arrays; +import java.util.stream.Collectors; + /** * @author 20252 * @createTime 2024/11/5 下午4:22 @@ -14,12 +17,28 @@ import lombok.Getter; @AllArgsConstructor public enum EnterprisesUnitType implements BaseEnum, IEnum { - school("school", "学校"), - hospital("hospital", "医院"), - community("community", "社区/小区"), - bank("bank", "银行"), - ; + PARTY_GOVERNMENT("party_government", "党政机关 "), + MEDICAL("medical", "医疗机构"), + RESIDENTIAL("residential", "小区"), + HIGHER_LEARNING("higher_learning", "高等院校"), + PRIMARY_AND_SECONDARY("primary_and_secondary", "中小学幼儿园"), + SHOPPING_SUPERMARKETS("shopping_supermarkets", "商场超市"), + FINANCIAL("financial", "金融机构"), + HYDROPOWER("hydropower", "水电油气"), + KEY_PROJECTS("key_projects", "重点工程建设单位"), + DELIVERY_LOGISTICS("delivery_logistics", "寄递物流"), + MILITARY("military", "军工、科研单位"), + WEN_BO("wen_bo", "文博单位"), + IMPORTANT_NEWS("important_news ", "重要新闻单位"), + LARGE_SCALE_MATERIAL("large_scale_material ", "大型物资储备"), + TRANSPORTATION("transportation", "交通运输企业"), + INDUSTRIAL_PARK("industrial_park", "工业园区企业"), + COMPLEX_PUBLIC_SECURITY("complex_public_security", "治安复杂场所"), + MAKING_EXPLOSIVE_EASILY("making_explosive_easily ", "易制爆"), + hazardous_materials("hazardous_materials ", "危化物品存放场所"), + other("other", "其他单位"); private final String value; private final String label; + } diff --git a/policeSecurityServer/src/main/java/com/changhu/config/WebConfig.java b/policeSecurityServer/src/main/java/com/changhu/config/WebConfig.java index 15fd4a3..48c4125 100644 --- a/policeSecurityServer/src/main/java/com/changhu/config/WebConfig.java +++ b/policeSecurityServer/src/main/java/com/changhu/config/WebConfig.java @@ -63,16 +63,16 @@ public class WebConfig implements WebMvcConfigurer { .addPathPatterns("/open/**"); } -// @Override -// public void addCorsMappings(CorsRegistry registry) { -// registry.addMapping("/**") -// .allowedOriginPatterns("*") -// .allowedMethods("GET", "POST", "OPTION", "PUT", "DELETE") -// .allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method", -// "Access-Control-Request-Headers", "Authorization","Token","*") -// .allowCredentials(true) -// .maxAge(3600); -// } + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOriginPatterns("*") + .allowedMethods("GET", "POST", "OPTION", "PUT", "DELETE") + .allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method", + "Access-Control-Request-Headers", "Authorization", "Token", "*") + .allowCredentials(true) + .maxAge(3600); + } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { diff --git a/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java b/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java index 238dd31..f8a5b92 100644 --- a/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java +++ b/policeSecurityServer/src/main/java/com/changhu/controller/OpenController.java @@ -33,9 +33,8 @@ public class OpenController { @Operation(summary = "获取企事业单位列表") @CheckOpenApi(value = OpenApiType.Information_on_enterprises_and_institutions) @GetMapping("/getEnterprisesUnit") - public List> getEnterprisesUnit(@Schema(description = "行政区划代码") @RequestParam String code, - @Schema(description = "行政区划等级") @RequestParam Integer level) { - return openApiService.getEnterprisesUnit(code, level); + public List> getEnterprisesUnit(@Schema(description = "公安单位机构代码") @RequestParam String policeCode) { + return openApiService.getEnterprisesUnit(policeCode); } @Operation(summary = "企事业单位详情") diff --git a/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java b/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java index cbe9870..c471c95 100644 --- a/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java +++ b/policeSecurityServer/src/main/java/com/changhu/service/OpenApiService.java @@ -15,11 +15,10 @@ public interface OpenApiService { /** * 获取企事业单位列表 * - * @param code 行政区划代码 - * @param level 行政区划等级 + * @param policeCode 公安机构代码 * @return 企事业单位列表 */ - List> getEnterprisesUnit(String code, Integer level); + List> getEnterprisesUnit(String policeCode); /** * 企事业单位详情 diff --git a/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java b/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java index ed346bd..2904329 100644 --- a/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java +++ b/policeSecurityServer/src/main/java/com/changhu/service/impl/OpenApiServiceImpl.java @@ -32,12 +32,10 @@ public class OpenApiServiceImpl implements OpenApiService { private ServiceProjectService serviceProjectService; @Override - public List> getEnterprisesUnit(String code, Integer level) { + public List> getEnterprisesUnit(String policeCode) { + PoliceUnit policeUnit = Db.lambdaQuery(PoliceUnit.class).eq(PoliceUnit::getCode, policeCode).oneOpt().orElseThrow(() -> new MessageException("当前系统没有该派出所")); return Db.lambdaQuery(EnterprisesUnit.class) - .eq(level == 1, EnterprisesUnit::getProvince, code) - .eq(level == 2, EnterprisesUnit::getCity, code) - .eq(level == 3, EnterprisesUnit::getDistricts, code) - .eq(level == 4, EnterprisesUnit::getStreet, code) + .eq(EnterprisesUnit::getPoliceUnitId, policeUnit.getSnowFlakeId()) .list() .stream() .map(item -> SelectNodeVo.builder()