1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068 |
- 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.service.ApplyOffWorkTimeService;
- //import com.idea.oa.apply.service.ApplyUseMoneyDetailService;
- 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.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 ApplyOffWorkTimeService applyOffWorkTimeService;
- // @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.getPushUserKey();
- // flowMain.
- // Map<String, Object> conditionMap
- //审核通过,转下一步
- boolean isEnd = false;//是否审核到最后一步了
- if (addConfirmResult.getConfirmResult().equals("1")) {//审核通过 ok
- {// 发起流程引擎操作 并查看下一节点的操作要求
- //1.如果当前角色是自己,就进行正常的审核流程
- //2.先查看当前角色是不是自己,不是自己就移动到自己的角色,然后再进行正常的审核流程
- Map<String, String> stringStringMap = proActiService.passToRunTask(flowMainPush, deploymentid, flowMainPush.getFlowMainId(), conditionMap);
- if (stringStringMap == null) {
- return "流程引擎开启失败,请查看原因!";
- }
- isEnd = stringStringMap.get("isEnd") == null ? false : true;
- }
- {
- //存入流程日志表的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 (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.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("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) || pushType.equals(2)) {
- //只要逻辑删除本推送
- } else if (pushType.equals(3)) {
- //要逻辑删除自己和其他推送
- //将其他并联推送的人员推送状态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")) {//退回上节点
- 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) || pushType.equals(2)) {
- //只要逻辑删除本推送
- } else if (pushType.equals(3)) {
- //要逻辑删除自己和其他推送
- //将其他并联推送的人员推送状态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) throws com.rockstar.flow.exception.FlowException {
- // 存入流程主表 ok
- FlowMain flowMain = new FlowMain();
- flowMain.setId(UUIDUtils.middleUUID());
- // 进入流程引擎,开始启动流程
- String processInstanceId = null;
- // 判断启动申请后是否结束
- boolean isEnd = false;
- {
- //启动流程引擎
- Map<String, String> stringStringMap = proActiService.startTask(processdefine, deploymentid, flowMain.getId(),currUser, conditionMap);
- if (stringStringMap == null) {
- return AjaxResult.error("流程引擎开启失败,请查看原因!");
- }
- processInstanceId = stringStringMap.get("processInstanceId");
- if (stringStringMap.get("isEnd") != null) {
- isEnd = true;
- }
- }
- //存入流程日志表的id
- String flowMainLogUuid = UUIDUtils.middleUUID();
- {
- // conditionMap
- // if (conditionMap!=null) {
- // Object conditionMapString = JSONObject.toJSON(conditionMap);
- // flowMain.setConditionMap(conditionMapString.toString());
- // }
- // 关于@客户名称@项目名称@供应商名称@付款名称的付款申请单
- flowMain.setApplyTheme(ApplyTheme);
- flowMain.setFormId(recordId);
- flowMain.setApplyUser(currUser.getId());
- flowMain.setDeptId(currUser.getDepartment());
- //todo 判断是否结束
- 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);
- flowMain.setFlowType(constantFlowType);
- //当前流程邮递操作人(frame_user)id 去除岗位的设定
- flowMain.setFlowPost(currUser.getId());
- {// 需要工作流引擎的支持
- flowMain.setFlowId(processInstanceId);
- flowMain.setTaskId(null);
- }
- flowMain.setLastMainLogId(flowMainLogUuid);
- flowMain.setUpdatedAt(new Date());
- flowMain.setCreatedAt(flowMain.getUpdatedAt());
- flowMain.setCreatedBy(currUser.getId());
- flowMain.setUpdatedBy(flowMain.getCreatedBy());
- flowMain.setGroupId(currUser.getGroupId());
- flowMain.setStatus(0);
- if (!StringUtils.isEmpty(recordRemark)) {
- flowMain.setRemark(recordRemark);
- }
- this.insertWithoutId(flowMain);
- }
- // 存入流程日志表 ok
- FlowMainLog flowMainLog = new FlowMainLog();
- {
- flowMainLog.setId(flowMainLogUuid);
- flowMainLog.setFlowMainId(flowMain.getId());
- flowMainLog.setFormId(recordId);
- flowMainLog.setAuditUser(currUser.getId());
- //todo 判断是否结束
- 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 (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 flowMainPush = new FlowMainPush();
- flowMainPush.setFlowMainId(flowMain.getId());
- flowMainPush.setFormId(recordId);
- {// 需要工作流引擎的支持
- flowMainPush.setPushUser(task.getAssignee());//推送人id'
- flowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
- flowMainPush.setNodeName(myUserTask.getName());
- 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);
- flowMainPushService.insert(flowMainPush);
- }
- }
- if (isEnd) {
- return AjaxResult.successData(1688, null);
- } else {
- return AjaxResult.success();
- }
- }
- /**
- * 申请人撤回申请
- *
- * @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);
- }
- public List<IMGFlowHistoryInfo> getIMGFlowHistroyByFlowMainId(String flowMainId) {
- FlowMain flowMain = flowMainMapper.selectByPrimaryKey(flowMainId);
- // 判断流程是哪种流程
- String[] flowStep = null;
- {
- if (flowMain.getFlowType().equals(ConstantFlowType.PAYMENT)) {
- flowStep = ConstantFlowType.PAYMENT_FLOWSTEPS;
- }
- }
- //获取返回值
- 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).getPushUserKey();
- 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);
- break;
- } else {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(flowStep[i]);
- imgFlowHistoryInfo.setType("1");// 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();
- 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);
- break;
- } else {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(flowStep[i]);
- imgFlowHistoryInfo.setType("1");// 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();
- 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);
- } else {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(flowStep[i]);
- imgFlowHistoryInfo.setType("1");// 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();
- 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);
- break;
- } else {
- IMGFlowHistoryInfo imgFlowHistoryInfo = new IMGFlowHistoryInfo();
- imgFlowHistoryInfo.setNodeKey(flowStep[i]);
- imgFlowHistoryInfo.setType("1");// 1 审核通过,2退回,3审核中,4申请人撤回,5,监控室撤回,6审核不同意,结束流程
- imgFlowHistoryInfos.add(imgFlowHistoryInfo);
- }
- }
- return imgFlowHistoryInfos;
- }
- }
- return null;
- }
- public AjaxResult doFlowMainForPurchase(String ApplyTheme, String recordId, String recordRemark,
- String recordCcList, String processdefine, String deploymentid,
- Map<String, Object> conditionMap, String constantFlowTypeNAME,
- String constantFlowType,FrameUser currUser)
- throws com.rockstar.flow.exception.FlowException {
- // 存入流程主表 ok
- FlowMain flowMain = new FlowMain();
- flowMain.setId(UUIDUtils.middleUUID());
- String processInstanceId = null;
- // 判断申请人是否是主要领导,是的话直接通过,不启动流程,保存相关信息
- boolean isEnd = false;
- List<FrameRoleData> frameRoleDataList = findFrameRoleDatasByUserId(currUser.getId(), ConstantFlowType.ROLETYPE);
- for (FrameRoleData data : frameRoleDataList) {
- if(data.getRoleKey().equals("zyld")){
- isEnd = true;
- }
- }
- // 进入流程引擎,开始启动流程
- if(!isEnd) {
- //启动流程引擎
- Map<String, String> stringStringMap = proActiService.startPurchaseTask(processdefine, deploymentid,
- flowMain.getId(),currUser, conditionMap);
- if (stringStringMap == null) {
- return AjaxResult.error("流程引擎开启失败,请查看原因!");
- }
- processInstanceId = stringStringMap.get("processInstanceId");
- if (stringStringMap.get("isEnd") != null) {
- isEnd = true;
- }
- }
- //存入流程日志表的id
- String flowMainLogUuid = UUIDUtils.middleUUID();
- {
- flowMain.setApplyTheme(ApplyTheme);
- flowMain.setFormId(recordId);
- flowMain.setApplyUser(currUser.getId());
- flowMain.setDeptId(currUser.getDepartment());
- 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);
- flowMain.setFlowType(constantFlowType);
- //当前流程邮递操作人(frame_user)id 去除岗位的设定
- flowMain.setFlowPost(currUser.getId());
- {// 需要工作流引擎的支持
- flowMain.setFlowId(processInstanceId);
- flowMain.setTaskId(null);
- }
- flowMain.setLastMainLogId(flowMainLogUuid);
- flowMain.setUpdatedAt(new Date());
- flowMain.setCreatedAt(flowMain.getUpdatedAt());
- flowMain.setCreatedBy(currUser.getId());
- flowMain.setUpdatedBy(flowMain.getCreatedBy());
- flowMain.setGroupId(currUser.getGroupId());
- flowMain.setStatus(0);
- if (!StringUtils.isEmpty(recordRemark)) {
- flowMain.setRemark(recordRemark);
- }
- 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 (UserTask userTask : TaskList) {
- if (userTask.getId().equals(taskDefinitionKey)) {
- myUserTask = userTask;
- break;
- }
- }
- //'推送时彭总给的key值',
- String pushUserKey = null;
- //'推送类型1单流程推送,2串联推送,3并联推送',
- Integer pushType = null;
- 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 flowMainPush = new FlowMainPush();
- flowMainPush.setFlowMainId(flowMain.getId());
- flowMainPush.setFormId(recordId);
- {// 需要工作流引擎的支持
- flowMainPush.setPushUser(task.getAssignee());//推送人id'
- flowMainPush.setPushUserKey(pushUserKey);//推送时彭总给的key值
- flowMainPush.setNodeName(null!=myUserTask?myUserTask.getName():null);
- flowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
- flowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
- flowMainPush.setFlowType(constantFlowType);
- flowMainPush.setFlowPost(task.getAssignee());
- 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);
- flowMainPushService.insert(flowMainPush);
- }
- }
- if (isEnd) {
- return AjaxResult.successData(1688, null);
- } else {
- return AjaxResult.success();
- }
- }
- public String doConfirmResultForPurchase(AddConfirmResult addConfirmResult, String deploymentid,
- String constantFlowType, FlowMainPush flowMainPush,
- HashMap<String, Object> conditionMap)
- throws com.rockstar.flow.exception.FlowException {
- if (addConfirmResult.getConfirmResult() == null) {
- return "没有获取到confirmResult值";
- }
- OperaterManage operaterManage = new OperaterManage();
- FrameUser frameUser = new FrameUser();
- try {
- frameUser.setId(ShiroUtils.getUser().getId());
- } catch (Exception e) {
- frameUser.setId(addConfirmResult.getOperaterId());
- }
- operaterManage.setUser(frameUser);
- 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.getPushUserKey();
- //审核通过,转下一步
- boolean isEnd = false;//是否审核到最后一步了
- if (addConfirmResult.getConfirmResult().equals("1")) {//审核通过 ok
- {// 发起流程引擎操作 并查看下一节点的操作要求
- Map<String, String> stringStringMap = proActiService.passToRunPurchaseTask(flowMainPush, deploymentid,
- flowMainPush.getFlowMainId(), conditionMap);
- if (stringStringMap == null) {
- return "流程引擎开启失败,请查看原因!";
- }
- isEnd = stringStringMap.get("isEnd") != null;
- }
- {
- //存入流程日志表的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.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();
- 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();
- //查看总的数据流程
- 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 (UserTask userTask : TaskList) {
- if (userTask.getId().equals(taskDefinitionKey)) {
- myUserTask = userTask;
- break;
- }
- }
- //判断是否存在串并联并修改推送状态
- 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.setNodeName(myUserTask.getName());
- newflowMainPush.setPushType(pushType);//推送类型1单流程推送,2串联推送,3并联推送
- newflowMainPush.setPushRole(1);//'推送人身份:1本人审核,2被委托人(代理审核人审核权限)',
- newflowMainPush.setFlowType(constantFlowType);
- newflowMainPush.setFlowPost(task.getAssignee());
- 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("2")) {//退回发起人 ok
- {// 退回发起人
- isEnd = true;
- //当前审核人/委托人代表的用户id
- String myFrameUserId = proActiService.getMyFrameUserId(flowMainPush);
- if (myFrameUserId == null) {
- return null;
- }
- //当前审核人/委托人代表的用户
- FrameUser myFrameUser = frameUserService.selectByPrimaryKey(myFrameUserId);
- FrameUser targetUser = frameUserService.selectByPrimaryKey(flowMain.getApplyUser());
- 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.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();
- if (pushType.equals(3)) {
- //要逻辑删除自己和其他推送
- //将其他并联推送的人员推送状态status改成2状态值
- flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
- }
- }
- }
- } else if (addConfirmResult.getConfirmResult().equals("3")) {//退回上节点
- 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());
- 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.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();
- //逻辑删除本推送
- {
- flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
- }
- }
- //4添加新的推送人员
- {//查看各个任务
- 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 (UserTask userTask : TaskList) {
- if (userTask.getId().equals(taskDefinitionKey)) {
- myUserTask = userTask;
- break;
- }
- }
- //判断是否存在串并联并修改推送状态
- //'推送时彭总给的key值',
- String pushUserKey = null;
- if (myUserTask != null) {
- pushUserKey = myUserTask.getCandidateGroups().get(0);
- }
- //'推送类型1单流程推送,2串联推送,3并联推送',
- Integer 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());
- 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.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();
- if (pushType.equals(3)) {
- //要逻辑删除自己和其他推送
- //将其他并联推送的人员推送状态status改成2状态值
- flowMainPushService.updateStatusTwoByUpMainLogId(operaterManage.getUser().getId(), flowMainPush.getUpMainLogId(), flowMainPush.getId());
- }
- }
- }
- }
- if (isEnd) {
- return "ok_end";
- } else {
- return "ok_noEnd";
- }
- }
- }
|