班组管理

This commit is contained in:
cwchen 2024-03-21 13:28:01 +08:00
parent 73c89bcaff
commit 6b14a697e2
9 changed files with 401 additions and 121 deletions

View File

@ -88,11 +88,8 @@ public class AesCbcUtils {
return new String(decoded, ENCODING);
}catch (Exception e){
log.error(e.toString(),e);
return null;
}
return "";
}
}

View File

@ -0,0 +1,20 @@
package com.securitycontrol.entity.background.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @authorcwchen
* @date2024-03-21-9:38
* @version1.0
* @description前端接受参数-dto
*/
@Data
public class ParamDto {
@ApiModelProperty(value = "关键字")
private String keyWord;
@ApiModelProperty(value = "id")
private String id;
}

View File

@ -3,6 +3,11 @@ package com.securitycontrol.entity.background.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/**
* @authorcwchen
* @date2024-03-20-14:12
@ -16,18 +21,29 @@ public class DeviceBdChildVo {
private String deviceId;
@ApiModelProperty(value = "设备编码")
@NotBlank(message = "设备编码不能为空", groups = {Query.class})
@Length(max = 80, message = "设备编码字符长度不能超过80", groups = {Query.class})
private String deviceCode;
@ApiModelProperty(value = "设备类型")
@NotBlank(message = "设备类型不能为空", groups = {Query.class})
@Length(max = 80, message = "设备类型字符长度不能超过80", groups = {Query.class})
private String deviceType;
@ApiModelProperty(value = "设备状态")
@NotBlank(message = "设备状态不能为空", groups = {Query.class})
@Length(max = 10, message = "设备状态字符长度不能超过10", groups = {Query.class})
private String status;
@ApiModelProperty(value = "设备网络")
@NotBlank(message = "设备网络不能为空", groups = {Query.class})
@Length(max = 20, message = "设备网络字符长度不能超过20", groups = {Query.class})
@Pattern(regexp = "((0|1\\d{0,2}|2[0-4]\\d|25[0-5])\\.){3}(0|1\\d{0,2}|2[0-4]\\d|25[0-5])",message = "设备网络格式不正确",groups = {Query.class})
private String ip;
@ApiModelProperty(value = "设备名称")
@NotBlank(message = "设备名称不能为空", groups = {Query.class})
@Length(max = 50, message = "设备名称字符长度不能超过50", groups = {Query.class})
private String deviceName;
@ApiModelProperty(value = "更新时间")
@ -37,9 +53,13 @@ public class DeviceBdChildVo {
private String updateTime;
@ApiModelProperty(value = "设备信号")
@NotBlank(message = "设备信号不能为空", groups = {Query.class})
@Length(max = 50, message = "设备信号字符长度不能超过50", groups = {Query.class})
private String deviceModel;
@ApiModelProperty(value = "边带ID")
@NotBlank(message = "设备所属边带不能为空", groups = {Query.class})
@Length(max = 100, message = "设备所属边带字符长度不能超过100", groups = {Query.class})
private String bdId;
@ApiModelProperty(value = "边带名称")
@ -51,6 +71,8 @@ public class DeviceBdChildVo {
@ApiModelProperty(value = "区域ID")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@NotBlank(message = "检测区域不能为空", groups = {Query.class})
@Length(max = 100, message = "检测区域字符长度不能超过100", groups = {Query.class})
private String areaId;
@ApiModelProperty(value = "区域名称")

View File

@ -1,34 +1,63 @@
package com.securitycontrol.entity.background.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
/**
* @author 10488
* 班组VO
*/
@Data
public class TeamManageVo {
@ApiModelProperty(value = "ID")
private String id;
@ApiModelProperty(value = "工程ID")
private String proId;
@ApiModelProperty(value = "班组ID")
private String teamId;
@ApiModelProperty(value = "班组名称")
@NotBlank(message = "班组名称不能为空", groups = {Query.class})
@Length(max = 80, message = "班组名称字符长度不能超过80", groups = {Query.class})
private String teamName;
@ApiModelProperty(value = "班组长")
@NotBlank(message = "班组长不能为空", groups = {Query.class})
@Length(max = 50, message = "班组长字符长度不能超过50", groups = {Query.class})
private String teamLeader;
@ApiModelProperty(value = "身份证编号")
@NotBlank(message = "身份证号码不能为空", groups = {Query.class})
@Length(max = 30, message = "身份证号码字符长度不能超过30", groups = {Query.class})
private String idNumber;
@ApiModelProperty(value = "电话号码")
@ApiModelProperty(value = "手机号码")
@NotBlank(message = "手机号码不能为空", groups = {Query.class})
@Length(max = 20, message = "手机号码字符长度不能超过20", groups = {Query.class})
private String teamLeaderPhone;
@ApiModelProperty(value = "工种")
private String userType;
@ApiModelProperty(value = "班组状态")
private String status;
@ApiModelProperty(value = "性别")
private String sex;
@ApiModelProperty(value = "年龄")
private String age;
@ApiModelProperty(value = "班组人数")
private String teamNum;
@ApiModelProperty(value = "工程编码")
@NotBlank(message = "工程编码能为空", groups = {Query.class})
@Length(max = 80, message = "工程编码字符长度不能超过80", groups = {Query.class})
private String bidCode;
private String delFalge;
private String userId;
@ApiModelProperty(value = "工程名称")
private String proName;
@ApiModelProperty(value = "1.新增 2.修改")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Integer type;
/**
* 查询条件限制
*/
public interface Query {
}
}

View File

@ -6,12 +6,10 @@ import com.securitycontrol.common.core.web.domain.AjaxResult;
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.TeamManageVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@ -21,41 +19,46 @@ import java.util.List;
*
* @author jsk
*/
@RequestMapping(value = "/teamManage")
@RequestMapping(value = "/back/workTeam/")
@RestController
public class TeamManageController extends BaseController {
@Resource(name = "TeamService")
private TeamService service;
@ApiOperation(value = "获取人员列表")
@PostMapping("getTeamLists")
@Log(title = "人员管理", menu = "人员管理->人员管理", grade = OperationType.QUERY_BUSINESS, details = "查询人员", type = "业务日志")
public TableDataInfo getTeamLists(TeamManageVo vo) {
@ApiOperation(value = "获取班组列表")
@GetMapping("getTeamLists")
@Log(title = "人员管理", menu = "人员管理->班组管理", grade = OperationType.QUERY_BUSINESS, details = "查询班组", type = "业务日志")
public TableDataInfo getTeamLists(ParamDto dto) {
startPage();
List<TeamManageVo> list = service.getTeamLists(vo);
List<TeamManageVo> list = service.getTeamLists(dto);
return getDataTable(list);
}
@ApiOperation(value = "新增人员")
@ApiOperation(value = "新增班组")
@PostMapping("addTeam")
@Log(title = "人员管理", menu = "人车管理->人员管理", grade = OperationType.ADD_BUSINESS, details = "新增人员", type = "业务日志")
public AjaxResult addTeam(TeamManageVo vo) {
return service.addTeam(vo);
@Log(title = "人员管理", menu = "人车管理->班组管理", grade = OperationType.ADD_BUSINESS, details = "新增班组", type = "业务日志")
public AjaxResult addTeam(@RequestBody TeamManageVo vo) {
return service.addOrUpdateTeam(vo);
}
@ApiOperation(value = "修改人员")
@PostMapping("updateTeam")
@Log(title = "人员管理", menu = "人车管理->人员管理", grade = OperationType.UPDATE_BUSINESS, details = "修改人员", type = "业务日志")
public AjaxResult updateTeam(TeamManageVo vo) {
return service.updateTeam(vo);
@ApiOperation(value = "修改班组")
@PostMapping("editTeam")
@Log(title = "人员管理", menu = "人车管理->班组管理", grade = OperationType.UPDATE_BUSINESS, details = "修改班组", type = "业务日志")
public AjaxResult editTeam(@RequestBody TeamManageVo vo) {
return service.addOrUpdateTeam(vo);
}
@ApiOperation(value = "删除人员")
@ApiOperation(value = "班组详情")
@GetMapping("getTeamDetailById")
public AjaxResult getTeamDetailById(ParamDto dto) {
return service.getTeamDetailById(dto);
}
@ApiOperation(value = "删除班组")
@PostMapping("delTeam")
@Log(title = "人员管理", menu = "人车管理->人员管理", grade = OperationType.DELETE_BUSINESS, details = "删除人员", type = "业务日志")
public AjaxResult delTeam(@RequestBody TeamManageVo dto) {
@Log(title = "人员管理", menu = "人车管理->班组管理", grade = OperationType.DELETE_BUSINESS, details = "删除班组", type = "业务日志")
public AjaxResult delTeam(@RequestBody ParamDto dto) {
return service.delTeam(dto);
}

View File

@ -1,22 +1,25 @@
package com.securitycontrol.background.mapper;
import com.securitycontrol.entity.background.dto.ParamDto;
import com.securitycontrol.entity.background.vo.TeamManageVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.MapKey;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
import java.util.Map;
/**
* 班组数据库访问层
*
* @author 10488
*/
@Repository(value = "TeamManageMapper")
public interface TeamManageMapper {
/**
* ss
* @param vo
* @return
*/
List<TeamManageVo> getTeamLists(TeamManageVo vo);
/**
* DD
*
* @param vo
* @return
*/
@ -24,8 +27,73 @@ public interface TeamManageMapper {
/**
* sssd
*
* @param vo
* @return
*/
int updateTeam(TeamManageVo vo);
/**
* 获取班组列表
*
* @param dto
* @return List<TeamManageVo>
* @description
* @author cwchen
* @date 2024/3/21 9:45
*/
List<TeamManageVo> getTeamLists(ParamDto dto);
/**
* 新增/修改班组
*
* @param vo
* @description
* @author cwchen
* @date 2024/3/21 10:21
*/
void addOrUpdateTeam(TeamManageVo vo);
/**
* 班组是否存在
*
* @param vo
* @return List<Map < String, String>>
* @description
* @author cwchen
* @date 2024/3/21 10:24
*/
@MapKey("id")
List<Map<String, String>> isTeamExist(TeamManageVo vo);
/**
* 班组详情
*
* @param dto
* @return TeamManageVo
* @description
* @author cwchen
* @date 2024/3/21 10:42
*/
TeamManageVo getTeamDetailById(ParamDto dto);
/**
* 删除班组
*
* @param dto
* @description
* @author cwchen
* @date 2024/3/21 10:47
*/
void delTeam(ParamDto dto);
/**
* 班组是否存在班组人员
* @param dto
* @return int
* @description
* @author cwchen
* @date 2024/3/21 10:48
*/
int isPeopleByTeam(ParamDto dto);
}

View File

@ -1,13 +1,56 @@
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.TeamManageVo;
import java.util.List;
/**
* @author 10488
* 班组-业务层
*/
public interface TeamService {
List<TeamManageVo> getTeamLists(TeamManageVo vo);
AjaxResult addTeam(TeamManageVo vo);
AjaxResult updateTeam(TeamManageVo vo);
AjaxResult delTeam(TeamManageVo vo);
/**
* 获取班组列表
*
* @param dto
* @return List<TeamManageVo>
* @description
* @author cwchen
* @date 2024/3/21 9:40
*/
List<TeamManageVo> getTeamLists(ParamDto dto);
/**
* 删除班组
* @param vo
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/21 10:45
*/
AjaxResult delTeam(ParamDto vo);
/**
* 新增/修改班组
*
* @param vo
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/21 10:10
*/
AjaxResult addOrUpdateTeam(TeamManageVo vo);
/**
* 班组详情
*
* @param dto
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/21 10:40
*/
AjaxResult getTeamDetailById(ParamDto dto);
}

View File

@ -2,13 +2,19 @@ package com.securitycontrol.background.service.impl;
import com.securitycontrol.background.mapper.TeamManageMapper;
import com.securitycontrol.background.service.TeamService;
import com.securitycontrol.common.core.utils.StringUtils;
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.TeamManageVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.*;
@Service(value = "TeamService")
@Slf4j
@ -17,41 +23,96 @@ public class TeamServiceImpl implements TeamService {
@Resource(name = "TeamManageMapper")
private TeamManageMapper mapper;
@Resource(name = "ValidatorsUtils")
private ValidatorsUtils validatorsUtils;
@Override
public List<TeamManageVo> getTeamLists(TeamManageVo vo) {
return null;
public List<TeamManageVo> getTeamLists(ParamDto dto) {
List<TeamManageVo> list = new ArrayList<>();
list = mapper.getTeamLists(dto);
return list;
}
@Override
public AjaxResult addTeam(TeamManageVo vo) {
try{
mapper.addTeam(vo);
}catch (Exception e){
@Transactional(rollbackFor = Exception.class)
public AjaxResult addOrUpdateTeam(TeamManageVo vo) {
try {
String validResult = validatorsUtils.valid(vo, TeamManageVo.Query.class);
if (StringUtils.isNotBlank(validResult)) {
return AjaxResult.error(validResult);
}
List<Map<String, String>> list = mapper.isTeamExist(vo);
if (CollectionUtils.isNotEmpty(list)) {
Boolean result = teamIsExist(list,vo.getIdNumber());
if (result) {
return AjaxResult.error("班组不能重复");
}
}
if (StringUtils.isEmpty(vo.getTeamId())) {
String teamId = UUID.randomUUID().toString().replace("-", "");
vo.setTeamId(teamId);
vo.setType(1);
} else {
vo.setType(2);
}
vo.setIdNumber(AesCbcUtils.encrypt(vo.getIdNumber(),AesCbcUtils.sKey));
mapper.addOrUpdateTeam(vo);
} catch (Exception e) {
log.error("新增/修改班组", e);
return AjaxResult.error();
}
return AjaxResult.success();
}
@Override
public AjaxResult updateTeam(TeamManageVo vo) {
try{
mapper.updateTeam(vo);
}catch (Exception e){
return AjaxResult.error();
/**
* 班组是否存在
* @param list
* @param idNumber
* @return Boolean
* @description
* @author cwchen
* @date 2024/3/21 10:36
*/
public Boolean teamIsExist(List<Map<String, String>> list, String idNumber) {
for (Map<String, String> map : list) {
String value = map.get("value");
String decryptValue = AesCbcUtils.decrypt(value);
if (decryptValue == null) {
if (Objects.equals(idNumber, value)) {
return true;
}
return AjaxResult.success();
} else {
if (Objects.equals(idNumber, decryptValue)) {
return true;
}
@Override
public AjaxResult delTeam(TeamManageVo vo) {
try{
TeamManageVo delvo=new TeamManageVo();
delvo.setTeamId(vo.getTeamId());
delvo.setDelFalge("0");
mapper.updateTeam(delvo);
}catch (Exception e){
return AjaxResult.error();
}
return AjaxResult.success();
}
return false;
}
@Override
public AjaxResult getTeamDetailById(ParamDto dto) {
TeamManageVo vo = new TeamManageVo();
try {
vo = mapper.getTeamDetailById(dto);
String decryptIdNumber = AesCbcUtils.decrypt(vo.getIdNumber());
if(decryptIdNumber != null){
vo.setIdNumber(decryptIdNumber);
}
} catch (Exception e) {
log.error("班组详情",e);
}
return AjaxResult.success(vo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult delTeam(ParamDto dto) {
int result = mapper.isPeopleByTeam(dto);
if(result > 0){
return AjaxResult.error("班组存在人员");
}
mapper.delTeam(dto);
return AjaxResult.success();
}
}

View File

@ -1,27 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.securitycontrol.background.mapper.TeamManageMapper">
<!--新增/修改 工程-->
<insert id="addTeam">
<!--新增/修改班组-->
<insert id="addOrUpdateTeam">
<if test="type == 1">
INSERT INTO tb_work_team
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="teamId != null and teamId != ''">team_id,</if>
<if test="teamName != null and teamName != ''">team_name,</if>
<if test="teamLeader != null and teamLeader != ''">team_leader,</if>
<if test="bidCode != null and bidCode!=''">bid_code,</if>
<if test="teamLeaderPhone != null and teamLeaderPhone!=''">team_leader_phone,</if>
<if test="idNumber != null and idNumber!=''">id_number,</if>
<if test="proCode != null and proCode!=''">team_num,</if>
<if test="status != null and status!=''">status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="teamId != null and teamId != ''">#{teamId},</if>
<if test="teamName != null and teamName != ''">#{teamName},</if>
<if test="teamLeader != null and teamLeader != ''">#{teamLeader},</if>
<if test="bidCode != null and bidCode!=''">#{bidCode},</if>
<if test="teamLeaderPhone != null and teamLeaderPhone!=''">#{teamLeaderPhone},</if>
<if test="idNumber != null and idNumber!=''">#{idNumber},</if>
<if test="teamNum != null and teamNum!=''">#{teamNum},</if>
<if test="status != null and status!=''">#{status},</if>
</trim>
</insert>
<update id="updateTeam">
</if>
<if test="type == 2">
UPDATE tb_work_team
<set>
<if test="teamName != null and teamName != ''">team_name = #{teamName},</if>
@ -29,29 +33,62 @@
<if test="bidCode != null and bidCode != ''">bid_code = #{bidCode},</if>
<if test="teamLeaderPhone != null and teamLeaderPhone != ''">team_leader_phone = #{teamLeaderPhone},</if>
<if test="idNumber != null and idNumber != ''">id_number = #{idNumber},</if>
<if test="teamNum != null and teamNum != ''">team_num = #{teamNum},</if>
<if test="delFalge != null and delFalge != ''">del_falge = #{delFalge},</if>
<if test="status != null and status != ''">status = #{status},</if>
</set>
WHERE team_id= #{teamId}
</update>
<!--获取人员列表-->
WHERE team_id = #{teamId}
</if>
</insert>
<!--删除班组-->
<delete id="delTeam">
DELETE FROM tb_work_team WHERE team_id = #{id}
</delete>
<!--获取班组列表-->
<select id="getTeamLists" resultType="com.securitycontrol.entity.background.vo.TeamManageVo">
SELECT
team_name as teamname,
team_leader as teamleader,
team_leader_phone as teamleaderphone,
id_number as idnumber,
bid_code as bidcode,
team_num as teamnum
from
tb_work_team twt
twt.team_id AS teamId,
twt.team_name as teamName,
twt.team_leader as teamleader,
twt.team_leader_phone as teamleaderphone,
tp.pro_name AS proName,
twt.team_num as teamNum,
twt.status,
twt.bid_code AS bidCode
FROM tb_work_team twt
LEFT JOIN tb_project tp on twt.bid_code = tp.bid_code
<where>
<if test="keyWord !=null and keyWord!=''">
AND (
INSTR(twt.team_leader,#{keyWord}) > 0 OR
INSTR(twt.id_number,#{keyWord}) > 0
INSTR(twt.team_leader,#{keyWord}) > 0
)
</if>
</where>
</select>
<!--班组是否存在-->
<select id="isTeamExist" resultType="java.util.Map">
<if test="teamId == null or teamId == ''">
SELECT team_id AS id,id_number AS value FROM tb_work_team
</if>
<if test="teamId != null and teamId != ''">
SELECT team_id AS id,id_number AS value FROM tb_work_team WHERE team_id != #{teamId}
</if>
</select>
<!--班组详情-->
<select id="getTeamDetailById" resultType="com.securitycontrol.entity.background.vo.TeamManageVo">
SELECT
twt.team_id AS teamId,
twt.team_name as teamname,
twt.team_leader as teamleader,
twt.team_leader_phone as teamleaderphone,
twt.status,
twt.bid_code AS bidCode,
twt.id_number AS idNumber
FROM tb_work_team twt
WHERE team_id = #{id}
</select>
<!--班组是否存在班组人员-->
<select id="isPeopleByTeam" resultType="java.lang.Integer">
SELECT COUNT(*) FROM t_team_people WHERE team_id = #{id}
</select>
</mapper>