diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/OrgInfoConstant.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/OrgInfoConstant.java index c20cb98c6d..d8c8567800 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/OrgInfoConstant.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/OrgInfoConstant.java @@ -12,4 +12,8 @@ public interface OrgInfoConstant { String DEPT = "dept"; + String NEIGHBOR_HOOD = "neighborHood"; + + String COMMUNITY = "community"; + } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/MapAddAreaFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/MapAddAreaFormDTO.java new file mode 100644 index 0000000000..8fcf455279 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/MapAddAreaFormDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/10/25 9:54 上午 + * @DESC + */ +@Data +public class MapAddAreaFormDTO implements Serializable { + + private static final long serialVersionUID = 2334704900459757549L; + + public interface MapAddAreaForm{} + + /** + * 类型,组织:agency,网格:grid,小区:neighborHood + */ + @NotBlank(message = "level不能为空",groups = MapAddAreaForm.class) + private String level; + + @NotBlank(message = "orgId不能为空",groups = MapAddAreaForm.class) + private String orgId; + + @NotBlank(message = "coordinates不能为空",groups = MapAddAreaForm.class) + private String coordinates; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/MapDelAreaFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/MapDelAreaFormDTO.java new file mode 100644 index 0000000000..efeaf5b0e2 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/MapDelAreaFormDTO.java @@ -0,0 +1,28 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/10/25 9:23 上午 + * @DESC + */ +@Data +public class MapDelAreaFormDTO implements Serializable { + + private static final long serialVersionUID = -539570523818788293L; + + public interface MapDelAreaForm{} + + /** + * 类型,组织:agency,网格:grid,小区:neighborHood + */ + @NotBlank(message = "level不能为空", groups = MapDelAreaForm.class) + private String level; + + @NotBlank(message = "orgId不能为空", groups = MapDelAreaForm.class) + private String orgId; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/MapOrgFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/MapOrgFormDTO.java new file mode 100644 index 0000000000..04ac916daa --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/MapOrgFormDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/10/25 10:40 上午 + * @DESC + */ +@Data +public class MapOrgFormDTO implements Serializable { + + private static final long serialVersionUID = 2021388285115834510L; + + /** + * 类型,组织:agency,网格:grid,小区:neighborHood + */ + private String level; + + /** + * 组织ID,默认不填写 + */ + private String orgId; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/MapOrgResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/MapOrgResultDTO.java new file mode 100644 index 0000000000..7f92e3bdc1 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/MapOrgResultDTO.java @@ -0,0 +1,71 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2021/10/25 10:40 上午 + * @DESC + */ +@Data +public class MapOrgResultDTO implements Serializable { + + private static final long serialVersionUID = 7296300942981202725L; + + /** + * 经度 + */ + @JsonIgnore + private String longitudeOrigin; + + private BigDecimal longitude; + + /** + * 纬度 + */ + @JsonIgnore + private String latitudeOrigin; + + private BigDecimal latitude; + + /** + * 组织或网格ID + */ + private String id; + + /** + * 组织或网格名字 + */ + private String name; + + /** + * 类型,组织:agency,网格:grid,小区:neighborHood + */ + private String level; + + /** + * 坐标 + */ + private String coordinates; + + /** + * 下级结果集 + */ + private List children; + + public MapOrgResultDTO() { + this.longitudeOrigin = ""; + this.latitudeOrigin = ""; + this.id = ""; + this.name = ""; + this.level = ""; + this.coordinates = ""; + this.children = new ArrayList<>(); + } +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/MapSonOrgResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/MapSonOrgResultDTO.java new file mode 100644 index 0000000000..77cb78266c --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/MapSonOrgResultDTO.java @@ -0,0 +1,64 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2021/10/25 10:40 上午 + * @DESC + */ +@Data +public class MapSonOrgResultDTO implements Serializable { + + private static final long serialVersionUID = 7296300942981202725L; + + /** + * 经度 + */ + @JsonIgnore + private String longitudeOrigin; + + private BigDecimal longitude; + + /** + * 纬度 + */ + @JsonIgnore + private String latitudeOrigin; + + private BigDecimal latitude; + + /** + * 组织或网格ID + */ + private String id; + + /** + * 组织或网格名字 + */ + private String name; + + /** + * 类型,组织:agency,网格:grid,小区:neighborHood + */ + private String level; + + /** + * 坐标 + */ + private String coordinates; + + public MapSonOrgResultDTO() { + this.longitudeOrigin = ""; + this.latitudeOrigin = ""; + this.id = ""; + this.name = ""; + this.level = ""; + this.coordinates = ""; + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java index 112d6b8e35..5d3ecedfbe 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java @@ -27,10 +27,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constant.CustomerAgencyConstant; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.form.*; -import com.epmet.dto.result.AddAgencyResultDTO; -import com.epmet.dto.result.AgencyListResultDTO; -import com.epmet.dto.result.AgencysResultDTO; -import com.epmet.dto.result.SubAgencyResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; import com.epmet.service.AgencyService; import com.epmet.service.CustomerAgencyService; @@ -255,4 +252,42 @@ public class AgencyController { return new Result(); } + /** + * @Description 【地图配置】删除 + * @param formDTO + * @author zxc + * @date 2021/10/25 9:30 上午 + */ + @PostMapping("mapdelarea") + public Result mapDelArea(@RequestBody MapDelAreaFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, MapDelAreaFormDTO.MapDelAreaForm.class); + agencyService.mapDelArea(formDTO); + return new Result(); + } + + /** + * @Description 【地图配置】新增 + * @param formDTO + * @author zxc + * @date 2021/10/25 9:58 上午 + */ + @PostMapping("mapaddarea") + public Result mapAddArea(@RequestBody MapAddAreaFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, MapAddAreaFormDTO.MapAddAreaForm.class); + agencyService.mapAddArea(formDTO); + return new Result(); + } + + /** + * @Description 【地图配置】组织查询 + * @param formDTO + * @param tokenDto + * @author zxc + * @date 2021/10/25 10:50 上午 + */ + @PostMapping("maporg") + public Result mapOrg(@RequestBody MapOrgFormDTO formDTO, @LoginUser TokenDto tokenDto){ + return new Result().ok(agencyService.mapOrg(formDTO,tokenDto)); + } + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java index 145178f50f..3f98a2f847 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java @@ -243,4 +243,32 @@ public interface CustomerAgencyDao extends BaseDao { AgencyTreeResultDTO getAllAgency(@Param("customerId") String customerId); List getSubAgencyList(@Param("pid") String pid); + + /** + * @Description 【地图配置】删除 + * @param orgId + * @param level + * @author zxc + * @date 2021/10/25 9:39 上午 + */ + void delMapArea(@Param("orgId") String orgId, @Param("level") String level); + + /** + * @Description 【地图配置】新增 + * @param orgId + * @param level + * @param coordinates + * @author zxc + * @date 2021/10/25 9:59 上午 + */ + void addMapArea(@Param("orgId") String orgId, @Param("level") String level,@Param("coordinates")String coordinates); + + /** + * @Description 地图查询下级组织 + * @param pid + * @param type + * @author zxc + * @date 2021/10/25 2:30 下午 + */ + List selectSonOrg(@Param("pid")String pid,@Param("type")String type); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java index ee327e421e..ff51b54c01 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java @@ -108,4 +108,19 @@ public class CustomerAgencyEntity extends BaseEpmetEntity { * 【社区】名称0409 */ private String community; + + /** + * 坐标 + */ + private String coordinates; + + /** + * 中心位置经度 + */ + private String longitude; + + /** + * 中心位置纬度 + */ + private String latitude; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerGridEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerGridEntity.java index 26d0cd84af..75674491f7 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerGridEntity.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerGridEntity.java @@ -79,4 +79,9 @@ public class CustomerGridEntity extends BaseEpmetEntity { * 所有上级组织ID */ private String pids; + + /** + * 坐标 + */ + private String coordinates; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java index 381fb7256a..b0153239fd 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java @@ -17,13 +17,11 @@ package com.epmet.service; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.form.*; -import com.epmet.dto.result.AddAgencyResultDTO; -import com.epmet.dto.result.AgencyListResultDTO; -import com.epmet.dto.result.AgencysResultDTO; -import com.epmet.dto.result.SubAgencyResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; import java.util.List; @@ -117,4 +115,28 @@ public interface AgencyService { */ AddAgencyResultDTO addAgencyV2(AddAgencyV2FormDTO formDTO); + /** + * @Description 【地图配置】删除 + * @param formDTO + * @author zxc + * @date 2021/10/25 9:30 上午 + */ + void mapDelArea(MapDelAreaFormDTO formDTO); + + /** + * @Description 【地图配置】新增 + * @param formDTO + * @author zxc + * @date 2021/10/25 9:58 上午 + */ + void mapAddArea(MapAddAreaFormDTO formDTO); + + /** + * @Description 【地图配置】组织查询 + * @param formDTO + * @param tokenDto + * @author zxc + * @date 2021/10/25 10:50 上午 + */ + MapOrgResultDTO mapOrg(MapOrgFormDTO formDTO, TokenDto tokenDto); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java index aa070f2d90..9da41f2e2c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java @@ -21,12 +21,16 @@ import com.alibaba.fastjson.JSON; import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CustomerAgencyConstant; +import com.epmet.constant.OrgInfoConstant; import com.epmet.constant.RoleKeyConstants; import com.epmet.dao.CustomerAgencyDao; import com.epmet.dao.CustomerGridDao; @@ -35,6 +39,7 @@ import com.epmet.dto.GovStaffRoleDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; +import com.epmet.entity.CustomerGridEntity; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; @@ -52,6 +57,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -530,6 +536,97 @@ public class AgencyServiceImpl implements AgencyService { return resultDTO; } + /** + * @Description 【地图配置】删除 + * @param formDTO + * @author zxc + * @date 2021/10/25 9:30 上午 + */ + @Override + public void mapDelArea(MapDelAreaFormDTO formDTO) { + customerAgencyDao.delMapArea(formDTO.getOrgId(),formDTO.getLevel()); + } + + /** + * @Description 【地图配置】新增 + * @param formDTO + * @author zxc + * @date 2021/10/25 9:58 上午 + */ + @Override + public void mapAddArea(MapAddAreaFormDTO formDTO) { + customerAgencyDao.addMapArea(formDTO.getOrgId(), formDTO.getLevel(), formDTO.getCoordinates()); + } + + /** + * @Description 【地图配置】组织查询 + * @param formDTO + * @param tokenDto + * @author zxc + * @date 2021/10/25 10:50 上午 + */ + @Override + public MapOrgResultDTO mapOrg(MapOrgFormDTO formDTO, TokenDto tokenDto) { + MapOrgResultDTO result = new MapOrgResultDTO(); + if (StringUtils.isBlank(formDTO.getOrgId())){ + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); + formDTO.setOrgId(staffInfo.getFromOrgId()); + formDTO.setLevel(staffInfo.getFromOrgType()); + } + if (formDTO.getLevel().equals(OrgInfoConstant.AGENCY)){ + CustomerAgencyEntity entity = customerAgencyDao.selectById(formDTO.getOrgId()); + result = ConvertUtils.sourceToTarget(entity,MapOrgResultDTO.class); + result.setName(entity.getOrganizationName()); + result.setLevel(formDTO.getLevel()); + result.setLatitude(StringUtils.isBlank(entity.getLatitude()) ? null : new BigDecimal(entity.getLatitude())); + result.setLongitude(StringUtils.isBlank(entity.getLongitude()) ? null : new BigDecimal(entity.getLongitude())); + if (entity.getLevel().equals(OrgInfoConstant.COMMUNITY)){ + List son = customerAgencyDao.selectSonOrg(formDTO.getOrgId(), OrgInfoConstant.GRID); + if (CollectionUtils.isNotEmpty(son)){ + son.forEach(s -> { + s.setLatitude(StringUtils.isBlank(s.getLatitudeOrigin()) ? null : new BigDecimal(s.getLatitudeOrigin())); + s.setLongitude(StringUtils.isBlank(s.getLongitudeOrigin()) ? null : new BigDecimal(s.getLongitudeOrigin())); + }); + } + result.setChildren(CollectionUtils.isEmpty(son) ? new ArrayList<>() : son); + }else { + List dtoList = new ArrayList<>(); + List son = customerAgencyDao.selectSonOrg(formDTO.getOrgId(), OrgInfoConstant.AGENCY); + if (CollectionUtils.isNotEmpty(son)){ + dtoList.addAll(son); + } + // 直属网格 + List directlySub = customerAgencyDao.selectSonOrg(formDTO.getOrgId(), OrgInfoConstant.GRID); + if (CollectionUtils.isNotEmpty(directlySub)){ + dtoList.addAll(directlySub); + } + if (CollectionUtils.isNotEmpty(dtoList)){ + dtoList.forEach(d -> { + d.setLatitude(StringUtils.isBlank(d.getLatitudeOrigin()) ? null : new BigDecimal(d.getLatitudeOrigin())); + d.setLongitude(StringUtils.isBlank(d.getLongitudeOrigin()) ? null : new BigDecimal(d.getLongitudeOrigin())); + }); + } + result.setChildren(dtoList); + } + }else if (formDTO.getLevel().equals(OrgInfoConstant.GRID)){ + CustomerGridEntity entity = customerGridDao.selectById(formDTO.getOrgId()); + result = ConvertUtils.sourceToTarget(entity,MapOrgResultDTO.class); + result.setName(entity.getGridName()); + result.setLevel(formDTO.getLevel()); + result.setLatitude(StringUtils.isBlank(entity.getLatitude()) ? null : new BigDecimal(entity.getLatitude())); + result.setLongitude(StringUtils.isBlank(entity.getLongitude()) ? null : new BigDecimal(entity.getLongitude())); + List son = customerAgencyDao.selectSonOrg(formDTO.getOrgId(), OrgInfoConstant.NEIGHBOR_HOOD); + if (CollectionUtils.isNotEmpty(son)){ + son.forEach(s -> { + s.setLatitude(StringUtils.isBlank(s.getLatitudeOrigin()) ? null : new BigDecimal(s.getLatitudeOrigin())); + s.setLongitude(StringUtils.isBlank(s.getLongitudeOrigin()) ? null : new BigDecimal(s.getLongitudeOrigin())); + }); + } + result.setChildren(CollectionUtils.isEmpty(son) ? new ArrayList<>() : son); + } + return result; + } + private CustomerAgencyEntity constructInsertEntity(AddAgencyV2FormDTO formDTO, CustomerAgencyDTO parent) { CustomerAgencyEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class); insertEntity.setOrganizationName(formDTO.getAgencyName()); diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.8__add_coordinates.sql b/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.8__add_coordinates.sql new file mode 100644 index 0000000000..51e687031c --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.8__add_coordinates.sql @@ -0,0 +1,4 @@ +alter table customer_agency add COLUMN LONGITUDE varchar(255) comment '经度' AFTER SYNC_FLAG; +alter table customer_agency add COLUMN LATITUDE varchar(255) comment '纬度' AFTER LONGITUDE; +alter table customer_agency add COLUMN COORDINATES text(0) comment '坐标区域' AFTER LATITUDE; +alter table customer_grid add COLUMN COORDINATES text(0) comment '坐标区域' AFTER LATITUDE; \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index 89a5df87f4..3dcb3a472e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -24,6 +24,44 @@ ca.updated_time AS "updatedtime" + + + UPDATE + + customer_agency + + + customer_grid + + + ic_neighbor_hood + + SET + COORDINATES = #{coordinates}, + UPDATED_TIME = NOW() + WHERE ID = #{orgId} + AND DEL_FLAG = '0' + + + + + UPDATE + + customer_agency + + + customer_grid + + + ic_neighbor_hood + + SET + COORDINATES = NULL, + UPDATED_TIME = NOW() + WHERE ID = #{orgId} + AND DEL_FLAG = '0' + + + + + \ No newline at end of file