检测相关功能
This commit is contained in:
parent
a83b5985ff
commit
2e3c202b73
@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.inspection.entity.InspectionInfo;
|
||||
import cn.iocoder.yudao.module.inspection.service.IInspectionInfoService;
|
||||
import cn.iocoder.yudao.module.inspection.service.IInspectionWorkNodeService;
|
||||
import cn.iocoder.yudao.util.ExcelUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -27,6 +28,9 @@ public class InspectionInfoController extends BaseController
|
||||
@Autowired
|
||||
private IInspectionInfoService inspectionInfoService;
|
||||
|
||||
@Autowired
|
||||
private IInspectionWorkNodeService inspectionWorkNodeService;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*/
|
||||
@ -102,7 +106,32 @@ public class InspectionInfoController extends BaseController
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("geStelectInspection")
|
||||
public CommonResult geStelectInspection(){
|
||||
return success(inspectionInfoService.geStelectInspection());
|
||||
public CommonResult geStelectInspection(@RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize){
|
||||
Page<InspectionInfo> page = new Page<>(pageNum, pageSize);
|
||||
return success(inspectionInfoService.geStelectInspection(page));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工单详情
|
||||
* @param inspectionId 工单id
|
||||
* @param workNodeId 节点id (geStelectInspection这个方法中返回了)
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getInspectionInfo")
|
||||
public CommonResult getInspectionInfo(Integer inspectionId, Integer workNodeId){
|
||||
return success(inspectionInfoService.getWorkNode(inspectionId,workNodeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 员工接单
|
||||
* @param inspectionId 工单id
|
||||
* @param workNodeId 节点id (geStelectInspection这个方法中返回了)
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("orderTaking")
|
||||
public CommonResult orderTaking(Integer inspectionId, Integer workNodeId){
|
||||
inspectionWorkNodeService.updateInspectionWorkNode(inspectionId,workNodeId);
|
||||
return success("接单成功");
|
||||
}
|
||||
}
|
||||
|
@ -148,6 +148,9 @@ public class InspectionInfo extends TenantBaseDO
|
||||
private Integer nowOrderNum;
|
||||
|
||||
/** 开始检测时需要 传入 选择项目的id、角色id、排序 */
|
||||
@TableField(exist = false)
|
||||
private List<InspectionWorkNode> inspectionWorkNodes;
|
||||
/** 流程节点id*/
|
||||
@TableField(exist = false)
|
||||
private String workNodeId;
|
||||
}
|
||||
|
@ -75,7 +75,18 @@ public class InspectionWorkNode extends TenantBaseDO {
|
||||
/**
|
||||
* 处理人员工表id
|
||||
*/
|
||||
private Integer dealUserId;
|
||||
private Long dealUserId;
|
||||
|
||||
/**
|
||||
* 状态(0-待开始 1-进行中 2-已完成)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
|
||||
/**
|
||||
* 1-退办理 2-选择重审 3-项目完成
|
||||
*/
|
||||
private Integer selectType;
|
||||
|
||||
|
||||
}
|
||||
|
@ -87,4 +87,10 @@ public interface InspectionInfoMapper extends BaseMapper<InspectionInfo>
|
||||
, @Param("roleId") Long roleId, @Param("endTime")String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 查询当前用户符合条件的工单
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
IPage<InspectionInfo> selectByUser(@Param("page") IPage page, @Param("roleIds") List<Long> roleIds);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.inspection.service;
|
||||
|
||||
import cn.iocoder.yudao.module.inspection.vo.DlInspectionWorkNodeVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
@ -79,5 +80,12 @@ public interface IInspectionInfoService extends IService<InspectionInfo>
|
||||
* 根据当前登陆人获取可以选择的工单
|
||||
* @return
|
||||
*/
|
||||
List<InspectionInfo> geStelectInspection();
|
||||
IPage<InspectionInfo> geStelectInspection(IPage page);
|
||||
|
||||
/**
|
||||
* 获取工单详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
DlInspectionWorkNodeVo getWorkNode(Integer inspectionId, Integer workNodeId);
|
||||
}
|
||||
|
@ -12,5 +12,17 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
* @since 2024-10-31
|
||||
*/
|
||||
public interface IInspectionWorkNodeService extends IService<InspectionWorkNode> {
|
||||
/**
|
||||
* 员工接单
|
||||
* @param inspectionId
|
||||
* @param workNodeId
|
||||
*/
|
||||
void updateInspectionWorkNode(Integer inspectionId, Integer workNodeId);
|
||||
|
||||
/**
|
||||
* 更新流程图片 步骤信息
|
||||
* @param inspectionWorkNode
|
||||
*/
|
||||
void updateImageAndStep(InspectionWorkNode inspectionWorkNode);
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
||||
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
|
||||
import cn.iocoder.yudao.module.inspection.vo.DlInspectionWorkNodeVo;
|
||||
import cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo;
|
||||
import cn.iocoder.yudao.module.partner.service.IPartnerCustomerInfoService;
|
||||
import cn.iocoder.yudao.module.partner.service.IPartnerWorkerService;
|
||||
@ -234,7 +235,13 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
|
||||
//补充检测流程
|
||||
List<InspectionWorkNode> inspectionWorkNodes = inspectionInfo.getInspectionWorkNodes();
|
||||
//将检测工单流程补充检测工单id
|
||||
inspectionWorkNodes.stream().forEach(inspectionWorkNode -> inspectionWorkNode.setInspectionInfoId(inspectionInfo.getId()));
|
||||
inspectionWorkNodes.stream().forEach(inspectionWorkNode -> {
|
||||
//检测工单id
|
||||
inspectionWorkNode.setInspectionInfoId(inspectionInfo.getId());
|
||||
//将节点状态设置为未开始
|
||||
inspectionWorkNode.setStatus("0");
|
||||
});
|
||||
|
||||
workNodeService.saveBatch(inspectionWorkNodes);
|
||||
|
||||
//检测步骤表插入检测开始
|
||||
@ -368,47 +375,40 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
|
||||
/**
|
||||
* 根据当前登陆人获取可以选择的工单
|
||||
*
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<InspectionInfo> geStelectInspection() {
|
||||
public IPage<InspectionInfo> geStelectInspection(IPage page) {
|
||||
//获取当前登录人
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
//获取当前登陆人的角色
|
||||
List<UserRoleDO> byUserId = roleService.getByUserId(loginUser.getId());
|
||||
List<Long> roleIds = byUserId.stream().map(UserRoleDO::getRoleId).collect(Collectors.toList());
|
||||
//查询所有工单为进行中的
|
||||
List<InspectionInfo> inspectionInfos = baseMapper.selectList(new LambdaQueryWrapper<InspectionInfo>()
|
||||
.eq(InspectionInfo::getStatus, 0));
|
||||
//根据工单id查询工单流程节点
|
||||
List<Long> infoIds = inspectionInfos.stream().map(inspectionInfo -> inspectionInfo.getId()).collect(Collectors.toList());
|
||||
if (ObjectUtils.isNotEmpty(infoIds)) {
|
||||
List<InspectionWorkNode> inspectionWorkNodes = workNodeService.list(new LambdaQueryWrapper<InspectionWorkNode>()
|
||||
.in(InspectionWorkNode::getInspectionInfoId, infoIds)
|
||||
.eq(InspectionWorkNode::getDealUserId, null));
|
||||
return baseMapper.selectByUser(page,roleIds);
|
||||
}
|
||||
|
||||
//工单集合
|
||||
List<InspectionInfo> inspectionInfoList = new ArrayList<>();
|
||||
/**
|
||||
* 获取工单详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DlInspectionWorkNodeVo getWorkNode(Integer inspectionId, Integer workNodeId) {
|
||||
//查询工单
|
||||
InspectionInfo inspectionInfo = this.getById(inspectionId);
|
||||
//根据工单id查询流程节点
|
||||
InspectionWorkNode inspectionWorkNode = workNodeService.getById(new LambdaQueryWrapper<InspectionWorkNode>()
|
||||
.eq(InspectionWorkNode::getInspectionInfoId, workNodeId));
|
||||
//根据工单id查询步骤
|
||||
List<InspectionStepInfo> inspectionStepInfos = inspectionStepInfoService.list(new LambdaQueryWrapper<InspectionStepInfo>()
|
||||
.eq(InspectionStepInfo::getInspectionInfoId, inspectionId));
|
||||
|
||||
//根据工单id查询工单流程节点
|
||||
Map<Long, List<InspectionWorkNode>> inspectionWorkNodeMap = inspectionWorkNodes.stream().collect(Collectors.groupingBy(InspectionWorkNode::getInspectionInfoId));
|
||||
for (InspectionInfo inspectionInfo : inspectionInfos) {
|
||||
List<InspectionWorkNode> inspectionWorkNodeList = inspectionWorkNodeMap.get(inspectionInfo.getId());
|
||||
//遍历工单流程节点 流程为key
|
||||
if (CollectionUtil.isNotEmpty(inspectionWorkNodeList)) {
|
||||
Map<Integer, InspectionWorkNode> inspectionWorkMap = inspectionWorkNodeList.stream().collect(Collectors.toMap(InspectionWorkNode::getOrderNum, item -> item));
|
||||
InspectionWorkNode inspectionWorkNode = inspectionWorkMap.get(inspectionInfo.getNowOrderNum());
|
||||
if (inspectionWorkNode != null){
|
||||
//判断当前项目 当前登录人员 是否可以处理
|
||||
if (roleIds.contains(inspectionWorkNode.getRoleId())){
|
||||
inspectionInfo.setWorkNodeId(inspectionWorkNode.getId());
|
||||
inspectionInfoList.add(inspectionInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return inspectionInfoList;
|
||||
}
|
||||
return null;
|
||||
DlInspectionWorkNodeVo dlInspectionWorkNodeVo = new DlInspectionWorkNodeVo();
|
||||
dlInspectionWorkNodeVo.setInspectionInfo(inspectionInfo);
|
||||
dlInspectionWorkNodeVo.setNode(inspectionWorkNode);
|
||||
dlInspectionWorkNodeVo.setSteps(inspectionStepInfos);
|
||||
return dlInspectionWorkNodeVo;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,27 @@
|
||||
package cn.iocoder.yudao.module.inspection.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject;
|
||||
import cn.iocoder.yudao.module.inspection.entity.InspectionInfo;
|
||||
import cn.iocoder.yudao.module.inspection.entity.InspectionStepInfo;
|
||||
import cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode;
|
||||
import cn.iocoder.yudao.module.inspection.mapper.InspectionWorkNodeMapper;
|
||||
import cn.iocoder.yudao.module.inspection.service.DlInspectionProjectService;
|
||||
import cn.iocoder.yudao.module.inspection.service.IInspectionInfoService;
|
||||
import cn.iocoder.yudao.module.inspection.service.IInspectionWorkNodeService;
|
||||
import cn.iocoder.yudao.module.inspection.service.InspectionStepInfoService;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 检测流程表 服务实现类
|
||||
@ -16,5 +32,122 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNodeMapper, InspectionWorkNode> implements IInspectionWorkNodeService {
|
||||
@Autowired
|
||||
private IInspectionInfoService inspectionInfoService;
|
||||
@Autowired
|
||||
private AdminUserService userService;
|
||||
@Autowired
|
||||
private DlInspectionProjectService inspectionProjectService;
|
||||
@Autowired
|
||||
private InspectionStepInfoService inspectionStepService;
|
||||
|
||||
}
|
||||
/**
|
||||
* 员工接单
|
||||
* @param inspectionId
|
||||
* @param workNodeId
|
||||
*/
|
||||
@Override
|
||||
public void updateInspectionWorkNode(Integer inspectionId, Integer workNodeId) {
|
||||
//获取当前登录人
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
//当前登陆人 就是检测人
|
||||
AdminUserDO workerUser = userService.getUser(loginUser.getId());
|
||||
//根据工单id获取工单
|
||||
InspectionInfo inspectionInfo = inspectionInfoService.getById(inspectionId);
|
||||
if (ObjectUtil.isNull(inspectionInfo)) {
|
||||
throw new RuntimeException("工单不存在");
|
||||
}
|
||||
//根据流程id获取流程
|
||||
InspectionWorkNode workNode = this.getById(workNodeId);
|
||||
if (ObjectUtil.isNull(workNode)) {
|
||||
throw new RuntimeException("流程不存在");
|
||||
}
|
||||
//判断当前流程是否已被接单
|
||||
if (ObjectUtil.isNotNull(workNode.getDealUserId())) {
|
||||
throw new RuntimeException("当前流程已被接单");
|
||||
}
|
||||
//修改流程相关信息
|
||||
workNode.setDealUserId(workerUser.getId());
|
||||
workNode.setDealUserName(workerUser.getNickname());
|
||||
workNode.setStatus("1");
|
||||
//更新
|
||||
this.updateById(workNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新流程图片 步骤信息
|
||||
*
|
||||
* @param inspectionWorkNode
|
||||
*/
|
||||
@Override
|
||||
public void updateImageAndStep(InspectionWorkNode inspectionWorkNode) {
|
||||
//根据流程id获取流程
|
||||
InspectionWorkNode workNode = this.getById(inspectionWorkNode.getId());
|
||||
|
||||
//根据工单id查询工单
|
||||
InspectionInfo inspectionInfo = inspectionInfoService.selectInspectionInfoById(inspectionWorkNode.getInspectionInfoId());
|
||||
|
||||
//判断是否是最后一个项目 根据工单id查询
|
||||
//根据工单id查询流程列表
|
||||
LambdaQueryWrapper<InspectionWorkNode> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(InspectionWorkNode::getInspectionInfoId, inspectionWorkNode.getInspectionInfoId());
|
||||
List<InspectionWorkNode> inspectionWorkNodes = this.list(queryWrapper);
|
||||
//判断当前是否是最后一个项目 根据顺序号判断
|
||||
boolean flag = hasNextNode(inspectionWorkNodes, workNode);
|
||||
|
||||
// 插入步骤信息
|
||||
InspectionStepInfo inspectionStepInfo = new InspectionStepInfo();
|
||||
inspectionStepInfo.setInspectionInfoId(Integer.parseInt(String.valueOf(inspectionWorkNode.getInspectionInfoId())));
|
||||
|
||||
//根据projectId查询项目名称
|
||||
DlInspectionProject project = inspectionProjectService.getOne(new LambdaQueryWrapper<DlInspectionProject>()
|
||||
.eq(DlInspectionProject::getId, inspectionWorkNode.getProjectId()));
|
||||
String stepTitle = project.getProjectName() + "项目检测完成";
|
||||
inspectionStepInfo.setTitle(stepTitle);
|
||||
inspectionStepInfo.setContent(inspectionWorkNode.getDealImages());
|
||||
inspectionStepService.save(inspectionStepInfo);
|
||||
if (!flag) {
|
||||
stepTitle = "检测结束";
|
||||
//设置工单状态为已完成
|
||||
inspectionInfo.setStatus("1");
|
||||
//设置工单通过
|
||||
inspectionInfo.setIsPass("1");
|
||||
//设置工单结束时间
|
||||
inspectionInfo.setEndTime(DateUtil.date());
|
||||
|
||||
//步骤结束
|
||||
inspectionStepInfo = new InspectionStepInfo();
|
||||
inspectionStepInfo.setTitle(stepTitle);
|
||||
inspectionStepService.save(inspectionStepInfo);
|
||||
} else {
|
||||
//修改工单表当前流程
|
||||
inspectionInfo.setNowOrderNum(workNode.getOrderNum() + 1);
|
||||
}
|
||||
|
||||
//将节点状态改为已完成
|
||||
inspectionWorkNode.setStatus("2");
|
||||
//更新流程节点表
|
||||
baseMapper.updateById(inspectionWorkNode);
|
||||
//更细工单状态
|
||||
inspectionInfoService.updateById(inspectionInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断传入的 InspectionWorkNode 对象是否在集合中有后续项目
|
||||
*
|
||||
* @param nodes InspectionWorkNode 对象的集合
|
||||
* @param currentNode 当前需要判断的 InspectionWorkNode 对象
|
||||
* @return 如果存在后续项目返回 true,否则返回 false
|
||||
*/
|
||||
public boolean hasNextNode(List<InspectionWorkNode> nodes, InspectionWorkNode currentNode) {
|
||||
int currentOrderNum = currentNode.getOrderNum();
|
||||
|
||||
// 遍历集合中的所有节点,检查是否有 orderNum 大于当前节点的
|
||||
for (InspectionWorkNode node : nodes) {
|
||||
if (node.getOrderNum() > currentOrderNum) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.inspection.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.inspection.entity.InspectionInfo;
|
||||
import cn.iocoder.yudao.module.inspection.entity.InspectionStepInfo;
|
||||
import cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DlInspectionWorkNodeVo {
|
||||
/**
|
||||
* 检测单
|
||||
*/
|
||||
private InspectionInfo inspectionInfo;
|
||||
/**
|
||||
* 流程节点
|
||||
*/
|
||||
private InspectionWorkNode node;
|
||||
/**
|
||||
* 步骤
|
||||
*/
|
||||
private List<InspectionStepInfo> steps;
|
||||
}
|
@ -266,4 +266,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
order by ins.start_time desc
|
||||
</select>
|
||||
<select id="selectByUser" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
|
||||
SELECT
|
||||
ii.*,
|
||||
iwn.id AS workNodeId
|
||||
FROM
|
||||
inspection_info ii
|
||||
JOIN
|
||||
inspection_work_node iwn ON ii.id = iwn.inspection_info_id
|
||||
WHERE
|
||||
ii.status = '0' -- 工单正在进行中
|
||||
AND ii.now_order_num = iwn.order_num -- 当前工单步骤与流程节点顺序一致
|
||||
AND iwn.status = '0' -- 流程节点状态为待开始
|
||||
AND iwn.role_id IN
|
||||
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user