|
|
@ -18,8 +18,10 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
@ -27,26 +29,32 @@ import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.OptionResultDTO; |
|
|
|
import com.epmet.commons.tools.enums.DictTypeEnum; |
|
|
|
import com.epmet.commons.tools.enums.OrgTypeEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.RedisKeys; |
|
|
|
import com.epmet.commons.tools.redis.RedisUtils; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|
|
|
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.CustomerGridConstant; |
|
|
|
import com.epmet.dao.CustomerGridDao; |
|
|
|
import com.epmet.dao.CustomerStaffGridDao; |
|
|
|
import com.epmet.dao.StaffOrgRelationDao; |
|
|
|
import com.epmet.dto.*; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.CustomerGridEntity; |
|
|
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|
|
|
import com.epmet.feign.EpmetMessageOpenFeignClient; |
|
|
|
import com.epmet.feign.EpmetUserFeignClient; |
|
|
|
import com.epmet.feign.OperCrmOpenFeignClient; |
|
|
|
import com.epmet.entity.CustomerStaffGridEntity; |
|
|
|
import com.epmet.entity.StaffOrgRelationEntity; |
|
|
|
import com.epmet.feign.*; |
|
|
|
import com.epmet.resi.partymember.feign.ResiPartyMemberOpenFeignClient; |
|
|
|
import com.epmet.service.CustomerAgencyService; |
|
|
|
import com.epmet.service.CustomerGridService; |
|
|
|
import com.epmet.util.ModuleConstant; |
|
|
@ -86,11 +94,26 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu |
|
|
|
@Autowired |
|
|
|
private CustomerGridDao customerGridDao; |
|
|
|
@Autowired |
|
|
|
private RedisUtils redisUtils; |
|
|
|
private StaffOrgRelationDao staffOrgRelationDao; |
|
|
|
@Autowired |
|
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
private RedisUtils redisUtils; |
|
|
|
@Autowired |
|
|
|
private EpmetAdminOpenFeignClient adminOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private LoginUserUtil loginUserUtil; |
|
|
|
|
|
|
|
|
|
|
|
//迁移网格
|
|
|
|
@Autowired |
|
|
|
private GovIssueOpenFeignClient govIssueOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private GovProjectOpenFeignClient govProjectOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private ResiPartyMemberOpenFeignClient resiPartyMemberOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<CustomerGridDTO> page(Map<String, Object> params) { |
|
|
@ -802,14 +825,6 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu |
|
|
|
if (null != gridInfo) { |
|
|
|
redisUtils.hMSet(redisKey, BeanUtil.beanToMap(gridInfo)); |
|
|
|
} |
|
|
|
/*CustomerGridDTO gridInfo = ConvertUtils.sourceToTarget(baseDao.selectById(customerGridFormDTO.getGridId()), CustomerGridDTO.class); |
|
|
|
if (null != gridInfo) { |
|
|
|
CustomerAgencyEntity agency = customerAgencyService.selectById(gridInfo.getPid()); |
|
|
|
gridInfo.setAgencyName(null != agency ? agency.getOrganizationName() : ""); |
|
|
|
gridInfo.setGridNamePath(null != agency ? agency.getOrganizationName().concat("-").concat(gridInfo.getGridName()) : gridInfo.getGridName()); |
|
|
|
|
|
|
|
redisUtils.hMSet(redisKey, BeanUtil.beanToMap(gridInfo)); |
|
|
|
}*/ |
|
|
|
return gridInfo; |
|
|
|
} |
|
|
|
|
|
|
@ -945,4 +960,107 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu |
|
|
|
return baseDao.getStaffGridList(customerId,orgId,orgType); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 弃用网格 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void abandonGrid(AbandonGridFormDTO formDTO) { |
|
|
|
//未处理的事件
|
|
|
|
Result<ProjectAuditResetResultDTO> projectDb = govProjectOpenFeignClient.eventAuditReset(formDTO.getGridId()); |
|
|
|
//表决中的议题
|
|
|
|
Result<Boolean> issueAuditReset = govIssueOpenFeignClient.issueAuditReset(formDTO.getGridId()); |
|
|
|
if (!projectDb.success() || !issueAuditReset.success()) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "校验数据异常", "服务器开小差了..."); |
|
|
|
} |
|
|
|
if (projectDb.getData().getResiEventStatus()) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "存在未处理的事件", "该网格存在未办结的群众直报事件,请先将事件办结后再操作"); |
|
|
|
} |
|
|
|
if (projectDb.getData().getProjectStatus()) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "存在未办结的项目", "该网格工作人员名下存在未结案的项目,请先将项目结案或转其它科室部门后再操作"); |
|
|
|
} |
|
|
|
if (issueAuditReset.getData()) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "存在未关闭的议题", "该网格存在未关闭的议题,请先将议题关闭后再操作"); |
|
|
|
} |
|
|
|
|
|
|
|
//可以弃用、处理数据(网格工作人员所属关系(网格工作人员人数), 删除正在审核中的徽章认证)
|
|
|
|
this.abandonGridForDealBizData(formDTO); |
|
|
|
CustomerOrgRedis.delGridInfo(formDTO.getGridId()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void abandonGridForDealBizData(AbandonGridFormDTO formDTO) { |
|
|
|
try { |
|
|
|
//根据网格id 获取网格内工作人员及其添加关系
|
|
|
|
List<StaffOrgRelationDTO> staffList = customerStaffGridDao.getGridStaffList(formDTO.getGridId()); |
|
|
|
if (staffList == null){ |
|
|
|
staffList = new ArrayList<>(); |
|
|
|
} |
|
|
|
logger.debug("abandonGridForDealBizData staffList:{}", JSON.toJSONString(staffList)); |
|
|
|
List<StaffOrgRelationEntity> updateList = new ArrayList<>(); |
|
|
|
staffList.forEach(staffOrg->{ |
|
|
|
//只有工作人员是网格添加的才处理
|
|
|
|
if(!OrgTypeEnum.GRID.getCode().equals(staffOrg.getOrgType())) { |
|
|
|
return; |
|
|
|
} |
|
|
|
StaffOrgRelationEntity entity = new StaffOrgRelationEntity(); |
|
|
|
entity.setId(staffOrg.getId()); |
|
|
|
entity.setOrgType(OrgTypeEnum.AGENCY.getCode()); |
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(staffOrg.getOrgId()); |
|
|
|
if (gridInfo == null || StringUtils.isBlank(gridInfo.getPid())) { |
|
|
|
assert gridInfo != null; |
|
|
|
log.error("abandonGridForDealBizData grid:{} pid is not exist", JSON.toJSONString(gridInfo)); |
|
|
|
return; |
|
|
|
} |
|
|
|
entity.setOrgId(gridInfo.getPid()); |
|
|
|
updateList.add(entity); |
|
|
|
}); |
|
|
|
String customerId = loginUserUtil.getLoginUserCustomerId(); |
|
|
|
//更新工作人员组织关系
|
|
|
|
dealBizDataForAbandon(customerId,formDTO.getGridId(),formDTO.getUserId(), staffList, updateList); |
|
|
|
//清空工作人员缓存
|
|
|
|
staffList.forEach(staff->CustomerStaffRedis.delStaffInfoFormCache(customerId,staff.getStaffId())); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
log.error("abandonGridForDealBizData exception", e); |
|
|
|
throw e; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
@Transactional |
|
|
|
public void dealBizDataForAbandon(String customerId, String gridId, String userId,List<StaffOrgRelationDTO> staffList, List<StaffOrgRelationEntity> updateList) { |
|
|
|
//1.删除工作人员与网格的关系
|
|
|
|
LambdaQueryWrapper<CustomerStaffGridEntity> updateWrapper = new LambdaQueryWrapper<>(); |
|
|
|
updateWrapper.eq(CustomerStaffGridEntity::getGridId,gridId); |
|
|
|
customerStaffGridDao.delete(updateWrapper); |
|
|
|
//2.修改 网格内添加工作人员改为组织
|
|
|
|
updateList.forEach(e->{ |
|
|
|
staffOrgRelationDao.update(e,null); |
|
|
|
}); |
|
|
|
//网格对应的人数减少
|
|
|
|
long reduceCount = NumConstant.ZERO - staffList.stream().map(StaffOrgRelationDTO::getStaffId).distinct().count(); |
|
|
|
log.debug("dealBizDataForAbandon gridId:{} reduceCount:{}",gridId, reduceCount); |
|
|
|
customerGridDao.updateTotalUser(gridId, reduceCount); |
|
|
|
//删除正在审核中的徽章认证
|
|
|
|
Result<Integer> badgeResult = epmetUserFeignClient.deleteBadgeCertificateAuditing(customerId,gridId); |
|
|
|
if (badgeResult == null || !badgeResult.success()){ |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"删除未审核徽章失败,请稍后重试"); |
|
|
|
} |
|
|
|
//删除废弃网格的访问记录
|
|
|
|
Result<Integer> gridLatestResult = epmetUserFeignClient.deleteGridLatestData(customerId,gridId); |
|
|
|
if (gridLatestResult == null || !gridLatestResult.success()){ |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"删除网格访问记录失败,请稍后重试"); |
|
|
|
} |
|
|
|
//处理成功,隐藏网格
|
|
|
|
LambdaUpdateWrapper<CustomerGridEntity> updateGrid=new LambdaUpdateWrapper<>(); |
|
|
|
updateGrid.set(CustomerGridEntity::getAbandonFlag,NumConstant.ONE); |
|
|
|
updateGrid.set(CustomerGridEntity::getUpdatedBy,userId); |
|
|
|
updateGrid.set(CustomerGridEntity::getUpdatedTime,new Date()); |
|
|
|
updateGrid.eq(CustomerGridEntity::getId,gridId); |
|
|
|
baseDao.update(null,updateGrid); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|