Browse Source

弃用网格 业务数据处理(组织关系和徽章)

dev
jianjun 4 years ago
parent
commit
e8619eb9da
  1. 12
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java
  2. 12
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java
  3. 10
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java
  4. 20
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java
  5. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java
  6. 66
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java
  7. 4
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml
  8. 14
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml
  9. 12
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java
  10. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java
  11. 8
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeCertificateRecordService.java
  12. 6
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java
  13. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeCertificateRecordServiceImpl.java

12
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java

@ -239,4 +239,16 @@ public class GridController {
customerGridService.abandonGrid(formDTO); customerGridService.abandonGrid(formDTO);
return new Result(); return new Result();
} }
/**
* desc:移除网格内的工作人员关系 并迁移到组织
* @author jianjun liu
* @remark: 如果是网格添加的则解除关系后将注册关系改为对应的组织 如果不是则直接解除关系(相当于移除该人员与网格的关系)
*/
@PostMapping("removeGridStaff2Agency/{gridId}")
//@RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_TRANSFER)
public Result removeGridStaff2Agency( @PathVariable String gridId){
customerGridService.abandonGridForDealBizData(gridId);
return new Result();
}
} }

12
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java

@ -367,11 +367,19 @@ public interface CustomerGridDao extends BaseDao<CustomerGridEntity> {
List<CustomerStaffGridResultDTO> getStaffGridList(@Param("customerId") String customerId, @Param("orgId") String orgId, @Param("orgType") String orgType); List<CustomerStaffGridResultDTO> getStaffGridList(@Param("customerId") String customerId, @Param("orgId") String orgId, @Param("orgType") String orgType);
/** /**
* @Description 根据网格名字查询网格信息
* @param names * @param names
* @Description 根据网格名字查询网格信息
* @author zxc * @author zxc
* @date 2022/2/12 2:06 下午 * @date 2022/2/12 2:06 下午
*/ */
List<InfoByNamesResultDTO> selectGridInfoByNames(@Param("names")List<String> names,@Param("customerId")String customerId); List<InfoByNamesResultDTO> selectGridInfoByNames(@Param("names") List<String> names, @Param("customerId") String customerId);
/**
* desc:修改网格工作人员数量
*
* @param gridId
* @param incrCount 增加人数 负数为 -
* @return
*/
int updateTotalUser(@Param("gridId") String gridId, @Param("incrCount") long incrCount);
} }

10
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java

@ -19,8 +19,8 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.CustomerStaffDepartmentDTO;
import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.StaffOrgRelationDTO;
import com.epmet.dto.form.LatestGridFormDTO; import com.epmet.dto.form.LatestGridFormDTO;
import com.epmet.dto.result.EventTitleOrgResultDTO; import com.epmet.dto.result.EventTitleOrgResultDTO;
import com.epmet.dto.result.GridStaffResultDTO; import com.epmet.dto.result.GridStaffResultDTO;
@ -28,7 +28,6 @@ import com.epmet.entity.CustomerStaffGridEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -115,4 +114,11 @@ public interface CustomerStaffGridDao extends BaseDao<CustomerStaffGridEntity> {
* @date 2021/8/5 5:36 下午 * @date 2021/8/5 5:36 下午
*/ */
List<EventTitleOrgResultDTO> eventOrg(@Param("userId") String userId); List<EventTitleOrgResultDTO> eventOrg(@Param("userId") String userId);
/**
* desc:根据网格id 获取网格下的工作人员及其添加关系
* @param gridId
* @return
*/
List<StaffOrgRelationDTO> getGridStaffList(String gridId);
} }

20
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java

@ -4,23 +4,8 @@ import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.*; import com.epmet.dto.*;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.StaffGridListDTO;
import com.epmet.dto.form.AddDepartmentStaffFormDTO;
import com.epmet.dto.form.DepartmentInStaffFormDTO;
import com.epmet.dto.form.StaffInfoFromDTO;
import com.epmet.dto.form.StaffSubmitFromDTO;
import com.epmet.dto.form.StaffsInAgencyFromDTO;
import com.epmet.dto.result.DepartInStaffListResultDTO;
import com.epmet.dto.result.StaffDetailResultDTO;
import com.epmet.dto.result.StaffInfoResultDTO;
import com.epmet.dto.result.StaffInitResultDTO;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.StaffGridListDTO;
import com.epmet.feign.EpmetUserFeignClient; import com.epmet.feign.EpmetUserFeignClient;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -106,4 +91,9 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient {
public Result<CustomerStaffListResultDTO> getCustomerStaffList(List<String> staffIdList) { public Result<CustomerStaffListResultDTO> getCustomerStaffList(List<String> staffIdList) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffList", staffIdList); return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffList", staffIdList);
} }
@Override
public Result<Integer> updateUserBadgeCertificateRecord(String customerId, String gridId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "updateUserBadgeCertificateRecord", customerId, gridId);
}
} }

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java

@ -381,4 +381,10 @@ public interface CustomerGridService extends BaseService<CustomerGridEntity> {
* @return * @return
*/ */
void abandonGrid(AbandonGridFormDTO formDTO); void abandonGrid(AbandonGridFormDTO formDTO);
/**
* desc:移除网格内的工作人员关系 并迁移到组织
* @param gridId
*/
void abandonGridForDealBizData(String gridId);
} }

66
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java

@ -18,6 +18,7 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import cn.hutool.core.bean.BeanUtil; 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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -28,12 +29,14 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.dto.result.OptionResultDTO;
import com.epmet.commons.tools.enums.DictTypeEnum; 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.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils; 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.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
@ -41,10 +44,13 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.CustomerGridConstant; import com.epmet.constant.CustomerGridConstant;
import com.epmet.dao.CustomerGridDao; import com.epmet.dao.CustomerGridDao;
import com.epmet.dao.CustomerStaffGridDao; import com.epmet.dao.CustomerStaffGridDao;
import com.epmet.dao.StaffOrgRelationDao;
import com.epmet.dto.*; import com.epmet.dto.*;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
import com.epmet.entity.CustomerGridEntity; import com.epmet.entity.CustomerGridEntity;
import com.epmet.entity.CustomerStaffGridEntity;
import com.epmet.entity.StaffOrgRelationEntity;
import com.epmet.feign.*; import com.epmet.feign.*;
import com.epmet.resi.partymember.feign.ResiPartyMemberOpenFeignClient; import com.epmet.resi.partymember.feign.ResiPartyMemberOpenFeignClient;
import com.epmet.service.CustomerAgencyService; import com.epmet.service.CustomerAgencyService;
@ -86,6 +92,8 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
@Autowired @Autowired
private CustomerGridDao customerGridDao; private CustomerGridDao customerGridDao;
@Autowired @Autowired
private StaffOrgRelationDao staffOrgRelationDao;
@Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Autowired @Autowired
private EpmetAdminOpenFeignClient adminOpenFeignClient; private EpmetAdminOpenFeignClient adminOpenFeignClient;
@ -983,7 +991,7 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
//可以弃用、处理数据 todo //可以弃用、处理数据 todo
// .... // ....
// .... // ....
this.abandonGridForDealBizData(formDTO.getGridId());
//处理成功,隐藏网格 //处理成功,隐藏网格
LambdaUpdateWrapper<CustomerGridEntity> updateGrid=new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<CustomerGridEntity> updateGrid=new LambdaUpdateWrapper<>();
@ -992,4 +1000,60 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
baseDao.update(null,updateGrid); baseDao.update(null,updateGrid);
} }
@Override
public void abandonGridForDealBizData(String gridId) {
try {
//根据网格id 获取网格内工作人员及其添加关系
List<StaffOrgRelationDTO> staffList = customerStaffGridDao.getGridStaffList(gridId);
if (CollectionUtils.isEmpty(staffList)){
log.info("abandonGridForDealBizData gridId:{} have any staff", gridId);
return;
}
logger.debug("abandonGridForDealBizData staffList:{}", JSON.toJSONString(staffList));
List<StaffOrgRelationEntity> updateList = new ArrayList<>();
staffList.forEach(staffOrg->{
if(OrgTypeEnum.GRID.getCode().equals(staffOrg.getOrgType())){
StaffOrgRelationEntity entity = new StaffOrgRelationEntity();
entity.setId(staffOrg.getId());
entity.setOrgType(OrgTypeEnum.AGENCY.getCode());
String pid = CustomerOrgRedis.getGridInfo(staffOrg.getStaffId()).getPid();
if (StringUtils.isBlank(pid)){
log.error("abandonGridForDealBizData agencyId:{} is not exist",pid);
return;
}
entity.setOrgId(pid);
updateList.add(entity);
}
});
//更新工作人员组织关系
String customerId = staffList.get(NumConstant.ZERO).getCustomerId();
updateGridStaff2Agency(customerId,gridId, staffList, updateList);
//清空工作人员缓存
staffList.forEach(staff->CustomerStaffRedis.delStaffInfoFormCache(customerId,staff.getStaffId()));
} catch (Exception e) {
log.error("abandonGridForDealBizData exception", e);
throw e;
}
}
@Transactional
public void updateGridStaff2Agency(String customerId, String gridId, 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("updateGridStaff2Agency gridId:{} reduceCount:{}",gridId, reduceCount);
int effectRow = 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(),"删除未审核徽章失败,请稍后重试");
}
}
} }

4
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml

@ -844,5 +844,9 @@
</foreach> </foreach>
) )
</select> </select>
<update id="updateTotalUser">
UPDATE customer_grid SET total_user = total_user+#{incrCount}
where id = #{gridId} and del_flag = '0'
</update>
</mapper> </mapper>

14
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml

@ -173,4 +173,18 @@
AND AND
DEL_FLAG = 0 DEL_FLAG = 0
</update> </update>
<select id="getGridStaffList" resultType="com.epmet.dto.StaffOrgRelationDTO">
SELECT
csg.customer_id,
csg.GRID_ID orgId,
csg.USER_ID staffId,
ifnull(sor.ORG_TYPE,'agency') orgType,
sor.id id
FROM
customer_staff_grid csg
LEFT JOIN staff_org_relation sor ON csg.USER_ID = sor.STAFF_ID AND csg.grid_id = sor.ORG_ID AND sor.del_flag = '0'
WHERE
csg.del_flag = '0'
AND csg.GRID_ID = #{gridId}
</select>
</mapper> </mapper>

12
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java

@ -12,7 +12,6 @@ import com.epmet.service.BadgeService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -218,4 +217,15 @@ public class BadgeController {
return new Result<Boolean>().ok(badgeService.badgeAuditReset(gridId)); return new Result<Boolean>().ok(badgeService.badgeAuditReset(gridId));
} }
/**
* Desc: 查询网格下是否存在未审核的徽章truefalse
* @param gridId
* @author zxc
* @date 2022/3/16 9:42 上午
*/
@PostMapping("deleteBadgeCertificateAuditing")
public Result<Boolean> deleteBadgeCertificateAuditing(@RequestParam("customerId") String customerId,@RequestParam("gridId")String gridId){
return new Result<Boolean>().ok(badgeService.deleteBadgeCertificateAuditing(customerId,gridId));
}
} }

7
epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java

@ -209,4 +209,11 @@ public interface BadgeService extends BaseService<BadgeEntity> {
*/ */
Boolean badgeAuditReset(String gridId); Boolean badgeAuditReset(String gridId);
/**
* desc:根据网格id 修改审核状态
* @param customerId
* @param gridId
* @return
*/
Integer deleteBadgeCertificateAuditing(String customerId, String gridId);
} }

8
epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeCertificateRecordService.java

@ -92,4 +92,12 @@ public interface UserBadgeCertificateRecordService extends BaseService<UserBadge
* @date 2020-11-05 * @date 2020-11-05
*/ */
void delete(String[] ids); void delete(String[] ids);
/**
* desc:删除审核中的徽章认证
* @param customerId
* @param gridId
* @return
*/
Integer deleteBadgeCertificateAuditing(String customerId, String gridId);
} }

6
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java

@ -24,7 +24,6 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.exception.ValidateException; import com.epmet.commons.tools.exception.ValidateException;
@ -510,4 +509,9 @@ public class BadgeServiceImpl extends BaseServiceImpl<BadgeDao, BadgeEntity> imp
} }
return false; return false;
} }
@Override
public Integer deleteBadgeCertificateAuditing(String customerId, String gridId) {
return userBadgeCertificateRecordService.deleteBadgeCertificateAuditing(customerId,gridId);
}
} }

10
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeCertificateRecordServiceImpl.java

@ -17,6 +17,7 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -97,4 +98,13 @@ public class UserBadgeCertificateRecordServiceImpl extends BaseServiceImpl<UserB
baseDao.deleteBatchIds(Arrays.asList(ids)); baseDao.deleteBatchIds(Arrays.asList(ids));
} }
@Override
public Integer deleteBadgeCertificateAuditing(String customerId, String gridId) {
LambdaQueryWrapper<UserBadgeCertificateRecordEntity> tWrapper = new LambdaQueryWrapper<>();
tWrapper.eq(UserBadgeCertificateRecordEntity::getCustomerId,customerId)
.eq(UserBadgeCertificateRecordEntity::getGridId,gridId)
.eq(UserBadgeCertificateRecordEntity::getAuditStatus,"auditing");
return baseDao.delete(tWrapper);
}
} }
Loading…
Cancel
Save