ProActiService.java 139 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445
  1. package com.idea.oa.activiti.service;
  2. import com.idea.oa.activiti.exception.FlowException;
  3. import com.idea.oa.activiti.model.UserTaskMore;
  4. import com.idea.oa.apply.util.constant.ConstantFlowType;
  5. import com.idea.oa.flow2.model.FlowMain;
  6. import com.idea.oa.flow2.model.FlowMainLog;
  7. import com.idea.oa.flow2.model.FlowMainPush;
  8. import com.idea.oa.flow2.model.in.TagerUserAndFlowRole;
  9. import com.idea.oa.flow2.service.FlowMainLogService;
  10. import com.idea.oa.flow2.service.FlowMainService;
  11. import com.rockstar.common.domain.AjaxResult;
  12. import com.rockstar.common.support.Convert;
  13. import com.rockstar.flow.dto.TaskDto;
  14. import com.rockstar.flow.service.FlowService;
  15. import com.rockstar.frame.model.*;
  16. import com.rockstar.frame.service.*;
  17. import com.rockstar.system.model.SysDept;
  18. import com.rockstar.system.service.SysDeptService;
  19. import com.rockstar.util.BeanUtils;
  20. import com.rockstar.util.StringUtils;
  21. import org.activiti.bpmn.model.*;
  22. import org.activiti.bpmn.model.Process;
  23. import org.activiti.engine.RepositoryService;
  24. import org.activiti.engine.TaskService;
  25. import org.activiti.engine.task.Task;
  26. import org.activiti.engine.task.TaskInfo;
  27. import org.apache.commons.collections.CollectionUtils;
  28. import org.springframework.beans.factory.annotation.Autowired;
  29. import org.springframework.stereotype.Service;
  30. import org.springframework.transaction.annotation.Transactional;
  31. import java.math.BigDecimal;
  32. import java.util.*;
  33. import java.util.stream.Collectors;
  34. @Service
  35. public class ProActiService {
  36. @Autowired
  37. private FlowMainLogService flowMainLogService;
  38. // 到时候如果先会签,串并联的问题,flowService.runTask和flowService.start判断一下,是否需要串联会签还是并联会签,如果是3的单人签核,1是并联会签,0是串联会签
  39. @Autowired
  40. private TaskService taskService;
  41. @Autowired
  42. private FlowService flowService;
  43. @Autowired
  44. private FlowMainService flowMainService;
  45. @Autowired
  46. private FrameUserService userService;
  47. //
  48. // @Autowired
  49. // private FramePostService postService;
  50. //
  51. @Autowired
  52. private SysDeptService sysDeptService;
  53. //
  54. //
  55. // @Autowired
  56. // private FrameUserDeptService frameUserDeptService;
  57. @Autowired
  58. private FrameUserService frameUserService;
  59. @Autowired
  60. private FrameRoleDataService frameRoleDataService;
  61. @Autowired
  62. private FrameRoleDataUserService frameRoleDataUserService;
  63. /**
  64. * ok
  65. * 删除并结束指定活动实例
  66. *
  67. * @param processInstanceId 启动流程的流程对象id
  68. * @param comments 评论/备注
  69. */
  70. @Transactional
  71. public void endTaskProcess(String processInstanceId, String comments) {
  72. flowService.deleteInstance(processInstanceId, comments);
  73. }
  74. /**
  75. * ok
  76. * 启动流程
  77. * 启动方法时,ActiDto内的必须值是:processType, currentUserId 和 businessId
  78. *
  79. * @param actiDto
  80. * @return
  81. * @throws FlowException
  82. */
  83. @Transactional
  84. public Map<String, String> startAutoTask(Map<String, Object> actiDto) throws FlowException, com.rockstar.flow.exception.FlowException {
  85. // processDefine 流程定义 apply_pay
  86. // dataRole 角色??是传什么?
  87. // businessId 流程id,就用主流程的id flow_main
  88. // targetUser 目标人员
  89. // currUser 当前人员
  90. String processDefine = "apply_pay";
  91. FrameUser targetUser = userService.selectByPrimaryKey("1080517374995595264");
  92. FrameUser currUser = userService.selectByPrimaryKey("1");
  93. // String businessId="1088138622709792768";
  94. // String businessId="1088140716548292608";
  95. String businessId = "1088140517679562752";//主申请表id
  96. Map<String, String> startTask = flowService.startTask(processDefine, null, businessId, targetUser, currUser);
  97. //返回数据{processInstanceId=7501}{processInstanceId=12501}{processInstanceId=17501}
  98. String taskId = "任务ID:17516";
  99. String flow_id = startTask.get("processInstanceId").toString();
  100. ;
  101. return startTask;
  102. }
  103. /**
  104. * ok
  105. * 执行当前流程节点
  106. * 该方法中,ActiDto内除了businessId,其他都是必须值
  107. *
  108. * @param actiDto isEndSet,当业务发现可以结束审核的时候向方法外传送是否结束审核的信号
  109. * @return
  110. * @throws FlowException
  111. */
  112. @Transactional
  113. public Object runAutoTask(Map actiDto) throws FlowException, com.rockstar.flow.exception.FlowException {
  114. FrameUser targetUser = userService.selectByPrimaryKey("1080522875951120384");
  115. FrameUser currUser = userService.selectByPrimaryKey("1080517374995595264");
  116. // private String processType;
  117. // private String currentUserId;
  118. // private String operateUserId;
  119. // private String dataRole;
  120. // private String agree;==>yes/no
  121. // private String comments;===================>????
  122. // private String businessId;
  123. // private String taskId;===>在展示列表里面有taskId
  124. // flowDto.getTaskId(), flowDto.getDataRole(), flowDto.getAgree(), flowDto.getComments()
  125. Map<String, Object> map = new HashMap<>();
  126. map.put("billMoney", 1250);
  127. return flowService.runTask("12516", null, "yes", "zt omments", targetUser, currUser, null);
  128. }
  129. /**
  130. * 查询数据
  131. *
  132. * @param taskDto
  133. * @return
  134. * @throws FlowException
  135. */
  136. @Transactional
  137. public List findTask(TaskDto taskDto) throws FlowException {
  138. List<String> taskGroups = new ArrayList<>();
  139. return flowService.findTask(taskDto, taskGroups);
  140. }
  141. /**
  142. * 还不知道干什么用的,猜是查看备注用的
  143. *
  144. * @param taskId
  145. * @param isHistoric
  146. * @return
  147. * @throws FlowException
  148. */
  149. @Transactional
  150. public List getCommentsByTid(String taskId, Boolean isHistoric) throws FlowException {
  151. if (StringUtils.isEmpty(taskId))
  152. throw new FlowException("任务ID为空");
  153. if (null == isHistoric) {
  154. isHistoric = false;
  155. }
  156. return flowService.getComments(taskId, isHistoric);
  157. }
  158. /**
  159. * 通过taskId获取任务后续得任务组列表,任务组列表定义如下:
  160. * 1,任务组是有('岗位'和yes) 或('curr_user'和'no')组合而成得字符串,具体如:director-yes,office_leader-yes或curr_user-no等
  161. * 2,一般来说curr_user-no都是被退回之后指向得任务组,而带-yes后缀的是同意所指向得任务组
  162. * <p>
  163. * 使用方式:
  164. * 1,在待审批列表中打开某个审批任务,先通过taskId(任务ID)获取该任务后续得任务组
  165. * 2,分析所拥有得任务组,一般是2个或者1个任务组
  166. * 3,根据所获得得任务组,来安排界面'同意'和'不同意'得按钮显示或隐藏
  167. * 4,任务组含curr_user-no,就具备'不同意'按钮,点击不同意按钮,传输值:agree值为no, dataRole:'-no'之前的
  168. * 5,任务组含带-yes后缀的,就具备'同意'按钮,点击同意按钮,传输值:agree值为yes, dataRole:'-yes'之前的
  169. * 6,任务组如果只含curr_user-no,没其他的,那就具备'不同意'和'结束'按钮,点结束按钮,传输值:agree值为yes即可
  170. *
  171. * @param taskId 任务ID
  172. * @param isHistoric 是否历史任务
  173. * @return
  174. */
  175. @Transactional
  176. public List<String> nextTaskGroups(String taskId, boolean isHistoric) throws FlowException {
  177. if (StringUtils.isEmpty(taskId))
  178. throw new FlowException("任务ID为空");
  179. List<String> strings = flowService.nextTaskGroups(taskId, isHistoric);
  180. List<UserTask> userTasks = flowService.nextTasks(taskId, isHistoric);
  181. System.out.println("nextTasks数据为:" + userTasks);
  182. return strings;
  183. }
  184. //=======偏业务的,到时候要搬走的=========================================================================================================================================================
  185. public String getNodeName(FlowMainPush flowMainPush) {
  186. {
  187. Task task = null;
  188. List<Task> taskList = taskService.createTaskQuery().processInstanceBusinessKey(flowMainPush.getFlowMainId()).taskId(flowMainPush.getTaskId()).list();
  189. if (taskList == null || taskList.isEmpty()) {
  190. return null;
  191. }
  192. task = taskList.get(0);
  193. return task.getName();
  194. }
  195. }
  196. /**
  197. * 通用方法 //当前审核人/委托人代表的用户id
  198. *
  199. * @param flowMainPush
  200. * @return
  201. */
  202. public String getMyFrameUserId(FlowMainPush flowMainPush) {
  203. //当前审核人/委托人代表的用户id
  204. String myFrameUserId = null;
  205. {
  206. Integer pushRole = flowMainPush.getPushRole();
  207. if (new Integer(1).equals(pushRole)) {//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  208. myFrameUserId = flowMainPush.getPushUser();
  209. } else if (new Integer(2).equals(pushRole)) {//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  210. //因为是被委托人,所以查到这个委托人的信息
  211. // {//通过流程监控进行操的时候就会有问题,不能找到原来的审核用户id 第一种方式,通过关联查询进行被委托人查询
  212. // FlowMainLog flowMainLog = flowMainLogService.selectByPrimaryKey(flowMainPush.getUpMainLogId());
  213. // String auditResult = flowMainLog.getAuditResult();
  214. // if (!"4".equals(auditResult)) {// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)',
  215. // return null;//异常情况
  216. // }
  217. // myFrameUserId = flowMainLog.getAuditUser();
  218. // }
  219. {//第二种方式
  220. // 通过 flowMainPush.getFlowPost()来获取对应的被委托人的信息,只是还没有测试不知道 第二种方式是否好用
  221. myFrameUserId = flowMainPush.getFlowPost();
  222. }
  223. } else {
  224. return null;//异常情况
  225. }
  226. }
  227. return myFrameUserId;
  228. }
  229. /**
  230. * 审核通过,进行下一步操作
  231. *
  232. * @return
  233. * @throws FlowException
  234. */
  235. @Transactional
  236. public Map<String, String> passToRunTask(FlowMainPush flowMainPush, String deploymentid, String businessId, Map<String, Object> conditionMap, FlowMain flowMain) throws com.rockstar.flow.exception.FlowException {
  237. // 发起流程引擎操作 并查看下一节点的操作要求
  238. //0,如果是收纳且匹配上角色就正常流程审核,没有匹配上就返回null,异常错误 ok,
  239. //1. 如果当前角色是自己,就进行正常的审核流程 ok
  240. //2. 先查看当前角色是不是自己,不是自己就移动到自己的角色,然后再进行正常的审核流程 ok
  241. //当前审核人/委托人代表的用户id
  242. String myFrameUserId = this.getMyFrameUserId(flowMainPush);
  243. if (myFrameUserId == null) {
  244. return null;
  245. }
  246. // {
  247. // Integer pushRole = flowMainPush.getPushRole();
  248. // if (new Integer(1).equals(pushRole)) {//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  249. // myFrameUserId = flowMainPush.getPushUser();
  250. // } else if (new Integer(2).equals(pushRole)) {//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  251. // //因为是被委托人,所以查到这个委托人的信息
  252. // {//第一种方式,通过关联查询进行被委托人查询
  253. // FlowMainLog flowMainLog = flowMainLogService.selectByPrimaryKey(flowMainPush.getUpMainLogId());
  254. // String auditResult = flowMainLog.getAuditResult();
  255. // if (!"4".equals(auditResult)) {// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)',
  256. // return null;//异常情况
  257. // }
  258. // myFrameUserId = flowMainLog.getAuditUser();
  259. // }
  260. // {//第二种方式
  261. // //通过 flowMainPush.getFlowPost()来获取对应的被委托人的信息,只是还没有测试不知道 第二种方式是否好用
  262. //// myFrameUserId = flowMainPush.getFlowPost()
  263. // }
  264. // } else {
  265. // return null;//异常情况
  266. // }
  267. // }
  268. //当前审核人/委托人代表的用户
  269. FrameUser myframeUser = frameUserService.selectByPrimaryKey(myFrameUserId);
  270. //根据任务id获取任务信息
  271. //当前任务流程
  272. Task task = null;
  273. {
  274. List<Task> taskList = taskService.createTaskQuery().processInstanceBusinessKey(flowMainPush.getFlowMainId()).taskId(flowMainPush.getTaskId()).list();
  275. if (taskList == null || taskList.isEmpty()) {
  276. return null;
  277. }
  278. task = taskList.get(0);
  279. }
  280. //本节点的关键子 例如flow_cnjs_1_1_0-yes
  281. String pushUserKey = flowMainPush.getPushUserKey();
  282. //本节点的角色 例如cnjs
  283. String setRurrRole = this.getSetRurrRole(pushUserKey);
  284. //判断setRurrRole是不是出纳类的角色,如果是出纳的角色,就判断当前审核人是不是也是出纳,是就继续,不是就是异常错误,返回null
  285. //判断是否符合出纳类型的要求 ok
  286. {
  287. for (int i = 0; i < ConstantFlowType.FLOW_ROLES_CHECK.length; i++) {
  288. if (ConstantFlowType.FLOW_ROLES_CHECK[i].equals(setRurrRole)) {//1.1.3如果是出纳关系的查收纳
  289. //查看谁是对应角色并查找对应的人
  290. String role = ConstantFlowType.ROLES_CHECK[i];//找到是出纳类的角色
  291. // List<FrameRoleData> FrameRoleDatas = flowMainService.findFrameRoleDatasByUserId(myFrameUserId, ConstantFlowType.ROLETYPE);//"FLOW"
  292. // for (FrameRoleData frameRoleData : FrameRoleDatas) {
  293. // String roleKey = frameRoleData.getRoleKey();
  294. // if (roleKey.equals(role)) {
  295. // //匹配到对应的人,用正常流程做审核
  296. // return this.donaturalTask(deploymentid, myframeUser, task, conditionMap);
  297. // }
  298. // }
  299. //如果没有匹配到就是异常错误,返回null
  300. // return null;
  301. //只所以注释掉上面的,是觉得原来订的审核人已经确认了,若中途改掉了也不需要校验了,确保流程的一致性,并能正常运行
  302. return this.donaturalTask(deploymentid, myframeUser, task, conditionMap, flowMain);
  303. }
  304. }
  305. }
  306. {
  307. //当前审核人/委托人代表的用户角色(只判断了是否是主管还是 分管领导的问题, 还没有判断是否是出纳的问题,不是哪里都适用的)
  308. String currRole = this.getCurrRole(myframeUser, flowMain);
  309. //没有获取到角色,直接对到admin那里
  310. if (currRole == null || currRole.equals("")) {
  311. // 直接对到admin那里
  312. System.out.println("8没有找到对应人:" + " if (currRole == null || currRole.equals(\"\"))");
  313. FrameUser targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  314. if (targetUser == null) {
  315. System.err.println("异常,没有找到目标人");
  316. return null;
  317. }
  318. {//下面的替换这里的数据,来解决管理员无法结束流程的问题
  319. // boolean yes = flowService.runTask(task.getId(), null, "yes", null, targetUser, myframeUser, conditionMap);
  320. // return new HashMap<>();
  321. }
  322. {
  323. return this.donaturalTask(deploymentid, myframeUser, task, conditionMap, flowMain);
  324. }
  325. }
  326. //当发现this.getCurrRole(myframeUser);获取的角色是普通员工的时候,就知道他作为审核人只是直接上级,并不是领导,所以把角色调上一级
  327. if (currRole.equals(ConstantFlowType.FLOW_ROLES_DEPT[0])) {
  328. currRole = ConstantFlowType.FLOW_ROLES_DEPT[1];
  329. }
  330. // 不是出纳的情况下进行的判断
  331. //1.如果当前角色是自己,就进行正常的审核流程 ok
  332. //2.先查看当前角色是不是自己,不是自己就移动到自己的角FlowException色,然后再进行正常的审核流程 ok
  333. if (setRurrRole.equals(currRole)) {//1.如果当前角色是自己,就进行正常的审核流程 ok
  334. return this.donaturalTask(deploymentid, myframeUser, task, conditionMap, flowMain);
  335. } else {//2.先查看当前角色是不是自己,不是自己就移动到自己的角色,然后再进行正常的审核流程 ok
  336. FrameUser targetUser = null;
  337. UserTaskMore userPosition = this.findUserPosition(currRole, deploymentid);
  338. // 返回为null就直接提交到admin用户去审核,如果对象里面的nodeNum是1就是正常流程,如果大于1就是非正常流程需要把目标人填自己直到自己流转到自己流程上
  339. if (userPosition == null) {//没有找到数据
  340. System.out.println("9没有找到对应人:" + "if (userPosition == null) {");
  341. targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  342. if (targetUser == null) {
  343. System.err.println("异常,没有找到目标人");
  344. return null;
  345. }
  346. boolean yes = flowService.runTask(task.getId(), null, "yes", null, targetUser, myframeUser, conditionMap);
  347. return new HashMap<>();
  348. } else {//找到userPosition数据录了
  349. //还不是自己的角色,还要遍历查找
  350. return getNextFlow(businessId, userPosition, deploymentid, myframeUser, conditionMap, task, flowMain);
  351. }
  352. }
  353. }
  354. }
  355. /**
  356. * 通用方法 写一个正常流程,正常下审核到下一个环节
  357. *
  358. * @param deploymentid 流程任务唯一id
  359. * @param currUser 当前审核人/委托人代表的用户
  360. * @param task2 当前的任务Task
  361. * @param conditionMap 所需要用到的条件
  362. * @return
  363. */
  364. public Map<String, String> donaturalTask(String deploymentid, FrameUser currUser, Task task2, Map<String, Object> conditionMap, FlowMain flowMain) throws com.rockstar.flow.exception.FlowException {
  365. {
  366. FrameUser targetUser = null;//目标人信息
  367. String roleType = null; //流程节点详细信息:例如:dept_superior_1_0_1
  368. //可以开始正常走流程了 嘻嘻...
  369. {
  370. UserTask myNowUserTask = this.getUserTaskById(task2.getTaskDefinitionKey(), deploymentid);//id的值如:_9
  371. //获取到了出去的各条路径
  372. List<SequenceFlow> outgoingFlows = myNowUserTask.getOutgoingFlows();
  373. //我的下一个节点位置
  374. SequenceFlow myNextSequenceFlow = null;
  375. for (SequenceFlow outgoingFlow : outgoingFlows) {
  376. String conditionExpression = outgoingFlow.getConditionExpression();
  377. //如果是空就跳过
  378. if (conditionExpression == null) {
  379. continue;
  380. } else
  381. //只有是yes的时候才是需要往下运行的,如果
  382. if (conditionExpression.contains("${agree=='no'}")) {//${agree=='yes'}
  383. continue;
  384. } else if (conditionExpression.contains("${agree=='back'}")) {//${agree=='yes'}
  385. continue;
  386. } else
  387. //只有是yes的时候才是需要往下运行的,如果
  388. if (conditionExpression.contains("${agree=='yes'}")) {//${agree=='yes'}//xxxx
  389. //发现没有判断条件,那本流程就是下个节点
  390. myNextSequenceFlow = outgoingFlow;
  391. } else {
  392. //发现有明确的判断条件,需要判断是否满足条件才能确认是否本流程就是下个节点
  393. //原来计划会有多个条件判断,但是现在就一个,所以就先写死一个条件吧
  394. //获取路径的判断条件
  395. if (this.booleanConditionIsOk(conditionExpression, conditionMap)) {
  396. myNextSequenceFlow = outgoingFlow;
  397. }
  398. }
  399. //如果没有找到下个流程节点就继续找
  400. if (myNextSequenceFlow == null) {
  401. continue;
  402. }
  403. {
  404. //下面是找到了下个流程节点,需要进行正常的运行节点了
  405. //================================================================
  406. //TaskList.get(1).getOutgoingFlows().get(1).getTargetFlowElement().getCandidateGroups()
  407. // TaskList.get(7).getOutgoingFlows().get(1).getTargetFlowElement().getClass().isInstance(EndEvent.class);
  408. FlowElement targetFlowElement = myNextSequenceFlow.getTargetFlowElement();
  409. if (targetFlowElement instanceof EndEvent) {//如果是的话就是最后审核状态
  410. System.out.println("已经是结束流程了,直接完成审核就行了1");
  411. boolean yes = flowService.runTask(task2.getId(), null, "yes", null, currUser, currUser, conditionMap);
  412. HashMap<String, String> objectObjectHashMap = new HashMap<>();
  413. objectObjectHashMap.put("isEnd", "1");
  414. return objectObjectHashMap;
  415. }
  416. //class org.activiti.bpmn.model.EndEvent
  417. String candidateGroup = ((UserTask) targetFlowElement).getCandidateGroups().get(0);//targetFlowElement.getCandidateGroups();
  418. String setRurrRole = this.getSetRurrRole(candidateGroup);
  419. boolean end = false;
  420. for (String s : ConstantFlowType.FLOW_ROLES_DEPT) {
  421. if (s.equals(setRurrRole)) {//1.1.1如果是部门关系的查部门
  422. // 写一个通用方法,专门根据条件获取部门领导是谁
  423. TagerUserAndFlowRole targerUser_flow_roles_dept = this.getTargerUser_FLOW_ROLES_DEPT(s, currUser, flowMain);
  424. targetUser = targerUser_flow_roles_dept.getFrameUser();
  425. roleType = targerUser_flow_roles_dept.getFlowRole();
  426. if (targetUser == null) {
  427. {// 统一到同一个方法中了:
  428. //如果没有找到目标人就肯定是要跳跃查找对应的目标人,如果都没有找到就在最全的节点中找但是(这时候该节点如果是会签也要改成并签)
  429. //
  430. TagerUserAndFlowRole up_targerUser_flow_roles_dept = null;
  431. if (targerUser_flow_roles_dept.getFlowRole() == null) {
  432. //要进行从本角色(部门已经查过了,就是从领导角色开始查)开始的本流程的全角色查询
  433. boolean isTagerUserNull = false;//判断目标用户对应的节点是否存在
  434. {//这里是获取目标用户除去部门信息以外的第一个节点key值
  435. String[] flowStep = flowMainService.getOnlylowStepAll(flowMain.getFlowType());
  436. // 1先找到flowStep中部门的最大i值
  437. // 2 再判断没有就是flowStep的第一个值, 有就再判断是否是最大值,不是最大值就能获取第i+1的值,否则就没有找到
  438. Integer maxI = null;
  439. for (int i = 0; i < flowStep.length; i++) {
  440. if (flowStep[i].startsWith(ConstantFlowType.FLOW_ROLES_DEPT[1])) {
  441. maxI = i;
  442. } else if (flowStep[i].startsWith(ConstantFlowType.FLOW_ROLES_DEPT[2])) {
  443. maxI = i;
  444. break;
  445. }
  446. }
  447. if (maxI == null) {
  448. targerUser_flow_roles_dept.setFlowRole(flowStep[0]);
  449. } else {
  450. if (maxI >= (flowStep.length - 1)) {
  451. isTagerUserNull = true;
  452. } else {
  453. targerUser_flow_roles_dept.setFlowRole(flowStep[maxI + 1]);
  454. }
  455. }
  456. }
  457. if (isTagerUserNull) {
  458. up_targerUser_flow_roles_dept = new TagerUserAndFlowRole();
  459. } else {
  460. up_targerUser_flow_roles_dept = flowMainService.getAllUpRoleTargetUsers(flowMain, targerUser_flow_roles_dept.getFlowRole());
  461. }
  462. } else {
  463. //查询对应设置角色开始的角色
  464. up_targerUser_flow_roles_dept = flowMainService.getUpRoleTargetUsers(flowMain, targerUser_flow_roles_dept.getFlowRole(), targerUser_flow_roles_dept.getOnlyFlowFlowStep());
  465. if (up_targerUser_flow_roles_dept.getFrameUser() == null) {
  466. up_targerUser_flow_roles_dept = flowMainService.getAllUpRoleTargetUsers(flowMain, targerUser_flow_roles_dept.getFlowRole());
  467. }
  468. }
  469. targetUser = up_targerUser_flow_roles_dept.getFrameUser();
  470. roleType = up_targerUser_flow_roles_dept.getFlowRole();
  471. }
  472. }
  473. if (targetUser == null) {
  474. // return null;
  475. System.out.println("0没有找到对应人:" + "if (targetUser == null) {==>" + setRurrRole + "==>" + ConstantFlowType.ROLETYPE);
  476. targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  477. if (targetUser == null) {
  478. System.err.println("异常,没有找到目标人");
  479. throw new RuntimeException("异常,没有找到目标人");
  480. // return null;
  481. }
  482. roleType = candidateGroup;
  483. }
  484. // SysDept sysDept = sysDeptService.selectByPrimaryKey(department);
  485. boolean yes = flowService.runTask(task2.getId(), null, "yes", null, targetUser, currUser, conditionMap);
  486. end = true;
  487. Map<String, String> objectObjectHashMap = new HashMap<>();
  488. objectObjectHashMap.put("roleType", roleType);
  489. return objectObjectHashMap;
  490. }
  491. }
  492. if (!end) {
  493. for (int i = 0; i < ConstantFlowType.FLOW_ROLES.length; i++) {
  494. if (ConstantFlowType.FLOW_ROLES[i].equals(setRurrRole)) {//1.1.2如果是领导关系的查领导
  495. //查看谁是对应角色并查找对应的人
  496. String role = ConstantFlowType.ROLES[i];
  497. // List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKey(role, ConstantFlowType.ROLETYPE);
  498. // 在上面的方法基础上,增加groupId和用户状态的过滤
  499. List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKeyAndGroup(
  500. role, ConstantFlowType.ROLETYPE, currUser.getGroupId());
  501. if (!targetUserList.isEmpty() && targetUserList.size() >= 1) {
  502. targetUser = targetUserList.get(0);
  503. roleType = candidateGroup;
  504. //进行串并联申请
  505. {
  506. targetUser = flowMainService.getFrameUsersId(roleType, targetUserList, targetUser);
  507. }
  508. }
  509. if (targetUser == null) {
  510. TagerUserAndFlowRole up_targerUser_flow_roles_dept = null;
  511. //查询对应设置角色开始的角色
  512. String nextRole = null;
  513. String[] onlyFlowFlowStep = flowMainService.getOnlyFlowFlowStep(flowMain);
  514. {//获取直接领导的下的流程节点是什么
  515. for (int iZT = 0; iZT < onlyFlowFlowStep.length; iZT++) {
  516. if (onlyFlowFlowStep[i].startsWith(setRurrRole)) {
  517. if (iZT == (onlyFlowFlowStep.length - 1)) {
  518. nextRole = null;
  519. } else {
  520. nextRole = onlyFlowFlowStep[iZT + 1];
  521. }
  522. break;
  523. }
  524. }
  525. }
  526. if (nextRole == null) {
  527. } else {
  528. up_targerUser_flow_roles_dept = flowMainService.getUpRoleTargetUsers(flowMain, nextRole, onlyFlowFlowStep);
  529. if (up_targerUser_flow_roles_dept.getFrameUser() == null) {
  530. up_targerUser_flow_roles_dept = flowMainService.getAllUpRoleTargetUsers(flowMain, nextRole);
  531. }
  532. targetUser = up_targerUser_flow_roles_dept.getFrameUser();
  533. roleType = up_targerUser_flow_roles_dept.getFlowRole();
  534. }
  535. }
  536. if (targetUser == null) {
  537. // return null;
  538. System.out.println("1没有找到对应人:" + "if (targetUser == null) {==>" + role + "==>" + ConstantFlowType.ROLETYPE);
  539. targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  540. if (targetUser == null) {
  541. System.err.println("异常,没有找到目标人");
  542. throw new RuntimeException("异常,没有找到目标人");
  543. // return null;
  544. }
  545. roleType = candidateGroup;
  546. }
  547. boolean yes = flowService.runTask(task2.getId(), null, "yes", null, targetUser, currUser, conditionMap);
  548. end = true;
  549. Map<String, String> objectObjectHashMap = new HashMap<>();
  550. objectObjectHashMap.put("roleType", roleType);
  551. return objectObjectHashMap;
  552. }
  553. }
  554. }
  555. if (!end) {
  556. for (int i = 0; i < ConstantFlowType.FLOW_ROLES_CHECK.length; i++) {
  557. if (ConstantFlowType.FLOW_ROLES_CHECK[i].equals(setRurrRole)) {//1.1.3如果是收纳关系的查收纳
  558. //查看谁是对应角色并查找对应的人
  559. String role = ConstantFlowType.ROLES_CHECK[i];
  560. // List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKey(role, ConstantFlowType.ROLETYPE);
  561. // 在上面的方法基础上,增加groupId和用户状态的过滤
  562. List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKeyAndGroup(
  563. role, ConstantFlowType.ROLETYPE, currUser.getGroupId());
  564. if (!targetUserList.isEmpty() && targetUserList.size() >= 1) {
  565. targetUser = targetUserList.get(0);
  566. roleType = candidateGroup;
  567. //进行串并联申请
  568. {
  569. targetUser = flowMainService.getFrameUsersId(roleType, targetUserList, targetUser);
  570. }
  571. }
  572. if (targetUser == null) {
  573. // return null;
  574. System.out.println("2没有找到对应人:" + "if (targetUser == null) {");
  575. targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  576. if (targetUser == null) {
  577. System.err.println("异常,没有找到目标人");
  578. throw new RuntimeException("异常,没有找到目标人");
  579. // return null;
  580. }
  581. roleType = candidateGroup;
  582. }
  583. boolean yes = flowService.runTask(task2.getId(), null, "yes", null, targetUser, currUser, conditionMap);
  584. end = true;
  585. Map<String, String> objectObjectHashMap = new HashMap<>();
  586. objectObjectHashMap.put("roleType", roleType);
  587. return objectObjectHashMap;
  588. }
  589. }
  590. }
  591. //采购流程相关都注释掉,以后模板不会用到的
  592. // if (!end) {
  593. // for (int i = 0; i < ConstantFlowType.PURCHASE_FLOW_ROLES_CHECK.length; i++) {
  594. // if (ConstantFlowType.PURCHASE_FLOW_ROLES_CHECK[i].equals(setRurrRole)) {//1.1.3如果是收纳关系的查收纳
  595. // //查看谁是对应角色并查找对应的人
  596. // String role = ConstantFlowType.PURCHASE_ROLES_CHECK[i];
  597. //// List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKey(role, ConstantFlowType.ROLETYPE);
  598. // // 在上面的方法基础上,增加groupId和用户状态的过滤
  599. // List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKeyAndGroup(
  600. // role, ConstantFlowType.ROLETYPE, currUser.getGroupId());
  601. // if (!targetUserList.isEmpty()) {
  602. // targetUser = targetUserList.get(0);
  603. // }
  604. // if (targetUser == null) {
  605. // targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  606. // if (targetUser == null) {
  607. // return null;
  608. // }
  609. // }
  610. // flowService.runTask(task2.getId(), null, "yes", null, targetUser, currUser, conditionMap);
  611. // return new HashMap<>();
  612. // }
  613. // }
  614. // }
  615. break;
  616. }
  617. }
  618. //都没有就是没有下个流程了,可以结束流程了
  619. System.out.println("已经没有下个申请流程了,已经结束了1");
  620. //
  621. boolean yes = flowService.runTask(task2.getId(), null, "yes", null, currUser, currUser, conditionMap);
  622. HashMap<String, String> objectObjectHashMap = new HashMap<>();
  623. objectObjectHashMap.put("isEnd", "1");
  624. return objectObjectHashMap;
  625. }
  626. //下面的代码要替换掉==========================================================================================
  627. // {
  628. //
  629. // //可以开始正常走流程了 嘻嘻...
  630. // List<Object> nextCandidateGroupByDeploy = flowService.getNextCandidateGroupByDeploy(deploymentid, task2.getTaskDefinitionKey(), false);
  631. // if (!nextCandidateGroupByDeploy.isEmpty() && nextCandidateGroupByDeploy.size() >= 1) {
  632. // for (int ii = 0; ii < nextCandidateGroupByDeploy.size(); ii++) {
  633. // UserTask myNextTask = null;//我要走的流程
  634. // UserTask userTask = (UserTask) nextCandidateGroupByDeploy.get(ii);
  635. // String candidateGroup = userTask.getCandidateGroups().get(0);//dept_superior_1_0_1-yes
  636. // if (!"-yes".equals(candidateGroup.substring(candidateGroup.indexOf("-")))){
  637. // continue;
  638. // }
  639. // String setRurrRole = this.getSetRurrRole(candidateGroup);
  640. // {
  641. // // 获取判断条件进行判断是否符合条件,符合就往下走,不符合就跳到下一个节点进行判断
  642. // //获取路径的判断条件
  643. // List<String> myconditionExpressions = new ArrayList<String>();
  644. // List<SequenceFlow> outgoingFlows = userTask.getOutgoingFlows();
  645. // for (SequenceFlow outgoingFlow : outgoingFlows) {
  646. // String conditionExpression = outgoingFlow.getConditionExpression();
  647. // if (conditionExpression == null) {
  648. // continue;
  649. // }
  650. // if (conditionExpression.contains("${agree==")) {
  651. // continue;
  652. // }
  653. // myconditionExpressions.add(conditionExpression);
  654. // }
  655. // if (myconditionExpressions.isEmpty()) {//没有条件就直接可以使用
  656. // myNextTask = userTask;
  657. //
  658. // } else {//有条件就判断是否满足条件,不满足就运行下一个
  659. // int isOkNum = 0;
  660. // for (int i1 = 0; i1 < myconditionExpressions.size(); i1++) {
  661. // boolean isOk = false;
  662. // //这是我的判断条件(通过条件判断库去比对数据)
  663. // String mycondition = myconditionExpressions.get(i1);
  664. // if (mycondition.contains("billMoney")) {
  665. //// ${billMoney>3000}
  666. // Double billMoney = Double.valueOf(conditionMap.get("billMoney").toString());
  667. // if (mycondition.contains("<=")) {
  668. // String substring = mycondition.substring(mycondition.indexOf("<=") + 2, mycondition.length() - 1);
  669. // if (billMoney <= Double.valueOf(substring)) {
  670. //// ok
  671. // isOk = true;
  672. //
  673. // }
  674. // } else if (mycondition.contains("<")) {
  675. // String substring = mycondition.substring(mycondition.indexOf("<") + 1, mycondition.length() - 1);
  676. // if (billMoney < Double.valueOf(substring)) {
  677. //// ok
  678. // isOk = true;
  679. // }
  680. // } else if (mycondition.contains(">=")) {
  681. // String substring = mycondition.substring(mycondition.indexOf(">=") + 2, mycondition.length() - 1);
  682. // if (billMoney >= Double.valueOf(substring)) {
  683. //// ok
  684. // isOk = true;
  685. // }
  686. // } else if (mycondition.contains(">")) {
  687. // String substring = mycondition.substring(mycondition.indexOf(">") + 1, mycondition.length() - 1);
  688. // if (billMoney > Double.valueOf(substring)) {
  689. //// ok
  690. // isOk = true;
  691. // }
  692. // } else if (mycondition.contains("==")) {
  693. // String substring = mycondition.substring(mycondition.indexOf("==") + 2, mycondition.length() - 1);
  694. // BigDecimal data1 = new BigDecimal(billMoney);
  695. // BigDecimal data2 = new BigDecimal(substring);
  696. // int i2 = data1.compareTo(data2);
  697. // if (i2 == 0) {
  698. //// ok
  699. // isOk = true;
  700. // }
  701. // }
  702. // }
  703. //
  704. // if (isOk) {
  705. // isOkNum = isOkNum + 1;
  706. // }
  707. // }
  708. // if (isOkNum == myconditionExpressions.size()) {
  709. // myNextTask = userTask;
  710. // }
  711. //
  712. // if (myNextTask == null) {
  713. // continue;
  714. // }
  715. //
  716. // }
  717. // }
  718. // //================================================================
  719. // boolean end = false;
  720. // for (String s : ConstantFlowType.FLOW_ROLES_DEPT) {
  721. // if (s.equals(setRurrRole)) {//1.1.1如果是部门关系的查部门
  722. // String leader = currUser.getLeader();
  723. // targetUser = userService.selectByPrimaryKey(leader);
  724. // if (targetUser == null) {
  725. // return null;
  726. // }
  727. // boolean yes = flowService.runTask(task2.getId(), null, "yes", null, targetUser, currUser, conditionMap);
  728. //
  729. // end = true;
  730. // return new HashMap<>();
  731. // }
  732. // }
  733. // if (!end) {
  734. // for (int i = 0; i < ConstantFlowType.FLOW_ROLES.length; i++) {
  735. // if (ConstantFlowType.FLOW_ROLES[i].equals(setRurrRole)) {//1.1.2如果是领导关系的查领导
  736. // //查看谁是对应角色并查找对应的人
  737. // String role = ConstantFlowType.ROLES[i];
  738. // List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKey(role, ConstantFlowType.ROLETYPE);
  739. // if (!targetUserList.isEmpty()) {
  740. // if (targetUserList.size() >= 1) {
  741. // targetUser = targetUserList.get(0);
  742. // }
  743. // }
  744. // if (targetUser == null) {
  745. // return null;
  746. // }
  747. // boolean yes = flowService.runTask(task2.getId(), null, "yes", null, targetUser, currUser, conditionMap);
  748. // end = true;
  749. // return new HashMap<>();
  750. // }
  751. // }
  752. //
  753. // }
  754. // if (!end) {
  755. // for (int i = 0; i < ConstantFlowType.FLOW_ROLES_CHECK.length; i++) {
  756. // if (ConstantFlowType.FLOW_ROLES_CHECK[i].equals(setRurrRole)) {//1.1.3如果是收纳关系的查收纳
  757. // //查看谁是对应角色并查找对应的人
  758. // String role = ConstantFlowType.ROLES_CHECK[i];
  759. // List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKey(role, ConstantFlowType.ROLETYPE);
  760. // if (!targetUserList.isEmpty()) {
  761. // if (targetUserList.size() >= 1) {
  762. // targetUser = targetUserList.get(0);
  763. // }
  764. // }
  765. // if (targetUser == null) {
  766. // return null;
  767. // }
  768. // boolean yes = flowService.runTask(task2.getId(), null, "yes", null, targetUser, currUser, conditionMap);
  769. // end = true;
  770. // return new HashMap<>();
  771. // }
  772. // }
  773. // }
  774. // break;
  775. // }
  776. // //都没有就是没有下个流程了,可以结束流程了
  777. // System.out.println("已经没有下个申请流程了,已经结束了");
  778. // //
  779. // boolean yes = flowService.runTask(task2.getId(), null, "yes", null, currUser, currUser, conditionMap);
  780. //
  781. // HashMap<String, String> objectObjectHashMap = new HashMap<>();
  782. // objectObjectHashMap.put("isEnd","1");
  783. // return objectObjectHashMap;
  784. // } else {
  785. // System.out.println("已经没有下个申请流程了,已经结束了");
  786. // //
  787. // boolean yes = flowService.runTask(task2.getId(), null, "yes", null, currUser, currUser, conditionMap);
  788. //
  789. // HashMap<String, String> objectObjectHashMap = new HashMap<>();
  790. // objectObjectHashMap.put("isEnd","1");
  791. // return objectObjectHashMap;
  792. // }
  793. // }
  794. }
  795. }
  796. /**
  797. * 写一个通用方法判断流程中的条件是否符合要求
  798. * conditionExpression 判断的条件
  799. * conditionMap拥有的条件
  800. */
  801. public boolean booleanConditionIsOk(String conditionExpression, Map<String, Object> conditionMap) {
  802. //发现有明确的判断条件,需要判断是否满足条件才能确认是否本流程就是下个节点
  803. //原来计划会有多个条件判断,但是现在就一个,所以就先写死一个条件吧
  804. //获取路径的判断条件
  805. List<String> myconditionExpressions = new ArrayList<String>();
  806. myconditionExpressions.add(conditionExpression);
  807. int isOkNum = 0;
  808. for (int i1 = 0; i1 < myconditionExpressions.size(); i1++) {
  809. boolean isOk = false;
  810. //这是我的判断条件(通过条件判断库去比对数据)
  811. String mycondition = myconditionExpressions.get(i1);
  812. if (mycondition.contains("billMoney")) {
  813. // ${billMoney>3000}
  814. Double billMoney = Double.valueOf(conditionMap.get("billMoney").toString());
  815. if (mycondition.contains("<=")) {
  816. String substring = mycondition.substring(mycondition.indexOf("<=") + 2, mycondition.length() - 1);
  817. if (billMoney <= Double.valueOf(substring)) {
  818. // ok
  819. isOk = true;
  820. }
  821. } else if (mycondition.contains("<")) {
  822. String substring = mycondition.substring(mycondition.indexOf("<") + 1, mycondition.length() - 1);
  823. if (billMoney < Double.valueOf(substring)) {
  824. // ok
  825. isOk = true;
  826. }
  827. } else if (mycondition.contains(">=")) {
  828. String substring = mycondition.substring(mycondition.indexOf(">=") + 2, mycondition.length() - 1);
  829. if (billMoney >= Double.valueOf(substring)) {
  830. // ok
  831. isOk = true;
  832. }
  833. } else if (mycondition.contains(">")) {
  834. String substring = mycondition.substring(mycondition.indexOf(">") + 1, mycondition.length() - 1);
  835. if (billMoney > Double.valueOf(substring)) {
  836. // ok
  837. isOk = true;
  838. }
  839. } else if (mycondition.contains("==")) {
  840. String substring = mycondition.substring(mycondition.indexOf("==") + 2, mycondition.length() - 1);
  841. BigDecimal data1 = new BigDecimal(billMoney);
  842. BigDecimal data2 = new BigDecimal(substring);
  843. int i2 = data1.compareTo(data2);
  844. if (i2 == 0) {
  845. // ok
  846. isOk = true;
  847. }
  848. }
  849. } else if (mycondition.contains("isExchangeOnly==")) {
  850. String isExchangeOnly = conditionMap.get("isExchangeOnly").toString();
  851. Integer applyDay = Integer.valueOf(conditionMap.get("applyDay").toString());
  852. if (mycondition.contains("(isExchangeOnly=='no') and (applyDay>3)")) {
  853. if ("no".equals(isExchangeOnly) && applyDay > 3) {
  854. isOk = true;
  855. }
  856. } else if (mycondition.contains("(isExchangeOnly=='yes') or (applyDay<=3)")) {
  857. if ("yes".equals(isExchangeOnly) || applyDay <= 3) {
  858. isOk = true;
  859. }
  860. }
  861. }
  862. if (isOk) {
  863. isOkNum = isOkNum + 1;
  864. }
  865. }
  866. if (isOkNum == myconditionExpressions.size()) {
  867. return true;
  868. } else {
  869. return false;
  870. }
  871. }
  872. /**
  873. * 根据用户位置启动信息启动流程
  874. * processDefine 在ConstantFlowType中的PAYMEN_PROCESSDEFINE
  875. * String businessId = "1088140517679562752";//主申请表id
  876. * deploymentid 在ConstantFlowType.USE_MONEY_DEPLOYMENTID
  877. * conditionMap 是条件数据,比如目前需要的条件是${billMoney>3000}
  878. * return 返回的数据是flow_id字段,如果是null,说明异常有问题了 如果是end就是没有下个流程了,可以结束了
  879. */
  880. public Map<String, String> startTask(String processDefine, String deploymentid, FlowMain flowMain, FrameUser currUser, Map<String, Object> conditionMap, String tagerUserId) throws com.rockstar.flow.exception.FlowException {
  881. String businessId = flowMain.getId();
  882. FrameUser targetUser = null;//目标人信息
  883. String roleType = null; //流程节点详细信息:例如:dept_superior_1_0_1
  884. String currRole = this.getCurrRole(currUser, flowMain);
  885. UserTaskMore userPosition = this.findUserPosition(currRole, deploymentid);
  886. // 返回为null就直接提交到admin用户去审核,如果对象里面的nodeNum是1就是正常流程,如果大于1就是非正常流程需要把目标人填自己直到自己流转到自己流程上
  887. Map<String, String> startTask = null;
  888. if (userPosition == null) {//没有找到数据
  889. System.out.println("7没有找到对应人:" + " if (userPosition == null) {");
  890. targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  891. if (targetUser == null) {
  892. System.err.println("异常,没有找到目标人");
  893. return null;
  894. }
  895. startTask = flowService.startTask(processDefine, null, businessId, targetUser, currUser);
  896. return startTask;
  897. } else {//找到userPosition对象数据了
  898. // 1.如果是1就正常网下写,如果发现目标审核人的角色不是正常角色,就要去找他的对应位置的角色,不管是谁都要审核通过才行, 所以开始的时候只要找到直接领导传下去就好了,在运行节点进行角色判断,将流程跳到自己的角色位置结束
  899. //1.1查看下个节点人员角色的需求
  900. //1.1.1如果是部门关系的查部门
  901. //1.1.2如果是领导关系的查领导
  902. //1.1.3如果是收纳关系的查收纳
  903. //2.如果大于1就是非正常流程需要把目标人填自己直到自己流转到自己流程上
  904. int nodeNum = userPosition.getNodeNum();
  905. UserTask currentUserTask = userPosition.getCurrentUserTask();
  906. if (nodeNum == 1) {
  907. {
  908. List<SequenceFlow> outgoingFlows = currentUserTask.getOutgoingFlows();
  909. //我的下一个节点位置
  910. SequenceFlow myNextSequenceFlow = null;
  911. for (SequenceFlow outgoingFlow : outgoingFlows) {
  912. String conditionExpression = outgoingFlow.getConditionExpression();
  913. //如果是空就跳过
  914. if (conditionExpression == null) {
  915. continue;
  916. } else
  917. //只有是yes的时候才是需要往下运行的,如果
  918. if (conditionExpression.contains("${agree=='no'}")) {//${agree=='yes'}
  919. continue;
  920. } else if (conditionExpression.contains("${agree=='back'}")) {//${agree=='yes'}
  921. continue;
  922. } else
  923. //只有是yes的时候才是需要往下运行的,如果
  924. if (conditionExpression.contains("${agree=='yes'}")) {//${agree=='yes'}//xxxx
  925. //发现没有判断条件,那本流程就是下个节点
  926. myNextSequenceFlow = outgoingFlow;
  927. } else {
  928. //发现有明确的判断条件,需要判断是否满足条件才能确认是否本流程就是下个节点
  929. //原来计划会有多个条件判断,但是现在就一个,所以就先写死一个条件吧
  930. //获取路径的判断条件
  931. if (this.booleanConditionIsOk(conditionExpression, conditionMap)) {
  932. myNextSequenceFlow = outgoingFlow;
  933. }
  934. }
  935. //如果没有找到下个流程节点就继续找
  936. if (myNextSequenceFlow == null) {
  937. continue;
  938. }
  939. //下面是找到了下个流程节点,需要进行正常的运行节点了
  940. FlowElement targetFlowElement = myNextSequenceFlow.getTargetFlowElement();
  941. if (targetFlowElement instanceof EndEvent) {//如果是的话就是最后审核状态
  942. System.out.println("已经是结束流程了,直接完成审核就行了2");
  943. return null;
  944. }
  945. String candidateGroup = ((UserTask) targetFlowElement).getCandidateGroups().get(0);//targetFlowElement.getCandidateGroups();
  946. String setRurrRole = this.getSetRurrRole(candidateGroup);
  947. boolean end = false;
  948. for (String s : ConstantFlowType.FLOW_ROLES_DEPT) {
  949. if (s.equals(setRurrRole)) {//1.1.1如果是部门关系的查部门
  950. // 写一个通用方法,专门根据条件获取部门领导是谁
  951. TagerUserAndFlowRole targerUser_flow_roles_dept = this.getTargerUser_FLOW_ROLES_DEPT(s, currUser, flowMain);
  952. targetUser = targerUser_flow_roles_dept.getFrameUser();
  953. roleType = targerUser_flow_roles_dept.getFlowRole();
  954. if (targetUser == null) {
  955. {// 统一到同一个方法中了:
  956. //如果没有找到目标人就肯定是要跳跃查找对应的目标人,如果都没有找到就在最全的节点中找但是(这时候该节点如果是会签也要改成并签)//
  957. TagerUserAndFlowRole up_targerUser_flow_roles_dept = null;
  958. if (targerUser_flow_roles_dept.getFlowRole() == null) {
  959. //要进行从本角色(部门已经查过了,就是从领导角色开始查)开始的本流程的全角色查询
  960. boolean isTagerUserNull = false;//判断目标用户对应的节点是否存在
  961. {//这里是获取目标用户除去部门信息以外的第一个节点key值
  962. String[] flowStep = flowMainService.getOnlylowStepAll(flowMain.getFlowType());
  963. for (int i = 0; i < flowStep.length; i++) {
  964. if (ConstantFlowType.FLOW_ROLES_DEPT[2].equals(flowStep[i])) {
  965. if (i >= (flowStep.length - 1)) {
  966. isTagerUserNull = true;
  967. break;
  968. } else {
  969. targerUser_flow_roles_dept.setFlowRole(flowStep[i + 1]);
  970. }
  971. }
  972. if (isTagerUserNull) {
  973. if (ConstantFlowType.FLOW_ROLES_DEPT[1].equals(flowStep[i])) {
  974. if (i >= (flowStep.length - 1)) {
  975. isTagerUserNull = true;
  976. break;
  977. } else {
  978. targerUser_flow_roles_dept.setFlowRole(flowStep[i + 1]);
  979. }
  980. }
  981. }
  982. }
  983. }
  984. if (isTagerUserNull) {
  985. up_targerUser_flow_roles_dept = new TagerUserAndFlowRole();
  986. } else {
  987. up_targerUser_flow_roles_dept = flowMainService.getAllUpRoleTargetUsers(flowMain, targerUser_flow_roles_dept.getFlowRole());
  988. }
  989. } else {
  990. //查询对应设置角色开始的角色
  991. up_targerUser_flow_roles_dept = flowMainService.getUpRoleTargetUsers(flowMain, targerUser_flow_roles_dept.getFlowRole(), targerUser_flow_roles_dept.getOnlyFlowFlowStep());
  992. if (up_targerUser_flow_roles_dept.getFrameUser() == null) {
  993. up_targerUser_flow_roles_dept = flowMainService.getAllUpRoleTargetUsers(flowMain, targerUser_flow_roles_dept.getFlowRole());
  994. }
  995. }
  996. targetUser = up_targerUser_flow_roles_dept.getFrameUser();
  997. roleType = up_targerUser_flow_roles_dept.getFlowRole();
  998. }
  999. }
  1000. if (targetUser == null) {
  1001. return null;
  1002. }
  1003. // SysDept sysDept = sysDeptService.selectByPrimaryKey(department);
  1004. startTask = flowService.startTask(processDefine, null, businessId, targetUser, currUser);
  1005. end = true;
  1006. startTask.put("roleType", roleType);
  1007. return startTask;
  1008. }
  1009. }
  1010. if (!end) {
  1011. for (int i = 0; i < ConstantFlowType.FLOW_ROLES.length; i++) {
  1012. if (ConstantFlowType.FLOW_ROLES[i].equals(setRurrRole)) {//1.1.2如果是领导关系的查领导
  1013. //查看谁是对应角色并查找对应的人
  1014. String role = ConstantFlowType.ROLES[i];
  1015. // List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKey(role, ConstantFlowType.ROLETYPE);
  1016. // 在上面的方法基础上,增加groupId和用户状态的过滤
  1017. List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKeyAndGroup(
  1018. role, ConstantFlowType.ROLETYPE, currUser.getGroupId());
  1019. if (!targetUserList.isEmpty() && targetUserList.size() >= 1) {
  1020. targetUser = targetUserList.get(0);
  1021. roleType = candidateGroup;
  1022. //进行串并联申请
  1023. {
  1024. targetUser = flowMainService.getFrameUsersId(roleType, targetUserList, targetUser);
  1025. }
  1026. }
  1027. if (targetUser == null) {
  1028. TagerUserAndFlowRole up_targerUser_flow_roles_dept = null;
  1029. //查询对应设置角色开始的角色
  1030. String nextRole = null;
  1031. String[] onlyFlowFlowStep = flowMainService.getOnlyFlowFlowStep(flowMain);
  1032. {//获取直接领导的下的流程节点是什么
  1033. for (int iZT = 0; iZT < onlyFlowFlowStep.length; iZT++) {
  1034. if (onlyFlowFlowStep[i].startsWith(setRurrRole)) {
  1035. if (iZT == (onlyFlowFlowStep.length - 1)) {
  1036. nextRole = null;
  1037. } else {
  1038. nextRole = onlyFlowFlowStep[iZT + 1];
  1039. }
  1040. break;
  1041. }
  1042. }
  1043. }
  1044. if (nextRole == null) {
  1045. } else {
  1046. up_targerUser_flow_roles_dept = flowMainService.getUpRoleTargetUsers(flowMain, nextRole, onlyFlowFlowStep);
  1047. if (up_targerUser_flow_roles_dept.getFrameUser() == null) {
  1048. up_targerUser_flow_roles_dept = flowMainService.getAllUpRoleTargetUsers(flowMain, nextRole);
  1049. }
  1050. targetUser = up_targerUser_flow_roles_dept.getFrameUser();
  1051. roleType = up_targerUser_flow_roles_dept.getFlowRole();
  1052. }
  1053. }
  1054. if (targetUser == null) {
  1055. // return null;
  1056. System.out.println("3没有找到对应人:" + "if (targetUser == null) {");
  1057. targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  1058. if (targetUser == null) {
  1059. System.err.println("异常,没有找到目标人");
  1060. return null;
  1061. }
  1062. roleType = candidateGroup;
  1063. }
  1064. startTask = flowService.startTask(processDefine, null, businessId, targetUser, currUser);
  1065. end = true;
  1066. startTask.put("roleType", roleType);
  1067. return startTask;
  1068. }
  1069. }
  1070. }
  1071. if (!end) {
  1072. for (int i = 0; i < ConstantFlowType.FLOW_ROLES_CHECK.length; i++) {
  1073. if (ConstantFlowType.FLOW_ROLES_CHECK[i].equals(setRurrRole)) {//1.1.3如果是收纳关系的查收纳
  1074. //查看谁是对应角色并查找对应的人
  1075. String role = ConstantFlowType.ROLES_CHECK[i];
  1076. // List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKey(role, ConstantFlowType.ROLETYPE);
  1077. // 在上面的方法基础上,增加groupId和用户状态的过滤
  1078. List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKeyAndGroup(
  1079. role, ConstantFlowType.ROLETYPE, currUser.getGroupId());
  1080. if (!targetUserList.isEmpty()) {
  1081. if (targetUserList.size() >= 1) {
  1082. targetUser = targetUserList.get(0);
  1083. }
  1084. }
  1085. if (targetUser == null) {
  1086. // return null;
  1087. System.out.println("4没有找到对应人:" + "if (targetUser == null) {");
  1088. targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  1089. if (targetUser == null) {
  1090. System.err.println("异常,没有找到目标人");
  1091. return null;
  1092. }
  1093. roleType = candidateGroup;
  1094. }
  1095. startTask = flowService.startTask(processDefine, null, businessId, targetUser, currUser);
  1096. end = true;
  1097. startTask.put("roleType", roleType);
  1098. return startTask;
  1099. }
  1100. }
  1101. }
  1102. return null;
  1103. }
  1104. //走到这里就没有找到对应的流程节点,所以需要报错 返回null
  1105. System.out.println("异常错误,没有找到对应的流程节点");
  1106. return null;
  1107. }
  1108. } else if (nodeNum > 1) {
  1109. // 2.如果大于1就是非正常流程需要把目标人填自己直到自己流转到自己流程上
  1110. // 需要进行循环审核过程
  1111. boolean isZhuYaoLingDao = "flow_zyld".equals(currRole) ? true : false; //2023年5月17日 章总修改,在开始申请的时候不判断身份是否是该节点本身份,而是必须要进行审核,所以注释掉下面的判断
  1112. if (isZhuYaoLingDao) {//2023年7月5日 章总在第七批次又改回来了 //2023年5月17日 章总修改,在开始申请的时候不判断身份是否是该节点本身份,而是必须要进行审核,所以注释掉下面的判断
  1113. targetUser = currUser;
  1114. startTask = flowService.startTask(processDefine, null, businessId, targetUser, currUser);
  1115. if (!startTask.isEmpty()) {
  1116. {
  1117. // String flow_id = startTask.get("processInstanceId").toString();//"流程实例ID:" + task.getProcessInstanceId());是会变化的所以没有用
  1118. List<Task> list = taskService.createTaskQuery().processInstanceBusinessKey(businessId)//创建任务查询对象
  1119. .taskAssignee(targetUser.getId())//指定个人任务查询
  1120. // .processInstanceId("12516")
  1121. .list();
  1122. if (list == null || list.isEmpty() || list.size() <= 0) {
  1123. System.err.println("异常,没有找到任务对象");
  1124. return null;
  1125. }
  1126. //2.1通过flow_id和targetUser获取下一个UserTask
  1127. Task task = list.get(0);
  1128. //task是当前流程的信息
  1129. //如果发现task对应的角色就是自己的角色,就开始正常的走
  1130. //如果发现task对应的角色还不是,就需要再进行设置自己的操作
  1131. String taskDefinitionKey = task.getTaskDefinitionKey(); //id的值如:_9
  1132. String flowId = userPosition.getUserTask().getId();//流程唯一id(我猜的)
  1133. if (flowId.equals(taskDefinitionKey)) {
  1134. //可以开始正常走流程了 嘻嘻...
  1135. Map<String, String> donaturalTaskMap = this.donaturalTask(deploymentid, currUser, task, conditionMap, flowMain);
  1136. if (donaturalTaskMap == null) {
  1137. return null;
  1138. } else {
  1139. startTask.put("roleType", donaturalTaskMap.get("roleType"));
  1140. return startTask;
  1141. }
  1142. } else {
  1143. //还不是自己的角色,还要遍历查找(但是要写在getNextFlow方法里面,且通过flowServiceNextFlow方法改造一下)
  1144. // boolean yes = flowService.runTask(task.getId(), null, "yes", null, currUser, currUser, conditionMap);
  1145. {//遍历对象
  1146. Map<String, String> getNextFlowMap = getNextFlow(businessId, userPosition, deploymentid, currUser, conditionMap, task, flowMain);
  1147. if (getNextFlowMap == null) {
  1148. return null;
  1149. } else {
  1150. startTask.put("roleType", getNextFlowMap.get("roleType"));
  1151. // 如果getNextFlowMap返回数据是:{isEnd=1} 需要特殊处理
  1152. if (getNextFlowMap.get("isEnd") == null) {
  1153. return startTask;
  1154. } else {
  1155. startTask.put("isEnd", getNextFlowMap.get("isEnd"));
  1156. return startTask;
  1157. }
  1158. }
  1159. }
  1160. }
  1161. }
  1162. } else {
  1163. return null;
  1164. }
  1165. } else { //2023年5月17日 章总修改,在开始申请的时候不判断身份是否是该节点本身份,而是必须要进行审核,所以新增掉下面的操作
  1166. if (ConstantFlowType.isMoreDept) {
  1167. String leader = null;
  1168. FrameUserDeptExample frameUserDeptExample = new FrameUserDeptExample();
  1169. frameUserDeptExample.createCriteria().andDeptIdEqualTo(flowMain.getDeptId()).andUserIdEqualTo(flowMain.getCreatedBy());
  1170. List<FrameUserDept> frameUserDepts = frameUserDeptService.selectByExample(frameUserDeptExample);
  1171. if (frameUserDepts.isEmpty()) {
  1172. } else {
  1173. // leader = frameUserDepts.get(0).getLeaderId();
  1174. if (leader != null) {
  1175. targetUser = userService.selectByPrimaryKey(leader);
  1176. }
  1177. }
  1178. } else {
  1179. if (currUser.getLeader() != null) {
  1180. targetUser = userService.selectByPrimaryKey(currUser.getLeader());
  1181. }
  1182. }
  1183. if (targetUser == null) {
  1184. targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  1185. }
  1186. startTask = flowService.startTask(processDefine, null, businessId, targetUser, currUser);
  1187. if (!startTask.isEmpty()) {
  1188. return startTask;
  1189. } else {
  1190. return null;
  1191. }
  1192. }
  1193. } else {
  1194. return null;
  1195. }
  1196. //为了实现并联串联审核流程的方法需求
  1197. //要求:flowService.startTask(processDefine, null, businessId, targetUser, currUser);改成flowService.startTask(processDefine, null, businessId, targetUsers,totalnumber, currUser);(修改内容目标人改成数组targetUsers,审核通过数量totalnumber自己定义)
  1198. //要求2:flowService.runTask(taskId, null, agree, comments, targetUser, currUser, null);改成flowService.runTask(taskId, null, agree, comments, targetUsers,totalnumber, currUser, null);(修改内容目标人改成数组targetUsers,审核通过数量totalnumber自己定义)
  1199. }
  1200. //返回数据{processInstanceId=7501}{processInstanceId=12501}{processInstanceId=17501}
  1201. }
  1202. /**
  1203. * 做一个通用方法,通过UserTask的id和deloymentId来获取指定的UserTask
  1204. */
  1205. public UserTask getUserTaskById(String id, String deloymentId) {
  1206. List<UserTask> taskList = flowService.getTaskList(deloymentId);
  1207. for (int i = 0; i < taskList.size(); i++) {
  1208. if (taskList.get(i).getId().equals(id)) {
  1209. return taskList.get(i);
  1210. }
  1211. }
  1212. return null;
  1213. // List<UserTask> collect = taskList.stream().filter(x -> x.getId().equals(id)).collect(Collectors.toList());
  1214. // if (collect.isEmpty()){
  1215. // return null;
  1216. // }else{
  1217. // return collect.get(0);
  1218. // }
  1219. }
  1220. /**
  1221. * 通过任务id获取userTask信息
  1222. *
  1223. * @param taskId
  1224. * @return
  1225. */
  1226. public UserTask getUserTaskByTaskId(String taskId) {
  1227. return (UserTask) flowService.getCurrentFlowNode(taskId);
  1228. }
  1229. /**
  1230. * 写一个方法,当还不是自己的角色时,需要进入下个节点,若下个节点是收纳就可以结束运行,返回false,说明是end结束了,若返回true,说明正常继续运行
  1231. *
  1232. * @return
  1233. */
  1234. public Boolean flowServiceNextFlow(String deploymentid, Map<String, Object> conditionMap, FrameUser currUser, Task task) throws com.rockstar.flow.exception.FlowException {
  1235. //获取到了我的userTask
  1236. {
  1237. UserTask myNowUserTask = this.getUserTaskById(task.getTaskDefinitionKey(), deploymentid);//id的值如:_9
  1238. //获取到了出去的各条路径
  1239. List<SequenceFlow> outgoingFlows = myNowUserTask.getOutgoingFlows();
  1240. //我的下一个节点位置
  1241. SequenceFlow myNextSequenceFlow = null;
  1242. for (SequenceFlow outgoingFlow : outgoingFlows) {
  1243. String conditionExpression = outgoingFlow.getConditionExpression();
  1244. //如果是空就跳过
  1245. if (conditionExpression == null) {
  1246. continue;
  1247. } else
  1248. //只有是yes的时候才是需要往下运行的,如果
  1249. if (conditionExpression.contains("${agree=='no'}")) {//${agree=='yes'}
  1250. continue;
  1251. } else if (conditionExpression.contains("${agree=='back'}")) {//${agree=='yes'}
  1252. continue;
  1253. } else
  1254. //只有是yes的时候才是需要往下运行的,如果
  1255. if (conditionExpression.contains("${agree=='yes'}")) {//${agree=='yes'}//xxxx
  1256. //发现没有判断条件,那本流程就是下个节点
  1257. myNextSequenceFlow = outgoingFlow;
  1258. } else {
  1259. //发现有明确的判断条件,需要判断是否满足条件才能确认是否本流程就是下个节点
  1260. //原来计划会有多个条件判断,但是现在就一个,所以就先写死一个条件吧
  1261. //获取路径的判断条件
  1262. // List<String> myconditionExpressions = new ArrayList<String>();
  1263. // myconditionExpressions.add(conditionExpression);
  1264. // int isOkNum = 0;
  1265. // for (int i1 = 0; i1 < myconditionExpressions.size(); i1++) {
  1266. // boolean isOk = false;
  1267. // //这是我的判断条件(通过条件判断库去比对数据)
  1268. // String mycondition = myconditionExpressions.get(i1);
  1269. // if (mycondition.contains("billMoney")) {
  1270. //// ${billMoney>3000}
  1271. // Double billMoney = Double.valueOf(conditionMap.get("billMoney").toString());
  1272. // if (mycondition.contains("<=")) {
  1273. // String substring = mycondition.substring(mycondition.indexOf("<=") + 2, mycondition.length() - 1);
  1274. // if (billMoney <= Double.valueOf(substring)) {
  1275. //// ok
  1276. // isOk = true;
  1277. //
  1278. // }
  1279. // } else if (mycondition.contains("<")) {
  1280. // String substring = mycondition.substring(mycondition.indexOf("<") + 1, mycondition.length() - 1);
  1281. // if (billMoney < Double.valueOf(substring)) {
  1282. //// ok
  1283. // isOk = true;
  1284. // }
  1285. // } else if (mycondition.contains(">=")) {
  1286. // String substring = mycondition.substring(mycondition.indexOf(">=") + 2, mycondition.length() - 1);
  1287. // if (billMoney >= Double.valueOf(substring)) {
  1288. //// ok
  1289. // isOk = true;
  1290. // }
  1291. // } else if (mycondition.contains(">")) {
  1292. // String substring = mycondition.substring(mycondition.indexOf(">") + 1, mycondition.length() - 1);
  1293. // if (billMoney > Double.valueOf(substring)) {
  1294. //// ok
  1295. // isOk = true;
  1296. // }
  1297. // } else if (mycondition.contains("==")) {
  1298. // String substring = mycondition.substring(mycondition.indexOf("==") + 2, mycondition.length() - 1);
  1299. // BigDecimal data1 = new BigDecimal(billMoney);
  1300. // BigDecimal data2 = new BigDecimal(substring);
  1301. // int i2 = data1.compareTo(data2);
  1302. // if (i2 == 0) {
  1303. //// ok
  1304. // isOk = true;
  1305. // }
  1306. // }
  1307. // }
  1308. //
  1309. // if (isOk) {
  1310. // isOkNum = isOkNum + 1;
  1311. // }
  1312. // }
  1313. // if (isOkNum == myconditionExpressions.size()) {
  1314. // myNextSequenceFlow = outgoingFlow;
  1315. // }
  1316. if (this.booleanConditionIsOk(conditionExpression, conditionMap)) {
  1317. myNextSequenceFlow = outgoingFlow;
  1318. }
  1319. }
  1320. //如果没有找到下个流程节点就继续找
  1321. if (myNextSequenceFlow == null) {
  1322. continue;
  1323. }
  1324. {//下面是找到了下个流程节点,需要进行正常的运行节点了
  1325. //================================================================================================
  1326. // TaskList.get(1).getOutgoingFlows().get(1).getTargetFlowElement().getCandidateGroups()
  1327. FlowElement targetFlowElement = myNextSequenceFlow.getTargetFlowElement();
  1328. if (targetFlowElement instanceof EndEvent) {//如果是的话就是最后审核状态
  1329. System.out.println("已经是结束流程了,直接完成审核就行了3");
  1330. boolean yes = flowService.runTask(task.getId(), null, "yes", null, currUser, currUser, conditionMap);
  1331. return null;
  1332. }
  1333. String candidateGroup = ((UserTask) targetFlowElement).getCandidateGroups().get(0);//targetFlowElement.getCandidateGroups();
  1334. String setRurrRole = this.getSetRurrRole(candidateGroup);
  1335. boolean end = false;
  1336. for (String s : ConstantFlowType.FLOW_ROLES_DEPT) {
  1337. if (s.equals(setRurrRole)) {//1.1.1如果是部门关系的查部门
  1338. // String leader = currUser.getLeader();
  1339. // targetUser = userService.selectByPrimaryKey(leader);
  1340. // if (targetUser == null) {
  1341. // return null;
  1342. // }
  1343. boolean yes = flowService.runTask(task.getId(), null, "yes", null, currUser, currUser, conditionMap);
  1344. end = true;
  1345. return true;
  1346. }
  1347. }
  1348. if (!end) {
  1349. for (int i = 0; i < ConstantFlowType.FLOW_ROLES.length; i++) {
  1350. if (ConstantFlowType.FLOW_ROLES[i].equals(setRurrRole)) {//1.1.2如果是领导关系的查领导
  1351. //查看谁是对应角色并查找对应的人
  1352. // String role = ConstantFlowType.ROLES[i];
  1353. // List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKey(role, ConstantFlowType.ROLETYPE);
  1354. // if (!targetUserList.isEmpty()) {
  1355. // if (targetUserList.size() >= 1) {
  1356. // targetUser = targetUserList.get(0);
  1357. // }
  1358. // }
  1359. // if (targetUser == null) {
  1360. // return null;
  1361. // }
  1362. boolean yes = flowService.runTask(task.getId(), null, "yes", null, currUser, currUser, conditionMap);
  1363. end = true;
  1364. return true;
  1365. }
  1366. }
  1367. }
  1368. if (!end) {
  1369. for (int i = 0; i < ConstantFlowType.FLOW_ROLES_CHECK.length; i++) {
  1370. if (ConstantFlowType.FLOW_ROLES_CHECK[i].equals(setRurrRole)) {//1.1.3如果是收纳关系的查收纳
  1371. //查看谁是对应角色并查找对应的人
  1372. String role = ConstantFlowType.ROLES_CHECK[i];
  1373. // List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKey(role, ConstantFlowType.ROLETYPE);
  1374. // 在上面的方法基础上,增加groupId和用户状态的过滤
  1375. List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKeyAndGroup(
  1376. role, ConstantFlowType.ROLETYPE, currUser.getGroupId());
  1377. FrameUser targetUser = null;
  1378. if (!targetUserList.isEmpty()) {
  1379. if (targetUserList.size() >= 1) {
  1380. targetUser = targetUserList.get(0);
  1381. }
  1382. }
  1383. if (targetUser == null) {
  1384. // return null;
  1385. System.out.println("5没有找到对应人:" + "if (targetUser == null) {");
  1386. targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  1387. if (targetUser == null) {
  1388. System.err.println("异常,没有找到目标人");
  1389. return null;
  1390. }
  1391. }
  1392. boolean yes = flowService.runTask(task.getId(), null, "yes", null, targetUser, currUser, conditionMap);
  1393. end = true;
  1394. return false;
  1395. }
  1396. }
  1397. }
  1398. break;
  1399. }
  1400. }
  1401. //如果运行找到这里就说明没有找到下个流程节点了,流程可以结束了
  1402. System.out.println("已经没有下个申请流程了,已经结束了2");
  1403. //
  1404. boolean yes = flowService.runTask(task.getId(), null, "yes", null, currUser, currUser, conditionMap);
  1405. return null;
  1406. }
  1407. // {
  1408. // //下面的部分将会被淘汰掉.....................................................
  1409. // List<Object> nextCandidateGroupByDeploy = flowService.getNextCandidateGroupByDeploy(deploymentid, task.getTaskDefinitionKey(), false);
  1410. // if (!nextCandidateGroupByDeploy.isEmpty() && nextCandidateGroupByDeploy.size() >= 1) {
  1411. // for (int ii = 0; ii < nextCandidateGroupByDeploy.size(); ii++) {
  1412. // UserTask myNextTask = null;//我要走的流程
  1413. // UserTask userTask = (UserTask) nextCandidateGroupByDeploy.get(ii);
  1414. // String candidateGroup = userTask.getCandidateGroups().get(0);//dept_superior_1_0_1-yes
  1415. // if (!"-yes".equals(candidateGroup.substring(candidateGroup.indexOf("-")))) {
  1416. // continue;
  1417. // }
  1418. // //需要的角色
  1419. // String setRurrRole = this.getSetRurrRole(candidateGroup);
  1420. // {
  1421. // // 获取判断条件进行判断是否符合条件,符合就往下走,不符合就跳到下一个节点进行判断
  1422. // //获取路径的判断条件
  1423. // List<String> myconditionExpressions = new ArrayList<String>();
  1424. // List<SequenceFlow> outgoingFlows = userTask.getOutgoingFlows();
  1425. // for (SequenceFlow outgoingFlow : outgoingFlows) {
  1426. // String conditionExpression = outgoingFlow.getConditionExpression();
  1427. // if (conditionExpression == null) {
  1428. // continue;
  1429. // }
  1430. // if (conditionExpression.contains("${agree==")) {
  1431. // continue;
  1432. // }
  1433. // myconditionExpressions.add(conditionExpression);
  1434. // }
  1435. // if (myconditionExpressions.isEmpty()) {//没有条件就直接可以使用
  1436. // myNextTask = userTask;
  1437. //
  1438. // } else {//有条件就判断是否满足条件,不满足就运行下一个
  1439. // int isOkNum = 0;
  1440. // for (int i1 = 0; i1 < myconditionExpressions.size(); i1++) {
  1441. // boolean isOk = false;
  1442. // //这是我的判断条件(通过条件判断库去比对数据)
  1443. // String mycondition = myconditionExpressions.get(i1);
  1444. // if (mycondition.contains("billMoney")) {
  1445. //// ${billMoney>3000}
  1446. // Double billMoney = Double.valueOf(conditionMap.get("billMoney").toString());
  1447. // if (mycondition.contains("<=")) {
  1448. // String substring = mycondition.substring(mycondition.indexOf("<=") + 2, mycondition.length() - 1);
  1449. // if (billMoney <= Double.valueOf(substring)) {
  1450. //// ok
  1451. // isOk = true;
  1452. //
  1453. // }
  1454. // } else if (mycondition.contains("<")) {
  1455. // String substring = mycondition.substring(mycondition.indexOf("<") + 1, mycondition.length() - 1);
  1456. // if (billMoney < Double.valueOf(substring)) {
  1457. //// ok
  1458. // isOk = true;
  1459. // }
  1460. // } else if (mycondition.contains(">=")) {
  1461. // String substring = mycondition.substring(mycondition.indexOf(">=") + 2, mycondition.length() - 1);
  1462. // if (billMoney >= Double.valueOf(substring)) {
  1463. //// ok
  1464. // isOk = true;
  1465. // }
  1466. // } else if (mycondition.contains(">")) {
  1467. // String substring = mycondition.substring(mycondition.indexOf(">") + 1, mycondition.length() - 1);
  1468. // if (billMoney > Double.valueOf(substring)) {
  1469. //// ok
  1470. // isOk = true;
  1471. // }
  1472. // } else if (mycondition.contains("==")) {
  1473. // String substring = mycondition.substring(mycondition.indexOf("==") + 2, mycondition.length() - 1);
  1474. // BigDecimal data1 = new BigDecimal(billMoney);
  1475. // BigDecimal data2 = new BigDecimal(substring);
  1476. // int i2 = data1.compareTo(data2);
  1477. // if (i2 == 0) {
  1478. //// ok
  1479. // isOk = true;
  1480. // }
  1481. // }
  1482. // }
  1483. //
  1484. // if (isOk) {
  1485. // isOkNum = isOkNum + 1;
  1486. // }
  1487. // }
  1488. // if (isOkNum == myconditionExpressions.size()) {
  1489. // myNextTask = userTask;
  1490. // }
  1491. //
  1492. // if (myNextTask == null) {
  1493. // continue;
  1494. // }
  1495. //
  1496. // }
  1497. // }
  1498. // //================================================================
  1499. // boolean end = false;
  1500. // for (String s : ConstantFlowType.FLOW_ROLES_DEPT) {
  1501. // if (s.equals(setRurrRole)) {//1.1.1如果是部门关系的查部门
  1502. //// String leader = currUser.getLeader();
  1503. //// targetUser = userService.selectByPrimaryKey(leader);
  1504. //// if (targetUser == null) {
  1505. //// return null;
  1506. //// }
  1507. // boolean yes = flowService.runTask(task.getId(), null, "yes", null, currUser, currUser, conditionMap);
  1508. //
  1509. // end = true;
  1510. // return true;
  1511. // }
  1512. // }
  1513. // if (!end) {
  1514. // for (int i = 0; i < ConstantFlowType.FLOW_ROLES.length; i++) {
  1515. // if (ConstantFlowType.FLOW_ROLES[i].equals(setRurrRole)) {//1.1.2如果是领导关系的查领导
  1516. // //查看谁是对应角色并查找对应的人
  1517. //// String role = ConstantFlowType.ROLES[i];
  1518. //// List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKey(role, ConstantFlowType.ROLETYPE);
  1519. //// if (!targetUserList.isEmpty()) {
  1520. //// if (targetUserList.size() >= 1) {
  1521. //// targetUser = targetUserList.get(0);
  1522. //// }
  1523. //// }
  1524. //// if (targetUser == null) {
  1525. //// return null;
  1526. //// }
  1527. // boolean yes = flowService.runTask(task.getId(), null, "yes", null, currUser, currUser, conditionMap);
  1528. // end = true;
  1529. // return true;
  1530. // }
  1531. // }
  1532. //
  1533. // }
  1534. // if (!end) {
  1535. // for (int i = 0; i < ConstantFlowType.FLOW_ROLES_CHECK.length; i++) {
  1536. // if (ConstantFlowType.FLOW_ROLES_CHECK[i].equals(setRurrRole)) {//1.1.3如果是收纳关系的查收纳
  1537. // //查看谁是对应角色并查找对应的人
  1538. // String role = ConstantFlowType.ROLES_CHECK[i];
  1539. // List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKey(role, ConstantFlowType.ROLETYPE);
  1540. // FrameUser targetUser = null;
  1541. // if (!targetUserList.isEmpty()) {
  1542. // if (targetUserList.size() >= 1) {
  1543. // targetUser = targetUserList.get(0);
  1544. // }
  1545. // }
  1546. // if (targetUser == null) {
  1547. // return null;
  1548. // }
  1549. // boolean yes = flowService.runTask(task.getId(), null, "yes", null, targetUser, currUser, conditionMap);
  1550. // end = true;
  1551. // return false;
  1552. // }
  1553. // }
  1554. // }
  1555. // break;
  1556. // }
  1557. // System.out.println("已经没有下个申请流程了,已经结束了");
  1558. // //
  1559. // boolean yes = flowService.runTask(task.getId(), null, "yes", null, currUser, currUser, conditionMap);
  1560. // return null;
  1561. // } else {
  1562. // System.out.println("已经没有下个申请流程了,已经结束了");
  1563. // //
  1564. // boolean yes = flowService.runTask(task.getId(), null, "yes", null, currUser, currUser, conditionMap);
  1565. // return null;
  1566. // }
  1567. // }
  1568. }
  1569. /**
  1570. * 遍历进行操作最终获取用户自己的角色
  1571. *
  1572. * @return
  1573. */
  1574. public Map<String, String> getNextFlow(String businessId, UserTaskMore userPosition, String deploymentid, FrameUser currUser, Map<String, Object> conditionMap, Task task, FlowMain flowMain) throws com.rockstar.flow.exception.FlowException {
  1575. FrameUser targetUser = currUser;
  1576. Boolean aBoolean = this.flowServiceNextFlow(deploymentid, conditionMap, currUser, task);
  1577. if (aBoolean == null) {
  1578. Map<String, String> objectObjectHashMap = new HashMap<>();
  1579. objectObjectHashMap.put("isEnd", "1");
  1580. return objectObjectHashMap;
  1581. } else if (!aBoolean) {
  1582. return new HashMap<>();
  1583. } else if (aBoolean) {
  1584. //继续运行下面的步骤
  1585. }
  1586. {//遍历对象
  1587. List<Task> list2 = taskService.createTaskQuery().processInstanceBusinessKey(businessId)//创建任务查询对象
  1588. .taskAssignee(targetUser.getId())//指定个人任务查询
  1589. // .processInstanceId("12516")
  1590. .list();
  1591. if (list2 == null || list2.isEmpty() || list2.size() <= 0) {
  1592. System.err.println("异常,没有找到任务对象2");
  1593. return null;
  1594. }
  1595. //2.1通过flow_id和targetUser获取下一个UserTask
  1596. Task task2 = list2.get(0);
  1597. //task是当前流程的信息
  1598. //如果发现task对应的角色就是自己的角色,就开始正常的走
  1599. //如果发现task对应的角色还不是,就需要再进行设置自己的操作
  1600. String taskDefinitionKey2 = task2.getTaskDefinitionKey(); //id的值如:_9
  1601. String flowId2 = userPosition.getUserTask().getId();//流程唯一id(我猜的)
  1602. if (flowId2.equals(taskDefinitionKey2)) {
  1603. //可以开始正常走流程了 嘻嘻...
  1604. {
  1605. // //可以开始正常走流程了 嘻嘻...
  1606. }
  1607. return this.donaturalTask(deploymentid, currUser, task2, conditionMap, flowMain);
  1608. } else {
  1609. //还不是自己的角色,还要遍历查找
  1610. return getNextFlow(businessId, userPosition, deploymentid, currUser, conditionMap, task2, flowMain);
  1611. }
  1612. }
  1613. // return null;
  1614. }
  1615. /**
  1616. * 共用方法 //当前用户的角色定义(如果判断下来还是""就是没有确认是否是部门主管),
  1617. * 但是注意,这只是判断是否是主管还是 分管领导的问题, 还没有判断是否是出纳的问题,不是哪里都适用的
  1618. *
  1619. * @param currUser
  1620. * @return
  1621. */
  1622. public String getCurrRole(FrameUser currUser, FlowMain flowMain) {
  1623. //当前用户的角色定义(如果判断下来还是""就是没有确认是否是部门主管)
  1624. String currRole = "";//flow_fgld", "flow_sjfgld", "flow_zyld或者curr_user,dept_head
  1625. {
  1626. //1获取用户流程类型
  1627. {
  1628. String[] flow_roles = ConstantFlowType.FLOW_ROLES;//{"flow_fgld", "flow_sjfgld", "flow_zyld"};
  1629. String[] roles = ConstantFlowType.ROLES;// {"fgld", "sjfgld", "zyld"};
  1630. // frame_role_data
  1631. List<FrameRoleData> FrameRoleDatas = flowMainService.findFrameRoleDatasByUserId(currUser.getId(), ConstantFlowType.ROLETYPE);//"FLOW"
  1632. Integer c = null;
  1633. //判断用户的最高用户流类型
  1634. for (FrameRoleData frameRoleData : FrameRoleDatas) {
  1635. String roleKey = frameRoleData.getRoleKey();
  1636. for (int i = 0; i < roles.length; i++) {
  1637. if (roles[i].equals(roleKey)) {
  1638. if (c == null) {
  1639. c = i;
  1640. } else if (c < i) {
  1641. c = i;
  1642. }
  1643. break;
  1644. }
  1645. }
  1646. }
  1647. if (c != null) {
  1648. currRole = flow_roles[c];
  1649. return currRole;
  1650. }
  1651. }
  1652. //2获取用户部门是否是主管
  1653. {
  1654. String department = flowMain.getDeptId();
  1655. SysDept sysDept = sysDeptService.selectByPrimaryKey(department);
  1656. if (sysDept == null) {//没有部门信息
  1657. if (currRole.equals("")) {
  1658. currRole = "";
  1659. return null;
  1660. } else {
  1661. //是领导流程类型
  1662. }
  1663. } else {
  1664. String changedBy = sysDept.getChangedBy();
  1665. if (StringUtils.isEmpty(changedBy)) {//没有找到部门主管
  1666. currRole = ConstantFlowType.FLOW_ROLES_DEPT[0];//"curr_user";
  1667. // if (currRole.equals("")) {
  1668. // currRole = "";
  1669. // } else {
  1670. // //是领导流程类型
  1671. // }
  1672. // return null;
  1673. } else {//找到部门主管
  1674. if (changedBy.equals(currUser.getId())) {//自己是部门主管
  1675. if (currRole.equals("")) {
  1676. currRole = ConstantFlowType.FLOW_ROLES_DEPT[2];//"dept_head";
  1677. } else {
  1678. //是领导流程类型
  1679. }
  1680. } else {//部门主管是别人,自己不是部门主管
  1681. if (currRole.equals("")) {
  1682. currRole = ConstantFlowType.FLOW_ROLES_DEPT[0];//"curr_user";
  1683. } else {
  1684. //是领导流程类型
  1685. }
  1686. }
  1687. }
  1688. }
  1689. }
  1690. }
  1691. return currRole;
  1692. }
  1693. /**
  1694. * 写一个方法, 已知用户信息 zt ok
  1695. * 申请付款时 通过用户信号获取用户在全流程中的位置,如果没有找到对象,返回为null就直接提交到admin用户去审核,如果对象里面的nodeNum是1就是正常流程,如果大于1就是非正常流程需要把目标人填自己直到自己流转到自己流程上
  1696. */
  1697. public UserTaskMore findUserPosition(String currRole, String deploymentid) {
  1698. //当前用户的角色定义(如果判断下来还是""就是没有确认是否是部门主管)
  1699. // String currRole = this.getCurrRole(currUser2);
  1700. //没有获取到角色异常返回null
  1701. if (currRole == null || currRole.equals("")) {
  1702. return null;
  1703. }
  1704. //获取活动节点
  1705. //这是流程排序编号
  1706. int nodeNum = 0;
  1707. List<UserTask> taskList = flowService.getTaskList(deploymentid);
  1708. UserTask userTask = taskList.get(0);
  1709. nodeNum = nodeNum + 1;
  1710. String s = userTask.getCandidateGroups().get(0);//s=dept_head_1_0_1-yes/curr_user-no
  1711. String setRurrRole = this.getSetRurrRole(s);
  1712. if (currRole.equals(setRurrRole)) {//如果设置角色和当前用户角色一致,表示用户就是当前流程排序编号上
  1713. // return userTask;
  1714. // return nodeNum;
  1715. return new UserTaskMore(userTask, nodeNum, userTask);
  1716. } else {//要进行轮查获取用户位置
  1717. UserTaskMore nextCandidateGroupByDeploy = this.getNextMyUserTask(taskList, currRole, nodeNum);
  1718. // UserTaskMore nextCandidateGroupByDeploy = getNextCandidateGroupByDeploy(userTask, currRole, nodeNum, deploymentid);
  1719. nextCandidateGroupByDeploy.setCurrentUserTask(userTask);
  1720. return nextCandidateGroupByDeploy;
  1721. }
  1722. }
  1723. /**
  1724. * 申请付款时 通过传递的数据递归获取用户角色实际的运行节点
  1725. *
  1726. * @return
  1727. */
  1728. public UserTaskMore getNextMyUserTask(List<UserTask> taskList, String currRole, Integer nodeNum) {
  1729. for (int i = 1; i < taskList.size(); i++) {
  1730. nodeNum = 2;
  1731. UserTask myuserTask = taskList.get(i);
  1732. String taskKey = myuserTask.getCandidateGroups().get(0);//s=dept_head_1_0_1-yes/curr_user-no
  1733. String taskSetRurrRole = this.getSetRurrRole(taskKey);
  1734. if (currRole.equals(taskSetRurrRole)) {//如果设置角色和当前用户角色一致,表示用户就是当前流程排序编号上
  1735. System.out.println("2结束节点" + nodeNum);
  1736. // return userTask;
  1737. // return nodeNum;
  1738. return new UserTaskMore(myuserTask, nodeNum);
  1739. }
  1740. }
  1741. return null;
  1742. }
  1743. /**
  1744. * 这个方法有问题,不能获取自己想要的,放弃使用了
  1745. * 申请付款时 通过传递的数据递归获取用户角色实际的运行节点
  1746. *
  1747. * @param newUserTask
  1748. * @param currRole
  1749. * @param nodeNum
  1750. * @return
  1751. */
  1752. public UserTaskMore getNextCandidateGroupByDeploy(UserTask newUserTask, String currRole, Integer nodeNum, String deploymentid) {
  1753. List<Object> nextCandidateGroupByDeploy = flowService.getNextCandidateGroupByDeploy(deploymentid, newUserTask.getId(), false);
  1754. if (!nextCandidateGroupByDeploy.isEmpty() && nextCandidateGroupByDeploy.size() >= 1) {
  1755. // //进行分支判断
  1756. // for (int i = 0; i < nextCandidateGroupByDeploy.size(); i++) {
  1757. // UserTask userTask = (UserTask) nextCandidateGroupByDeploy.get(i);
  1758. // String taskKey = userTask.getCandidateGroups().get(0);//dept_head_1_0_1-yes
  1759. // String yesNo = taskKey.substring(taskKey.indexOf("-"));
  1760. // if (!"yes".equals(yesNo)) {
  1761. // continue;
  1762. // }
  1763. // String setRurrRole = this.getSetRurrRole(taskKey);//获取任务的角色
  1764. //
  1765. // }
  1766. nodeNum = nodeNum + 1;
  1767. System.out.println("运行节点" + nodeNum);
  1768. UserTask userTask = (UserTask) nextCandidateGroupByDeploy.get(0);
  1769. String s = userTask.getCandidateGroups().get(0);//s=dept_head_1_0_1-yes/curr_user-no
  1770. String setRurrRole = this.getSetRurrRole(s);
  1771. if (currRole.equals(setRurrRole)) {//如果设置角色和当前用户角色一致,表示用户就是当前流程排序编号上
  1772. System.out.println("1结束节点" + nodeNum);
  1773. // return userTask;
  1774. // return nodeNum;
  1775. return new UserTaskMore(userTask, nodeNum);
  1776. } else {
  1777. getNextCandidateGroupByDeploy(userTask, currRole, nodeNum, deploymentid);
  1778. }
  1779. } else {
  1780. return null;
  1781. }
  1782. return null;
  1783. }
  1784. @Autowired
  1785. private FrameUserDeptService frameUserDeptService;
  1786. /**
  1787. * 获取部门领导
  1788. *
  1789. * @param currUser
  1790. * @param flowMain
  1791. * @return
  1792. */
  1793. public FrameUser getDepartmentChargedBy(FrameUser currUser, FlowMain flowMain) {
  1794. FrameUser targetUser = null;
  1795. String department = null;
  1796. if (ConstantFlowType.isMoreDept) {
  1797. department = flowMain.getDeptId();
  1798. } else {
  1799. department = currUser.getDepartment();
  1800. }
  1801. SysDept sysDept = sysDeptService.selectByPrimaryKey(department);
  1802. if (sysDept == null) {//没有部门信息
  1803. } else {
  1804. String chargedBy = sysDept.getChangedBy();
  1805. if (StringUtils.isEmpty(chargedBy)) {//没有找到部门主管
  1806. } else {
  1807. targetUser = userService.selectByPrimaryKey(chargedBy);
  1808. }
  1809. }
  1810. return targetUser;
  1811. }
  1812. /**
  1813. * 写一个通用方法,专门根据条件获取部门领导是谁
  1814. * targetRole:下一个审核人的角色
  1815. * currUser:当前的审核人角色
  1816. * 返回 部门的目标用户和对应的角色,如果部门的目标用户没有找到,就返回下个节点的角色信息(并且下个节点必定不是部门用户信息),目标用户为空
  1817. */
  1818. public TagerUserAndFlowRole getTargerUser_FLOW_ROLES_DEPT(String targetRole, FrameUser currUser, FlowMain flowMain) {
  1819. TagerUserAndFlowRole tagerUserAndFlowRole = new TagerUserAndFlowRole();
  1820. FrameUser targetUser = null;
  1821. if (targetRole.equals(ConstantFlowType.FLOW_ROLES_DEPT[2])) {//发现下一个审核人是部门领导,要去找部门领导
  1822. targetUser = this.getDepartmentChargedBy(currUser, flowMain);
  1823. if (targetUser == null) {
  1824. String nextRole = null;
  1825. String[] onlyFlowFlowStep = flowMainService.getOnlyFlowFlowStep(flowMain);
  1826. {//获取直接领导的下的流程节点是什么
  1827. for (int i = 0; i < onlyFlowFlowStep.length; i++) {
  1828. if (onlyFlowFlowStep[i].startsWith(ConstantFlowType.FLOW_ROLES_DEPT[2])) {
  1829. if (i == (onlyFlowFlowStep.length - 1)) {
  1830. nextRole = null;
  1831. } else {
  1832. nextRole = onlyFlowFlowStep[i + 1];
  1833. }
  1834. break;
  1835. }
  1836. }
  1837. }
  1838. if (nextRole == null) {
  1839. tagerUserAndFlowRole.setOnlyFlowFlowStep(onlyFlowFlowStep);
  1840. return tagerUserAndFlowRole;
  1841. } else {
  1842. tagerUserAndFlowRole.setFlowRole(nextRole);
  1843. tagerUserAndFlowRole.setOnlyFlowFlowStep(onlyFlowFlowStep);
  1844. return tagerUserAndFlowRole;
  1845. }
  1846. } else {
  1847. tagerUserAndFlowRole.setFlowRole(this.getAllFlowRole(ConstantFlowType.FLOW_ROLES_DEPT[2], flowMain.getFlowType()));
  1848. tagerUserAndFlowRole.setFrameUser(targetUser);
  1849. // tagerUserAndFlowRole.setOnlyFlowFlowStep(onlyFlowFlowStep);
  1850. return tagerUserAndFlowRole;
  1851. }
  1852. } else {
  1853. String leader = null;
  1854. if (ConstantFlowType.isMoreDept) {
  1855. FrameUserDeptExample frameUserDeptExample = new FrameUserDeptExample();
  1856. frameUserDeptExample.createCriteria().andDeptIdEqualTo(flowMain.getDeptId()).andUserIdEqualTo(flowMain.getCreatedBy());
  1857. List<FrameUserDept> frameUserDepts = frameUserDeptService.selectByExample(frameUserDeptExample);
  1858. if (frameUserDepts.isEmpty()) {
  1859. String nextRole = null;
  1860. String[] onlyFlowFlowStep = flowMainService.getOnlyFlowFlowStep(flowMain);
  1861. int findSetpI = 0;
  1862. {//获取直接领导的下的流程节点是什么
  1863. for (int i = 0; i < onlyFlowFlowStep.length; i++) {
  1864. if (onlyFlowFlowStep[i].startsWith(ConstantFlowType.FLOW_ROLES_DEPT[1])) {
  1865. if (i == (onlyFlowFlowStep.length - 1)) {
  1866. nextRole = null;
  1867. } else {
  1868. nextRole = onlyFlowFlowStep[i + 1];
  1869. findSetpI = i + 1;
  1870. }
  1871. break;
  1872. }
  1873. }
  1874. }
  1875. if (nextRole == null) {
  1876. tagerUserAndFlowRole.setOnlyFlowFlowStep(onlyFlowFlowStep);
  1877. return tagerUserAndFlowRole;
  1878. } else if (!nextRole.startsWith(ConstantFlowType.FLOW_ROLES_DEPT[2])) {
  1879. tagerUserAndFlowRole.setFlowRole(nextRole);
  1880. tagerUserAndFlowRole.setOnlyFlowFlowStep(onlyFlowFlowStep);
  1881. return tagerUserAndFlowRole;
  1882. } else {
  1883. if (findSetpI == (onlyFlowFlowStep.length - 1)) {
  1884. tagerUserAndFlowRole.setOnlyFlowFlowStep(onlyFlowFlowStep);
  1885. return tagerUserAndFlowRole;
  1886. } else {
  1887. tagerUserAndFlowRole.setFlowRole(onlyFlowFlowStep[findSetpI + 1]);
  1888. tagerUserAndFlowRole.setOnlyFlowFlowStep(onlyFlowFlowStep);
  1889. return tagerUserAndFlowRole;
  1890. }
  1891. }
  1892. } else {
  1893. // leader = frameUserDepts.get(0).getLeaderId();
  1894. }
  1895. } else {
  1896. leader = currUser.getLeader();
  1897. }
  1898. if (StringUtils.isEmpty(leader)) {//没有找到直接领导
  1899. String nextRole = null;
  1900. String[] onlyFlowFlowStep = flowMainService.getOnlyFlowFlowStep(flowMain);
  1901. int findSetpI = 0;
  1902. {//获取直接领导的下的流程节点是什么
  1903. for (int i = 0; i < onlyFlowFlowStep.length; i++) {
  1904. if (onlyFlowFlowStep[i].startsWith(ConstantFlowType.FLOW_ROLES_DEPT[1])) {
  1905. if (i == (onlyFlowFlowStep.length - 1)) {
  1906. nextRole = null;
  1907. } else {
  1908. nextRole = onlyFlowFlowStep[i + 1];
  1909. findSetpI = i + 1;
  1910. }
  1911. break;
  1912. }
  1913. }
  1914. }
  1915. if (nextRole == null) {
  1916. tagerUserAndFlowRole.setOnlyFlowFlowStep(onlyFlowFlowStep);
  1917. return tagerUserAndFlowRole;
  1918. } else if (!nextRole.startsWith(ConstantFlowType.FLOW_ROLES_DEPT[2])) {
  1919. tagerUserAndFlowRole.setFlowRole(nextRole);
  1920. tagerUserAndFlowRole.setOnlyFlowFlowStep(onlyFlowFlowStep);
  1921. return tagerUserAndFlowRole;
  1922. } else {
  1923. targetUser = this.getDepartmentChargedBy(currUser, flowMain);
  1924. if (targetUser == null) {
  1925. if (findSetpI == (onlyFlowFlowStep.length - 1)) {
  1926. tagerUserAndFlowRole.setOnlyFlowFlowStep(onlyFlowFlowStep);
  1927. return tagerUserAndFlowRole;
  1928. } else {
  1929. tagerUserAndFlowRole.setFlowRole(onlyFlowFlowStep[findSetpI + 1]);
  1930. tagerUserAndFlowRole.setOnlyFlowFlowStep(onlyFlowFlowStep);
  1931. return tagerUserAndFlowRole;
  1932. }
  1933. } else {
  1934. tagerUserAndFlowRole.setFlowRole(this.getAllFlowRole(ConstantFlowType.FLOW_ROLES_DEPT[2], flowMain.getFlowType()));
  1935. tagerUserAndFlowRole.setFrameUser(targetUser);
  1936. tagerUserAndFlowRole.setOnlyFlowFlowStep(onlyFlowFlowStep);
  1937. return tagerUserAndFlowRole;
  1938. }
  1939. }
  1940. } else {
  1941. targetUser = userService.selectByPrimaryKey(leader);
  1942. tagerUserAndFlowRole.setFlowRole(this.getAllFlowRole(ConstantFlowType.FLOW_ROLES_DEPT[1], flowMain.getFlowType()));
  1943. tagerUserAndFlowRole.setFrameUser(targetUser);
  1944. // tagerUserAndFlowRole.setOnlyFlowFlowStep(onlyFlowFlowStep);
  1945. return tagerUserAndFlowRole;
  1946. }
  1947. }
  1948. // if (targetUser == null) {//没有找到目标人就都传到admin中去
  1949. //// return null;
  1950. // System.out.println("6没有找到对应人:" + "if (targetUser == null) {");
  1951. // targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  1952. // if (targetUser == null) {
  1953. // System.err.println("异常,没有找到目标人");
  1954. // return null;
  1955. // }
  1956. // }
  1957. // return targetUser;
  1958. }
  1959. /**
  1960. * 通过角色关键字,反查本流程节点全部信息,和下面的方法相反
  1961. *
  1962. * @param shortRole
  1963. * @param flowType
  1964. * @return
  1965. */
  1966. public String getAllFlowRole(String shortRole, String flowType) {
  1967. String[] onlylowStepAll = flowMainService.getOnlylowStepAll(flowType);
  1968. for (int i = 0; i < onlylowStepAll.length; i++) {
  1969. if (onlylowStepAll[i].startsWith(shortRole)) {
  1970. return onlylowStepAll[i];
  1971. }
  1972. }
  1973. throw new RuntimeException("异常错误,没有获取到角色信息!");
  1974. // return null;
  1975. }
  1976. /**
  1977. * 通过原key获取角色数据
  1978. *
  1979. * @param s
  1980. * @return
  1981. */
  1982. public static String getSetRurrRole(String s) {
  1983. // String s="dept_head_1_0_1-yes";或者curr_user-no
  1984. String[] s1 = s.contains("-") ? s.substring(0, s.indexOf("-")).split("_") : s.split("_");
  1985. s = s1[0] + "_" + s1[1];
  1986. // System.out.println(s);
  1987. return s;
  1988. }
  1989. /**
  1990. * 采购相关没有用到
  1991. * @param targetRole
  1992. * @param currUser
  1993. * @return
  1994. */
  1995. // public FrameUser getTargerUser_FLOW_ROLES_DEPT_PLUS(String targetRole, FrameUser currUser) {
  1996. // FrameUser targetUser = null;
  1997. // if (targetRole.equals(ConstantFlowType.FLOW_ROLES_DEPT[2])) {//发现下一个审核人是部门领导,要去找部门领导
  1998. // String department = currUser.getDepartment();
  1999. // SysDept sysDept = sysDeptService.selectByPrimaryKey(department);
  2000. // if (sysDept == null) {//没有部门信息
  2001. // } else {
  2002. // String changedBy = sysDept.getChargedBy();
  2003. // if (StringUtils.isEmpty(changedBy)) {//没有找到部门主管
  2004. //
  2005. // } else {
  2006. // targetUser = userService.selectByPrimaryKey(changedBy);
  2007. // }
  2008. // }
  2009. // } else {
  2010. // String leader = currUser.getLeader();
  2011. // if (StringUtils.isEmpty(leader)) {//没有找到直接领导
  2012. // // 流转给子公司超管
  2013. // FrameRoleDataExample example = new FrameRoleDataExample();
  2014. // example.createCriteria().andRoleKeyEqualTo(ConstantFlowType.PURCHASE_ROLES_CHECK_PLUS)
  2015. // .andRoleTypeEqualTo(ConstantFlowType.ROLETYPE2);
  2016. // List<FrameRoleData> frameRoleDataList = frameRoleDataService.selectByExample(example);
  2017. // if(CollectionUtils.isNotEmpty(frameRoleDataList)) {
  2018. // FrameRoleData frameRoleData = frameRoleDataList.get(0);
  2019. // List<String> userIds = frameRoleDataUserService.selectUserByRoleDataId(frameRoleData.getId());
  2020. // if(CollectionUtils.isNotEmpty(userIds)) {
  2021. // FrameUserExample example1 = new FrameUserExample();
  2022. // example1.createCriteria().andIdIn(userIds).andGroupIdEqualTo(currUser.getGroupId())
  2023. // .andStatusEqualTo("1");
  2024. // List<FrameUser> frameUserList = frameUserService.selectByExample(example1);
  2025. // if(CollectionUtils.isNotEmpty(frameUserList)) {
  2026. // targetUser = frameUserList.get(0);
  2027. // }
  2028. // }
  2029. // }
  2030. // } else {
  2031. // targetUser = userService.selectByPrimaryKey(leader);
  2032. // }
  2033. // }
  2034. // if (targetUser == null) {//没有找到目标人就都传到admin中去
  2035. // targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  2036. // if (targetUser == null) {
  2037. // return null;
  2038. // }
  2039. // }
  2040. // return targetUser;
  2041. // }
  2042. /**
  2043. * 没有用到
  2044. * @param processDefine
  2045. * @param deploymentid
  2046. * @param businessId
  2047. * @param currUser
  2048. * @param conditionMap
  2049. * @return
  2050. * @throws com.rockstar.flow.exception.FlowException
  2051. */
  2052. // public Map<String, String> startPurchaseTask(String processDefine, String deploymentid, String businessId,
  2053. // FrameUser currUser, Map<String, Object> conditionMap)
  2054. // throws com.rockstar.flow.exception.FlowException {
  2055. // FrameUser targetUser = null;
  2056. // String currRole = this.getCurrRole(currUser);
  2057. // UserTaskMore userPosition = this.findUserPosition(currRole, deploymentid);
  2058. // Map<String, String> startTask;
  2059. // if (userPosition == null) {
  2060. // targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  2061. // if (targetUser == null) {
  2062. // return null;
  2063. // }
  2064. // startTask = flowService.startTask(processDefine, null, businessId, targetUser, currUser);
  2065. // return startTask;
  2066. // } else {
  2067. // int nodeNum = userPosition.getNodeNum();
  2068. // UserTask currentUserTask = userPosition.getCurrentUserTask();
  2069. // if (nodeNum == 1) {
  2070. // {
  2071. // List<SequenceFlow> outgoingFlows = currentUserTask.getOutgoingFlows();
  2072. // //我的下一个节点位置
  2073. // SequenceFlow myNextSequenceFlow = null;
  2074. // for (SequenceFlow outgoingFlow : outgoingFlows) {
  2075. // String conditionExpression = outgoingFlow.getConditionExpression();
  2076. // //如果是空就跳过
  2077. // if (conditionExpression == null) {
  2078. // continue;
  2079. // } else if (conditionExpression.contains("${agree=='no'}")) {//${agree=='yes'}
  2080. // continue;
  2081. // } else if (conditionExpression.contains("${agree=='back'}")) {//${agree=='yes'}
  2082. // continue;
  2083. // } else if (conditionExpression.contains("${agree=='yes'}")) {//${agree=='yes'}//xxxx
  2084. // //发现没有判断条件,那本流程就是下个节点
  2085. // myNextSequenceFlow = outgoingFlow;
  2086. // }
  2087. // //如果没有找到下个流程节点就继续找
  2088. // if (myNextSequenceFlow == null) {
  2089. // continue;
  2090. // }
  2091. // //下面是找到了下个流程节点,需要进行正常的运行节点了
  2092. // FlowElement targetFlowElement = myNextSequenceFlow.getTargetFlowElement();
  2093. // if (targetFlowElement instanceof EndEvent) {//如果是的话就是最后审核状态
  2094. // return null;
  2095. // }
  2096. // String candidateGroup = ((UserTask) targetFlowElement).getCandidateGroups().get(0);//targetFlowElement.getCandidateGroups();
  2097. // String setRurrRole = getSetRurrRole(candidateGroup);
  2098. // for (String s : ConstantFlowType.FLOW_ROLES_DEPT) {
  2099. // if (s.equals(setRurrRole)) {
  2100. // targetUser = this.getTargerUser_FLOW_ROLES_DEPT_PLUS(s, currUser);
  2101. // if (targetUser == null) {
  2102. // return null;
  2103. // }
  2104. // startTask = flowService.startTask(processDefine, null, businessId, targetUser, currUser);
  2105. // return startTask;
  2106. // }
  2107. // }
  2108. // for (int i = 0; i < ConstantFlowType.FLOW_ROLES.length; i++) {
  2109. // if (ConstantFlowType.FLOW_ROLES[i].equals(setRurrRole)) {//1.1.2如果是领导关系的查领导
  2110. // //查看谁是对应角色并查找对应的人
  2111. // String role = ConstantFlowType.ROLES[i];
  2112. // List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKeyAndGroup(role,
  2113. // ConstantFlowType.ROLETYPE, currUser.getGroupId());
  2114. // if (!targetUserList.isEmpty()) {
  2115. // targetUser = targetUserList.get(0);
  2116. // }
  2117. // if (targetUser == null) {
  2118. // targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  2119. // if (targetUser == null) {
  2120. // return null;
  2121. // }
  2122. // }
  2123. // startTask = flowService.startTask(processDefine, null, businessId, targetUser, currUser);
  2124. // return startTask;
  2125. // }
  2126. // }
  2127. // for (int i = 0; i < ConstantFlowType.PURCHASE_FLOW_ROLES_CHECK.length; i++) {
  2128. // if (ConstantFlowType.PURCHASE_FLOW_ROLES_CHECK[i].equals(setRurrRole)) {
  2129. // //查看谁是对应角色并查找对应的人
  2130. // String role = ConstantFlowType.PURCHASE_ROLES_CHECK[i];
  2131. // List<FrameUser> targetUserList = flowMainService.findFrameUsersByRoleKeyAndGroup(role,
  2132. // ConstantFlowType.ROLETYPE, currUser.getGroupId());
  2133. // if (!targetUserList.isEmpty()) {
  2134. // targetUser = targetUserList.get(0);
  2135. // }
  2136. // if (targetUser == null) {
  2137. // targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  2138. // if (targetUser == null) {
  2139. // return null;
  2140. // }
  2141. // }
  2142. // startTask = flowService.startTask(processDefine, null, businessId, targetUser, currUser);
  2143. // return startTask;
  2144. // }
  2145. // }
  2146. // return null;
  2147. // }
  2148. // return null;
  2149. // }
  2150. // } else if (nodeNum > 1) {
  2151. // // 2.如果大于1就是非正常流程需要把目标人填自己直到自己流转到自己流程上
  2152. // // 需要进行循环审核过程
  2153. // boolean isZhuYaoLingDao= "flow_zyld".equals(currRole);
  2154. // if(isZhuYaoLingDao) {
  2155. // targetUser = currUser;
  2156. // startTask = flowService.startTask(processDefine, null, businessId, targetUser, currUser);
  2157. // if (!startTask.isEmpty()) {
  2158. // {
  2159. // List<Task> list = taskService.createTaskQuery().processInstanceBusinessKey(businessId)//创建任务查询对象
  2160. // .taskAssignee(targetUser.getId())//指定个人任务查询
  2161. // .list();
  2162. // if (list == null || list.isEmpty()) {
  2163. // return null;
  2164. // }
  2165. // //2.1通过flow_id和targetUser获取下一个UserTask
  2166. // Task task = list.get(0);
  2167. // //task是当前流程的信息
  2168. // //如果发现task对应的角色就是自己的角色,就开始正常的走
  2169. // //如果发现task对应的角色还不是,就需要再进行设置自己的操作
  2170. // String taskDefinitionKey = task.getTaskDefinitionKey();
  2171. // String flowId = userPosition.getUserTask().getId();
  2172. // if (flowId.equals(taskDefinitionKey)) {
  2173. // Map<String, String> donaturalTaskMap = this.donaturalTask(deploymentid, currUser, task,
  2174. // conditionMap);
  2175. // if (donaturalTaskMap == null) {
  2176. // return null;
  2177. // } else {
  2178. // return startTask;
  2179. // }
  2180. // } else {
  2181. // {//遍历对象
  2182. // Map<String, String> getNextFlowMap = getNextFlow(businessId, userPosition,
  2183. // deploymentid, currUser, conditionMap, task);
  2184. // if (getNextFlowMap == null) {
  2185. // return null;
  2186. // } else {
  2187. // if (null != getNextFlowMap.get("isEnd")) {
  2188. // startTask.put("isEnd", getNextFlowMap.get("isEnd"));
  2189. // }
  2190. // return startTask;
  2191. // }
  2192. // }
  2193. // }
  2194. // }
  2195. // } else {
  2196. // return null;
  2197. // }
  2198. // } else {
  2199. // if (currUser.getLeader()!=null) {
  2200. // targetUser = userService.selectByPrimaryKey(currUser.getLeader());
  2201. // }
  2202. // if (targetUser==null){
  2203. // targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  2204. // }
  2205. // startTask = flowService.startTask(processDefine, null, businessId, targetUser, currUser);
  2206. // if (!startTask.isEmpty()) {
  2207. // return startTask;
  2208. // } else {
  2209. // return null;
  2210. // }
  2211. // }
  2212. // } else {
  2213. // return null;
  2214. // }
  2215. // }
  2216. // }
  2217. /**
  2218. * 采购流程用,这里没有用到
  2219. * @param flowMainPush
  2220. * @param deploymentid
  2221. * @param businessId
  2222. * @param conditionMap
  2223. * @return
  2224. * @throws com.rockstar.flow.exception.FlowException
  2225. */
  2226. // public Map<String, String> passToRunPurchaseTask(FlowMainPush flowMainPush, String deploymentid, String businessId,
  2227. // Map<String, Object> conditionMap)
  2228. // throws com.rockstar.flow.exception.FlowException {
  2229. // // 发起流程引擎操作 并查看下一节点的操作要求
  2230. // //0,如果是收纳且匹配上角色就正常流程审核,没有匹配上就返回null,异常错误 ok,
  2231. // //1. 如果当前角色是自己,就进行正常的审核流程 ok
  2232. // //2. 先查看当前角色是不是自己,不是自己就移动到自己的角色,然后再进行正常的审核流程 ok
  2233. //
  2234. // //当前审核人/委托人代表的用户id
  2235. // String myFrameUserId = this.getMyFrameUserId(flowMainPush);
  2236. // if (myFrameUserId == null) {
  2237. // return null;
  2238. // }
  2239. // //当前审核人/委托人代表的用户
  2240. // FrameUser myframeUser = frameUserService.selectByPrimaryKey(myFrameUserId);
  2241. // //根据任务id获取任务信息
  2242. // //当前任务流程
  2243. // Task task;
  2244. // {
  2245. // List<Task> taskList = taskService.createTaskQuery().processInstanceBusinessKey(flowMainPush.getFlowMainId())
  2246. // .taskId(flowMainPush.getTaskId()).list();
  2247. // if (taskList == null || taskList.isEmpty()) {
  2248. // return null;
  2249. // }
  2250. // task = taskList.get(0);
  2251. // }
  2252. // //本节点的关键子 例如flow_cnjs_1_1_0-yes
  2253. // String pushUserKey = flowMainPush.getPushUserKey();
  2254. // //本节点的角色 例如cnjs
  2255. // String setRurrRole = getSetRurrRole(pushUserKey);
  2256. //
  2257. // //判断setRurrRole是不是出纳类的角色,如果是出纳的角色,就判断当前审核人是不是也是出纳,是就继续,不是就是异常错误,返回null
  2258. // //判断是否符合出纳类型的要求 ok
  2259. // {
  2260. // for (int i = 0; i < ConstantFlowType.PURCHASE_FLOW_ROLES_CHECK.length; i++) {
  2261. // if (ConstantFlowType.PURCHASE_FLOW_ROLES_CHECK[i].equals(setRurrRole)) {
  2262. // return this.donaturalTask(deploymentid, myframeUser, task, conditionMap);
  2263. // }
  2264. // }
  2265. // }
  2266. // {
  2267. // //当前审核人/委托人代表的用户角色(只判断了是否是主管还是 分管领导的问题, 还没有判断是否是出纳的问题,不是哪里都适用的)
  2268. // String currRole = this.getCurrRole(myframeUser);
  2269. // //没有获取到角色,直接对到admin那里
  2270. // if (!StringUtils.isNotEmpty(currRole)) {
  2271. // // 直接对到admin那里
  2272. // FrameUser targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  2273. // if (targetUser == null) {
  2274. // return null;
  2275. // }
  2276. // return this.donaturalTask(deploymentid, myframeUser, task, conditionMap);
  2277. // }
  2278. // //当发现this.getCurrRole(myframeUser);获取的角色是普通员工的时候,就知道他作为审核人只是直接上级,并不是领导,所以把角色调上一级
  2279. // if (currRole.equals(ConstantFlowType.FLOW_ROLES_DEPT[0])) {
  2280. // currRole = ConstantFlowType.FLOW_ROLES_DEPT[1];
  2281. // }
  2282. // // 不是出纳的情况下进行的判断
  2283. // //1.如果当前角色是自己,就进行正常的审核流程 ok
  2284. // //2.先查看当前角色是不是自己,不是自己就移动到自己的角色,然后再进行正常的审核流程 ok
  2285. // if (setRurrRole.equals(currRole)) {//1.如果当前角色是自己,就进行正常的审核流程 ok
  2286. // return this.donaturalTask(deploymentid, myframeUser, task, conditionMap);
  2287. // } else {//2.先查看当前角色是不是自己,不是自己就移动到自己的角色,然后再进行正常的审核流程 ok
  2288. // FrameUser targetUser = null;
  2289. // UserTaskMore userPosition = this.findUserPosition(currRole, deploymentid);
  2290. //// 返回为null就直接提交到admin用户去审核,如果对象里面的nodeNum是1就是正常流程,如果大于1就是非正常流程需要把目标人填自己直到自己流转到自己流程上
  2291. // if (userPosition == null) {//没有找到数据
  2292. // targetUser = userService.selectByPrimaryKey(ConstantFlowType.ADMINID);
  2293. // if (targetUser == null) {
  2294. // return null;
  2295. // }
  2296. // boolean yes = flowService.runTask(task.getId(), null, "yes", null, targetUser, myframeUser, conditionMap);
  2297. // return new HashMap<>();
  2298. // } else {//找到userPosition数据录了
  2299. // //还不是自己的角色,还要遍历查找
  2300. // return getNextFlow(businessId, userPosition, deploymentid, myframeUser, conditionMap, task);
  2301. // }
  2302. // }
  2303. // }
  2304. // }
  2305. }