Compare commits

...

2 Commits
master ... dev

Author SHA1 Message Date
许允枞
035d61cb33 更新 2024-11-15 17:46:37 +08:00
许允枞
4662ae356e 更新 2024-11-14 17:50:14 +08:00
14 changed files with 258 additions and 69 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

@ -63,7 +63,7 @@ public class InspectionInfoController extends BaseController {
/**
* 获取请填写功能名称详细信息
*/
@PreAuthorize("@ss.hasPermi('system:info:query')")
// @PreAuthorize("@ss.hasPermi('system:info:query')")
@GetMapping(value = "/{id}")
public CommonResult getInfo(@PathVariable("id") Long id) {
return success(inspectionInfoService.selectInspectionInfoById(id));
@ -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("接单成功");
}
/**
* 项目操作退办理重审项目完成
*
@ -229,4 +242,15 @@ public class InspectionInfoController extends BaseController {
inspectionWorkNode.setDealUserId(loginUser.getId());
return success(inspectionWorkNodeService.getRoyaltySum(inspectionWorkNode));
}
/**
* 重新审核
* @param inspectionWorkNode
* @return
*/
@PostMapping("recheck")
public CommonResult recheck(@RequestBody InspectionWorkNode inspectionWorkNode){
inspectionWorkNodeService.recheck(inspectionWorkNode);
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

@ -40,6 +40,8 @@ public class InspectionStepInfo extends Model<InspectionStepInfo> {
private Date updateTime;
//更新人id
private Integer updater;
//检测节点id
private String workNodeId;
@TableField(exist = false)
private String nickname;
}

View File

@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@ -98,4 +100,7 @@ public class InspectionWorkNode extends TenantBaseDO {
private String rescueStart;
@TableField(exist = false)
private String rescueEnd;
/*重检或复检时需要传*/
@TableField(exist = false)
private List<InspectionWorkNode> workNodes;
}

View File

@ -29,4 +29,12 @@ 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);
/**
* 批量修改检测状态
* @param workNodes
*/
void recheck(@Param("list") List<InspectionWorkNode> workNodes);
}

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
@ -47,4 +54,10 @@ public interface IInspectionWorkNodeService extends IService<InspectionWorkNode>
IPage<Map> getRoyaltyList(IPage page, InspectionWorkNode inspectionWorkNode);
Map getRoyaltySum(InspectionWorkNode inspectionWorkNode);
/**
* 重新检测
* @param workNodes
*/
void recheck(InspectionWorkNode workNodes);
}

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) {
@ -298,7 +300,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
ShopMallPartners partners = appInspectionPartnerService.shopInfo();
LambdaQueryWrapper<PartnerWorker> workerQueryWrapper = new LambdaQueryWrapper<>();
workerQueryWrapper.eq(PartnerWorker::getUserId, loginUser.getId()).eq(PartnerWorker::getPartnerId, partners.getPartnerId());
PartnerWorker worker = workerService.getOne(workerQueryWrapper);
// PartnerWorker worker = workerService.getOne(workerQueryWrapper);
AdminUserDO workerUser = userService.getUser(loginUser.getId());
// if (ObjectUtils.isNotEmpty(worker)) {
inspectionInfo.setWorkId(workerUser.getId());

View File

@ -96,21 +96,52 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
inspectionInfo.setWorkerPhone(workerUser.getMobile());
inspectionInfoService.updateById(inspectionInfo);
//新增步骤
//根据projectId查询项目名称
DlInspectionProject project = inspectionProjectService.getOne(new LambdaQueryWrapper<DlInspectionProject>()
.eq(DlInspectionProject::getId, workNode.getProjectId()));
InspectionStepInfo inspectionStepInfo = new InspectionStepInfo();
inspectionStepInfo.setInspectionInfoId(Integer.parseInt(String.valueOf(inspectionInfo.getId())));
if (ObjectUtil.isNotNull(project)) {
inspectionStepInfo.setTitle(project.getProjectName() + "项目开始检测");
} else {
inspectionStepInfo.setTitle("项目检测开始");
// //新增步骤
// //根据projectId查询项目名称
// DlInspectionProject project = inspectionProjectService.getOne(new LambdaQueryWrapper<DlInspectionProject>()
// .eq(DlInspectionProject::getId, workNode.getProjectId()));
//
// InspectionStepInfo inspectionStepInfo = new InspectionStepInfo();
// inspectionStepInfo.setInspectionInfoId(Integer.parseInt(String.valueOf(inspectionInfo.getId())));
// if (ObjectUtil.isNotNull(project)) {
// inspectionStepInfo.setTitle(project.getProjectName() + "项目开始检测");
// } else {
// inspectionStepInfo.setTitle("项目检测开始");
// }
// inspectionStepInfo.setCreateTime(DateUtil.date());
// inspectionStepInfo.setCreator(Integer.parseInt(String.valueOf(workerUser.getId())));
// inspectionStepService.save(inspectionStepInfo);
}
inspectionStepInfo.setCreateTime(DateUtil.date());
inspectionStepInfo.setCreator(Integer.parseInt(String.valueOf(workerUser.getId())));
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);
}
/**
@ -142,13 +173,19 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
//根据工单id查询工单
InspectionInfo inspectionInfo = inspectionInfoService.selectInspectionInfoById(workNode.getInspectionInfoId());
//判断是否是最后一个项目 根据工单id查询
//判断是否是还有项目完成 根据工单id查询
//根据工单id查询流程列表
LambdaQueryWrapper<InspectionWorkNode> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(InspectionWorkNode::getInspectionInfoId, workNode.getInspectionInfoId());
//是否还有进行中或者待开始的状态
queryWrapper.in(InspectionWorkNode::getStatus, "0","1");
List<InspectionWorkNode> inspectionWorkNodes = this.list(queryWrapper);
//判断当前是否是最后一个项目 根据顺序号判断
boolean flag = hasNextNode(inspectionWorkNodes, workNode);
boolean flag = true;
//判断是否是最后一个流程
if (inspectionWorkNodes.size() == 1 && inspectionWorkNodes.get(0).getId().equals(workNode.getId())){
flag = false;
}
// 插入步骤信息
InspectionStepInfo inspectionStepInfo = new InspectionStepInfo();
@ -169,6 +206,7 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
if (ObjectUtil.isNotEmpty(inspectionWorkNode.getDealImages())) {
inspectionStepInfo.setImages(inspectionWorkNode.getDealImages());
}
inspectionStepInfo.setWorkNodeId(workNode.getId());
inspectionStepInfo.setCreateTime(DateUtil.date());
inspectionStepInfo.setCreator(Integer.parseInt(String.valueOf(loginUser.getId())));
inspectionStepService.save(inspectionStepInfo);
@ -190,19 +228,20 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
inspectionStepInfo.setCreateTime(DateUtil.date());
inspectionStepInfo.setCreator(Integer.parseInt(String.valueOf(loginUser.getId())));
inspectionStepService.save(inspectionStepInfo);
} else {
//修改工单表当前流程
inspectionInfo.setNowOrderNum(workNode.getOrderNum() + 1);
//获取下一节点
InspectionWorkNode nextNode = getNextNode(inspectionWorkNodes, workNode);
/*给下一单人员发送信息*/
List<UserDTO> listByUserId = roleService.getListByUserId(nextNode.getRoleId());
List<Long> ids = listByUserId.stream().map(UserDTO::getId).collect(Collectors.toList());
if (ObjectUtil.isNotNull(inspectionInfo.getLeadManId())){
ids.add(inspectionInfo.getLeadManId());
}
sendSocketMessage(ids);
}
// else {
// //修改工单表当前流程
// inspectionInfo.setNowOrderNum(workNode.getOrderNum() + 1);
// //获取下一节点
// InspectionWorkNode nextNode = getNextNode(inspectionWorkNodes, workNode);
// /*给下一单人员发送信息*/
// List<UserDTO> listByUserId = roleService.getListByUserId(nextNode.getRoleId());
// List<Long> ids = listByUserId.stream().map(UserDTO::getId).collect(Collectors.toList());
// if (ObjectUtil.isNotNull(inspectionInfo.getLeadManId())){
// ids.add(inspectionInfo.getLeadManId());
// }
// sendSocketMessage(ids);
// }
//将节点状态改为已完成
inspectionWorkNode.setStatus("2");
@ -264,6 +303,38 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
return baseMapper.getRoyaltySum(inspectionWorkNode);
}
/**
* 重新检测
*
* @param workNodes
*/
@Override
public void recheck(InspectionWorkNode workNodes) {
//获取当前登陆人
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
//将传递过来的流程节点全部改为未进行
baseMapper.recheck(workNodes.getWorkNodes());
//将检测工单设置为重审
InspectionInfo info = inspectionInfoService.getById(workNodes.getInspectionInfoId());
info.setIsRetrial("1");
info.setIsPass("0");
//更新工单表
inspectionInfoService.updateById(info);
// 添加步骤信息表
InspectionStepInfo stepInfo = new InspectionStepInfo();
stepInfo.setInspectionInfoId(Integer.parseInt(workNodes.getInspectionInfoId().toString()));
stepInfo.setTitle("重审");
stepInfo.setCreateTime(DateUtil.date());
stepInfo.setCreator(Integer.parseInt(loginUser.getId().toString()));
if (ObjectUtil.isNotEmpty(workNodes.getRemark())) {
stepInfo.setContent(workNodes.getRemark());
}
if (ObjectUtil.isNotEmpty(workNodes.getDealImages())) {
stepInfo.setImages(workNodes.getDealImages());
}
inspectionStepService.save(stepInfo);
}
/**
* 判断传入的 InspectionWorkNode 对象是否在集合中有后续项目
*
@ -361,6 +432,7 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
// 添加步骤信息表
InspectionStepInfo stepInfo = new InspectionStepInfo();
stepInfo.setInspectionInfoId(Integer.parseInt(inspectionWorkNode.getInspectionInfoId().toString()));
stepInfo.setWorkNodeId(inspectionWorkNode.getId());
stepInfo.setTitle("重审");
if (ObjectUtil.isNotEmpty(inspectionWorkNode.getRemark())) {
stepInfo.setContent(inspectionWorkNode.getRemark());
@ -378,7 +450,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,20 @@
<?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>
<update id="recheck">
UPDATE inspection_work_node
SET status = '0', deal_user_id = null, deal_user_name = null, deal_images = null, remark = null
WHERE id in (
<foreach collection="list" item="item" separator=",">
#{item.id}
</foreach>
)
</update>
<select id="getWeorkNodesById" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode"
parameterType="java.lang.Integer">

View File

@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectInspectionInfoVo">
select id, inspection_order_id, work_id, worker_name, worker_phone, is_pass, status, start_time, end_time, year, month, day, create_time, creator, update_time, updater from inspection_info
select id,buy_name,buy_phone,user_address, inspection_order_id, work_id, worker_name, worker_phone, is_pass, status, start_time, end_time, year, month, day, create_time, creator, update_time, updater from inspection_info
</sql>
<select id="selectInspectionInfoList" parameterType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo" resultMap="InspectionInfoResult">
@ -45,8 +45,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectInspectionInfoById" parameterType="Long" resultMap="InspectionInfoResult">
<include refid="selectInspectionInfoVo"/>
where id = #{id}
select info.*,o.sku_name,o.sku_id,o.goods_id
from inspection_info info
left join order_info o on info.inspection_order_id = o.id
where info.id = #{id}
</select>
<insert id="insertInspectionInfo" parameterType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
@ -272,38 +274,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
iwn.id AS workNodeId,
iwn.status AS workNodeStatus,
oi.order_no AS orderNo,
oi.phonenumber AS buyPhone
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' -- 流程节点状态为待开始
<!-- 工单负责人或角色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},'%')
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
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}
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}
AND iwn.status = '2'
AND iwn.deal_user_id = #{inspectionInfo.dealUserId}
</if>
</where>
ORDER BY ii.create_time DESC
</select>
</select>
</mapper>