UserTest.java 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. package com.jtgh.yjpt.auth;
  2. import java.util.Date;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import org.activiti.engine.TaskService;
  7. import org.activiti.engine.impl.identity.Authentication;
  8. import org.activiti.engine.task.Task;
  9. import org.apache.commons.lang.StringUtils;
  10. import org.junit.Test;
  11. import org.junit.runner.RunWith;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.test.context.ContextConfiguration;
  14. import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  15. import com.jtgh.qlyg.service.InfApplyService;
  16. import com.jtgh.yjpt.common.GlobalData;
  17. import com.jtgh.yjpt.common.WorkFlowParam;
  18. import com.jtgh.yjpt.entity.zyfzndjy.GkwxhwzyfzblhhzEntity;
  19. import com.jtgh.yjpt.service.aqsszxyssc.AqsszxysService;
  20. import com.jtgh.yjpt.service.auth.UserService;
  21. import com.jtgh.yjpt.service.common.WorkflowMangerService;
  22. import com.jtgh.yjpt.service.zyfzndjy.GkwxhwzyfzblhhzService;
  23. @RunWith(SpringJUnit4ClassRunner.class)
  24. @ContextConfiguration("/spring/applicationContext*.xml")
  25. public class UserTest {
  26. @Autowired
  27. private AqsszxysService aqsszxysService;
  28. @Autowired
  29. private UserService userService;
  30. @Autowired
  31. private InfApplyService infApplyService;
  32. @Autowired
  33. private GkwxhwzyfzblhhzService gkwxhwzyfzblhhzService;
  34. /** 工作流服务 */
  35. @Autowired
  36. protected WorkflowMangerService workflowMangerService;
  37. @Autowired
  38. protected TaskService taskService;
  39. // @Test
  40. // public void test1() {
  41. // Long id = 1l;
  42. // UserEntity user = userService.findOne(id);
  43. // assertEquals("admin", user.getName());
  44. // }
  45. // @Test
  46. // public void test2() {
  47. // Long id = 1l;
  48. // UserEntity user = userService.findOne(id);
  49. // assertEquals("test", user.getName());
  50. // }
  51. // @Test
  52. public void test() {
  53. System.out.println(infApplyService.findOne("1").getSyncDate());
  54. System.out.println(userService.findOne(1l));
  55. }
  56. @Test
  57. public void test3() {
  58. // 提交市级修改
  59. WorkFlowParam param = new WorkFlowParam();
  60. param.put(WorkFlowParam.IS_AUDIT, "true");
  61. param.put(WorkFlowParam.AUDIT_DATE, new Date());
  62. param.put(WorkFlowParam.AUDIT_TEXT, "");
  63. param.put(WorkFlowParam.AUDIT_RESULT, false);
  64. param.put(WorkFlowParam.AUDIT_USER, GlobalData.adminID);
  65. param.put(WorkFlowParam.BUSINESS_KEY, 1000196l);
  66. Map<String, Object> variables = new HashMap<String, Object>();
  67. variables.put(WorkFlowParam.AUDIT_PASS, false);
  68. aqsszxysService.complete(param, variables);
  69. }
  70. // @Test
  71. public void testWorkFlow() {
  72. GkwxhwzyfzblhhzEntity data = new GkwxhwzyfzblhhzEntity();
  73. data = gkwxhwzyfzblhhzService.findOne(3300l);
  74. // data.setQymc("authTest222222222222222");
  75. // data = gkwxhwzyfzblhhzService.save(data);
  76. System.out.println("ID:" + data.getId());
  77. String key = GkwxhwzyfzblhhzEntity.PROCESS_DEFINITION_KEY + "1";
  78. String currentRole = "001001001001001";
  79. Map<String, Object> variables = new HashMap<String, Object>();
  80. // currentRole = Utils.getParentRole(currentRole);
  81. // variables.put("role_xssc", currentRole);
  82. // currentRole = Utils.getParentRole(currentRole);
  83. // variables.put("role_sc1", currentRole);
  84. // variables.put("role_sc2", currentRole + "0");
  85. // currentRole = Utils.getParentRole(currentRole);
  86. // variables.put("role_sh", currentRole);
  87. // currentRole = Utils.getParentRole(currentRole);
  88. // variables.put("role_pz", currentRole);
  89. variables.put(WorkFlowParam.AUDIT_PASS, true);
  90. WorkFlowParam param = new WorkFlowParam();
  91. param.put(WorkFlowParam.AUDIT_DATE, new Date());
  92. param.put(WorkFlowParam.AUDIT_TEXT, "sh audit text...");
  93. param.put(WorkFlowParam.AUDIT_RESULT, "sh audit result...");
  94. // 设置流程发起人
  95. if (StringUtils.isEmpty(param.getString(WorkFlowParam.AUDIT_USER))) {
  96. param.put(WorkFlowParam.AUDIT_USER, "186900");
  97. }
  98. Authentication.setAuthenticatedUserId("186900");
  99. param.put(WorkFlowParam.BUSINESS_KEY, data.getId());
  100. // 提交流程
  101. String processInstanceId = "13505";
  102. // = workflowMangerService.create(param, variables, key);
  103. // workflowMangerService.autoComplete(param, processInstanceId);
  104. List<Task> taskList = workflowMangerService
  105. .getProcessActiveTasks(processInstanceId);
  106. if (null != taskList && taskList.size() > 0) {
  107. for (Task t : taskList) {
  108. System.out.println("186900:"
  109. + taskService.createTaskQuery()
  110. .taskCandidateUser("186900").taskId(t.getId())
  111. .count());
  112. System.out.println("186903:"
  113. + taskService.createTaskQuery()
  114. .taskCandidateUser("186903").taskId(t.getId())
  115. .count());
  116. System.out.println("186905:"
  117. + taskService.createTaskQuery()
  118. .taskCandidateUser("186905").taskId(t.getId())
  119. .count());
  120. System.out.println("226357:"
  121. + taskService.createTaskQuery()
  122. .taskCandidateUser("226357").taskId(t.getId())
  123. .count());
  124. workflowMangerService.claim(t.getId(), "186905");
  125. workflowMangerService.complete(param, variables, t);
  126. variables.put(WorkFlowParam.AUDIT_PASS, false);
  127. System.out.println("186900:"
  128. + taskService.createTaskQuery()
  129. .taskCandidateUser("186900").taskId(t.getId())
  130. .count());
  131. System.out.println("186903:"
  132. + taskService.createTaskQuery()
  133. .taskCandidateUser("186903").taskId(t.getId())
  134. .count());
  135. System.out.println("186905:"
  136. + taskService.createTaskQuery()
  137. .taskCandidateUser("186905").taskId(t.getId())
  138. .count());
  139. System.out.println("226357:"
  140. + taskService.createTaskQuery()
  141. .taskCandidateUser("226357").taskId(t.getId())
  142. .count());
  143. }
  144. }
  145. }
  146. }