|
|
@ -31,13 +31,22 @@ import com.epmet.dto.*; |
|
|
|
import com.epmet.dto.form.CustomerGridFormDTO; |
|
|
|
import com.epmet.dto.CustomerStaffDTO; |
|
|
|
import com.epmet.dto.CustomerStaffGridDTO; |
|
|
|
import com.epmet.dto.GovStaffRoleDTO; |
|
|
|
import com.epmet.dto.StaffGridListDTO; |
|
|
|
import com.epmet.dto.form.CustomerStaffFormDTO; |
|
|
|
import com.epmet.dto.form.StaffInfoFromDTO; |
|
|
|
import com.epmet.dto.form.StaffSubmitFromDTO; |
|
|
|
import com.epmet.dto.form.StaffsInAgencyFromDTO; |
|
|
|
import com.epmet.dto.result.StaffDetailResultDTO; |
|
|
|
import com.epmet.dto.result.StaffInfoResultDTO; |
|
|
|
import com.epmet.dto.result.StaffInitResultDTO; |
|
|
|
import com.epmet.dto.result.StaffRoleResultDTO; |
|
|
|
import com.epmet.entity.CustomerStaffEntity; |
|
|
|
import com.epmet.entity.GovStaffRoleEntity; |
|
|
|
import com.epmet.redis.CustomerStaffRedis; |
|
|
|
import com.epmet.service.CustomerStaffService; |
|
|
|
import com.epmet.service.GovStaffRoleService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.logging.log4j.LogManager; |
|
|
|
import org.apache.logging.log4j.Logger; |
|
|
@ -48,6 +57,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 政府工作人员表 |
|
|
@ -55,108 +65,193 @@ import java.util.Map; |
|
|
|
* @author generator generator@elink-cn.com |
|
|
|
* @since v1.0.0 2020-04-18 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao, CustomerStaffEntity> implements CustomerStaffService { |
|
|
|
private Logger logger = LogManager.getLogger(getClass()); |
|
|
|
@Autowired |
|
|
|
private CustomerStaffRedis customerStaffRedis; |
|
|
|
private Logger logger = LogManager.getLogger(getClass()); |
|
|
|
@Autowired |
|
|
|
private CustomerStaffRedis customerStaffRedis; |
|
|
|
@Autowired |
|
|
|
private GovStaffRoleService govStaffRoleService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<CustomerStaffDTO> page(Map<String, Object> params) { |
|
|
|
IPage<CustomerStaffEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, CustomerStaffDTO.class); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public PageData<CustomerStaffDTO> page(Map<String, Object> params) { |
|
|
|
IPage<CustomerStaffEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, CustomerStaffDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CustomerStaffDTO> list(Map<String, Object> params) { |
|
|
|
List<CustomerStaffEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
|
@Override |
|
|
|
public List<CustomerStaffDTO> list(Map<String, Object> params) { |
|
|
|
List<CustomerStaffEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(entityList, CustomerStaffDTO.class); |
|
|
|
} |
|
|
|
return ConvertUtils.sourceToTarget(entityList, CustomerStaffDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<CustomerStaffEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
private QueryWrapper<CustomerStaffEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<CustomerStaffEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
QueryWrapper<CustomerStaffEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
|
|
|
|
return wrapper; |
|
|
|
} |
|
|
|
return wrapper; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public CustomerStaffDTO get(String id) { |
|
|
|
CustomerStaffEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, CustomerStaffDTO.class); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public CustomerStaffDTO get(String id) { |
|
|
|
CustomerStaffEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, CustomerStaffDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(CustomerStaffDTO dto) { |
|
|
|
CustomerStaffEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStaffEntity.class); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(CustomerStaffDTO dto) { |
|
|
|
CustomerStaffEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStaffEntity.class); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(CustomerStaffDTO dto) { |
|
|
|
CustomerStaffEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStaffEntity.class); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(CustomerStaffDTO dto) { |
|
|
|
CustomerStaffEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStaffEntity.class); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<List<CustomerStaffDTO>> getCustsomerStaffByPhone(String mobile) { |
|
|
|
//判断用户是否存在
|
|
|
|
List<CustomerStaffDTO> customerStaffDTOList = baseDao.selectListCustomerStaffDTO(mobile); |
|
|
|
if (null == customerStaffDTOList || customerStaffDTOList.size() == 0) { |
|
|
|
logger.error(String.format("根据手机号查询用户异常,手机号:[%s],code[%s],msg[%s]", mobile, EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getMsg())); |
|
|
|
return new Result().error(EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode()); |
|
|
|
} |
|
|
|
return new Result<List<CustomerStaffDTO>>().ok(customerStaffDTOList); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public Result<List<CustomerStaffDTO>> getCustsomerStaffByPhone(String mobile) { |
|
|
|
//判断用户是否存在
|
|
|
|
List<CustomerStaffDTO> customerStaffDTOList = baseDao.selectListCustomerStaffDTO(mobile); |
|
|
|
if (null == customerStaffDTOList || customerStaffDTOList.size() == 0) { |
|
|
|
logger.error(String.format("根据手机号查询用户异常,手机号:[%s],code[%s],msg[%s]", mobile, EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getMsg())); |
|
|
|
return new Result().error(EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode()); |
|
|
|
} |
|
|
|
return new Result<List<CustomerStaffDTO>>().ok(customerStaffDTOList); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<CustomerStaffDTO> getCustomerStaffInfo(CustomerStaffFormDTO formDTO) { |
|
|
|
CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(formDTO); |
|
|
|
if (null == customerStaffDTO) { |
|
|
|
logger.error(String.format("根据手机号查询用户异常,手机号:[%s],code[%s],msg[%s]", formDTO.getMobile(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getMsg())); |
|
|
|
return new Result().error(EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode()); |
|
|
|
} |
|
|
|
//判断用户是否已被禁用
|
|
|
|
if (null != customerStaffDTO && UserConstant.DISABLED.equals(customerStaffDTO.getEnableFlag())) { |
|
|
|
logger.error(String.format("根据手机号查询用户异常,手机号:[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getMobile(), formDTO.getCustomerId(), EpmetErrorCode.GOV_STAFF_DISABLED.getCode(), EpmetErrorCode.GOV_STAFF_DISABLED.getMsg())); |
|
|
|
return new Result().error(EpmetErrorCode.GOV_STAFF_DISABLED.getCode()); |
|
|
|
} |
|
|
|
return new Result<CustomerStaffDTO>().ok(customerStaffDTO); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public Result<CustomerStaffDTO> getCustomerStaffInfo(CustomerStaffFormDTO formDTO) { |
|
|
|
CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(formDTO); |
|
|
|
if (null == customerStaffDTO) { |
|
|
|
logger.error(String.format("根据手机号查询用户异常,手机号:[%s],code[%s],msg[%s]", formDTO.getMobile(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getMsg())); |
|
|
|
return new Result().error(EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode()); |
|
|
|
} |
|
|
|
//判断用户是否已被禁用
|
|
|
|
if (null != customerStaffDTO && UserConstant.DISABLED.equals(customerStaffDTO.getEnableFlag())) { |
|
|
|
logger.error(String.format("根据手机号查询用户异常,手机号:[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getMobile(), formDTO.getCustomerId(), EpmetErrorCode.GOV_STAFF_DISABLED.getCode(), EpmetErrorCode.GOV_STAFF_DISABLED.getMsg())); |
|
|
|
return new Result().error(EpmetErrorCode.GOV_STAFF_DISABLED.getCode()); |
|
|
|
} |
|
|
|
return new Result<CustomerStaffDTO>().ok(customerStaffDTO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<CustomerStaffDTO> getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) { |
|
|
|
CustomerStaffDTO customerStaffDTO = baseDao.selectStaffInfoByUserId(formDTO); |
|
|
|
return new Result<CustomerStaffDTO>().ok(customerStaffDTO); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public Result<CustomerStaffDTO> getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) { |
|
|
|
CustomerStaffDTO customerStaffDTO = baseDao.selectStaffInfoByUserId(formDTO); |
|
|
|
return new Result<CustomerStaffDTO>().ok(customerStaffDTO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<List<StaffGridListDTO>> selectStaffGridListByUserId(List<CustomerStaffGridDTO> customerStaffGridDTOS) { |
|
|
|
List<StaffGridListDTO> staffGridListDTOS = baseDao.selectStaffGridListByUserId(customerStaffGridDTOS); |
|
|
|
return new Result<List<StaffGridListDTO>>().ok(staffGridListDTOS); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public Result<List<StaffGridListDTO>> selectStaffGridListByUserId(List<CustomerStaffGridDTO> customerStaffGridDTOS) { |
|
|
|
List<StaffGridListDTO> staffGridListDTOS = baseDao.selectStaffGridListByUserId(customerStaffGridDTOS); |
|
|
|
return new Result<List<StaffGridListDTO>>().ok(staffGridListDTOS); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<List<StaffInfoResultDTO>> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { |
|
|
|
List<StaffInfoResultDTO> list = baseDao.selectCustomerStaffList(fromDTO); |
|
|
|
return new Result<List<StaffInfoResultDTO>>().ok(list); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public Result<List<StaffInfoResultDTO>> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { |
|
|
|
List<StaffInfoResultDTO> list = baseDao.selectCustomerStaffList(fromDTO); |
|
|
|
return new Result<List<StaffInfoResultDTO>>().ok(list); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<List<StaffInfoResultDTO>> getStaffList(StaffsInAgencyFromDTO fromDTO) { |
|
|
|
List<StaffInfoResultDTO> list = baseDao.selectStaffList(fromDTO); |
|
|
|
return new Result<List<StaffInfoResultDTO>>().ok(list); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<StaffInitResultDTO> addStaffInit(StaffInfoFromDTO fromDTO) { |
|
|
|
StaffInitResultDTO resultDTO = new StaffInitResultDTO(); |
|
|
|
GovStaffRoleDTO govStaffRoleDTO = new GovStaffRoleDTO(); |
|
|
|
govStaffRoleDTO.setCustomerId(fromDTO.getCustomerId()); |
|
|
|
List<GovStaffRoleDTO> roleList = govStaffRoleService.getGovStaffRoleList(govStaffRoleDTO); |
|
|
|
if (null == roleList || roleList.size() == 0) { |
|
|
|
return new Result<StaffInitResultDTO>().ok(null); |
|
|
|
} |
|
|
|
List<StaffRoleResultDTO> staffRoleList = roleList.stream().map(p -> { |
|
|
|
StaffRoleResultDTO staffRoleResultDTO = new StaffRoleResultDTO(); |
|
|
|
staffRoleResultDTO.setRoleId(p.getId()); |
|
|
|
staffRoleResultDTO.setRoleName(p.getRoleName()); |
|
|
|
return staffRoleResultDTO; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
resultDTO.setRoleList(staffRoleList); |
|
|
|
return new Result<StaffInitResultDTO>().ok(resultDTO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<StaffInitResultDTO> editStaffInit(StaffInfoFromDTO fromDTO) { |
|
|
|
StaffInitResultDTO resultDTO = new StaffInitResultDTO(); |
|
|
|
//获取工作人员信息
|
|
|
|
CustomerStaffDTO customerStaffDTO = baseDao.selectStaffInfo(fromDTO); |
|
|
|
if (null == customerStaffDTO) { |
|
|
|
log.error("工作人员不存在"); |
|
|
|
} |
|
|
|
resultDTO.setStaffId(customerStaffDTO.getUserId()); |
|
|
|
resultDTO.setName(customerStaffDTO.getRealName()); |
|
|
|
resultDTO.setGender(customerStaffDTO.getGender()); |
|
|
|
resultDTO.setMobile(customerStaffDTO.getMobile()); |
|
|
|
resultDTO.setWorkType(customerStaffDTO.getWorkType()); |
|
|
|
//获取角色列表
|
|
|
|
GovStaffRoleDTO govStaffRoleDTO = new GovStaffRoleDTO(); |
|
|
|
govStaffRoleDTO.setCustomerId(fromDTO.getCustomerId()); |
|
|
|
List<GovStaffRoleDTO> roleList = govStaffRoleService.getGovStaffRoleList(govStaffRoleDTO); |
|
|
|
//获取工作人员角色
|
|
|
|
List<GovStaffRoleEntity> staffRoles = govStaffRoleService.listRolesByStaffId(fromDTO.getStaffId(), fromDTO.getAgencyId()); |
|
|
|
List<StaffRoleResultDTO> staffRoleList = roleList.stream().map(p -> { |
|
|
|
StaffRoleResultDTO staffRoleResultDTO = new StaffRoleResultDTO(); |
|
|
|
staffRoleResultDTO.setRoleId(p.getId()); |
|
|
|
staffRoleResultDTO.setRoleName(p.getRoleName()); |
|
|
|
staffRoleResultDTO.setSelected(false); |
|
|
|
return staffRoleResultDTO; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
staffRoleList.forEach(role -> staffRoles.forEach(staffRole -> { |
|
|
|
if (role.getRoleId().equals(staffRole.getId())) { |
|
|
|
role.setSelected(true); |
|
|
|
} |
|
|
|
})); |
|
|
|
resultDTO.setRoleList(staffRoleList); |
|
|
|
|
|
|
|
return new Result<StaffInitResultDTO>().ok(resultDTO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result addStaff(StaffSubmitFromDTO fromDTO) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result editStaff(StaffSubmitFromDTO fromDTO) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<StaffDetailResultDTO> getStaffDetail(StaffInfoFromDTO fromDTO) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result disabledStaff(StaffInfoFromDTO fromDTO) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据userId查询网格下未被禁用的人员数量 |
|
|
|