|
@ -3,8 +3,10 @@ package com.epmet.service.impl; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.epmet.LingShanAgentServiceProcessStatusEnum; |
|
|
import com.epmet.LingShanAgentServiceProcessStatusEnum; |
|
|
|
|
|
import com.epmet.commons.tools.distributedlock.DistributedLock; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; |
|
|
import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; |
|
@ -24,6 +26,7 @@ import com.epmet.service.LingShanAgentServiceService; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.redisson.api.RLock; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
@ -41,6 +44,11 @@ public class LingShanAgentServiceServiceImpl implements LingShanAgentServiceServ |
|
|
@Autowired |
|
|
@Autowired |
|
|
private LingshanAgentServiceRecordDao agentServiceRecordDao; |
|
|
private LingshanAgentServiceRecordDao agentServiceRecordDao; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private DistributedLock distributedLock; |
|
|
|
|
|
|
|
|
|
|
|
public static final String AGENT_SERVICE_LOCK_PREFIX = "lingshan:agentservice:statuschange:"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void resiSubmit(AgentServiceResiSubmitFormDTO form) { |
|
|
public void resiSubmit(AgentServiceResiSubmitFormDTO form) { |
|
@ -104,8 +112,10 @@ public class LingShanAgentServiceServiceImpl implements LingShanAgentServiceServ |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "【代办服务】未找到指定的服务信息,ID:" + id); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "【代办服务】未找到指定的服务信息,ID:" + id); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RLock lock = distributedLock.getLock(AGENT_SERVICE_LOCK_PREFIX + id); |
|
|
|
|
|
try { |
|
|
// 执行状态变更校验
|
|
|
// 执行状态变更校验
|
|
|
statusChangeValid(service.getProcessStatus(), processType); |
|
|
statusChangeCheck(service.getProcessStatus(), processType); |
|
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
@ -117,6 +127,15 @@ public class LingShanAgentServiceServiceImpl implements LingShanAgentServiceServ |
|
|
e2Update.setProcessTime(now); |
|
|
e2Update.setProcessTime(now); |
|
|
|
|
|
|
|
|
agentServiceRecordDao.updateById(e2Update); |
|
|
agentServiceRecordDao.updateById(e2Update); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("【待办服务】办结:分布式锁错误:" + ExceptionUtils.getErrorStackTrace(e)); |
|
|
|
|
|
throw e; |
|
|
|
|
|
} finally { |
|
|
|
|
|
// 释放锁
|
|
|
|
|
|
if (lock.isHeldByCurrentThread()) { |
|
|
|
|
|
lock.unlock(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -126,9 +145,12 @@ public class LingShanAgentServiceServiceImpl implements LingShanAgentServiceServ |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "【代办服务】未找到指定的服务信息,ID:" + id); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "【代办服务】未找到指定的服务信息,ID:" + id); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RLock lock = distributedLock.getLock(AGENT_SERVICE_LOCK_PREFIX + id); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
// 执行状态变更校验
|
|
|
// 执行状态变更校验
|
|
|
LingShanAgentServiceProcessStatusEnum closeStatusEnum = LingShanAgentServiceProcessStatusEnum.CLOSED; |
|
|
LingShanAgentServiceProcessStatusEnum closeStatusEnum = LingShanAgentServiceProcessStatusEnum.CLOSED; |
|
|
statusChangeValid(service.getProcessStatus(), closeStatusEnum.getStatusCode()); |
|
|
statusChangeCheck(service.getProcessStatus(), closeStatusEnum.getStatusCode()); |
|
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
@ -140,6 +162,15 @@ public class LingShanAgentServiceServiceImpl implements LingShanAgentServiceServ |
|
|
e2Update.setCloseTime(now); |
|
|
e2Update.setCloseTime(now); |
|
|
|
|
|
|
|
|
agentServiceRecordDao.updateById(e2Update); |
|
|
agentServiceRecordDao.updateById(e2Update); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("【待办服务】办结:分布式锁错误:" + ExceptionUtils.getErrorStackTrace(e)); |
|
|
|
|
|
throw e; |
|
|
|
|
|
} finally { |
|
|
|
|
|
// 释放锁
|
|
|
|
|
|
if (lock.isHeldByCurrentThread()) { |
|
|
|
|
|
lock.unlock(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -150,7 +181,7 @@ public class LingShanAgentServiceServiceImpl implements LingShanAgentServiceServ |
|
|
* @author: WangXianZhang |
|
|
* @author: WangXianZhang |
|
|
* @date: 2023/5/9 1:57 PM |
|
|
* @date: 2023/5/9 1:57 PM |
|
|
*/ |
|
|
*/ |
|
|
private void statusChangeValid(Integer oldStatus, Integer newStatus) { |
|
|
private void statusChangeCheck(Integer oldStatus, Integer newStatus) { |
|
|
if (newStatus.intValue() == LingShanAgentServiceProcessStatusEnum.WITHDRAW.getStatusCode() |
|
|
if (newStatus.intValue() == LingShanAgentServiceProcessStatusEnum.WITHDRAW.getStatusCode() |
|
|
&& oldStatus.intValue() != LingShanAgentServiceProcessStatusEnum.WAIT_ACCEPT.getStatusCode()) { |
|
|
&& oldStatus.intValue() != LingShanAgentServiceProcessStatusEnum.WAIT_ACCEPT.getStatusCode()) { |
|
|
// 只有待处理状态,才能撤回
|
|
|
// 只有待处理状态,才能撤回
|
|
@ -170,4 +201,50 @@ public class LingShanAgentServiceServiceImpl implements LingShanAgentServiceServ |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, String.format("【代办服务】当前状态为'%s',不允许操作", LingShanAgentServiceProcessStatusEnum.getByStatus(oldStatus).getStatusName())); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, String.format("【代办服务】当前状态为'%s',不允许操作", LingShanAgentServiceProcessStatusEnum.getByStatus(oldStatus).getStatusName())); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void resiWithDraw(String id) { |
|
|
|
|
|
LingshanAgentServiceRecordEntity service; |
|
|
|
|
|
if ((service = agentServiceRecordDao.selectById(id)) == null) { |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "【代办服务】未找到指定的服务信息,ID:" + id); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RLock lock = distributedLock.getLock(AGENT_SERVICE_LOCK_PREFIX + id); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
// 状态检查
|
|
|
|
|
|
statusChangeCheck(service.getProcessStatus(), LingShanAgentServiceProcessStatusEnum.WITHDRAW.getStatusCode()); |
|
|
|
|
|
|
|
|
|
|
|
LingshanAgentServiceRecordEntity e2update = new LingshanAgentServiceRecordEntity(); |
|
|
|
|
|
e2update.setId(id); |
|
|
|
|
|
e2update.setProcessStatus(LingShanAgentServiceProcessStatusEnum.WITHDRAW.getStatusCode()); |
|
|
|
|
|
agentServiceRecordDao.updateById(e2update); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("【待办服务】撤回:分布式锁错误:" + ExceptionUtils.getErrorStackTrace(e)); |
|
|
|
|
|
throw e; |
|
|
|
|
|
} finally { |
|
|
|
|
|
// 释放锁
|
|
|
|
|
|
if (lock.isHeldByCurrentThread()) { |
|
|
|
|
|
lock.unlock(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void resiEvaluate(String id, Integer satisfication) { |
|
|
|
|
|
LingshanAgentServiceRecordEntity service; |
|
|
|
|
|
if ((service = agentServiceRecordDao.selectById(id)) == null) { |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "【代办服务】未找到指定的服务信息,ID:" + id); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (! service.getProcessStatus().equals(LingShanAgentServiceProcessStatusEnum.CLOSED.getStatusCode())) { |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, |
|
|
|
|
|
"【代办服务】只有办结的服务才能进行评价,当前状态为:" + LingShanAgentServiceProcessStatusEnum.getByStatus(service.getProcessStatus()).getStatusName()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LingshanAgentServiceRecordEntity e2update = new LingshanAgentServiceRecordEntity(); |
|
|
|
|
|
e2update.setId(id); |
|
|
|
|
|
e2update.setSatisfication(satisfication); |
|
|
|
|
|
agentServiceRecordDao.updateById(e2update); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|