FlowMainService.java 98 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859
  1. package com.idea.oa.flow2.service;
  2. import com.github.pagehelper.PageHelper;
  3. import com.github.pagehelper.PageInfo;
  4. import com.idea.oa.activiti.service.ProActiService;
  5. import com.idea.oa.apply.model.inout.AddConfirmResult;
  6. import com.idea.oa.apply.model.inout.OperaterManage;
  7. import com.idea.oa.apply.util.constant.ConstantFlowType;
  8. import com.idea.oa.flow2.mapper.FlowMainExtendMapper;
  9. import com.idea.oa.flow2.mapper.FlowMainMapper;
  10. import com.idea.oa.flow2.model.*;
  11. import com.idea.oa.flow2.model.in.FlowMainIn;
  12. import com.idea.oa.flow2.model.in.TagerUserAndFlowRole;
  13. import com.idea.oa.flow2.model.out.FlowHistoryInfo;
  14. import com.idea.oa.flow2.model.out.IMGFlowHistoryInfo;
  15. import com.rockstar.common.base.BaseService;
  16. import com.rockstar.common.domain.AjaxResult;
  17. import com.rockstar.common.support.Convert;
  18. import com.rockstar.flow.service.FlowService;
  19. import com.rockstar.frame.model.FrameRoleData;
  20. import com.rockstar.frame.model.FrameUser;
  21. import com.rockstar.frame.model.extend.DateTrans;
  22. import com.rockstar.frame.model.extend.Tablepar;
  23. import com.rockstar.frame.service.FrameUserService;
  24. import com.rockstar.shiro.util.ShiroUtils;
  25. import com.rockstar.util.UUIDUtils;
  26. import org.activiti.bpmn.model.UserTask;
  27. import org.activiti.engine.TaskService;
  28. import org.activiti.engine.task.Task;
  29. import org.springframework.beans.factory.annotation.Autowired;
  30. import org.springframework.stereotype.Service;
  31. import org.springframework.util.StringUtils;
  32. import java.math.BigDecimal;
  33. import java.math.MathContext;
  34. import java.util.*;
  35. @Service
  36. public class FlowMainService implements BaseService<FlowMain, FlowMainExample> {
  37. // @Autowired
  38. // private ApplyUseMoneyDetailService applyUseMoneyDetailService;
  39. @Autowired
  40. public FrameUserService frameUserService;
  41. @Autowired
  42. private TaskService taskService;
  43. @Autowired
  44. private FlowService flowService;
  45. @Autowired
  46. private FlowMainPushService flowMainPushService;
  47. //文件mapper
  48. @Autowired
  49. private FlowMainMapper flowMainMapper;
  50. @Autowired
  51. private FlowMainExtendMapper flowMainExtendMapper;
  52. @Autowired
  53. private ProActiService proActiService;
  54. @Autowired
  55. private FlowMainLogService flowMainLogService;
  56. @Autowired
  57. private FlowMainCcService flowMainCcService;
  58. /**
  59. * 添加审核结果
  60. * 根据不同的状态值confirmResult判断是 1:审核通过,转下一步;2:退回发起人;3:退回上节点;4:结束流程(不同意,并且结束流程);
  61. *
  62. * @return string 如果为ok就是成功,不然就是失败message
  63. */
  64. public String doConfirmResult(AddConfirmResult addConfirmResult, String deploymentid, String constantFlowType, FlowMainPush flowMainPush, HashMap<String, Object> conditionMap) throws com.rockstar.flow.exception.FlowException {
  65. if (addConfirmResult.getConfirmResult() == null) {
  66. return "没有获取到confirmResult值";
  67. }
  68. // String deploymentid = ConstantFlowType.USE_MONEY_DEPLOYMENTID;
  69. // String constantFlowType = ConstantFlowType.USE_MONEY;
  70. OperaterManage operaterManage = new OperaterManage();
  71. FrameUser frameUser = new FrameUser();
  72. try {
  73. frameUser.setId(ShiroUtils.getUser().getId());
  74. } catch (Exception e) {
  75. frameUser.setId(addConfirmResult.getOperaterId());
  76. }
  77. operaterManage.setUser(frameUser);
  78. // FlowMainPush flowMainPush = flowMainPushService.selectByPrimaryKey(addConfirmResult.getFlowMainPushId());
  79. if (!flowMainPush.getStatus().equals(0)) {
  80. if (flowMainPush.getStatus().equals(1)) {
  81. return "已经在" + flowMainPush.getUpdatedAt() + "时操作过了,请重新确认";
  82. } else if (flowMainPush.getStatus().equals(2)) {
  83. return "已经在" + flowMainPush.getUpdatedAt() + "时由其他审核人操作过了,请重新确认";
  84. }
  85. }
  86. {//提前逻辑删除推送信息,保证数据不会因为同步操作出现冲突
  87. FlowMainPush updateFlowMainPush = new FlowMainPush();
  88. updateFlowMainPush.setId(flowMainPush.getId());
  89. updateFlowMainPush.setStatus(1);
  90. updateFlowMainPush.setUpdatedAt(new Date());
  91. updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
  92. flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
  93. }
  94. FlowMain flowMain = this.selectByPrimaryKey(flowMainPush.getFlowMainId());
  95. //当前任务流程 目的是获取节点名称,存起来nodeName
  96. String nodeName = flowMainPush.getNodeName() == null ? proActiService.getNodeName(flowMainPush) : flowMainPush.getNodeName();
  97. if (nodeName == null) {
  98. return "异常:没有找到对应的任务...请通知管理员";
  99. }
  100. String mypushUserKey = flowMainPush.getNodeUserRole();
  101. if (mypushUserKey == null) {
  102. mypushUserKey = flowMainPush.getPushUserKey();
  103. }
  104. // flowMain.
  105. // Map<String, Object> conditionMap
  106. //审核通过,转下一步
  107. boolean isEnd = false;//是否审核到最后一步了
  108. String roleType = null; //节点key 例如dept_superior_1_0_1
  109. {
  110. //todo 先要判断是否是会签,会签要过滤一下, (后面的部分下面完成了)不是会签的就把其他待审核数据逻辑删除
  111. // 1:单流程推送
  112. // 2:串联审核(会签)
  113. // 3:并联推送
  114. // 步骤1,判断是否是会签
  115. //2,如果是,判断是否是同意
  116. //3,如果不是同意就跳出本判断,如果是同意就判断会签人是不是都同意了,如果都同意了也跳过本判断,如果还没有都同意,就只修改push(已经改了)和增加log和抄送信息
  117. Integer pushType = flowMainPush.getPushType();
  118. if (new Integer(2).equals(pushType)) {
  119. if (addConfirmResult.getConfirmResult().equals("1")) {//审核通过 ok
  120. // 判断会签人是不是都同意了,如果都同意了也跳过本判断,如果还没有都同意,就只修改push(已经改了)和增加log和抄送信息
  121. {
  122. List<FlowMainPush> pushByFlowMainId = flowMainPushService.findPushByFlowMainId(flowMainPush.getFlowMainId());
  123. if (pushByFlowMainId != null && !pushByFlowMainId.isEmpty() && pushByFlowMainId.size() > 0) {
  124. //存入流程日志表的id
  125. String flowMainLogUuid = UUIDUtils.middleUUID();
  126. //发现不需要修改setLastMainLogId,因为这个字段是保存:最后一次上个节点审核时的表(flow_main_log)id
  127. // {
  128. // FlowMain flowMain1 = new FlowMain();
  129. // flowMain1.setId(flowMainPush.getFlowMainId());
  130. // flowMain1.setLastMainLogId(flowMainLogUuid);
  131. // this.updateLastMainLogId(flowMainPush.getFlowMainId(),flowMainLogUuid);//修改主表的日志最后记录
  132. // }
  133. //2添加日志 ok
  134. FlowMainLog flowMainLog = new FlowMainLog();
  135. {
  136. flowMainLog.setId(flowMainLogUuid);
  137. flowMainLog.setFlowMainId(flowMain.getId());
  138. flowMainLog.setFormId(flowMain.getFormId());
  139. flowMainLog.setAuditUser(operaterManage.getUser().getId());
  140. flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
  141. flowMainLog.setAuditResult("1");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)',
  142. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  143. flowMainLog.setAuditType("1");
  144. flowMainLog.setFlowType(constantFlowType);
  145. flowMainLog.setFlowPost(operaterManage.getUser().getId());
  146. {// 需要工作流引擎的支持
  147. flowMainLog.setFlowId(flowMain.getFlowId());
  148. flowMainLog.setTaskId(flowMainPush.getTaskId());
  149. flowMainLog.setNodeName(nodeName);
  150. flowMainLog.setPushUserKey(mypushUserKey);
  151. }
  152. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  153. // 因为感觉用不到,暂时不放进去
  154. // flowMainLog.setNextPersons();
  155. flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
  156. flowMainLog.setCcList(null);
  157. flowMainLog.setCreatedAt(new Date());
  158. flowMainLog.setCreatedBy(operaterManage.getUser().getId());
  159. flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
  160. flowMainLog.setStatus(0);
  161. flowMainLogService.insertWithoutId(flowMainLog);
  162. }
  163. // 3存入抄送人信息 ok
  164. if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
  165. String[] split = addConfirmResult.getCcList().split(",");
  166. for (String ccId : split) {
  167. if (!StringUtils.isEmpty(ccId)) {
  168. FlowMainCc flowMainCc = new FlowMainCc();
  169. flowMainCc.setFlowMainId(flowMain.getId());
  170. flowMainCc.setCcUser(ccId);
  171. //选择抄送人时的记录表id(flow_main_log):例如:112122
  172. flowMainCc.setMainLogIds(flowMainLog.getId());
  173. flowMainCc.setUpdatedAt(new Date());
  174. flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
  175. flowMainCc.setCreatedBy(operaterManage.getUser().getId());
  176. flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
  177. flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
  178. flowMainCc.setStatus(0);
  179. flowMainCcService.insert(flowMainCc);
  180. }
  181. }
  182. }
  183. return "ok_noEnd";
  184. }
  185. }
  186. }
  187. }
  188. }
  189. if (addConfirmResult.getConfirmResult().equals("1")) {//审核通过 ok
  190. {// 发起流程引擎操作 并查看下一节点的操作要求
  191. //1.如果当前角色是自己,就进行正常的审核流程
  192. //2.先查看当前角色是不是自己,不是自己就移动到自己的角色,然后再进行正常的审核流程
  193. Map<String, String> stringStringMap = proActiService.passToRunTask(flowMainPush, deploymentid, flowMainPush.getFlowMainId(), conditionMap, flowMain);
  194. if (stringStringMap == null) {
  195. return "流程引擎开启失败,请查看原因!";
  196. }
  197. isEnd = stringStringMap.get("isEnd") == null ? false : true;
  198. //可能会传roleType,但是如果没有传就在pushuser中进行查询
  199. roleType = stringStringMap.get("roleType");
  200. }
  201. {
  202. //存入流程日志表的id
  203. String flowMainLogUuid = UUIDUtils.middleUUID();
  204. //1修改主表状态 ok
  205. {
  206. FlowMain flowMain1 = new FlowMain();
  207. flowMain1.setId(flowMainPush.getFlowMainId());
  208. if (isEnd) {
  209. flowMain1.setFlowStatus(3);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  210. flowMain1.setFlowResult(1); //审核结果0无状态,1审核通过结束,2审核不通过结束
  211. } else {
  212. flowMain1.setFlowStatus(1);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  213. flowMain1.setFlowResult(0); //审核结果0无状态,1审核通过结束,2审核不通过结束
  214. }
  215. flowMain1.setLastMainLogId(flowMainLogUuid);
  216. flowMain1.setUpdatedAt(new Date());
  217. flowMain1.setUpdatedBy(operaterManage.getUser().getId());
  218. this.updateByPrimaryKeySelective(flowMain1);
  219. }
  220. //2添加日志 ok
  221. FlowMainLog flowMainLog = new FlowMainLog();
  222. {
  223. flowMainLog.setId(flowMainLogUuid);
  224. flowMainLog.setFlowMainId(flowMain.getId());
  225. flowMainLog.setFormId(flowMain.getFormId());
  226. flowMainLog.setAuditUser(operaterManage.getUser().getId());
  227. flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
  228. flowMainLog.setAuditResult("1");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)',
  229. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  230. if (isEnd) {
  231. flowMainLog.setAuditType("2");
  232. } else {
  233. flowMainLog.setAuditType("1");
  234. }
  235. flowMainLog.setFlowType(constantFlowType);
  236. flowMainLog.setFlowPost(operaterManage.getUser().getId());
  237. {// 需要工作流引擎的支持
  238. flowMainLog.setFlowId(flowMain.getFlowId());
  239. flowMainLog.setTaskId(flowMainPush.getTaskId());
  240. flowMainLog.setNodeName(nodeName);
  241. flowMainLog.setPushUserKey(mypushUserKey);
  242. }
  243. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  244. // 因为感觉用不到,暂时不放进去
  245. // flowMainLog.setNextPersons();
  246. flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
  247. flowMainLog.setCcList(null);
  248. flowMainLog.setCreatedAt(new Date());
  249. flowMainLog.setCreatedBy(operaterManage.getUser().getId());
  250. flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
  251. flowMainLog.setStatus(0);
  252. flowMainLogService.insertWithoutId(flowMainLog);
  253. }
  254. // 3存入抄送人信息 ok
  255. if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
  256. String[] split = addConfirmResult.getCcList().split(",");
  257. for (String ccId : split) {
  258. if (!StringUtils.isEmpty(ccId)) {
  259. FlowMainCc flowMainCc = new FlowMainCc();
  260. flowMainCc.setFlowMainId(flowMain.getId());
  261. flowMainCc.setCcUser(ccId);
  262. //选择抄送人时的记录表id(flow_main_log):例如:112122
  263. flowMainCc.setMainLogIds(flowMainLog.getId());
  264. flowMainCc.setUpdatedAt(new Date());
  265. flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
  266. flowMainCc.setCreatedBy(operaterManage.getUser().getId());
  267. flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
  268. flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
  269. flowMainCc.setStatus(0);
  270. flowMainCcService.insert(flowMainCc);
  271. }
  272. }
  273. }
  274. //4.0判断是否存在串并联并修改推送状态 逻辑删除旧的推送人
  275. {
  276. //todo推送类型1单流程推送,2串联推送,3并联推送
  277. Integer pushType = flowMainPush.getPushType();
  278. //逻辑删除本推送
  279. {
  280. // FlowMainPush updateFlowMainPush = new FlowMainPush();
  281. // updateFlowMainPush.setId(flowMainPush.getId());
  282. // updateFlowMainPush.setStatus(1);
  283. // updateFlowMainPush.setUpdatedAt(new Date());
  284. // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
  285. // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
  286. }
  287. if (pushType.equals(1) || pushType.equals(2)) {
  288. //只要逻辑删除本推送
  289. } else if (pushType.equals(3)) {
  290. //要逻辑删除自己和其他推送
  291. //将其他并联推送的人员推送状态status改成2状态值
  292. flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
  293. }
  294. }
  295. //4添加新的推送人员
  296. if (!isEnd) {//查看各个任务
  297. List<Task> listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list();
  298. // taskService.createTaskQuery().processInstanceId();
  299. //查看总的数据流程
  300. List<UserTask> TaskList = flowService.getTaskList(deploymentid);
  301. for (Task task : listTask) {
  302. {
  303. //获取推送类型1单流程推送,2串联推送,3并联推送',
  304. Integer pushType = null;
  305. //'推送时彭总给的key值',
  306. String pushUserKey = null;
  307. UserTask myUserTask = null;
  308. {
  309. String taskDefinitionKey = task.getTaskDefinitionKey();
  310. for (int i = 0; i < TaskList.size(); i++) {
  311. if (TaskList.get(i).getId().equals(taskDefinitionKey)) {
  312. myUserTask = TaskList.get(i);
  313. break;
  314. }
  315. }
  316. if (myUserTask != null) {
  317. pushUserKey = myUserTask.getCandidateGroups().get(0);
  318. }
  319. //判断是否存在串并联并修改推送状态
  320. if (roleType == null) {//只有在首次申请,且直属上级还有更高级的身份才会没有,但是还是在直属上级这里进行并联审核
  321. if (pushUserKey != null) {
  322. if (listTask.size() > 1) {
  323. String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_");
  324. if (s1.length >= 5) {
  325. String pushTypeNum = s1[4];
  326. if ("0".equals(pushTypeNum)) {
  327. pushType = 2;
  328. } else if ("1".equals(pushTypeNum)) {
  329. pushType = 3;
  330. }
  331. }
  332. } else {
  333. pushType = 2;
  334. }
  335. }
  336. } else {
  337. String[] roleTypeArray = roleType.split("_");
  338. String pushTypeNum = roleTypeArray[roleTypeArray.length - 1];
  339. if ("1".equals(pushTypeNum)) {
  340. pushType = 1;
  341. } else if ("2".equals(pushTypeNum)) {
  342. pushType = 2;
  343. } else if ("3".equals(pushTypeNum)) {
  344. pushType = 3;
  345. } else {
  346. pushType = 2;
  347. }
  348. }
  349. }
  350. FlowMainPush newflowMainPush = new FlowMainPush();
  351. newflowMainPush.setFlowMainId(flowMain.getId());
  352. newflowMainPush.setFormId(flowMain.getFormId());
  353. {// 需要工作流引擎的支持
  354. newflowMainPush.setPushUser(task.getAssignee().split(",")[0]);//推送人id'
  355. newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
  356. newflowMainPush.setNodeName(myUserTask.getName());
  357. {
  358. // flowMainPush.setNodeUserRole(pushUserKey);
  359. // flowMainPush.setNodeName(myUserTask.getName());
  360. // 上面的方法进行修改 做一个方法替换原来的填写节点名称,目的是获取用户跳节点时对应的节点名称放在新的对象字段(node_user_role)中
  361. newflowMainPush = this.setPushUserKeyAndNodeName(newflowMainPush, task.getAssignee().split(",")[0], flowMain, roleType);
  362. }
  363. newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
  364. newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  365. newflowMainPush.setFlowType(constantFlowType);
  366. newflowMainPush.setFlowPost(task.getAssignee());
  367. ////2023年5月10日 修改成上面的了 张洮
  368. // newflowMainPush.setFlowPost(operaterManage.getUser().getId());
  369. newflowMainPush.setFlowId(flowMain.getFlowId());
  370. newflowMainPush.setTaskId(task.getId());
  371. }
  372. newflowMainPush.setUpMainLogId(flowMainLog.getId());
  373. newflowMainPush.setUpdatedAt(new Date());
  374. newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt());
  375. newflowMainPush.setCreatedBy(operaterManage.getUser().getId());
  376. newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy());
  377. newflowMainPush.setGroupId(operaterManage.getUser().getGroupId());
  378. newflowMainPush.setStatus(0);
  379. {//插入推送人前进行判断
  380. if (new Integer(1).equals(newflowMainPush.getPushType())) {
  381. flowMainPushService.insert(newflowMainPush);
  382. } else {
  383. String[] splitIds = task.getAssignee().split(",");
  384. for (int i = 0; i < splitIds.length; i++) {
  385. newflowMainPush.setPushUser(splitIds[i]);
  386. flowMainPushService.insert(newflowMainPush);
  387. }
  388. }
  389. }
  390. }
  391. }
  392. }
  393. }
  394. } else if (addConfirmResult.getConfirmResult().equals("2")) {//退回发起人 ok
  395. {// 退回发起人
  396. isEnd = true;
  397. // flowService.deleteInstance(flowMain.getFlowId(), "退回发起人");
  398. //当前审核人/委托人代表的用户id
  399. String myFrameUserId = proActiService.getMyFrameUserId(flowMainPush);
  400. if (myFrameUserId == null) {
  401. return null;
  402. }
  403. //当前审核人/委托人代表的用户
  404. FrameUser myFrameUser = frameUserService.selectByPrimaryKey(myFrameUserId);
  405. FrameUser targetUser = frameUserService.selectByPrimaryKey(flowMain.getApplyUser());
  406. // FrameUser currUser = operaterManage.getUser();
  407. boolean yes = flowService.runTask(flowMainPush.getTaskId(), null, "no", "退回发起人", targetUser, myFrameUser, null);
  408. }
  409. {
  410. //存入流程日志表的id
  411. String flowMainLogUuid = UUIDUtils.middleUUID();
  412. //1修改主表状态
  413. {
  414. FlowMain flowMain1 = new FlowMain();
  415. flowMain1.setId(flowMainPush.getFlowMainId());
  416. flowMain1.setFlowStatus(2);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  417. flowMain1.setLastMainLogId(flowMainLogUuid);
  418. flowMain1.setUpdatedAt(new Date());
  419. flowMain1.setUpdatedBy(operaterManage.getUser().getId());
  420. this.updateByPrimaryKeySelective(flowMain1);
  421. }
  422. //2添加日志 ok
  423. FlowMainLog flowMainLog = new FlowMainLog();
  424. {
  425. flowMainLog.setId(flowMainLogUuid);
  426. flowMainLog.setFlowMainId(flowMain.getId());
  427. flowMainLog.setFormId(flowMain.getFormId());
  428. flowMainLog.setAuditUser(operaterManage.getUser().getId());
  429. flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
  430. flowMainLog.setAuditResult("2");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)',
  431. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  432. flowMainLog.setAuditType("1");
  433. flowMainLog.setFlowType(constantFlowType);
  434. flowMainLog.setFlowPost(operaterManage.getUser().getId());
  435. {// 需要工作流引擎的支持
  436. flowMainLog.setFlowId(flowMain.getFlowId());
  437. flowMainLog.setTaskId(flowMainPush.getTaskId());
  438. flowMainLog.setNodeName(nodeName);
  439. flowMainLog.setPushUserKey(mypushUserKey);
  440. }
  441. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  442. // 因为感觉用不到,暂时不放进去
  443. // flowMainLog.setNextPersons();
  444. flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
  445. flowMainLog.setCcList(null);
  446. flowMainLog.setCreatedAt(new Date());
  447. flowMainLog.setCreatedBy(operaterManage.getUser().getId());
  448. flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
  449. flowMainLog.setStatus(0);
  450. flowMainLogService.insertWithoutId(flowMainLog);
  451. }
  452. //2.1添加抄送
  453. if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
  454. String[] split = addConfirmResult.getCcList().split(",");
  455. for (String ccId : split) {
  456. if (!StringUtils.isEmpty(ccId)) {
  457. FlowMainCc flowMainCc = new FlowMainCc();
  458. flowMainCc.setFlowMainId(flowMain.getId());
  459. flowMainCc.setCcUser(ccId);
  460. //选择抄送人时的记录表id(flow_main_log):例如:112122
  461. flowMainCc.setMainLogIds(flowMainLog.getId());
  462. flowMainCc.setUpdatedAt(new Date());
  463. flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
  464. flowMainCc.setCreatedBy(operaterManage.getUser().getId());
  465. flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
  466. flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
  467. flowMainCc.setStatus(0);
  468. flowMainCcService.insert(flowMainCc);
  469. }
  470. }
  471. }
  472. //3判断是否存在串并联并修改推送状态 逻辑删除旧的推送人
  473. {
  474. //todo推送类型1单流程推送,2串联推送,3并联推送
  475. Integer pushType = flowMainPush.getPushType();
  476. //逻辑删除本推送
  477. {
  478. // FlowMainPush updateFlowMainPush = new FlowMainPush();
  479. // updateFlowMainPush.setId(flowMainPush.getId());
  480. // updateFlowMainPush.setStatus(1);
  481. // updateFlowMainPush.setUpdatedAt(new Date());
  482. // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
  483. // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
  484. }
  485. if (pushType.equals(1)) {
  486. //只要逻辑删除本推送
  487. } else if (pushType.equals(3) || pushType.equals(2)) {//3是并签//2是会签
  488. //要逻辑删除自己和其他推送
  489. //将其他并联推送的人员推送状态status改成2状态值
  490. flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
  491. }
  492. }
  493. //4添加推送人(因为退回发起人之后 发起人不需要再审核,所以改成推送人就不要了,下面的注释掉了)
  494. {//查看各个任务
  495. // List<Task> listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list();
  496. //// taskService.createTaskQuery().processInstanceId();
  497. // //查看总的数据流程
  498. // List<UserTask> TaskList = flowService.getTaskList(deploymentid);
  499. // for (Task task : listTask) {
  500. // UserTask myUserTask = null;
  501. // {
  502. // String taskDefinitionKey = task.getTaskDefinitionKey();
  503. // for (int i = 0; i < TaskList.size(); i++) {
  504. // if (TaskList.get(i).getId().equals(taskDefinitionKey)) {
  505. // myUserTask = TaskList.get(i);
  506. // break;
  507. // }
  508. // }
  509. // //判断是否存在串并联并修改推送状态
  510. // //'推送时彭总给的key值',
  511. // String pushUserKey = null;
  512. // if (myUserTask != null) {
  513. // pushUserKey = myUserTask.getCandidateGroups().get(0);
  514. // }
  515. // //'推送类型1单流程推送,2串联推送,3并联推送',
  516. // Integer pushType = 1;
  517. //// if (myUserTask != null) {
  518. //// pushUserKey = myUserTask.getCandidateGroups().get(0);
  519. //// if (listTask.size() > 1) {
  520. //// String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_");
  521. //// if (s1.length >= 5) {
  522. //// String pushTypeNum = s1[4];
  523. //// if ("0".equals(pushTypeNum)) {
  524. //// pushType = 2;
  525. //// } else if ("1".equals(pushTypeNum)) {
  526. //// pushType = 3;
  527. //// }
  528. ////
  529. //// }
  530. //// } else {
  531. //// pushType = 1;
  532. //// }
  533. //// }
  534. // FlowMainPush newflowMainPush = new FlowMainPush();
  535. // newflowMainPush.setFlowMainId(flowMain.getId());
  536. // newflowMainPush.setFormId(flowMain.getFormId());
  537. // {// 需要工作流引擎的支持
  538. // newflowMainPush.setPushUser(task.getAssignee());//推送人id'
  539. // newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
  540. // newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
  541. // newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  542. // newflowMainPush.setFlowType(constantFlowType);
  543. // newflowMainPush.setFlowPost(operaterManage.getUser().getId());
  544. // newflowMainPush.setFlowId(flowMain.getFlowId());
  545. // newflowMainPush.setTaskId(task.getId());
  546. // }
  547. // newflowMainPush.setUpMainLogId(flowMainLog.getId());
  548. // newflowMainPush.setUpdatedAt(new Date());
  549. // newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt());
  550. // newflowMainPush.setCreatedBy(operaterManage.getUser().getId());
  551. // newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy());
  552. // newflowMainPush.setGroupId(operaterManage.getUser().getGroupId());
  553. // newflowMainPush.setStatus(0);
  554. // flowMainPushService.insert(newflowMainPush);
  555. // }
  556. // }
  557. }
  558. }
  559. } else if (addConfirmResult.getConfirmResult().equals("3")) {//退回上节点(todo 退回上个节点有问题,如果是跳跃审核的还有进行编辑,目前只支持不能跳跃审核的节点)
  560. FrameUser targetUser = null;
  561. {// 发起流程引擎操作
  562. //当前审核人/委托人代表的用户id
  563. String myFrameUserId = proActiService.getMyFrameUserId(flowMainPush);
  564. if (myFrameUserId == null) {
  565. return null;
  566. }
  567. //当前审核人/委托人代表的用户
  568. FrameUser myFrameUser = frameUserService.selectByPrimaryKey(myFrameUserId);
  569. FlowMainLog flowMainLog = flowMainLogService.selectByPrimaryKey(flowMainPush.getUpMainLogId());
  570. while ("4".equals(flowMainLog.getAuditResult())) {
  571. flowMainLog = flowMainLogService.selectByPrimaryKey(flowMainLog.getUpMainLogId());
  572. }
  573. targetUser = frameUserService.selectByPrimaryKey(flowMainLog.getAuditUser());
  574. // FrameUser currUser = operaterManage.getUser();
  575. boolean yes = flowService.runTask(flowMainPush.getTaskId(), null, "back", "退回上节点", targetUser, myFrameUser, null);
  576. }
  577. {
  578. //存入流程日志表的id
  579. String flowMainLogUuid = UUIDUtils.middleUUID();
  580. //1修改主表状态
  581. {
  582. FlowMain flowMain1 = new FlowMain();
  583. flowMain1.setId(flowMainPush.getFlowMainId());
  584. flowMain1.setFlowStatus(1);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  585. flowMain1.setLastMainLogId(flowMainLogUuid);
  586. flowMain1.setUpdatedAt(new Date());
  587. flowMain1.setUpdatedBy(operaterManage.getUser().getId());
  588. this.updateByPrimaryKeySelective(flowMain1);
  589. }
  590. //2添加日志 ok
  591. FlowMainLog flowMainLog = new FlowMainLog();
  592. {
  593. flowMainLog.setId(flowMainLogUuid);
  594. flowMainLog.setFlowMainId(flowMain.getId());
  595. flowMainLog.setFormId(flowMain.getFormId());
  596. flowMainLog.setAuditUser(operaterManage.getUser().getId());
  597. flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
  598. flowMainLog.setAuditResult("3");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)',
  599. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  600. flowMainLog.setAuditType("1");
  601. flowMainLog.setFlowType(constantFlowType);
  602. flowMainLog.setFlowPost(operaterManage.getUser().getId());
  603. {// 需要工作流引擎的支持
  604. flowMainLog.setFlowId(flowMain.getFlowId());
  605. flowMainLog.setTaskId(flowMainPush.getTaskId());
  606. flowMainLog.setNodeName(nodeName);
  607. flowMainLog.setPushUserKey(mypushUserKey);
  608. }
  609. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  610. // 因为感觉用不到,暂时不放进去
  611. // flowMainLog.setNextPersons();
  612. flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
  613. flowMainLog.setCcList(null);
  614. flowMainLog.setCreatedAt(new Date());
  615. flowMainLog.setCreatedBy(operaterManage.getUser().getId());
  616. flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
  617. flowMainLog.setStatus(0);
  618. flowMainLogService.insertWithoutId(flowMainLog);
  619. }
  620. //2.1添加抄送
  621. if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
  622. String[] split = addConfirmResult.getCcList().split(",");
  623. for (String ccId : split) {
  624. if (!StringUtils.isEmpty(ccId)) {
  625. FlowMainCc flowMainCc = new FlowMainCc();
  626. flowMainCc.setFlowMainId(flowMain.getId());
  627. flowMainCc.setCcUser(ccId);
  628. //选择抄送人时的记录表id(flow_main_log):例如:112122
  629. flowMainCc.setMainLogIds(flowMainLog.getId());
  630. flowMainCc.setUpdatedAt(new Date());
  631. flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
  632. flowMainCc.setCreatedBy(operaterManage.getUser().getId());
  633. flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
  634. flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
  635. flowMainCc.setStatus(0);
  636. flowMainCcService.insert(flowMainCc);
  637. }
  638. }
  639. }
  640. //3判断是否存在串并联并修改推送状态 逻辑删除旧的推送人
  641. {
  642. //todo推送类型1单流程推送,2串联推送,3并联推送
  643. Integer pushType = flowMainPush.getPushType();
  644. //逻辑删除本推送
  645. {
  646. // FlowMainPush updateFlowMainPush = new FlowMainPush();
  647. // updateFlowMainPush.setId(flowMainPush.getId());
  648. // updateFlowMainPush.setStatus(1);
  649. // updateFlowMainPush.setUpdatedAt(new Date());
  650. // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
  651. // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
  652. flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
  653. }
  654. }
  655. //4添加新的推送人员
  656. {//查看各个任务
  657. List<Task> listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list();
  658. // taskService.createTaskQuery().processInstanceId();
  659. //查看总的数据流程
  660. List<UserTask> TaskList = flowService.getTaskList(deploymentid);
  661. for (Task task : listTask) {
  662. UserTask myUserTask = null;
  663. {
  664. String taskDefinitionKey = task.getTaskDefinitionKey();
  665. for (int i = 0; i < TaskList.size(); i++) {
  666. if (TaskList.get(i).getId().equals(taskDefinitionKey)) {
  667. myUserTask = TaskList.get(i);
  668. break;
  669. }
  670. }
  671. //判断是否存在串并联并修改推送状态
  672. //'推送时彭总给的key值',
  673. String pushUserKey = null;
  674. if (myUserTask != null) {
  675. pushUserKey = myUserTask.getCandidateGroups().get(0);
  676. }
  677. //'推送类型1单流程推送,2串联推送,3并联推送',
  678. Integer pushType = 1;
  679. // if (myUserTask != null) {
  680. // pushUserKey = myUserTask.getCandidateGroups().get(0);
  681. // if (listTask.size() > 1) {
  682. // String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_");
  683. // if (s1.length >= 5) {
  684. // String pushTypeNum = s1[4];
  685. // if ("0".equals(pushTypeNum)) {
  686. // pushType = 2;
  687. // } else if ("1".equals(pushTypeNum)) {
  688. // pushType = 3;
  689. // }
  690. //
  691. // }
  692. // } else {
  693. // pushType = 1;
  694. // }
  695. // }
  696. FlowMainPush newflowMainPush = new FlowMainPush();
  697. newflowMainPush.setFlowMainId(flowMain.getId());
  698. newflowMainPush.setFormId(flowMain.getFormId());
  699. {// 需要工作流引擎的支持
  700. if (!task.getAssignee().equals(targetUser.getId())) {
  701. continue;
  702. }
  703. newflowMainPush.setPushUser(task.getAssignee());//推送人id'
  704. newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
  705. newflowMainPush.setNodeName(myUserTask.getName());
  706. newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
  707. newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  708. newflowMainPush.setFlowType(constantFlowType);
  709. newflowMainPush.setFlowPost(task.getAssignee());
  710. ////2023年5月10日 修改成上面的了 张洮
  711. // newflowMainPush.setFlowPost(operaterManage.getUser().getId());
  712. newflowMainPush.setFlowId(flowMain.getFlowId());
  713. newflowMainPush.setTaskId(task.getId());
  714. }
  715. newflowMainPush.setUpMainLogId(flowMainLog.getId());
  716. newflowMainPush.setUpdatedAt(new Date());
  717. newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt());
  718. newflowMainPush.setCreatedBy(operaterManage.getUser().getId());
  719. newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy());
  720. newflowMainPush.setGroupId(operaterManage.getUser().getGroupId());
  721. newflowMainPush.setStatus(0);
  722. flowMainPushService.insert(newflowMainPush);
  723. }
  724. }
  725. }
  726. }
  727. } else if (addConfirmResult.getConfirmResult().equals("4")) {//结束流程 ok
  728. isEnd = true;
  729. {// 发起流程引擎操作 并结束该流程
  730. flowService.deleteInstance(flowMain.getFlowId(), "结束流程");
  731. }
  732. {
  733. //存入流程日志表的id
  734. String flowMainLogUuid = UUIDUtils.middleUUID();
  735. //1修改主表状态
  736. {
  737. FlowMain flowMain1 = new FlowMain();
  738. flowMain1.setId(flowMainPush.getFlowMainId());
  739. flowMain1.setFlowStatus(3);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  740. flowMain1.setFlowResult(2); //审核结果0无状态,1审核通过结束,2审核不通过结束
  741. flowMain1.setLastMainLogId(flowMainLogUuid);
  742. flowMain1.setUpdatedAt(new Date());
  743. flowMain1.setUpdatedBy(operaterManage.getUser().getId());
  744. this.updateByPrimaryKeySelective(flowMain1);
  745. }
  746. //2添加日志 ok
  747. FlowMainLog flowMainLog = new FlowMainLog();
  748. {
  749. flowMainLog.setId(flowMainLogUuid);
  750. flowMainLog.setFlowMainId(flowMain.getId());
  751. flowMainLog.setFormId(flowMain.getFormId());
  752. flowMainLog.setAuditUser(operaterManage.getUser().getId());
  753. flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
  754. flowMainLog.setAuditResult("5");// `audit_result` varchar(4) DEFAULT NULL COMMENT 审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,5,不同意且结束流程,null没有审核)',
  755. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  756. flowMainLog.setAuditType("2");
  757. flowMainLog.setFlowType(constantFlowType);
  758. flowMainLog.setFlowPost(operaterManage.getUser().getId());
  759. {// 需要工作流引擎的支持
  760. flowMainLog.setFlowId(flowMain.getFlowId());
  761. flowMainLog.setTaskId(flowMainPush.getTaskId());
  762. flowMainLog.setNodeName(nodeName);
  763. flowMainLog.setPushUserKey(mypushUserKey);
  764. }
  765. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  766. // 因为感觉用不到,暂时不放进去
  767. // flowMainLog.setNextPersons();
  768. flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
  769. flowMainLog.setCcList(null);
  770. flowMainLog.setCreatedAt(new Date());
  771. flowMainLog.setCreatedBy(operaterManage.getUser().getId());
  772. flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
  773. flowMainLog.setStatus(0);
  774. flowMainLogService.insertWithoutId(flowMainLog);
  775. }
  776. //3 存入抄送人信息
  777. if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
  778. String[] split = addConfirmResult.getCcList().split(",");
  779. for (String ccId : split) {
  780. if (!StringUtils.isEmpty(ccId)) {
  781. FlowMainCc flowMainCc = new FlowMainCc();
  782. flowMainCc.setFlowMainId(flowMain.getId());
  783. flowMainCc.setCcUser(ccId);
  784. //选择抄送人时的记录表id(flow_main_log):例如:112122
  785. flowMainCc.setMainLogIds(flowMainLog.getId());
  786. flowMainCc.setUpdatedAt(new Date());
  787. flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
  788. flowMainCc.setCreatedBy(operaterManage.getUser().getId());
  789. flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
  790. flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
  791. flowMainCc.setStatus(0);
  792. flowMainCcService.insert(flowMainCc);
  793. }
  794. }
  795. }
  796. //4.0逻辑删除旧的推送人
  797. {
  798. //todo推送类型1单流程推送,2串联推送,3并联推送
  799. Integer pushType = flowMainPush.getPushType();
  800. //逻辑删除本推送
  801. {
  802. // FlowMainPush updateFlowMainPush = new FlowMainPush();
  803. // updateFlowMainPush.setId(flowMainPush.getId());
  804. // updateFlowMainPush.setStatus(1);
  805. // updateFlowMainPush.setUpdatedAt(new Date());
  806. // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
  807. // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
  808. }
  809. if (pushType.equals(1)) {
  810. //只要逻辑删除本推送
  811. } else if (pushType.equals(3) || pushType.equals(2)) {
  812. //要逻辑删除自己和其他推送
  813. //将其他并联推送的人员推送状态status改成2状态值
  814. flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
  815. }
  816. }
  817. }
  818. }
  819. if (isEnd) {
  820. return "ok_end";
  821. } else {
  822. return "ok_noEnd";
  823. }
  824. }
  825. /**
  826. * 通用方法,加载到流程业务模块
  827. *
  828. * @return
  829. */
  830. public AjaxResult doFlowMain(String ApplyTheme, String recordId, String recordRemark, String recordCcList, String processdefine, String deploymentid, Map<String, Object> conditionMap, String constantFlowTypeNAME, String constantFlowType, FrameUser currUser, String deptId, String tagerUserId) throws com.rockstar.flow.exception.FlowException {
  831. // 存入流程主表 ok
  832. FlowMain flowMain = new FlowMain();
  833. {
  834. flowMain.setId(UUIDUtils.middleUUID());
  835. flowMain.setFormId(recordId);
  836. flowMain.setFlowType(constantFlowType);
  837. if (ConstantFlowType.isMoreDept) {
  838. if (deptId == null) {
  839. return AjaxResult.error("请选择部门信息");
  840. }
  841. flowMain.setDeptId(deptId);
  842. } else {
  843. flowMain.setDeptId(currUser.getDepartment());
  844. }
  845. flowMain.setApplyTheme(ApplyTheme);
  846. flowMain.setApplyUser(currUser.getId());
  847. flowMain.setUpdatedAt(new Date());
  848. flowMain.setCreatedAt(flowMain.getUpdatedAt());
  849. flowMain.setCreatedBy(currUser.getId());
  850. flowMain.setUpdatedBy(flowMain.getCreatedBy());
  851. flowMain.setGroupId(currUser.getGroupId());
  852. if (!StringUtils.isEmpty(recordRemark)) {
  853. flowMain.setRemark(recordRemark);
  854. }
  855. }
  856. // 进入流程引擎,开始启动流程
  857. String processInstanceId = null;
  858. // 判断启动申请后是否结束
  859. boolean isEnd = false;
  860. currUser = frameUserService.selectByPrimaryKey(currUser.getId());
  861. String roleType = null; //节点key 例如dept_superior_1_0_1
  862. {
  863. //启动流程引擎
  864. Map<String, String> stringStringMap = proActiService.startTask(processdefine, deploymentid, flowMain, currUser, conditionMap, tagerUserId);
  865. if (stringStringMap == null) {
  866. return AjaxResult.error("流程引擎开启失败,请查看原因!");
  867. }
  868. processInstanceId = stringStringMap.get("processInstanceId");
  869. if (stringStringMap.get("isEnd") != null) {
  870. isEnd = true;
  871. }
  872. //可能会传roleType,但是如果没有传就在pushuser中进行查询
  873. roleType = stringStringMap.get("roleType");
  874. }
  875. //存入流程日志表的id
  876. String flowMainLogUuid = UUIDUtils.middleUUID();
  877. {
  878. // conditionMap
  879. // if (conditionMap!=null) {
  880. // Object conditionMapString = JSONObject.toJSON(conditionMap);
  881. // flowMain.setConditionMap(conditionMapString.toString());
  882. // }
  883. // 关于@客户名称@项目名称@供应商名称@付款名称的付款申请单
  884. // 判断是否结束
  885. if (isEnd) {
  886. flowMain.setFlowStatus(3);//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  887. flowMain.setFlowResult(1); //审核结果0无状态,1审核通过结束,2审核不通过结束
  888. } else {
  889. flowMain.setFlowStatus(1);//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  890. flowMain.setFlowResult(0); //审核结果0无状态,1审核通过结束,2审核不通过结束
  891. }
  892. flowMain.setReturnStatus(0);//'0/null无状态,1已撤回并且已重新发起',
  893. flowMain.setCcList(null);
  894. flowMain.setFlowName(constantFlowTypeNAME);
  895. //当前流程邮递操作人(frame_user)id 去除岗位的设定
  896. flowMain.setFlowPost(currUser.getId());
  897. {// 需要工作流引擎的支持
  898. flowMain.setFlowId(processInstanceId);
  899. flowMain.setTaskId(null);
  900. }
  901. flowMain.setLastMainLogId(flowMainLogUuid);
  902. flowMain.setStatus(0);
  903. this.insertWithoutId(flowMain);
  904. }
  905. // 存入流程日志表 ok
  906. FlowMainLog flowMainLog = new FlowMainLog();
  907. {
  908. flowMainLog.setId(flowMainLogUuid);
  909. flowMainLog.setFlowMainId(flowMain.getId());
  910. flowMainLog.setFormId(recordId);
  911. flowMainLog.setAuditUser(currUser.getId());
  912. // 判断是否结束
  913. if (isEnd) {
  914. flowMainLog.setAuditType("2"); //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  915. flowMainLog.setAuditContent("自审通过");
  916. flowMainLog.setAuditResult("1");
  917. } else {
  918. flowMainLog.setAuditType("0"); //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  919. flowMainLog.setAuditContent(null);
  920. flowMainLog.setAuditResult(null);
  921. }
  922. flowMainLog.setFlowType(constantFlowType);
  923. flowMainLog.setFlowPost(currUser.getId());
  924. {// 需要工作流引擎的支持
  925. flowMainLog.setFlowId(processInstanceId);
  926. flowMainLog.setTaskId(null);
  927. flowMainLog.setNodeName(ConstantFlowType.nodeKeysName.get(1));
  928. flowMainLog.setPushUserKey(ConstantFlowType.nodeKeysName.get(11));
  929. }
  930. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  931. // 因为感觉用不到,暂时不放进去
  932. // flowMainLog.setNextPersons();
  933. flowMainLog.setUpMainLogId(null);
  934. flowMainLog.setCcList(null);
  935. flowMainLog.setCreatedAt(new Date());
  936. flowMainLog.setCreatedBy(currUser.getId());
  937. flowMainLog.setGroupId(currUser.getGroupId());
  938. flowMainLog.setStatus(0);
  939. flowMainLogService.insertWithoutId(flowMainLog);
  940. }
  941. // 存入抄送人信息 ok
  942. if (!StringUtils.isEmpty(recordCcList)) {
  943. String[] split = recordCcList.split(",");
  944. for (String ccId : split) {
  945. if (!StringUtils.isEmpty(ccId)) {
  946. FlowMainCc flowMainCc = new FlowMainCc();
  947. flowMainCc.setFlowMainId(flowMain.getId());
  948. flowMainCc.setCcUser(ccId);
  949. //选择抄送人时的记录表id(flow_main_log):例如:112122
  950. flowMainCc.setMainLogIds(flowMainLog.getId());
  951. flowMainCc.setUpdatedAt(new Date());
  952. flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
  953. flowMainCc.setCreatedBy(currUser.getId());
  954. flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
  955. flowMainCc.setGroupId(currUser.getGroupId());
  956. flowMainCc.setStatus(0);
  957. flowMainCcService.insert(flowMainCc);
  958. }
  959. }
  960. }
  961. // 存入推送人
  962. //查看各个任务
  963. List<Task> listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list();
  964. List<UserTask> TaskList = flowService.getTaskList(deploymentid);
  965. for (Task task : listTask) {
  966. UserTask myUserTask = null;
  967. {
  968. String taskDefinitionKey = task.getTaskDefinitionKey();
  969. for (int i = 0; i < TaskList.size(); i++) {
  970. if (TaskList.get(i).getId().equals(taskDefinitionKey)) {
  971. myUserTask = TaskList.get(i);
  972. break;
  973. }
  974. }
  975. //'推送时彭总给的key值',
  976. String pushUserKey = null;
  977. //'推送类型1单流程推送,2串联推送,3并联推送',
  978. Integer pushType = null;
  979. if (myUserTask != null) {
  980. pushUserKey = myUserTask.getCandidateGroups().get(0);
  981. }
  982. if (roleType == null) {
  983. if (pushUserKey != null) {
  984. if (listTask.size() > 1) {
  985. String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_");
  986. if (s1.length >= 5) { // 现在发现这个有问题,因为当前审核人的下个节点审核可能会跳节点,所以要找到下个审核人对应的节点才能判断推送类型,现在存的推送类型只是流程引擎中下个节点的推送类型,没有意义
  987. String pushTypeNum = s1[4];
  988. if ("1".equals(pushTypeNum)) {
  989. pushType = 1;
  990. } else if ("2".equals(pushTypeNum)) {
  991. pushType = 2;
  992. } else if ("3".equals(pushTypeNum)) {
  993. pushType = 3;
  994. }
  995. }
  996. } else {
  997. pushType = 2;
  998. }
  999. }
  1000. } else {
  1001. String[] roleTypeArray = roleType.split("_");
  1002. String pushTypeNum = roleTypeArray[roleTypeArray.length - 1];
  1003. if ("1".equals(pushTypeNum)) {
  1004. pushType = 1;
  1005. } else if ("2".equals(pushTypeNum)) {
  1006. pushType = 2;
  1007. } else if ("3".equals(pushTypeNum)) {
  1008. pushType = 3;
  1009. } else {
  1010. pushType = 2;
  1011. }
  1012. }
  1013. FlowMainPush flowMainPush = new FlowMainPush();
  1014. flowMainPush.setFlowMainId(flowMain.getId());
  1015. flowMainPush.setFormId(recordId);
  1016. {// 需要工作流引擎的支持
  1017. flowMainPush.setPushUser(task.getAssignee().split(",")[0]);//推送人id'
  1018. flowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
  1019. flowMainPush.setNodeName(myUserTask.getName());
  1020. {
  1021. // flowMainPush.setNodeUserRole(pushUserKey);
  1022. // flowMainPush.setNodeName(myUserTask.getName());
  1023. // 上面的方法进行修改 做一个方法替换原来的填写节点名称,目的是获取用户跳节点时对应的节点名称放在新的对象字段(node_user_role)中
  1024. flowMainPush = this.setPushUserKeyAndNodeName(flowMainPush, task.getAssignee().split(",")[0], flowMain, roleType);
  1025. }
  1026. flowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
  1027. flowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
  1028. flowMainPush.setFlowType(constantFlowType);
  1029. flowMainPush.setFlowPost(task.getAssignee());
  1030. //2023年5月10日 修改成上面的了 张洮
  1031. // flowMainPush.setFlowPost(currUser.getId());
  1032. flowMainPush.setFlowId(processInstanceId);
  1033. flowMainPush.setTaskId(task.getId());
  1034. }
  1035. flowMainPush.setUpMainLogId(flowMainLog.getId());
  1036. flowMainPush.setUpdatedAt(new Date());
  1037. flowMainPush.setCreatedAt(flowMainPush.getUpdatedAt());
  1038. flowMainPush.setCreatedBy(currUser.getId());
  1039. flowMainPush.setUpdatedBy(flowMainPush.getCreatedBy());
  1040. flowMainPush.setGroupId(currUser.getGroupId());
  1041. flowMainPush.setStatus(0);
  1042. {//插入推送人前进行判断
  1043. if (new Integer(1).equals(flowMainPush.getPushType())) {
  1044. flowMainPushService.insert(flowMainPush);
  1045. } else {
  1046. String[] splitIds = task.getAssignee().split(",");
  1047. for (int i = 0; i < splitIds.length; i++) {
  1048. flowMainPush.setPushUser(splitIds[i]);
  1049. flowMainPushService.insert(flowMainPush);
  1050. }
  1051. }
  1052. }
  1053. }
  1054. }
  1055. if (isEnd) {
  1056. return AjaxResult.successData(1688, null);
  1057. } else {
  1058. return AjaxResult.success();
  1059. }
  1060. }
  1061. //做一个方法替换原来的填写节点名称,目的是获取用户跳节点时对应的节点名称
  1062. private FlowMainPush setPushUserKeyAndNodeName(FlowMainPush flowMainPush, String pushUserId, FlowMain flowMain, String roleType) {
  1063. // flowMainPush.setNodeUserRole(pushUserKey);
  1064. // flowMainPush.setNodeName(myUserTask.getName());
  1065. if (roleType == null) {
  1066. FrameUser frameUser = frameUserService.selectByPrimaryKey(pushUserId);
  1067. boolean isCheck = false;//判断是否是出纳类型,如果是出纳类型就再查一下
  1068. for (String s : ConstantFlowType.FLOW_ROLES_CHECK) {
  1069. if (flowMainPush.getPushUserKey().startsWith(s)) {
  1070. isCheck = true;
  1071. break;
  1072. }
  1073. }
  1074. if (isCheck) {
  1075. flowMainPush.setNodeUserRole(flowMainPush.getPushUserKey());
  1076. // 使用原来的设置 flowMainPush.setNodeName(myUserTask.getName());
  1077. } else {
  1078. String currRole = proActiService.getCurrRole(frameUser, flowMain);
  1079. if (currRole == null || currRole.equals(ConstantFlowType.FLOW_ROLES_DEPT[0])) {//如果判断只是普通员工就还是设置成原来的(流程设置的)
  1080. currRole = ConstantFlowType.FLOW_ROLES_DEPT[1];//flowMainPush.getPushUserKey();//ConstantFlowType.FLOW_ROLES_DEPT[1];
  1081. }
  1082. flowMainPush.setNodeUserRole(currRole);
  1083. flowMainPush.setNodeName(ConstantFlowType.nodeKeys_Name.get(currRole));
  1084. }
  1085. } else {
  1086. flowMainPush.setNodeUserRole(roleType);
  1087. flowMainPush.setNodeName(ConstantFlowType.nodeKeys_Name.get(proActiService.getSetRurrRole(roleType)));
  1088. }
  1089. return flowMainPush;
  1090. }
  1091. /**
  1092. * 申请人撤回申请
  1093. *
  1094. * @param flowMainid
  1095. */
  1096. public AjaxResult recallApply(String flowMainid) {
  1097. if (com.rockstar.util.StringUtils.isEmpty(flowMainid)) {
  1098. return AjaxResult.error("数据不能为空");
  1099. }
  1100. FlowMain flowMain = this.selectByPrimaryKey(flowMainid);
  1101. //流转状态为审核中时,可以由发起人撤回。ok
  1102. if (!flowMain.getFlowStatus().equals(1)) {
  1103. return AjaxResult.error("流程状态不在审核中,请重新确认");
  1104. }
  1105. String mypushUserKey = null;
  1106. {//开始申请人撤回申请
  1107. //先搜索目前有哪些人在审核中 ,获取key
  1108. // select * from flow_main_push WHERE flow_main_push.flow_main_id=#{flowMainId} and STATUS=0
  1109. FlowMainPushExample example = new FlowMainPushExample();
  1110. example.createCriteria().andFlowMainIdEqualTo(flowMain.getId()).andStatusEqualTo(0);
  1111. List<FlowMainPush> flowMainPushes = flowMainPushService.selectByExample(example);
  1112. mypushUserKey = flowMainPushes.get(0).getPushUserKey();
  1113. //1.关闭所有推送人数据信息表 ok
  1114. {
  1115. flowMainPushService.updateStatusThreeByFlowMainId(ShiroUtils.getUser().getId(), flowMain.getId());
  1116. }
  1117. //2.关闭主流程 ok
  1118. {// 发起流程引擎操作 并结束该流程
  1119. try {
  1120. flowService.deleteInstance(flowMain.getFlowId(), "申请人撤回申请_结束流程");
  1121. } catch (Exception e) {
  1122. System.err.println("流程引擎异常");
  1123. e.printStackTrace();
  1124. // throw new RuntimeException(e);
  1125. }
  1126. }
  1127. //3.关闭主流程表 ok
  1128. //存入流程日志表的id
  1129. String flowMainLogUuid = UUIDUtils.middleUUID();
  1130. {
  1131. FlowMain flowMain1 = new FlowMain();
  1132. flowMain1.setId(flowMain.getId());
  1133. flowMain1.setFlowStatus(4);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
  1134. flowMain1.setLastMainLogId(flowMainLogUuid);
  1135. flowMain1.setUpdatedAt(new Date());
  1136. flowMain1.setUpdatedBy(ShiroUtils.getUser().getId());
  1137. this.updateByPrimaryKeySelective(flowMain1);
  1138. }
  1139. //4 添加日志表
  1140. FlowMainLog flowMainLog = new FlowMainLog();
  1141. {//其表单对应的流转历史该节点审核结果显示为”发起人撤回”
  1142. // flowMainLogUuid
  1143. flowMainLog.setId(flowMainLogUuid);
  1144. flowMainLog.setFlowMainId(flowMain.getId());
  1145. flowMainLog.setFormId(flowMain.getFormId());
  1146. flowMainLog.setAuditUser(ShiroUtils.getUser().getId());
  1147. flowMainLog.setAuditContent(null);
  1148. flowMainLog.setAuditResult(null);
  1149. //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
  1150. flowMainLog.setAuditType("4");
  1151. flowMainLog.setFlowType(flowMain.getFlowType());
  1152. flowMainLog.setFlowPost(ShiroUtils.getUser().getId());
  1153. {// 需要工作流引擎的支持
  1154. flowMainLog.setFlowId(flowMain.getFlowId());
  1155. flowMainLog.setTaskId(null);
  1156. flowMainLog.setNodeName("发起人撤回");
  1157. flowMainLog.setPushUserKey(mypushUserKey);//发起人撤回时 当时的审核人所对应的角色
  1158. }
  1159. // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
  1160. // 因为感觉用不到,暂时不放进去
  1161. // flowMainLog.setNextPersons();
  1162. flowMainLog.setUpMainLogId(flowMain.getLastMainLogId());
  1163. flowMainLog.setCcList(null);
  1164. flowMainLog.setCreatedAt(new Date());
  1165. flowMainLog.setCreatedBy(ShiroUtils.getUser().getId());
  1166. flowMainLog.setGroupId(ShiroUtils.getUser().getGroupId());
  1167. flowMainLog.setStatus(0);
  1168. flowMainLogService.insertWithoutId(flowMainLog);
  1169. }
  1170. }
  1171. return AjaxResult.success();
  1172. }
  1173. /**
  1174. * 分页查询
  1175. *
  1176. * @return
  1177. */
  1178. public PageInfo<FlowMain> list(Tablepar tablepar, FlowMain model, DateTrans dt) {
  1179. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1180. List<FlowMain> list = null;//modelMapper.selectByExample(getCondition(model,dt));
  1181. PageInfo<FlowMain> pageInfo = new PageInfo<>(list);
  1182. return pageInfo;
  1183. }
  1184. public Object listAll(FlowMain model, DateTrans dt) {
  1185. List<FlowMain> list = null;//modelMapper.selectByExample(getCondition(model,dt));
  1186. return list;
  1187. }
  1188. @Override
  1189. public int deleteByPrimaryKey(String ids) {
  1190. List<String> lista = Convert.toListStrArray(ids);
  1191. FlowMainExample example = new FlowMainExample();
  1192. example.createCriteria().andIdIn(lista);
  1193. return flowMainMapper.deleteByExample(example);
  1194. }
  1195. @Override
  1196. public FlowMain selectByPrimaryKey(String id) {
  1197. return flowMainMapper.selectByPrimaryKey(id);
  1198. }
  1199. @Override
  1200. public int updateByPrimaryKeySelective(FlowMain record) {
  1201. return flowMainMapper.updateByPrimaryKeySelective(record);
  1202. }
  1203. @Override
  1204. public int updateByExampleSelective(FlowMain record, FlowMainExample example) {
  1205. return flowMainMapper.updateByExampleSelective(record, example);
  1206. }
  1207. @Override
  1208. public int updateByExample(FlowMain record, FlowMainExample example) {
  1209. return flowMainMapper.updateByExample(record, example);
  1210. }
  1211. @Override
  1212. public List<FlowMain> selectByExample(FlowMainExample example) {
  1213. return flowMainMapper.selectByExample(example);
  1214. }
  1215. @Override
  1216. public long countByExample(FlowMainExample example) {
  1217. return flowMainMapper.countByExample(example);
  1218. }
  1219. @Override
  1220. public int deleteByExample(FlowMainExample example) {
  1221. return flowMainMapper.deleteByExample(example);
  1222. }
  1223. public int insert(FlowMain record) {
  1224. record.setId(UUIDUtils.middleUUID());
  1225. return insertWithoutId(record);
  1226. }
  1227. public int insertWithoutId(FlowMain record) {
  1228. return flowMainMapper.insert(record);
  1229. }
  1230. @Override
  1231. public int insertSelective(FlowMain record) {
  1232. record.setId(UUIDUtils.middleUUID());
  1233. record.setCreatedAt(new Date());
  1234. return flowMainMapper.insertSelective(record);
  1235. }
  1236. public PageInfo<FlowMainIn> hasDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1237. model.setAuditResult(new String[]{"1", "2", "3", "5"});
  1238. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1239. List<FlowMainIn> list = flowMainExtendMapper.listByInfo(model, dt);
  1240. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1241. return pageInfo;
  1242. }
  1243. public List<FrameRoleData> findFrameRoleDatasByUserId(String userId, String roleType) {
  1244. return flowMainExtendMapper.findFrameRoleDatasByUserId(userId, roleType);
  1245. }
  1246. public List<FrameUser> findFrameUsersByRoleKey(String roleKey, String roleType) {
  1247. List<FrameUser> frameUsersByRoleKey = null;
  1248. try {
  1249. // System.out.println("SELECT frame_user.* FROM frame_role_data_user LEFT JOIN frame_role_data ON frame_role_data.id=frame_role_data_user.role_data_id LEFT JOIN frame_user ON frame_user.id=frame_role_data_user.user_id WHERE frame_role_data.role_key='"+roleKey+"' AND frame_role_data.role_type='"+roleType+"'");
  1250. frameUsersByRoleKey = flowMainExtendMapper.findFrameUsersByRoleKey(roleKey, roleType);
  1251. } catch (Exception e) {
  1252. e.printStackTrace();
  1253. frameUsersByRoleKey = new ArrayList<>();
  1254. }
  1255. return frameUsersByRoleKey;
  1256. }
  1257. public List<FrameUser> findFrameUsersByRoleKeyAndGroup(String roleKey, String roleType, String groupId) {
  1258. List<FrameUser> frameUsersByRoleKey = null;
  1259. try {
  1260. frameUsersByRoleKey = flowMainExtendMapper.findFrameUsersByRoleKeyAndGroup(roleKey, roleType, groupId);
  1261. } catch (Exception e) {
  1262. e.printStackTrace();
  1263. frameUsersByRoleKey = new ArrayList<>();
  1264. }
  1265. return frameUsersByRoleKey;
  1266. }
  1267. public PageInfo<FlowMainIn> myApplylistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1268. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1269. List<FlowMainIn> list = flowMainExtendMapper.myApplylistByInfo(model, dt);
  1270. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1271. return pageInfo;
  1272. }
  1273. /**
  1274. * 抄送事项 ok
  1275. * web端开始页面查询,不同类型, 流程名称,主题,发起人查询
  1276. */
  1277. public PageInfo<FlowMainIn> cclistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1278. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1279. List<FlowMainIn> list = flowMainExtendMapper.cclistByInfo(model, dt);
  1280. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1281. return pageInfo;
  1282. }
  1283. public PageInfo<FlowMainIn> myEntrustlistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1284. model.setAuditResult(new String[]{"4"});
  1285. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1286. List<FlowMainIn> list = flowMainExtendMapper.listByInfo(model, dt);
  1287. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1288. return pageInfo;
  1289. }
  1290. /**
  1291. * 待办事项
  1292. *
  1293. * @param tablepar
  1294. * @param model
  1295. * @param dt
  1296. * @return
  1297. */
  1298. public PageInfo<FlowMainIn> toDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1299. model.setAuditResult(new String[]{"1"});
  1300. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1301. List<FlowMainIn> list = flowMainExtendMapper.toDolistByInfo(model, dt);
  1302. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1303. return pageInfo;
  1304. }
  1305. /**
  1306. * 委托代办事项
  1307. *
  1308. * @param tablepar
  1309. * @param model
  1310. * @param dt
  1311. * @return
  1312. */
  1313. public PageInfo<FlowMainIn> entrustToDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1314. model.setAuditResult(new String[]{"2"});
  1315. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1316. List<FlowMainIn> list = flowMainExtendMapper.toDolistByInfo(model, dt);
  1317. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1318. return pageInfo;
  1319. }
  1320. public List<FlowHistoryInfo> getFlowHistroyByFlowMainId(String flowMainId) {
  1321. return flowMainExtendMapper.getFlowHistroyByFlowMainId(flowMainId);
  1322. }
  1323. public Integer numtoDolistByInfo(FlowMainIn model, DateTrans dt) {
  1324. model.setAuditResult(new String[]{"1"});
  1325. return flowMainExtendMapper.numtoDolistByInfo(model, dt);
  1326. }
  1327. public PageInfo<FlowMainIn> toDolisAndEntrusttByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
  1328. model.setAuditResult(new String[]{"1", "2"});
  1329. // model.setAuditResult(new String[]{"2"});
  1330. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  1331. List<FlowMainIn> list = flowMainExtendMapper.toDolistByInfo(model, dt);
  1332. PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
  1333. return pageInfo;
  1334. }
  1335. public Integer numtoDolisAndEntrusttByInfo(FlowMainIn model, DateTrans dt) {
  1336. model.setAuditResult(new String[]{"1", "2"});
  1337. return flowMainExtendMapper.numtoDolistByInfo(model, dt);
  1338. }
  1339. /**
  1340. * 获取流程步骤(前端用) todo 新增流程要在这里加_步骤3
  1341. *
  1342. * @return
  1343. */
  1344. public String[] getFlowStep(FlowMain flowMain) {
  1345. String[] flowStep = null;
  1346. {
  1347. if (flowMain.getFlowType().equals(ConstantFlowType.ADD_WORK)) {
  1348. flowStep = ConstantFlowType.ADD_WORK_FLOWSTEPS;
  1349. }else if (flowMain.getFlowType().equals(ConstantFlowType.PAYMENT)) {
  1350. flowStep = ConstantFlowType.PAYMENT_FLOWSTEPS;
  1351. }
  1352. }
  1353. return flowStep;
  1354. }
  1355. /**
  1356. * 获取流程步骤(后端查询各个节点名称用),逻辑同上 todo 新增流程要在这里加_步骤2
  1357. *
  1358. * @param flowMain(就用了其中的getFlowType和getFormId方法)
  1359. * @return
  1360. */
  1361. public String[] getOnlyFlowFlowStep(FlowMain flowMain) {
  1362. String[] flowStep = null;
  1363. {
  1364. if (flowMain.getFlowType().equals(ConstantFlowType.ADD_WORK)) {
  1365. flowStep = ConstantFlowType.onlyFlow_ADD_WORK_FLOWSTEPS;
  1366. }else if (flowMain.getFlowType().equals(ConstantFlowType.PAYMENT)) {
  1367. flowStep = ConstantFlowType.onlyFlow_PAYMENT_FLOWSTEPS;
  1368. }
  1369. }
  1370. return flowStep;
  1371. }
  1372. /**
  1373. * 获取全流程信息 todo 新增流程要在这里加_步骤1
  1374. *
  1375. * @param flowType
  1376. * @return
  1377. */
  1378. public String[] getOnlylowStepAll(String flowType) {
  1379. String[] flowStep = null;
  1380. {
  1381. if (flowType.equals(ConstantFlowType.ADD_WORK)) {
  1382. flowStep = ConstantFlowType.onlyFlow_ADD_WORK_FLOWSTEPS_ALL;
  1383. }else if (flowType.equals(ConstantFlowType.PAYMENT)) {
  1384. flowStep = ConstantFlowType.onlyFlow_PAYMENT_FLOWSTEPS_ALL;
  1385. }
  1386. }
  1387. return flowStep;
  1388. }
  1389. /**
  1390. * 前端流程图使用查看各个流程节点目前的情况
  1391. *
  1392. * @param flowMainId
  1393. * @return
  1394. */
  1395. public List<IMGFlowHistoryInfo> getIMGFlowHistroyByFlowMainId(String flowMainId) {
  1396. FlowMain flowMain = flowMainMapper.selectByPrimaryKey(flowMainId);
  1397. // 判断流程是哪种流程
  1398. String[] flowStep = this.getFlowStep(flowMain);
  1399. //获取返回值
  1400. ArrayList<IMGFlowHistoryInfo> imgFlowHistoryInfos = new ArrayList<>();
  1401. {//`flow_status` int(4) DEFAULT NULL COMMENT //'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  1402. if (flowMain.getFlowStatus().equals(1)) { //ok //需要找到最新推送人 //'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  1403. List<FlowMainPush> pushByFlowMainId = flowMainPushService.findPushByFlowMainId(flowMainId);
  1404. String pushUserKey = pushByFlowMainId.get(0).getNodeUserRole();
  1405. if (pushUserKey == null) {
  1406. pushUserKey = pushByFlowMainId.get(0).getPushUserKey();
  1407. }
  1408. boolean isLastLogFind = false;//是否最后一个流程记录在节点中找到了,如果没有找到就在imgFlowHistoryInfos中插入一条信息
  1409. for (int i = 0; i < flowStep.length; i++) {
  1410. if (flowStep[i].startsWith(pushUserKey)) {
  1411. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1412. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1413. imgFlowHistoryInfo.setType("3");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1414. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1415. isLastLogFind = true;
  1416. break;
  1417. } else {
  1418. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1419. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1420. imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1421. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1422. }
  1423. }
  1424. if (!isLastLogFind) {
  1425. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1426. imgFlowHistoryInfo.setNodeKey(pushUserKey);
  1427. imgFlowHistoryInfo.setType("3");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1428. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1429. }
  1430. // return imgFlowHistoryInfos;
  1431. } else if (flowMain.getFlowStatus().equals(2)) {//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  1432. //需要找到最新操作日志
  1433. FlowMainLog flowMainLog = flowMainLogService.selectLastOneByFlowMainId(flowMainId);
  1434. if (flowMainLog == null) {
  1435. return null;
  1436. }
  1437. String pushUserKey = flowMainLog.getPushUserKey();
  1438. boolean isLastLogFind = false;//是否最后一个流程记录在节点中找到了,如果没有找到就在imgFlowHistoryInfos中插入一条信息
  1439. for (int i = 0; i < flowStep.length; i++) {
  1440. if (flowStep[i].startsWith(pushUserKey)) {
  1441. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1442. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1443. imgFlowHistoryInfo.setType("2");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1444. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1445. isLastLogFind = true;
  1446. break;
  1447. } else {
  1448. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1449. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1450. imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1451. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1452. }
  1453. }
  1454. if (!isLastLogFind) {
  1455. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1456. imgFlowHistoryInfo.setNodeKey(pushUserKey);
  1457. imgFlowHistoryInfo.setType("2");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1458. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1459. }
  1460. // return imgFlowHistoryInfos;
  1461. } else if (flowMain.getFlowStatus().equals(3)) {//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  1462. //需要找到最新操作日志
  1463. FlowMainLog flowMainLog = flowMainLogService.selectLastOneByFlowMainId(flowMainId);
  1464. if (flowMainLog == null) {
  1465. return null;
  1466. }
  1467. String pushUserKey = flowMainLog.getPushUserKey();
  1468. boolean isLastLogFind = false;//是否最后一个流程记录在节点中找到了,如果没有找到就在imgFlowHistoryInfos中插入一条信息
  1469. for (int i = 0; i < flowStep.length; i++) {
  1470. if (flowStep[i].startsWith(pushUserKey)) {
  1471. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1472. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1473. if ("1".equals(flowMainLog.getAuditResult())) {//1,同意
  1474. imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1475. imgFlowHistoryInfo.setIsPass("1");
  1476. } else {
  1477. imgFlowHistoryInfo.setType("6");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1478. }
  1479. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1480. isLastLogFind = true;
  1481. break;
  1482. } else {
  1483. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1484. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1485. imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1486. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1487. }
  1488. }
  1489. if (!isLastLogFind) {
  1490. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1491. imgFlowHistoryInfo.setNodeKey(pushUserKey);
  1492. if ("1".equals(flowMainLog.getAuditResult())) {//1,同意
  1493. imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1494. imgFlowHistoryInfo.setIsPass("1");
  1495. } else {
  1496. imgFlowHistoryInfo.setType("6");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1497. }
  1498. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1499. }
  1500. // return imgFlowHistoryInfos;
  1501. } else if (flowMain.getFlowStatus().equals(4)) {//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
  1502. //判断是监控室撤回还是自己撤回
  1503. //需要找到最新操作日志
  1504. FlowMainLog flowMainLog = flowMainLogService.selectLastOneByFlowMainId(flowMainId);
  1505. if (flowMainLog == null) {
  1506. return null;
  1507. }
  1508. String pushUserKey = flowMainLog.getPushUserKey();
  1509. boolean isLastLogFind = false;//是否最后一个流程记录在节点中找到了,如果没有找到就在imgFlowHistoryInfos中插入一条信息
  1510. for (int i = 0; i < flowStep.length; i++) {
  1511. if (flowStep[i].startsWith(pushUserKey)) {
  1512. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1513. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1514. if (flowMainLog.getAuditType().equals(5)) {
  1515. //监控室撤回
  1516. imgFlowHistoryInfo.setType("5");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1517. } else {
  1518. imgFlowHistoryInfo.setType("4");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1519. }
  1520. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1521. isLastLogFind = true;
  1522. break;
  1523. } else {
  1524. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1525. imgFlowHistoryInfo.setNodeKey(flowStep[i]);
  1526. imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1527. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1528. }
  1529. }
  1530. if (!isLastLogFind) {
  1531. IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
  1532. imgFlowHistoryInfo.setNodeKey(pushUserKey);
  1533. if (flowMainLog.getAuditType().equals(5)) {
  1534. //监控室撤回
  1535. imgFlowHistoryInfo.setType("5");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1536. } else {
  1537. imgFlowHistoryInfo.setType("4");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
  1538. }
  1539. imgFlowHistoryInfos.add(imgFlowHistoryInfo);
  1540. }
  1541. // return imgFlowHistoryInfos;
  1542. }
  1543. }
  1544. {//查询操作记录,将操作过的设置isjump为false,默认isjump为true
  1545. List<FlowMainLog> flowMainLogs = flowMainLogService.selectPassListByFlowMainId(flowMainId);
  1546. for (int i = 0; i < imgFlowHistoryInfos.size(); i++) {
  1547. IMGFlowHistoryInfo imgFlowHistoryInfo = imgFlowHistoryInfos.get(i);
  1548. if (i == 0) {
  1549. imgFlowHistoryInfo.setJump(false);
  1550. } else if (i == (imgFlowHistoryInfos.size() - 1)) {
  1551. imgFlowHistoryInfo.setJump(false);
  1552. } else {
  1553. for (FlowMainLog flowMainLog : flowMainLogs) {
  1554. // FlowMainLog flowMainLog
  1555. if (flowMainLog.getPushUserKey().startsWith(imgFlowHistoryInfo.getNodeKey())) {
  1556. imgFlowHistoryInfo.setJump(false);
  1557. break;
  1558. }
  1559. }
  1560. }
  1561. }
  1562. }
  1563. return imgFlowHistoryInfos;
  1564. }
  1565. /**
  1566. * 进行串并联申请,将id合并起来,用逗号,隔开
  1567. *
  1568. * @return
  1569. */
  1570. public FrameUser getFrameUsersId(String roleType, List<FrameUser> targetUserList, FrameUser targetUser) {
  1571. String[] roleTypeArray = roleType.split("_");
  1572. String key_e = roleTypeArray[roleTypeArray.length - 1];
  1573. if ("1".equals(key_e)) {//1 单流程推送 2 串联审核 3 并联推送
  1574. } else {
  1575. String ids = "";
  1576. for (FrameUser frameUser : targetUserList) {
  1577. ids += ("," + frameUser.getId());
  1578. }
  1579. targetUser.setId(ids.substring(1));
  1580. }
  1581. return targetUser;
  1582. }
  1583. /**
  1584. * 查询领导的全流程查看对应的目标用户,如果未来有需求可以将出纳等财务的角色也放进去
  1585. * //要进行从本角色(部门已经查过了,就是从领导角色开始查)开始的本流程的全角色查询
  1586. * 还有查全流程如果是会签就要改成并签了,因为之前支线流程里面没有找到对应节点
  1587. *
  1588. * @param flowMain
  1589. * @param flowRole
  1590. * @return
  1591. */
  1592. public TagerUserAndFlowRole getAllUpRoleTargetUsers(FlowMain flowMain, String flowRole) {
  1593. String[] flowStep = this.getOnlylowStepAll(flowMain.getFlowType());
  1594. return this.getAllUpRoleTargetUsers_getUpRoleTargetUsers(flowStep, flowMain, flowRole, true);
  1595. }
  1596. /**
  1597. * 合并两个方法
  1598. * isNeed3To2:是否需要并签改串签
  1599. *
  1600. * @return
  1601. */
  1602. public TagerUserAndFlowRole getAllUpRoleTargetUsers_getUpRoleTargetUsers(String[] flowStep, FlowMain flowMain, String flowRole, boolean isNeed3To2) {
  1603. TagerUserAndFlowRole tagerUserAndFlowRole = new TagerUserAndFlowRole();
  1604. String targetRole = null;//找目标用户的角色
  1605. FrameUser targetUser = null;//目标人
  1606. int i = 0;
  1607. boolean isFindStartRole = false;
  1608. for (; i < flowStep.length; i++) {
  1609. if (!isFindStartRole) {
  1610. if (flowStep[i].startsWith(flowRole)) {
  1611. isFindStartRole = true;
  1612. targetRole = flowStep[i]; //例如 flow_fgld_1_0_1
  1613. String shortTargetRole = proActiService.getSetRurrRole(targetRole); //例如 flow_fgld
  1614. {//查看谁是对应角色并查找对应的人
  1615. for (int j = 0; j < ConstantFlowType.FLOW_ROLES.length; j++) {
  1616. if (ConstantFlowType.FLOW_ROLES[j].equals(shortTargetRole)) {//1.1.2如果是领导关系的查领导
  1617. //查看谁是对应角色并查找对应的人
  1618. String role = ConstantFlowType.ROLES[j]; //例如 fgld
  1619. // 进行查询目标人
  1620. List<FrameUser> targetUserList = this.findFrameUsersByRoleKeyAndGroup(
  1621. role, ConstantFlowType.ROLETYPE, flowMain.getGroupId());
  1622. if (!targetUserList.isEmpty() && targetUserList.size() >= 1) {
  1623. targetUser = targetUserList.get(0);
  1624. //进行串并联申请
  1625. {
  1626. targetUser = this.getFrameUsersId(targetRole, targetUserList, targetUser);
  1627. }
  1628. }
  1629. break;
  1630. }
  1631. }
  1632. if (targetUser == null) {
  1633. //进行下个角色查询
  1634. } else {
  1635. tagerUserAndFlowRole.setFrameUser(targetUser);
  1636. if (isNeed3To2) {//是否需要并签改串签
  1637. String[] roleTypeArray = targetRole.split("_");
  1638. String key_e = roleTypeArray[roleTypeArray.length - 1];
  1639. if ("3".equals(key_e)) {//1 单流程推送 2 串联审核 3 并联推送
  1640. targetRole = targetRole.substring(0, targetRole.length() - 1) + "2";
  1641. }
  1642. }
  1643. tagerUserAndFlowRole.setFlowRole(targetRole);
  1644. tagerUserAndFlowRole.setOnlyFlowFlowStep(flowStep);
  1645. return tagerUserAndFlowRole;
  1646. }
  1647. }
  1648. }
  1649. } else {
  1650. targetRole = flowStep[i]; //例如 flow_fgld_1_0_1
  1651. String shortTargetRole = proActiService.getSetRurrRole(targetRole); //例如 flow_fgld
  1652. {//查看谁是对应角色并查找对应的人
  1653. for (int j = 0; j < ConstantFlowType.FLOW_ROLES.length; j++) {
  1654. if (ConstantFlowType.FLOW_ROLES[j].equals(shortTargetRole)) {//1.1.2如果是领导关系的查领导
  1655. //查看谁是对应角色并查找对应的人
  1656. String role = ConstantFlowType.ROLES[j]; //例如 fgld
  1657. // 进行查询目标人
  1658. List<FrameUser> targetUserList = this.findFrameUsersByRoleKeyAndGroup(
  1659. role, ConstantFlowType.ROLETYPE, flowMain.getGroupId());
  1660. if (!targetUserList.isEmpty() && targetUserList.size() >= 1) {
  1661. targetUser = targetUserList.get(0);
  1662. //进行串并联申请
  1663. {
  1664. targetUser = this.getFrameUsersId(targetRole, targetUserList, targetUser);
  1665. }
  1666. }
  1667. break;
  1668. }
  1669. }
  1670. if (targetUser == null) {
  1671. //进行下个角色查询
  1672. } else {
  1673. tagerUserAndFlowRole.setFrameUser(targetUser);
  1674. if (isNeed3To2) {//是否需要并签改串签
  1675. String[] roleTypeArray = targetRole.split("_");
  1676. String key_e = roleTypeArray[roleTypeArray.length - 1];
  1677. if ("3".equals(key_e)) {//1 单流程推送 2 串联审核 3 并联推送
  1678. targetRole = targetRole.substring(0, targetRole.length() - 1) + "2";
  1679. }
  1680. }
  1681. tagerUserAndFlowRole.setFlowRole(targetRole);
  1682. tagerUserAndFlowRole.setOnlyFlowFlowStep(flowStep);
  1683. return tagerUserAndFlowRole;
  1684. }
  1685. }
  1686. }
  1687. }
  1688. if (targetRole == null) {
  1689. return tagerUserAndFlowRole;
  1690. } else {
  1691. return tagerUserAndFlowRole;
  1692. }
  1693. }
  1694. /**
  1695. * 根据传入的步骤进行查询(注意,有可能有出纳等财务角色,目前会剔除,默认出纳等财务必须有)
  1696. * //查询对应设置角色开始的角色
  1697. *
  1698. * @param flowRole
  1699. * @param onlyFlowFlowStep
  1700. * @return
  1701. */
  1702. public TagerUserAndFlowRole getUpRoleTargetUsers(FlowMain flowMain, String flowRole, String[] onlyFlowFlowStep) {
  1703. String[] flowStep = onlyFlowFlowStep;
  1704. return this.getAllUpRoleTargetUsers_getUpRoleTargetUsers(flowStep, flowMain, flowRole, false);
  1705. }
  1706. }