This commit is contained in:
许允枞 2024-11-14 17:50:14 +08:00
parent 5179cbb013
commit 4662ae356e
12 changed files with 143 additions and 36 deletions

View File

@ -9,7 +9,11 @@ import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;
/**`1
@ -88,12 +92,36 @@ public class InspectionSocket {
* 发送给指定的用户
* @param message
*/
public void sendMessage(String message, String userId) throws IOException {
if (sessionMap.containsKey(userId)){
private final Map<String, BlockingQueue<String>> messageQueueMap = new ConcurrentHashMap<>();
public void sendMessage(String message, String userId) {
if (sessionMap.containsKey(userId)) {
Session session = sessionMap.get(userId);
session.getAsyncRemote().sendText(message);
messageQueueMap.putIfAbsent(userId, new LinkedBlockingQueue<>());
// 将消息加入用户的队列
messageQueueMap.get(userId).offer(message);
// 异步处理消息队列
processQueue(session, userId);
}
}
private void processQueue(Session session, String userId) {
BlockingQueue<String> queue = messageQueueMap.get(userId);
CompletableFuture.runAsync(() -> {
String nextMessage;
while ((nextMessage = queue.poll()) != null) {
session.getAsyncRemote().sendText(nextMessage, result -> {
if (!result.isOK()) {
System.err.println("Message sending failed for user: " + userId);
}
});
}
});
}
}

View File

@ -137,6 +137,19 @@ public class InspectionInfoController extends BaseController {
return success("接单成功");
}
/**
* 员工取消接单
*
* @param inspectionId 工单id
* @param workNodeId 节点id geStelectInspection这个方法中返回了
* @return
*/
@PostMapping("cancelAnOrder")
public CommonResult cancelAnOrder(Integer inspectionId, String workNodeId) {
inspectionWorkNodeService.cancelAnOrder(inspectionId, workNodeId);
return success("接单成功");
}
/**
* 项目操作退办理重审项目完成
*

View File

@ -539,8 +539,9 @@ public class PartnerOwnController extends BaseController {
@RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum,
@RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) {
LoginUser user = SecurityFrameworkUtils.getLoginUser();
// .eq(PartnerWorker::getUserId,user.getId())
LambdaQueryWrapper<PartnerWorker> queryWrapper =new LambdaQueryWrapper<>();
queryWrapper.eq(PartnerWorker::getUserId,user.getId()).eq(PartnerWorker::getPartnerId,partnerId);
queryWrapper.eq(PartnerWorker::getPartnerId,partnerId);
PartnerWorker worker = partnerWorkerService.getOne(queryWrapper);
if (ObjectUtil.isEmpty(worker)){
return null;

View File

@ -161,4 +161,6 @@ public class InspectionInfo extends TenantBaseDO
private String workNodeStatus;
@TableField(exist = false)
private String selectType;
@TableField(exist = false)
private String projectName;
}

View File

@ -29,4 +29,6 @@ public interface InspectionWorkNodeMapper extends BaseMapper<InspectionWorkNode>
IPage<Map> getRoyaltyList(@Param("page")IPage page,@Param("inspectionWorkNode") InspectionWorkNode inspectionWorkNode);
Map getRoyaltySum(@Param("inspectionWorkNode") InspectionWorkNode inspectionWorkNode);
void cancelAnOrder(InspectionWorkNode workNode);
}

View File

@ -23,6 +23,13 @@ public interface IInspectionWorkNodeService extends IService<InspectionWorkNode>
*/
void updateInspectionWorkNode(Integer inspectionId, String workNodeId);
/**
* 员工取消接单
* @param inspectionId
* @param workNodeId
*/
void cancelAnOrder(Integer inspectionId, String workNodeId);
/**
* 更新流程图片 步骤信息
* @param inspectionWorkNode

View File

@ -119,6 +119,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
private RoleService roleService;
@Autowired
private AdminUserService adminUserService;
@Autowired
private IInspectionWorkNodeService inspectionWorkNodeService;
@Override
public IPage<PartnerListVo> partnerList(Page<PartnerListVo> page, PartnerListQuery partnerListQuery) {
@ -1495,6 +1497,9 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
}
ShopInspectionCategory category = categoryService.getById(info.getCategoryId());
res.setCarType(category.getCategoryName());
// 查询节点表
List<InspectionWorkNode> workNodes = inspectionWorkNodeService.getWeorkNodesById(Integer.parseInt(String.valueOf(inspectionInfoId)));
res.setWorkNodes(workNodes);
return res;
}

View File

@ -251,6 +251,8 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
if (ObjectUtil.isNotNull(inspectionInfo.getLeadManId())) {
ids.add(inspectionInfo.getLeadManId());
}
//给ids去重
ids = ids.stream().distinct().collect(Collectors.toList());
// 获取当前共单引车员的id
if (CollUtil.isNotEmpty(ids)) {
for (Long id : ids) {

View File

@ -113,6 +113,37 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
inspectionStepService.save(inspectionStepInfo);
}
/**
* 员工取消接单
*
* @param inspectionId
* @param workNodeId
*/
@Override
public void cancelAnOrder(Integer inspectionId, String 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 (!workNode.getDealUserId().equals(workerUser.getId())) {
throw new RuntimeException("当前流程不是你接单的");
}
// 更新流程
// this.updateById(workNode);
baseMapper.cancelAnOrder(workNode);
}
/**
* 更新流程图片 步骤信息
*
@ -378,7 +409,7 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
for (Long userId : userIds) {
try {
inspectionSocket.sendMessage("接工单", userId.toString());
} catch (IOException e) {
} catch (Exception e) {
throw new RuntimeException(e);
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.inspection.vo;
import cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import cn.iocoder.yudao.annotation.Excel;
@ -85,4 +86,6 @@ public class InspectionInfoVo {
/*引车员名字*/
private String leadManName;
@TableField(exist = false)
List<InspectionWorkNode> workNodes;
}

View File

@ -1,6 +1,11 @@
<?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="cn.iocoder.yudao.module.inspection.mapper.InspectionWorkNodeMapper">
<update id="cancelAnOrder">
UPDATE inspection_work_node
SET status = '0', deal_user_id = null, deal_user_name = null, deal_images = null, remark = null
WHERE id = #{id} AND inspection_info_id = #{inspectionInfoId}
</update>
<select id="getWeorkNodesById" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode"
parameterType="java.lang.Integer">

View File

@ -267,43 +267,51 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by ins.start_time desc
</select>
<select id="selectByUser" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
SELECT
SELECT
ii.*,
iwn.id AS workNodeId,
iwn.status AS workNodeStatus,
oi.order_no AS orderNo,
oi.phonenumber AS buyPhone
FROM
oi.phonenumber AS buyPhone,
ip.project_name AS projectName
FROM
inspection_info ii
JOIN
LEFT JOIN
inspection_work_node iwn ON ii.id = iwn.inspection_info_id
JOIN order_info oi ON ii.inspection_order_id = oi.id
LEFT JOIN
order_info oi ON ii.inspection_order_id = oi.id
LEFT JOIN
inspection_project ip ON iwn.project_id = ip.id
<where>
-- ii.status = '0' -- 工单正在进行中
-- ii.now_order_num = iwn.order_num -- 当前工单步骤与流程节点顺序一致
-- AND iwn.status = '0' -- 流程节点状态为待开始
(ii.lead_man_id = #{inspectionInfo.leadManId}
OR iwn.role_id IN
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
#{roleId}
</foreach>)
<if test="inspectionInfo.carNum != null">
AND ii.car_num like concat('%',#{inspectionInfo.carNum},'%')
</if>
-- 待接受
<if test="inspectionInfo.status == 1">
AND ii.status = '0' AND iwn.status = '0' AND ii.now_order_num = iwn.order_num
</if>
-- 进行中
<if test="inspectionInfo.status == 2">
AND ii.status = '0' AND iwn.status = '1' AND iwn.deal_user_id = #{inspectionInfo.dealUserId}
</if>
-- 已完成
<if test="inspectionInfo.status == 3">
AND iwn.status = '2' AND iwn.deal_user_id = #{inspectionInfo.dealUserId}
</if>
</where>
ORDER BY ii.create_time DESC
<!-- 工单负责人或角色ID匹配 -->
(ii.lead_man_id = #{inspectionInfo.leadManId}
OR iwn.role_id IN
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
#{roleId}
</foreach>)
<!-- 车牌号模糊查询 -->
<if test="inspectionInfo.carNum != null">
AND ii.car_num LIKE CONCAT('%', #{inspectionInfo.carNum}, '%')
</if>
<!-- 待接受 -->
<if test="inspectionInfo.status == 1">
AND ii.status = '0'
AND iwn.status = '0'
-- AND ii.now_order_num = iwn.order_num
</if>
<!-- 进行中 -->
<if test="inspectionInfo.status == 2">
AND ii.status = '0'
AND iwn.status = '1'
AND iwn.deal_user_id = #{inspectionInfo.dealUserId}
</if>
<!-- 已完成 -->
<if test="inspectionInfo.status == 3">
AND iwn.status = '2'
AND iwn.deal_user_id = #{inspectionInfo.dealUserId}
</if>
</where>
ORDER BY ii.create_time DESC
</select>
</select>
</mapper>