|
|
@@ -2,18 +2,25 @@ package com.ygtx.gxt.task;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
+import com.ygtx.common.core.domain.entity.SysUser;
|
|
|
+import com.ygtx.common.core.domain.model.LoginUser;
|
|
|
import com.ygtx.common.utils.DateUtils;
|
|
|
+import com.ygtx.framework.web.service.SysPermissionService;
|
|
|
import com.ygtx.gxt.domain.GxtRepairOrder;
|
|
|
import com.ygtx.gxt.domain.GxtRepairOrderFlow;
|
|
|
import com.ygtx.gxt.service.IGxtRepairOrderService;
|
|
|
import com.ygtx.gxt.service.IGxtRepairOrderFlowService;
|
|
|
|
|
|
+import com.ygtx.system.mapper.SysUserMapper;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
|
+import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
/**
|
|
|
@@ -35,14 +42,31 @@ public class RepairOrderArchiveTask {
|
|
|
@Autowired
|
|
|
private IGxtRepairOrderFlowService repairOrderFlowService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysUserMapper userMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysPermissionService permissionService;
|
|
|
+
|
|
|
/**
|
|
|
* 每小时执行定时任务
|
|
|
* 查找已完成复运操作且评分为非空的工单,并进行归档
|
|
|
*/
|
|
|
+ //@Scheduled(cron = "0 0/3 * * * ?")
|
|
|
@Scheduled(cron = "0 0 * * * ?")
|
|
|
public void archiveRepairOrders() {
|
|
|
log.info("开始执行维修工单自动归档任务");
|
|
|
+ SysUser userAdmin = userMapper.selectUserByUserName("admin");
|
|
|
+ Set<String> permissions = permissionService.getMenuPermission(userAdmin);
|
|
|
+ LoginUser loginUser = new LoginUser(userAdmin,permissions);
|
|
|
+
|
|
|
+ UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(
|
|
|
+ loginUser,
|
|
|
+ null,
|
|
|
+ loginUser.getAuthorities()
|
|
|
+ );
|
|
|
|
|
|
+ SecurityContextHolder.getContext().setAuthentication(authentication);
|
|
|
try {
|
|
|
// 构造查询条件:已完成复运操作且评分为非空的工单
|
|
|
GxtRepairOrder queryOrder = new GxtRepairOrder();
|