Commit e9db104a authored by 王蔡翾's avatar 王蔡翾
Browse files

优化

parent aa7286f0
package com.example.operation_platform.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@TableName("bs_work_level")
public class BsWorkLevelEntity {
@TableId(type = IdType.ASSIGN_ID )
private String id;
@TableField("level")
private String level;
@TableField("color")
private String color;
@TableField("description")
private String description;
@ApiModelProperty("处理时长(h)")
@TableField("handle_time")
private Integer handleTime;
}
package com.example.operation_platform.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@TableName("bs_work_operation")
public class BsWorkOperationEntity {
@TableId(type = IdType.ASSIGN_ID)
private String id;
@ApiModelProperty(value = "工单id")
@TableField("work_id")
private String workId;
@ApiModelProperty(value = "处理时间")
@TableField("handle_time")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date handleTime;
@ApiModelProperty(value = "处理人")
@TableField("handler")
private String handler;
@ApiModelProperty(value = "说明")
private String remark;
@ApiModelProperty(value = "附件地址")
@TableField("file_path")
private String filePath;
}
package com.example.operation_platform.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName ("bs_work_type")
public class BsWorkTypeEntity {
@TableId(type = IdType.ASSIGN_ID )
private String id;
@TableField("type_name")
private String typeName;
@TableField("description")
private String description;
}
package com.example.operation_platform.model.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class LoginEntity {
@ApiModelProperty(value = "访问令牌")
private String token;
@ApiModelProperty(value = "用户ID")
private String userId;
@ApiModelProperty(value = "用户名")
private String name;
@ApiModelProperty(value = "密码")
private String password;
}
package com.example.operation_platform.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
@TableName("user")
public class UserEntity {
@TableId(type = IdType.ASSIGN_ID)
private String id;
@TableField("name")
private String name;
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date createTime;
@TableField("phone")
private String phone;
@TableField("id_card")
private String idCard;
@TableField("fn")
private String fn;
@TableField("work_no")
private String workNo;
@TableField("sex")
private Integer sex;
@TableField("birth_date")
private String birthDate;
@TableField("birth")
private String birth;
@TableField("age")
private Integer age;
@TableField("nation")
private String nation;
@TableField("company_name")
private String companyName;
@TableField("post")
private String post;
@TableField("post_rank")
private String postRank;
@TableField("sequence")
private String sequence;
@TableField("join_date")
private Date joinDate;
@TableField("second_dept")
private String secondDept;
@TableField("third_dept")
private String thirdDept;
@TableField("password")
private String password;
@TableField("email")
private String email;
@TableField("user_role")
private String userRole;
@TableField("dept_id")
private String deptId;
@TableField("role_id")
private Integer roleId;
}
package com.example.operation_platform.model.vo;
import com.example.operation_platform.model.entity.BsWorkLevelEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class BsWorkLevelVO extends BsWorkLevelEntity {
}
package com.example.operation_platform.model.vo;
import com.example.operation_platform.model.entity.BsWorkTypeEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class BsWorkTypeVO extends BsWorkTypeEntity {
}
package com.example.operation_platform.model.vo;
import com.example.operation_platform.model.entity.BsWorkEntity;
import com.example.operation_platform.model.entity.BsWorkOperationEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
public class BsWorkVO extends BsWorkEntity {
private String createByName;
private String handleByName;
@ApiModelProperty("关闭标记")
private Integer closeFlag=0;
@ApiModelProperty("处理标记")
private Integer handleFlag=0;
@ApiModelProperty("转派标记")
private Integer transferFlag=0;
@ApiModelProperty("完结标记")
private Integer finishFlag=0;
@ApiModelProperty("工单处理记录")
private List<BsWorkOperationEntity> bsWorkOperationEntities;
@ApiModelProperty("颜色")
private String color;
@ApiModelProperty("项目名称")
private String projectName;
}
package com.example.operation_platform.model.vo;
import com.example.operation_platform.model.entity.UserEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class UserVO extends UserEntity {
}
...@@ -17,4 +17,6 @@ public class WorkerVO { ...@@ -17,4 +17,6 @@ public class WorkerVO {
private String password; private String password;
private Integer typeId; private Integer typeId;
private String token;
} }
package com.example.operation_platform.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.operation_platform.model.entity.BsProjectEntity;
import java.util.List;
public interface BsProjectService extends IService<BsProjectEntity> {
}
package com.example.operation_platform.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.operation_platform.model.entity.BsWorkLevelEntity;
import com.example.operation_platform.model.vo.BsWorkLevelVO;
import java.util.List;
public interface BsWorkLevelService extends IService<BsWorkLevelEntity> {
List<BsWorkLevelVO> queryWorkLevelList();
BsWorkLevelVO queryByLevel(String level);
}
package com.example.operation_platform.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.operation_platform.model.entity.BsWorkOperationEntity;
import java.util.List;
public interface BsWorkOperationService extends IService<BsWorkOperationEntity> {
List<BsWorkOperationEntity> queryOperationByWorkId(String workId);
}
package com.example.operation_platform.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.operation_platform.model.dto.BsWorkDTO;
import com.example.operation_platform.model.entity.BsWorkEntity;
import com.example.operation_platform.model.vo.BsWorkVO;
import java.util.List;
public interface BsWorkService extends IService<BsWorkEntity> {
/**
* 查询工单列表
* @param bsWorkDTO
* @return
*/
List<BsWorkVO> queryWorkList(BsWorkDTO bsWorkDTO);
Boolean addWork(BsWorkDTO bsWorkDTO);
/*
** 处理工单
*/
Boolean handleWork(BsWorkDTO bsWorkDTO);
/*
** 确认工单
*/
Boolean confirmWork(BsWorkDTO bsWorkDTO);
/*
** 关闭工单
*/
Boolean closeWork(BsWorkDTO bsWorkDTO);
/*
** 转单
*/
Boolean transferWork(BsWorkDTO bsWorkDTO);
/*
** 获取工单详情
*/
BsWorkVO getWorkDetail(String id,String loginName);
}
package com.example.operation_platform.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.operation_platform.model.entity.BsWorkTypeEntity;
import com.example.operation_platform.model.vo.BsWorkTypeVO;
import java.util.List;
public interface BsWorkTypeService extends IService<BsWorkTypeEntity> {
/**
* 查询所有工单类型
* @return
*/
List<BsWorkTypeVO> queryWorkTypeList();
}
package com.example.operation_platform.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.operation_platform.model.dto.UserDTO;
import com.example.operation_platform.model.entity.LoginEntity;
import com.example.operation_platform.model.entity.UserEntity;
import com.example.operation_platform.model.vo.UserVO;
import java.util.List;
public interface UserService extends IService<UserEntity> {
LoginEntity login(LoginEntity login);
List<UserVO> queryUserList(UserDTO userDTO);
}
package com.example.operation_platform.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.operation_platform.mapper.BsProjectMapper;
import com.example.operation_platform.model.entity.BsProjectEntity;
import com.example.operation_platform.service.BsProjectService;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class BsProjectServiceImpl extends ServiceImpl<BsProjectMapper, BsProjectEntity> implements BsProjectService {
@Override
public List<BsProjectEntity> list(){
return baseMapper.queryProjectList();
}
}
package com.example.operation_platform.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.operation_platform.mapper.BsWorkLevelMapper;
import com.example.operation_platform.model.entity.BsWorkLevelEntity;
import com.example.operation_platform.model.vo.BsWorkLevelVO;
import com.example.operation_platform.service.BsWorkLevelService;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class BsWorkLevelServiceImpl extends ServiceImpl<BsWorkLevelMapper, BsWorkLevelEntity> implements BsWorkLevelService {
@Override
public List<BsWorkLevelVO> queryWorkLevelList() {
return baseMapper.queryWorkLevelList();
}
@Override
public BsWorkLevelVO queryByLevel(String level) {
return baseMapper.queryByLevel(level);
}
}
package com.example.operation_platform.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.operation_platform.mapper.BsWorkOperationMapper;
import com.example.operation_platform.model.entity.BsWorkOperationEntity;
import com.example.operation_platform.service.BsWorkOperationService;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class BsWorkOperationServiceImpl extends ServiceImpl<BsWorkOperationMapper, BsWorkOperationEntity> implements BsWorkOperationService {
@Override
public List<BsWorkOperationEntity> queryOperationByWorkId(String workId) {
return baseMapper.queryOperationByWorkId(workId);
}
}
package com.example.operation_platform.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.operation_platform.mapper.BsWorkMapper;
import com.example.operation_platform.model.dto.BsWorkDTO;
import com.example.operation_platform.model.entity.BsProjectEntity;
import com.example.operation_platform.model.entity.BsWorkEntity;
import com.example.operation_platform.model.entity.BsWorkOperationEntity;
import com.example.operation_platform.model.entity.UserEntity;
import com.example.operation_platform.model.vo.BsWorkLevelVO;
import com.example.operation_platform.model.vo.BsWorkVO;
import com.example.operation_platform.service.*;
import com.example.operation_platform.util.SmsSendUtils;
import com.platform.utils.DozerUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class BsWorkServiceImpl extends ServiceImpl <BsWorkMapper, BsWorkEntity> implements BsWorkService {
private final String DEPT_LEADER="朱翔";
@Resource
private BsWorkLevelService bsWorkLevelService;
@Resource
private BsWorkOperationService bsWorkOperationService;
@Resource
private UserService userService;
@Resource
private SmsSendUtils smsSendUtils;
@Resource
private BsProjectService bsProjectService;
@Override
public List<BsWorkVO> queryWorkList(BsWorkDTO bsWorkDTO){
UserEntity userEntity = userService.getOne(new QueryWrapper<UserEntity>().eq("name", bsWorkDTO.getLoginName()));
// 判断是否是部门领导
if (!DEPT_LEADER.equals(bsWorkDTO.getLoginName())) {
bsWorkDTO.setHandleBy(userEntity.getId());
}
// 查询工单列表
List<BsWorkVO> workVOS = baseMapper.queryWorkList(bsWorkDTO);
//根据当前登录人进行按钮标记赋值
for ( BsWorkVO workVO : workVOS){
if ("待处理".equals( workVO.getStatus())){
// 判断是否是创建人和处理人
if (bsWorkDTO.getLoginName().equals(workVO.getCreateByName())&& bsWorkDTO.getLoginName().equals(workVO.getHandleByName())){
workVO.setCloseFlag(1);
workVO.setHandleFlag(1);
workVO.setTransferFlag(1);
}
// 判断是否是创建人
else if (bsWorkDTO.getLoginName().equals(workVO.getCreateByName())) {
workVO.setCloseFlag(1);
}
//判断是否是处理人
else if (bsWorkDTO.getLoginName().equals(workVO.getHandleByName())) {
workVO.setHandleFlag(1);
workVO.setTransferFlag(1);
}
} else if ("待确认".equals(workVO.getStatus())) {
if (bsWorkDTO.getLoginName().equals(DEPT_LEADER)){
workVO.setFinishFlag(1);
}
}
//如果都不是则不添加任何标记
}
return workVOS;
}
/*
** 新增工单
*/
@Override
public Boolean addWork(BsWorkDTO bsWorkDTO){
BsWorkLevelVO bsWorkLevelVO = bsWorkLevelService.queryByLevel(bsWorkDTO.getLevel());
UserEntity userEntity = userService.getOne(new QueryWrapper<UserEntity>().eq("name", bsWorkDTO.getLoginName()));
bsWorkDTO.setCreateBy(userEntity.getId());
bsWorkDTO.setCreateTime( new Date());
bsWorkDTO.setStatus("待处理");
//获取处理时长
Integer handleTime = bsWorkLevelVO.getHandleTime();
//设置工单结束时间
if (handleTime == null){
handleTime =0;
}
long endTimeMillis = bsWorkDTO.getCreateTime().getTime() + handleTime * 60 * 1000L;
bsWorkDTO.setEndTime(new java.util.Date(endTimeMillis));
String code = "T" + System.currentTimeMillis() % 10000000000L;
bsWorkDTO.setCode(code);
//创建操作记录数据
BsWorkOperationEntity bsWorkOperationEntity =new BsWorkOperationEntity();
bsWorkOperationEntity.setHandleTime( new Date());
bsWorkOperationEntity.setHandler(bsWorkDTO.getLoginName());
bsWorkOperationEntity.setRemark("新增工单");
bsWorkOperationEntity.setWorkId(bsWorkDTO.getId());
//发送工单处理提醒
// smsSendUtils.sendSms(userEntity.getPhone(),bsWorkDTO);
return save(bsWorkDTO)&&bsWorkOperationService .save(bsWorkOperationEntity);
}
/*
** 处理工单
*/
@Override
public Boolean handleWork(BsWorkDTO bsWorkDTO){
bsWorkDTO.setStatus("待确认");
//查找部门领导用户id
UserEntity userEntity = userService.getOne(new QueryWrapper<UserEntity>().eq("name", DEPT_LEADER));
bsWorkDTO.setHandleBy(userEntity.getId());
Date now = new Date();
//设置 工单处理时间
bsWorkDTO.setHandleTime(now);
//创建操作记录数据
BsWorkOperationEntity bsWorkOperationEntity =new BsWorkOperationEntity();
bsWorkOperationEntity.setHandleTime( new Date());
bsWorkOperationEntity.setHandler(bsWorkDTO.getLoginName());
bsWorkOperationEntity.setRemark("处理工单:"+ bsWorkDTO.getRemark());
bsWorkOperationEntity.setWorkId(bsWorkDTO.getId());
bsWorkOperationEntity .setFilePath(bsWorkDTO.getFilePath());
//更新工单状态,并 保存操作记录
return updateById(bsWorkDTO) && bsWorkOperationService.save(bsWorkOperationEntity);
}
/*
** 确认工单
*/
@Override
public Boolean confirmWork(BsWorkDTO bsWorkDTO) {
BsWorkEntity bsWorkEntity = getById(bsWorkDTO.getId());
if (bsWorkEntity.getHandleTime().after( bsWorkEntity.getEndTime())){
bsWorkDTO.setStatus("逾期完成");
}else {
bsWorkDTO.setStatus("已完成");
}
//创建操作记录数据
BsWorkOperationEntity bsWorkOperationEntity = new BsWorkOperationEntity();
bsWorkOperationEntity.setHandleTime(new Date());
bsWorkOperationEntity.setHandler(bsWorkDTO.getLoginName());
bsWorkOperationEntity.setRemark("完结确认");
bsWorkOperationEntity.setWorkId(bsWorkDTO.getId());
bsWorkOperationEntity .setFilePath(bsWorkDTO.getFilePath());
//更新工单状态,并 保存操作记录
return updateById(bsWorkDTO) && bsWorkOperationService.save(bsWorkOperationEntity);
}
/*
** 关闭工单
*/
@Override
public Boolean closeWork(BsWorkDTO bsWorkDTO){
bsWorkDTO.setStatus("已关闭");
//创建操作记录数据
BsWorkOperationEntity bsWorkOperationEntity = new BsWorkOperationEntity();
bsWorkOperationEntity.setHandleTime(new Date());
bsWorkOperationEntity.setHandler(bsWorkDTO.getLoginName());
bsWorkOperationEntity.setRemark("关闭工单");
bsWorkOperationEntity.setWorkId(bsWorkDTO.getId());
bsWorkOperationEntity .setFilePath(bsWorkDTO.getFilePath());
//更新工单状态,并 保存操作记录
return updateById(bsWorkDTO) && bsWorkOperationService.save(bsWorkOperationEntity);
}
/*
** 转单
*/
@Override
public Boolean transferWork(BsWorkDTO bsWorkDTO){
//创建操作记录数据
BsWorkOperationEntity bsWorkOperationEntity = new BsWorkOperationEntity();
bsWorkOperationEntity.setHandleTime(new Date());
bsWorkOperationEntity.setHandler(bsWorkDTO.getLoginName());
bsWorkOperationEntity.setRemark("转派工单:"+bsWorkDTO.getRemark());
bsWorkOperationEntity.setWorkId(bsWorkDTO.getId());
bsWorkOperationEntity .setFilePath(bsWorkDTO.getFilePath());
//更新工单,并 保存操作记录
return updateById(bsWorkDTO) && bsWorkOperationService.save(bsWorkOperationEntity);
}
/*
** 获取工单详情
*/
@Override
public BsWorkVO getWorkDetail(String id,String loginName){
//获取工单详情
BsWorkEntity bsWorkEntity = getById(id);
BsWorkVO bsWorkVO = DozerUtils.convertBean( bsWorkEntity,BsWorkVO.class);
BsWorkLevelVO bsWorkLevelVO = bsWorkLevelService.queryByLevel(bsWorkEntity.getLevel());
bsWorkVO.setColor(bsWorkLevelVO.getColor());
//获取创建人name和处理人name
UserEntity userEntity = userService.getById( bsWorkEntity.getCreateBy());
bsWorkVO.setCreateByName(userEntity.getName());
UserEntity userEntity2 = userService.getById( bsWorkEntity.getHandleBy());
bsWorkVO.setHandleByName( userEntity2.getName());
//获取项目名称
BsProjectEntity projectEntity = bsProjectService.getById( bsWorkEntity.getProjectId());
bsWorkVO.setProjectName(projectEntity.getProjectName());
// 获取工单操作记录
List<BsWorkOperationEntity> bsWorkOperationEntities = bsWorkOperationService.queryOperationByWorkId(id);
bsWorkVO.setBsWorkOperationEntities(bsWorkOperationEntities);
if ("待处理".equals(bsWorkVO.getStatus())){
// 判断是否是创建人和处理人
if (loginName.equals(bsWorkVO.getCreateByName())&& loginName.equals(bsWorkVO.getHandleByName())){
bsWorkVO.setCloseFlag(1);
bsWorkVO.setHandleFlag(1);
bsWorkVO.setTransferFlag(1);
}
// 判断是否是创建人
else if (loginName.equals(bsWorkVO.getCreateByName())) {
bsWorkVO.setCloseFlag(1);
}
//判断是否是处理人
else if (loginName.equals(bsWorkVO.getHandleByName())) {
bsWorkVO.setHandleFlag(1);
bsWorkVO.setTransferFlag(1);
}
} else if ("待确认".equals(bsWorkVO.getStatus())) {
if (loginName.equals(DEPT_LEADER)){
bsWorkVO.setFinishFlag(1);
}
}
//如果都不是则不添加任何标记
return bsWorkVO;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment