websocket方法调用(检测)
This commit is contained in:
parent
8b74bc9496
commit
fd94f59ee1
@ -8,11 +8,13 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
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.appBase.controller.admin.InspectionSocket;
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
||||
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
|
||||
import cn.iocoder.yudao.module.inspection.vo.DlInspectionWorkNodeVo;
|
||||
@ -21,6 +23,7 @@ import cn.iocoder.yudao.module.partner.service.IPartnerCustomerInfoService;
|
||||
import cn.iocoder.yudao.module.partner.service.IPartnerWorkerService;
|
||||
import cn.iocoder.yudao.module.payment.service.IOrderInfoDetailService;
|
||||
import cn.iocoder.yudao.module.payment.service.OrderInfoService;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
@ -86,6 +89,8 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
|
||||
private CustomerMainService customerMainService;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private InspectionSocket inspectionSocket;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
@ -234,6 +239,15 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
|
||||
});
|
||||
|
||||
workNodeService.saveBatch(inspectionWorkNodes);
|
||||
//获取第一个节点的角色
|
||||
Integer roleId = inspectionWorkNodes.get(0).getRoleId();
|
||||
//根据角色id获取所有用户
|
||||
List<UserDTO> listByUserId = roleService.getListByUserId(roleId);
|
||||
if (CollUtil.isNotEmpty(listByUserId)) {
|
||||
for (UserDTO userDTO : listByUserId) {
|
||||
inspectionSocket.sendMessage("接工单", userDTO.getId().toString());
|
||||
}
|
||||
}
|
||||
|
||||
//检测步骤表插入检测开始
|
||||
InspectionStepInfo stepInfo = new InspectionStepInfo();
|
||||
|
@ -1,9 +1,11 @@
|
||||
package cn.iocoder.yudao.module.inspection.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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.appBase.controller.admin.InspectionSocket;
|
||||
import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject;
|
||||
import cn.iocoder.yudao.module.inspection.entity.InspectionInfo;
|
||||
import cn.iocoder.yudao.module.inspection.entity.InspectionStepInfo;
|
||||
@ -13,7 +15,9 @@ 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.api.user.dto.UserDTO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
@ -23,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -44,6 +49,10 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
|
||||
private DlInspectionProjectService inspectionProjectService;
|
||||
@Autowired
|
||||
private InspectionStepInfoService inspectionStepService;
|
||||
@Autowired
|
||||
private InspectionSocket inspectionSocket;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
/**
|
||||
* 员工接单
|
||||
@ -95,7 +104,7 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
|
||||
inspectionStepInfo.setInspectionInfoId(Integer.parseInt(String.valueOf(inspectionInfo.getId())));
|
||||
if (ObjectUtil.isNotNull(project)) {
|
||||
inspectionStepInfo.setTitle(project.getProjectName() + "项目开始检测");
|
||||
}else {
|
||||
} else {
|
||||
inspectionStepInfo.setTitle("项目检测开始");
|
||||
}
|
||||
inspectionStepInfo.setCreateTime(DateUtil.date());
|
||||
@ -148,9 +157,9 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
|
||||
DlInspectionProject project = inspectionProjectService.getOne(new LambdaQueryWrapper<DlInspectionProject>()
|
||||
.eq(DlInspectionProject::getId, workNode.getProjectId()));
|
||||
String stepTitle = "";
|
||||
if(ObjectUtil.isNotNull(project)) {
|
||||
if (ObjectUtil.isNotNull(project)) {
|
||||
inspectionStepInfo.setTitle(project.getProjectName() + "项目检测完成");
|
||||
}else {
|
||||
} else {
|
||||
inspectionStepInfo.setTitle("项目检测完成");
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(inspectionWorkNode.getRemark())) {
|
||||
@ -183,6 +192,10 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
|
||||
} else {
|
||||
//修改工单表当前流程
|
||||
inspectionInfo.setNowOrderNum(workNode.getOrderNum() + 1);
|
||||
//获取下一节点
|
||||
InspectionWorkNode nextNode = getNextNode(inspectionWorkNodes, workNode);
|
||||
List<UserDTO> listByUserId = roleService.getListByUserId(nextNode.getRoleId());
|
||||
sendSocketMessage(listByUserId);
|
||||
}
|
||||
|
||||
//将节点状态改为已完成
|
||||
@ -193,6 +206,15 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
|
||||
inspectionInfoService.updateById(inspectionInfo);
|
||||
}
|
||||
|
||||
private InspectionWorkNode getNextNode(List<InspectionWorkNode> inspectionWorkNodes, InspectionWorkNode workNode) {
|
||||
for (InspectionWorkNode node : inspectionWorkNodes) {
|
||||
if (node.getOrderNum() == workNode.getOrderNum() + 1) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据检测id获取流程信息
|
||||
*
|
||||
@ -302,7 +324,7 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
|
||||
*
|
||||
* @param inspectionWorkNode
|
||||
*/
|
||||
public void retrial(InspectionWorkNode inspectionWorkNode) {
|
||||
public void retrial(InspectionWorkNode inspectionWorkNode){
|
||||
//通过流程节点id查询流程
|
||||
InspectionWorkNode workNode = this.getById(inspectionWorkNode.getId());
|
||||
//通过工单id获取工单
|
||||
@ -320,6 +342,11 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
|
||||
//跟新工单表
|
||||
inspectionInfoService.updateById(info);
|
||||
|
||||
//获取重审的节点的roleID
|
||||
Integer roleId = workNode.getRoleId();
|
||||
List<UserDTO> listByUserId = roleService.getListByUserId(roleId);
|
||||
sendSocketMessage(listByUserId);
|
||||
|
||||
// 添加步骤信息表
|
||||
InspectionStepInfo stepInfo = new InspectionStepInfo();
|
||||
stepInfo.setInspectionInfoId(Integer.parseInt(inspectionWorkNode.getInspectionInfoId().toString()));
|
||||
@ -332,4 +359,16 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
|
||||
}
|
||||
inspectionStepService.save(stepInfo);
|
||||
}
|
||||
|
||||
public void sendSocketMessage(List<UserDTO> listByUserId) {
|
||||
if (CollUtil.isNotEmpty(listByUserId)) {
|
||||
for (UserDTO userDTO : listByUserId) {
|
||||
try {
|
||||
inspectionSocket.sendMessage("接工单", userDTO.getId().toString());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -42,4 +42,6 @@ public interface UserRoleMapper extends BaseMapperX<UserRoleDO> {
|
||||
List<UserDTO> selectByRoleCode(@Param("tenantId") Long tenantId, @Param("roleCode") String roleCode);
|
||||
|
||||
IPage<UserDTO> selectListByRoleId(@Param("page") Page<UserDTO> page,@Param("role") RolePageReqVO role);
|
||||
|
||||
List<UserDTO> selectByRoleId(Integer roleId);
|
||||
}
|
||||
|
@ -175,4 +175,11 @@ public interface RoleService {
|
||||
* @return
|
||||
*/
|
||||
List<UserRoleDO> getByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色id查询用户
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
List<UserDTO> getListByUserId(Integer roleId);
|
||||
}
|
||||
|
@ -372,6 +372,18 @@ public class RoleServiceImpl implements RoleService {
|
||||
return userRoleDOS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色id查询用户
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<UserDTO> getListByUserId(Integer roleId) {
|
||||
List<UserDTO> userDTOS = userRoleMapper.selectByRoleId(roleId);
|
||||
return userDTOS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得自身的代理对象,解决 AOP 生效问题
|
||||
*
|
||||
|
@ -35,4 +35,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectByRoleId" resultType="cn.iocoder.yudao.module.system.api.user.dto.UserDTO">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
system_users
|
||||
WHERE
|
||||
id IN (
|
||||
SELECT
|
||||
user_id
|
||||
FROM
|
||||
system_user_role sur
|
||||
WHERE
|
||||
sur.role_id = #{roleId})
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user