|
|
@ -30,8 +30,13 @@ import com.elink.esua.epdc.dto.epdc.GridForLeaderRegisterDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.GridLeaderRegisterDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.EpdcAppGridManFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.result.EpdcAppGridManListResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.management.form.*; |
|
|
|
import com.elink.esua.epdc.dto.management.result.GlobalResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.result.SysDeptInfoResultDTO; |
|
|
|
import com.elink.esua.epdc.entity.SysUserEntity; |
|
|
|
import com.elink.esua.epdc.feign.CommunityManageFeignClient; |
|
|
|
import com.elink.esua.epdc.service.*; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -48,15 +53,21 @@ import java.util.Map; |
|
|
|
* @since 1.0.0 |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
@Slf4j |
|
|
|
public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntity> implements SysUserService { |
|
|
|
@Autowired |
|
|
|
private SysRoleUserService sysRoleUserService; |
|
|
|
@Autowired |
|
|
|
private SysDeptService sysDeptService; |
|
|
|
@Autowired |
|
|
|
private SysDeptInfoService sysDeptInfoService; |
|
|
|
@Autowired |
|
|
|
private SysPropertyUserService sysPropertyUserService; |
|
|
|
@Autowired |
|
|
|
private SysEpmetUserRelationService sysEpmetUserRelationService; |
|
|
|
@Autowired |
|
|
|
private CommunityManageFeignClient communityManageFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<SysUserDTO> page(Map<String, Object> params) { |
|
|
@ -129,6 +140,9 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit |
|
|
|
|
|
|
|
// 保存/更新网格员信息
|
|
|
|
sysEpmetUserRelationService.saveOrUpdateUserEpmetRelation(entity.getId(), dto.getWgyInfo()); |
|
|
|
|
|
|
|
// 社区管理推送
|
|
|
|
sendInfo(dto, entity, 0); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -161,6 +175,9 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit |
|
|
|
|
|
|
|
// 保存/更新网格员信息
|
|
|
|
sysEpmetUserRelationService.saveOrUpdateUserEpmetRelation(entity.getId(), dto.getWgyInfo()); |
|
|
|
|
|
|
|
// 社区管理推送
|
|
|
|
sendInfo(dto, entity, 1); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -191,6 +208,15 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit |
|
|
|
logicDelete(ids, SysUserEntity.class); |
|
|
|
|
|
|
|
//角色用户关系,需要保留,不然逻辑删除就变成物理删除了
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SysUserEntity entity = new SysUserEntity(); |
|
|
|
SysUserDTO dto = new SysUserDTO(); |
|
|
|
entity.setId(ids[0]); |
|
|
|
dto.setId(ids[0]); |
|
|
|
// 社区管理推送
|
|
|
|
sendInfo(dto, entity, 2); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -342,4 +368,105 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit |
|
|
|
return listGridmanInfo; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 推送处理 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @param entity |
|
|
|
* @param type 0:新增 1:编辑 2:删除 |
|
|
|
* @return void |
|
|
|
* @author wgf |
|
|
|
* @date 2022/12/9 04:56 |
|
|
|
*/ |
|
|
|
private void sendInfo(SysUserDTO dto, SysUserEntity entity, int type) { |
|
|
|
try { |
|
|
|
// 获取网格的ManageId
|
|
|
|
SysDeptInfoResultDTO sysDeptInfoResultDTO = sysDeptInfoService.getSysDeptInfo(entity.getDeptId().toString()); |
|
|
|
if (type == NumConstant.ZERO) { |
|
|
|
if(sysDeptInfoResultDTO.getGridManageId() != null && sysDeptInfoResultDTO.getCommunityManageId() != null){ |
|
|
|
ManageUserAddFormDTO userAddFormDTO = new ManageUserAddFormDTO(); |
|
|
|
userAddFormDTO.setGridId(sysDeptInfoResultDTO.getGridManageId()); |
|
|
|
userAddFormDTO.setUserName(entity.getUsername()); |
|
|
|
userAddFormDTO.setPhone(entity.getMobile()); |
|
|
|
userAddFormDTO.setGender(entity.getGender() == null ? "" : entity.getGender().toString()); |
|
|
|
userAddFormDTO.setBornTime(""); |
|
|
|
userAddFormDTO.setWorkDate(""); |
|
|
|
userAddFormDTO.setHeadImage(entity.getHeadUrl()); |
|
|
|
userAddFormDTO.setIntroduction(entity.getRemark()); |
|
|
|
userAddFormDTO.setDescription(""); |
|
|
|
userAddFormDTO.setCreateTime(entity.getCreateDate().toString()); |
|
|
|
userAddFormDTO.setOldManageId(entity.getId().toString()); |
|
|
|
|
|
|
|
log.info("++++++++++++++++++++++++++++++++++++++++++++sysUserAddFormDTO:" + userAddFormDTO); |
|
|
|
Result<GlobalResultDTO> result = communityManageFeignClient.addManageUser(userAddFormDTO); |
|
|
|
log.info("++++++++++++++++++++++++++++++++++++++++++++sysUserAdd result:" + result); |
|
|
|
communityManageHandle(result, dto, entity); |
|
|
|
} |
|
|
|
} else if (type == NumConstant.ONE) { |
|
|
|
SysUserEntity userEntity = baseDao.selectById(dto.getId()); |
|
|
|
if (userEntity != null && userEntity.getManageId() != null) { |
|
|
|
ManageUserUpdFormDTO userUpdFormDTO = new ManageUserUpdFormDTO(); |
|
|
|
|
|
|
|
userUpdFormDTO.setUserName(entity.getUsername()); |
|
|
|
userUpdFormDTO.setGender(entity.getGender() == null ? "" : entity.getGender().toString()); |
|
|
|
userUpdFormDTO.setBornTime(""); |
|
|
|
userUpdFormDTO.setWorkDate(""); |
|
|
|
userUpdFormDTO.setHeadImage(entity.getHeadUrl()); |
|
|
|
userUpdFormDTO.setIntroduction(entity.getRemark()); |
|
|
|
userUpdFormDTO.setDescription(""); |
|
|
|
userUpdFormDTO.setId(userEntity.getManageId()); |
|
|
|
userUpdFormDTO.setGridId(sysDeptInfoResultDTO.getGridManageId()); |
|
|
|
|
|
|
|
log.info("++++++++++++++++++++++++++++++++++++++++++++sysUserUpdFormDTO:" + userUpdFormDTO); |
|
|
|
Result<GlobalResultDTO> result = communityManageFeignClient.updManageUser(userUpdFormDTO); |
|
|
|
log.info("++++++++++++++++++++++++++++++++++++++++++++sysUserupd result:" + result); |
|
|
|
communityManageHandle(result, dto, entity); |
|
|
|
} |
|
|
|
} else if (type == NumConstant.TWO) { |
|
|
|
SysUserEntity userEntity = baseDao.selectById(dto.getId()); |
|
|
|
if (userEntity != null && userEntity.getManageId() != null) { |
|
|
|
ManageUserDelFormDTO userDelFormDTO = new ManageUserDelFormDTO(); |
|
|
|
userDelFormDTO.setId(userEntity.getManageId()); |
|
|
|
log.info("++++++++++++++++++++++++++++++++++++++++++++sysUserDelFormDTO:" + userDelFormDTO); |
|
|
|
Result<GlobalResultDTO> result = communityManageFeignClient.delManageUser(userDelFormDTO); |
|
|
|
log.info("++++++++++++++++++++++++++++++++++++++++++++sysUserDel result:" + result); |
|
|
|
// communityManageHandle(result, dto, entity);
|
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("推送社区管理接口失败:type>>" + type + "||id>>" + entity.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设置ManageId |
|
|
|
* @param result |
|
|
|
* @param dto |
|
|
|
* @param entity |
|
|
|
*/ |
|
|
|
private void communityManageHandle(Result<GlobalResultDTO> result, SysUserDTO dto, SysUserEntity entity) { |
|
|
|
if (result.success()) { |
|
|
|
Object resultObject = result.getData().getResult(); |
|
|
|
Integer mId = null; |
|
|
|
// 只有新增操作result才会有值,编辑删除是null,直接通过这个来判断是不是新增操作
|
|
|
|
if (resultObject != null) { |
|
|
|
mId = Integer.valueOf(resultObject.toString()); |
|
|
|
} |
|
|
|
SysUserEntity userEntity = baseDao.selectById(entity.getId()); |
|
|
|
// 表里没有直接插入
|
|
|
|
if (userEntity == null) { |
|
|
|
// 插入信息表
|
|
|
|
SysUserEntity addUserEntity = ConvertUtils.sourceToTarget(dto, SysUserEntity.class); |
|
|
|
addUserEntity.setManageId(mId); |
|
|
|
baseDao.insert(addUserEntity); |
|
|
|
} else { |
|
|
|
// 更新信息表
|
|
|
|
userEntity.setManageId(mId); |
|
|
|
baseDao.updateById(userEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|