| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- package com.qdport.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.qdport.entity.PolicyStrive;
- import com.qdport.enums.QDPortEnum;
- import com.qdport.mapper.PolicyCaseMapper;
- import com.qdport.mapper.PolicyShareMapper;
- import com.qdport.mapper.PolicyStriveMapper;
- import com.qdport.modules.system.entity.SysUser;
- import com.qdport.modules.system.service.TSysUserService;
- import com.qdport.query.QueryWrapperBuilder;
- import com.qdport.service.PolicyShareService;
- import com.qdport.util.StringUtil;
- import com.qdport.vo.*;
- import com.qdport.workflow.core.utils.WfTaskUtil;
- import com.qdport.workflow.process.model.WfProcess;
- import com.qdport.workflow.process.service.IWfProcessService;
- import lombok.AllArgsConstructor;
- import com.qdport.entity.PolicyTodo;
- import com.qdport.query.PolicyTodoQuery;
- import com.qdport.mapper.PolicyTodoMapper;
- import com.qdport.service.PolicyTodoService;
- import com.qdport.wrapper.PolicyTodoWrapper;
- import com.qdport.core.tool.utils.BeanUtil;
- import org.flowable.engine.HistoryService;
- import org.flowable.task.api.history.HistoricTaskInstance;
- import org.flowable.task.api.history.HistoricTaskInstanceQuery;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import javax.annotation.Resource;
- import java.util.Date;
- import java.util.List;
- import java.util.concurrent.ExecutionException;
- import java.util.concurrent.Future;
- import java.util.stream.Collectors;
- /**
- * 政策待办
- *
- * @author yuheng
- * @since 1.0.0 2024-10-11
- */
- @Service
- public class PolicyTodoServiceImpl extends ServiceImpl<PolicyTodoMapper, PolicyTodo> implements PolicyTodoService {
- @Resource
- private IWfProcessService processService;
- @Resource
- private TSysUserService sysUserService;
- @Resource
- private PolicyShareMapper policyShareMapper;
- @Resource
- private PolicyStriveMapper policyStriveMapper;
- @Resource
- private PolicyCaseMapper policyCaseMapper;
- @Override
- public IPage<PolicyTodoVO> page(PolicyTodoQuery query) {
- IPage<PolicyTodo> page = new Page<>(query.getPage(), query.getSize());
- page = baseMapper.selectPage(page, getWrapper(query));
- return PolicyTodoWrapper.build().pageVO(page);
- }
- private QueryWrapper<PolicyTodo> getWrapper(PolicyTodoQuery query) {
- QueryWrapper<PolicyTodo> wrapper = QueryWrapperBuilder.buildQueryWrapper(query, PolicyTodo.class);
- wrapper.orderByDesc("CREATE_TIME");
- return wrapper;
- }
- @Override
- public void save(PolicyTodoVO vo) {
- PolicyTodo entity = BeanUtil.copy(vo, PolicyTodo.class);
- baseMapper.insert(entity);
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void save(PolicyShareVO vo) throws ExecutionException, InterruptedException {
- QueryWrapper<PolicyTodo> todoQueryWrapper = new QueryWrapper<>();
- todoQueryWrapper.eq("REF_ID", vo.getId());
- todoQueryWrapper.eq("REF_TYPE", QDPortEnum.POLICY_TODO_REFTYPE_POLICY_SHARE.getValue());
- todoQueryWrapper.eq("TODO_TYPE", QDPortEnum.POLICY_TODO_TYPE_APPROVE.getValue());
- todoQueryWrapper.eq("STATUS", QDPortEnum.POLICY_TODO_STATUS_ACTIVE.getValue());
- PolicyTodo todo = new PolicyTodo();
- todo.setStatus(QDPortEnum.POLICY_TODO_STATUS_DONE.getValue());
- update(todo, todoQueryWrapper);
- Future<List<WfProcess>> flowFuture = processService.historyFlowList(vo.getProcessInstanceId(), null, null);
- List<WfProcess> ll = flowFuture.get();
- List<WfProcess> filter = ll.stream().filter(wfProcess ->
- QDPortEnum.POLICY_PROCESS_TYPE_USER_TASK.getValue().equals(wfProcess.getHistoryActivityType())
- && StringUtil.isEmpty(wfProcess.getEndTime())
- ).collect(Collectors.toList());
- if (!filter.isEmpty()) {
- WfProcess process = filter.get(0);
- String[] assignNames = process.getAssigneeName().split("/");
- for (String username : assignNames) {
- QueryWrapper<SysUser> sysUserWrapper = new QueryWrapper<>();
- sysUserWrapper.eq("username", username);
- SysUser user = sysUserService.getOne(sysUserWrapper);
- todo = new PolicyTodo();
- todo.setRefId(vo.getId());
- todo.setRefType(QDPortEnum.POLICY_TODO_REFTYPE_POLICY_SHARE.getValue());
- todo.setCreateTime(new Date());
- todo.setStatus(QDPortEnum.POLICY_TODO_STATUS_ACTIVE.getValue());
- todo.setTodoType(QDPortEnum.POLICY_TODO_TYPE_APPROVE.getValue());
- todo.setTodoUserId(user.getId());
- todo.setZcAbstractContent(vo.getAbstractContent());
- todo.setZcContactPhone(vo.getContactPhone());
- todo.setZcCreateId(vo.getCreateId());
- todo.setZcCreateName(vo.getCreateName());
- todo.setZcCreateTime(vo.getCreateTime());
- todo.setZcName(vo.getName());
- todo.setZcType(vo.getZcType());
- baseMapper.insert(todo);
- }
- } else {
- vo.setStatus(QDPortEnum.POLICY_SHARE_STATUS_DONE.getValue());
- vo.setUpdateTime(new Date());
- policyShareMapper.updateById(vo);
- }
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void save(PolicyStriveVO vo) throws ExecutionException, InterruptedException {
- QueryWrapper<PolicyTodo> todoQueryWrapper = new QueryWrapper<>();
- todoQueryWrapper.eq("REF_ID", vo.getId());
- todoQueryWrapper.eq("REF_TYPE", QDPortEnum.POLICY_TODO_REFTYPE_POLICY_STRIVE.getValue());
- todoQueryWrapper.eq("TODO_TYPE", QDPortEnum.POLICY_TODO_TYPE_APPROVE.getValue());
- todoQueryWrapper.eq("STATUS", QDPortEnum.POLICY_TODO_STATUS_ACTIVE.getValue());
- PolicyTodo todo = new PolicyTodo();
- todo.setStatus(QDPortEnum.POLICY_TODO_STATUS_DONE.getValue());
- update(todo, todoQueryWrapper);
- Future<List<WfProcess>> flowFuture = processService.historyFlowList(vo.getProcessInstanceId(), null, null);
- List<WfProcess> ll = flowFuture.get();
- List<WfProcess> filter = ll.stream().filter(wfProcess ->
- QDPortEnum.POLICY_PROCESS_TYPE_USER_TASK.getValue().equals(wfProcess.getHistoryActivityType())
- && StringUtil.isEmpty(wfProcess.getEndTime())
- ).collect(Collectors.toList());
- if (!filter.isEmpty()) {
- WfProcess process = filter.get(0);
- String[] assignNames = process.getAssigneeName().split("/");
- for (String username : assignNames) {
- QueryWrapper<SysUser> sysUserWrapper = new QueryWrapper<>();
- sysUserWrapper.eq("username", username);
- SysUser user = sysUserService.getOne(sysUserWrapper);
- todo = new PolicyTodo();
- todo.setRefId(vo.getId());
- todo.setRefType(QDPortEnum.POLICY_TODO_REFTYPE_POLICY_STRIVE.getValue());
- todo.setCreateTime(new Date());
- todo.setStatus(QDPortEnum.POLICY_TODO_STATUS_ACTIVE.getValue());
- todo.setTodoType(QDPortEnum.POLICY_TODO_TYPE_APPROVE.getValue());
- todo.setTodoUserId(user.getId());
- todo.setZcAbstractContent(vo.getAbstractContent());
- todo.setZcContactPhone(vo.getContactPhone());
- todo.setZcCreateId(vo.getCreateId());
- todo.setZcCreateName(vo.getCreateName());
- todo.setZcCreateTime(vo.getCreateTime());
- todo.setZcName(vo.getName());
- todo.setZcType(vo.getZcType());
- baseMapper.insert(todo);
- }
- } else {
- vo.setStatus(QDPortEnum.POLICY_SHARE_STATUS_DONE.getValue());
- vo.setUpdateTime(new Date());
- policyStriveMapper.updateById(vo);
- }
- }
- @Override
- public void save(PolicyCaseVO vo) throws ExecutionException, InterruptedException {
- QueryWrapper<PolicyTodo> todoQueryWrapper = new QueryWrapper<>();
- todoQueryWrapper.eq("REF_ID", vo.getId());
- todoQueryWrapper.eq("REF_TYPE", QDPortEnum.POLICY_TODO_REFTYPE_POLICY_CASE.getValue());
- todoQueryWrapper.eq("TODO_TYPE", QDPortEnum.POLICY_TODO_TYPE_APPROVE.getValue());
- todoQueryWrapper.eq("STATUS", QDPortEnum.POLICY_TODO_STATUS_ACTIVE.getValue());
- PolicyTodo todo = new PolicyTodo();
- todo.setStatus(QDPortEnum.POLICY_TODO_STATUS_DONE.getValue());
- update(todo, todoQueryWrapper);
- Future<List<WfProcess>> flowFuture = processService.historyFlowList(vo.getProcessInstanceId(), null, null);
- List<WfProcess> ll = flowFuture.get();
- List<WfProcess> filter = ll.stream().filter(wfProcess ->
- QDPortEnum.POLICY_PROCESS_TYPE_USER_TASK.getValue().equals(wfProcess.getHistoryActivityType())
- && StringUtil.isEmpty(wfProcess.getEndTime())
- ).collect(Collectors.toList());
- PolicyStrive policyStrive = vo.getPolicyStrive();
- if (!filter.isEmpty()) {
- WfProcess process = filter.get(0);
- String[] assignNames = process.getAssigneeName().split("/");
- for (String username : assignNames) {
- QueryWrapper<SysUser> sysUserWrapper = new QueryWrapper<>();
- sysUserWrapper.eq("username", username);
- SysUser user = sysUserService.getOne(sysUserWrapper);
- todo = new PolicyTodo();
- todo.setRefId(vo.getId());
- todo.setRefType(QDPortEnum.POLICY_TODO_REFTYPE_POLICY_CASE.getValue());
- todo.setCreateTime(new Date());
- todo.setStatus(QDPortEnum.POLICY_TODO_STATUS_ACTIVE.getValue());
- todo.setTodoType(QDPortEnum.POLICY_TODO_TYPE_APPROVE.getValue());
- todo.setTodoUserId(user.getId());
- todo.setZcAbstractContent(policyStrive.getAbstractContent());
- todo.setZcContactPhone(policyStrive.getContactPhone());
- todo.setZcCreateId(policyStrive.getCreateId());
- todo.setZcCreateName(policyStrive.getCreateName());
- todo.setZcCreateTime(vo.getCreateTime());
- todo.setZcName(policyStrive.getName());
- todo.setZcType(policyStrive.getZcType());
- baseMapper.insert(todo);
- }
- } else {
- vo.setStatus(QDPortEnum.POLICY_SHARE_STATUS_DONE.getValue());
- vo.setUpdateTime(new Date());
- policyCaseMapper.updateById(vo);
- }
- }
- @Override
- public void update(PolicyTodoVO vo) {
- PolicyTodo entity = BeanUtil.copy(vo, PolicyTodo.class);
- updateById(entity);
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void delete(List<String> idList) {
- removeByIds(idList);
- }
- }
|