12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859 |
- package com.idea.oa.flow2.service;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.idea.oa.activiti.service.ProActiService;
- import com.idea.oa.apply.model.inout.AddConfirmResult;
- import com.idea.oa.apply.model.inout.OperaterManage;
- import com.idea.oa.apply.util.constant.ConstantFlowType;
- import com.idea.oa.flow2.mapper.FlowMainExtendMapper;
- import com.idea.oa.flow2.mapper.FlowMainMapper;
- import com.idea.oa.flow2.model.*;
- import com.idea.oa.flow2.model.in.FlowMainIn;
- import com.idea.oa.flow2.model.in.TagerUserAndFlowRole;
- import com.idea.oa.flow2.model.out.FlowHistoryInfo;
- import com.idea.oa.flow2.model.out.IMGFlowHistoryInfo;
- import com.rockstar.common.base.BaseService;
- import com.rockstar.common.domain.AjaxResult;
- import com.rockstar.common.support.Convert;
- import com.rockstar.flow.service.FlowService;
- import com.rockstar.frame.model.FrameRoleData;
- import com.rockstar.frame.model.FrameUser;
- import com.rockstar.frame.model.extend.DateTrans;
- import com.rockstar.frame.model.extend.Tablepar;
- import com.rockstar.frame.service.FrameUserService;
- import com.rockstar.shiro.util.ShiroUtils;
- import com.rockstar.util.UUIDUtils;
- import org.activiti.bpmn.model.UserTask;
- import org.activiti.engine.TaskService;
- import org.activiti.engine.task.Task;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.util.StringUtils;
- import java.math.BigDecimal;
- import java.math.MathContext;
- import java.util.*;
- @Service
- public class FlowMainService implements BaseService<FlowMain, FlowMainExample> {
- // @Autowired
- // private ApplyUseMoneyDetailService applyUseMoneyDetailService;
- @Autowired
- public FrameUserService frameUserService;
- @Autowired
- private TaskService taskService;
- @Autowired
- private FlowService flowService;
- @Autowired
- private FlowMainPushService flowMainPushService;
- //文件mapper
- @Autowired
- private FlowMainMapper flowMainMapper;
- @Autowired
- private FlowMainExtendMapper flowMainExtendMapper;
- @Autowired
- private ProActiService proActiService;
- @Autowired
- private FlowMainLogService flowMainLogService;
- @Autowired
- private FlowMainCcService flowMainCcService;
- /**
- * 添加审核结果
- * 根据不同的状态值confirmResult判断是 1:审核通过,转下一步;2:退回发起人;3:退回上节点;4:结束流程(不同意,并且结束流程);
- *
- * @return string 如果为ok就是成功,不然就是失败message
- */
- public String doConfirmResult(AddConfirmResult addConfirmResult, String deploymentid, String constantFlowType, FlowMainPush flowMainPush, HashMap<String, Object> conditionMap) throws com.rockstar.flow.exception.FlowException {
- if (addConfirmResult.getConfirmResult() == null) {
- return "没有获取到confirmResult值";
- }
- // String deploymentid = ConstantFlowType.USE_MONEY_DEPLOYMENTID;
- // String constantFlowType = ConstantFlowType.USE_MONEY;
- OperaterManage operaterManage = new OperaterManage();
- FrameUser frameUser = new FrameUser();
- try {
- frameUser.setId(ShiroUtils.getUser().getId());
- } catch (Exception e) {
- frameUser.setId(addConfirmResult.getOperaterId());
- }
- operaterManage.setUser(frameUser);
- // FlowMainPush flowMainPush = flowMainPushService.selectByPrimaryKey(addConfirmResult.getFlowMainPushId());
- if (!flowMainPush.getStatus().equals(0)) {
- if (flowMainPush.getStatus().equals(1)) {
- return "已经在" + flowMainPush.getUpdatedAt() + "时操作过了,请重新确认";
- } else if (flowMainPush.getStatus().equals(2)) {
- return "已经在" + flowMainPush.getUpdatedAt() + "时由其他审核人操作过了,请重新确认";
- }
- }
- {//提前逻辑删除推送信息,保证数据不会因为同步操作出现冲突
- FlowMainPush updateFlowMainPush = new FlowMainPush();
- updateFlowMainPush.setId(flowMainPush.getId());
- updateFlowMainPush.setStatus(1);
- updateFlowMainPush.setUpdatedAt(new Date());
- updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
- flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
- }
- FlowMain flowMain = this.selectByPrimaryKey(flowMainPush.getFlowMainId());
- //当前任务流程 目的是获取节点名称,存起来nodeName
- String nodeName = flowMainPush.getNodeName() == null ? proActiService.getNodeName(flowMainPush) : flowMainPush.getNodeName();
- if (nodeName == null) {
- return "异常:没有找到对应的任务...请通知管理员";
- }
- String mypushUserKey = flowMainPush.getNodeUserRole();
- if (mypushUserKey == null) {
- mypushUserKey = flowMainPush.getPushUserKey();
- }
- // flowMain.
- // Map<String, Object> conditionMap
- //审核通过,转下一步
- boolean isEnd = false;//是否审核到最后一步了
- String roleType = null; //节点key 例如dept_superior_1_0_1
- {
- //todo 先要判断是否是会签,会签要过滤一下, (后面的部分下面完成了)不是会签的就把其他待审核数据逻辑删除
- // 1:单流程推送
- // 2:串联审核(会签)
- // 3:并联推送
- // 步骤1,判断是否是会签
- //2,如果是,判断是否是同意
- //3,如果不是同意就跳出本判断,如果是同意就判断会签人是不是都同意了,如果都同意了也跳过本判断,如果还没有都同意,就只修改push(已经改了)和增加log和抄送信息
- Integer pushType = flowMainPush.getPushType();
- if (new Integer(2).equals(pushType)) {
- if (addConfirmResult.getConfirmResult().equals("1")) {//审核通过 ok
- // 判断会签人是不是都同意了,如果都同意了也跳过本判断,如果还没有都同意,就只修改push(已经改了)和增加log和抄送信息
- {
- List<FlowMainPush> pushByFlowMainId = flowMainPushService.findPushByFlowMainId(flowMainPush.getFlowMainId());
- if (pushByFlowMainId != null && !pushByFlowMainId.isEmpty() && pushByFlowMainId.size() > 0) {
- //存入流程日志表的id
- String flowMainLogUuid = UUIDUtils.middleUUID();
- //发现不需要修改setLastMainLogId,因为这个字段是保存:最后一次上个节点审核时的表(flow_main_log)id
- // {
- // FlowMain flowMain1 = new FlowMain();
- // flowMain1.setId(flowMainPush.getFlowMainId());
- // flowMain1.setLastMainLogId(flowMainLogUuid);
- // this.updateLastMainLogId(flowMainPush.getFlowMainId(),flowMainLogUuid);//修改主表的日志最后记录
- // }
- //2添加日志 ok
- FlowMainLog flowMainLog = new FlowMainLog();
- {
- flowMainLog.setId(flowMainLogUuid);
- flowMainLog.setFlowMainId(flowMain.getId());
- flowMainLog.setFormId(flowMain.getFormId());
- flowMainLog.setAuditUser(operaterManage.getUser().getId());
- flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
- flowMainLog.setAuditResult("1");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)',
- //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
- flowMainLog.setAuditType("1");
- flowMainLog.setFlowType(constantFlowType);
- flowMainLog.setFlowPost(operaterManage.getUser().getId());
- {// 需要工作流引擎的支持
- flowMainLog.setFlowId(flowMain.getFlowId());
- flowMainLog.setTaskId(flowMainPush.getTaskId());
- flowMainLog.setNodeName(nodeName);
- flowMainLog.setPushUserKey(mypushUserKey);
- }
- // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
- // 因为感觉用不到,暂时不放进去
- // flowMainLog.setNextPersons();
- flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
- flowMainLog.setCcList(null);
- flowMainLog.setCreatedAt(new Date());
- flowMainLog.setCreatedBy(operaterManage.getUser().getId());
- flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
- flowMainLog.setStatus(0);
- flowMainLogService.insertWithoutId(flowMainLog);
- }
- // 3存入抄送人信息 ok
- if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
- String[] split = addConfirmResult.getCcList().split(",");
- for (String ccId : split) {
- if (!StringUtils.isEmpty(ccId)) {
- FlowMainCc flowMainCc = new FlowMainCc();
- flowMainCc.setFlowMainId(flowMain.getId());
- flowMainCc.setCcUser(ccId);
- //选择抄送人时的记录表id(flow_main_log):例如:112122
- flowMainCc.setMainLogIds(flowMainLog.getId());
- flowMainCc.setUpdatedAt(new Date());
- flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
- flowMainCc.setCreatedBy(operaterManage.getUser().getId());
- flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
- flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
- flowMainCc.setStatus(0);
- flowMainCcService.insert(flowMainCc);
- }
- }
- }
- return "ok_noEnd";
- }
- }
- }
- }
- }
- if (addConfirmResult.getConfirmResult().equals("1")) {//审核通过 ok
- {// 发起流程引擎操作 并查看下一节点的操作要求
- //1.如果当前角色是自己,就进行正常的审核流程
- //2.先查看当前角色是不是自己,不是自己就移动到自己的角色,然后再进行正常的审核流程
- Map<String, String> stringStringMap = proActiService.passToRunTask(flowMainPush, deploymentid, flowMainPush.getFlowMainId(), conditionMap, flowMain);
- if (stringStringMap == null) {
- return "流程引擎开启失败,请查看原因!";
- }
- isEnd = stringStringMap.get("isEnd") == null ? false : true;
- //可能会传roleType,但是如果没有传就在pushuser中进行查询
- roleType = stringStringMap.get("roleType");
- }
- {
- //存入流程日志表的id
- String flowMainLogUuid = UUIDUtils.middleUUID();
- //1修改主表状态 ok
- {
- FlowMain flowMain1 = new FlowMain();
- flowMain1.setId(flowMainPush.getFlowMainId());
- if (isEnd) {
- flowMain1.setFlowStatus(3);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
- flowMain1.setFlowResult(1); //审核结果0无状态,1审核通过结束,2审核不通过结束
- } else {
- flowMain1.setFlowStatus(1);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
- flowMain1.setFlowResult(0); //审核结果0无状态,1审核通过结束,2审核不通过结束
- }
- flowMain1.setLastMainLogId(flowMainLogUuid);
- flowMain1.setUpdatedAt(new Date());
- flowMain1.setUpdatedBy(operaterManage.getUser().getId());
- this.updateByPrimaryKeySelective(flowMain1);
- }
- //2添加日志 ok
- FlowMainLog flowMainLog = new FlowMainLog();
- {
- flowMainLog.setId(flowMainLogUuid);
- flowMainLog.setFlowMainId(flowMain.getId());
- flowMainLog.setFormId(flowMain.getFormId());
- flowMainLog.setAuditUser(operaterManage.getUser().getId());
- flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
- flowMainLog.setAuditResult("1");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)',
- //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
- if (isEnd) {
- flowMainLog.setAuditType("2");
- } else {
- flowMainLog.setAuditType("1");
- }
- flowMainLog.setFlowType(constantFlowType);
- flowMainLog.setFlowPost(operaterManage.getUser().getId());
- {// 需要工作流引擎的支持
- flowMainLog.setFlowId(flowMain.getFlowId());
- flowMainLog.setTaskId(flowMainPush.getTaskId());
- flowMainLog.setNodeName(nodeName);
- flowMainLog.setPushUserKey(mypushUserKey);
- }
- // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
- // 因为感觉用不到,暂时不放进去
- // flowMainLog.setNextPersons();
- flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
- flowMainLog.setCcList(null);
- flowMainLog.setCreatedAt(new Date());
- flowMainLog.setCreatedBy(operaterManage.getUser().getId());
- flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
- flowMainLog.setStatus(0);
- flowMainLogService.insertWithoutId(flowMainLog);
- }
- // 3存入抄送人信息 ok
- if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
- String[] split = addConfirmResult.getCcList().split(",");
- for (String ccId : split) {
- if (!StringUtils.isEmpty(ccId)) {
- FlowMainCc flowMainCc = new FlowMainCc();
- flowMainCc.setFlowMainId(flowMain.getId());
- flowMainCc.setCcUser(ccId);
- //选择抄送人时的记录表id(flow_main_log):例如:112122
- flowMainCc.setMainLogIds(flowMainLog.getId());
- flowMainCc.setUpdatedAt(new Date());
- flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
- flowMainCc.setCreatedBy(operaterManage.getUser().getId());
- flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
- flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
- flowMainCc.setStatus(0);
- flowMainCcService.insert(flowMainCc);
- }
- }
- }
- //4.0判断是否存在串并联并修改推送状态 逻辑删除旧的推送人
- {
- //todo推送类型1单流程推送,2串联推送,3并联推送
- Integer pushType = flowMainPush.getPushType();
- //逻辑删除本推送
- {
- // FlowMainPush updateFlowMainPush = new FlowMainPush();
- // updateFlowMainPush.setId(flowMainPush.getId());
- // updateFlowMainPush.setStatus(1);
- // updateFlowMainPush.setUpdatedAt(new Date());
- // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
- // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
- }
- if (pushType.equals(1) || pushType.equals(2)) {
- //只要逻辑删除本推送
- } else if (pushType.equals(3)) {
- //要逻辑删除自己和其他推送
- //将其他并联推送的人员推送状态status改成2状态值
- flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
- }
- }
- //4添加新的推送人员
- if (!isEnd) {//查看各个任务
- List<Task> listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list();
- // taskService.createTaskQuery().processInstanceId();
- //查看总的数据流程
- List<UserTask> TaskList = flowService.getTaskList(deploymentid);
- for (Task task : listTask) {
- {
- //获取推送类型1单流程推送,2串联推送,3并联推送',
- Integer pushType = null;
- //'推送时彭总给的key值',
- String pushUserKey = null;
- UserTask myUserTask = null;
- {
- String taskDefinitionKey = task.getTaskDefinitionKey();
- for (int i = 0; i < TaskList.size(); i++) {
- if (TaskList.get(i).getId().equals(taskDefinitionKey)) {
- myUserTask = TaskList.get(i);
- break;
- }
- }
- if (myUserTask != null) {
- pushUserKey = myUserTask.getCandidateGroups().get(0);
- }
- //判断是否存在串并联并修改推送状态
- if (roleType == null) {//只有在首次申请,且直属上级还有更高级的身份才会没有,但是还是在直属上级这里进行并联审核
- if (pushUserKey != null) {
- if (listTask.size() > 1) {
- String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_");
- if (s1.length >= 5) {
- String pushTypeNum = s1[4];
- if ("0".equals(pushTypeNum)) {
- pushType = 2;
- } else if ("1".equals(pushTypeNum)) {
- pushType = 3;
- }
- }
- } else {
- pushType = 2;
- }
- }
- } else {
- String[] roleTypeArray = roleType.split("_");
- String pushTypeNum = roleTypeArray[roleTypeArray.length - 1];
- if ("1".equals(pushTypeNum)) {
- pushType = 1;
- } else if ("2".equals(pushTypeNum)) {
- pushType = 2;
- } else if ("3".equals(pushTypeNum)) {
- pushType = 3;
- } else {
- pushType = 2;
- }
- }
- }
- FlowMainPush newflowMainPush = new FlowMainPush();
- newflowMainPush.setFlowMainId(flowMain.getId());
- newflowMainPush.setFormId(flowMain.getFormId());
- {// 需要工作流引擎的支持
- newflowMainPush.setPushUser(task.getAssignee().split(",")[0]);//推送人id'
- newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
- newflowMainPush.setNodeName(myUserTask.getName());
- {
- // flowMainPush.setNodeUserRole(pushUserKey);
- // flowMainPush.setNodeName(myUserTask.getName());
- // 上面的方法进行修改 做一个方法替换原来的填写节点名称,目的是获取用户跳节点时对应的节点名称放在新的对象字段(node_user_role)中
- newflowMainPush = this.setPushUserKeyAndNodeName(newflowMainPush, task.getAssignee().split(",")[0], flowMain, roleType);
- }
- newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
- newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
- newflowMainPush.setFlowType(constantFlowType);
- newflowMainPush.setFlowPost(task.getAssignee());
- ////2023年5月10日 修改成上面的了 张洮
- // newflowMainPush.setFlowPost(operaterManage.getUser().getId());
- newflowMainPush.setFlowId(flowMain.getFlowId());
- newflowMainPush.setTaskId(task.getId());
- }
- newflowMainPush.setUpMainLogId(flowMainLog.getId());
- newflowMainPush.setUpdatedAt(new Date());
- newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt());
- newflowMainPush.setCreatedBy(operaterManage.getUser().getId());
- newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy());
- newflowMainPush.setGroupId(operaterManage.getUser().getGroupId());
- newflowMainPush.setStatus(0);
- {//插入推送人前进行判断
- if (new Integer(1).equals(newflowMainPush.getPushType())) {
- flowMainPushService.insert(newflowMainPush);
- } else {
- String[] splitIds = task.getAssignee().split(",");
- for (int i = 0; i < splitIds.length; i++) {
- newflowMainPush.setPushUser(splitIds[i]);
- flowMainPushService.insert(newflowMainPush);
- }
- }
- }
- }
- }
- }
- }
- } else if (addConfirmResult.getConfirmResult().equals("2")) {//退回发起人 ok
- {// 退回发起人
- isEnd = true;
- // flowService.deleteInstance(flowMain.getFlowId(), "退回发起人");
- //当前审核人/委托人代表的用户id
- String myFrameUserId = proActiService.getMyFrameUserId(flowMainPush);
- if (myFrameUserId == null) {
- return null;
- }
- //当前审核人/委托人代表的用户
- FrameUser myFrameUser = frameUserService.selectByPrimaryKey(myFrameUserId);
- FrameUser targetUser = frameUserService.selectByPrimaryKey(flowMain.getApplyUser());
- // FrameUser currUser = operaterManage.getUser();
- boolean yes = flowService.runTask(flowMainPush.getTaskId(), null, "no", "退回发起人", targetUser, myFrameUser, null);
- }
- {
- //存入流程日志表的id
- String flowMainLogUuid = UUIDUtils.middleUUID();
- //1修改主表状态
- {
- FlowMain flowMain1 = new FlowMain();
- flowMain1.setId(flowMainPush.getFlowMainId());
- flowMain1.setFlowStatus(2);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
- flowMain1.setLastMainLogId(flowMainLogUuid);
- flowMain1.setUpdatedAt(new Date());
- flowMain1.setUpdatedBy(operaterManage.getUser().getId());
- this.updateByPrimaryKeySelective(flowMain1);
- }
- //2添加日志 ok
- FlowMainLog flowMainLog = new FlowMainLog();
- {
- flowMainLog.setId(flowMainLogUuid);
- flowMainLog.setFlowMainId(flowMain.getId());
- flowMainLog.setFormId(flowMain.getFormId());
- flowMainLog.setAuditUser(operaterManage.getUser().getId());
- flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
- flowMainLog.setAuditResult("2");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)',
- //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
- flowMainLog.setAuditType("1");
- flowMainLog.setFlowType(constantFlowType);
- flowMainLog.setFlowPost(operaterManage.getUser().getId());
- {// 需要工作流引擎的支持
- flowMainLog.setFlowId(flowMain.getFlowId());
- flowMainLog.setTaskId(flowMainPush.getTaskId());
- flowMainLog.setNodeName(nodeName);
- flowMainLog.setPushUserKey(mypushUserKey);
- }
- // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
- // 因为感觉用不到,暂时不放进去
- // flowMainLog.setNextPersons();
- flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
- flowMainLog.setCcList(null);
- flowMainLog.setCreatedAt(new Date());
- flowMainLog.setCreatedBy(operaterManage.getUser().getId());
- flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
- flowMainLog.setStatus(0);
- flowMainLogService.insertWithoutId(flowMainLog);
- }
- //2.1添加抄送
- if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
- String[] split = addConfirmResult.getCcList().split(",");
- for (String ccId : split) {
- if (!StringUtils.isEmpty(ccId)) {
- FlowMainCc flowMainCc = new FlowMainCc();
- flowMainCc.setFlowMainId(flowMain.getId());
- flowMainCc.setCcUser(ccId);
- //选择抄送人时的记录表id(flow_main_log):例如:112122
- flowMainCc.setMainLogIds(flowMainLog.getId());
- flowMainCc.setUpdatedAt(new Date());
- flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
- flowMainCc.setCreatedBy(operaterManage.getUser().getId());
- flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
- flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
- flowMainCc.setStatus(0);
- flowMainCcService.insert(flowMainCc);
- }
- }
- }
- //3判断是否存在串并联并修改推送状态 逻辑删除旧的推送人
- {
- //todo推送类型1单流程推送,2串联推送,3并联推送
- Integer pushType = flowMainPush.getPushType();
- //逻辑删除本推送
- {
- // FlowMainPush updateFlowMainPush = new FlowMainPush();
- // updateFlowMainPush.setId(flowMainPush.getId());
- // updateFlowMainPush.setStatus(1);
- // updateFlowMainPush.setUpdatedAt(new Date());
- // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
- // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
- }
- if (pushType.equals(1)) {
- //只要逻辑删除本推送
- } else if (pushType.equals(3) || pushType.equals(2)) {//3是并签//2是会签
- //要逻辑删除自己和其他推送
- //将其他并联推送的人员推送状态status改成2状态值
- flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
- }
- }
- //4添加推送人(因为退回发起人之后 发起人不需要再审核,所以改成推送人就不要了,下面的注释掉了)
- {//查看各个任务
- // List<Task> listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list();
- //// taskService.createTaskQuery().processInstanceId();
- // //查看总的数据流程
- // List<UserTask> TaskList = flowService.getTaskList(deploymentid);
- // for (Task task : listTask) {
- // UserTask myUserTask = null;
- // {
- // String taskDefinitionKey = task.getTaskDefinitionKey();
- // for (int i = 0; i < TaskList.size(); i++) {
- // if (TaskList.get(i).getId().equals(taskDefinitionKey)) {
- // myUserTask = TaskList.get(i);
- // break;
- // }
- // }
- // //判断是否存在串并联并修改推送状态
- // //'推送时彭总给的key值',
- // String pushUserKey = null;
- // if (myUserTask != null) {
- // pushUserKey = myUserTask.getCandidateGroups().get(0);
- // }
- // //'推送类型1单流程推送,2串联推送,3并联推送',
- // Integer pushType = 1;
- //// if (myUserTask != null) {
- //// pushUserKey = myUserTask.getCandidateGroups().get(0);
- //// if (listTask.size() > 1) {
- //// String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_");
- //// if (s1.length >= 5) {
- //// String pushTypeNum = s1[4];
- //// if ("0".equals(pushTypeNum)) {
- //// pushType = 2;
- //// } else if ("1".equals(pushTypeNum)) {
- //// pushType = 3;
- //// }
- ////
- //// }
- //// } else {
- //// pushType = 1;
- //// }
- //// }
- // FlowMainPush newflowMainPush = new FlowMainPush();
- // newflowMainPush.setFlowMainId(flowMain.getId());
- // newflowMainPush.setFormId(flowMain.getFormId());
- // {// 需要工作流引擎的支持
- // newflowMainPush.setPushUser(task.getAssignee());//推送人id'
- // newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
- // newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
- // newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
- // newflowMainPush.setFlowType(constantFlowType);
- // newflowMainPush.setFlowPost(operaterManage.getUser().getId());
- // newflowMainPush.setFlowId(flowMain.getFlowId());
- // newflowMainPush.setTaskId(task.getId());
- // }
- // newflowMainPush.setUpMainLogId(flowMainLog.getId());
- // newflowMainPush.setUpdatedAt(new Date());
- // newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt());
- // newflowMainPush.setCreatedBy(operaterManage.getUser().getId());
- // newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy());
- // newflowMainPush.setGroupId(operaterManage.getUser().getGroupId());
- // newflowMainPush.setStatus(0);
- // flowMainPushService.insert(newflowMainPush);
- // }
- // }
- }
- }
- } else if (addConfirmResult.getConfirmResult().equals("3")) {//退回上节点(todo 退回上个节点有问题,如果是跳跃审核的还有进行编辑,目前只支持不能跳跃审核的节点)
- FrameUser targetUser = null;
- {// 发起流程引擎操作
- //当前审核人/委托人代表的用户id
- String myFrameUserId = proActiService.getMyFrameUserId(flowMainPush);
- if (myFrameUserId == null) {
- return null;
- }
- //当前审核人/委托人代表的用户
- FrameUser myFrameUser = frameUserService.selectByPrimaryKey(myFrameUserId);
- FlowMainLog flowMainLog = flowMainLogService.selectByPrimaryKey(flowMainPush.getUpMainLogId());
- while ("4".equals(flowMainLog.getAuditResult())) {
- flowMainLog = flowMainLogService.selectByPrimaryKey(flowMainLog.getUpMainLogId());
- }
- targetUser = frameUserService.selectByPrimaryKey(flowMainLog.getAuditUser());
- // FrameUser currUser = operaterManage.getUser();
- boolean yes = flowService.runTask(flowMainPush.getTaskId(), null, "back", "退回上节点", targetUser, myFrameUser, null);
- }
- {
- //存入流程日志表的id
- String flowMainLogUuid = UUIDUtils.middleUUID();
- //1修改主表状态
- {
- FlowMain flowMain1 = new FlowMain();
- flowMain1.setId(flowMainPush.getFlowMainId());
- flowMain1.setFlowStatus(1);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
- flowMain1.setLastMainLogId(flowMainLogUuid);
- flowMain1.setUpdatedAt(new Date());
- flowMain1.setUpdatedBy(operaterManage.getUser().getId());
- this.updateByPrimaryKeySelective(flowMain1);
- }
- //2添加日志 ok
- FlowMainLog flowMainLog = new FlowMainLog();
- {
- flowMainLog.setId(flowMainLogUuid);
- flowMainLog.setFlowMainId(flowMain.getId());
- flowMainLog.setFormId(flowMain.getFormId());
- flowMainLog.setAuditUser(operaterManage.getUser().getId());
- flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
- flowMainLog.setAuditResult("3");// `audit_result` varchar(4) DEFAULT NULL COMMENT '审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,null没有审核)',
- //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
- flowMainLog.setAuditType("1");
- flowMainLog.setFlowType(constantFlowType);
- flowMainLog.setFlowPost(operaterManage.getUser().getId());
- {// 需要工作流引擎的支持
- flowMainLog.setFlowId(flowMain.getFlowId());
- flowMainLog.setTaskId(flowMainPush.getTaskId());
- flowMainLog.setNodeName(nodeName);
- flowMainLog.setPushUserKey(mypushUserKey);
- }
- // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
- // 因为感觉用不到,暂时不放进去
- // flowMainLog.setNextPersons();
- flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
- flowMainLog.setCcList(null);
- flowMainLog.setCreatedAt(new Date());
- flowMainLog.setCreatedBy(operaterManage.getUser().getId());
- flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
- flowMainLog.setStatus(0);
- flowMainLogService.insertWithoutId(flowMainLog);
- }
- //2.1添加抄送
- if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
- String[] split = addConfirmResult.getCcList().split(",");
- for (String ccId : split) {
- if (!StringUtils.isEmpty(ccId)) {
- FlowMainCc flowMainCc = new FlowMainCc();
- flowMainCc.setFlowMainId(flowMain.getId());
- flowMainCc.setCcUser(ccId);
- //选择抄送人时的记录表id(flow_main_log):例如:112122
- flowMainCc.setMainLogIds(flowMainLog.getId());
- flowMainCc.setUpdatedAt(new Date());
- flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
- flowMainCc.setCreatedBy(operaterManage.getUser().getId());
- flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
- flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
- flowMainCc.setStatus(0);
- flowMainCcService.insert(flowMainCc);
- }
- }
- }
- //3判断是否存在串并联并修改推送状态 逻辑删除旧的推送人
- {
- //todo推送类型1单流程推送,2串联推送,3并联推送
- Integer pushType = flowMainPush.getPushType();
- //逻辑删除本推送
- {
- // FlowMainPush updateFlowMainPush = new FlowMainPush();
- // updateFlowMainPush.setId(flowMainPush.getId());
- // updateFlowMainPush.setStatus(1);
- // updateFlowMainPush.setUpdatedAt(new Date());
- // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
- // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
- flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
- }
- }
- //4添加新的推送人员
- {//查看各个任务
- List<Task> listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list();
- // taskService.createTaskQuery().processInstanceId();
- //查看总的数据流程
- List<UserTask> TaskList = flowService.getTaskList(deploymentid);
- for (Task task : listTask) {
- UserTask myUserTask = null;
- {
- String taskDefinitionKey = task.getTaskDefinitionKey();
- for (int i = 0; i < TaskList.size(); i++) {
- if (TaskList.get(i).getId().equals(taskDefinitionKey)) {
- myUserTask = TaskList.get(i);
- break;
- }
- }
- //判断是否存在串并联并修改推送状态
- //'推送时彭总给的key值',
- String pushUserKey = null;
- if (myUserTask != null) {
- pushUserKey = myUserTask.getCandidateGroups().get(0);
- }
- //'推送类型1单流程推送,2串联推送,3并联推送',
- Integer pushType = 1;
- // if (myUserTask != null) {
- // pushUserKey = myUserTask.getCandidateGroups().get(0);
- // if (listTask.size() > 1) {
- // String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_");
- // if (s1.length >= 5) {
- // String pushTypeNum = s1[4];
- // if ("0".equals(pushTypeNum)) {
- // pushType = 2;
- // } else if ("1".equals(pushTypeNum)) {
- // pushType = 3;
- // }
- //
- // }
- // } else {
- // pushType = 1;
- // }
- // }
- FlowMainPush newflowMainPush = new FlowMainPush();
- newflowMainPush.setFlowMainId(flowMain.getId());
- newflowMainPush.setFormId(flowMain.getFormId());
- {// 需要工作流引擎的支持
- if (!task.getAssignee().equals(targetUser.getId())) {
- continue;
- }
- newflowMainPush.setPushUser(task.getAssignee());//推送人id'
- newflowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
- newflowMainPush.setNodeName(myUserTask.getName());
- newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
- newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
- newflowMainPush.setFlowType(constantFlowType);
- newflowMainPush.setFlowPost(task.getAssignee());
- ////2023年5月10日 修改成上面的了 张洮
- // newflowMainPush.setFlowPost(operaterManage.getUser().getId());
- newflowMainPush.setFlowId(flowMain.getFlowId());
- newflowMainPush.setTaskId(task.getId());
- }
- newflowMainPush.setUpMainLogId(flowMainLog.getId());
- newflowMainPush.setUpdatedAt(new Date());
- newflowMainPush.setCreatedAt(newflowMainPush.getUpdatedAt());
- newflowMainPush.setCreatedBy(operaterManage.getUser().getId());
- newflowMainPush.setUpdatedBy(newflowMainPush.getCreatedBy());
- newflowMainPush.setGroupId(operaterManage.getUser().getGroupId());
- newflowMainPush.setStatus(0);
- flowMainPushService.insert(newflowMainPush);
- }
- }
- }
- }
- } else if (addConfirmResult.getConfirmResult().equals("4")) {//结束流程 ok
- isEnd = true;
- {// 发起流程引擎操作 并结束该流程
- flowService.deleteInstance(flowMain.getFlowId(), "结束流程");
- }
- {
- //存入流程日志表的id
- String flowMainLogUuid = UUIDUtils.middleUUID();
- //1修改主表状态
- {
- FlowMain flowMain1 = new FlowMain();
- flowMain1.setId(flowMainPush.getFlowMainId());
- flowMain1.setFlowStatus(3);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
- flowMain1.setFlowResult(2); //审核结果0无状态,1审核通过结束,2审核不通过结束
- flowMain1.setLastMainLogId(flowMainLogUuid);
- flowMain1.setUpdatedAt(new Date());
- flowMain1.setUpdatedBy(operaterManage.getUser().getId());
- this.updateByPrimaryKeySelective(flowMain1);
- }
- //2添加日志 ok
- FlowMainLog flowMainLog = new FlowMainLog();
- {
- flowMainLog.setId(flowMainLogUuid);
- flowMainLog.setFlowMainId(flowMain.getId());
- flowMainLog.setFormId(flowMain.getFormId());
- flowMainLog.setAuditUser(operaterManage.getUser().getId());
- flowMainLog.setAuditContent(addConfirmResult.getConfirmContent());
- flowMainLog.setAuditResult("5");// `audit_result` varchar(4) DEFAULT NULL COMMENT 审批结果(1同意或者2不同意驳回到申请人,3不同意驳回到上一个审核人,4,委托别人进行审核,5,不同意且结束流程,null没有审核)',
- //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
- flowMainLog.setAuditType("2");
- flowMainLog.setFlowType(constantFlowType);
- flowMainLog.setFlowPost(operaterManage.getUser().getId());
- {// 需要工作流引擎的支持
- flowMainLog.setFlowId(flowMain.getFlowId());
- flowMainLog.setTaskId(flowMainPush.getTaskId());
- flowMainLog.setNodeName(nodeName);
- flowMainLog.setPushUserKey(mypushUserKey);
- }
- // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
- // 因为感觉用不到,暂时不放进去
- // flowMainLog.setNextPersons();
- flowMainLog.setUpMainLogId(flowMainPush.getUpMainLogId());
- flowMainLog.setCcList(null);
- flowMainLog.setCreatedAt(new Date());
- flowMainLog.setCreatedBy(operaterManage.getUser().getId());
- flowMainLog.setGroupId(operaterManage.getUser().getGroupId());
- flowMainLog.setStatus(0);
- flowMainLogService.insertWithoutId(flowMainLog);
- }
- //3 存入抄送人信息
- if (!StringUtils.isEmpty(addConfirmResult.getCcList())) {
- String[] split = addConfirmResult.getCcList().split(",");
- for (String ccId : split) {
- if (!StringUtils.isEmpty(ccId)) {
- FlowMainCc flowMainCc = new FlowMainCc();
- flowMainCc.setFlowMainId(flowMain.getId());
- flowMainCc.setCcUser(ccId);
- //选择抄送人时的记录表id(flow_main_log):例如:112122
- flowMainCc.setMainLogIds(flowMainLog.getId());
- flowMainCc.setUpdatedAt(new Date());
- flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
- flowMainCc.setCreatedBy(operaterManage.getUser().getId());
- flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
- flowMainCc.setGroupId(operaterManage.getUser().getGroupId());
- flowMainCc.setStatus(0);
- flowMainCcService.insert(flowMainCc);
- }
- }
- }
- //4.0逻辑删除旧的推送人
- {
- //todo推送类型1单流程推送,2串联推送,3并联推送
- Integer pushType = flowMainPush.getPushType();
- //逻辑删除本推送
- {
- // FlowMainPush updateFlowMainPush = new FlowMainPush();
- // updateFlowMainPush.setId(flowMainPush.getId());
- // updateFlowMainPush.setStatus(1);
- // updateFlowMainPush.setUpdatedAt(new Date());
- // updateFlowMainPush.setUpdatedBy(operaterManage.getUser().getId());
- // flowMainPushService.updateByPrimaryKeySelective(updateFlowMainPush);
- }
- if (pushType.equals(1)) {
- //只要逻辑删除本推送
- } else if (pushType.equals(3) || pushType.equals(2)) {
- //要逻辑删除自己和其他推送
- //将其他并联推送的人员推送状态status改成2状态值
- flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
- }
- }
- }
- }
- if (isEnd) {
- return "ok_end";
- } else {
- return "ok_noEnd";
- }
- }
- /**
- * 通用方法,加载到流程业务模块
- *
- * @return
- */
- 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 {
- // 存入流程主表 ok
- FlowMain flowMain = new FlowMain();
- {
- flowMain.setId(UUIDUtils.middleUUID());
- flowMain.setFormId(recordId);
- flowMain.setFlowType(constantFlowType);
- if (ConstantFlowType.isMoreDept) {
- if (deptId == null) {
- return AjaxResult.error("请选择部门信息");
- }
- flowMain.setDeptId(deptId);
- } else {
- flowMain.setDeptId(currUser.getDepartment());
- }
- flowMain.setApplyTheme(ApplyTheme);
- flowMain.setApplyUser(currUser.getId());
- flowMain.setUpdatedAt(new Date());
- flowMain.setCreatedAt(flowMain.getUpdatedAt());
- flowMain.setCreatedBy(currUser.getId());
- flowMain.setUpdatedBy(flowMain.getCreatedBy());
- flowMain.setGroupId(currUser.getGroupId());
- if (!StringUtils.isEmpty(recordRemark)) {
- flowMain.setRemark(recordRemark);
- }
- }
- // 进入流程引擎,开始启动流程
- String processInstanceId = null;
- // 判断启动申请后是否结束
- boolean isEnd = false;
- currUser = frameUserService.selectByPrimaryKey(currUser.getId());
- String roleType = null; //节点key 例如dept_superior_1_0_1
- {
- //启动流程引擎
- Map<String, String> stringStringMap = proActiService.startTask(processdefine, deploymentid, flowMain, currUser, conditionMap, tagerUserId);
- if (stringStringMap == null) {
- return AjaxResult.error("流程引擎开启失败,请查看原因!");
- }
- processInstanceId = stringStringMap.get("processInstanceId");
- if (stringStringMap.get("isEnd") != null) {
- isEnd = true;
- }
- //可能会传roleType,但是如果没有传就在pushuser中进行查询
- roleType = stringStringMap.get("roleType");
- }
- //存入流程日志表的id
- String flowMainLogUuid = UUIDUtils.middleUUID();
- {
- // conditionMap
- // if (conditionMap!=null) {
- // Object conditionMapString = JSONObject.toJSON(conditionMap);
- // flowMain.setConditionMap(conditionMapString.toString());
- // }
- // 关于@客户名称@项目名称@供应商名称@付款名称的付款申请单
- // 判断是否结束
- if (isEnd) {
- flowMain.setFlowStatus(3);//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
- flowMain.setFlowResult(1); //审核结果0无状态,1审核通过结束,2审核不通过结束
- } else {
- flowMain.setFlowStatus(1);//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
- flowMain.setFlowResult(0); //审核结果0无状态,1审核通过结束,2审核不通过结束
- }
- flowMain.setReturnStatus(0);//'0/null无状态,1已撤回并且已重新发起',
- flowMain.setCcList(null);
- flowMain.setFlowName(constantFlowTypeNAME);
- //当前流程邮递操作人(frame_user)id 去除岗位的设定
- flowMain.setFlowPost(currUser.getId());
- {// 需要工作流引擎的支持
- flowMain.setFlowId(processInstanceId);
- flowMain.setTaskId(null);
- }
- flowMain.setLastMainLogId(flowMainLogUuid);
- flowMain.setStatus(0);
- this.insertWithoutId(flowMain);
- }
- // 存入流程日志表 ok
- FlowMainLog flowMainLog = new FlowMainLog();
- {
- flowMainLog.setId(flowMainLogUuid);
- flowMainLog.setFlowMainId(flowMain.getId());
- flowMainLog.setFormId(recordId);
- flowMainLog.setAuditUser(currUser.getId());
- // 判断是否结束
- if (isEnd) {
- flowMainLog.setAuditType("2"); //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
- flowMainLog.setAuditContent("自审通过");
- flowMainLog.setAuditResult("1");
- } else {
- flowMainLog.setAuditType("0"); //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
- flowMainLog.setAuditContent(null);
- flowMainLog.setAuditResult(null);
- }
- flowMainLog.setFlowType(constantFlowType);
- flowMainLog.setFlowPost(currUser.getId());
- {// 需要工作流引擎的支持
- flowMainLog.setFlowId(processInstanceId);
- flowMainLog.setTaskId(null);
- flowMainLog.setNodeName(ConstantFlowType.nodeKeysName.get(1));
- flowMainLog.setPushUserKey(ConstantFlowType.nodeKeysName.get(11));
- }
- // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
- // 因为感觉用不到,暂时不放进去
- // flowMainLog.setNextPersons();
- flowMainLog.setUpMainLogId(null);
- flowMainLog.setCcList(null);
- flowMainLog.setCreatedAt(new Date());
- flowMainLog.setCreatedBy(currUser.getId());
- flowMainLog.setGroupId(currUser.getGroupId());
- flowMainLog.setStatus(0);
- flowMainLogService.insertWithoutId(flowMainLog);
- }
- // 存入抄送人信息 ok
- if (!StringUtils.isEmpty(recordCcList)) {
- String[] split = recordCcList.split(",");
- for (String ccId : split) {
- if (!StringUtils.isEmpty(ccId)) {
- FlowMainCc flowMainCc = new FlowMainCc();
- flowMainCc.setFlowMainId(flowMain.getId());
- flowMainCc.setCcUser(ccId);
- //选择抄送人时的记录表id(flow_main_log):例如:112122
- flowMainCc.setMainLogIds(flowMainLog.getId());
- flowMainCc.setUpdatedAt(new Date());
- flowMainCc.setCreatedAt(flowMainCc.getUpdatedAt());
- flowMainCc.setCreatedBy(currUser.getId());
- flowMainCc.setUpdatedBy(flowMainCc.getCreatedBy());
- flowMainCc.setGroupId(currUser.getGroupId());
- flowMainCc.setStatus(0);
- flowMainCcService.insert(flowMainCc);
- }
- }
- }
- // 存入推送人
- //查看各个任务
- List<Task> listTask = taskService.createTaskQuery().processInstanceBusinessKey(flowMain.getId()).list();
- List<UserTask> TaskList = flowService.getTaskList(deploymentid);
- for (Task task : listTask) {
- UserTask myUserTask = null;
- {
- String taskDefinitionKey = task.getTaskDefinitionKey();
- for (int i = 0; i < TaskList.size(); i++) {
- if (TaskList.get(i).getId().equals(taskDefinitionKey)) {
- myUserTask = TaskList.get(i);
- break;
- }
- }
- //'推送时彭总给的key值',
- String pushUserKey = null;
- //'推送类型1单流程推送,2串联推送,3并联推送',
- Integer pushType = null;
- if (myUserTask != null) {
- pushUserKey = myUserTask.getCandidateGroups().get(0);
- }
- if (roleType == null) {
- if (pushUserKey != null) {
- if (listTask.size() > 1) {
- String[] s1 = pushUserKey.substring(0, pushUserKey.indexOf("-")).split("_");
- if (s1.length >= 5) { // 现在发现这个有问题,因为当前审核人的下个节点审核可能会跳节点,所以要找到下个审核人对应的节点才能判断推送类型,现在存的推送类型只是流程引擎中下个节点的推送类型,没有意义
- String pushTypeNum = s1[4];
- if ("1".equals(pushTypeNum)) {
- pushType = 1;
- } else if ("2".equals(pushTypeNum)) {
- pushType = 2;
- } else if ("3".equals(pushTypeNum)) {
- pushType = 3;
- }
- }
- } else {
- pushType = 2;
- }
- }
- } else {
- String[] roleTypeArray = roleType.split("_");
- String pushTypeNum = roleTypeArray[roleTypeArray.length - 1];
- if ("1".equals(pushTypeNum)) {
- pushType = 1;
- } else if ("2".equals(pushTypeNum)) {
- pushType = 2;
- } else if ("3".equals(pushTypeNum)) {
- pushType = 3;
- } else {
- pushType = 2;
- }
- }
- FlowMainPush flowMainPush = new FlowMainPush();
- flowMainPush.setFlowMainId(flowMain.getId());
- flowMainPush.setFormId(recordId);
- {// 需要工作流引擎的支持
- flowMainPush.setPushUser(task.getAssignee().split(",")[0]);//推送人id'
- flowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
- flowMainPush.setNodeName(myUserTask.getName());
- {
- // flowMainPush.setNodeUserRole(pushUserKey);
- // flowMainPush.setNodeName(myUserTask.getName());
- // 上面的方法进行修改 做一个方法替换原来的填写节点名称,目的是获取用户跳节点时对应的节点名称放在新的对象字段(node_user_role)中
- flowMainPush = this.setPushUserKeyAndNodeName(flowMainPush, task.getAssignee().split(",")[0], flowMain, roleType);
- }
- flowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
- flowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
- flowMainPush.setFlowType(constantFlowType);
- flowMainPush.setFlowPost(task.getAssignee());
- //2023年5月10日 修改成上面的了 张洮
- // flowMainPush.setFlowPost(currUser.getId());
- flowMainPush.setFlowId(processInstanceId);
- flowMainPush.setTaskId(task.getId());
- }
- flowMainPush.setUpMainLogId(flowMainLog.getId());
- flowMainPush.setUpdatedAt(new Date());
- flowMainPush.setCreatedAt(flowMainPush.getUpdatedAt());
- flowMainPush.setCreatedBy(currUser.getId());
- flowMainPush.setUpdatedBy(flowMainPush.getCreatedBy());
- flowMainPush.setGroupId(currUser.getGroupId());
- flowMainPush.setStatus(0);
- {//插入推送人前进行判断
- if (new Integer(1).equals(flowMainPush.getPushType())) {
- flowMainPushService.insert(flowMainPush);
- } else {
- String[] splitIds = task.getAssignee().split(",");
- for (int i = 0; i < splitIds.length; i++) {
- flowMainPush.setPushUser(splitIds[i]);
- flowMainPushService.insert(flowMainPush);
- }
- }
- }
- }
- }
- if (isEnd) {
- return AjaxResult.successData(1688, null);
- } else {
- return AjaxResult.success();
- }
- }
- //做一个方法替换原来的填写节点名称,目的是获取用户跳节点时对应的节点名称
- private FlowMainPush setPushUserKeyAndNodeName(FlowMainPush flowMainPush, String pushUserId, FlowMain flowMain, String roleType) {
- // flowMainPush.setNodeUserRole(pushUserKey);
- // flowMainPush.setNodeName(myUserTask.getName());
- if (roleType == null) {
- FrameUser frameUser = frameUserService.selectByPrimaryKey(pushUserId);
- boolean isCheck = false;//判断是否是出纳类型,如果是出纳类型就再查一下
- for (String s : ConstantFlowType.FLOW_ROLES_CHECK) {
- if (flowMainPush.getPushUserKey().startsWith(s)) {
- isCheck = true;
- break;
- }
- }
- if (isCheck) {
- flowMainPush.setNodeUserRole(flowMainPush.getPushUserKey());
- // 使用原来的设置 flowMainPush.setNodeName(myUserTask.getName());
- } else {
- String currRole = proActiService.getCurrRole(frameUser, flowMain);
- if (currRole == null || currRole.equals(ConstantFlowType.FLOW_ROLES_DEPT[0])) {//如果判断只是普通员工就还是设置成原来的(流程设置的)
- currRole = ConstantFlowType.FLOW_ROLES_DEPT[1];//flowMainPush.getPushUserKey();//ConstantFlowType.FLOW_ROLES_DEPT[1];
- }
- flowMainPush.setNodeUserRole(currRole);
- flowMainPush.setNodeName(ConstantFlowType.nodeKeys_Name.get(currRole));
- }
- } else {
- flowMainPush.setNodeUserRole(roleType);
- flowMainPush.setNodeName(ConstantFlowType.nodeKeys_Name.get(proActiService.getSetRurrRole(roleType)));
- }
- return flowMainPush;
- }
- /**
- * 申请人撤回申请
- *
- * @param flowMainid
- */
- public AjaxResult recallApply(String flowMainid) {
- if (com.rockstar.util.StringUtils.isEmpty(flowMainid)) {
- return AjaxResult.error("数据不能为空");
- }
- FlowMain flowMain = this.selectByPrimaryKey(flowMainid);
- //流转状态为审核中时,可以由发起人撤回。ok
- if (!flowMain.getFlowStatus().equals(1)) {
- return AjaxResult.error("流程状态不在审核中,请重新确认");
- }
- String mypushUserKey = null;
- {//开始申请人撤回申请
- //先搜索目前有哪些人在审核中 ,获取key
- // select * from flow_main_push WHERE flow_main_push.flow_main_id=#{flowMainId} and STATUS=0
- FlowMainPushExample example = new FlowMainPushExample();
- example.createCriteria().andFlowMainIdEqualTo(flowMain.getId()).andStatusEqualTo(0);
- List<FlowMainPush> flowMainPushes = flowMainPushService.selectByExample(example);
- mypushUserKey = flowMainPushes.get(0).getPushUserKey();
- //1.关闭所有推送人数据信息表 ok
- {
- flowMainPushService.updateStatusThreeByFlowMainId(ShiroUtils.getUser().getId(), flowMain.getId());
- }
- //2.关闭主流程 ok
- {// 发起流程引擎操作 并结束该流程
- try {
- flowService.deleteInstance(flowMain.getFlowId(), "申请人撤回申请_结束流程");
- } catch (Exception e) {
- System.err.println("流程引擎异常");
- e.printStackTrace();
- // throw new RuntimeException(e);
- }
- }
- //3.关闭主流程表 ok
- //存入流程日志表的id
- String flowMainLogUuid = UUIDUtils.middleUUID();
- {
- FlowMain flowMain1 = new FlowMain();
- flowMain1.setId(flowMain.getId());
- flowMain1.setFlowStatus(4);//申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)
- flowMain1.setLastMainLogId(flowMainLogUuid);
- flowMain1.setUpdatedAt(new Date());
- flowMain1.setUpdatedBy(ShiroUtils.getUser().getId());
- this.updateByPrimaryKeySelective(flowMain1);
- }
- //4 添加日志表
- FlowMainLog flowMainLog = new FlowMainLog();
- {//其表单对应的流转历史该节点审核结果显示为”发起人撤回”
- // flowMainLogUuid
- flowMainLog.setId(flowMainLogUuid);
- flowMainLog.setFlowMainId(flowMain.getId());
- flowMainLog.setFormId(flowMain.getFormId());
- flowMainLog.setAuditUser(ShiroUtils.getUser().getId());
- flowMainLog.setAuditContent(null);
- flowMainLog.setAuditResult(null);
- //审批类型(0流程开始状态还是1流程审核状态还是2流程结束状态还是3申请人暂停状态4申请人结束状态
- flowMainLog.setAuditType("4");
- flowMainLog.setFlowType(flowMain.getFlowType());
- flowMainLog.setFlowPost(ShiroUtils.getUser().getId());
- {// 需要工作流引擎的支持
- flowMainLog.setFlowId(flowMain.getFlowId());
- flowMainLog.setTaskId(null);
- flowMainLog.setNodeName("发起人撤回");
- flowMainLog.setPushUserKey(mypushUserKey);//发起人撤回时 当时的审核人所对应的角色
- }
- // 下一环节操作人(审核人/委托人/退回申请人),列表例如:,张三,李四,
- // 因为感觉用不到,暂时不放进去
- // flowMainLog.setNextPersons();
- flowMainLog.setUpMainLogId(flowMain.getLastMainLogId());
- flowMainLog.setCcList(null);
- flowMainLog.setCreatedAt(new Date());
- flowMainLog.setCreatedBy(ShiroUtils.getUser().getId());
- flowMainLog.setGroupId(ShiroUtils.getUser().getGroupId());
- flowMainLog.setStatus(0);
- flowMainLogService.insertWithoutId(flowMainLog);
- }
- }
- return AjaxResult.success();
- }
- /**
- * 分页查询
- *
- * @return
- */
- public PageInfo<FlowMain> list(Tablepar tablepar, FlowMain model, DateTrans dt) {
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<FlowMain> list = null;//modelMapper.selectByExample(getCondition(model,dt));
- PageInfo<FlowMain> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- public Object listAll(FlowMain model, DateTrans dt) {
- List<FlowMain> list = null;//modelMapper.selectByExample(getCondition(model,dt));
- return list;
- }
- @Override
- public int deleteByPrimaryKey(String ids) {
- List<String> lista = Convert.toListStrArray(ids);
- FlowMainExample example = new FlowMainExample();
- example.createCriteria().andIdIn(lista);
- return flowMainMapper.deleteByExample(example);
- }
- @Override
- public FlowMain selectByPrimaryKey(String id) {
- return flowMainMapper.selectByPrimaryKey(id);
- }
- @Override
- public int updateByPrimaryKeySelective(FlowMain record) {
- return flowMainMapper.updateByPrimaryKeySelective(record);
- }
- @Override
- public int updateByExampleSelective(FlowMain record, FlowMainExample example) {
- return flowMainMapper.updateByExampleSelective(record, example);
- }
- @Override
- public int updateByExample(FlowMain record, FlowMainExample example) {
- return flowMainMapper.updateByExample(record, example);
- }
- @Override
- public List<FlowMain> selectByExample(FlowMainExample example) {
- return flowMainMapper.selectByExample(example);
- }
- @Override
- public long countByExample(FlowMainExample example) {
- return flowMainMapper.countByExample(example);
- }
- @Override
- public int deleteByExample(FlowMainExample example) {
- return flowMainMapper.deleteByExample(example);
- }
- public int insert(FlowMain record) {
- record.setId(UUIDUtils.middleUUID());
- return insertWithoutId(record);
- }
- public int insertWithoutId(FlowMain record) {
- return flowMainMapper.insert(record);
- }
- @Override
- public int insertSelective(FlowMain record) {
- record.setId(UUIDUtils.middleUUID());
- record.setCreatedAt(new Date());
- return flowMainMapper.insertSelective(record);
- }
- public PageInfo<FlowMainIn> hasDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
- model.setAuditResult(new String[]{"1", "2", "3", "5"});
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<FlowMainIn> list = flowMainExtendMapper.listByInfo(model, dt);
- PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- public List<FrameRoleData> findFrameRoleDatasByUserId(String userId, String roleType) {
- return flowMainExtendMapper.findFrameRoleDatasByUserId(userId, roleType);
- }
- public List<FrameUser> findFrameUsersByRoleKey(String roleKey, String roleType) {
- List<FrameUser> frameUsersByRoleKey = null;
- try {
- // 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+"'");
- frameUsersByRoleKey = flowMainExtendMapper.findFrameUsersByRoleKey(roleKey, roleType);
- } catch (Exception e) {
- e.printStackTrace();
- frameUsersByRoleKey = new ArrayList<>();
- }
- return frameUsersByRoleKey;
- }
- public List<FrameUser> findFrameUsersByRoleKeyAndGroup(String roleKey, String roleType, String groupId) {
- List<FrameUser> frameUsersByRoleKey = null;
- try {
- frameUsersByRoleKey = flowMainExtendMapper.findFrameUsersByRoleKeyAndGroup(roleKey, roleType, groupId);
- } catch (Exception e) {
- e.printStackTrace();
- frameUsersByRoleKey = new ArrayList<>();
- }
- return frameUsersByRoleKey;
- }
- public PageInfo<FlowMainIn> myApplylistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<FlowMainIn> list = flowMainExtendMapper.myApplylistByInfo(model, dt);
- PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- /**
- * 抄送事项 ok
- * web端开始页面查询,不同类型, 流程名称,主题,发起人查询
- */
- public PageInfo<FlowMainIn> cclistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<FlowMainIn> list = flowMainExtendMapper.cclistByInfo(model, dt);
- PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- public PageInfo<FlowMainIn> myEntrustlistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
- model.setAuditResult(new String[]{"4"});
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<FlowMainIn> list = flowMainExtendMapper.listByInfo(model, dt);
- PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- /**
- * 待办事项
- *
- * @param tablepar
- * @param model
- * @param dt
- * @return
- */
- public PageInfo<FlowMainIn> toDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
- model.setAuditResult(new String[]{"1"});
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<FlowMainIn> list = flowMainExtendMapper.toDolistByInfo(model, dt);
- PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- /**
- * 委托代办事项
- *
- * @param tablepar
- * @param model
- * @param dt
- * @return
- */
- public PageInfo<FlowMainIn> entrustToDolistByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
- model.setAuditResult(new String[]{"2"});
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<FlowMainIn> list = flowMainExtendMapper.toDolistByInfo(model, dt);
- PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- public List<FlowHistoryInfo> getFlowHistroyByFlowMainId(String flowMainId) {
- return flowMainExtendMapper.getFlowHistroyByFlowMainId(flowMainId);
- }
- public Integer numtoDolistByInfo(FlowMainIn model, DateTrans dt) {
- model.setAuditResult(new String[]{"1"});
- return flowMainExtendMapper.numtoDolistByInfo(model, dt);
- }
- public PageInfo<FlowMainIn> toDolisAndEntrusttByInfo(Tablepar tablepar, FlowMainIn model, DateTrans dt) {
- model.setAuditResult(new String[]{"1", "2"});
- // model.setAuditResult(new String[]{"2"});
- PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
- List<FlowMainIn> list = flowMainExtendMapper.toDolistByInfo(model, dt);
- PageInfo<FlowMainIn> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- public Integer numtoDolisAndEntrusttByInfo(FlowMainIn model, DateTrans dt) {
- model.setAuditResult(new String[]{"1", "2"});
- return flowMainExtendMapper.numtoDolistByInfo(model, dt);
- }
- /**
- * 获取流程步骤(前端用) todo 新增流程要在这里加_步骤3
- *
- * @return
- */
- public String[] getFlowStep(FlowMain flowMain) {
- String[] flowStep = null;
- {
- if (flowMain.getFlowType().equals(ConstantFlowType.ADD_WORK)) {
- flowStep = ConstantFlowType.ADD_WORK_FLOWSTEPS;
- }else if (flowMain.getFlowType().equals(ConstantFlowType.PAYMENT)) {
- flowStep = ConstantFlowType.PAYMENT_FLOWSTEPS;
- }
- }
- return flowStep;
- }
- /**
- * 获取流程步骤(后端查询各个节点名称用),逻辑同上 todo 新增流程要在这里加_步骤2
- *
- * @param flowMain(就用了其中的getFlowType和getFormId方法)
- * @return
- */
- public String[] getOnlyFlowFlowStep(FlowMain flowMain) {
- String[] flowStep = null;
- {
- if (flowMain.getFlowType().equals(ConstantFlowType.ADD_WORK)) {
- flowStep = ConstantFlowType.onlyFlow_ADD_WORK_FLOWSTEPS;
- }else if (flowMain.getFlowType().equals(ConstantFlowType.PAYMENT)) {
- flowStep = ConstantFlowType.onlyFlow_PAYMENT_FLOWSTEPS;
- }
- }
- return flowStep;
- }
- /**
- * 获取全流程信息 todo 新增流程要在这里加_步骤1
- *
- * @param flowType
- * @return
- */
- public String[] getOnlylowStepAll(String flowType) {
- String[] flowStep = null;
- {
- if (flowType.equals(ConstantFlowType.ADD_WORK)) {
- flowStep = ConstantFlowType.onlyFlow_ADD_WORK_FLOWSTEPS_ALL;
- }else if (flowType.equals(ConstantFlowType.PAYMENT)) {
- flowStep = ConstantFlowType.onlyFlow_PAYMENT_FLOWSTEPS_ALL;
- }
- }
- return flowStep;
- }
- /**
- * 前端流程图使用查看各个流程节点目前的情况
- *
- * @param flowMainId
- * @return
- */
- public List<IMGFlowHistoryInfo> getIMGFlowHistroyByFlowMainId(String flowMainId) {
- FlowMain flowMain = flowMainMapper.selectByPrimaryKey(flowMainId);
- // 判断流程是哪种流程
- String[] flowStep = this.getFlowStep(flowMain);
- //获取返回值
- ArrayList<IMGFlowHistoryInfo> imgFlowHistoryInfos = new ArrayList<>();
- {//`flow_status` int(4) DEFAULT NULL COMMENT //'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
- if (flowMain.getFlowStatus().equals(1)) { //ok //需要找到最新推送人 //'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
- List<FlowMainPush> pushByFlowMainId = flowMainPushService.findPushByFlowMainId(flowMainId);
- String pushUserKey = pushByFlowMainId.get(0).getNodeUserRole();
- if (pushUserKey == null) {
- pushUserKey = pushByFlowMainId.get(0).getPushUserKey();
- }
- boolean isLastLogFind = false;//是否最后一个流程记录在节点中找到了,如果没有找到就在imgFlowHistoryInfos中插入一条信息
- for (int i = 0; i < flowStep.length; i++) {
- if (flowStep[i].startsWith(pushUserKey)) {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(flowStep[i]);
- imgFlowHistoryInfo.setType("3");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- imgFlowHistoryInfos.add(imgFlowHistoryInfo);
- isLastLogFind = true;
- break;
- } else {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(flowStep[i]);
- imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- imgFlowHistoryInfos.add(imgFlowHistoryInfo);
- }
- }
- if (!isLastLogFind) {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(pushUserKey);
- imgFlowHistoryInfo.setType("3");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- imgFlowHistoryInfos.add(imgFlowHistoryInfo);
- }
- // return imgFlowHistoryInfos;
- } else if (flowMain.getFlowStatus().equals(2)) {//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
- //需要找到最新操作日志
- FlowMainLog flowMainLog = flowMainLogService.selectLastOneByFlowMainId(flowMainId);
- if (flowMainLog == null) {
- return null;
- }
- String pushUserKey = flowMainLog.getPushUserKey();
- boolean isLastLogFind = false;//是否最后一个流程记录在节点中找到了,如果没有找到就在imgFlowHistoryInfos中插入一条信息
- for (int i = 0; i < flowStep.length; i++) {
- if (flowStep[i].startsWith(pushUserKey)) {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(flowStep[i]);
- imgFlowHistoryInfo.setType("2");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- imgFlowHistoryInfos.add(imgFlowHistoryInfo);
- isLastLogFind = true;
- break;
- } else {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(flowStep[i]);
- imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- imgFlowHistoryInfos.add(imgFlowHistoryInfo);
- }
- }
- if (!isLastLogFind) {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(pushUserKey);
- imgFlowHistoryInfo.setType("2");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- imgFlowHistoryInfos.add(imgFlowHistoryInfo);
- }
- // return imgFlowHistoryInfos;
- } else if (flowMain.getFlowStatus().equals(3)) {//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
- //需要找到最新操作日志
- FlowMainLog flowMainLog = flowMainLogService.selectLastOneByFlowMainId(flowMainId);
- if (flowMainLog == null) {
- return null;
- }
- String pushUserKey = flowMainLog.getPushUserKey();
- boolean isLastLogFind = false;//是否最后一个流程记录在节点中找到了,如果没有找到就在imgFlowHistoryInfos中插入一条信息
- for (int i = 0; i < flowStep.length; i++) {
- if (flowStep[i].startsWith(pushUserKey)) {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(flowStep[i]);
- if ("1".equals(flowMainLog.getAuditResult())) {//1,同意
- imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- imgFlowHistoryInfo.setIsPass("1");
- } else {
- imgFlowHistoryInfo.setType("6");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- }
- imgFlowHistoryInfos.add(imgFlowHistoryInfo);
- isLastLogFind = true;
- break;
- } else {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(flowStep[i]);
- imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- imgFlowHistoryInfos.add(imgFlowHistoryInfo);
- }
- }
- if (!isLastLogFind) {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(pushUserKey);
- if ("1".equals(flowMainLog.getAuditResult())) {//1,同意
- imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- imgFlowHistoryInfo.setIsPass("1");
- } else {
- imgFlowHistoryInfo.setType("6");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- }
- imgFlowHistoryInfos.add(imgFlowHistoryInfo);
- }
- // return imgFlowHistoryInfos;
- } else if (flowMain.getFlowStatus().equals(4)) {//'申请状态(1审批中,2,退回发起人,3,已结束,4已撤回)',
- //判断是监控室撤回还是自己撤回
- //需要找到最新操作日志
- FlowMainLog flowMainLog = flowMainLogService.selectLastOneByFlowMainId(flowMainId);
- if (flowMainLog == null) {
- return null;
- }
- String pushUserKey = flowMainLog.getPushUserKey();
- boolean isLastLogFind = false;//是否最后一个流程记录在节点中找到了,如果没有找到就在imgFlowHistoryInfos中插入一条信息
- for (int i = 0; i < flowStep.length; i++) {
- if (flowStep[i].startsWith(pushUserKey)) {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(flowStep[i]);
- if (flowMainLog.getAuditType().equals(5)) {
- //监控室撤回
- imgFlowHistoryInfo.setType("5");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- } else {
- imgFlowHistoryInfo.setType("4");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- }
- imgFlowHistoryInfos.add(imgFlowHistoryInfo);
- isLastLogFind = true;
- break;
- } else {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(flowStep[i]);
- imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- imgFlowHistoryInfos.add(imgFlowHistoryInfo);
- }
- }
- if (!isLastLogFind) {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(pushUserKey);
- if (flowMainLog.getAuditType().equals(5)) {
- //监控室撤回
- imgFlowHistoryInfo.setType("5");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- } else {
- imgFlowHistoryInfo.setType("4");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- }
- imgFlowHistoryInfos.add(imgFlowHistoryInfo);
- }
- // return imgFlowHistoryInfos;
- }
- }
- {//查询操作记录,将操作过的设置isjump为false,默认isjump为true
- List<FlowMainLog> flowMainLogs = flowMainLogService.selectPassListByFlowMainId(flowMainId);
- for (int i = 0; i < imgFlowHistoryInfos.size(); i++) {
- IMGFlowHistoryInfo imgFlowHistoryInfo = imgFlowHistoryInfos.get(i);
- if (i == 0) {
- imgFlowHistoryInfo.setJump(false);
- } else if (i == (imgFlowHistoryInfos.size() - 1)) {
- imgFlowHistoryInfo.setJump(false);
- } else {
- for (FlowMainLog flowMainLog : flowMainLogs) {
- // FlowMainLog flowMainLog
- if (flowMainLog.getPushUserKey().startsWith(imgFlowHistoryInfo.getNodeKey())) {
- imgFlowHistoryInfo.setJump(false);
- break;
- }
- }
- }
- }
- }
- return imgFlowHistoryInfos;
- }
- /**
- * 进行串并联申请,将id合并起来,用逗号,隔开
- *
- * @return
- */
- public FrameUser getFrameUsersId(String roleType, List<FrameUser> targetUserList, FrameUser targetUser) {
- String[] roleTypeArray = roleType.split("_");
- String key_e = roleTypeArray[roleTypeArray.length - 1];
- if ("1".equals(key_e)) {//1 单流程推送 2 串联审核 3 并联推送
- } else {
- String ids = "";
- for (FrameUser frameUser : targetUserList) {
- ids += ("," + frameUser.getId());
- }
- targetUser.setId(ids.substring(1));
- }
- return targetUser;
- }
- /**
- * 查询领导的全流程查看对应的目标用户,如果未来有需求可以将出纳等财务的角色也放进去
- * //要进行从本角色(部门已经查过了,就是从领导角色开始查)开始的本流程的全角色查询
- * 还有查全流程如果是会签就要改成并签了,因为之前支线流程里面没有找到对应节点
- *
- * @param flowMain
- * @param flowRole
- * @return
- */
- public TagerUserAndFlowRole getAllUpRoleTargetUsers(FlowMain flowMain, String flowRole) {
- String[] flowStep = this.getOnlylowStepAll(flowMain.getFlowType());
- return this.getAllUpRoleTargetUsers_getUpRoleTargetUsers(flowStep, flowMain, flowRole, true);
- }
- /**
- * 合并两个方法
- * isNeed3To2:是否需要并签改串签
- *
- * @return
- */
- public TagerUserAndFlowRole getAllUpRoleTargetUsers_getUpRoleTargetUsers(String[] flowStep, FlowMain flowMain, String flowRole, boolean isNeed3To2) {
- TagerUserAndFlowRole tagerUserAndFlowRole = new TagerUserAndFlowRole();
- String targetRole = null;//找目标用户的角色
- FrameUser targetUser = null;//目标人
- int i = 0;
- boolean isFindStartRole = false;
- for (; i < flowStep.length; i++) {
- if (!isFindStartRole) {
- if (flowStep[i].startsWith(flowRole)) {
- isFindStartRole = true;
- targetRole = flowStep[i]; //例如 flow_fgld_1_0_1
- String shortTargetRole = proActiService.getSetRurrRole(targetRole); //例如 flow_fgld
- {//查看谁是对应角色并查找对应的人
- for (int j = 0; j < ConstantFlowType.FLOW_ROLES.length; j++) {
- if (ConstantFlowType.FLOW_ROLES[j].equals(shortTargetRole)) {//1.1.2如果是领导关系的查领导
- //查看谁是对应角色并查找对应的人
- String role = ConstantFlowType.ROLES[j]; //例如 fgld
- // 进行查询目标人
- List<FrameUser> targetUserList = this.findFrameUsersByRoleKeyAndGroup(
- role, ConstantFlowType.ROLETYPE, flowMain.getGroupId());
- if (!targetUserList.isEmpty() && targetUserList.size() >= 1) {
- targetUser = targetUserList.get(0);
- //进行串并联申请
- {
- targetUser = this.getFrameUsersId(targetRole, targetUserList, targetUser);
- }
- }
- break;
- }
- }
- if (targetUser == null) {
- //进行下个角色查询
- } else {
- tagerUserAndFlowRole.setFrameUser(targetUser);
- if (isNeed3To2) {//是否需要并签改串签
- String[] roleTypeArray = targetRole.split("_");
- String key_e = roleTypeArray[roleTypeArray.length - 1];
- if ("3".equals(key_e)) {//1 单流程推送 2 串联审核 3 并联推送
- targetRole = targetRole.substring(0, targetRole.length() - 1) + "2";
- }
- }
- tagerUserAndFlowRole.setFlowRole(targetRole);
- tagerUserAndFlowRole.setOnlyFlowFlowStep(flowStep);
- return tagerUserAndFlowRole;
- }
- }
- }
- } else {
- targetRole = flowStep[i]; //例如 flow_fgld_1_0_1
- String shortTargetRole = proActiService.getSetRurrRole(targetRole); //例如 flow_fgld
- {//查看谁是对应角色并查找对应的人
- for (int j = 0; j < ConstantFlowType.FLOW_ROLES.length; j++) {
- if (ConstantFlowType.FLOW_ROLES[j].equals(shortTargetRole)) {//1.1.2如果是领导关系的查领导
- //查看谁是对应角色并查找对应的人
- String role = ConstantFlowType.ROLES[j]; //例如 fgld
- // 进行查询目标人
- List<FrameUser> targetUserList = this.findFrameUsersByRoleKeyAndGroup(
- role, ConstantFlowType.ROLETYPE, flowMain.getGroupId());
- if (!targetUserList.isEmpty() && targetUserList.size() >= 1) {
- targetUser = targetUserList.get(0);
- //进行串并联申请
- {
- targetUser = this.getFrameUsersId(targetRole, targetUserList, targetUser);
- }
- }
- break;
- }
- }
- if (targetUser == null) {
- //进行下个角色查询
- } else {
- tagerUserAndFlowRole.setFrameUser(targetUser);
- if (isNeed3To2) {//是否需要并签改串签
- String[] roleTypeArray = targetRole.split("_");
- String key_e = roleTypeArray[roleTypeArray.length - 1];
- if ("3".equals(key_e)) {//1 单流程推送 2 串联审核 3 并联推送
- targetRole = targetRole.substring(0, targetRole.length() - 1) + "2";
- }
- }
- tagerUserAndFlowRole.setFlowRole(targetRole);
- tagerUserAndFlowRole.setOnlyFlowFlowStep(flowStep);
- return tagerUserAndFlowRole;
- }
- }
- }
- }
- if (targetRole == null) {
- return tagerUserAndFlowRole;
- } else {
- return tagerUserAndFlowRole;
- }
- }
- /**
- * 根据传入的步骤进行查询(注意,有可能有出纳等财务角色,目前会剔除,默认出纳等财务必须有)
- * //查询对应设置角色开始的角色
- *
- * @param flowRole
- * @param onlyFlowFlowStep
- * @return
- */
- public TagerUserAndFlowRole getUpRoleTargetUsers(FlowMain flowMain, String flowRole, String[] onlyFlowFlowStep) {
- String[] flowStep = onlyFlowFlowStep;
- return this.getAllUpRoleTargetUsers_getUpRoleTargetUsers(flowStep, flowMain, flowRole, false);
- }
- }
|