Browse Source

组织-工作人员相关接口 bug修改

dev_shibei_match
zhaoqifeng 5 years ago
parent
commit
63e16b80d9
  1. 6
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 4
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitFromDTO.java
  3. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
  4. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java
  5. 56
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java
  6. 70
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java
  7. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java
  8. 64
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
  9. 38
      epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml

6
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -34,8 +34,10 @@ public enum EpmetErrorCode {
REQUIRE_PERMISSION(8301, "没有足够的操作权限"),
NOT_ADD_GRID(8401,"您当前的网格名称已存在,请重新修改");
NOT_ADD_GRID(8401,"您当前的网格名称已存在,请重新修改"),
MOBILE_USED(8402,"该手机号已注册"),
STAFF_ADD_FAILED(8403,"人员添加失败"),
STAFF_EDIT_FAILED(8404,"人员编辑失败");
private int code;
private String msg;

4
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitFromDTO.java

@ -16,6 +16,10 @@ import java.util.List;
@Data
public class StaffSubmitFromDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 机关ID
*/

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java

@ -96,7 +96,7 @@ public interface EpmetUserFeignClient {
* @return Result
*/
@PostMapping("/epmetuser/customerstaff/addstaff")
Result addStaff(@RequestBody StaffSubmitFromDTO fromDTO);
Result<CustomerStaffDTO> addStaff(@RequestBody StaffSubmitFromDTO fromDTO);
/**
* 人员编辑

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

@ -68,7 +68,7 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient {
}
@Override
public Result addStaff(StaffSubmitFromDTO fromDTO) {
public Result<CustomerStaffDTO> addStaff(StaffSubmitFromDTO fromDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "addStaff", fromDTO);
}

56
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java

@ -1,8 +1,10 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerStaffAgencyDTO;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.form.StaffInfoFromDTO;
import com.epmet.dto.form.StaffSubmitFromDTO;
import com.epmet.dto.form.StaffsInAgencyFromDTO;
@ -11,6 +13,7 @@ import com.epmet.dto.result.StaffInfoResultDTO;
import com.epmet.dto.result.StaffInitResultDTO;
import com.epmet.dto.result.StaffsInAgencyResultDTO;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.entity.CustomerStaffAgencyEntity;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.OperCrmFeignClient;
import com.epmet.service.CustomerAgencyService;
@ -18,7 +21,9 @@ import com.epmet.service.CustomerStaffAgencyService;
import com.epmet.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -43,11 +48,17 @@ public class StaffServiceImpl implements StaffService {
StaffsInAgencyResultDTO resultDTO = new StaffsInAgencyResultDTO();
//获取机关所在客户ID和人员总数
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId());
if (null == customerAgencyEntity) {
resultDTO.setStaffList(new ArrayList<>());
resultDTO.setStaffCount(0);
return new Result<StaffsInAgencyResultDTO>().ok(resultDTO);
}
resultDTO.setStaffCount(customerAgencyEntity.getTotalUser());
fromDTO.setCustomerId(customerAgencyEntity.getCustomerId());
List<CustomerStaffAgencyDTO> customerStaffAgencyList = customerStaffAgencyService.getCustomerStaffAgencyList(fromDTO).getData();
if (null == customerStaffAgencyList || customerStaffAgencyList.size() == 0) {
return new Result<StaffsInAgencyResultDTO>().ok(null);
resultDTO.setStaffList(new ArrayList<>());
return new Result<StaffsInAgencyResultDTO>().ok(resultDTO);
}
//提取所有userID
List<String> staffIds = customerStaffAgencyList.stream().map(CustomerStaffAgencyDTO::getUserId).collect(Collectors.toList());
@ -62,6 +73,9 @@ public class StaffServiceImpl implements StaffService {
public Result<List<StaffInfoResultDTO>> getStaffList(StaffsInAgencyFromDTO fromDTO) {
//获取机关所在客户ID
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId());
if (null == customerAgencyEntity) {
return new Result<List<StaffInfoResultDTO>>().ok(new ArrayList<>());
}
fromDTO.setCustomerId(customerAgencyEntity.getCustomerId());
List<CustomerStaffAgencyDTO> customerStaffAgencyList = customerStaffAgencyService.getCustomerStaffAgencyList(fromDTO).getData();
if (null == customerStaffAgencyList || customerStaffAgencyList.size() == 0) {
@ -71,8 +85,7 @@ public class StaffServiceImpl implements StaffService {
List<String> staffIds = customerStaffAgencyList.stream().map(CustomerStaffAgencyDTO::getUserId).collect(Collectors.toList());
fromDTO.setStaffList(staffIds);
//获取用户列表
Result<List<StaffInfoResultDTO>> staffInfoListResult = epmetUserFeignClient.getStaffInfoForHome(fromDTO);
return null;
return epmetUserFeignClient.getStaffList(fromDTO);
}
@Override
@ -90,24 +103,47 @@ public class StaffServiceImpl implements StaffService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result addStaff(TokenDto tokenDto, StaffSubmitFromDTO fromDTO) {
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId());
fromDTO.setApp(tokenDto.getApp());
fromDTO.setClient(tokenDto.getClient());
Result result = epmetUserFeignClient.addStaff(fromDTO);
//机关总人数加一
if (result.success()) {
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId());
customerAgencyEntity.setTotalUser(customerAgencyEntity.getTotalUser() + 1);
customerAgencyService.updateById(customerAgencyEntity);
fromDTO.setCustomerId(customerAgencyEntity.getCustomerId());
Result<CustomerStaffDTO> result = epmetUserFeignClient.addStaff(fromDTO);
if (!result.success()) {
if (result.getCode() != EpmetErrorCode.SERVER_ERROR.getCode()) {
return new Result().error(result.getCode(), result.getMsg());
}
return new Result().error(EpmetErrorCode.STAFF_ADD_FAILED.getCode(), EpmetErrorCode.STAFF_ADD_FAILED.getMsg());
}
//人员机关关系表
CustomerStaffAgencyEntity customerStaffAgencyEntity = new CustomerStaffAgencyEntity();
customerStaffAgencyEntity.setCustomerId(customerAgencyEntity.getCustomerId());
customerStaffAgencyEntity.setUserId(result.getData().getUserId());
customerStaffAgencyEntity.setAgencyId(customerAgencyEntity.getId());
customerStaffAgencyService.insert(customerStaffAgencyEntity);
//机关总人数加一
customerAgencyEntity.setTotalUser(customerAgencyEntity.getTotalUser() + 1);
customerAgencyService.updateById(customerAgencyEntity);
return new Result();
}
@Override
public Result editStaff(TokenDto tokenDto, StaffSubmitFromDTO fromDTO) {
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId());
fromDTO.setCustomerId(customerAgencyEntity.getCustomerId());
fromDTO.setApp(tokenDto.getApp());
fromDTO.setClient(tokenDto.getClient());
return epmetUserFeignClient.editStaff(fromDTO);
Result result = epmetUserFeignClient.editStaff(fromDTO);
if (!result.success()) {
if (result.getCode() != EpmetErrorCode.SERVER_ERROR.getCode()) {
return new Result().error(result.getCode(), result.getMsg());
}
return new Result().error(EpmetErrorCode.STAFF_EDIT_FAILED.getCode(), EpmetErrorCode.STAFF_EDIT_FAILED.getMsg());
}
return result;
}
@Override

70
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java

@ -155,7 +155,7 @@ public class CustomerStaffController {
* @return
*/
@PostMapping("staffsinagency")
public Result<List<StaffInfoResultDTO>> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) {
public Result<List<StaffInfoResultDTO>> getStaffInfoForHome(@RequestBody StaffsInAgencyFromDTO fromDTO) {
return customerStaffService.getStaffInfoForHome(fromDTO);
}
@ -165,7 +165,7 @@ public class CustomerStaffController {
* @return
*/
@PostMapping("stafflist")
public Result<List<StaffInfoResultDTO>> getStaffList(StaffsInAgencyFromDTO fromDTO) {
public Result<List<StaffInfoResultDTO>> getStaffList(@RequestBody StaffsInAgencyFromDTO fromDTO) {
return customerStaffService.getStaffList(fromDTO);
}
@ -194,4 +194,70 @@ public class CustomerStaffController {
public Result<List<CustomerIdDTO>> selectCustomerIdByUserId(@RequestBody AddDepartmentStaffFormDTO addDepartmentStaffFormDTO){
return customerStaffService.selectCustomerIdByUserId(addDepartmentStaffFormDTO);
}
/**
* 人员添加页面初始化
*
* @param fromDTO 参数
* @return Result<StaffInitResultDTO>
*/
@PostMapping("rolelist")
public Result<StaffInitResultDTO> addStaffInit(@RequestBody StaffInfoFromDTO fromDTO){
return customerStaffService.addStaffInit(fromDTO);
}
/**
* 人员编辑页面初始化
*
* @param fromDTO 参数
* @return Result<StaffInitResultDTO>
*/
@PostMapping("editstaffinit")
public Result<StaffInitResultDTO> editStaffInit(@RequestBody StaffInfoFromDTO fromDTO){
return customerStaffService.editStaffInit(fromDTO);
}
/**
* 人员添加
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("addstaff")
public Result<CustomerStaffDTO> addStaff(@RequestBody StaffSubmitFromDTO fromDTO){
return customerStaffService.addStaff(fromDTO);
}
/**
* 人员编辑
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("editstaff")
public Result editStaff(@RequestBody StaffSubmitFromDTO fromDTO){
return customerStaffService.editStaff(fromDTO);
}
/**
* 人员详情
*
* @param fromDTO 参数
* @return Result<StaffDetailResultDTO>
*/
@PostMapping("staffdetail")
public Result<StaffDetailResultDTO> getStaffDetail(@RequestBody StaffInfoFromDTO fromDTO){
return customerStaffService.getStaffDetail(fromDTO);
}
/**
* 人员禁用
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("disabledstaff")
public Result disabledStaff(@RequestBody StaffInfoFromDTO fromDTO){
return customerStaffService.disabledStaff(fromDTO);
}
}

2
epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java

@ -173,7 +173,7 @@ public interface CustomerStaffService extends BaseService<CustomerStaffEntity> {
* @param fromDTO 参数
* @return Result
*/
Result addStaff(StaffSubmitFromDTO fromDTO);
Result<CustomerStaffDTO> addStaff(StaffSubmitFromDTO fromDTO);
/**
* 人员编辑

64
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

@ -61,6 +61,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -84,6 +85,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
private UserService userService;
@Autowired
private StaffRoleService staffRoleService;
@Override
public PageData<CustomerStaffDTO> page(Map<String, Object> params) {
IPage<CustomerStaffEntity> page = baseDao.selectPage(
@ -178,12 +180,18 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
@Override
public Result<List<StaffInfoResultDTO>> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) {
List<StaffInfoResultDTO> list = baseDao.selectCustomerStaffList(fromDTO);
if (null == list) {
list = new ArrayList<>();
}
return new Result<List<StaffInfoResultDTO>>().ok(list);
}
@Override
public Result<List<StaffInfoResultDTO>> getStaffList(StaffsInAgencyFromDTO fromDTO) {
List<StaffInfoResultDTO> list = baseDao.selectStaffList(fromDTO);
if (null == list) {
list = new ArrayList<>();
}
return new Result<List<StaffInfoResultDTO>>().ok(list);
}
@ -194,7 +202,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
govStaffRoleDTO.setCustomerId(fromDTO.getCustomerId());
List<GovStaffRoleDTO> roleList = govStaffRoleService.getGovStaffRoleList(govStaffRoleDTO);
if (null == roleList || roleList.size() == 0) {
return new Result<StaffInitResultDTO>().ok(null);
return new Result<StaffInitResultDTO>().error(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
}
List<StaffRoleResultDTO> staffRoleList = roleList.stream().map(p -> {
StaffRoleResultDTO staffRoleResultDTO = new StaffRoleResultDTO();
@ -245,7 +253,14 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
@Override
@Transactional(rollbackFor = Exception.class)
public Result addStaff(StaffSubmitFromDTO fromDTO) {
public Result<CustomerStaffDTO> addStaff(StaffSubmitFromDTO fromDTO) {
CustomerStaffFormDTO customerStaffFormDTO = new CustomerStaffFormDTO();
customerStaffFormDTO.setCustomerId(fromDTO.getCustomerId());
customerStaffFormDTO.setMobile(fromDTO.getMobile());
CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(customerStaffFormDTO);
if (null != customerStaffDTO) {
return new Result<CustomerStaffDTO>().error(EpmetErrorCode.MOBILE_USED.getCode(), EpmetErrorCode.MOBILE_USED.getMsg());
}
//USER表插入数据
UserEntity userEntity = new UserEntity();
userEntity.setFromApp(fromDTO.getApp());
@ -253,6 +268,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
userService.insert(userEntity);
//Customer_Staff表插入数据
CustomerStaffEntity staffEntity = new CustomerStaffEntity();
staffEntity.setCustomerId(fromDTO.getCustomerId());
staffEntity.setUserId(userEntity.getId());
staffEntity.setRealName(fromDTO.getName());
staffEntity.setMobile(fromDTO.getMobile());
@ -271,12 +287,20 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
staffRoleService.insert(staffRoleEntity);
});
return new Result();
return new Result<CustomerStaffDTO>().ok(ConvertUtils.sourceToTarget(staffEntity, CustomerStaffDTO.class));
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result editStaff(StaffSubmitFromDTO fromDTO) {
CustomerStaffFormDTO customerStaffFormDTO = new CustomerStaffFormDTO();
customerStaffFormDTO.setCustomerId(fromDTO.getCustomerId());
customerStaffFormDTO.setMobile(fromDTO.getMobile());
CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(customerStaffFormDTO);
if (!fromDTO.getStaffId().equals(customerStaffDTO.getUserId())) {
return new Result<CustomerStaffDTO>().error(EpmetErrorCode.MOBILE_USED.getCode(), EpmetErrorCode.MOBILE_USED.getMsg());
}
CustomerStaffEntity customerStaffEntity = baseDao.selectByUserId(fromDTO.getStaffId());
//Customer_Staff表插入数据
CustomerStaffEntity staffEntity = new CustomerStaffEntity();
@ -334,18 +358,19 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
return new Result();
}
/**
* 根据userId查询网格下未被禁用的人员数量
* @param userIdDTO
* @return
*/
@Override
public Result<GridStaffCountDTO> selectGridStaffCountByUserId(List<UserIdDTO> userIdDTO) {
Result<GridStaffCountDTO> gridStaffCountDTOResult = new Result<GridStaffCountDTO>();
GridStaffCountDTO gridStaffCountDTO = baseDao.selectGridStaffCountByUserId(userIdDTO);
gridStaffCountDTOResult.setData(gridStaffCountDTO);
return gridStaffCountDTOResult;
}
/**
* 根据userId查询网格下未被禁用的人员数量
*
* @param userIdDTO
* @return
*/
@Override
public Result<GridStaffCountDTO> selectGridStaffCountByUserId(List<UserIdDTO> userIdDTO) {
Result<GridStaffCountDTO> gridStaffCountDTOResult = new Result<GridStaffCountDTO>();
GridStaffCountDTO gridStaffCountDTO = baseDao.selectGridStaffCountByUserId(userIdDTO);
gridStaffCountDTOResult.setData(gridStaffCountDTO);
return gridStaffCountDTOResult;
}
@Override
public Result<List<DepartInStaffListResultDTO>> getDepartmentStaffList(DepartmentInStaffFormDTO formDTO) {
@ -364,11 +389,10 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
return new Result<List<DepartInStaffListResultDTO>>().ok(staffList);
}
/**
*
* @param: addDepartmentStaffFormDTO
* @auther: zxc
*/
/**
* @param: addDepartmentStaffFormDTO
* @auther: zxc
*/
@Override
public Result<List<CustomerIdDTO>> selectCustomerIdByUserId(AddDepartmentStaffFormDTO addDepartmentStaffFormDTO) {
return new Result<List<CustomerIdDTO>>().ok(baseDao.selectCustomerIdByUserId(addDepartmentStaffFormDTO));

38
epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml

@ -59,29 +59,39 @@
</select>
<select id="selectCustomerStaffList" resultType="com.epmet.dto.result.StaffInfoResultDTO" parameterType="com.epmet.dto.form.StaffsInAgencyFromDTO">
SELECT
cs.USER_ID AS "staffId",
cs.REAL_NAME AS "staffName",
cs.GENDER AS "gender",
IFNULL(cs.HEAD_PHOTO, "") AS "staffHeadPhoto",
cs.ENABLE_FLAG AS "enableFlag",
gsr.ROLE_NAME AS "roleName"
cs.USER_ID AS "staffId",
cs.REAL_NAME AS "staffName",
cs.GENDER AS "gender",
IFNULL( cs.HEAD_PHOTO, "" ) AS "staffHeadPhoto",
cs.ENABLE_FLAG AS "enableFlag",
role.ROLE_NAME AS "roleName"
FROM
customer_staff cs
LEFT JOIN staff_role sr ON cs.USER_ID = sr.STAFF_ID
AND sr.DEL_FLAG = '0'
AND sr.ORG_ID = #{agencyId}
customer_staff cs
LEFT JOIN (
SELECT
sr.STAFF_ID,
sr.ROLE_ID,
gsr.ROLE_NAME
FROM
staff_role sr
LEFT JOIN gov_staff_role gsr ON sr.ROLE_ID = gsr.ID
AND gsr.DEL_FLAG = '0'
AND gsr.CUSTOMER_ID = #{customerId}
WHERE
sr.DEL_FLAG = '0'
AND sr.ORG_ID = #{agencyId}
AND gsr.ROLE_KEY = 'agency_leader'
) role ON cs.USER_ID = role.STAFF_ID
WHERE
cs.DEL_FLAG = '0'
cs.DEL_FLAG = '0'
AND cs.CUSTOMER_ID = #{customerId}
AND cs.USER_ID in
AND cs.USER_ID IN
<foreach item="userId" collection="staffList" separator="," open="(" close=")" index="">
#{userId}
</foreach>
ORDER BY gsr.ROLE_NAME DESC, cs.CREATED_TIME DESC
ORDER BY
role.ROLE_NAME DESC,
cs.CREATED_TIME DESC
LIMIT 12
</select>
@ -111,7 +121,7 @@
<foreach item="userId" collection="staffList" separator="," open="(" close=")" index="">
#{userId}
</foreach>
ORDER BY convert(cs.REAL_NAME using gbk) asc ASC
ORDER BY convert(cs.REAL_NAME using gbk) ASC
</select>
<select id="selectStaffInfo" resultType="com.epmet.dto.CustomerStaffDTO" parameterType="com.epmet.dto.form.StaffInfoFromDTO">
SELECT

Loading…
Cancel
Save