Commit 8ba7bb00 authored by 王飞's avatar 王飞

Merge branch 'wangfei' into 'dev'

Feat

See merge request !32
parents 7bf8a1ba 7fe0c2fd
package com.ruoyi.service.impl;
import com.ruoyi.service.StrategyCarReviewTask;
import com.ruoyi.service.StrategySystemReviewTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -15,11 +16,11 @@ public class StrategyCarReviewTaskContext {
@Autowired
private final Map<String, StrategyCarReviewTask> resourceMap = new ConcurrentHashMap<>();
public StrategyCarReviewTaskContext(Map<String, StrategyCarReviewTask> strategyMap) {
this.resourceMap.clear();
strategyMap.forEach(resourceMap::put);
public void putResource(String key, StrategyCarReviewTask strategyCarReviewTask) {
resourceMap.put(key, strategyCarReviewTask);
}
public StrategyCarReviewTask getResource(String operation){
return resourceMap.get(operation);
}
......
......@@ -8,7 +8,9 @@ import com.ruoyi.service.ReviewSceneChangeTaskService;
import com.ruoyi.service.ReviewStandardService;
import com.ruoyi.service.StrategyCarReviewTask;
import com.ruoyi.web.response.CarReviewTaskViewResponse;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -18,8 +20,13 @@ import java.util.function.Function;
import java.util.stream.Collectors;
@Transactional
@Service(CarReviewTask.TASK_STATUS_PENDING)
public class StrategyCarReviewTaskPending implements StrategyCarReviewTask {
@Service
public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, InitializingBean {
@Autowired
private StrategyCarReviewTaskContext strategyCarReviewTaskContext;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private ReviewStandardService reviewStandardService;
......@@ -82,4 +89,9 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask {
}
}
}
@Override
public void afterPropertiesSet() throws Exception {
strategyCarReviewTaskContext.putResource(CarReviewTask.TASK_STATUS_PENDING, applicationContext.getBean(this.getClass()));
}
}
......@@ -5,13 +5,20 @@ import com.ruoyi.domain.ReviewSceneChangeTask;
import com.ruoyi.mapper.ReviewSceneMapper;
import com.ruoyi.service.StrategyReviewSceneChange;
import com.ruoyi.service.ReviewSceneChangeTaskService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Transactional
@Service(ReviewSceneChangeTask.OPERATION_ADD)
public class StrategyReviewSceneChangeAdd implements StrategyReviewSceneChange {
@Service
public class StrategyReviewSceneChangeAdd implements StrategyReviewSceneChange, InitializingBean {
@Autowired
private StrategyReviewSceneChangeContext strategyReviewSceneChangeContext;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private ReviewSceneMapper reviewSceneMapper;
......@@ -38,4 +45,8 @@ public class StrategyReviewSceneChangeAdd implements StrategyReviewSceneChange {
}
@Override
public void afterPropertiesSet() throws Exception {
strategyReviewSceneChangeContext.putResource(ReviewSceneChangeTask.OPERATION_ADD, applicationContext.getBean(this.getClass()));
}
}
......@@ -15,9 +15,8 @@ public class StrategyReviewSceneChangeContext {
@Autowired
private final Map<String, StrategyReviewSceneChange> strategyMap = new ConcurrentHashMap<>();
public StrategyReviewSceneChangeContext(Map<String, StrategyReviewSceneChange> strategyMap) {
this.strategyMap.clear();
strategyMap.forEach(strategyMap::put);
public void putResource(String key, StrategyReviewSceneChange strategySystemReviewTask) {
strategyMap.put(key, strategySystemReviewTask);
}
public StrategyReviewSceneChange getResource(String operation){
......
......@@ -3,13 +3,20 @@ package com.ruoyi.service.impl;
import com.ruoyi.domain.ReviewSceneChangeTask;
import com.ruoyi.service.StrategyReviewSceneChange;
import com.ruoyi.service.ReviewSceneService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Transactional
@Service(ReviewSceneChangeTask.OPERATION_DELETE)
public class StrategyReviewSceneChangeDelete implements StrategyReviewSceneChange {
@Service
public class StrategyReviewSceneChangeDelete implements StrategyReviewSceneChange, InitializingBean {
@Autowired
private StrategyReviewSceneChangeContext strategyReviewSceneChangeContext;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private ReviewSceneService reviewSceneService;
......@@ -18,4 +25,9 @@ public class StrategyReviewSceneChangeDelete implements StrategyReviewSceneChang
public void doChange(ReviewSceneChangeTask reviewSceneChangeTask) {
reviewSceneService.removeById(reviewSceneChangeTask.getReviewSceneId());
}
@Override
public void afterPropertiesSet() throws Exception {
strategyReviewSceneChangeContext.putResource(ReviewSceneChangeTask.OPERATION_DELETE, applicationContext.getBean(this.getClass()));
}
}
......@@ -4,13 +4,21 @@ import com.ruoyi.domain.ReviewScene;
import com.ruoyi.domain.ReviewSceneChangeTask;
import com.ruoyi.service.StrategyReviewSceneChange;
import com.ruoyi.service.ReviewSceneService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Transactional
@Service(ReviewSceneChangeTask.OPERATION_UPDATE)
public class StrategyReviewSceneChangeUpdate implements StrategyReviewSceneChange {
@Service
public class StrategyReviewSceneChangeUpdate implements StrategyReviewSceneChange, InitializingBean {
@Autowired
private StrategyReviewSceneChangeContext strategyReviewSceneChangeContext;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private ReviewSceneService reviewSceneService;
......@@ -22,4 +30,9 @@ public class StrategyReviewSceneChangeUpdate implements StrategyReviewSceneChang
reviewSceneService.updateById(reviewScene);
}
@Override
public void afterPropertiesSet() throws Exception {
strategyReviewSceneChangeContext.putResource(ReviewSceneChangeTask.OPERATION_UPDATE, applicationContext.getBean(this.getClass()));
}
}
......@@ -5,12 +5,20 @@ import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.SystemReviewTask;
import com.ruoyi.service.StrategySystemReviewTask;
import com.ruoyi.web.response.SystemReviewTaskViewResponse;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Transactional
@Service(SystemReviewTask.STATUS_CLOSE)
public class StrategySystemReviewTaskClose implements StrategySystemReviewTask {
@Service
public class StrategySystemReviewTaskClose implements StrategySystemReviewTask, InitializingBean {
@Autowired
private StrategySystemReviewTaskContext strategySystemReviewTaskContext;
@Autowired
private ApplicationContext applicationContext;
@Override
public void doStart(SystemReviewTask systemReviewTask) {
......@@ -39,4 +47,9 @@ public class StrategySystemReviewTaskClose implements StrategySystemReviewTask {
return response;
}
@Override
public void afterPropertiesSet() throws Exception {
strategySystemReviewTaskContext.putResource(SystemReviewTask.STATUS_CLOSE, applicationContext.getBean(this.getClass()));
}
}
......@@ -15,9 +15,8 @@ public class StrategySystemReviewTaskContext {
@Autowired
private final Map<String, StrategySystemReviewTask> resourceMap = new ConcurrentHashMap<>();
public StrategySystemReviewTaskContext(Map<String, StrategySystemReviewTask> strategyMap) {
this.resourceMap.clear();
strategyMap.forEach(resourceMap::put);
public void putResource(String key, StrategySystemReviewTask strategySystemReviewTask) {
resourceMap.put(key, strategySystemReviewTask);
}
public StrategySystemReviewTask getResource(String operation){
......
......@@ -5,12 +5,20 @@ import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.SystemReviewTask;
import com.ruoyi.service.StrategySystemReviewTask;
import com.ruoyi.web.response.SystemReviewTaskViewResponse;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Transactional
@Service(SystemReviewTask.STATUS_FINISH)
public class StrategySystemReviewTaskFinish implements StrategySystemReviewTask {
@Service
public class StrategySystemReviewTaskFinish implements StrategySystemReviewTask, InitializingBean {
@Autowired
private StrategySystemReviewTaskContext strategySystemReviewTaskContext;
@Autowired
private ApplicationContext applicationContext;
@Override
public void doStart(SystemReviewTask systemReviewTask) {
......@@ -39,4 +47,9 @@ public class StrategySystemReviewTaskFinish implements StrategySystemReviewTask
return response;
}
@Override
public void afterPropertiesSet() throws Exception {
strategySystemReviewTaskContext.putResource(SystemReviewTask.STATUS_FINISH, applicationContext.getBean(this.getClass()));
}
}
......@@ -8,7 +8,9 @@ import com.ruoyi.mapper.SystemReviewTaskMapper;
import com.ruoyi.service.ReviewStandardService;
import com.ruoyi.service.StrategySystemReviewTask;
import com.ruoyi.web.response.SystemReviewTaskViewResponse;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -16,8 +18,13 @@ import java.util.Date;
import java.util.List;
@Transactional
@Service(SystemReviewTask.STATUS_NEW)
public class StrategySystemReviewTaskNew implements StrategySystemReviewTask {
@Service
public class StrategySystemReviewTaskNew implements StrategySystemReviewTask, InitializingBean {
@Autowired
private StrategySystemReviewTaskContext strategySystemReviewTaskContext;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private ReviewStandardService reviewStandardService;
......@@ -63,4 +70,9 @@ public class StrategySystemReviewTaskNew implements StrategySystemReviewTask {
return response;
}
@Override
public void afterPropertiesSet() throws Exception {
strategySystemReviewTaskContext.putResource(SystemReviewTask.STATUS_NEW, applicationContext.getBean(this.getClass()));
}
}
......@@ -9,7 +9,9 @@ import com.ruoyi.mapper.ReviewDetailsResultMapper;
import com.ruoyi.mapper.SystemReviewTaskMapper;
import com.ruoyi.service.*;
import com.ruoyi.web.response.SystemReviewTaskViewResponse;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -20,8 +22,13 @@ import java.util.function.Function;
import java.util.stream.Collectors;
@Transactional
@Service(SystemReviewTask.STATUS_PENDING + "SystemReviewTask")
public class StrategySystemReviewTaskPending implements StrategySystemReviewTask {
@Service
public class StrategySystemReviewTaskPending implements StrategySystemReviewTask, InitializingBean {
@Autowired
private StrategySystemReviewTaskContext strategySystemReviewTaskContext;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private ReviewStandardService reviewStandardService;
......@@ -38,7 +45,6 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
@Autowired
private ReviewDetailsResultMapper reviewDetailsResultMapper;
@Override
public void doStart(SystemReviewTask systemReviewTask) {
throw new ServiceException("不能开始一个已经开始的任务", HttpStatus.ERROR);
......@@ -130,4 +136,9 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
}
}
}
@Override
public void afterPropertiesSet() throws Exception {
strategySystemReviewTaskContext.putResource(SystemReviewTask.STATUS_PENDING, applicationContext.getBean(this.getClass()));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment