Browse Source

新增工作人员V2

dev_shibei_match
sunyuchao 4 years ago
parent
commit
afe15fef3e
  1. 32
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddStaffV2FromDTO.java
  2. 91
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/OrgResultDTO.java
  3. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java
  4. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  5. 69
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java
  6. 63
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

32
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddStaffV2FromDTO.java

@ -1,5 +1,6 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
@ -19,44 +20,49 @@ import java.util.List;
public class AddStaffV2FromDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 客户ID
* 新增人员所属类型Id
*/
private String customerId;
private String orgId;
/**
* 机关ID
* 客户ID
*/
private String agencyId;
private String customerId;
/**
* 人员ID
* 新增人员所属类型组织:agency;部门:dept;网格:grid
*/
private String staffId;
private String orgType;
/**
* 姓名
*/
@NotBlank(message = "姓名不能为空")
@Length(max = 15, message = "姓名仅允许输入15个字符")
@NotBlank(message = "姓名不能为空", groups = AddStaffV2FromDTO.AddStaff.class)
@Length(max = 15, message = "姓名仅允许输入15个字符", groups = AddStaffV2FromDTO.AddStaff.class)
private String name;
/**
* 人员ID
*/
private String staffId;
/**
* 手机
*/
@NotBlank(message = "手机号不能为空")
@Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "请输入正确的手机号")
@NotBlank(message = "手机号不能为空", groups = AddStaffV2FromDTO.AddStaff.class)
@Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "请输入正确的手机号", groups = AddStaffV2FromDTO.AddStaff.class)
private String mobile;
/**
* 性别
*/
@NotNull(message = "性别不能为空")
@NotNull(message = "性别不能为空", groups = AddStaffV2FromDTO.AddStaff.class)
private Integer gender;
/**
* 专兼职
*/
@NotBlank(message = "专兼职不能为空")
@NotBlank(message = "专兼职不能为空", groups = AddStaffV2FromDTO.AddStaff.class)
private String workType;
/**
* 角色id列表
*/
@NotNull(message = "角色不能为空")
@NotNull(message = "角色不能为空", groups = AddStaffV2FromDTO.AddStaff.class)
private List<String> roles;
public interface AddStaff extends CustomerClientShowGroup {}
/**
* 来源app(政府端:gov居民端:resi运营端:oper)
*/

91
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/OrgResultDTO.java

@ -0,0 +1,91 @@
/**
* 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.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* 按类型查询对应机关信息
*/
@Data
public class OrgResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关Id
*/
private String agencyId;
/**
* 客户ID
*/
private String customerId;
/**
* 上级组织机构ID
*/
private String pid;
/**
* 所有上级组织机构ID(以英文:隔开)
*/
private String pids;
/**
* 所有上级名称,-连接
*/
private String allParentName;
/**
* 组织名称
*/
private String organizationName;
/**
* 机关级别社区级community
街道:street,
区县级: district,
市级: city
省级:province 机关级别社区级community街道:street,区县级: district,市级: city省级:province
*/
private String level;
/**
* 地区编码
*/
private String areaCode;
/**
* 总人数
*/
private Integer totalUser = 0;
/**
* 部门总人数
*/
private Integer DeptTotalUser = 0;
/**
* 网格总人数
*/
private Integer gridTotalUser = 0;
}

9
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java

@ -172,10 +172,11 @@ public class StaffController {
*/
@PostMapping("addstaffv2")
@RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_CREATE)
public Result addStaffV2(@RequestBody AddStaffV2FromDTO fromDTO){
fromDTO.setApp("gov");
fromDTO.setClient("wxmp");
ValidatorUtils.validateEntity(fromDTO);
public Result addStaffV2(@LoginUser TokenDto tokenDto, @RequestBody AddStaffV2FromDTO fromDTO){
ValidatorUtils.validateEntity(fromDTO, AddStaffV2FromDTO.AddStaff.class);
fromDTO.setCustomerId(tokenDto.getCustomerId());
fromDTO.setApp(tokenDto.getApp());
fromDTO.setClient(tokenDto.getClient());
return staffService.addStaffV2(fromDTO);
}

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java

@ -233,4 +233,10 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
@Param("customerId") String customerId,
@Param("agencyId") String agencyId,
@Param("parentAgencyId") String parentAgencyId);
/**
* 根据新增人员类型判断查询机关信息
* @author sun
*/
OrgResultDTO selectAgencyDetail(@Param("orgId") String orgId, @Param("orgType") String orgType);
}

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

@ -6,16 +6,20 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.CustomerAgencyConstant;
import com.epmet.dao.CustomerAgencyDao;
import com.epmet.dao.CustomerStaffAgencyDao;
import com.epmet.dto.*;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.entity.CustomerStaffAgencyEntity;
import com.epmet.entity.*;
import com.epmet.feign.*;
import com.epmet.service.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -31,6 +35,7 @@ import java.util.stream.Collectors;
*/
@Service
public class StaffServiceImpl implements StaffService {
private static final Logger logger = LoggerFactory.getLogger(StaffServiceImpl.class);
@Autowired
private EpmetUserFeignClient epmetUserFeignClient;
@Autowired
@ -55,6 +60,12 @@ public class StaffServiceImpl implements StaffService {
private RedisUtils redisUtils;
@Autowired
private CustomerStaffAgencyDao customerStaffAgencyDao;
@Autowired
private com.epmet.dao.CustomerAgencyDao customerAgencyDao;
@Autowired
private CustomerStaffDepartmentService customerStaffDepartmentService;
@Autowired
private CustomerStaffGridService customerStaffGridService;
@Override
public Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) {
@ -309,8 +320,62 @@ public class StaffServiceImpl implements StaffService {
@Override
@Transactional(rollbackFor = Exception.class)
public Result addStaffV2(AddStaffV2FromDTO fromDTO) {
//1.根据新增人员类型判断查询机关信息
OrgResultDTO orgDTO = customerAgencyDao.selectAgencyDetail(fromDTO.getOrgId(), fromDTO.getOrgType());
if (null == orgDTO) {
logger.error(String.format("工作人员新增,根据新增人员组织类型未查询到相关组织信息,orgId->%s,orgType->%s", fromDTO.getOrgId(), fromDTO.getOrgType()));
throw new RenException("根据新增人员组织类型未查询到相关组织信息");
}
//2.调用user服务,新增用户信息
StaffSubmitFromDTO submitDTO = ConvertUtils.sourceToTarget(fromDTO, StaffSubmitFromDTO.class);
Result<CustomerStaffDTO> result = epmetUserFeignClient.addStaff(submitDTO);
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());
}
//3.人员机关表总人数加一、关系表新增关系数据
//人员机关关系表
CustomerStaffAgencyEntity customerStaffAgencyEntity = new CustomerStaffAgencyEntity();
customerStaffAgencyEntity.setCustomerId(fromDTO.getCustomerId());
customerStaffAgencyEntity.setUserId(result.getData().getUserId());
customerStaffAgencyEntity.setAgencyId(orgDTO.getAgencyId());
customerStaffAgencyService.insert(customerStaffAgencyEntity);
//机关总人数加一
CustomerAgencyEntity agencyEntity = new CustomerAgencyEntity();
agencyEntity.setId(orgDTO.getAgencyId());
agencyEntity.setTotalUser(orgDTO.getTotalUser() + 1);
customerAgencyService.updateById(agencyEntity);
//4.部门、网格主表、关系表修改、新增数据
if ("dept".equals(fromDTO.getOrgType())) {
CustomerStaffDepartmentEntity dept = new CustomerStaffDepartmentEntity();
dept.setCustomerId(fromDTO.getCustomerId());
dept.setUserId(result.getData().getUserId());
dept.setDepartmentId(fromDTO.getOrgId());
customerStaffDepartmentService.insert(dept);
CustomerDepartmentEntity departmentEntity = new CustomerDepartmentEntity();
departmentEntity.setId(fromDTO.getOrgId());
departmentEntity.setTotalUser(orgDTO.getDeptTotalUser() + 1);
customerDepartmentService.updateById(departmentEntity);
}
if ("grid".equals(fromDTO.getOrgType())) {
CustomerStaffGridEntity grid = new CustomerStaffGridEntity();
grid.setCustomerId(fromDTO.getCustomerId());
grid.setUserId(result.getData().getUserId());
grid.setGridId(fromDTO.getOrgId());
customerStaffGridService.insert(grid);
CustomerGridEntity gridEntity = new CustomerGridEntity();
gridEntity.setId(fromDTO.getOrgId());
gridEntity.setTotalUser(orgDTO.getGridTotalUser() + 1);
customerGridService.updateById(gridEntity);
}
return new Result();
}
}

63
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

@ -441,4 +441,67 @@
AND ca.pid =#{parentAgencyId}
</if>
</select>
<select id="selectAgencyDetail" resultType="com.epmet.dto.result.OrgResultDTO">
<choose>
<when test="orgType != null orgType == 'dept' ">
SELECT
ca.customer_id,
ca.id AS "agencyId",
ca.pid,
ca.pids,
ca.all_parent_name,
ca.organization_name,
ca. level,
ca.area_code,
ca.total_user,
cd.total_user AS "DeptTotalUser"
FROM
customer_department cd
INNER JOIN customer_agency ca ON cd.agency_id = ca.id
WHERE
cd.del_flag = '0'
AND ca.del_flag = '0'
AND cd.id = #{orgId}
</when>
<when test="orgType != null orgType == 'grid' ">
SELECT
ca.customer_id,
ca.id AS "agencyId",
ca.pid,
ca.pids,
ca.all_parent_name,
ca.organization_name,
ca. level,
ca.area_code,
ca.total_user,
cg.total_user AS "gridTotalUser"
FROM
customer_grid cg
INNER JOIN customer_agency ca ON cg.pid = ca.id
WHERE
cg.del_flag = '0'
AND ca.del_flag = '0'
AND cg.id = #{orgId}
</when>
<otherwise>
SELECT
ca.customer_id,
ca.id AS "agencyId",
ca.pid,
ca.pids,
ca.all_parent_name,
ca.organization_name,
ca. level,
ca.area_code,
ca.total_user
FROM
customer_agency ca
WHERE
ca.del_flag = '0'
AND ca.id = #{orgId}
</otherwise>
</choose>
</select>
</mapper>
Loading…
Cancel
Save