You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

633 lines
23 KiB

/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.controller;
import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.annotation.RequirePermission;
import com.epmet.commons.tools.enums.RequirePermissionEnum;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.RSASignature;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.*;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.excel.CustomerStaffExcel;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.send.SendMqMsgUtil;
import com.epmet.service.CustomerStaffService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 政府工作人员表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-18
*/
@RestController
@RequestMapping("customerstaff")
public class CustomerStaffController {
@Value("${epmet.login.privateKey}")
private String privateKey;
@Autowired
private CustomerStaffService customerStaffService;
@Autowired
private LoginUserUtil loginUserUtil;
@Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@GetMapping("page")
public Result<PageData<CustomerStaffDTO>> page(@RequestParam Map<String, Object> params) {
PageData<CustomerStaffDTO> page = customerStaffService.page(params);
return new Result<PageData<CustomerStaffDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<CustomerStaffDTO> get(@PathVariable("id") String id) {
CustomerStaffDTO data = customerStaffService.get(id);
return new Result<CustomerStaffDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody CustomerStaffDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
customerStaffService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody CustomerStaffDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
customerStaffService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids) {
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
customerStaffService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<CustomerStaffDTO> list = customerStaffService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, CustomerStaffExcel.class);
}
/**
* @param mobile 手机号
* @return com.epmet.commons.tools.utils.Result
* @Author yinzuomei
* @Description 根据手机号查询政府端工作人员基本信息,校验用户是否存在
* @Date 2020/4/18 14:07
**/
@GetMapping(value = "getcustsomerstaffbyphone/{mobile}")
public Result<List<CustomerStaffDTO>> getCustsomerStaffByPhone(@PathVariable("mobile") String mobile) {
return customerStaffService.getCustsomerStaffByPhone(mobile);
}
/**
* @param account 账户
* @return com.epmet.commons.tools.utils.Result
* @Author zhy
* @Description 根据账户查询政府端工作人员基本信息,校验用户是否存在
* @Date 2020/4/18 14:07
**/
@GetMapping(value = "getcustsomerstaffbyaccount/{account}")
public Result<List<CustomerStaffDTO>> getCustsomerStaffByAccount(@PathVariable("account") String account) {
return customerStaffService.getCustsomerStaffByAccount(account);
}
/**
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.CustomerStaffDTO>
* @Author yinzuomei
* @Description 根据手机号+客户id获取工作人员基本信息
* @Date 2020/4/20 14:04
**/
@PostMapping(value = "getcustomerstaffinfo")
public Result<CustomerStaffDTO> getCustomerStaffInfo(@RequestBody CustomerStaffFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, CustomerStaffFormDTO.GetCustomerStaffInfo.class);
return customerStaffService.getCustomerStaffInfo(formDTO);
}
/**
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.CustomerStaffDTO>
* @Author zhy
* @Description 根据账户+客户id获取工作人员基本信息
* @Date 2020/4/20 14:04
**/
@PostMapping(value = "getcustomerstaffinfobyaccount")
public Result<CustomerStaffDTO> getCustomerStaffInfoByAccount(@RequestBody CustomerStaffByAccountFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, CustomerStaffFormDTO.GetCustomerStaffInfo.class);
return customerStaffService.getCustomerStaffInfoByAccount(formDTO);
}
/**
* 根据userId查询网格下用户信息
* @param customerStaffGridDTOS
* @return
*/
@PostMapping(value = "selectstaffgridlistbyuserid")
public Result<List<StaffGridListDTO>> selectStaffGridListByUserId(@RequestBody List<UserIdAndPidDTO> customerStaffGridDTOS){
Result<List<StaffGridListDTO>> listResult = customerStaffService.selectStaffGridListByUserId(customerStaffGridDTOS);
return listResult;
}
/**
* 根据用户ID获取工作人员基本信息
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.CustomerStaffDTO>
* @author zhaoqifeng
* @date 2020/4/22 10:05
**/
@PostMapping(value = "getstaffinfobyuserid")
public Result<CustomerStaffDTO> getCustomerStaffInfoByUserId(@RequestBody CustomerStaffDTO formDTO) {
return customerStaffService.getCustomerStaffInfoByUserId(formDTO);
}
/**
* 组织首页-工作人员列表
* @param fromDTO
* @return
*/
@PostMapping("staffsinagency")
public Result<List<StaffInfoResultDTO>> getStaffInfoForHome(@RequestBody StaffsInAgencyFromDTO fromDTO) {
return customerStaffService.getStaffInfoForHome(fromDTO);
}
/**
* 工作人员列表
* @param fromDTO
* @return
*/
@PostMapping("stafflist")
public Result<List<StaffInfoResultDTO>> getStaffList(@RequestBody StaffsInAgencyFromDTO fromDTO) {
return customerStaffService.getStaffList(fromDTO);
}
/**
* 查询网格下未被禁用人员
* @param userIdDTO
* @auther zxc
*/
@PostMapping(value = "selectgridstaffcountbyuserid")
public Result<GridStaffCountDTO> selectGridStaffCountByUserId(@RequestBody List<UserIdDTO> userIdDTO){
return customerStaffService.selectGridStaffCountByUserId(userIdDTO);
}
/**
* 人员添加页面初始化
*
* @param fromDTO 参数
* @return Result<StaffInitResultDTO>
*/
@PostMapping("rolelist")
public Result<List<RoleInfoResultDTO>> 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){
Result<CustomerStaffDTO> result = customerStaffService.addStaff(fromDTO);
//2021-10-18 推送mq,数据同步到中介库 start
if (result.success()) {
OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg();
mq.setCustomerId(fromDTO.getCustomerId());
List<String> st = new ArrayList<>();
st.add(result.getData().getUserId());
mq.setStaffIdList(st);
mq.setOrgType("staff");
mq.setType("staff_create");
SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendOrgStaffMqMsg(mq);
}
//2021-10-18 end
return result;
}
/**
* 人员添加
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("addstaffaccount")
public Result<CustomerStaffDTO> addStaffByAccount(@RequestBody StaffSubmitAccountFromDTO fromDTO){
Result<CustomerStaffDTO> result = customerStaffService.addStaffByAccount(fromDTO);
//2021-10-18 推送mq,数据同步到中介库 start
if (result.success()) {
OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg();
mq.setCustomerId(fromDTO.getCustomerId());
mq.setOrgId(result.getData().getUserId());
mq.setOrgType("staff");
mq.setType("staff_create");
SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendOrgStaffMqMsg(mq);
}
//2021-10-18 end
return result;
}
/**
* 人员编辑
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("editstaff")
public Result editStaff(@RequestBody StaffSubmitFromDTO fromDTO){
Result result = customerStaffService.editStaff(fromDTO);
//2021-10-18 推送mq,数据同步到中介库 start
if (result.success()) {
OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg();
mq.setCustomerId(fromDTO.getCustomerId());
List<String> st = new ArrayList<>();
st.add(fromDTO.getStaffId());
mq.setStaffIdList(st);
mq.setOrgType("staff");
mq.setType("staff_change");
SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendOrgStaffMqMsg(mq);
}
//2021-10-18 end
return result;
}
/**
* 人员编辑
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("editstaffaccount")
public Result editStaffByAccount(@RequestBody StaffSubmitAccountFromDTO fromDTO){
Result result = customerStaffService.editStaffByAccount(fromDTO);
//2021-10-18 推送mq,数据同步到中介库 start
if (result.success()) {
OrgOrStaffMQMsg mq = new OrgOrStaffMQMsg();
mq.setCustomerId(fromDTO.getCustomerId());
mq.setOrgId(fromDTO.getStaffId());
mq.setOrgType("staff");
mq.setType("staff_change");
SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendOrgStaffMqMsg(mq);
}
//2021-10-18 end
return result;
}
/**
* 人员详情
*
* @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);
}
/**
* @param fromDTO
* @return
* @Author sun
* @Description 根据客户Id及userId集合查询用户基本信息
*/
@PostMapping("getdepartmentstafflist")
public Result<List<DepartInStaffListResultDTO>> getDepartmentStaffList(@RequestBody DepartmentInStaffFormDTO fromDTO) {
return customerStaffService.getDepartmentStaffList(fromDTO);
}
/**
* @Description 通过userId列表查询未被禁用的用户信息
* @Param CommonUserIdListFormDTO :: getUserIdList
* @return Result<List<CommonStaffInfoResultDTO>>
* @Author wangc
* @Date 2020.04.24 15:44
**/
@PostMapping(value = "enabestaffmsglist")
public Result<List<CommonStaffInfoResultDTO>> enableStaffMsgList(@RequestBody CommonUserIdListFormDTO userIdList){
ValidatorUtils.validateEntity(userIdList);
return customerStaffService.getEnableStaffMsgList(userIdList);
}
/**
* @param staffIdList
* @return
* @Author sun
* @Description 根据staffId集合查询工作人员基础信息
**/
@PostMapping(value = "getcustomerstafflist")
public Result<CustomerStaffListResultDTO> getCustomerStaffList(@RequestBody List<String> staffIdList){
return new Result<CustomerStaffListResultDTO>().ok(customerStaffService.getCustomerStaffList(staffIdList));
}
/**
* @param staffId
* @return
* @Author sun
* @Description 根据staffId查询工作人员基本信息
**/
@PostMapping(value = "getcustomerstaff/{staffId}")
public Result<CustomerStaffDTO> getCustomerStaff(@PathVariable("staffId") String staffId){
return new Result<CustomerStaffDTO>().ok(customerStaffService.getCustomerStaff(staffId));
}
/**
* @return com.epmet.commons.tools.utils.Result
* @param staffResetPwFormDTO
* @author yinzuomei
* @description 工作端,修改工作人员密码
* @Date 2020/7/1 10:39
**/
@PostMapping("resetstaffpassword")
public Result resetStaffPassword(@RequestBody StaffResetPwFormDTO staffResetPwFormDTO){
ValidatorUtils.validateEntity(staffResetPwFormDTO,StaffResetPwFormDTO.AddUserShowGroup.class,StaffResetPwFormDTO.AddUserInternalGroup.class);
customerStaffService.resetStaffPassword(staffResetPwFormDTO);
return new Result();
}
/**
* @Description 得到工组人员的头像、名称、所属机关名称
* @param userId
* @return
* @author wangc
* @date 2020.07.27 14:45
**/
@PostMapping("staffmsg")
public Result<StaffEtAgencyResultDTO> staffMsg(@RequestBody IssueInitiatorFormDTO userId){
ValidatorUtils.validateEntity(userId, IssueInitiatorFormDTO.UserIdGroup.class);
return new Result<StaffEtAgencyResultDTO>().ok(customerStaffService.getStaffMsg(userId));
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 根据客户ID、手机号查询政府端工作人员基本信息,校验用户是否存在
**/
@GetMapping(value = "getCustsomerStaffByIdAndPhone")
public Result<List<CustomerStaffDTO>> getCustsomerStaffByIdAndPhone(@RequestBody ThirdCustomerStaffFormDTO formDTO) {
return new Result<List<CustomerStaffDTO>>().ok(customerStaffService.getCustsomerStaffByIdAndPhone(formDTO));
}
/**
* @param formDTO
* @return
* @Author zhy
* @Description 根据客户ID、账户查询政府端工作人员基本信息,校验用户是否存在
**/
@GetMapping(value = "getCustsomerStaffByIdAndAccount")
public Result<List<CustomerStaffDTO>> getCustsomerStaffByIdAndAccount(@RequestBody ThirdCustomerStaffByAccountFormDTO formDTO) {
return new Result<List<CustomerStaffDTO>>().ok(customerStaffService.getCustsomerStaffByIdAndAccount(formDTO));
}
/**
* @Description 查询工作人员的信息
* @param formDTO
* @author zxc
* @date 2020/8/13 1:45 下午
*/
@PostMapping("getstaffinfolist")
public Result<List<StaffSinGridResultDTO>> getStaffInfoList(@RequestHeader("customerId") String customerId,@RequestBody UserIdsFormDTO formDTO){
formDTO.setCustomerId(customerId);
ValidatorUtils.validateEntity(formDTO);
return new Result<List<StaffSinGridResultDTO>>().ok(customerStaffService.getStaffInfoList(formDTO));
}
/**
* @Description 查找工作人员的信息 - 对外开放接口
* @param staffParam
* @return
* @author wangc
* @date 2020.08.17 10:30
**/
@PostMapping("extstaffinfo")
public Result<ExtStaffInfoResultDTO> extStaffInfo(@RequestBody CommonStaffIdFormDTO staffParam){
ValidatorUtils.validateEntity(staffParam, CommonStaffIdFormDTO.StaffIdGroup.class);
return new Result<ExtStaffInfoResultDTO>().ok(customerStaffService.extStaffInfo(staffParam));
}
/**
* 修改根管理员信息
* @author zhaoqifeng
* @date 2020/8/19 14:31
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
*/
@PostMapping("updaterootmanage")
public Result updateRootManage(@RequestBody UpdateRootManageFormDTO formDTO) {
customerStaffService.updateRootManage(formDTO);
return new Result();
}
/**
* 查询登陆用户客户列表(工作端)
* 根据手机号查询customer_staff表数据,在根据查询到的数据的userId判断是不是根管理员,最后将同一手机号对应的客户列表且该手机都是根管理员的客户列表返给前端
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.CustomerListResultDTO>>
* @Author zhangyong
* @Date 10:03 2020-08-25
**/
@PostMapping(value = "customerlist")
public Result<List<CustomerListResultDTO>> customerList(@RequestBody CustomerListFormDTO formDTO) throws Exception {
//解密密码
if (StringUtils.isNotBlank(formDTO.getPhone())&&formDTO.getPhone().length() > 50) {
String phone = RSASignature.decryptByPrivateKey(formDTO.getPhone(), privateKey);
formDTO.setPhone(phone);
}
return customerStaffService.selectCustomerList(formDTO);
}
/**
* 获取pc工作端登陆用户信息
* 根据token中userId,去查询登陆用户基本信息
* @param tokenDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.StaffBasicInfoResultDTO>
* @Author zhangyong
* @Date 11:09 2020-08-25
**/
@PostMapping(value = "staffbasicinfo")
public Result<StaffBasicInfoResultDTO> staffBasicInfo(@LoginUser TokenDto tokenDTO){
return customerStaffService.selectStaffBasicInfo(tokenDTO.getUserId(),tokenDTO.getCustomerId());
}
/**
* @param formDTO
* @return
* @Author sun
* @Description PC工作端登陆-根据客户Id和手机号查询登陆用户信息
**/
@PostMapping("getstaffidandpwd")
public Result<GovWebOperLoginResultDTO> getStaffIdAndPwd(@RequestBody GovWebOperLoginFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
return new Result<GovWebOperLoginResultDTO>().ok(customerStaffService.getStaffIdAndPwd(formDTO));
}
/**
* 根据staffId查询用户基本信息
* @author sun
*/
@PostMapping("getstaffbasicinfo")
public Result<BasicInfoResultDTO> getStaffBasicInfo(@RequestBody StaffBasicInfoFromDTO fromDTO){
return new Result<BasicInfoResultDTO>().ok(customerStaffService.getStaffBasicInfo(fromDTO));
}
/**
* @Description 通用列表查询。可以指定customerId,如果指定了,则使用指定的,如果未指定,则使用当前登录用户的customerId
* @return
* @author wxz
* @date 2021.06.08 10:54
*/
@PostMapping("list")
public Result<List<CustomerStaffDTO>> list(@RequestBody CustomerStaffFormDTO input) {
List<CustomerStaffDTO> staffs = customerStaffService.list(input.getCustomerId(), input.getRealName(), input.getMobile(), input.getUserIds());
return new Result<List<CustomerStaffDTO>>().ok(staffs);
}
/**
* 【通讯录】工作人员解禁
* @author sun
*/
@PostMapping("enablestaff")
@RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_ENABLE)
public Result enableStaff(@LoginUser TokenDto tokenDto, @RequestBody EnableStaffFormDTO fromDTO){
if (tokenDto.getUserId().equals(fromDTO.getStaffId())) {
throw new RenException("工作人员自己不能解禁自己");
}
customerStaffService.enableStaff(fromDTO);
return new Result();
}
/**
* @Author sun
* @Description 根据工作人员姓名批量查询基础信息数据
**/
@PostMapping(value = "getbyrealnames")
public Result<List<CustomerStaffDTO>> getByRealNames(@RequestBody GetByRealNamesFormDTO formDTO) {
return new Result<List<CustomerStaffDTO>>().ok(customerStaffService.getByRealNames(formDTO));
}
/**
* @Author sun
* @Description 【事件】网格员服务电话
**/
@PostMapping(value = "gridmobilelist")
public Result<List<GridMobileListResultDTO>> gridMobileList(@LoginUser TokenDto tokenDto, @RequestBody GridMobileListFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, GridMobileListFormDTO.Gridobile.class);
return new Result<List<GridMobileListResultDTO>>().ok(customerStaffService.gridMobileList(formDTO.getGridId(), tokenDto.getUserId()));
}
@PostMapping(value = "staffdetailinfo")
public Result<CustomerStaffDTO> staffDetailInfo(@RequestBody CustomerStaffFormDTO formDTO) {
return new Result<CustomerStaffDTO>().ok(customerStaffService.staffDetailInfo(formDTO));
}
@PostMapping("depttoaddstaff")
public Result<CustomerStaffDTO> dedittostaffeptToAddStaff(@RequestBody StaffSubmitFromDTO fromDTO){
Result<CustomerStaffDTO> result = customerStaffService.deptToAddStaff(fromDTO);
return result;
}
@PostMapping(value = "edittostaff")
public Result editToStaff(@RequestBody CustomerStaffDTO formDTO) {
customerStaffService.editToStaff(formDTO);
return new Result();
}
/**
* @Author sun
* @Description 网格工作人员数据上报-查询客户网格下有效工作人员信息数据
**/
@PostMapping(value = "customerstaff")
public Result<List<GridStaffUploadResultDTO>> customerStaff(@RequestBody GridStaffUploadtFormDTO formDTO) {
return new Result<List<GridStaffUploadResultDTO>>().ok(customerStaffService.customerStaff(formDTO));
}
/**
* Desc: 客户下所有工作人员放缓存
* @param customerId
* @author zxc
* @date 2022/10/19 14:07
*/
@PostMapping("allCustomerStaffInCache")
public Result allCustomerStaffInCache(@RequestParam("customerId")String customerId){
customerStaffService.allCustomerStaffInCache(customerId);
return new Result();
}
}