123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- package com.jtgh.yjpt.auth;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import org.activiti.engine.TaskService;
- import org.activiti.engine.impl.identity.Authentication;
- import org.activiti.engine.task.Task;
- import org.apache.commons.lang.StringUtils;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.test.context.ContextConfiguration;
- import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
- import com.jtgh.qlyg.service.InfApplyService;
- import com.jtgh.yjpt.common.GlobalData;
- import com.jtgh.yjpt.common.WorkFlowParam;
- import com.jtgh.yjpt.entity.zyfzndjy.GkwxhwzyfzblhhzEntity;
- import com.jtgh.yjpt.service.aqsszxyssc.AqsszxysService;
- import com.jtgh.yjpt.service.auth.UserService;
- import com.jtgh.yjpt.service.common.WorkflowMangerService;
- import com.jtgh.yjpt.service.zyfzndjy.GkwxhwzyfzblhhzService;
- @RunWith(SpringJUnit4ClassRunner.class)
- @ContextConfiguration("/spring/applicationContext*.xml")
- public class UserTest {
- @Autowired
- private AqsszxysService aqsszxysService;
- @Autowired
- private UserService userService;
- @Autowired
- private InfApplyService infApplyService;
- @Autowired
- private GkwxhwzyfzblhhzService gkwxhwzyfzblhhzService;
- /** 工作流服务 */
- @Autowired
- protected WorkflowMangerService workflowMangerService;
- @Autowired
- protected TaskService taskService;
- // @Test
- // public void test1() {
- // Long id = 1l;
- // UserEntity user = userService.findOne(id);
- // assertEquals("admin", user.getName());
- // }
- // @Test
- // public void test2() {
- // Long id = 1l;
- // UserEntity user = userService.findOne(id);
- // assertEquals("test", user.getName());
- // }
- // @Test
- public void test() {
- System.out.println(infApplyService.findOne("1").getSyncDate());
- System.out.println(userService.findOne(1l));
- }
- @Test
- public void test3() {
- // 提交市级修改
- WorkFlowParam param = new WorkFlowParam();
- param.put(WorkFlowParam.IS_AUDIT, "true");
- param.put(WorkFlowParam.AUDIT_DATE, new Date());
- param.put(WorkFlowParam.AUDIT_TEXT, "");
- param.put(WorkFlowParam.AUDIT_RESULT, false);
- param.put(WorkFlowParam.AUDIT_USER, GlobalData.adminID);
- param.put(WorkFlowParam.BUSINESS_KEY, 1000196l);
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put(WorkFlowParam.AUDIT_PASS, false);
- aqsszxysService.complete(param, variables);
- }
- // @Test
- public void testWorkFlow() {
- GkwxhwzyfzblhhzEntity data = new GkwxhwzyfzblhhzEntity();
- data = gkwxhwzyfzblhhzService.findOne(3300l);
- // data.setQymc("authTest222222222222222");
- // data = gkwxhwzyfzblhhzService.save(data);
- System.out.println("ID:" + data.getId());
- String key = GkwxhwzyfzblhhzEntity.PROCESS_DEFINITION_KEY + "1";
- String currentRole = "001001001001001";
- Map<String, Object> variables = new HashMap<String, Object>();
- // currentRole = Utils.getParentRole(currentRole);
- // variables.put("role_xssc", currentRole);
- // currentRole = Utils.getParentRole(currentRole);
- // variables.put("role_sc1", currentRole);
- // variables.put("role_sc2", currentRole + "0");
- // currentRole = Utils.getParentRole(currentRole);
- // variables.put("role_sh", currentRole);
- // currentRole = Utils.getParentRole(currentRole);
- // variables.put("role_pz", currentRole);
- variables.put(WorkFlowParam.AUDIT_PASS, true);
- WorkFlowParam param = new WorkFlowParam();
- param.put(WorkFlowParam.AUDIT_DATE, new Date());
- param.put(WorkFlowParam.AUDIT_TEXT, "sh audit text...");
- param.put(WorkFlowParam.AUDIT_RESULT, "sh audit result...");
- // 设置流程发起人
- if (StringUtils.isEmpty(param.getString(WorkFlowParam.AUDIT_USER))) {
- param.put(WorkFlowParam.AUDIT_USER, "186900");
- }
- Authentication.setAuthenticatedUserId("186900");
- param.put(WorkFlowParam.BUSINESS_KEY, data.getId());
- // 提交流程
- String processInstanceId = "13505";
- // = workflowMangerService.create(param, variables, key);
- // workflowMangerService.autoComplete(param, processInstanceId);
- List<Task> taskList = workflowMangerService
- .getProcessActiveTasks(processInstanceId);
- if (null != taskList && taskList.size() > 0) {
- for (Task t : taskList) {
- System.out.println("186900:"
- + taskService.createTaskQuery()
- .taskCandidateUser("186900").taskId(t.getId())
- .count());
- System.out.println("186903:"
- + taskService.createTaskQuery()
- .taskCandidateUser("186903").taskId(t.getId())
- .count());
- System.out.println("186905:"
- + taskService.createTaskQuery()
- .taskCandidateUser("186905").taskId(t.getId())
- .count());
- System.out.println("226357:"
- + taskService.createTaskQuery()
- .taskCandidateUser("226357").taskId(t.getId())
- .count());
- workflowMangerService.claim(t.getId(), "186905");
- workflowMangerService.complete(param, variables, t);
- variables.put(WorkFlowParam.AUDIT_PASS, false);
- System.out.println("186900:"
- + taskService.createTaskQuery()
- .taskCandidateUser("186900").taskId(t.getId())
- .count());
- System.out.println("186903:"
- + taskService.createTaskQuery()
- .taskCandidateUser("186903").taskId(t.getId())
- .count());
- System.out.println("186905:"
- + taskService.createTaskQuery()
- .taskCandidateUser("186905").taskId(t.getId())
- .count());
- System.out.println("226357:"
- + taskService.createTaskQuery()
- .taskCandidateUser("226357").taskId(t.getId())
- .count());
- }
- }
- }
- }
|