Browse Source

网格员维护修改

dev
yujintao 6 years ago
parent
commit
97207febb6
  1. 55
      esua-epdc/epdc-module/epdc-custom/epdc-custom-client/src/main/java/com/elink/esua/epdc/dto/consult/GridOperatorInfoDTO.java
  2. 135
      esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/service/impl/GridOperatorInfoServiceImpl.java

55
esua-epdc/epdc-module/epdc-custom/epdc-custom-client/src/main/java/com/elink/esua/epdc/dto/consult/GridOperatorInfoDTO.java

@ -19,6 +19,8 @@ package com.elink.esua.epdc.dto.consult;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
import lombok.Data; import lombok.Data;
@ -36,113 +38,118 @@ public class GridOperatorInfoDTO implements Serializable {
/** /**
* 主键 * 主键
*/ */
private String id; private String id;
/** /**
* 用户姓名 * 用户姓名
*/ */
private String realName; private String realName;
/** /**
* 性别 0女 1男 * 性别 0女 1男
*/ */
private String sex; private String sex;
/** /**
* 排序 * 排序
*/ */
private Integer sort; private Integer sort;
/** /**
* 联系电话 * 联系电话
*/ */
private String mobile; private String mobile;
/** /**
* 身份证号 * 身份证号
*/ */
private String identityNo; private String identityNo;
/** /**
* 头像访问地址 * 头像访问地址
*/ */
private String faceImg; private String faceImg;
/** /**
* 工作单位 * 工作单位
*/ */
private String workUnit; private String workUnit;
/** /**
* 职责类别id * 职责类别id
*/ */
private String dutyCategoryId; private String dutyCategoryId;
/** /**
* 前端收费展示 0否 1是 * 前端收费展示 0否 1是
*/ */
private String showFlag; private String showFlag;
/** /**
* 备注 * 备注
*/ */
private String remark; private String remark;
/** /**
* 居住网格id * 居住网格id
*/ */
private Long deptId; private Long deptId;
/** /**
* 父所有部门 * 父所有部门
*/ */
private String parentDeptIds; private String parentDeptIds;
/** /**
* 父所有部门 * 父所有部门
*/ */
private String parentDeptNames; private String parentDeptNames;
/** /**
* 所有部门ID * 所有部门ID
*/ */
private String[] allDeptIds; private String allDeptIds;
private String allDeptIdsStr;
/** /**
* 所有部门名称 * 所有部门名称
*/ */
private String allDeptNames; private String allDeptNames;
/** /**
* 乐观锁 * 乐观锁
*/ */
private Integer revision; private Integer revision;
/** /**
* 删除标识 01 * 删除标识 01
*/ */
private String delFlag; private String delFlag;
/** /**
* 创建人 * 创建人
*/ */
private String createdBy; private String createdBy;
/** /**
* 创建时间 * 创建时间
*/ */
private Date createdTime; private Date createdTime;
/** /**
* 更新人 * 更新人
*/ */
private String updatedBy; private String updatedBy;
/** /**
* 更新时间 * 更新时间
*/ */
private Date updatedTime; private Date updatedTime;
///////////////////下面的字段,为pc页面上送数据的绑定字段/////////////////////////////////
/**
* 新增是选择所属网格多选
*/
private List<Long[]> selectedDeptIds;
} }

135
esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/service/impl/GridOperatorInfoServiceImpl.java

@ -17,6 +17,7 @@
package com.elink.esua.epdc.modules.consult.service.impl; package com.elink.esua.epdc.modules.consult.service.impl;
import cn.hutool.core.collection.CollUtil;
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.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
@ -36,6 +37,7 @@ import com.elink.esua.epdc.modules.consult.redis.GridOperatorInfoRedis;
import com.elink.esua.epdc.modules.consult.service.GridOperatorInfoService; import com.elink.esua.epdc.modules.consult.service.GridOperatorInfoService;
import com.elink.esua.epdc.modules.feign.AdminFeignClient; import com.elink.esua.epdc.modules.feign.AdminFeignClient;
import com.elink.esua.epdc.rocketmq.dto.OrganizationModifyDTO; import com.elink.esua.epdc.rocketmq.dto.OrganizationModifyDTO;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -89,55 +91,105 @@ public class GridOperatorInfoServiceImpl extends BaseServiceImpl<GridOperatorInf
@Override @Override
public GridOperatorInfoDTO get(String id) { public GridOperatorInfoDTO get(String id) {
GridOperatorInfoEntity entity = baseDao.selectById(id); GridOperatorInfoEntity entity = baseDao.selectById(id);
GridOperatorInfoDTO gridOperatorInfoDTO = ConvertUtils.sourceToTarget(entity, GridOperatorInfoDTO.class); return ConvertUtils.sourceToTarget(entity, GridOperatorInfoDTO.class);
if (StringUtils.isNotBlank(entity.getAllDeptIds())) {
String[] depts = entity.getAllDeptIds().split(",");
List<String> ids = Arrays.asList(depts);
String[] allDeptIds = new String[(ids.subList(1, ids.size())).size()];
gridOperatorInfoDTO.setAllDeptIds((ids.subList(1, ids.size())).toArray(allDeptIds));
}
return gridOperatorInfoDTO;
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void save(GridOperatorInfoDTO dto) { public void save(GridOperatorInfoDTO dto) {
List<Long> operatorGridIdList = getOperatorGridId(dto);
if (CollUtil.isEmpty(operatorGridIdList)) {
return;
}
GridOperatorInfoEntity entity = ConvertUtils.sourceToTarget(dto, GridOperatorInfoEntity.class); GridOperatorInfoEntity entity = ConvertUtils.sourceToTarget(dto, GridOperatorInfoEntity.class);
Result<ParentAndAllDeptDTO> parentResult = null; for (Long deptId : operatorGridIdList) {
if (dto.getAllDeptIds() != null && dto.getAllDeptIds().length > 1) { // 填充部门信息字段
parentResult = adminFeignClient.getParentAndAllDept(dto.getAllDeptIds()[dto.getAllDeptIds().length - 1]); this.fillDeptInfoByGridId(entity, deptId);
if (null == entity.getDeptId() || StringUtils.isBlank(entity.getAllDeptNames())) {
continue;
}
entity.setId(null);
baseDao.insert(entity);
}
}
/**
* 通过前端选择的部门id组装网格id集合
*
* @param selectedDeptIds
* @return java.util.List<java.lang.Long>
* @author work@yujt.net.cn
* @date 2020/3/12 10:30
*/
private List<Long> getOperatorGridId(List<Long[]> selectedDeptIds) {
if (CollUtil.isEmpty(selectedDeptIds)) {
throw new RenException("请选择网格人员所属部门");
} }
if (parentResult != null) { List<Long> operatorGridIdList = Lists.newArrayList();
if (!parentResult.success() || parentResult.getData() == null) { for (Long[] selectedDeptIdArray : selectedDeptIds) {
throw new RenException("获取部门信息失败"); if (selectedDeptIdArray.length == NumConstant.THREE) {
} else { operatorGridIdList.add(selectedDeptIdArray[NumConstant.TWO]);
ParentAndAllDeptDTO deptDTO = parentResult.getData();
entity.setAllDeptIds(deptDTO.getAllDeptIds());
entity.setAllDeptNames(deptDTO.getAllDeptNames());
entity.setParentDeptIds(deptDTO.getParentDeptIds());
entity.setParentDeptNames(deptDTO.getParentDeptNames());
entity.setDeptId(deptDTO.getGridId());
} }
} }
insert(entity); return operatorGridIdList;
} }
/**
* 获取需要进行绑定的网格id并移除已绑定的网格
*
* @param operatorInfo
* @return java.util.List<java.lang.Long>
* @author work@yujt.net.cn
* @date 2020/3/12 11:19
*/
private List<Long> getOperatorGridId(GridOperatorInfoDTO operatorInfo) {
List<Long> operatorGridIdList = getOperatorGridId(operatorInfo.getSelectedDeptIds());
if (CollUtil.isEmpty(operatorGridIdList)) {
throw new RenException("获取网格人员所属网格失败");
}
QueryWrapper<GridOperatorInfoEntity> wrapper = new QueryWrapper<>();
wrapper.eq("real_name", operatorInfo.getRealName())
.eq("mobile", operatorInfo.getMobile());
List<GridOperatorInfoEntity> entityList = baseDao.selectList(wrapper);
if (CollUtil.isNotEmpty(entityList)) {
for (GridOperatorInfoEntity operatorInfoEntity : entityList) {
Long deptId = operatorInfoEntity.getDeptId();
if (operatorGridIdList.contains(deptId)) {
operatorGridIdList.remove(deptId);
}
}
}
return operatorGridIdList;
}
/**
* 组装网格人员机构信息
*
* @param gridOperator 网格员对象
* @param gridId 网格id
* @return void
* @author work@yujt.net.cn
* @date 2020/3/12 13:37
*/
private void fillDeptInfoByGridId(GridOperatorInfoEntity gridOperator, Long gridId) {
Result<ParentAndAllDeptDTO> adminResult = adminFeignClient.getParentAndAllDept(String.valueOf(gridId));
if (!adminResult.success() || null == adminResult.getData()) {
return;
}
ParentAndAllDeptDTO deptInfo = adminResult.getData();
gridOperator.setAllDeptIds(deptInfo.getAllDeptIds());
gridOperator.setAllDeptNames(deptInfo.getAllDeptNames());
gridOperator.setParentDeptIds(deptInfo.getParentDeptIds());
gridOperator.setParentDeptNames(deptInfo.getParentDeptNames());
gridOperator.setDeptId(gridId);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void update(GridOperatorInfoDTO dto) { public void update(GridOperatorInfoDTO dto) {
GridOperatorInfoEntity entity = ConvertUtils.sourceToTarget(dto, GridOperatorInfoEntity.class); GridOperatorInfoEntity entity = ConvertUtils.sourceToTarget(dto, GridOperatorInfoEntity.class);
String[] allDeptIds = dto.getAllDeptIds();
Result<ParentAndAllDeptDTO> parentResult = adminFeignClient.getParentAndAllDept(String.valueOf(allDeptIds[allDeptIds.length - 1]));
if (!parentResult.success() || parentResult.getData() == null) {
throw new RenException("获取部门信息失败");
} else {
ParentAndAllDeptDTO deptDTO = parentResult.getData();
entity.setAllDeptIds(deptDTO.getAllDeptIds());
entity.setAllDeptNames(deptDTO.getAllDeptNames());
entity.setParentDeptIds(deptDTO.getParentDeptIds());
entity.setParentDeptNames(deptDTO.getParentDeptNames());
entity.setDeptId(deptDTO.getGridId());
}
updateById(entity); updateById(entity);
} }
@ -174,10 +226,10 @@ public class GridOperatorInfoServiceImpl extends BaseServiceImpl<GridOperatorInf
@Override @Override
public boolean isExistsByDutyId(String dutyCategoryId) { public boolean isExistsByDutyId(String dutyCategoryId) {
QueryWrapper queryWrapper= new QueryWrapper(); QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq(StringUtils.isNotBlank(dutyCategoryId),"DUTY_CATEGORY_ID",dutyCategoryId); queryWrapper.eq(StringUtils.isNotBlank(dutyCategoryId), "DUTY_CATEGORY_ID", dutyCategoryId);
Integer integer = baseDao.selectCount(queryWrapper); Integer integer = baseDao.selectCount(queryWrapper);
if(integer>0){ if (integer > 0) {
return true; return true;
} }
return false; return false;
@ -197,17 +249,16 @@ public class GridOperatorInfoServiceImpl extends BaseServiceImpl<GridOperatorInf
} }
/** /**
*
* 组织机构信息处理 * 组织机构信息处理
* *
* @params [dto, gridList]
* @return java.util.List<com.elink.esua.epdc.modules.consult.entity.GridOperatorInfoEntity> * @return java.util.List<com.elink.esua.epdc.modules.consult.entity.GridOperatorInfoEntity>
* @params [dto, gridList]
* @author liuchuang * @author liuchuang
* @since 2020/3/7 14:12 * @since 2020/3/7 14:12
*/ */
private List<GridOperatorInfoEntity> handleOrganizationInfo(OrganizationModifyDTO dto, List<GridOperatorInfoDTO> gridList) { private List<GridOperatorInfoEntity> handleOrganizationInfo(OrganizationModifyDTO dto, List<GridOperatorInfoDTO> gridList) {
List<GridOperatorInfoEntity> entities = new ArrayList<>(); List<GridOperatorInfoEntity> entities = new ArrayList<>();
for (GridOperatorInfoDTO grid: gridList) { for (GridOperatorInfoDTO grid : gridList) {
GridOperatorInfoEntity entity = new GridOperatorInfoEntity(); GridOperatorInfoEntity entity = new GridOperatorInfoEntity();
if (StringUtils.isNotEmpty(grid.getParentDeptIds()) && StringUtils.isNotEmpty(grid.getParentDeptNames())) { if (StringUtils.isNotEmpty(grid.getParentDeptIds()) && StringUtils.isNotEmpty(grid.getParentDeptNames())) {
List<String> parentDeptIds = Arrays.asList(grid.getParentDeptIds().split(",")); List<String> parentDeptIds = Arrays.asList(grid.getParentDeptIds().split(","));
@ -220,8 +271,8 @@ public class GridOperatorInfoServiceImpl extends BaseServiceImpl<GridOperatorInf
} }
} }
if (StringUtils.isNotEmpty(grid.getAllDeptIdsStr()) && StringUtils.isNotEmpty(grid.getAllDeptNames())) { if (StringUtils.isNotEmpty(grid.getAllDeptIds()) && StringUtils.isNotEmpty(grid.getAllDeptNames())) {
List<String> allDeptIds = Arrays.asList(grid.getAllDeptIdsStr().split(",")); List<String> allDeptIds = Arrays.asList(grid.getAllDeptIds().split(","));
List<String> allDeptNames = Arrays.asList(grid.getAllDeptNames().split("-")); List<String> allDeptNames = Arrays.asList(grid.getAllDeptNames().split("-"));
int index = allDeptIds.indexOf(dto.getDeptId().toString()); int index = allDeptIds.indexOf(dto.getDeptId().toString());
if (index >= 0 && allDeptNames.size() > index) { if (index >= 0 && allDeptNames.size() > index) {

Loading…
Cancel
Save