/// <summary> /// 添加报修表单 /// </summary> /// <param name="repairAddViewModel"></param> /// <returns>返回主键id</returns> public WorkFlowFistReturnIdList Repair_Add(RepairAddViewModel repairAddViewModel, int Flow_ProcedureDefineId) { //存入表单信息 var repair_Info = _IMapper.Map <RepairAddViewModel, Repair_Info>(repairAddViewModel); _IRepairInfoRepository.Add(repair_Info); _IRepairInfoRepository.SaveChanges(); //存入流程信息(只有在开始节点的时候才会存入一条数据) var flowProcedureAddViewModel = _IMapper.Map <Repair_Info, FlowProcedureAddViewModel>(repair_Info); var procedure_Info = _IMapper.Map <FlowProcedureAddViewModel, Flow_Procedure>(flowProcedureAddViewModel); procedure_Info.remark = "1";//流程开始 _IFlowProcedureInfoRepository.Add(procedure_Info); _IFlowProcedureInfoRepository.SaveChanges(); //通过流程定义Id去查开始节点的主键id var ProcedureDefine = _IFlowNodeDefineInfoRepository.GetInfoByProcedureDefineId(Flow_ProcedureDefineId); int FirstNodeId = ProcedureDefine.Id; //返回三个Id WorkFlowFistReturnIdList workFlowFistReturnIdList = new WorkFlowFistReturnIdList(); workFlowFistReturnIdList.Repair_InfoId = repair_Info.id; //表单主键Id workFlowFistReturnIdList.RepairType = repair_Info.RepairsType; //填写的类型与角色类相对应 workFlowFistReturnIdList.User_InfoId = repair_Info.User_InfoId; //填写表单的用户Id workFlowFistReturnIdList.Flow_ProcedureId = procedure_Info.Id; //流程Id workFlowFistReturnIdList.Flow_NodeDefineId = FirstNodeId; //该流程第一个节点Id return(workFlowFistReturnIdList); }
public ActionResult <RepairAddResModel> Manage_Repair_Add(RepairAddViewModel repairAddViewModel) { WorkFlowFistReturnIdList workFlowFistReturnIdList = new WorkFlowFistReturnIdList(); workFlowFistReturnIdList = _IRepairService.Repair_Add(repairAddViewModel, repairAddViewModel.Flow_ProcedureDefineId); RepairAddResModel repairAddResModel = new RepairAddResModel(); if (workFlowFistReturnIdList != null) { repairAddResModel.IsSuccess = true; repairAddResModel.workFlowFistReturnIdList = workFlowFistReturnIdList; repairAddResModel.baseViewModel.Message = "添加成功"; repairAddResModel.baseViewModel.ResponseCode = 200; _ILogger.Information("增添报修信息成功"); return(Ok(repairAddResModel)); } else { repairAddResModel.IsSuccess = false; repairAddResModel.workFlowFistReturnIdList = null; repairAddResModel.baseViewModel.Message = "添加失败"; repairAddResModel.baseViewModel.ResponseCode = 400; _ILogger.Information("增添报修信息失败"); return(Ok(repairAddResModel)); } }