班组管路
This commit is contained in:
parent
0ae3826162
commit
f921144059
|
|
@ -38,4 +38,10 @@ public class ParamDto {
|
|||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private String endTime;
|
||||
|
||||
@ApiModelProperty(value = "绑定班组人员")
|
||||
private String bandingUsers;
|
||||
|
||||
@ApiModelProperty(value = "未绑定班组人员")
|
||||
private String unBandingUsers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.securitycontrol.common.core.web.page.TableDataInfo;
|
|||
import com.securitycontrol.common.log.annotation.Log;
|
||||
import com.securitycontrol.common.log.enums.OperationType;
|
||||
import com.securitycontrol.entity.background.dto.ParamDto;
|
||||
import com.securitycontrol.entity.background.vo.HumanManageVo;
|
||||
import com.securitycontrol.entity.background.vo.TeamManageVo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -62,4 +63,32 @@ public class TeamManageController extends BaseController {
|
|||
return service.delTeam(dto);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取班组人员列表")
|
||||
@GetMapping("getTeamUserLists")
|
||||
@Log(title = "人员管理", menu = "人员管理->班组管理", grade = OperationType.QUERY_BUSINESS, details = "查询班组人员", type = "业务日志")
|
||||
public TableDataInfo getTeamUserLists(ParamDto dto) {
|
||||
startPage();
|
||||
List<HumanManageVo> list = service.getTeamUserLists(dto);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "移出班组人员")
|
||||
@PostMapping("removeTeamUser")
|
||||
@Log(title = "人员管理", menu = "人员管理->班组管理", grade = OperationType.UPDATE_BUSINESS, details = "移出班组人员", type = "业务日志")
|
||||
public AjaxResult removeTeamUser(@RequestBody ParamDto dto) {
|
||||
return service.removeTeamUser(dto);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取班组组员和未加入班组人员")
|
||||
@GetMapping("getTeamUserAndNoBandingUser")
|
||||
public AjaxResult getTeamUserAndNoBandingUser(ParamDto dto) {
|
||||
return service.getTeamUserAndNoBandingUser(dto);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加班组人员")
|
||||
@PostMapping("addTeamUser")
|
||||
@Log(title = "人员管理", menu = "人员管理->班组管理", grade = OperationType.ADD_BUSINESS, details = "添加班组人员", type = "业务日志")
|
||||
public AjaxResult addTeamUser(@RequestBody ParamDto dto) {
|
||||
return service.addTeamUser(dto);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package com.securitycontrol.background.mapper;
|
||||
|
||||
import com.securitycontrol.entity.background.dto.ParamDto;
|
||||
import com.securitycontrol.entity.background.vo.HumanManageVo;
|
||||
import com.securitycontrol.entity.background.vo.TeamManageVo;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -89,6 +91,7 @@ public interface TeamManageMapper {
|
|||
|
||||
/**
|
||||
* 班组是否存在班组人员
|
||||
*
|
||||
* @param dto
|
||||
* @return int
|
||||
* @description
|
||||
|
|
@ -96,4 +99,59 @@ public interface TeamManageMapper {
|
|||
* @date 2024/3/21 10:48
|
||||
*/
|
||||
int isPeopleByTeam(ParamDto dto);
|
||||
|
||||
/**
|
||||
* 班组人员数量
|
||||
*
|
||||
* @param teamId
|
||||
* @return int
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/3/22 9:59
|
||||
*/
|
||||
int getTeamUserNum(String teamId);
|
||||
|
||||
/**
|
||||
* 获取班组人员列表
|
||||
*
|
||||
* @param dto
|
||||
* @return List<HumanManageVo>
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/3/22 10:04
|
||||
*/
|
||||
List<HumanManageVo> getTeamUserLists(ParamDto dto);
|
||||
|
||||
/**
|
||||
* 移出班组人员
|
||||
*
|
||||
* @param dto
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/3/22 10:13
|
||||
*/
|
||||
void removeTeamUser(ParamDto dto);
|
||||
|
||||
/**
|
||||
* 获取班组组员和未加入班组人员
|
||||
*
|
||||
* @param dto
|
||||
* @return List<Map < String>>
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/3/22 10:35
|
||||
*/
|
||||
@MapKey("id")
|
||||
List<Map<String, String>> getTeamUserAndNoBandingUser(ParamDto dto);
|
||||
|
||||
/**
|
||||
* 添加班组人员
|
||||
* @param userId
|
||||
* @param teamId
|
||||
* @param type
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/3/22 10:52
|
||||
*/
|
||||
void addTeamUser(@Param("userId") String userId, @Param("teamId") String teamId, @Param("type") int type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.securitycontrol.background.service;
|
|||
|
||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||
import com.securitycontrol.entity.background.dto.ParamDto;
|
||||
import com.securitycontrol.entity.background.vo.HumanManageVo;
|
||||
import com.securitycontrol.entity.background.vo.TeamManageVo;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -24,6 +25,7 @@ public interface TeamService {
|
|||
|
||||
/**
|
||||
* 删除班组
|
||||
*
|
||||
* @param vo
|
||||
* @return AjaxResult
|
||||
* @description
|
||||
|
|
@ -53,4 +55,47 @@ public interface TeamService {
|
|||
* @date 2024/3/21 10:40
|
||||
*/
|
||||
AjaxResult getTeamDetailById(ParamDto dto);
|
||||
|
||||
/**
|
||||
* 获取班组人员列表
|
||||
*
|
||||
* @param dto
|
||||
* @return List<HumanManageVo>
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/3/22 10:02
|
||||
*/
|
||||
List<HumanManageVo> getTeamUserLists(ParamDto dto);
|
||||
|
||||
/**
|
||||
* 移出班组人员
|
||||
*
|
||||
* @param dto
|
||||
* @return AjaxResult
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/3/22 10:10
|
||||
*/
|
||||
AjaxResult removeTeamUser(ParamDto dto);
|
||||
|
||||
/**
|
||||
* 获取班组组员和未加入班组人员
|
||||
*
|
||||
* @param dto
|
||||
* @return AjaxResult
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/3/22 10:31
|
||||
*/
|
||||
AjaxResult getTeamUserAndNoBandingUser(ParamDto dto);
|
||||
|
||||
/**
|
||||
* 添加班组人员
|
||||
* @param dto
|
||||
* @return AjaxResult
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/3/22 10:44
|
||||
*/
|
||||
AjaxResult addTeamUser(ParamDto dto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,15 +7,21 @@ import com.securitycontrol.common.core.utils.aes.AesCbcUtils;
|
|||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||
import com.securitycontrol.common.security.utils.ValidatorsUtils;
|
||||
import com.securitycontrol.entity.background.dto.ParamDto;
|
||||
import com.securitycontrol.entity.background.vo.HumanManageVo;
|
||||
import com.securitycontrol.entity.background.vo.TeamManageVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 班组-业务逻辑层
|
||||
* @author 10488
|
||||
*/
|
||||
@Service(value = "TeamService")
|
||||
@Slf4j
|
||||
public class TeamServiceImpl implements TeamService {
|
||||
|
|
@ -30,6 +36,10 @@ public class TeamServiceImpl implements TeamService {
|
|||
public List<TeamManageVo> getTeamLists(ParamDto dto) {
|
||||
List<TeamManageVo> list = new ArrayList<>();
|
||||
list = mapper.getTeamLists(dto);
|
||||
for (TeamManageVo vo : list) {
|
||||
int num = mapper.getTeamUserNum(vo.getTeamId());
|
||||
vo.setTeamNum(String.valueOf(num));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
@ -59,6 +69,8 @@ public class TeamServiceImpl implements TeamService {
|
|||
mapper.addOrUpdateTeam(vo);
|
||||
} catch (Exception e) {
|
||||
log.error("新增/修改班组", e);
|
||||
//手动回滚异常
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error();
|
||||
}
|
||||
return AjaxResult.success();
|
||||
|
|
@ -108,11 +120,84 @@ public class TeamServiceImpl implements TeamService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult delTeam(ParamDto dto) {
|
||||
try {
|
||||
int result = mapper.isPeopleByTeam(dto);
|
||||
if(result > 0){
|
||||
return AjaxResult.error("班组存在人员");
|
||||
}
|
||||
mapper.delTeam(dto);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
log.error("删除班组",e);
|
||||
//手动回滚异常
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HumanManageVo> getTeamUserLists(ParamDto dto) {
|
||||
List<HumanManageVo> list = new ArrayList<>();
|
||||
list = mapper.getTeamUserLists(dto);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult removeTeamUser(ParamDto dto) {
|
||||
try {
|
||||
mapper.removeTeamUser(dto);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
log.error("移出班组人员");
|
||||
//手动回滚异常
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getTeamUserAndNoBandingUser(ParamDto dto) {
|
||||
Map<String, Object> map = new HashMap<>(16);
|
||||
List<Map<String, String>> teamUsers = new ArrayList<>();
|
||||
List<Map<String, String>> noBandingUsers = new ArrayList<>();
|
||||
List<Map<String, String>> list = mapper.getTeamUserAndNoBandingUser(dto);
|
||||
if(CollectionUtils.isNotEmpty(list)){
|
||||
for (Map<String, String> stringMap : list) {
|
||||
if(Objects.equals(stringMap.get("type"),"1")){
|
||||
teamUsers.add(stringMap);
|
||||
}else if(Objects.equals(stringMap.get("type"),"2")){
|
||||
noBandingUsers.add(stringMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("teamUsers",teamUsers);
|
||||
map.put("noBandingUsers",noBandingUsers);
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult addTeamUser(ParamDto dto) {
|
||||
try {
|
||||
if(StringUtils.isNotEmpty(dto.getBandingUsers())){
|
||||
String[] bandingUserArr = dto.getBandingUsers().split(",");
|
||||
for (String bandingUser : bandingUserArr) {
|
||||
mapper.addTeamUser(bandingUser,dto.getId(),1);
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotEmpty(dto.getUnBandingUsers())){
|
||||
String[] unBandingUserArr = dto.getUnBandingUsers().split(",");
|
||||
for (String unBandingUser : unBandingUserArr) {
|
||||
mapper.addTeamUser(unBandingUser,null,2);
|
||||
}
|
||||
}
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
log.error("添加班组人员");
|
||||
//手动回滚异常
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,19 @@
|
|||
WHERE team_id = #{teamId}
|
||||
</if>
|
||||
</insert>
|
||||
<!--添加班组人员-->
|
||||
<insert id="addTeamUser">
|
||||
<if test="type == 1">
|
||||
UPDATE t_team_people SET team_id = #{teamId} WHERE user_id = #{userId}
|
||||
</if>
|
||||
<if test="type == 2">
|
||||
UPDATE t_team_people SET team_id = NULL WHERE user_id = #{userId}
|
||||
</if>
|
||||
</insert>
|
||||
<!--移出班组人员-->
|
||||
<update id="removeTeamUser">
|
||||
UPDATE t_team_people SET team_id = NULL WHERE user_id = #{id}
|
||||
</update>
|
||||
<!--删除班组-->
|
||||
<delete id="delTeam">
|
||||
DELETE FROM tb_work_team WHERE team_id = #{id}
|
||||
|
|
@ -92,4 +105,29 @@
|
|||
<select id="isPeopleByTeam" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM t_team_people WHERE team_id = #{id}
|
||||
</select>
|
||||
<!--班组人员数量-->
|
||||
<select id="getTeamUserNum" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM t_team_people WHERE team_id = #{teamId}
|
||||
</select>
|
||||
<!--获取班组人员列表-->
|
||||
<select id="getTeamUserLists" resultType="com.securitycontrol.entity.background.vo.HumanManageVo">
|
||||
SELECT
|
||||
ttp.user_id AS userId,
|
||||
ttp.user_name AS userName,
|
||||
sd.dict_name AS userType
|
||||
FROM t_team_people ttp
|
||||
LEFT JOIN sys_dict sd ON ttp.user_type = sd.dict_code
|
||||
<where>
|
||||
ttp.team_id = #{id}
|
||||
<if test="userName!=null and userName !=''">
|
||||
AND INSTR(ttp.user_name,#{userName}) > 0
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<!--获取班组组员和未加入班组人员-->
|
||||
<select id="getTeamUserAndNoBandingUser" resultType="java.util.Map">
|
||||
SELECT user_id AS id,user_name AS userName,'1' AS type FROM t_team_people WHERE team_id = #{id}
|
||||
UNION ALL
|
||||
SELECT user_id AS id,user_name AS userName,'2' AS type FROM t_team_people WHERE team_id IS NULL OR team_id = ''
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue