using System; using System.Collections.Generic; using System.Web; using System.Data; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.Linq; using FangYar.BLL.OA; using FangYar.IDAL; using NPOI.SS.Formula.Functions; using FangYar.BLL; using FangYar.BLL.FIRE; using System.Collections; using System.Text; using System.Threading.Tasks; using System.Drawing; using System.IO; using System.Text.RegularExpressions; using static FangYar.WebUI.ashx.FaceStatisticsHandler; namespace FangYar.WebUI.ashx { /// /// AppHandler 的摘要说明 /// public class AppHandler : IHttpHandler { private RoadFlow.Platform.WorkFlowTask bworkFlowTask = new RoadFlow.Platform.WorkFlowTask(); private RoadFlow.Platform.WorkFlow bworkFlow = new RoadFlow.Platform.WorkFlow(); private RoadFlow.Platform.WorkFlowButtons bworkFlowButtons = new RoadFlow.Platform.WorkFlowButtons(); private RoadFlow.Platform.AppLibrary bappLibrary = new RoadFlow.Platform.AppLibrary(); private RoadFlow.Platform.Organize borganize = new RoadFlow.Platform.Organize(); #region ProcessRequest public void ProcessRequest(HttpContext context) { // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP操作请求", ""); context.Response.ContentType = "text/plain"; string action = context.Request.Params["Action"]; string returnstr = ""; switch (action) { case "AppGetTaskWaitListByUid": returnstr = AppGetTaskWaitListByUid(context); break; case "AppGetTaskProcessedListByUid": returnstr = AppGetTaskProcessedListByUid(context); break; case "AppLeaveTaskApply": returnstr = AppLeaveTaskApply(context); break; case "AppGetTaskWaitLeaveItem": returnstr = AppGetTaskWaitLeaveItem(context); break; case "AppToleranceTaskApply": returnstr = AppToleranceTaskApply(context); break; case "AppGetTaskWaitToleranceItem": returnstr = AppGetTaskWaitToleranceItem(context); break; case "AppCarTaskApply": returnstr = AppCarTaskApply(context); break; case "AppGetTaskWaitCarItem": returnstr = AppGetTaskWaitCarItem(context); break; case "AppLeaveTaskHandle": returnstr = AppLeaveTaskHandle(context); break; case "AppToleranceTaskHandle": returnstr = AppToleranceTaskHandle(context); break; case "AppCarTaskHandle": returnstr = AppCarTaskHandle(context); break; case "AppGetOrgDeptEmpTreeByOrgId": returnstr = AppGetOrgDeptEmpTreeByOrgId(context); break; case "AppGetCorrelationCampOrgDeptEmpTreeByOrgId": returnstr = AppGetCorrelationCampOrgDeptEmpTreeByOrgId(context); break; case "AppGetEmpListByTags": returnstr = AppGetEmpListByTags(context); break; case "AppGetOrgDeptCarTreeByOrgId": returnstr = AppGetOrgDeptCarTreeByOrgId(context); break; case "AppGetOrgDeptCarTreeByOrgId2": returnstr = AppGetOrgDeptCarTreeByOrgId2(context); break; case "AppGetLeaveTypeList": returnstr = AppGetLeaveTypeList(context); break; case "AppGetToleranceTypeList": returnstr = AppGetToleranceTypeList(context); break; case "AppGetAlarmEmpListByOrgId": returnstr = AppGetAlarmEmpListByOrgId(context); break; case "AppGetAlarmEmpListByOrgIdApprovalState": returnstr = AppGetAlarmEmpListByOrgIdApprovalState(context); break; case "AppUpdateAlarmEmpStateByOrgId": returnstr = AppUpdateAlarmEmpStateByOrgId(context); break; case "AppGetAlarmCarListByOrgId": returnstr = AppGetAlarmCarListByOrgId(context); break; case "AppGetVisitorRegListByUid": returnstr = AppGetVisitorRegListByUid(context); break; case "AppVisitorRegHandle": returnstr = AppVisitorRegHandle(context); break; case "AppGetLeaveListByUid": returnstr = AppGetLeaveListByUid(context); break; case "AppGetLeaveModelByLeaveId": returnstr = AppGetLeaveModelByLeaveId(context); break; case "AppGetToleranceListByUid": returnstr = AppGetToleranceListByUid(context); break; case "AppGetToleranceModelByToleranceId": returnstr = AppGetToleranceModelByToleranceId(context); break; case "AppGetCarApplyListByUid": returnstr = AppGetCarApplyListByUid(context); break; case "AppGetCarApplyListByOrgId": returnstr = AppGetCarApplyListByOrgId(context); break; case "AppDeleteCarApplyById": returnstr = AppDeleteCarApplyById(context); break; case "AppGetCarApplyModelByCarApplyId": returnstr = AppGetCarApplyModelByCarApplyId(context); break; case "AppGetVisitorWeekByOrgId": returnstr = AppGetVisitorWeekByOrgId(context); break; case "AppGetPerAccWeekByOrgId": returnstr = AppGetPerAccWeekByOrgId(context); break; case "AppGetCarAccWeekByOrgId": returnstr = AppGetCarAccWeekByOrgId(context); break; case "AppGetCarNumListByOrgId": returnstr = AppGetCarNumListByOrgId(context); break; //岗哨交接 case "AppGetShiftsListByOrgId": returnstr = AppGetShiftsListByOrgId(context); break; case "AppGetShiftsListByUserUid": returnstr = AppGetShiftsListByUserUid(context); break; case "AppGetShiftsHistoryListByOrgId": returnstr = AppGetShiftsHistoryListByOrgId(context); break; case "AppGetShiftsIsDutyByIFID": returnstr = AppGetShiftsIsDutyByIFID(context); break; case "AppUpdateShiftsByID": returnstr = AppUpdateShiftsByID(context); break; case "AppUpdateShiftsOverdueByID": returnstr = AppUpdateShiftsOverdueByID(context); break; case "AppGetOrgListByOrgId": returnstr = AppGetOrgListByOrgId(context); break; case "AppGetAlarmDataListByOrgId": returnstr = AppGetAlarmDataListByOrgId(context); break; case "AppGetOaPatrolSpotListByOrgId": returnstr = AppGetOaPatrolSpotListByOrgId(context); break; case "AppGetOaPatrolSpotModelById": returnstr = AppGetOaPatrolSpotModelById(context); break; case "AppGetOaPatrolSpotModelByRFID": returnstr = AppGetOaPatrolSpotModelByRFID(context); break; case "AppAddOaPatrolSpotModel": returnstr = AppAddOaPatrolSpotModel(context); break; case "AppEditOaPatrolSpotModel": returnstr = AppEditOaPatrolSpotModel(context); break; case "AppGetFireEpuipListByOrgId": returnstr = AppGetFireEpuipListByOrgId(context); break; case "AppAddFireEpuipModel": returnstr = AppAddFireEpuipModel(context); break; //提示角标接口 case "AppGetTaskWaitCountByUid"://获取待办数 returnstr = AppGetTaskWaitCountByUid(context); break; case "AppGetVisitorApplySuperscript"://访客审批 returnstr = AppGetVisitorApplySuperscript(context); break; case "AppGetProjectPatrolSuperscript"://计划巡查 returnstr = AppGetProjectPatrolSuperscript(context); break; case "AppGetRectifySecurityThreatSuperscript"://隐患整改 returnstr = AppGetRectifySecurityThreatSuperscript(context); break; case "AppGetSentryAndRestInspectSuperscript": returnstr = AppGetSentryAndRestInspectSuperscript(context);//查铺查哨 break; case "AppGetBeOnSentrySuperscript": returnstr = AppGetBeOnSentrySuperscript(context);//上哨任务 break; case "AppGetOrgTree": returnstr = AppGetOrgTree(context);//获取本机和下级单位 break; //战训功能接口 case "AppGetTrainTaskListByOrgId": returnstr = AppGetTrainTaskListByOrgId(context); break; case "AppGetTrainTaskListByUserUid": returnstr = AppGetTrainTaskListByUserUid(context); break; case "AppGetTrainParticipateTaskListByUserUid": returnstr = AppGetTrainParticipateTaskListByUserUid(context); break; case "AppGetSubjectScoreByTask": returnstr = AppGetSubjectScoreByTask(context); break; case "AppAddTrainReportScore": returnstr = AppAddTrainReportScore(context); break; case "AppGetTrainSubject": returnstr = AppGetTrainSubject(context); break; case "AppGetTrainScoreBySubjectid": returnstr = AppGetTrainScoreBySubjectid(context); break; case "AppGetTrainScoreListByTaskID": returnstr = AppGetTrainScoreListByTaskID(context); break; case "AppGetTrainRedBlackListByOrgId": returnstr = AppGetTrainRedBlackListByOrgId(context); break; case "AppGetTrainStandardListBySubjectId": returnstr = AppGetTrainStandardListBySubjectId(context); break; case "AppGetTrainSubjectModelBySubjectId": returnstr = AppGetTrainSubjectModelBySubjectId(context); break; case "AppGetTrainHistoryScoreListByUserUid": returnstr = AppGetTrainHistoryScoreListByUserUid(context); break; case "AppGetTrainBestScoreByUserUid": returnstr = AppGetTrainBestScoreByUserUid(context); break; case "AppGetTrainTimeScoreSubjectByUid": returnstr = AppGetTrainTimeScoreSubjectByUid(context); break; case "AppGetTrainTimeScoreBySubjectId": returnstr = AppGetTrainTimeScoreBySubjectId(context); break; case "AppGetTrainKnowDicListByMod": returnstr = AppGetTrainKnowDicListByMod(context); break; case "AppGetTrainKnowListByOrgId": returnstr = AppGetTrainKnowListByOrgId(context); break; case "AppGetTrainKnowModelByKnowId": returnstr = AppGetTrainKnowModelByKnowId(context); break; case "AppGetPerPhoneListByOrgId": returnstr = AppGetPerPhoneListByOrgId(context); break; case "AppGetShiftsOnDutyByRFID": returnstr = AppGetShiftsOnDutyByRFID(context); break; case "AppUpdateShiftsDutyByID": returnstr = AppUpdateShiftsDutyByID(context); break; case "AppLeaveTaskApplyMoreStep"://请假申请-多分支多级机构 returnstr = AppLeaveTaskApplyMoreStep(context); break; case "AppCarTaskApplyMoreStep"://用车申请-多级分支多级机构 returnstr = AppCarTaskApplyMoreStep(context); break; case "AppLeaveWorkFlowTaskHandle"://请假流程处理-多级分支多级机构 returnstr = AppLeaveWorkFlowTaskHandle(context); break; case "AppCarWorkFlowTaskHandle"://车辆审批流程处理-多级分支多级机构 returnstr = AppCarWorkFlowTaskHandle(context); break; case "AppGetToleranceListByOrgId"://本单位公差记录列表 returnstr = AppGetToleranceListByOrgId(context); break; case "AppGetToleranceSta": returnstr = AppGetToleranceSta(context); break; case "AppCountPatrolTask": returnstr = AppCountPatrolTask(context);//查铺查哨(地点) break; case "AppCountFireInspect": returnstr = AppCountFireInspect(context);//查铺查哨(机构+任务) break; case "AppCountLeave": returnstr = AppCountLeave(context);//请假统计 break; case "AppGetOrgNodeTree": returnstr = AppGetOrgNodeTree(context);//获取多个机构子级 break; case "AppGetOrgDeptEmpTreeByOrgId3": returnstr = AppGetOrgDeptEmpTreeByOrgId3(context);//根据机构ID获取下属所有机构、部门、人员 break; case "AppCountEmp": returnstr = AppCountEmp(context);//人员统计 break; case "AppCountCar": returnstr = AppCountCar(context);//车辆统计 break; case "AppToleranceTaskApplyMoreStep": returnstr = AppToleranceTaskApplyMoreStep(context);//公差审批流程-发起-多级分支多级机构 break; case "AppToleranceWorkFlowTaskHandle": returnstr = AppToleranceWorkFlowTaskHandle(context);//公差审批流程-处理-多级分支多级机构 break; case "AppCountFireInspectPlace": returnstr = AppCountFireInspectPlace(context);//查铺查哨(地点) break; case "AppCountPatrolTaskList": returnstr = AppCountPatrolTaskList(context); break; case "AppGetPartolTaskTrajectory": returnstr = AppGetPartolTaskTrajectory(context); break; case "AppGetOrgEmpList": returnstr = AppGetOrgEmpList(context); break; case "AppGetOrgCarList": returnstr = AppGetOrgCarList(context); break; case "AppGetToleranceStaList": returnstr = AppGetToleranceStaList(context); break; case "AppGetOrgLeaveList": returnstr = AppGetOrgLeaveList(context); //请假列表查询 break; case "AppGetDutyLeaderListByOrgId": returnstr = AppGetDutyLeaderListByOrgId(context); //战训副支队长步骤:只获取值班领导人员列表 break; case "AppCountCarApply": returnstr = AppCountCarApply(context); break; case "AppGetOaAttendanceRecord": returnstr = AppGetOaAttendanceRecord(context); break; case "AppGetEmpCIDListByOrgId": returnstr = AppGetEmpCIDListByOrgId(context); break; case "AppGetToleranceListByOrgIdManagement": returnstr = AppGetToleranceListByOrgIdManagement(context); break; case "AppSoftDeleteTaskById": returnstr = AppSoftDeleteTaskById(context); break; case "AppGetCarApplyListByOrgIdManagement": returnstr = AppGetCarApplyListByOrgIdManagement(context); break; case "AppFaceRecognitionEquipment": returnstr = AppQueryFaceRecognitionEquipment(context); break; //APP查询出操统计信息 case "getExerciseSta": returnstr = getExerciseSta(context); break; //提交出操现场文件 case "PostExerciseFile": returnstr = PostExerciseFile(context); break; //出操信息详情 case "getExerciseStaItem": returnstr = getExerciseStaItem(context); break; //西藏总队APP餐厅跳转地址 case "getDiningUrl": returnstr = getDiningUrl(context); break; //待办角标汇总统计 case "AppGetCornerMarkSta": returnstr = AppGetCornerMarkSta(context); break; //更新待办角标汇总统计缓存 case "AppGetCornerMarkStaRedisReplace": returnstr = AppGetCornerMarkStaRedisReplace(context); break; } context.Response.Write(returnstr); } #endregion #region 流程相关接口 #region 获取待办数 //获取待办数 private string AppGetTaskWaitCountByUid(HttpContext context) { string returnstr = ""; try { string useruid = context.Request.Params["useruid"]; string title = context.Request.Params["title"]; string flowid = context.Request.Params["flowid"]; string sender = context.Request.Params["sender"]; string date1 = context.Request.Params["date1"]; string date2 = context.Request.Params["date2"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 99999; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } List taskList = bworkFlowTask.AppGetTasks (useruid, pageIndex, pageSize, title, flowid, sender, date1, date2); returnstr = "{\"code\":0,\"count\":" + taskList.Count + "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"count\":0}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取待办数异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取待办数"); return returnstr; } #endregion #region 获取待办列表 //获取待办列表 private string AppGetTaskWaitListByUid(HttpContext context) { string returnstr = ""; try { string useruid = context.Request.Params["useruid"]; string title = context.Request.Params["title"]; string flowid = context.Request.Params["flowid"]; string sender = context.Request.Params["sender"]; string date1 = context.Request.Params["date1"]; string date2 = context.Request.Params["date2"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } List taskList = bworkFlowTask.AppGetTasks(useruid, pageIndex, pageSize, title, flowid, sender, date1, date2); returnstr = "{\"code\":" + taskList.Count + ",\"msg\":\"\",\"taskList\":"; if (taskList.Count > 0) { returnstr += FangYar.Common.JsonHelper.ToJson(taskList); } else { returnstr += "[]"; } returnstr += ",\"newDate\":\"" + DateTime.Now.ToString() + "\"}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"taskList\":[],\"flowOptions\":\"\",\"pager\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取待办列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取待办列表"); return returnstr; } #endregion #region 获取已办列表 //获取待办列表 private string AppGetTaskProcessedListByUid(HttpContext context) { string returnstr = ""; try { string useruid = context.Request.Params["useruid"]; string title = context.Request.Params["title"]; string flowid = context.Request.Params["flowid"]; string sender = context.Request.Params["sender"]; string date1 = context.Request.Params["date1"]; string date2 = context.Request.Params["date2"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } List taskList = bworkFlowTask.AppGetTasks (useruid, pageIndex, pageSize, title, flowid, sender, date1, date2); taskList = bworkFlowTask.AppGetTasks(useruid, pageIndex, pageSize, title, flowid, sender, date1, date2, 1); returnstr = "{\"code\":" + taskList.Count + ",\"msg\":\"\",\"taskList\":"; if (taskList.Count > 0) { returnstr += FangYar.Common.JsonHelper.ToJson(taskList); } else { returnstr += "[]"; } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"taskList\":[],\"flowOptions\":\"\",\"pager\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取已办列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取已办列表"); return returnstr; } #endregion #region 请假申请 //请假申请 private string AppLeaveTaskApply(HttpContext context) { string returnstr = ""; try { bool flag = false; //请假表单字段 string leaveId = context.Request.Params["leaveId"]; if (string.IsNullOrEmpty(leaveId)) { flag = true; leaveId = Guid.NewGuid().ToString().ToGuid().ToString(); } string pplId = context.Request.Params["pplId"]; string pplName = context.Request.Params["pplName"]; string lType = context.Request.Params["lType"]; string sTime = context.Request.Params["sTime"]; string eTime = context.Request.Params["eTime"]; string lNum = context.Request.Params["lNum"]; string lOut = context.Request.Params["lOut"]; string accPplId = context.Request.Params["accId"]; string repPplId = context.Request.Params["repId"]; string lReason = context.Request.Params["reason"]; string title = context.Request.Params["title"]; FangYar.Model.OA_LEAVE leaveModel = new FangYar.Model.OA_LEAVE(); leaveModel.ID = leaveId; leaveModel.PPL_ID = pplId; leaveModel.PPL_NAME = pplName; leaveModel.L_TYPE = lType; leaveModel.S_TIME = sTime; leaveModel.E_TIME = eTime; leaveModel.L_NUM = lNum; leaveModel.L_OUT = lOut; leaveModel.ACC_PPL = accPplId; leaveModel.REP_PPL = repPplId; leaveModel.L_REASON = lReason; leaveModel.TITLE = title; leaveModel.STATE = "0"; leaveModel.IS_RETURN = "1"; RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); string opation = context.Request.Params["opation"];//操作类型 string receiveId = context.Request.Params["receiveId"];//接收人员 switch (opation) { case "apply": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; } FangYar.BLL.OA_LEAVE leaveBll = new FangYar.BLL.OA_LEAVE(); //流程字段 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID var wfInstalled = bworkFlow.GetWorkFlowRunModel("48b51077-4bc7-4807-bcc2-b33e8ef0f5b2"); if (flag) { leaveBll.Add(leaveModel); execute.FlowID = "48b51077-4bc7-4807-bcc2-b33e8ef0f5b2".ToGuid(); execute.GroupID = Guid.Empty; execute.InstanceID = leaveModel.ID.ToGuid().ToString(); execute.IsSign = false; execute.Note = ""; execute.Sender = userBll.GetModelByUID(pplId); execute.StepID = wfInstalled.FirstStepID; execute.TaskID = Guid.Empty; } else { leaveBll.Update(leaveModel); wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); } execute.Title = title ?? ""; var steps = wfInstalled.Steps.Where(p => p.ID == execute.StepID); var currentStep = steps.First(); var nextSteps = bworkFlow.GetNextSteps(wfInstalled.ID, currentStep.ID).OrderBy(p => p.Position_x).ThenBy(p => p.Position_y).ToList(); execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); var reslut = bworkFlowTask.AppExecute(execute); returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; //app推送消息 try { //人员详细信息 FangYar.BLL.TBL.SysEmpBLL empBll = new BLL.TBL.SysEmpBLL(); FangYar.Model.TBL.TBL_SYS_EMP_Model empModel = empBll.GetModelByUID(pplId); //消息通知记录入库操作 FangYar.Model.TBL.TBL_MESSAGE_LOG tbl_message_log = new Model.TBL.TBL_MESSAGE_LOG(); tbl_message_log.ID = Guid.NewGuid().ToString("N"); tbl_message_log.TITLE = "请假申请"; tbl_message_log.CONTENT = "[" + pplName + "]的请假申请,请查看!"; tbl_message_log.SENDID = pplId; tbl_message_log.SENDNAME = pplName; tbl_message_log.SENDTIME = DateTime.Now.ToString("G"); tbl_message_log.TYPE = "0"; //请假 tbl_message_log.URL = "/pages/team/dspxnew/dspxlist"; tbl_message_log.PARAM = ""; tbl_message_log.RECEIVEID = receiveId; tbl_message_log.RECEIVENAME = ""; tbl_message_log.OPENTIME = ""; tbl_message_log.STATE = "0"; //未读 tbl_message_log.ORG_ID = empModel.ORG_ID; //机构ID FangYar.FYMQTT.MessageLog ml = new FangYar.FYMQTT.MessageLog(); ml.MessageLogAdd(tbl_message_log); FangYar.FYMQTT.MessagePush mp = new FYMQTT.MessagePush(); mp.AloneMsgPush(receiveId, "请假申请", "[" + pplName + "]的请假申请,请查看!", tbl_message_log.ID); } catch (Exception e) { } } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "请假申请异常" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP操作请求", "请假申请"); return returnstr; } #endregion #region 获取请假待办详情 //获取请假待办详情 private string AppGetTaskWaitLeaveItem(HttpContext context) { string returnstr = ""; try { string flowid = context.Request.Params["flowid"]; string stepid = context.Request.Params["stepid"]; string instanceid = context.Request.Params["instanceid"]; string status = context.Request.Params["status"]; if (status == "0") { //更新打开时间 Guid taskgid; string taskid = context.Request.Params["taskid"]; taskid.IsGuid(out taskgid); RoadFlow.Data.Model.WorkFlowTask task = bworkFlowTask.Get(taskgid); //如果是执行,并且任务ID为GUID,则更新打开时间和状态,检查当前任务是否可以执行。 bworkFlowTask.UpdateOpenTime(taskgid, RoadFlow.Utility.DateTimeNew.Now, true); } var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); Guid stepID; if (!stepid.IsGuid(out stepID)) { stepID = wfInstalled.FirstStepID; } returnstr = "{\"code\":0,\"msg\":\"\""; RoadFlow.Data.Model.WorkFlowInstalledSub.Step currentStep = wfInstalled.Steps.ToList().Find(p => p.ID == stepID); returnstr += ",\"buttons\":"; //按钮 List buttons = new List(); foreach (var button in currentStep.Buttons) { buttons.Add(button); } returnstr += FangYar.Common.JsonHelper.ToJson(buttons); returnstr += ",\"leaveModel\":"; FangYar.BLL.OA_LEAVE leavebll = new FangYar.BLL.OA_LEAVE(); List data = leavebll.getLeave(instanceid); if (data == null) { return "{\"code\":-1,\"msg\":\"未查询到详情!\",\"buttons\":[],\"leaveModel\":\"\",\"commentData\":\"\"}"; } returnstr += FangYar.Common.JsonHelper.ToJson(data[0]); returnstr += ",\"commentData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data[1]); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"buttons\":[],\"leaveModel\":\"\",\"commentData\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取请假待办详情异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取请假待办详情"); return returnstr; } #endregion #region 公差申请 //公差申请 private string AppToleranceTaskApply(HttpContext context) { string returnstr = ""; try { bool flag = false; //请假表单字段 string toleranceId = context.Request.Params["toleranceId"]; if (string.IsNullOrEmpty(toleranceId)) { flag = true; toleranceId = Guid.NewGuid().ToString().ToGuid().ToString(); } string pplId = context.Request.Params["pplId"]; string pplName = context.Request.Params["pplName"]; string lType = context.Request.Params["lType"]; string sTime = context.Request.Params["sTime"]; string eTime = context.Request.Params["eTime"]; string lNum = context.Request.Params["lNum"]; string lOut = context.Request.Params["lOut"]; string accPplId = context.Request.Params["accId"]; string repPplId = context.Request.Params["repId"]; string lReason = context.Request.Params["reason"]; string title = context.Request.Params["title"]; string carNum = context.Request.Params["carNum"]; FangYar.Model.OA.OA_TOLERANCE toleranceModel = new FangYar.Model.OA.OA_TOLERANCE(); toleranceModel.ID = toleranceId; toleranceModel.PPL_ID = pplId; toleranceModel.PPL_NAME = pplName; toleranceModel.L_TYPE = lType; toleranceModel.S_TIME = sTime; toleranceModel.E_TIME = eTime; toleranceModel.L_NUM = lNum; toleranceModel.L_OUT = lOut; toleranceModel.ACC_PPL = accPplId; toleranceModel.REP_PPL = repPplId; toleranceModel.L_REASON = lReason; toleranceModel.TITLE = title; toleranceModel.STATE = "0"; toleranceModel.CAR_NUM = carNum; RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); string opation = context.Request.Params["opation"];//操作类型 string receiveId = context.Request.Params["receiveId"];//接收人员 switch (opation) { case "apply": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; } FangYar.BLL.OA.OA_TOLERANCE toleranceBll = new FangYar.BLL.OA.OA_TOLERANCE(); //流程字段 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID var wfInstalled = bworkFlow.GetWorkFlowRunModel("37337d05-251a-459d-8c5e-b545b8593f9c"); if (flag) { toleranceBll.Add(toleranceModel); execute.FlowID = "37337d05-251a-459d-8c5e-b545b8593f9c".ToGuid(); execute.GroupID = Guid.Empty; execute.InstanceID = toleranceModel.ID.ToGuid().ToString(); execute.IsSign = false; execute.Note = ""; execute.Sender = userBll.GetModelByUID(pplId); execute.StepID = wfInstalled.FirstStepID; execute.TaskID = Guid.Empty; } else { toleranceBll.Update(toleranceModel); wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); } execute.Title = title ?? ""; var steps = wfInstalled.Steps.Where(p => p.ID == execute.StepID); var currentStep = steps.First(); var nextSteps = bworkFlow.GetNextSteps(wfInstalled.ID, currentStep.ID).OrderBy(p => p.Position_x).ThenBy(p => p.Position_y).ToList(); execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); var reslut = bworkFlowTask.AppExecute(execute); returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; //app推送消息 try { //人员详细信息 FangYar.BLL.TBL.SysEmpBLL empBll = new BLL.TBL.SysEmpBLL(); FangYar.Model.TBL.TBL_SYS_EMP_Model empModel = empBll.GetModelByUID(pplId); //消息通知记录入库操作 FangYar.Model.TBL.TBL_MESSAGE_LOG tbl_message_log = new Model.TBL.TBL_MESSAGE_LOG(); tbl_message_log.ID = Guid.NewGuid().ToString("N"); tbl_message_log.TITLE = "公差申请"; tbl_message_log.CONTENT = "[" + pplName + "]的公差申请,请查看!"; tbl_message_log.SENDID = pplId; tbl_message_log.SENDNAME = pplName; tbl_message_log.SENDTIME = DateTime.Now.ToString("G"); tbl_message_log.TYPE = "2"; //公差 tbl_message_log.URL = "/pages/team/dspxnew/dspxlist"; tbl_message_log.PARAM = ""; tbl_message_log.RECEIVEID = receiveId; tbl_message_log.RECEIVENAME = ""; tbl_message_log.OPENTIME = ""; tbl_message_log.STATE = "0"; //未读 tbl_message_log.ORG_ID = empModel.ORG_ID; //机构ID FangYar.FYMQTT.MessageLog ml = new FangYar.FYMQTT.MessageLog(); ml.MessageLogAdd(tbl_message_log); FangYar.FYMQTT.MessagePush mp = new FYMQTT.MessagePush(); mp.AloneMsgPush(receiveId, "公差申请", "[" + pplName + "]的公差申请,请查看!", tbl_message_log.ID); } catch (Exception e) { } } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "公差申请异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP操作请求", "公差申请"); return returnstr; } #endregion #region 获取公差待办详情 //获取公差待办详情 private string AppGetTaskWaitToleranceItem(HttpContext context) { string returnstr = ""; try { string flowid = context.Request.Params["flowid"]; string stepid = context.Request.Params["stepid"]; string instanceid = context.Request.Params["instanceid"]; string status = context.Request.Params["status"]; if (status == "0") { //更新打开时间 Guid taskgid; string taskid = context.Request.Params["taskid"]; taskid.IsGuid(out taskgid); RoadFlow.Data.Model.WorkFlowTask task = bworkFlowTask.Get(taskgid); //如果是执行,并且任务ID为GUID,则更新打开时间和状态,检查当前任务是否可以执行。 bworkFlowTask.UpdateOpenTime(taskgid, RoadFlow.Utility.DateTimeNew.Now, true); } var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); Guid stepID; if (!stepid.IsGuid(out stepID)) { stepID = wfInstalled.FirstStepID; } returnstr = "{\"code\":0,\"msg\":\"\""; RoadFlow.Data.Model.WorkFlowInstalledSub.Step currentStep = wfInstalled.Steps.ToList().Find(p => p.ID == stepID); returnstr += ",\"buttons\":"; //按钮 List buttons = new List(); foreach (var button in currentStep.Buttons) { buttons.Add(button); } returnstr += FangYar.Common.JsonHelper.ToJson(buttons); returnstr += ",\"toleranceModel\":"; FangYar.BLL.OA.OA_TOLERANCE tolerancebll = new FangYar.BLL.OA.OA_TOLERANCE(); List data = tolerancebll.getTolerance(instanceid); returnstr += FangYar.Common.JsonHelper.ToJson(data[0]); returnstr += ",\"commentData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data[1]); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"buttons\":[],\"toleranceModel\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取公差待办详情异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取公差待办详情"); return returnstr; } #endregion #region 用车申请 //用车申请 private string AppCarTaskApply(HttpContext context) { string returnstr = ""; try { bool flag = false; //用车表单字段 string applyId = context.Request.Params["applyId"]; if (string.IsNullOrEmpty(applyId)) { flag = true; applyId = Guid.NewGuid().ToString().ToGuid().ToString(); } string userId = context.Request.Params["userId"]; string userName = context.Request.Params["userName"]; string userPhone = context.Request.Params["userPhone"]; string carId = context.Request.Params["carId"]; string carNum = context.Request.Params["carNum"]; string userMan = context.Request.Params["userMan"]; string rideNum = context.Request.Params["rideNum"]; string rideMan = context.Request.Params["rideMan"]; string ridePurpose = context.Request.Params["ridePurpose"]; string startPoint = context.Request.Params["startPoint"]; string endPoint = context.Request.Params["endPoint"]; string startTime = context.Request.Params["startTime"]; string endTime = context.Request.Params["endTime"]; string title = context.Request.Params["title"]; FangYar.Model.TBL_SYS_CARAPPLY carModel = new FangYar.Model.TBL_SYS_CARAPPLY(); carModel.ID = applyId; carModel.USERID = userId; carModel.USERNAME = userName; carModel.USERPHONE = userPhone; carModel.CARID = carId; carModel.CARNUM = carNum; carModel.USERMAN = userMan; if (!string.IsNullOrEmpty(rideNum)) { carModel.RIDENUM = Int32.Parse(rideNum); } else { carModel.RIDENUM = 1; } carModel.RIDEMANS = rideMan; carModel.RIDEPURPOSE = ridePurpose; carModel.STARTPOINT = startPoint; carModel.DESTINATION = endPoint; if (!string.IsNullOrEmpty(startTime)) { carModel.STARTTIME = DateTime.Parse(startTime); } if (!string.IsNullOrEmpty(endTime)) { carModel.FINISHTIME = DateTime.Parse(endTime); } carModel.STATE = "0"; carModel.EXTENDCODE2 = "1"; carModel.TITLE = title; FangYar.BLL.TBL_SYS_CARAPPLY carBll = new FangYar.BLL.TBL_SYS_CARAPPLY(); RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); string opation = context.Request.Params["opation"];//操作类型 string receiveId = context.Request.Params["receiveId"];//接收人员 switch (opation) { case "apply": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; } //流程字段 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID var wfInstalled = bworkFlow.GetWorkFlowRunModel("c6533642-dc36-4728-aac7-81e6989f6105"); if (flag) { carBll.Add(carModel); execute.FlowID = "c6533642-dc36-4728-aac7-81e6989f6105".ToGuid(); execute.GroupID = Guid.Empty; execute.InstanceID = carModel.ID.ToGuid().ToString(); execute.IsSign = false; execute.Note = ""; execute.Sender = userBll.GetModelByUID(userId); execute.StepID = wfInstalled.FirstStepID; execute.TaskID = Guid.Empty; } else { carBll.Update(carModel); wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); } execute.Title = title ?? ""; var steps = wfInstalled.Steps.Where(p => p.ID == execute.StepID); var currentStep = steps.First(); var nextSteps = bworkFlow.GetNextSteps(wfInstalled.ID, currentStep.ID).OrderBy(p => p.Position_x).ThenBy(p => p.Position_y).ToList(); execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); var reslut = bworkFlowTask.AppExecute(execute); returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; //app推送消息 try { //人员详细信息 FangYar.BLL.TBL.SysEmpBLL empBll = new BLL.TBL.SysEmpBLL(); FangYar.Model.TBL.TBL_SYS_EMP_Model empModel = empBll.GetModelByUID(userId); //消息通知记录入库操作 FangYar.Model.TBL.TBL_MESSAGE_LOG tbl_message_log = new Model.TBL.TBL_MESSAGE_LOG(); tbl_message_log.ID = Guid.NewGuid().ToString("N"); tbl_message_log.TITLE = "用车申请"; tbl_message_log.CONTENT = "[" + userName + "]的用车申请,请查看!"; tbl_message_log.SENDID = userId; tbl_message_log.SENDNAME = userName; tbl_message_log.SENDTIME = DateTime.Now.ToString("G"); tbl_message_log.TYPE = "1"; //用车 tbl_message_log.URL = "/pages/team/dspxnew/dspxlist"; tbl_message_log.PARAM = ""; tbl_message_log.RECEIVEID = receiveId; tbl_message_log.RECEIVENAME = ""; tbl_message_log.OPENTIME = ""; tbl_message_log.STATE = "0"; //未读 tbl_message_log.ORG_ID = empModel.ORG_ID; //机构ID FangYar.FYMQTT.MessageLog ml = new FangYar.FYMQTT.MessageLog(); ml.MessageLogAdd(tbl_message_log); FangYar.FYMQTT.MessagePush mp = new FYMQTT.MessagePush(); mp.AloneMsgPush(receiveId, "用车申请", "[" + userName + "]的用车申请,请查看!", tbl_message_log.ID); } catch (Exception e) { } } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "用车申请异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP操作请求", "用车申请"); return returnstr; } #endregion #region 获取用车待办详情 //获取用车待办详情 private string AppGetTaskWaitCarItem(HttpContext context) { string returnstr = ""; try { string flowid = context.Request.Params["flowid"]; string stepid = context.Request.Params["stepid"]; string instanceid = context.Request.Params["instanceid"]; string status = context.Request.Params["status"]; if (status == "0") { //更新打开时间 Guid taskgid; string taskid = context.Request.Params["taskid"]; taskid.IsGuid(out taskgid); RoadFlow.Data.Model.WorkFlowTask task = bworkFlowTask.Get(taskgid); //如果是执行,并且任务ID为GUID,则更新打开时间和状态,检查当前任务是否可以执行。 bworkFlowTask.UpdateOpenTime(taskgid, RoadFlow.Utility.DateTimeNew.Now, true); } var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); Guid stepID; if (!stepid.IsGuid(out stepID)) { stepID = wfInstalled.FirstStepID; } returnstr = "{\"code\":0,\"msg\":\"\""; RoadFlow.Data.Model.WorkFlowInstalledSub.Step currentStep = wfInstalled.Steps.ToList().Find(p => p.ID == stepID); returnstr += ",\"buttons\":"; //按钮 List buttons = new List(); foreach (var button in currentStep.Buttons) { buttons.Add(button); } returnstr += FangYar.Common.JsonHelper.ToJson(buttons); returnstr += ",\"carModel\":"; FangYar.BLL.TBL_SYS_CARAPPLY carbll = new FangYar.BLL.TBL_SYS_CARAPPLY(); List data = carbll.getCarApply(instanceid); returnstr += FangYar.Common.JsonHelper.ToJson(data[0]); returnstr += ",\"commentData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data[1]); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"buttons\":[],\"carModel\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取用车待办详情异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取用车待办详情"); return returnstr; } #endregion #region 请假流程处理 //请假流程处理 private string AppLeaveTaskHandle(HttpContext context) { string returnstr = ""; try { //流程字段 string comment = context.Request.Params["comment"];//处理意见 string opation = context.Request.Params["opation"];//操作类型 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string receiveId = context.Request.Params["receiveId"];//接收人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID string title = context.Request.Params["title"];//标题 string EXTEND = context.Request.Params["EXTEND"];//延假小时 string isEXTEND = context.Request.Params["isEXTEND"];//是否为延假 0销假;1延假 if (isEXTEND == "1") { FangYar.BLL.OA_LEAVE ldal = new FangYar.BLL.OA_LEAVE(); FangYar.Model.OA_LEAVE lmodel = ldal.GetModel(instanceid); lmodel.EXTEND = EXTEND; ldal.Update(lmodel); } RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.OA_LEAVE leavebll = new FangYar.BLL.OA_LEAVE(); FangYar.Model.OA_LEAVE leaveModel = leavebll.GetModel(instanceid); switch (opation) { case "submit": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; case "back": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "completed": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "redirect": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Redirect; break; //新增同意 case "agree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree; leavebll.EditState(instanceid, "1"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; //新增不同意 case "disagree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree; leavebll.EditState(instanceid, "2"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; } FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); execute.Title = title ?? ""; if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed) { FangYar.BLL.TBL.SysEmpBLL empbll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.Model.TBL.TBL_SYS_EMP_Model emodel = new FangYar.Model.TBL.TBL_SYS_EMP_Model(); emodel.USERS_UID = leaveModel.PPL_ID; emodel.IS_WORK = "1"; empbll.EditEmpIswork(emodel); var accUsers = leaveModel.ACC_PPL.Split(','); foreach (string uid in accUsers) { emodel.USERS_UID = uid.Replace("u_", ""); empbll.EditEmpIswork(emodel); } } var steps = wfInstalled.Steps.Where(p => p.ID == execute.StepID); var currentStep = steps.First(); if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { int backType = currentStep.Behavior.BackType;//退回类型 var prevSteps = bworkFlowTask.GetBackSteps(taskid.ToGuid(), backType, stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID, wfInstalled); foreach (var step in prevSteps) { execute.Steps.Add(step.Key, new List()); } } else { var nextSteps = bworkFlow.GetNextSteps(wfInstalled.ID, currentStep.ID).OrderBy(p => p.Position_x).ThenBy(p => p.Position_y).ToList(); if (nextSteps.Count > 0) { for (int i = 0; i < nextSteps.Count; i++) { if (isEXTEND == "0") { if (nextSteps[i].ID == "5899f4f3-44ed-4235-9241-3e8ce0c84aec".ToGuid()) { execute.Steps.Add(nextSteps[i].ID, borganize.GetAllUsersIdString(receiveId)); break; } else { execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); break; } } else if (isEXTEND == "1") { if (nextSteps[i].ID == "50067d16-19cf-439f-9b63-662ba04566ab".ToGuid()) { execute.Steps.Add(nextSteps[i].ID, borganize.GetAllUsersIdString(receiveId)); break; } } else { execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); break; } } } } var reslut = bworkFlowTask.AppExecute(execute); RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; foreach (var step in steps) { //步骤提交后事件 if (!step.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(step.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!step.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(step.Event.BackAfter.Trim(), eventParams); } } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; //app推送消息 try { FangYar.FYMQTT.MessagePush mp = new FYMQTT.MessagePush(); mp.AloneMsgPush(receiveId, "请销假审批", "您有一条[请销假]待办审批反馈,状态:" + comment.Trim() + "!"); } catch (Exception e) { } } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "请假流程处理异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "APP操作请求", "请假流程处理"); return returnstr; } #endregion #region 公差流程处理 //公差流程处理 private string AppToleranceTaskHandle(HttpContext context) { string returnstr = ""; try { //流程字段 string comment = context.Request.Params["comment"];//处理意见 string opation = context.Request.Params["opation"];//操作类型 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string receiveId = context.Request.Params["receiveId"];//接收人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID string title = context.Request.Params["title"];//标题 RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.OA.OA_TOLERANCE tolerancebll = new FangYar.BLL.OA.OA_TOLERANCE(); FangYar.Model.OA.OA_TOLERANCE toleranceModel = tolerancebll.GetModel(instanceid); switch (opation) { case "submit": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; case "back": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "completed": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "redirect": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Redirect; break; //新增同意 case "agree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree; tolerancebll.EditState(instanceid, "1"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; //新增不同意 case "disagree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree; tolerancebll.EditState(instanceid, "2"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; } FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); execute.Title = title ?? ""; if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed) { FangYar.BLL.TBL.SysEmpBLL empbll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.Model.TBL.TBL_SYS_EMP_Model emodel = new FangYar.Model.TBL.TBL_SYS_EMP_Model(); emodel.USERS_UID = toleranceModel.PPL_ID; emodel.IS_WORK = "1"; empbll.EditEmpIswork(emodel); var accUsers = toleranceModel.ACC_PPL.Split(','); foreach (string uid in accUsers) { emodel.USERS_UID = uid.Replace("u_", ""); empbll.EditEmpIswork(emodel); } } if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { var steps2 = wfInstalled.Steps.Where(p => p.ID == stepid.ToGuid()); var currentStep2 = steps2.First(); int backType = currentStep2.Behavior.BackType;//退回类型 var prevSteps = bworkFlowTask.GetBackSteps(taskid.ToGuid(), backType, stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID, wfInstalled); foreach (var step in prevSteps) { execute.Steps.Add(step.Key, new List()); } } else { var steps = wfInstalled.Steps.Where(p => p.ID == execute.StepID); var currentStep = steps.First(); var nextSteps = bworkFlow.GetNextSteps(wfInstalled.ID, currentStep.ID).OrderBy(p => p.Position_x).ThenBy(p => p.Position_y).ToList(); if (nextSteps.Count > 0) { execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); } } var reslut = bworkFlowTask.AppExecute(execute); returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; //app推送消息 try { FangYar.FYMQTT.MessagePush mp = new FYMQTT.MessagePush(); mp.AloneMsgPush(receiveId, "公差审批", "您有一条[公差]待办审批反馈,状态:" + comment.Trim() + "!"); } catch (Exception e) { } } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "公差流程处理异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "APP操作请求", "公差流程处理"); return returnstr; } #endregion #region 用车流程处理 //用车流程处理 private string AppCarTaskHandle(HttpContext context) { string returnstr = ""; try { //流程字段 string comment = context.Request.Params["comment"];//处理意见 string opation = context.Request.Params["opation"];//操作类型 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string receiveId = context.Request.Params["receiveId"];//接收人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID string title = context.Request.Params["title"];//标题 RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.TBL_SYS_CARAPPLY carBll = new FangYar.BLL.TBL_SYS_CARAPPLY(); FangYar.Model.TBL_SYS_CARAPPLY carModel = carBll.GetModel(instanceid); switch (opation) { case "submit": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; case "back": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "completed": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "redirect": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Redirect; break; //新增同意 case "agree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree; carBll.EditState(instanceid, "1"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; //新增不同意 case "disagree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree; carBll.EditState(instanceid, "2"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; } FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); execute.Title = title ?? ""; if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed) { FangYar.BLL.TBL.SysEmpBLL empbll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.Model.TBL.TBL_SYS_EMP_Model emodel = new FangYar.Model.TBL.TBL_SYS_EMP_Model(); emodel.USERS_UID = carModel.USERID; emodel.IS_WORK = "1"; empbll.EditEmpIswork(emodel); emodel.USERS_UID = carModel.USERMAN; empbll.EditEmpIswork(emodel); var accUsers = carModel.RIDEMANS.Split(','); foreach (string uid in accUsers) { emodel.USERS_UID = uid.Replace("u_", ""); empbll.EditEmpIswork(emodel); } //还车通过后修改车辆的状态 FangYar.BLL.TBL_SYS_CAR carbll = new TBL_SYS_CAR(); FangYar.Model.TBL_SYS_CAR carmodel = carbll.GetModel(carModel.CARID); if (carmodel != null) { carmodel.ISAPPLY = "0"; } carbll.EditCarIsapply(carmodel); } if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { var steps2 = wfInstalled.Steps.Where(p => p.ID == stepid.ToGuid()); var currentStep2 = steps2.First(); int backType = currentStep2.Behavior.BackType;//退回类型 var prevSteps = bworkFlowTask.GetBackSteps(taskid.ToGuid(), backType, stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID, wfInstalled); foreach (var step in prevSteps) { execute.Steps.Add(step.Key, new List()); } } else { var steps = wfInstalled.Steps.Where(p => p.ID == execute.StepID); var currentStep = steps.First(); var nextSteps = bworkFlow.GetNextSteps(wfInstalled.ID, currentStep.ID).OrderBy(p => p.Position_x).ThenBy(p => p.Position_y).ToList(); if (nextSteps.Count > 0) { execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); } } var reslut = bworkFlowTask.AppExecute(execute); returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; //app推送消息 try { FangYar.FYMQTT.MessagePush mp = new FYMQTT.MessagePush(); mp.AloneMsgPush(receiveId, "用车审批", "您有一条[用车]待办审批反馈,状态:" + comment.Trim() + "!"); } catch (Exception e) { } } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "用车流程处理异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "APP操作请求", "用车流程处理"); return returnstr; } #endregion #region 根据机构ID获取下属所有部门、人员 //根据机构ID获取下属所有部门、人员 private string AppGetOrgDeptEmpTreeByOrgId(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["OrgId"]; FangYar.BLL.FIRE.FIRE_ORG orgBll = new FangYar.BLL.FIRE.FIRE_ORG(); FangYar.BLL.TBL.SysEmpBLL empBll = new FangYar.BLL.TBL.SysEmpBLL(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; DataTable dt = orgBll.GetSuperiorOrgListTreeByOrgId(orgId); if (dt != null) { string[] org_ids = dt.Rows[0]["ORG_IDS"].ToString().Split(','); string orgIds = ""; for (int i = 0; i < org_ids.Length; i++) { if (i == 0) { orgIds = "'" + org_ids[i] + "'"; } else { orgIds += ",'" + org_ids[i] + "'"; } } DataTable data = empBll.getOrgAndDeptEmpByOrgIds(orgIds); returnstr += FangYar.Common.JsonHelper.ToJson(data); } else { DataTable data = empBll.getOrgAndDeptEmpByOrgIds(orgId); returnstr += FangYar.Common.JsonHelper.ToJson(data); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据机构ID获取下属所有部门、人员异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据机构ID获取下属所有部门、人员"); return returnstr; } //根据机构ID获取(在一个院里的单位)下属所有部门、人员 private string AppGetCorrelationCampOrgDeptEmpTreeByOrgId(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["OrgId"]; returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; string orgIds = "'" + orgId + "'", orgId_s = "" + orgId + ""; string getCorrelationOrgSql = "select CORRELATION_CAMP_ORG_ID from fire_org where org_id = '" + orgId + "'"; DataTable orgDt = FangYar.Common.MySqlHelper.Query(getCorrelationOrgSql).Tables[0]; if (orgDt.Rows.Count != 0) { string CORRELATION_CAMP_ORG_ID = orgDt.Rows[0]["CORRELATION_CAMP_ORG_ID"].ToString(); if (!string.IsNullOrEmpty(CORRELATION_CAMP_ORG_ID)) { if (CORRELATION_CAMP_ORG_ID.Contains(",")) { string[] CORRELATION_CAMP_ORG_ID_S = CORRELATION_CAMP_ORG_ID.Split(','); for (int i = 0; i < CORRELATION_CAMP_ORG_ID_S.Length; i++) { if (!string.IsNullOrEmpty(CORRELATION_CAMP_ORG_ID_S[i])) { orgIds += ",'" + CORRELATION_CAMP_ORG_ID_S[i] + "'"; orgId_s += "," + CORRELATION_CAMP_ORG_ID_S[i]; } } } else { orgIds += ",'" + CORRELATION_CAMP_ORG_ID + "'"; orgId_s += "," + CORRELATION_CAMP_ORG_ID; } } } StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT o.org_id id, o.org_name NAME, o.pid pid, CASE o.TYPE WHEN 0 THEN 'org' WHEN 1 THEN 'dept' ELSE o.TYPE END AS TYPE, '0' sort, '0' photo "); strSql.Append("FROM fire_org o ,( SELECT get_Org_child_Dept_list_OrgIds ( '" + orgId_s + "' ) cids ) s WHERE find_in_set( o.org_id, cids ) "); strSql.Append("UNION ALL SELECT e.users_uid id, e.emp_name NAME, IF (( ISNULL( e.dept_id ) > 0 OR LENGTH( trim( e.dept_id ))= 0 ), e.org_id, e.dept_id ) pid, 'emp' type, "); strSql.Append("( CASE WHEN e.is_leader IS NOT NULL THEN e.is_leader ELSE 1 END ) sort,IF (( ISNULL( PHOTO ) > 0 OR LENGTH( trim( PHOTO ))= 0 ), 'images/imgPerDefaut.jpg', PHOTO ) photo "); strSql.Append("FROM tbl_sys_emp e WHERE IS_ADMIN = '0' AND e.ORG_ID IN ( " + orgIds + " ) AND e.users_uid IS NOT NULL AND e.is_del != '1' ORDER BY type, sort DESC"); DataTable data = FangYar.Common.MySqlHelper.QueryTable(strSql.ToString()); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据机构ID获取下属所有部门、人员异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据机构ID获取下属所有部门、人员"); return returnstr; } //根据机构ID获取当日总指挥 private string AppGetEmpListByTags(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["orgId"]; string tag = context.Request.Params["tag"]; FangYar.BLL.TBL.SysEmpBLL empBll = new FangYar.BLL.TBL.SysEmpBLL(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; DataTable data = empBll.GetOrgDeptEmpTreeByTags(orgId, tag); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据机构ID获取当日总指挥异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据机构ID获取当日总指挥"); return returnstr; } //根据机构ID获取下属所有机构、部门、人员 private string AppGetOrgDeptEmpTreeByOrgId3(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["OrgId"]; string deptId = context.Request.Params["DeptId"]; if (deptId == "0192a6228fca4ed2bea225ad3bbf0dc9") { orgId = deptId; } FangYar.BLL.FIRE.FIRE_ORG orgBll = new FangYar.BLL.FIRE.FIRE_ORG(); FangYar.BLL.TBL.SysEmpBLL empBll = new FangYar.BLL.TBL.SysEmpBLL(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; DataTable dt = orgBll.GetSubordinateOrgListTreeByOrgId(orgId); if (dt != null) { string[] org_ids = dt.Rows[0]["ORG_IDS"].ToString().Split(','); string orgIds = ""; for (int i = 0; i < org_ids.Length; i++) { if (i == 0) { orgIds = "'" + org_ids[i] + "'"; } else { orgIds += ",'" + org_ids[i] + "'"; } } DataTable data = empBll.getOrgDeptEmpTreeByOrgIds2(orgIds); returnstr += FangYar.Common.JsonHelper.ToJson(data); } else { DataTable data = empBll.getOrgDeptEmpTreeByOrgId(orgId); returnstr += FangYar.Common.JsonHelper.ToJson(data); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据机构ID获取下属所有机构、部门、人员异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据机构ID获取下属所有机构、部门、人员"); return returnstr; } #endregion #region 根据机构ID获取下属所有部门、车辆 //根据机构ID获取下属所有部门、车辆 private string AppGetOrgDeptCarTreeByOrgId(HttpContext context) { string returnstr = ""; try { TBL_SYS_CAR bll = new TBL_SYS_CAR(); string orgId = context.Request.Params["OrgId"]; string type = context.Request.Params["type"]; returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; DataTable data = null; if (string.IsNullOrEmpty(type)) { data = bll.GetListCarTree(orgId).Tables[0]; } else { data = bll.GetListCarTree(orgId, type).Tables[0]; } data.Columns.Add("nocheck", typeof(string)); //数据类型为文本 for (int i = 0; i < data.Rows.Count; i++) { string aaa = data.Rows[i]["TYPE"].ToString(); if (data.Rows[i]["TYPE"].ToString() == "car") { data.Rows[i]["nocheck"] = "false"; } else { data.Rows[i]["nocheck"] = "true"; } } returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据机构ID获取下属所有部门、车辆异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据机构ID获取下属所有部门、车辆"); return returnstr; } //根据机构ID获取下属所有部门、车辆 private string AppGetOrgDeptCarTreeByOrgId2(HttpContext context) { string returnstr = ""; try { TBL_SYS_CAR bll = new TBL_SYS_CAR(); string orgId = context.Request.Params["OrgId"]; string type = context.Request.Params["type"]; string startTime = context.Request.Params["startTime"]; string endTime = context.Request.Params["endTime"]; returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; DataTable data = null; if (string.IsNullOrEmpty(type)) { data = bll.GetListCarTree(orgId, startTime, endTime).Tables[0]; } else { data = bll.GetListCarTree(orgId, type, startTime, endTime).Tables[0]; } data.Columns.Add("nocheck", typeof(string)); //数据类型为文本 for (int i = 0; i < data.Rows.Count; i++) { string aaa = data.Rows[i]["TYPE"].ToString(); if (data.Rows[i]["TYPE"].ToString() == "car") { data.Rows[i]["nocheck"] = "false"; } else { data.Rows[i]["nocheck"] = "true"; } } returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据机构ID获取下属所有部门、车辆异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据机构ID获取下属所有部门、车辆"); return returnstr; } #endregion #region 请假类型列表 //请假类型列表 private string AppGetLeaveTypeList(HttpContext context) { string returnstr = ""; try { RoadFlow.Platform.Dictionary dicBll = new RoadFlow.Platform.Dictionary(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; List data = dicBll.GetChilds("e7f836be-f091-460f-86e1-f0b6cdceba39".ToGuid()); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "请假类型列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "请假类型列表"); return returnstr; } #endregion #region 公差类型列表 //公差类型列表 private string AppGetToleranceTypeList(HttpContext context) { string returnstr = ""; try { RoadFlow.Platform.Dictionary dicBll = new RoadFlow.Platform.Dictionary(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; List data = dicBll.GetChilds("e420e6ab-acb3-4de2-a316-d9a67ca76e69".ToGuid()); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "公差类型列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "公差类型列表"); return returnstr; } #endregion #endregion 流程相关接口 #region 请假记录列表 //请假记录列表 private string AppGetLeaveListByUid(HttpContext context) { string returnstr = ""; try { string uid = context.Request.Params["uid"]; string keyword = context.Request.Params["keywords"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } FangYar.BLL.OA_LEAVE leaveBll = new FangYar.BLL.OA_LEAVE(); string where = null; where = "(PPL_ID = '" + uid + "' or PPL_ID = 'u_" + uid + "') "; if (!string.IsNullOrEmpty(keyword)) { where += " and (L_OUT like '" + keyword + "' or L_REASON like '" + keyword + "') "; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = leaveBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = leaveBll.QueryList(pageIndex, pageSize, where, " s_time desc"); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += ",\"newDate\":\"" + DateTime.Now.ToString() + "\"}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "请假记录列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "请假记录列表"); return returnstr; } #endregion #region 获取请假信息、流转记录 //获取请假信息、流转记录 private string AppGetLeaveModelByLeaveId(HttpContext context) { string returnstr = ""; try { string leaveId = context.Request.Params["leaveId"]; returnstr = "{\"code\":0,\"msg\":\"\",\"leaveData\":"; FangYar.BLL.OA_LEAVE leaveBll = new FangYar.BLL.OA_LEAVE(); List data = leaveBll.getLeave(leaveId); returnstr += FangYar.Common.JsonHelper.ToJson(data[0]); returnstr += ",\"waitData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data[1]); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"leaveData\":[],\"waitData\":[] }"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取请假信息、流转记录异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取请假信息、流转记录"); return returnstr; } #endregion #region 公差记录列表 //公差记录列表 private string AppGetToleranceListByUid(HttpContext context) { string returnstr = ""; try { string uid = context.Request.Params["uid"]; string keyword = context.Request.Params["keywords"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } FangYar.BLL.OA.OA_TOLERANCE toleranceBll = new FangYar.BLL.OA.OA_TOLERANCE(); string where = null; where = "(PPL_ID = '" + uid + "' or PPL_ID = 'u_" + uid + "') "; if (!string.IsNullOrEmpty(keyword)) { where += " and (L_OUT like '" + keyword + "' or L_REASON like '" + keyword + "') "; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = toleranceBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = toleranceBll.QueryList(pageIndex, pageSize, where, " s_time desc"); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "公差记录列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "公差记录列表"); return returnstr; } //本单位公差记录列表 private string AppGetToleranceListByOrgId(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["orgid"]; string keyword = context.Request.Params["keywords"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } FangYar.BLL.OA.OA_TOLERANCE toleranceBll = new FangYar.BLL.OA.OA_TOLERANCE(); string where = null; where = " PPL_ID in ( select USERS_UID from TBL_SYS_EMP where IS_ADMIN='0' and (org_id ='" + OrgId + "' or DEPT_ID='" + OrgId + "' ) ) "; if (!string.IsNullOrEmpty(keyword)) { where += " and (PPL_NAME like '%" + keyword + "%' or TITLE like '%" + keyword + "%' or L_OUT like '%" + keyword + "' or L_REASON like '%" + keyword + "%') "; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = toleranceBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = toleranceBll.QueryList(pageIndex, pageSize, where, " s_time desc"); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "本单位公差记录列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "本单位公差记录列表"); return returnstr; } /// /// 公差统计 /// /// /// private string AppGetToleranceSta(HttpContext context) { string returnstr = ""; try { string org_id = context.Request.Params["org_id"];//机构id string stime = context.Request.Params["stime"];//stime string etime = context.Request.Params["etime"];//etime string islower = context.Request.Params["islower"];//islower 0 本级 1多级 string sql = ""; returnstr = "{\"code\":0,\"msg\":\"\""; sql += " with t1 as( "; sql += " SELECT o.L_TYPE,e.ORG_ID,o.S_TIME,o.E_TIME from OA_TOLERANCE o LEFT JOIN tbl_sys_emp e on e.IS_ADMIN='0' and o.ppl_id = e.users_uid "; sql += " WHERE date_format('" + stime + "', '%Y-%m-%d %H:%i:%s') <= date_format(o.S_TIME, '%Y-%m-%d %H:%i:%s') "; sql += " and date_format('" + etime + "', '%Y-%m-%d %H:%i:%s') >= date_format(o.E_TIME, '%Y-%m-%d %H:%i:%s') "; sql += " ),t2 as( "; sql += " SELECT ORG_ID,sum(case L_TYPE when 'ee62a186-336f-4984-b650-fd9826ad82cd' then 1 else 0 end) incar "; sql += " ,sum(case L_TYPE when '33a0821a-c264-44be-8da3-70a4077e933e' then 1 else 0 end) innocar "; sql += " ,sum(case L_TYPE when '6bba0521-37e7-4c30-9bcd-971815ac6168' then 1 else 0 end) outcar "; sql += " ,sum(case L_TYPE when '48137282-3373-4da0-836f-fd223849a85f' then 1 else 0 end) outnocar "; sql += " from t1 GROUP BY ORG_ID),t4 as( "; if (islower == "1") { sql += " SELECT * from fire_org,(select get_Org_child_list('" + org_id + "') cids ) s WHERE find_in_set(org_id,cids) and type = '0' "; } else if (islower == "0") { sql += "SELECT * from fire_org WHERE ORG_ID='" + org_id + "' "; } sql += " )SELECT t4.ORG_ID,t4.ORG_NAME,IFNULL(t2.INCAR,0) INCAR,IFNULL(t2.INNOCAR,0) INNOCAR,IFNULL(t2.OUTCAR,0) OUTCAR,IFNULL(t2.OUTNOCAR,0) OUTNOCAR from t4 LEFT JOIN t2 on t4.ORG_ID=t2.ORG_ID "; sql += " order by t4.ORG_ID = '" + org_id + "' desc"; returnstr += ",\"Data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(new CommomBLL().GetTableList(sql)); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "公差统计异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "公差统计"); return returnstr; } #endregion #region 获取公差信息、流转记录 //获取公差信息、流转记录 private string AppGetToleranceModelByToleranceId(HttpContext context) { string returnstr = ""; try { string toleranceId = context.Request.Params["toleranceId"]; returnstr = "{\"code\":0,\"msg\":\"\",\"toleranceData\":"; FangYar.BLL.OA.OA_TOLERANCE toleranceBll = new FangYar.BLL.OA.OA_TOLERANCE(); List data = toleranceBll.getTolerance(toleranceId); returnstr += FangYar.Common.JsonHelper.ToJson(data[0]); returnstr += ",\"waitData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data[1]); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"toleranceData\":[],\"waitData\":[] }"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取公差信息、流转记录异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取公差信息、流转记录"); return returnstr; } #endregion #region 人员报警列表查询 //人员报警列表查询 private string AppGetAlarmEmpListByOrgId(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TBL_ALARMDATA alarmBll = new FangYar.BLL.TBL_ALARMDATA(); string OrgId = context.Request.Params["orgId"]; string sTime = context.Request.Params["sTime"]; string eTime = context.Request.Params["eTime"]; string type = context.Request.Params["type"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } string where = " ALARM_TYPE='1' "; if (!string.IsNullOrEmpty(OrgId)) { where += " and (ORG_ID ='" + OrgId + "' or ORG_ID in (select o.org_id from fire_org o where o.pid = '" + OrgId + "') )"; } if (!string.IsNullOrEmpty(sTime)) { where += " and TIME >= date_format('" + sTime + "','%Y-%m-%d')"; } if (!string.IsNullOrEmpty(eTime)) { where += " and TIME <= date_format('" + eTime + "','%Y-%m-%d')"; } if (!string.IsNullOrEmpty(type)) { where += " and EXTENDCODE1 = '" + type + "'"; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = alarmBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { DataTable dt = alarmBll.GetListByPage(where, " TIME desc ", (pageIndex - 1) * pageSize, pageSize).Tables[0]; returnstr += FangYar.Common.JsonHelper.ToJson(dt); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "人员报警列表查询异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "人员报警列表查询"); return returnstr; } //人员报警列表查询(待审批) private string AppGetAlarmEmpListByOrgIdApprovalState(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TBL_ALARMDATA alarmBll = new FangYar.BLL.TBL_ALARMDATA(); string OrgId = context.Request.Params["orgId"]; string sTime = context.Request.Params["sTime"]; string eTime = context.Request.Params["eTime"]; string type = context.Request.Params["type"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } string where = " ALARM_TYPE='1' and state = '0' "; if (!string.IsNullOrEmpty(OrgId)) { where += " and (ORG_ID ='" + OrgId + "' or ORG_ID in (select o.org_id from fire_org o where o.pid = '" + OrgId + "') )"; } if (!string.IsNullOrEmpty(sTime)) { where += " and TIME >= date_format('" + sTime + "','%Y-%m-%d')"; } if (!string.IsNullOrEmpty(eTime)) { where += " and TIME <= date_format('" + eTime + "','%Y-%m-%d')"; } if (!string.IsNullOrEmpty(type)) { where += " and EXTENDCODE1 = '" + type + "'"; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = alarmBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { DataTable dt = alarmBll.GetListByPage(where, " TIME desc ", (pageIndex - 1) * pageSize, pageSize).Tables[0]; returnstr += FangYar.Common.JsonHelper.ToJson(dt); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "人员报警列表查询异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "人员报警列表查询"); return returnstr; } //审批人员报警 private string AppUpdateAlarmEmpStateByOrgId(HttpContext context) { string returnstr = "", msg = "审批失败!"; int code = 0; try { string id = context.Request.Params["id"]; string OPINION = context.Request.Params["OPINION"]; string sql = " update tbl_alarmdata set state='1',OPINION='"+ OPINION + "' where id='" + id + "' "; var n1 = FangYar.Common.MySqlHelper.Execute(sql); if (n1 > 0) { msg = "审批成功!"; code = 1; } else { msg = "审批失败!"; } } catch(Exception e) { } returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}"; return returnstr; } #endregion #region 车辆报警列表查询 //车辆报警列表查询 private string AppGetAlarmCarListByOrgId(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TBL_ALARMDATA alarmBll = new FangYar.BLL.TBL_ALARMDATA(); string OrgId = context.Request.Params["orgId"]; string keywords = context.Request.Params["keywords"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } string where = " ALARM_TYPE='2' "; if (!string.IsNullOrEmpty(OrgId)) { where += " and (ORG_ID ='" + OrgId + "' or ORG_ID in (select o.org_id from fire_org o where o.pid = '" + OrgId + "') )"; } if (!string.IsNullOrEmpty(keywords)) { where += " and CAR_NUM like '%" + keywords + "%'"; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = alarmBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { DataTable dt = alarmBll.GetListByPage(where, " TIME desc ", (pageIndex - 1) * pageSize, pageSize).Tables[0]; returnstr += FangYar.Common.JsonHelper.ToJson(dt); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "车辆报警列表查询异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "车辆报警列表查询"); return returnstr; } #endregion #region 访客登记列表 //访客登记列表 private string AppGetVisitorRegListByUid(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["OrgId"]; string userId = context.Request.Params["userId"]; string sTime = context.Request.Params["sTime"]; string eTime = context.Request.Params["eTime"]; string keyword = context.Request.Params["keywords"]; string state = context.Request.Params["state"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } string where = " state>=0 "; if (!string.IsNullOrEmpty(OrgId)) { where += " and ORG_ID ='" + OrgId + "'"; } if (!string.IsNullOrEmpty(userId)) { if (where != null) { where += " and "; } where += " VED_ID ='" + userId + "'"; } if (!string.IsNullOrEmpty(sTime)) { if (where != null) { where += " and "; } where += " date_format(APPROVALTIME,'%Y-%m-%d %H:%i:%s') >= date_format('" + sTime + "','%Y-%m-%d %H:%i:%s')"; } if (!string.IsNullOrEmpty(eTime)) { if (where != null) { where += " and "; } where += " date_format(APPROVALTIME,'%Y-%m-%d %H:%i:%s') <= date_format('" + eTime + "','%Y-%m-%d %H:%i:%s')"; } if (!string.IsNullOrEmpty(keyword)) { if (where != null) { where += " and "; } where += " name like '%" + keyword + "%' "; } FangYar.BLL.OA.TBL_VISITOR_REG visBll = new FangYar.BLL.OA.TBL_VISITOR_REG(); returnstr = "{\"code\":0,\"msg\":\"\","; int count = visBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = visBll.QueryList(pageIndex, pageSize, where, " state, REGISTERTIME desc"); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "车辆报警列表查询异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "车辆报警列表查询"); return returnstr; } #endregion #region 访客登记单处理 //访客登记单处理 private string AppVisitorRegHandle(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { string visId = context.Request.Params["visId"]; string state = context.Request.Params["state"]; string feedbackinfo = context.Request.Params["feedbackinfo"]; FangYar.BLL.OA.TBL_VISITOR_REG visBll = new FangYar.BLL.OA.TBL_VISITOR_REG(); FangYar.Model.OA.TBL_VISITOR_REG vrmodel = new FangYar.Model.OA.TBL_VISITOR_REG(); vrmodel.ID = visId; vrmodel.STATE = state; if (feedbackinfo == "" || feedbackinfo == null) { if (state == "1") { feedbackinfo = "同意"; } else if (state == "2") { feedbackinfo = "不同意"; } } vrmodel.FEEDBACKINFO = feedbackinfo; if (visBll.editVisReg(vrmodel)) { if (state == "1") { WebCommon.HttpUtil.VisitorRegEmpower(visId); } msg = "审批成功!"; code = 1; } else { msg = "审批失败!"; } } catch (Exception e) { msg = "审批失败!"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "访客登记单处理异常:" + e); } returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "APP操作请求", "访客登记单处理"); return returnstr; } #endregion #region 用车记录列表 //用车记录列表 private string AppGetCarApplyListByUid(HttpContext context) { string returnstr = ""; try { string uid = context.Request.Params["uid"]; string name = context.Request.Params["name"]; string phone = context.Request.Params["phone"]; string carNum = context.Request.Params["carNum"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } FangYar.BLL.TBL_SYS_CARAPPLY carBll = new FangYar.BLL.TBL_SYS_CARAPPLY(); string where = null; where = "(USERID = '" + uid + "' or USERID = 'u_" + uid + "') "; if (!string.IsNullOrEmpty(name)) { where += " and USERNAME like '%" + name + "%' "; } if (!string.IsNullOrEmpty(phone)) { where += " and USERPHONE like '%" + phone + "%' "; } if (!string.IsNullOrEmpty(carNum)) { where += " and CARNUM like '%" + carNum + "%' "; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = carBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = carBll.QueryList(pageIndex, pageSize, where, " STARTTIME desc"); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "用车记录列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "用车记录列表"); return returnstr; } //用车记录列表——根据机构ID获取 private string AppGetCarApplyListByOrgId(HttpContext context) { string returnstr = ""; try { string Orgid = context.Request.Params["org_id"]; string keywords = context.Request.Params["keywords"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; string startTime = context.Request.Params["stime"]; string endTime = context.Request.Params["etime"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } //string strOrg = " ( ORG_ID = '" + Orgid + "' )"; string where = " USERID in ( SELECT USERS_UID from tbl_sys_emp WHERE ( org_id ='" + Orgid + "' or DEPT_ID='" + Orgid + "' ) ) "; if (!string.IsNullOrEmpty(keywords)) { where += " and ( USERNAME like '%" + keywords + "%' or TITLE like '%" + keywords + "%' or carnum like '%" + keywords + "%' ) "; } if (!string.IsNullOrEmpty(startTime)) { if (!startTime.Contains("请选择")) { where += " and STARTTIME >= date_format('" + startTime + "','%Y-%m-%d %H:%i:%s')"; } } if (!string.IsNullOrEmpty(endTime)) { if (!endTime.Contains("请选择")) { where += " and STARTTIME <= date_format('" + endTime + "','%Y-%m-%d %H:%i:%s')"; } } //string where1 = " and state = '1' and extendcode2 = '2' "; FangYar.BLL.TBL_SYS_CARAPPLY carBll = new FangYar.BLL.TBL_SYS_CARAPPLY(); returnstr = "{\"code\":0,\"msg\":\"\","; int count = carBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { //string where2 = " and t.state = '1' order by starttime desc"; DataTable dt = carBll.QueryTable(pageIndex, pageSize, where, " starttime desc "); returnstr += FangYar.Common.JsonHelper.ToJson(dt); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "用车记录列表——根据机构ID获取异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "用车记录列表——根据机构ID获取"); return returnstr; } //删除审批失败的用车申请记录 private string AppDeleteCarApplyById(HttpContext context) { string returnstr = ""; try { string id = context.Request.Params["id"]; FangYar.BLL.TBL_SYS_CARAPPLY carBll = new FangYar.BLL.TBL_SYS_CARAPPLY(); if (carBll.DeleteCarApplyById(id)) { returnstr += "{\"code\":0,\"msg\":\"删除成功!\",\"count\":0,\"data\":[]}"; } else { returnstr = "{\"code\":-1,\"msg\":\"删除失败!\",\"count\":0,\"data\":[]}"; } } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "删除审批失败的用车申请记录异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "APP操作请求", "删除审批失败的用车申请记录"); return returnstr; } #endregion #region 获取用车信息、流转记录 //获取用车信息、流转记录 private string AppGetCarApplyModelByCarApplyId(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TBL_SYS_CARAPPLY carBll = new FangYar.BLL.TBL_SYS_CARAPPLY(); string id = context.Request.Params["carApplyId"]; returnstr = "{\"code\":0,\"msg\":\"\",\"applyData\":"; List data = carBll.getCarApply(id); returnstr += FangYar.Common.JsonHelper.ToJson(data[0]); returnstr += ",\"waitData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data[1]); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"toleranceData\":[],\"waitData\":[] }"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取用车信息、流转记录异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取用车信息、流转记录"); return returnstr; } #endregion #region 获取访客一周数量趋势 //获取访客一周数量趋势 private string AppGetVisitorWeekByOrgId(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TBL_VISITOR visBll = new FangYar.BLL.TBL_VISITOR(); returnstr = "{\"code\":1,\"msg\":\"\","; returnstr += "\"data\":"; string orgId = context.Request.Params["orgId"]; //增加上级转换机关机构数据转换 orgId = Common.WebCommonUtil.GetOrgIdUpLevelToDownLevel(orgId); string where = "1=1"; where += " and (ORG_ID ='" + orgId + "' or ORG_ID in (select o.org_id from fire_org o where o.pid = '" + orgId + "') )"; returnstr += JsonConvert.SerializeObject(visBll.TotalDaysAlarm(7, where)); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取访客一周数量趋势异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取访客一周数量趋势"); return returnstr; } #endregion #region 获取人员一周数量趋势 //获取人员一周数量趋势 private string AppGetPerAccWeekByOrgId(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TBL_PERSONACCESS perBll = new FangYar.BLL.TBL_PERSONACCESS(); returnstr = "{\"code\":1,\"msg\":\"\","; returnstr += "\"data\":"; string orgId = context.Request.Params["orgId"]; //增加上级转换机关机构数据转换 orgId = Common.WebCommonUtil.GetOrgIdUpLevelToDownLevel(orgId); string where = "1=1"; where += " and id in ( select ID from TBL_PERSONACCESS ,(select get_Org_child_list('" + orgId + "') cids ) s where find_in_set(org_id,cids) and START_TIME > DATE_SUB(NOW(), INTERVAL 8 DAY) and EXTEND3 in (SELECT EPUIP_ID from tbl_epuip_org WHERE ORG_ID = '" + orgId + "' and IS_Attendance = '0') ) "; returnstr += JsonConvert.SerializeObject(perBll.TotalDaysAlarm(7, where)); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取人员一周数量趋势异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取人员一周数量趋势"); return returnstr; } #endregion #region 获取车辆一周数量趋势 //获取车辆一周数量趋势 private string AppGetCarAccWeekByOrgId(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TBL_CARACCESS carBll = new BLL.TBL_CARACCESS(); string orgId = context.Request.Params["orgId"]; //增加上级转换机关机构数据转换 orgId = Common.WebCommonUtil.GetOrgIdUpLevelToDownLevel(orgId); returnstr = "{\"code\":1,\"msg\":\"\""; returnstr += ",\"InData\":"; string where = " INOROUT = '0' and (ORG_ID ='" + orgId + "' or ORG_ID in (select o.org_id from fire_org o where o.pid = '" + orgId + "') )"; returnstr += JsonConvert.SerializeObject(carBll.TotalDaysAlarm(7, where)); returnstr += ",\"OutData\":"; string where1 = " INOROUT = '1' and (ORG_ID ='" + orgId + "' or ORG_ID in (select o.org_id from fire_org o where o.pid = '" + orgId + "') )"; returnstr += JsonConvert.SerializeObject(carBll.TotalDaysAlarm(7, where1)); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取车辆一周数量趋势异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取车辆一周数量趋势"); return returnstr; } #endregion #region 获取可用车辆列表 //获取可用车辆列表 private string AppGetCarNumListByOrgId(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["OrgId"]; FangYar.BLL.TBL_SYS_CAR carBll = new FangYar.BLL.TBL_SYS_CAR(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; DataTable data = carBll.getCarNumListByOrgId(orgId); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取可用车辆列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取可用车辆列表"); return returnstr; } #endregion #region 岗哨交接 //根据orgid获取岗哨记录 private string AppGetShiftsListByOrgId(HttpContext context) { string returnstr = ""; try { FangYar.BLL.FIRE.FIRE_SHIFTS shiftsBll = new FangYar.BLL.FIRE.FIRE_SHIFTS(); string orgId = context.Request.Params["orgId"]; string ifid = context.Request.Params["ifid"]; string state = context.Request.Params["state"]; string keyword = context.Request.Params["keywords"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } string where = ""; if (!string.IsNullOrEmpty(orgId)) { where += " ORG_ID ='" + orgId + "'"; } else { return returnstr = "{\"code\":0,\"msg\":\"未查询到机构下数据\",\"count\":0,\"data\":[]}"; } if (!string.IsNullOrEmpty(ifid)) { where += " and EXTENDCODE3='" + ifid + "'"; } if (!string.IsNullOrEmpty(state)) { where += " and TO_STATE='" + state + "'"; } if (!string.IsNullOrEmpty(keyword)) { where += " and (O_NAME like '%" + keyword + "%' or T_NAME like '%" + keyword + "%')"; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = shiftsBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = shiftsBll.QueryList(pageIndex, pageSize, where, ""); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据orgid获取岗哨记录异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据orgid获取岗哨记录"); return returnstr; } //根据uid获取上岗任务 private string AppGetShiftsListByUserUid(HttpContext context) { string returnstr = ""; try { FangYar.BLL.FIRE.FIRE_SHIFTS shiftsBll = new FangYar.BLL.FIRE.FIRE_SHIFTS(); string uid = context.Request.Params["uid"]; returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; DataTable dt = shiftsBll.getShiftsListByState(uid, "0", " TO_STATE, O_DATE DESC "); returnstr += FangYar.Common.JsonHelper.ToJson(dt); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据uid获取上岗任务异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据uid获取上岗任务"); return returnstr; } //根据uid获取历史上岗记录 private string AppGetShiftsHistoryListByOrgId(HttpContext context) { string returnstr = ""; try { FangYar.BLL.FIRE.FIRE_SHIFTS shiftsBll = new FangYar.BLL.FIRE.FIRE_SHIFTS(); string uid = context.Request.Params["uid"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } string where = " find_in_set(CONCAT(',' , '" + uid + "' , ','),CONCAT(',' , O_UID , ','))<> 0 and TO_STATE in (1,2,3) "; returnstr = "{\"code\":0,\"msg\":\"\","; int count = shiftsBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { where += " order by o_date desc"; List list = shiftsBll.QueryList(pageIndex, pageSize, where, " TO_STATE, O_DATE DESC "); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据uid获取历史上岗记录异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据uid获取历史上岗记录"); return returnstr; } //根据条件判断是否允许上岗,返回当前在岗人信息 private string AppGetShiftsIsDutyByIFID(HttpContext context) { string returnstr = ""; try { FangYar.BLL.FIRE.FIRE_SHIFTS shiftsBll = new FangYar.BLL.FIRE.FIRE_SHIFTS(); string id = context.Request.Params["id"]; string ifid = context.Request.Params["ifid"]; FangYar.Model.FIRE.FIRE_SHIFTS model = shiftsBll.GetModel(id); if (model == null) { return "{\"code\":-1,\"msg\":\"未查询到该任务\"}"; } System.DateTime oDate = Convert.ToDateTime(model.O_DATE.ToString()); System.DateTime startTime = oDate.AddMinutes(-20); System.DateTime endTime = oDate.AddMinutes(+15); System.DateTime newTime = System.DateTime.Now; if (ifid == model.EXTENDCODE3) { if (startTime <= newTime && endTime >= newTime) { returnstr = "{\"code\":0,\"data\":"; DataTable dt = shiftsBll.getPreviousShiftsModel(ifid, model.O_DATE.ToString(), model.T_DATE.ToString()); returnstr += FangYar.Common.JsonHelper.ToJson(dt); returnstr += ",\"isDuty\":0}"; } else if (endTime < newTime && model.T_DATE > newTime) { returnstr = "{\"code\":0,\"data\":"; DataTable dt = shiftsBll.getPreviousShiftsModel(ifid, model.O_DATE.ToString(), model.T_DATE.ToString()); returnstr += FangYar.Common.JsonHelper.ToJson(dt); returnstr += ",\"isDuty\":1}"; } else if (model.T_DATE < newTime) { returnstr = "{\"code\":-3,\"msg\":\"您已缺岗,请返回任务填写缺岗理由!\"}"; } else { returnstr = "{\"code\":-4,\"msg\":\"还未到上岗时间,无法上岗!\"}"; } } else { returnstr = "{\"code\":-2,\"msg\":\"信息不匹配无法上岗!\"}"; } } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据条件判断是否允许上岗,返回当前在岗人信息异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据条件判断是否允许上岗,返回当前在岗人信息"); return returnstr; } //修改交接岗位状态 private string AppUpdateShiftsByID(HttpContext context) { string returnstr = ""; try { FangYar.BLL.FIRE.FIRE_SHIFTS shiftsBll = new FangYar.BLL.FIRE.FIRE_SHIFTS(); string id = context.Request.Params["id"]; string tName = context.Request.Params["tName"]; string toWork = context.Request.Params["toWork"]; string upid = context.Request.Params["upid"]; string uid = context.Request.Params["uid"]; string uName = context.Request.Params["uname"]; System.DateTime toDate = System.DateTime.Now; System.DateTime time = toDate.AddMinutes(-15); FangYar.Model.FIRE.FIRE_SHIFTS model = shiftsBll.GetModel(id); if (model == null) { return "{\"code\":-1,\"msg\":\"未查询到该任务\"}"; } if (model.EXTENDCODE5 == "" || model.EXTENDCODE5 == null) { model.EXTENDCODE5 = uid; } else { model.EXTENDCODE5 += "," + uid; } ArrayList oUids = new ArrayList(model.O_UID.Split(',')); ArrayList EXTENDCODE4s = new ArrayList(model.EXTENDCODE5.Split(',')); for (int i = 0; i < oUids.Count; i++) { for (int y = 0; y < EXTENDCODE4s.Count; y++) { var a = oUids[i].ToString(); var b = EXTENDCODE4s[y].ToString(); if (oUids[i].ToString() == EXTENDCODE4s[y].ToString()) { oUids.RemoveAt(i); } } } if (String.IsNullOrEmpty(model.TO_WORK)) { model.TO_WORK = uName + ":" + toWork; } else { model.TO_WORK += "
" + uName + ":" + toWork; } if (String.IsNullOrEmpty(model.T_NAME)) { model.T_NAME = tName; } else { model.T_NAME += "," + tName; } if (String.IsNullOrEmpty(model.TO_PHOTO)) { model.TO_PHOTO = AddPhotoWatermark("FireShifts", context, "U_" + id); } else { model.TO_PHOTO += "," + AddPhotoWatermark("FireShifts", context, "U_" + id); } if (oUids.Count == 0) { model.T_NAME = tName; model.TO_DATE = toDate; if (time < model.O_DATE) { model.TO_STATE = "2"; } else { model.TO_STATE = "1"; } } if (upid != null && upid != "") { if (upid.Contains(",")) { string[] upids = upid.Split(','); for (int i = 0; i < upids.Length; i++) { FangYar.Model.FIRE.FIRE_SHIFTS model2 = shiftsBll.GetModel(upids[i]); model2.TO_TIME = toDate.ToString(); shiftsBll.Update(model2); } } else { FangYar.Model.FIRE.FIRE_SHIFTS model2 = shiftsBll.GetModel(upid); model2.TO_TIME = toDate.ToString(); shiftsBll.Update(model2); } } if (shiftsBll.Update(model)) { returnstr = "{\"code\":0,\"msg\":\"交接成功!\"}"; } else { returnstr = "{\"code\":-2,\"msg\":\"交接失败!\"}"; } } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "修改交接岗位状态异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "APP操作请求", "修改交接岗位状态"); return returnstr; } //修改缺岗(超期的)交接岗位状态 private string AppUpdateShiftsOverdueByID(HttpContext context) { string returnstr = ""; try { FangYar.BLL.FIRE.FIRE_SHIFTS shiftsBll = new FangYar.BLL.FIRE.FIRE_SHIFTS(); string id = context.Request.Params["id"]; string tName = context.Request.Params["tName"]; string toWork = context.Request.Params["toWork"]; System.DateTime toDate = System.DateTime.Now; FangYar.Model.FIRE.FIRE_SHIFTS model = shiftsBll.GetModel(id); model.T_NAME = tName; model.TO_WORK = toWork; model.TO_DATE = toDate; model.TO_TIME = toDate.ToString(); model.TO_STATE = "3"; if (shiftsBll.Update(model)) { returnstr = "{\"code\":0,\"msg\":\"已办结!\"}"; } else { returnstr = "{\"code\":-2,\"msg\":\"办结失败!\"}"; } } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "修改缺岗(超期的)交接岗位状态异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "APP操作请求", "修改缺岗(超期的)交接岗位状态"); return returnstr; } //根据机构ID获取所有下级机构 private string AppGetOrgListByOrgId(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["OrgId"]; FangYar.BLL.FIRE.FIRE_ORG bll = new FangYar.BLL.FIRE.FIRE_ORG(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; List data = bll.GetOrgListTreeByOrgId(orgId); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据机构ID获取所有下级机构异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据机构ID获取所有下级机构"); return returnstr; } //根据rfid获取当前在岗、下次上岗人信息 private string AppGetShiftsOnDutyByRFID(HttpContext context) { string returnstr = ""; try { FangYar.BLL.FIRE.FIRE_SHIFTS shiftsBll = new FangYar.BLL.FIRE.FIRE_SHIFTS(); string rfid = context.Request.Params["ifid"]; string newTime = DateTime.Now.ToString(); returnstr = "{\"code\":0,\"onDuty\":"; FangYar.Model.FIRE.FIRE_SHIFTS model = shiftsBll.GetModelByRfid(rfid, newTime); if (model == null) { returnstr += "\"\""; } else { returnstr += FangYar.Common.JsonHelper.ToJson(model); } returnstr += ",\"nextDuty\":"; FangYar.Model.FIRE.FIRE_SHIFTS model2 = shiftsBll.GetNextModelByRfid(rfid, newTime); if (model2 == null) { returnstr += "\"\""; } else { returnstr += FangYar.Common.JsonHelper.ToJson(model2); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\",\"onDuty\":\"{}\",\"nextDuty\":\"{}\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据rfid获取当前在岗、下次上岗人信息异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据rfid获取当前在岗、下次上岗人信息"); return returnstr; } //根据岗哨表ID替换上岗人信息 private string AppUpdateShiftsDutyByID(HttpContext context) { string returnstr = ""; try { FangYar.BLL.FIRE.FIRE_SHIFTS shiftsBll = new FangYar.BLL.FIRE.FIRE_SHIFTS(); string id = context.Request.Params["id"]; string ifid = context.Request.Params["ifid"]; string olduid = context.Request.Params["olduid"]; string newuid = context.Request.Params["newuid"]; string oldname = context.Request.Params["oldname"]; string newname = context.Request.Params["newname"]; string oldfpr = context.Request.Params["oldfpr"]; string newfpr = context.Request.Params["newfpr"]; if (shiftsBll.UpdateDuty(id, olduid, newuid, oldname, newname, oldfpr, newfpr)) { return AppGetShiftsIsDutyByIFID(context); } else { returnstr = "{\"code\":-5,\"msg\":\"替班失败!\"}"; } } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据岗哨表ID替换上岗人信息异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "APP操作请求", "根据岗哨表ID替换上岗人信息"); return returnstr; } #endregion 岗哨交接 #region 安防报警 //根据机构ID、报警类型、时间、地点获取报警列表 private string AppGetAlarmDataListByOrgId(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TBL_ALARMDATA bll = new FangYar.BLL.TBL_ALARMDATA(); string OrgId = context.Request.Params["OrgId"]; string type = context.Request.Params["type"]; string startTime = context.Request.Params["startTime"]; string endTime = context.Request.Params["endTime"]; string addr = context.Request.Params["addr"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; int.TryParse(page, out pageIndex); int.TryParse(limit, out pageSize); //if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } //if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } pageIndex = pageIndex < 1 ? 1 : pageIndex; pageSize = pageSize < 1 ? 1 : pageSize; string sql = "WITH t1 as ( SELECT * from tbl_alarmdata ,(select get_Org_child_list('" + OrgId + "') cids ) s "; string where = ""; if (!string.IsNullOrEmpty(OrgId)) { where = " where find_in_set(org_id,cids) "; } else { return returnstr = "{\"code\":0,\"msg\":\"未查询到机构下数据\",\"count\":0,\"data\":[]}"; } if (!string.IsNullOrEmpty(type)) { where += " and TYPE='" + type + "' "; } if (!string.IsNullOrEmpty(startTime)) { where += " and time >= date_format('" + startTime + " 00:00:00','%Y-%m-%d %H:%i:%s')"; } if (!string.IsNullOrEmpty(endTime)) { where += " and time <= date_format('" + endTime + " 23:59:59','%Y-%m-%d %H:%i:%s')"; } if (!string.IsNullOrEmpty(addr)) { where += " and ADDR like '%" + addr + "%' "; } returnstr = "{\"code\":0,\"msg\":\"\","; string countSql = "select count(1) FROM TBL_ALARMDATA,(select get_Org_child_list('" + OrgId + "') cids ) s "; int count = FangYar.Common.MySqlHelper.GetCount(countSql + where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { DataTable list = FangYar.Common.MySqlHelper.QueryTable(sql + where + " ORDER BY TIME desc LIMIT " + ((pageIndex - 1) * pageSize) + ", " + pageSize + " ) SELECT j.*, k.org_name from t1 j LEFT JOIN fire_org k on j.org_id = k.org_id"); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据机构ID、报警类型、时间、地点获取报警列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据机构ID、报警类型、时间、地点获取报警列表"); return returnstr; } #endregion 安防报警 #region 巡查巡检 //根据机构ID、巡查点类型、名称、地点 获取营区内巡查点列表 private string AppGetOaPatrolSpotListByOrgId(HttpContext context) { string returnstr = ""; try { FangYar.BLL.OA_PATROL_SPOT bll = new FangYar.BLL.OA_PATROL_SPOT(); string orgId = context.Request.Params["OrgId"]; string keyword = context.Request.Params["keywords"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } string where = null; where = "ORG_ID = '" + orgId + "' "; if (!string.IsNullOrEmpty(keyword)) { where += " and (NAME like '%" + keyword + "%' or ADDR like '%" + keyword + "%') "; } if (!string.IsNullOrEmpty(EXTENDCODE1)) { where += " and EXTENDCODE1 = '" + EXTENDCODE1 + "' "; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = bll.QueryList(pageIndex, pageSize, where, " SORT "); foreach (FangYar.Model.OA_PATROL_SPOT model in list) { JObject EXTENDCODE2_s = JsonConvert.DeserializeObject(model.EXTENDCODE2); string EXTENDCODE21 = ""; int EXTENDCODE21count = 0; if (EXTENDCODE2_s != null) { foreach (JObject EXTENDCODE31obj in EXTENDCODE2_s.Value("data")) { if (EXTENDCODE21count == 0) { EXTENDCODE21 = "" + EXTENDCODE31obj["ppl_Name"]; } else { EXTENDCODE21 += "," + EXTENDCODE31obj["ppl_Name"]; } EXTENDCODE21count++; } } model.EXTENDCODE21 = EXTENDCODE21; } returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据机构ID、巡查点类型、名称、地点 获取营区内巡查点列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据机构ID、巡查点类型、名称、地点 获取营区内巡查点列表"); return returnstr; } //根据主键ID得到一个对象实体 private string AppGetOaPatrolSpotModelById(HttpContext context) { string returnstr = ""; try { FangYar.BLL.OA_PATROL_SPOT bll = new FangYar.BLL.OA_PATROL_SPOT(); string ID = context.Request.Params["ID"]; FangYar.Model.OA_PATROL_SPOT model = bll.GetModel(ID); if (model == null) { returnstr = "{}"; } else { returnstr += FangYar.Common.JsonHelper.ToJson(model); } } catch (Exception e) { returnstr = null; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据主键ID得到一个对象实体异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据主键ID得到一个对象实体"); return returnstr; } //根据IFID(芯片编号)得到一个对象实体 private string AppGetOaPatrolSpotModelByRFID(HttpContext context) { string returnstr = ""; try { FangYar.BLL.OA_PATROL_SPOT bll = new FangYar.BLL.OA_PATROL_SPOT(); string ORG_ID = context.Request.Params["ORG_ID"]; string RFID = context.Request.Params["RFID"]; FangYar.Model.OA_PATROL_SPOT model = bll.IFIDGetModel(ORG_ID, RFID); if (model == null) { returnstr = "{}"; } else { returnstr += FangYar.Common.JsonHelper.ToJson(model); } } catch (Exception e) { returnstr = null; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据IFID(芯片编号)得到一个对象实体异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据IFID(芯片编号)得到一个对象实体"); return returnstr; } //添加营区内巡查点信息 private string AppAddOaPatrolSpotModel(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { FangYar.BLL.OA_PATROL_SPOT bll = new FangYar.BLL.OA_PATROL_SPOT(); string spotId = Guid.NewGuid().ToString("N"); string orgId = context.Request.Params["ORG_ID"]; string NAME = context.Request.Params["NAME"]; string SPOT_NO = context.Request.Params["SPOT_NO"]; string POINT = context.Request.Params["POINT"]; string DES = context.Request.Params["DES"]; string ADDR = context.Request.Params["ADDR"]; string STATE = context.Request.Params["STATE"]; string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"]; string EXTENDCODE2 = context.Request.Params["EXTENDCODE2"]; string SORT = context.Request.Params["SORT"]; //巡查点表 FangYar.Model.OA_PATROL_SPOT model = new Model.OA_PATROL_SPOT(); model.ID = spotId; model.NAME = NAME; model.SPOT_NO = SPOT_NO; model.POINT = POINT; model.DES = DES; model.ADDR = ADDR; model.ORG_ID = orgId; model.STATE = STATE; model.SORT = SORT; model.EXTENDCODE1 = EXTENDCODE1; model.EXTENDCODE2 = EXTENDCODE2; model.PHOTO = UploadFile("OaPatrolSpot", context, spotId); bool a = bll.ExistsSpotNo(SPOT_NO); if (a == true) { msg = "对不起,该芯片编号已经存在"; } else { if (bll.Add(model)) { msg = "添加成功!"; code = 1; } else { msg = "添加失败!"; } } } catch (Exception e) { msg = "添加失败!"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "添加营区内巡查点信息异常:" + e); } returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP操作请求", "添加营区内巡查点信息"); return returnstr; } //修改营区内巡查点信息 private string AppEditOaPatrolSpotModel(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { FangYar.BLL.OA_PATROL_SPOT bll = new FangYar.BLL.OA_PATROL_SPOT(); string ID = context.Request.Params["ID"]; string orgId = context.Request.Params["ORG_ID"]; string NAME = context.Request.Params["NAME"]; string SPOT_NO = context.Request.Params["SPOT_NO"]; string POINT = context.Request.Params["POINT"]; string DES = context.Request.Params["DES"]; string ADDR = context.Request.Params["ADDR"]; string STATE = context.Request.Params["STATE"]; string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"]; string EXTENDCODE2 = context.Request.Params["EXTENDCODE2"]; string SORT = context.Request.Params["SORT"]; string oldimgs = context.Request.Params["oldimgs"]; //巡查点表 FangYar.Model.OA_PATROL_SPOT model = new Model.OA_PATROL_SPOT(); model.ID = ID; model.NAME = NAME; model.SPOT_NO = SPOT_NO; model.POINT = POINT; model.DES = DES; model.ADDR = ADDR; model.ORG_ID = orgId; model.STATE = STATE; model.SORT = SORT; model.EXTENDCODE1 = EXTENDCODE1; model.EXTENDCODE2 = EXTENDCODE2; if (oldimgs == "") { model.PHOTO = UploadFile("OaPatrolSpot", context, Guid.NewGuid().ToString("N")); } else { string newimg = UploadFile("OaPatrolSpot", context, Guid.NewGuid().ToString("N")); if (newimg == "") { model.PHOTO = oldimgs; } else { model.PHOTO = oldimgs + "," + newimg; } } if (bll.Update(model)) { msg = "修改成功!"; code = 1; } else { msg = "修改失败!"; } } catch (Exception e) { if (e.Message.ToString().IndexOf("违反唯一约束条件") > -1) { msg = "芯片编号重复!"; } else { msg = "修改失败!"; } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "修改营区内巡查点信息异常:" + e); } returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "APP操作请求", "修改营区内巡查点信息"); return returnstr; } #endregion 巡查巡检 #region 物资管理 //根据机构ID、名称、编号 获取消防装备列表 private string AppGetFireEpuipListByOrgId(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TBL.SysEmpBLL ebll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.BLL.FIRE.FIRE_EPUIP bll = new FangYar.BLL.FIRE.FIRE_EPUIP(); string OrgId = context.Request.Params["OrgId"]; string isChildren = context.Request.Params["isChildren"]; string keyword = context.Request.Params["keywords"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } string where = ""; if (!string.IsNullOrEmpty(OrgId)) { if (!string.IsNullOrEmpty(isChildren)) { if (isChildren == "false") { where = " org_id = '" + OrgId + "' "; } if (isChildren == "true") { where = " org_id in ( select o.org_id from fire_org o,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids) ) "; } } else { where = " org_id in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids) ) "; } } else { return "{\"code\":0,\"msg\":\"未查询到机构下数据\",\"count\":0,\"data\":[]}"; } if (!string.IsNullOrEmpty(keyword)) { if (where != null) { where += " and "; } where += " (NAME like '%" + keyword + "%' or code like '%" + keyword + "%') "; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = bll.QueryList(pageIndex, pageSize, where, ""); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据机构ID、名称、编号 获取消防装备列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据机构ID、名称、编号 获取消防装备列表"); return returnstr; } //添加消防装备 private string AppAddFireEpuipModel(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { FangYar.BLL.FIRE.FIRE_EPUIP bll = new FangYar.BLL.FIRE.FIRE_EPUIP(); string USER_ID = context.Request.Params["USER_ID"]; string ID = Guid.NewGuid().ToString("N"); string TYPE_ID = context.Request.Params["TYPE_ID"]; string ORG_ID = context.Request.Params["ORG_ID"]; string EQ_NUM = context.Request.Params["EQ_NUM"]; string SENSOR = context.Request.Params["SENSOR"]; string TRADEMARK = context.Request.Params["TRADEMARK"]; string GB_CODE = context.Request.Params["GB_CODE"]; string MANUFACTOR = context.Request.Params["MANUFACTOR"]; string LIABLE = context.Request.Params["LIABLE"]; string STATE = context.Request.Params["STATE"]; //上传图片 string EXTENDCODE1 = UploadFile(context, ID); //消防装备表 FangYar.Model.FIRE.FIRE_EPUIP model = new Model.FIRE.FIRE_EPUIP(); model.ID = ID; model.TYPE_ID = TYPE_ID; model.ORG_ID = ORG_ID; if (!string.IsNullOrEmpty(EQ_NUM)) { model.EQ_NUM = int.Parse(EQ_NUM); } else { model.EQ_NUM = 1; } model.SENSOR = SENSOR; model.TRADEMARK = TRADEMARK; model.GB_CODE = GB_CODE; model.MANUFACTOR = MANUFACTOR; model.LIABLE = LIABLE; model.EXTENDCODE1 = EXTENDCODE1; model.STATE = STATE; model.A_PER = USER_ID; if (bll.AddEpu(model)) { msg = "添加成功!"; code = 1; } else { msg = "添加失败!"; } } catch (Exception e) { msg = "添加失败:装备编码有重复数据"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "添加消防装备异常:" + e); } returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP操作请求", "添加消防装备"); return returnstr; } #endregion 物资管理 #region App日常巡查角标提醒 #region 获取访客待审批数角标提醒 /// /// 获取访客审批数角标提醒 /// /// /// public string AppGetVisitorApplySuperscript(HttpContext context) { string returnstr = ""; int count = 0; try { //GetRecordCount TBL_VISITOR_REG visitorReg = new TBL_VISITOR_REG(); string useruid = context.Request.Params["useruid"]; if (!String.IsNullOrWhiteSpace(useruid)) { string where = string.Format(" 1=1 and state='0' and ved_id='{0}'", useruid); count = visitorReg.GetRecordCount(where); returnstr = "{\"code\":0,\"count\":" + count + ",\"msg\":\"" + "查询成功" + "\"}"; } else { returnstr = "{\"code\":1,\"count\":" + count + ",\"msg\":\"" + "查询条件不能为空" + "\"}"; } } catch (Exception e) { returnstr = "{\"code\":-1,\"count\":" + count + ",\"msg\":\"查询失败\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取访客审批数角标提醒异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取访客审批数角标提醒"); return returnstr; } #endregion #region 获取计划巡查数角标提醒 /// /// 获取计划巡查数角标提醒 /// /// /// public string AppGetProjectPatrolSuperscript(HttpContext context) { OA_PATROL_TASK partolTaskBLL = new OA_PATROL_TASK(); string returnstr = ""; string userid = context.Request.Params["useruid"]; int count = 0; try { if (!string.IsNullOrEmpty(userid)) { string where = string.Format(" 1=1 and state='0' and EMP_ID ='{0}'", userid); count = partolTaskBLL.GetRecordCount(where); returnstr = "{\"code\":0,\"count\":" + count + ",\"msg\":\"查询成功\"}"; } else { return "{\"code\":1,\"count\":" + count + ",\"msg\":\"查询条件不能为空\"}"; } } catch (Exception e) { returnstr = "{\"code\":-1,\"count\":" + count + ",\"msg\":\"查询失败\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取计划巡查数角标提醒异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取计划巡查数角标提醒"); return returnstr; } #endregion #region 获取隐患整改数角标提醒 /// /// 获取隐患整改数角标提醒 /// /// /// public string AppGetRectifySecurityThreatSuperscript(HttpContext context) { OA_PATROL_DANGER patrolDangerBLL = new OA_PATROL_DANGER(); string returnstr = ""; string orgId = context.Request.Params["orgId"]; int count = 0; try { if (!string.IsNullOrEmpty(orgId)) { string where = string.Format(" 1=1 and state='0' and ORG_ID ='{0}'", orgId); count = patrolDangerBLL.GetRecordCount(where); returnstr = "{\"code\":0,\"count\":" + count + ",\"msg\":\"查询成功\"}"; } else { return "{\"code\":1,\"count\":" + count + ",\"msg\":\"查询条件不能为空\"}"; } } catch (Exception e) { returnstr = "{\"code\":-1,\"count\":" + count + ",\"msg\":\"查询失败\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取隐患整改数角标提醒异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取隐患整改数角标提醒"); return returnstr; } #endregion #region 查铺查哨数角标提醒 /// /// 查铺查哨数角标提醒 /// /// /// public string AppGetSentryAndRestInspectSuperscript(HttpContext context) { OA_PATROLSENTRYTASK patrolSentryBLL = new OA_PATROLSENTRYTASK(); string returnstr = ""; string patrollerId = context.Request.Params["patrollerId"]; int count = 0; try { if (!string.IsNullOrEmpty(patrollerId)) { string where = " PATROLLERID ='" + patrollerId + "'"; where += " and date_format(ENDDATE, '%Y-%m-%d %H:%i:%s') >= date_format(now(), '%Y-%m-%d %H:%i:%s')"; count = patrolSentryBLL.GetRecordCount(where); returnstr = "{\"code\":0,\"count\":" + count + ",\"msg\":\"查询成功\"}"; } else { return "{\"code\":1,\"count\":" + count + ",\"msg\":\"查询条件不能为空\"}"; } } catch (Exception e) { returnstr = "{\"code\":-1,\"count\":" + count + ",\"msg\":\"查询失败\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "查铺查哨数角标提醒异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "查铺查哨数角标提醒"); return returnstr; } #endregion #region 上哨任务数角标提醒 /// /// 上哨任务数角标提醒 /// /// /// public string AppGetBeOnSentrySuperscript(HttpContext context) { FIRE_SHIFTS fireShiftsBLL = new FIRE_SHIFTS(); string returnstr = ""; string uid = context.Request.Params["uid"]; int count = 0; try { if (!string.IsNullOrEmpty(uid)) { DataTable dt = fireShiftsBLL.getShiftsListByState(uid, "0", "O_DATE"); //string where = string.Format(" 1=1 and O_UID ='{0}'", uid); //count = fireShiftsBLL.GetRecordCount(where); returnstr = "{\"code\":0,\"count\":" + dt.Rows.Count + ",\"msg\":\"查询成功\"}"; } else { return "{\"code\":1,\"count\":" + count + ",\"msg\":\"查询条件不能为空\"}"; } } catch (Exception e) { returnstr = "{\"code\":-1,\"count\":" + count + ",\"msg\":\"查询失败\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "查铺查哨数角标提醒异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "查铺查哨数角标提醒"); return returnstr; } #endregion #region 获取本机和下级单位 /// /// 获取本机和下级单位 /// /// /// public string AppGetOrgTree(HttpContext context) { FangYar.BLL.TBL.SysEmpBLL empbll = new FangYar.BLL.TBL.SysEmpBLL(); string returnstr = ""; try { string orgId = context.Request.Params["OrgId"]; returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; DataTable data = empbll.getOrgOnlyTree(orgId); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取本机和下级单位异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取本机和下级单位"); return returnstr; } #endregion #endregion #region 战训功能 /// /// 查询当前机构下训练任务列表 /// /// /// private string AppGetTrainTaskListByOrgId(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["OrgId"]; string keyword = context.Request.Params["keywords"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; string is_content = context.Request.Params["is_content"]; int pageIndex = 1; int pageSize = 10; int startIndex = 0; int endIndex = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } startIndex = (pageIndex - 1) * pageSize; endIndex = pageSize; string where = ""; if (!string.IsNullOrEmpty(OrgId)) { if (is_content == "1") { where += " org_id in ( select o.org_id from fire_org o,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids) ) "; } else { where += " ORG_ID = '" + OrgId + "'"; } } else { return "{\"code\":-1,\"msg\":\"OrgId参数错误\",\"count\":0,\"data\":[]}"; } if (!string.IsNullOrEmpty(keyword)) { where += " and NAME like '%" + keyword + "%'"; } FangYar.BLL.TRAIN.T_TRAININGTASK bll = new BLL.TRAIN.T_TRAININGTASK(); returnstr = "{\"code\":200,\"msg\":\"成功\","; int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { DataTable dt = bll.GetListByPage(where, "TRAINIGDATE desc", startIndex, endIndex).Tables[0]; returnstr += FangYar.Common.JsonHelper.ToJson(dt); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "查询当前机构下训练任务列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "查询当前机构下训练任务列表"); return returnstr; } /// /// 根据登录人ID获取训练任务列表(带训人) /// /// /// private string AppGetTrainTaskListByUserUid(HttpContext context) { string returnstr = ""; try { string UserUid = context.Request.Params["UserUid"]; string keyword = context.Request.Params["keywords"]; string where = ""; if (!string.IsNullOrEmpty(UserUid)) { where += " instr(LEADTRAINING, CONCAT('\"ppl_Id\":\"' , '" + UserUid + "' , '\"') )<> 0 "; } else { return "{\"code\":-1,\"msg\":\"UserUid参数错误\",\"count\":0,\"data\":[]}"; } if (!string.IsNullOrEmpty(keyword)) { where += " and NAME like '%" + keyword + "%'"; } where += " and (state != '0' or state != null)"; FangYar.BLL.TRAIN.T_TRAININGTASK bll = new BLL.TRAIN.T_TRAININGTASK(); returnstr = "{\"code\":200,\"msg\":\"成功\","; int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { where += " order by STATE,TRAINIGDATE desc"; List list = bll.GetModelList(where); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据登录人ID获取训练任务列表(带训人)异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据登录人ID获取训练任务列表(带训人)"); return returnstr; } /// /// 根据登录人ID获取训练任务列表(参训人) /// /// /// private string AppGetTrainParticipateTaskListByUserUid(HttpContext context) { string returnstr = ""; try { string UserUid = context.Request.Params["UserUid"]; string keyword = context.Request.Params["keywords"]; string where = ""; if (!string.IsNullOrEmpty(UserUid)) { where += " instr(TRAININGPERSON, CONCAT('\"ppl_Id\":\"' , '" + UserUid + "' , '\"') )<> 0 "; } else { return "{\"code\":-1,\"msg\":\"UserUid参数错误\",\"count\":0,\"data\":[]}"; } if (!string.IsNullOrEmpty(keyword)) { where += " and NAME like '%" + keyword + "%'"; } FangYar.BLL.TRAIN.T_TRAININGTASK bll = new BLL.TRAIN.T_TRAININGTASK(); returnstr = "{\"code\":200,\"msg\":\"成功\","; int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { where += " order by STATE,TRAINIGDATE desc"; List list = bll.GetModelList(where); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据登录人ID获取训练任务列表(参训人)异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据登录人ID获取训练任务列表(参训人)"); return returnstr; } /// /// 根据任务获取科目成绩 /// /// /// private string AppGetSubjectScoreByTask(HttpContext context) { string returnstr = ""; try { string taskid = context.Request.Params["taskid"]; string subjectid = context.Request.Params["subjectid"]; string where = " 1=1 "; if (!string.IsNullOrEmpty(taskid)) { where += " and taskid = '" + taskid + "'"; } if (!string.IsNullOrEmpty(subjectid)) { where += " and subjectid = '" + subjectid + "'"; } FangYar.BLL.TRAIN.T_TRAININGSCORE bll = new BLL.TRAIN.T_TRAININGSCORE(); returnstr = "{\"code\":200,\"msg\":\"成功\","; int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { where += " order by reporttime desc"; List list = bll.GetModelList(where); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据任务获取科目成绩异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据任务获取科目成绩"); return returnstr; } /// /// 带训人上报成绩 /// /// /// private string AppAddTrainReportScore(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { string data = context.Request.Params["data"]; string taskid = ""; List ht = new List(); JObject jsonobj = JsonConvert.DeserializeObject(data); foreach (JObject obj in jsonobj.Value("data0")) { FangYar.Model.TRAIN.T_TRAININGSCORE scoremodel = new Model.TRAIN.T_TRAININGSCORE(); scoremodel.ID = Guid.NewGuid().ToString("N"); scoremodel.USERS_UID = obj["uuid"].ToString(); scoremodel.USERS_NAME = obj["name"].ToString(); scoremodel.SUBJECTID = obj["subjectid"].ToString(); scoremodel.SUBJECTNAME = obj["subjectname"].ToString(); scoremodel.TRAINIGDATE = obj["traintime"].ToString(); scoremodel.TASKID = obj["taskid"].ToString(); scoremodel.TASKNAME = obj["taskname"].ToString(); scoremodel.RESULT = obj["result"].ToString(); scoremodel.ACHIEVEMENT = decimal.Parse(obj["achievement"].ToString() != "" ? obj["achievement"].ToString() : "0"); scoremodel.REPORTPERSONID = obj["reportuid"].ToString(); scoremodel.REPORTPERSONNAME = obj["reportname"].ToString(); scoremodel.REPORTTIME = DateTime.Now; //scoremodel.REMARK = obj["remark"].ToString(); scoremodel.ORG_ID = obj["orgid"].ToString(); scoremodel.ORG_NAME = obj["orgname"].ToString(); taskid = scoremodel.TASKID; FangYar.BLL.TRAIN.T_TRAININGSCORE score_bll = new BLL.TRAIN.T_TRAININGSCORE(); FangYar.Model.OA.CommonSql scoreModel = score_bll.getInsertScoreSql(scoremodel); ht.Add(scoreModel); } //上传图片 string filesurl = UploadFile("TrainingTask", context, taskid); FangYar.BLL.TRAIN.T_TRAININGTASK bll = new BLL.TRAIN.T_TRAININGTASK(); FangYar.Model.OA.CommonSql taskModel = bll.getUpdateTaskSql(taskid, filesurl); ht.Add(taskModel); if (FangYar.Common.MySqlHelper.ExecuteSqlTranBool(ht)) { code = 1; msg = "操作成功"; } else { code = 0; msg = "操作失败"; } } catch (Exception e) { msg = e.Message; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "带训人上报成绩异常:" + e); } returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP操作请求", "带训人上报成绩"); return returnstr; } /// /// 查询当前机构下训练科目 /// /// /// private string AppGetTrainSubject(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TRAIN.T_SUBJECT subject_bll = new BLL.TRAIN.T_SUBJECT(); string OrgId = context.Request.Params["OrgId"]; returnstr = "{\"code\":200,\"msg\":\"成功\",\"count\":0,\"data\":"; DataTable dt = subject_bll.GetList(" ORG_ID = '" + OrgId + "'").Tables[0]; returnstr += FangYar.Common.JsonHelper.ToJson(dt); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "查询当前机构下训练科目异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "查询当前机构下训练科目"); return returnstr; } /// /// 站内成绩排名 /// /// /// private string AppGetTrainScoreBySubjectid(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["OrgId"]; string subjectid = context.Request.Params["subjectid"]; string startTime = context.Request.Params["startTime"]; string endTime = context.Request.Params["endTime"]; string company = context.Request.Params["company"]; if (!string.IsNullOrEmpty(subjectid)) { string where = " SUBJECTID = '" + subjectid + "' and org_id in ( select oo.org_id from fire_org oo,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids) )"; if (!string.IsNullOrEmpty(startTime)) { if (!startTime.Contains("请选择")) { where += " and date_format(TRAINIGDATE,'%Y-%m-%d %H:%i:%s') >= date_format('" + startTime + "','%Y-%m-%d %H:%i:%s')"; } } if (!string.IsNullOrEmpty(endTime)) { if (!endTime.Contains("请选择")) { where += " and date_format(TRAINIGDATE,'%Y-%m-%d %H:%i:%s') <= date_format('" + endTime + "','%Y-%m-%d %H:%i:%s')"; } } //单位 0时间;1次数;2分数;3是否通过 string sortStr = ""; if (company == "0") { sortStr = " order by ACHIEVEMENT desc, case RESULT when '0' then '9999分' end,RESULT "; } else if (company == "1") { sortStr = " order by ACHIEVEMENT desc ,RESULT desc "; } else if (company == "2") { sortStr = " order by ACHIEVEMENT desc , RESULT desc "; } else if (company == "3") { sortStr = " order by ACHIEVEMENT desc "; } else { sortStr = " order by ACHIEVEMENT desc "; } where += sortStr; returnstr = "{\"code\":200,\"data\":"; FangYar.BLL.TRAIN.T_TRAININGSCORE bll = new BLL.TRAIN.T_TRAININGSCORE(); DataTable dt = bll.GetList(where).Tables[0]; returnstr += FangYar.Common.JsonHelper.ToJson(dt); returnstr += "}"; } else { returnstr = "{\"code\":0,\"msg\":\"未查询到数据\",\"count\":0,\"data\":[]}"; } } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "站内成绩排名异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "站内成绩排名"); return returnstr; } /// /// 根据任务ID获取每人每科训练成绩 /// /// /// private string AppGetTrainScoreListByTaskID(HttpContext context) { string returnstr = ""; try { string TaskId = context.Request.Params["TaskId"]; FangYar.BLL.TRAIN.T_TRAININGSCORE score_bll = new BLL.TRAIN.T_TRAININGSCORE(); DataTable dt = score_bll.GetScoreListByTaskID(TaskId); returnstr = "{\"code\":200,\"data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(dt); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据任务ID获取每人每科训练成绩异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据任务ID获取每人每科训练成绩"); return returnstr; } /// /// 获取红黑榜 /// /// /// private string AppGetTrainRedBlackListByOrgId(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["OrgId"]; string subjectid = context.Request.Params["subjectid"]; string startTime = context.Request.Params["startTime"]; string endTime = context.Request.Params["endTime"]; string company = context.Request.Params["company"]; FangYar.BLL.TRAIN.T_TRAININGSCORE bll = new BLL.TRAIN.T_TRAININGSCORE(); if (!string.IsNullOrEmpty(subjectid)) { string where = " SUBJECTID = '" + subjectid + "' and org_id in ( select oo.org_id from fire_org oo,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids) )"; if (!string.IsNullOrEmpty(startTime)) { if (!startTime.Contains("请选择")) { where += " and date_format(TRAINIGDATE,'%Y-%m-%d %H:%i:%s') >= date_format('" + startTime + "','%Y-%m-%d %H:%i:%s')"; } } if (!string.IsNullOrEmpty(endTime)) { if (!endTime.Contains("请选择")) { where += " and date_format(TRAINIGDATE,'%Y-%m-%d %H:%i:%s') <= date_format('" + endTime + "','%Y-%m-%d %H:%i:%s')"; } } //单位 0时间;1次数;2分数;3是否通过 string sortStr = ""; if (company == "0") { sortStr = " ACHIEVEMENT desc , case RESULT when '0' then '9999分' end,RESULT) "; } else if (company == "1") { sortStr = " ACHIEVEMENT desc , (RESULT) desc "; } else if (company == "2") { sortStr = " ACHIEVEMENT desc , (RESULT) desc "; } else if (company == "3") { sortStr = " ACHIEVEMENT desc "; } else { sortStr = " ACHIEVEMENT desc "; } //where += " and ACHIEVEMENT is not null"; where += " AND RESULT IS NOT NULL"; returnstr = "{\"code\":200,\"msg\":\"成功\","; returnstr += "\"data1\":"; DataTable dttop = bll.GetListByPage(where, sortStr, 0, 3).Tables[0]; returnstr += FangYar.Common.JsonHelper.ToJson(dttop); //where += " and ACHIEVEMENT<60 order by ACHIEVEMENT asc"; where += " AND RESULT IS NOT NULL order by " + sortStr; returnstr += ",\"data2\":"; DataTable dtbottom = bll.GetList(where).Tables[0]; returnstr += FangYar.Common.JsonHelper.ToJson(dtbottom); returnstr += "}"; } else { returnstr = "{\"code\":-10,\"msg\":\"未查询到数据\",\"count\":0,\"data\":[]}"; } } catch (Exception e) { returnstr = "{\"code\":-10,\"msg\":\"" + e.Message + "\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取红黑榜异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取红黑榜"); return returnstr; } /// /// 根据科目获取标准(根据科目单位,排序) /// /// /// private string AppGetTrainStandardListBySubjectId(HttpContext context) { string returnstr = ""; try { string subjectid = context.Request.Params["subjectid"]; string company = context.Request.Params["company"]; var subjectid_s = subjectid.Split(','); var company_s = company.Split(','); returnstr = "{ \"list\": ["; for (int i = 0; i < subjectid_s.Length; i++) { string subjectid_item = subjectid_s[i]; string company_item = company_s[i]; string where = " SUBJECTID = '" + subjectid_item + "'"; if (i == 0) { returnstr += "{\"id\":\"" + subjectid_item + "\",\"company\":\"" + company_item + "\","; } else { returnstr += ",{\"id\":\"" + subjectid_item + "\",\"company\":\"" + company_item + "\","; } FangYar.BLL.TRAIN.T_SUBJECTGRADESTANDARD bll = new BLL.TRAIN.T_SUBJECTGRADESTANDARD(); int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { if (company_item == "0") { where += " order by (GENDER) ,(AGE1) desc ,(STASYS1)"; } else if (company_item == "1") { where += " order by (GENDER) ,(AGE1) desc ,(STASYS1) desc"; } DataTable dt = bll.GetList(where).Tables[0]; returnstr += FangYar.Common.JsonHelper.ToJson(dt); } returnstr += "}"; } returnstr += "]}"; } catch (Exception e) { returnstr = "{ \"code\": -1,\"msg\": \"" + e.Message + "\",\"list\": []}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据科目获取标准(根据科目单位,排序)异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据科目获取标准(根据科目单位,排序)"); return returnstr; } /// /// 根据科目ID获取科目Model /// /// /// private string AppGetTrainSubjectModelBySubjectId(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TRAIN.T_SUBJECT bll = new BLL.TRAIN.T_SUBJECT(); string subjectId = context.Request.Params["subjectId"]; returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; FangYar.Model.TRAIN.T_SUBJECT data = bll.GetModel(subjectId); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据科目ID获取科目Model异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据科目ID获取科目Model"); return returnstr; } /// /// 根据uid获取历史成绩 /// /// /// private string AppGetTrainHistoryScoreListByUserUid(HttpContext context) { string returnstr = ""; try { string subjectid = context.Request.Params["subjectid"]; string UserUid = context.Request.Params["UserUid"]; string startTime = context.Request.Params["startTime"]; string endTime = context.Request.Params["endTime"]; string where = ""; if (!string.IsNullOrEmpty(UserUid)) { where += " users_uid = '" + UserUid + "'"; } else { return "{\"code\":-1,\"msg\":\"参数错误\",\"count\":0,\"data\":[]}"; } if (!string.IsNullOrEmpty(subjectid)) { if (!string.IsNullOrEmpty(where)) { where += " and"; } where += " subjectid = '" + subjectid + "'"; } if (!string.IsNullOrEmpty(startTime)) { if (!startTime.Contains("请选择")) { where += " and date_format(TRAINIGDATE,'%Y-%m-%d %H:%i:%s') >= date_format('" + startTime + "','%Y-%m-%d %H:%i:%s')"; } } if (!string.IsNullOrEmpty(endTime)) { if (!endTime.Contains("请选择")) { where += " and date_format(TRAINIGDATE,'%Y-%m-%d %H:%i:%s') <= date_format('" + endTime + "','%Y-%m-%d %H:%i:%s')"; } } FangYar.BLL.TRAIN.T_TRAININGSCORE bll = new BLL.TRAIN.T_TRAININGSCORE(); returnstr = "{\"code\":200,\"msg\":\"成功\","; int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { where += " order by TRAINIGDATE desc"; List dt = bll.GetModelList(where); returnstr += FangYar.Common.JsonHelper.ToJson(dt); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-2,\"msg\":\"" + e.Message + "\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据uid获取历史成绩异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据uid获取历史成绩"); return returnstr; } /// /// 根据uid获取个人各科最高成绩、训练通过率 /// /// /// private string AppGetTrainBestScoreByUserUid(HttpContext context) { string returnstr = ""; try { string UserUid = context.Request.Params["UserUid"]; if (string.IsNullOrEmpty(UserUid)) { return "{\"code\":-1,\"msg\":\"参数错误\",\"count\":0,\"data\":[]}"; } FangYar.BLL.TRAIN.T_TRAININGSCORE bll = new BLL.TRAIN.T_TRAININGSCORE(); FangYar.BLL.TRAIN.TRAININGSCOREBEST bestbll = new BLL.TRAIN.TRAININGSCOREBEST(); returnstr = "{\"code\":200,\"msg\":\"成功\",\"data0\":"; DataTable dt0 = bestbll.GetList("users_uid='" + UserUid + "'").Tables[0]; //DataTable dt0 = bll.GetBestScore("users_uid='" + UserUid + "' and (achievement is not null or achievement != '0') and (RESULT is not null or RESULT != '0')"); returnstr += FangYar.Common.JsonHelper.ToJson(dt0); returnstr += ",\"data1\":"; DataTable dt1 = bll.GetPassRate(" users_uid = '" + UserUid + "' and ACHIEVEMENT is not null "); returnstr += FangYar.Common.JsonHelper.ToJson(dt1); //returnstr += ",\"data2\":"; //DataTable dt2 = bll.timeScoreSubject(" users_uid = '" + UserUid + "'"); //returnstr += FangYar.Common.JsonHelper.ToJson(dt2); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-2,\"msg\":\"" + e.Message + "\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据uid获取个人各科最高成绩、训练通过率异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据uid获取个人各科最高成绩、训练通过率"); return returnstr; } /// /// 根据uid获取人员的训练成绩科目 /// /// /// private string AppGetTrainTimeScoreSubjectByUid(HttpContext context) { string returnstr = ""; try { string UID = context.Request.Params["UID"]; if (!string.IsNullOrEmpty(UID)) { string where = " users_uid = '" + UID + "'"; returnstr = "{\"code\":1,\"msg\":\"\","; returnstr += "\"count\":0,\"data\":"; FangYar.BLL.TRAIN.T_TRAININGSCORE bll = new BLL.TRAIN.T_TRAININGSCORE(); DataTable dt = bll.timeScoreSubject(where); returnstr += FangYar.Common.JsonHelper.ToJson(dt); returnstr += "}"; } else { returnstr = "{\"code\":0,\"未查询到数据\":\"error\",\"count\":0,\"data\":[]}"; } } catch (Exception e) { returnstr = "{\"code\":0,\"" + e.Message + "\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据uid获取人员的训练成绩科目异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据uid获取人员的训练成绩科目"); return returnstr; } /// /// 根据uid、科目ID获取个人近期训练成绩 /// /// /// private string AppGetTrainTimeScoreBySubjectId(HttpContext context) { string returnstr = ""; try { string UID = context.Request.Params["UID"]; string subjectid = context.Request.Params["subjectid"]; if (!string.IsNullOrEmpty(UID)) { string where = " subjectid = '" + subjectid + "' and users_uid = '" + UID + "'"; returnstr = "{\"code\":1,\"msg\":\"\","; returnstr += "\"count\":0,\"data\":"; FangYar.BLL.TRAIN.T_TRAININGSCORE bll = new BLL.TRAIN.T_TRAININGSCORE(); DataTable dt = bll.timeScore(where); returnstr += FangYar.Common.JsonHelper.ToJson(dt); returnstr += "}"; } else { returnstr = "{\"code\":0,\"未查询到数据\":\"error\",\"count\":0,\"data\":[]}"; } } catch (Exception e) { returnstr = "{\"code\":0,\"" + e.Message + "\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据uid、科目ID获取个人近期训练成绩异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据uid、科目ID获取个人近期训练成绩"); return returnstr; } /// /// 根据字典表类型获取战训知识库模块 /// /// /// private string AppGetTrainKnowDicListByMod(HttpContext context) { string returnstr = ""; try { string mod_code = context.Request.Params["mod_code"]; string dic_fid = context.Request.Params["dic_fid"]; string where = " mod_code = '" + mod_code + "' "; if (!string.IsNullOrEmpty(dic_fid)) { where += " and dic_fid = '" + dic_fid + "' "; } else { where += " and dic_fid is null "; } FangYar.BLL.TBL.SysDicdetailBLL dicbll = new BLL.TBL.SysDicdetailBLL(); returnstr = "{\"code\":0,\"msg\":\"\","; returnstr += "\"count\":0,\"data\":"; DataTable dt = dicbll.GetList(where).Tables[0]; returnstr += FangYar.Common.JsonHelper.ToJson(dt); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据字典表类型获取战训知识库模块异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据字典表类型获取战训知识库模块"); return returnstr; } /// /// 根据机构ID查询训练知识库列表 /// /// /// private string AppGetTrainKnowListByOrgId(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["OrgId"]; string is_content = context.Request.Params["is_content"]; string cls = context.Request.Params["cls"]; string ntype = context.Request.Params["ntype"]; string keyword = context.Request.Params["keyword"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } int startIndex = (pageIndex - 1) * pageSize; int endIndex = pageSize; string where = ""; if (is_content == "1") { where = " org_id in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids) ) "; } else { where = " ORG_ID = '" + OrgId + "'"; } if (!string.IsNullOrEmpty(cls)) { where += " and CLS = '" + cls + "'"; } if (!string.IsNullOrEmpty(ntype)) { where += " and NTYPE = '" + ntype + "'"; } if (!string.IsNullOrEmpty(keyword)) { where += " and ART_TITLE like '%" + keyword + "%' "; } returnstr = "{\"code\":0,\"msg\":\"\","; FangYar.BLL.OA.OA_KNOWLEDGEBASE bll = new BLL.OA.OA_KNOWLEDGEBASE(); int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { DataTable dt = bll.GetListByPage2(where, "", startIndex, endIndex).Tables[0]; returnstr += Common.JsonHelper.ToJson(dt); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据机构ID查询训练知识库列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据机构ID查询训练知识库列表"); return returnstr; } /// /// 根据知识库ID查询训练知识库详情 /// /// /// private string AppGetTrainKnowModelByKnowId(HttpContext context) { string returnstr = ""; try { string KnowId = context.Request.Params["KnowId"]; returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; FangYar.BLL.OA.OA_KNOWLEDGEBASE bll = new BLL.OA.OA_KNOWLEDGEBASE(); DataTable dt = bll.GetDataTableById(KnowId); returnstr += Common.JsonHelper.ToJson(dt); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "根据知识库ID查询训练知识库详情异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "根据知识库ID查询训练知识库详情"); return returnstr; } #endregion 战训功能 #region 人员通讯录 //获取人员通讯录 private string AppGetPerPhoneListByOrgId(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["OrgId"]; FangYar.BLL.TBL.SysEmpBLL empBll = new FangYar.BLL.TBL.SysEmpBLL(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; DataTable data = empBll.getPerPhoneListByOrgId(orgId); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取人员通讯录异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取人员通讯录"); return returnstr; } #endregion #region 图片操作 /// /// 上传单张图片 /// /// /// /// private static string UploadFile(HttpContext context, string CONNMOD_ID) { string result = ""; if (context.Request.Files.Count > 0) { HttpPostedFile item = context.Request.Files[0]; string imageRootPath = "/upload/Fire/Epuip/"; string extensionStr = System.IO.Path.GetExtension(item.FileName); string str = System.DateTime.Now.ToString("yyyyHHddHHmmss"); string fileName = str + CONNMOD_ID + extensionStr + ".png"; try { string rootPath = System.AppDomain.CurrentDomain.BaseDirectory + imageRootPath; if (System.IO.Directory.Exists(rootPath)) { item.SaveAs(rootPath + fileName); result = imageRootPath + fileName; } else { System.IO.Directory.CreateDirectory(rootPath); item.SaveAs(rootPath + fileName); result = imageRootPath + fileName; } } catch (Exception e) { result = ""; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "上传单张图片异常:" + e); } } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP操作请求", "上传单张图片"); return result; } /// /// 上传多张图片 /// /// /// /// /// private static string UploadFile(string url, HttpContext context, string CONNMOD_ID) { string result = ""; try { if (context.Request.Files.Count > 0) { string ImageFilePath = "/Upload/" + url + "/" + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/"; if (System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(ImageFilePath)) == false)//如果不存在就创建文件夹 { System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(ImageFilePath)); } for (int i = 0; i < context.Request.Files.Count; i++) { HttpPostedFile item = context.Request.Files[i]; string fileName = CONNMOD_ID + i + ".png"; try { string rootPath = System.AppDomain.CurrentDomain.BaseDirectory + ImageFilePath; item.SaveAs(rootPath + fileName); result += ImageFilePath + fileName + ","; } catch { result += ""; } } result = result.Substring(0, result.Length - 1); } } catch (Exception e) { // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "上传多张图片异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP操作请求", "上传多张图片"); return result; } /// /// 上传多张图片(加水印) /// /// /// /// /// private static string AddPhotoWatermark(string url, HttpContext context, string CONNMOD_ID) { string result = ""; try { if (context.Request.Files.Count > 0) { string ImageFilePath = "/Upload/" + url + "/" + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/"; if (System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(ImageFilePath)) == false)//如果不存在就创建文件夹 { System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(ImageFilePath)); } for (int i = 0; i < context.Request.Files.Count; i++) { HttpPostedFile item = context.Request.Files[i]; string fileName = CONNMOD_ID + i + ".png"; try { string rootPath = System.AppDomain.CurrentDomain.BaseDirectory + ImageFilePath; System.Drawing.Image img = Image.FromStream(item.InputStream); //创建画布 System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(img); g.DrawString(DateTime.Now.ToString(), new Font("黑体", 100), new SolidBrush(Color.Black), 10, 10); //释放画布 g.Dispose(); System.Drawing.Image img2 = new Bitmap(img); img.Dispose(); img2.Save(rootPath + fileName); img2.Dispose(); result += ImageFilePath + fileName + ","; } catch (Exception e) { result += ""; } } result = result.Substring(0, result.Length - 1); } } catch (Exception e) { // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "上传多张图片(加水印)异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP操作请求", "上传多张图片(加水印)"); return result; } #endregion #region 请假申请-多分支多级机构 //请假申请 private string AppLeaveTaskApplyMoreStep(HttpContext context) { string returnstr = ""; try { bool flag = false; //请假表单字段 string leaveId = context.Request.Params["leaveId"]; if (string.IsNullOrEmpty(leaveId)) { flag = true; leaveId = Guid.NewGuid().ToString().ToGuid().ToString(); } string pplId = context.Request.Params["pplId"]; string pplName = context.Request.Params["pplName"]; string lType = context.Request.Params["lType"]; string sTime = context.Request.Params["sTime"]; string eTime = context.Request.Params["eTime"]; string lNum = context.Request.Params["lNum"]; string lOut = context.Request.Params["lOut"]; string accPplId = context.Request.Params["accId"]; string repPplId = context.Request.Params["repId"]; string lReason = context.Request.Params["reason"]; string title = context.Request.Params["title"]; string extend2 = context.Request.Params["extend2"]; FangYar.Model.OA_LEAVE leaveModel = new FangYar.Model.OA_LEAVE(); leaveModel.ID = leaveId; leaveModel.PPL_ID = pplId; leaveModel.PPL_NAME = pplName; leaveModel.L_TYPE = lType; leaveModel.S_TIME = sTime; leaveModel.E_TIME = eTime; leaveModel.L_NUM = lNum; leaveModel.L_OUT = lOut; leaveModel.ACC_PPL = accPplId; leaveModel.REP_PPL = repPplId; leaveModel.L_REASON = lReason; leaveModel.TITLE = title; leaveModel.STATE = "0"; leaveModel.IS_RETURN = "1"; leaveModel.EXTEND2 = extend2; leaveModel.EXTEND4 = "1_"; string str = AppLeaveFirst(pplId); if (str != null && str.Contains(';')) { var str2 = str.Split(';'); leaveModel.EXTEND3 = str2[1]; leaveModel.EXTEND4 = str2[0]; leaveModel.EXTEND5 = "xj_" + str2[0]; } RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); string opation = context.Request.Params["opation"];//操作类型 string receiveId = context.Request.Params["receiveId"];//接收人员 if (string.IsNullOrEmpty(receiveId)) { receiveId = leaveModel.EXTEND3; } switch (opation) { case "apply": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; } FangYar.BLL.OA_LEAVE leaveBll = new FangYar.BLL.OA_LEAVE(); //流程字段 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID //多级销假审批 //var wfInstalled = bworkFlow.GetWorkFlowRunModel("1e293f27-ac08-4087-8a0e-6c0aa9e3af6f"); //无销假审批,发起即完成 var wfInstalled = bworkFlow.GetWorkFlowRunModel("04ea14b3-fabc-48dd-8024-2dd59569a1f4"); if (flag) { leaveBll.Add(leaveModel); //多级销假审批 //execute.FlowID = "1e293f27-ac08-4087-8a0e-6c0aa9e3af6f".ToGuid(); //无销假审批,发起即完成 execute.FlowID = "04ea14b3-fabc-48dd-8024-2dd59569a1f4".ToGuid(); execute.GroupID = Guid.Empty; execute.InstanceID = leaveModel.ID.ToGuid().ToString(); execute.IsSign = false; execute.Note = ""; execute.Sender = userBll.GetModelByUID(pplId); execute.StepID = wfInstalled.FirstStepID; execute.TaskID = Guid.Empty; } else { leaveBll.Update(leaveModel); wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); } execute.Title = title ?? ""; //04ea14b3-fabc-48dd-8024-2dd59569a1f4 RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == eventParams.StepID); var currentStep = steps.First(); var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "请假申请异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP操作请求", "请假申请"); return returnstr; } /// /// 获取流转步骤 /// /// /// /// /// public List GetNextSteps(RoadFlow.Data.Model.WorkFlowInstalledSub.Step currentStep, RoadFlow.Data.Model.WorkFlowInstalled wfInstalled, RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams) { try { List removeIDList = new List(); RoadFlow.Platform.WorkFlowTask btask = new RoadFlow.Platform.WorkFlowTask(); RoadFlow.Platform.Users busers = new RoadFlow.Platform.Users(); var nextSteps = bworkFlow.GetNextSteps(wfInstalled.ID, currentStep.ID).OrderBy(p => p.Position_x).ThenBy(p => p.Position_y).ToList(); foreach (var step in nextSteps) { var lines = wfInstalled.Lines.Where(p => p.ToID == step.ID && p.FromID == currentStep.ID); if (lines.Count() > 0) { var line = lines.First(); if (!line.SqlWhere.IsNullOrEmpty()) { if (wfInstalled.DataBases.Count() == 0) { removeIDList.Add(step.ID); //nosubmitMsg.Append("流程未设置数据连接"); //nosubmitMsg.Append("\\n"); } else { if (!btask.TestLineSql(wfInstalled.DataBases.First().LinkID, wfInstalled.DataBases.First().Table, wfInstalled.DataBases.First().PrimaryKey, eventParams.InstanceID, line.SqlWhere)) { removeIDList.Add(step.ID); //nosubmitMsg.Append(string.Concat("提交条件未满足")); //nosubmitMsg.Append("\\n"); } } } if (!line.CustomMethod.IsNullOrEmpty()) { object obj = btask.ExecuteFlowCustomEvent(line.CustomMethod.Trim(), eventParams); var objType = obj.GetType(); var boolType = typeof(Boolean); if (objType != boolType && "1" != obj.ToString()) { removeIDList.Add(step.ID); } else if (objType == boolType && !(bool)obj) { removeIDList.Add(step.ID); } } #region 组织机构关系判断 string SenderID = RoadFlow.Platform.Users.CurrentUserID; if ("1" == line.Organize_SenderChargeLeader && !busers.IsChargeLeader(SenderID)) { removeIDList.Add(step.ID); } if (!line.Organize_SenderIn.IsNullOrEmpty() && !busers.IsContains(SenderID, line.Organize_SenderIn)) { removeIDList.Add(step.ID); } if ("1" == line.Organize_SenderLeader && !busers.IsLeader(SenderID)) { removeIDList.Add(step.ID); } if (!line.Organize_SenderNotIn.IsNullOrEmpty() && busers.IsContains(SenderID, line.Organize_SenderNotIn)) { removeIDList.Add(step.ID); } string sponserID = "";//发起者ID if (currentStep.ID == wfInstalled.FirstStepID)//如果是第一步则发起者就是发送者 { sponserID = SenderID; } else { sponserID = btask.GetFirstSnderID(eventParams.FlowID, eventParams.GroupID.ToString()); } if ("1" == line.Organize_SponsorChargeLeader && !busers.IsChargeLeader(sponserID)) { removeIDList.Add(step.ID); } if (!line.Organize_SponsorIn.IsNullOrEmpty() && !busers.IsContains(sponserID, line.Organize_SponsorIn)) { removeIDList.Add(step.ID); } if ("1" == line.Organize_SponsorLeader && !busers.IsLeader(sponserID)) { removeIDList.Add(step.ID); } if (!line.Organize_SponsorNotIn.IsNullOrEmpty() && busers.IsContains(sponserID, line.Organize_SponsorNotIn)) { removeIDList.Add(step.ID); } if ("1" == line.Organize_NotSenderChargeLeader && busers.IsChargeLeader(SenderID)) { removeIDList.Add(step.ID); } if ("1" == line.Organize_NotSenderLeader && busers.IsLeader(SenderID)) { removeIDList.Add(step.ID); } if ("1" == line.Organize_NotSponsorChargeLeader && busers.IsChargeLeader(sponserID)) { removeIDList.Add(step.ID); } if ("1" == line.Organize_NotSponsorLeader && busers.IsLeader(sponserID)) { removeIDList.Add(step.ID); } #endregion } } foreach (Guid rid in removeIDList) { nextSteps.RemoveAll(p => p.ID == rid); } return nextSteps; } catch (Exception e) { string str = "获取流转步骤异常:" + e; FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = str, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error, path = "AppHandLog" }); } return new List(); } /// /// 流程发起查询对应步骤和处理人 /// /// /// private string AppLeaveFirst(string userId) { FangYar.BLL.TBL.SysEmpBLL bll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.BLL.FIRE.FIRE_ORG bll_org = new FangYar.BLL.FIRE.FIRE_ORG(); string returnstr = ""; try { //string userId = context.Request.Params["qjr"]; var user = bll.GetModelByUID(userId); var nextUid = ""; var nextStep = ""; var org = bll_org.GetModel(user.ORG_ID);//所在单位部门 var unit_org = org;//所在单位 //if (unit_org.TYPE=='1') { // unit_org = bll_org.getHigherOrgByOrgId(unit_org.ORG_ID); //} //var height_unit_org = bll_org.getHigherOrgByOrgId(unit_org.ORG_ID);//上级单位 var tags = user.TAGS; if (!string.IsNullOrEmpty(user.TAGS_BAK)) { tags = user.TAGS_BAK; } if (tags != null && tags.Contains("消防站")) { nextStep = "1_"; nextUid = ""; //获取消防站主官 var listuser = bll.QueryListByOrgIdOrDeptId(unit_org.ORG_ID); if (listuser != null && listuser.Count > 0) { foreach (var model in listuser) { if (model.TAGS != null && model.TAGS.Contains("消防站主官")) { nextUid += model.USERS_UID + ","; } } } nextUid = nextUid.Trim(','); } else if (tags.Contains("常委")) { nextStep = "4_"; nextUid = ""; //获取支队长、政委 var listuser = bll.QueryListByOrgIdOrDeptId(unit_org.ORG_ID); if (listuser != null && listuser.Count > 0) { foreach (var model in listuser) { if (model.TAGS != null && !model.TAGS.Contains("副支队长") && (model.TAGS.Contains("支队长") || model.TAGS.Contains("政治委员"))) { nextUid += model.USERS_UID + ","; } } } nextUid = nextUid.Trim(','); } else if (tags.Contains("大队")) { nextStep = "2_"; nextUid = ""; //获取支队长、政委 var listuser = bll.QueryListByOrgIdOrDeptId(unit_org.ORG_ID); if (listuser != null && listuser.Count > 0) { foreach (var model in listuser) { if (model.TAGS != null && (model.TAGS.Contains("大队长") || model.TAGS.Contains("教导员"))) { nextUid += model.USERS_UID + ","; } } } nextUid = nextUid.Trim(','); } else { nextStep = "3_"; nextUid = ""; var dept_org = bll_org.GetModel(user.DEPT_ID);//部门信息 if (dept_org != null && dept_org.LEADER != null) { var kz = bll.GetModelByID(dept_org.LEADER); if (kz != null && kz.USERS_UID != null) { nextUid = kz.USERS_UID;//部门领导 } } } returnstr += nextStep + ";" + nextUid; } catch (Exception e) { returnstr = ""; // 记录操作日志 //WebCommon.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "流程发起查询对应步骤和处理人异常:" + e); string str = "流程发起查询对应步骤和处理人异常:" + e; FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = str, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error, path = "AppHandLog" }); } return returnstr; } #region 请假流程处理 //请假流程处理 private string AppLeaveWorkFlowTaskHandle(HttpContext context) { string returnstr = ""; try { //流程字段 string comment = context.Request.Params["comment"];//处理意见 string opation = context.Request.Params["opation"];//操作类型 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string receiveId = context.Request.Params["receiveId"];//接收人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID string title = context.Request.Params["title"];//标题 string EXTEND = context.Request.Params["EXTEND"];//延假小时 string isEXTEND = context.Request.Params["isEXTEND"];//是否为延假 0销假;1延假 //string EXTEND3 = context.Request.Params["EXTEND3"];// //receiveId = EXTEND3; if (isEXTEND == "1") { FangYar.BLL.OA_LEAVE ldal = new FangYar.BLL.OA_LEAVE(); FangYar.Model.OA_LEAVE lmodel = ldal.GetModel(instanceid); lmodel.EXTEND = EXTEND; ldal.Update(lmodel); } RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.OA_LEAVE leavebll = new FangYar.BLL.OA_LEAVE(); FangYar.Model.OA_LEAVE leaveModel = leavebll.GetModel(instanceid); switch (opation) { case "submit": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; case "back": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "completed": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "redirect": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Redirect; break; //新增同意 case "agree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree; //leavebll.EditState(instanceid, "1"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; //新增不同意 case "disagree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree; leavebll.EditState(instanceid, "2"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; } FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); execute.Title = title ?? ""; if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed) { FangYar.BLL.TBL.SysEmpBLL empbll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.Model.TBL.TBL_SYS_EMP_Model emodel = new FangYar.Model.TBL.TBL_SYS_EMP_Model(); emodel.USERS_UID = leaveModel.PPL_ID; emodel.IS_WORK = "1"; empbll.EditEmpIswork(emodel); var accUsers = leaveModel.ACC_PPL.Split(','); foreach (string uid in accUsers) { emodel.USERS_UID = uid.Replace("u_", ""); empbll.EditEmpIswork(emodel); } } RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == execute.StepID); var currentStep = steps.First(); if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { int backType = currentStep.Behavior.BackType;//退回类型 var prevSteps = bworkFlowTask.GetBackSteps(taskid.ToGuid(), backType, stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID, wfInstalled); foreach (var step in prevSteps) { execute.Steps.Add(step.Key, new List()); } } else { var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); if (nextSteps.Count > 0) { for (int i = 0; i < nextSteps.Count; i++) { switch (nextSteps[i].Behavior.HandlerType) { case 5://发起者 receiveId = bworkFlowTask.GetFirstSnderID(wfInstalled.ID, groupid); break; case 6://前一步骤处理者 //defaultMember = btask.GetStepSnderIDString(wfInstalled.ID, currentStep.ID, groupid.ToGuid()); //if (defaultMember.IsNullOrEmpty() && currentStep.ID == wfInstalled.FirstStepID) //{ receiveId = RoadFlow.Platform.Users.PREFIX + RoadFlow.Platform.Users.CurrentUserID.ToString(); //} break; case 7://某一步骤处理者 receiveId = bworkFlowTask.GetStepSnderIDString(wfInstalled.ID, nextSteps[i].Behavior.HandlerStepID, groupid.ToGuid()); break; case 8://字段值 string linkString = nextSteps[i].Behavior.ValueField; if (!linkString.IsNullOrEmpty() && !instanceid.IsNullOrEmpty() && wfInstalled.DataBases.Count() > 0) { receiveId = new RoadFlow.Platform.DBConnection().GetFieldValue(linkString, wfInstalled.DataBases.First().PrimaryKey, instanceid); } break; } execute.Steps.Add(nextSteps[i].ID, borganize.GetAllUsersIdString(receiveId)); } } } var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "请假流程处理异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "APP操作请求", "请假流程处理"); return returnstr; } #endregion #endregion #region 用车申请-多级分支多级机构 //用车申请 private string AppCarTaskApplyMoreStep(HttpContext context) { string returnstr = ""; try { bool flag = false; //用车表单字段 string applyId = context.Request.Params["applyId"]; if (string.IsNullOrEmpty(applyId)) { flag = true; applyId = Guid.NewGuid().ToString().ToGuid().ToString(); } string userId = context.Request.Params["userId"]; string userName = context.Request.Params["userName"]; string userPhone = context.Request.Params["userPhone"]; string carId = context.Request.Params["carId"]; string carNum = context.Request.Params["carNum"]; string userMan = context.Request.Params["userMan"]; string rideNum = context.Request.Params["rideNum"]; string rideMan = context.Request.Params["rideMan"]; string ridePurpose = context.Request.Params["ridePurpose"]; string startPoint = context.Request.Params["startPoint"]; string endPoint = context.Request.Params["endPoint"]; string startTime = context.Request.Params["startTime"]; string endTime = context.Request.Params["endTime"]; string title = context.Request.Params["title"]; string extend = context.Request.Params["extend"]; string extend2 = context.Request.Params["extend2"]; FangYar.Model.TBL_SYS_CARAPPLY carModel = new FangYar.Model.TBL_SYS_CARAPPLY(); carModel.ID = applyId; carModel.USERID = userId; carModel.USERNAME = userName; carModel.USERPHONE = userPhone; carModel.CARID = carId; carModel.CARNUM = carNum; carModel.USERMAN = userMan; if (!string.IsNullOrEmpty(rideNum)) { carModel.RIDENUM = Int32.Parse(rideNum); } else { carModel.RIDENUM = 1; } carModel.RIDEMANS = rideMan; carModel.RIDEPURPOSE = ridePurpose; carModel.STARTPOINT = startPoint; carModel.DESTINATION = endPoint; if (!string.IsNullOrEmpty(startTime)) { carModel.STARTTIME = DateTime.Parse(startTime); } if (!string.IsNullOrEmpty(endTime)) { carModel.FINISHTIME = DateTime.Parse(endTime); } carModel.STATE = "0"; carModel.EXTENDCODE2 = "1"; carModel.TITLE = title; carModel.EXTENDCODE3 = extend; carModel.EXTENDCODE6 = extend2; carModel.EXTENDCODE5 = "1_"; string str = AppCarApplyFirst(userId); if (str != null && str.Contains(';')) { var str2 = str.Split(';'); carModel.EXTENDCODE4 = str2[1]; carModel.EXTENDCODE5 = str2[0]; } FangYar.BLL.TBL_SYS_CARAPPLY carBll = new FangYar.BLL.TBL_SYS_CARAPPLY(); RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); string opation = context.Request.Params["opation"];//操作类型 string receiveId = context.Request.Params["receiveId"];//接收人员 if (string.IsNullOrEmpty(receiveId)) { receiveId = carModel.EXTENDCODE4; } switch (opation) { case "apply": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; } //流程字段 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID var wfInstalled = bworkFlow.GetWorkFlowRunModel("830258e8-69e8-404d-ac32-5da2545c18e0"); if (flag) { carBll.Add(carModel); execute.FlowID = "830258e8-69e8-404d-ac32-5da2545c18e0".ToGuid(); execute.GroupID = Guid.Empty; execute.InstanceID = carModel.ID.ToGuid().ToString(); execute.IsSign = false; execute.Note = ""; execute.Sender = userBll.GetModelByUID(userId); execute.StepID = wfInstalled.FirstStepID; execute.TaskID = Guid.Empty; } else { carBll.Update(carModel); wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); } execute.Title = title ?? ""; RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == eventParams.StepID); var currentStep = steps.First(); var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP操作请求", "用车申请异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP操作请求", "用车申请"); return returnstr; } /// /// 流程发起查询对应步骤和处理人 /// /// /// private string AppCarApplyFirst(string userId) { FangYar.BLL.TBL.SysEmpBLL bll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.BLL.FIRE.FIRE_ORG bll_org = new FangYar.BLL.FIRE.FIRE_ORG(); string returnstr = ""; try { //string userId = context.Request.Params["qjr"]; var user = bll.GetModelByUID(userId); var nextUid = ""; var nextStep = ""; var org = bll_org.GetModel(user.ORG_ID);//所在单位部门 var unit_org = org;//所在单位 //if (unit_org.TYPE=='1') { // unit_org = bll_org.getHigherOrgByOrgId(unit_org.ORG_ID); //} //var height_unit_org = bll_org.getHigherOrgByOrgId(unit_org.ORG_ID);//上级单位 var tags = user.TAGS; if (!string.IsNullOrEmpty(user.TAGS_BAK)) { tags = user.TAGS_BAK; } if (tags != null && tags.Contains("消防站")) { nextStep = "1_"; nextUid = ""; //获取消防站主官 var listuser = bll.QueryListByOrgIdOrDeptId(unit_org.ORG_ID); if (listuser != null && listuser.Count > 0) { foreach (var model in listuser) { if (model.TAGS != null && ("," + model.TAGS + ",").Contains(",消防站主官,")) { nextUid += model.USERS_UID + ","; } //if (model.TAGS != null && model.TAGS.Contains("消防站主官")) //{ // nextUid += model.USERS_UID + ","; //} } } nextUid = nextUid.Trim(','); } else if (tags.Contains("大队")) { nextStep = "2_"; nextUid = ""; //获取支队长、政委 var listuser = bll.QueryListByOrgIdOrDeptId(unit_org.ORG_ID); if (listuser != null && listuser.Count > 0) { foreach (var model in listuser) { if (model.TAGS != null && (("," + model.TAGS + ",").Contains(",大队长,") || ("," + model.TAGS + ",").Contains(",教导员,"))) { nextUid += model.USERS_UID + ","; } //if (model.TAGS != null && (model.TAGS.Contains("大队长") || model.TAGS.Contains("教导员"))) //{ // nextUid += model.USERS_UID + ","; //} } } nextUid = nextUid.Trim(','); } else { nextStep = "3_"; nextUid = ""; var dept_org = bll_org.GetModel(user.DEPT_ID);//部门信息 if (dept_org != null && dept_org.LEADER != null) { var kz = bll.GetModelByID(dept_org.LEADER); if (kz != null && kz.USERS_UID != null) { nextUid = kz.USERS_UID;//部门领导 } } } returnstr += nextStep + ";" + nextUid; } catch (Exception ex) { returnstr = ""; string str = "流程发起查询对应步骤和处理人异常:" + ex; FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = str, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error, path = "AppHandLog" }); } return returnstr; } #region 用车流程处理 //用车流程处理 private string AppCarWorkFlowTaskHandle(HttpContext context) { string returnstr = ""; try { //流程字段 string comment = context.Request.Params["comment"];//处理意见 string opation = context.Request.Params["opation"];//操作类型 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string receiveId = context.Request.Params["receiveId"];//接收人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID string title = context.Request.Params["title"];//标题 RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.TBL_SYS_CARAPPLY carBll = new FangYar.BLL.TBL_SYS_CARAPPLY(); FangYar.Model.TBL_SYS_CARAPPLY carModel = carBll.GetModel(instanceid); switch (opation) { case "submit": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; case "back": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "completed": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "redirect": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Redirect; break; //新增同意 case "agree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree; //carBll.EditState(instanceid, "1"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; //新增不同意 case "disagree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree; carBll.EditState(instanceid, "2"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; } FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); execute.Title = title ?? ""; if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed) { FangYar.BLL.TBL.SysEmpBLL empbll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.Model.TBL.TBL_SYS_EMP_Model emodel = new FangYar.Model.TBL.TBL_SYS_EMP_Model(); emodel.USERS_UID = carModel.USERID; emodel.IS_WORK = "1"; empbll.EditEmpIswork(emodel); emodel.USERS_UID = carModel.USERMAN; empbll.EditEmpIswork(emodel); var accUsers = carModel.RIDEMANS.Split(','); foreach (string uid in accUsers) { emodel.USERS_UID = uid.Replace("u_", ""); empbll.EditEmpIswork(emodel); } //还车通过后修改车辆的状态 TBL_SYS_CAR carbll = new TBL_SYS_CAR(); Model.TBL_SYS_CAR carmodel = carbll.GetModel(carModel.CARID); if (carmodel != null) { carmodel.ISAPPLY = "0"; } carbll.EditCarIsapply(carmodel); } RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == execute.StepID); var currentStep = steps.First(); if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { var steps2 = wfInstalled.Steps.Where(p => p.ID == stepid.ToGuid()); var currentStep2 = steps2.First(); int backType = currentStep2.Behavior.BackType;//退回类型 var prevSteps = bworkFlowTask.GetBackSteps(taskid.ToGuid(), backType, stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID, wfInstalled); foreach (var step in prevSteps) { execute.Steps.Add(step.Key, new List()); } } //else if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit) //{ // TBL_SYS_CAR carbll = new TBL_SYS_CAR(); // Model.TBL_SYS_CAR carmodel = carbll.GetModel(carModel.CARID); // if (carmodel != null) // { // carmodel.ISAPPLY = "1"; // } // carbll.EditCarIsapply(carmodel); //} //else if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree) //{ // //审批通过后调整车辆状态 // TBL_SYS_CAR carbll = new TBL_SYS_CAR(); // Model.TBL_SYS_CAR carmodel = carbll.GetModel(carModel.CARID); // if (carmodel != null) // { // carmodel.ISAPPLY = "2"; // } // carbll.EditCarIsapply(carmodel); //} else { //审批通过后调整车辆状态 TBL_SYS_CAR carbll = new TBL_SYS_CAR(); Model.TBL_SYS_CAR carmodel = carbll.GetModel(carModel.CARID); if (carmodel != null) { carmodel.ISAPPLY = "2"; } carbll.EditCarIsapply(carmodel); var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); if (nextSteps.Count > 0) { switch (nextSteps[0].Behavior.HandlerType) { case 5://发起者 receiveId = bworkFlowTask.GetFirstSnderID(wfInstalled.ID, groupid); break; case 6://前一步骤处理者 //defaultMember = btask.GetStepSnderIDString(wfInstalled.ID, currentStep.ID, groupid.ToGuid()); //if (defaultMember.IsNullOrEmpty() && currentStep.ID == wfInstalled.FirstStepID) //{ receiveId = RoadFlow.Platform.Users.PREFIX + RoadFlow.Platform.Users.CurrentUserID.ToString(); //} break; case 7://某一步骤处理者 receiveId = bworkFlowTask.GetStepSnderIDString(wfInstalled.ID, nextSteps[0].Behavior.HandlerStepID, groupid.ToGuid()); break; case 8://字段值 string linkString = nextSteps[0].Behavior.ValueField; if (!linkString.IsNullOrEmpty() && !instanceid.IsNullOrEmpty() && wfInstalled.DataBases.Count() > 0) { receiveId = new RoadFlow.Platform.DBConnection().GetFieldValue(linkString, wfInstalled.DataBases.First().PrimaryKey, instanceid); } break; } execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); } } var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "用车流程处理异常" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "APP操作请求", "用车流程处理"); return returnstr; } #endregion #endregion #region 公差申请-多级分支多级机构 //公差申请 private string AppToleranceTaskApplyMoreStep(HttpContext context) { string returnstr = ""; try { bool flag = false; //公差表单字段 string toleranceId = context.Request.Params["toleranceId"]; if (string.IsNullOrEmpty(toleranceId)) { flag = true; toleranceId = Guid.NewGuid().ToString().ToGuid().ToString(); } string pplId = context.Request.Params["pplId"]; string pplName = context.Request.Params["pplName"]; string lType = context.Request.Params["lType"]; string sTime = context.Request.Params["sTime"]; string eTime = context.Request.Params["eTime"]; string lNum = context.Request.Params["lNum"]; string lOut = context.Request.Params["lOut"]; string accPplId = context.Request.Params["accId"]; string repPplId = context.Request.Params["repId"]; string lReason = context.Request.Params["reason"]; string title = context.Request.Params["title"]; string carNum = context.Request.Params["carNum"]; string carId = context.Request.Params["carId"]; FangYar.Model.OA.OA_TOLERANCE toleranceModel = new FangYar.Model.OA.OA_TOLERANCE(); toleranceModel.ID = toleranceId; toleranceModel.PPL_ID = pplId; toleranceModel.PPL_NAME = pplName; toleranceModel.L_TYPE = lType; toleranceModel.S_TIME = sTime; toleranceModel.E_TIME = eTime; toleranceModel.L_NUM = lNum; toleranceModel.L_OUT = lOut; toleranceModel.ACC_PPL = accPplId; toleranceModel.REP_PPL = repPplId; toleranceModel.L_REASON = lReason; toleranceModel.TITLE = title; toleranceModel.STATE = "0"; toleranceModel.CAR_NUM = carNum; toleranceModel.EXTENDCODE3 = carId; string str = AppToleranceApplyFirst(pplId); if (str != null && str.Contains(';')) { var str2 = str.Split(';'); toleranceModel.EXTENDCODE1 = str2[1]; toleranceModel.EXTENDCODE2 = str2[0]; } FangYar.BLL.OA.OA_TOLERANCE carBll = new FangYar.BLL.OA.OA_TOLERANCE(); RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); string opation = context.Request.Params["opation"];//操作类型 string receiveId = context.Request.Params["receiveId"];//接收人员 if (string.IsNullOrEmpty(receiveId)) { receiveId = toleranceModel.EXTENDCODE1; } switch (opation) { case "apply": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; } //流程字段 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID var wfInstalled = bworkFlow.GetWorkFlowRunModel("7a3711b6-4cf1-4501-823e-9ccd69eec4da"); if (flag) { carBll.Add(toleranceModel); execute.FlowID = "7a3711b6-4cf1-4501-823e-9ccd69eec4da".ToGuid(); execute.GroupID = Guid.Empty; execute.InstanceID = toleranceModel.ID.ToGuid().ToString(); execute.IsSign = false; execute.Note = ""; execute.Sender = userBll.GetModelByUID(pplId); execute.StepID = wfInstalled.FirstStepID; execute.TaskID = Guid.Empty; } else { carBll.Update(toleranceModel); wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); } execute.Title = title ?? ""; RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == eventParams.StepID); var currentStep = steps.First(); var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "公差申请异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "APP操作请求", "公差申请"); return returnstr; } /// /// 流程发起查询对应步骤和处理人 /// /// /// private string AppToleranceApplyFirst(string userId) { FangYar.BLL.TBL.SysEmpBLL bll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.BLL.FIRE.FIRE_ORG bll_org = new FangYar.BLL.FIRE.FIRE_ORG(); string returnstr = ""; try { var user = bll.GetModelByUID(userId); var nextUid = ""; var nextStep = ""; var org = bll_org.GetModel(user.ORG_ID);//所在单位部门 var unit_org = org;//所在单位 var tags = user.TAGS; if (!string.IsNullOrEmpty(user.TAGS_BAK)) { tags = user.TAGS_BAK; } if (tags != null && tags.Contains("消防站")) { nextStep = "1_"; nextUid = ""; //获取消防站主官 var listuser = bll.QueryListByOrgIdOrDeptId(unit_org.ORG_ID); if (listuser != null && listuser.Count > 0) { foreach (var model in listuser) { if (model.TAGS != null && ("," + model.TAGS + ",").Contains(",消防站主官,")) { nextUid += model.USERS_UID + ","; } } } nextUid = nextUid.Trim(','); } else if (tags.Contains("大队")) { nextStep = "2_"; nextUid = ""; //获取支队长、政委 var listuser = bll.QueryListByOrgIdOrDeptId(unit_org.ORG_ID); if (listuser != null && listuser.Count > 0) { foreach (var model in listuser) { if (model.TAGS != null && (("," + model.TAGS + ",").Contains(",大队长,") || ("," + model.TAGS + ",").Contains(",教导员,"))) { nextUid += model.USERS_UID + ","; } } } nextUid = nextUid.Trim(','); } else { nextStep = "3_"; nextUid = ""; var dept_org = bll_org.GetModel(user.DEPT_ID);//部门信息 if (dept_org != null && dept_org.LEADER != null) { var kz = bll.GetModelByID(dept_org.LEADER); if (kz != null && kz.USERS_UID != null) { nextUid = kz.USERS_UID;//部门领导 } } } returnstr += nextStep + ";" + nextUid; } catch (Exception ex) { returnstr = ""; string str = "流程发起查询对应步骤和处理人异常:" + ex; FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = str, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error, path = "AppHandLog" }); } return returnstr; } #region 公差流程处理 //公差流程处理 private string AppToleranceWorkFlowTaskHandle(HttpContext context) { string returnstr = ""; try { //流程字段 string comment = context.Request.Params["comment"];//处理意见 string opation = context.Request.Params["opation"];//操作类型 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string receiveId = context.Request.Params["receiveId"];//接收人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID string title = context.Request.Params["title"];//标题 RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.OA.OA_TOLERANCE tolerancebll = new FangYar.BLL.OA.OA_TOLERANCE(); FangYar.Model.OA.OA_TOLERANCE toleranceModel = tolerancebll.GetModel(instanceid); switch (opation) { case "submit": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; case "back": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "completed": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "redirect": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Redirect; break; //新增同意 case "agree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; //新增不同意 case "disagree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree; tolerancebll.EditState(instanceid, "2"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; } FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); execute.Title = title ?? ""; RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == execute.StepID); var currentStep = steps.First(); if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { var steps2 = wfInstalled.Steps.Where(p => p.ID == stepid.ToGuid()); var currentStep2 = steps2.First(); int backType = currentStep2.Behavior.BackType;//退回类型 var prevSteps = bworkFlowTask.GetBackSteps(taskid.ToGuid(), backType, stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID, wfInstalled); foreach (var step in prevSteps) { execute.Steps.Add(step.Key, new List()); } } else { var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); if (nextSteps.Count > 0) { switch (nextSteps[0].Behavior.HandlerType) { case 5://发起者 receiveId = bworkFlowTask.GetFirstSnderID(wfInstalled.ID, groupid); break; case 6://前一步骤处理者 //defaultMember = btask.GetStepSnderIDString(wfInstalled.ID, currentStep.ID, groupid.ToGuid()); //if (defaultMember.IsNullOrEmpty() && currentStep.ID == wfInstalled.FirstStepID) //{ receiveId = RoadFlow.Platform.Users.PREFIX + RoadFlow.Platform.Users.CurrentUserID.ToString(); //} break; case 7://某一步骤处理者 receiveId = bworkFlowTask.GetStepSnderIDString(wfInstalled.ID, nextSteps[0].Behavior.HandlerStepID, groupid.ToGuid()); break; case 8://字段值 string linkString = nextSteps[0].Behavior.ValueField; if (!linkString.IsNullOrEmpty() && !instanceid.IsNullOrEmpty() && wfInstalled.DataBases.Count() > 0) { receiveId = new RoadFlow.Platform.DBConnection().GetFieldValue(linkString, wfInstalled.DataBases.First().PrimaryKey, instanceid); } break; } execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); } } var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "公差流程处理异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "APP操作请求", "公差流程处理"); return returnstr; } #endregion #endregion #region 巡查巡检 /// /// 巡查巡检 /// /// /// private string AppCountPatrolTask(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["OrgId"];//机构id string stime = context.Request.Params["stime"];//开始日期 string etime = context.Request.Params["etime"];//结束日期 string sql = ""; string sql1 = ""; FangYar.BLL.FIRE.FIRE_ORG orgBll = new FangYar.BLL.FIRE.FIRE_ORG(); FangYar.BLL.FIRE.FIRE_INSPECT inspectBLL = new FangYar.BLL.FIRE.FIRE_INSPECT(); returnstr = "{\"code\":0,\"msg\":\"\""; sql += " SELECT org_name, org_id,orgType,"; sql += " sum(case when state = '0' then 1 else 0 end) +sum(case when state = '1' then 1 else 0 end) as zs,"; sql += " sum(case when state = '0' then 1 else 0 end) as wxc,"; sql += " sum(case when state = '1' then 1 else 0 end) as yxc,"; sql += " CONCAT(ROUND(sum(case when state = '1' then 1 else 0 end)*100 /"; sql += " case (sum(case when state = '0' then 1 else 0 end) +sum(case when state = '1' then 1 else 0 end)) when 0 THEN 1 ELSE(sum(case when state = '0' then 1 else 0 end) +sum(case when state = '1' then 1 else 0 end)) END ,2) , '%') as xcl"; sql += " FROM ( SELECT fo.org_name,fo.org_id,fo.EXTENDCODE1 as orgType ,pt.state state FROM fire_org fo LEFT JOIN("; sql += " SELECT org_id, state FROM ( SELECT tas.id,tas.org_id, tra.state FROM ("; sql += " SELECT * FROM oa_patrol_task t WHERE t.org_id IN( SELECT org_id FROM fire_org,("; sql += " SELECT get_Org_child_list('" + orgId + "') cids ) s WHERE type = 0"; sql += " AND find_in_set(org_id, cids) ) "; sql += " AND ((DATE_FORMAT( s_time, '%Y-%m-%d' ) >= DATE_FORMAT( '" + stime + "', '%Y-%m-%d' ) "; sql += " AND DATE_FORMAT(e_time, '%Y-%m-%d' ) <= DATE_FORMAT('" + etime + "', '%Y-%m-%d'))"; sql += " or"; sql += " (DATE_FORMAT(s_time, '%Y-%m-%d') >= DATE_FORMAT('" + stime + "', '%Y-%m-%d') AND"; sql += " DATE_FORMAT(s_time, '%Y-%m-%d') <= DATE_FORMAT('" + etime + "', '%Y-%m-%d'))"; sql += " or"; sql += " (DATE_FORMAT(e_time, '%Y-%m-%d') >= DATE_FORMAT('" + stime + "', '%Y-%m-%d') AND"; sql += " DATE_FORMAT(e_time, '%Y-%m-%d') <= DATE_FORMAT('" + etime + "', '%Y-%m-%d'))"; sql += " )"; sql += " ) tas"; sql += " LEFT JOIN oa_patrol_trajectory tra ON tas.id = tra.task_id ) a ) pt ON fo.org_id = pt.org_id"; sql += " WHERE fo.org_id IN( SELECT org_id FROM fire_org,( SELECT get_Org_child_list ('" + orgId + "') cids ) s"; sql += " WHERE TYPE = 0 AND find_in_set(org_id, cids)) AND fo.TYPE = 0 ) d group by org_name, org_id"; sql += " ORDER BY ORG_ID = '" + orgId + "' desc"; sql1 += "select b.id taskid,b.org_id,b.NAME,b.EMP_NAME,STR_TO_DATE(s_time, '%Y-%m-%d %H:%i:%s') S_TIME,"; sql1 += " STR_TO_DATE(e_time, '%Y-%m-%d %H:%i:%s') E_TIME,STATE from oa_patrol_task b "; sql1 += " where b.org_id='" + orgId + "'"; sql1 += " AND("; sql1 += " (DATE_FORMAT(s_time, '%Y-%m-%d') >= DATE_FORMAT('" + stime + "', '%Y-%m-%d')"; sql1 += " AND DATE_FORMAT(e_time, '%Y-%m-%d') <= DATE_FORMAT('" + etime + "', '%Y-%m-%d'))"; sql1 += " or"; sql1 += " (DATE_FORMAT(s_time, '%Y-%m-%d') >= DATE_FORMAT('" + stime + "', '%Y-%m-%d') AND"; sql1 += " DATE_FORMAT(s_time, '%Y-%m-%d') <= DATE_FORMAT('" + etime + "', '%Y-%m-%d'))"; sql1 += " or"; sql1 += " (DATE_FORMAT(e_time, '%Y-%m-%d') >= DATE_FORMAT('" + stime + "', '%Y-%m-%d') AND"; sql1 += " DATE_FORMAT(e_time, '%Y-%m-%d') <= DATE_FORMAT('" + etime + "', '%Y-%m-%d'))"; sql1 += " )"; sql1 += " ORDER BY S_TIME desc"; returnstr += ",\"orgData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(new CommomBLL().GetTableList(sql)); returnstr += ",\"taskData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(new CommomBLL().GetTableList(sql1)); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "巡查巡检异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "巡查巡检"); return returnstr; } #endregion #region 查铺查哨 /// /// 查铺查哨(机构和任务) /// qA1 /// /// private string AppCountFireInspect(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["OrgId"];//机构id string sn_Id = context.Request.Params["sn_Id"];//1.查铺2.查哨 string startDate = context.Request.Params["stime"];//日期 string endDate = context.Request.Params["etime"];//日期 string sql = ""; string sql1 = ""; sql += "SELECT b.org_id, b.org_name,b.orgType, IFNULL(placeZS, 0) placeZS, IFNULL(placeYXC, 0) placeYXC,"; sql += " ( IFNULL(placeZS, 0) - IFNULL(placeYXC, 0)) placeWXC,IFNULL(zs, 0) zs,IFNULL(zw, 0) zw,"; sql += " IFNULL(wd, 0) wd, IFNULL(wc, 0) wc FROM ( SELECT org_id, org_name,EXTENDCODE1 as orgType FROM fire_org,"; sql += " (SELECT get_Org_child_list('" + orgId + "' ) cids ) s WHERE"; sql += " type = 0 AND find_in_set(org_id, cids)) b LEFT JOIN("; sql += " SELECT count(1) placeZS, org_id FROM fire_inspect t"; sql += " INNER JOIN OA_PATROLSENTRYTASK s ON t.sentrytaskid = s.id WHERE (REPLACE(TASKNAME,'查铺查哨任务','') between '" + startDate + "' and '" + endDate + "')"; sql += " GROUP BY org_id ) a ON a.org_id = b.org_id LEFT JOIN( SELECT count(1) placeYXC, org_id FROM fire_inspect t"; sql += " INNER JOIN OA_PATROLSENTRYTASK s ON t.sentrytaskid = s.id WHERE (REPLACE(TASKNAME,'查铺查哨任务','') between '" + startDate + "' and '" + endDate + "')"; sql += " AND EXTENDCODE2 IS NOT NULL GROUP BY org_id) d ON d.org_id = b.org_id LEFT JOIN("; sql += " SELECT t.org_id,sum(EXTENDCODE6) zs,sum(EXTENDCODE2) zw,sum(EXTENDCODE4) wd,sum(LEAVE_NUM) wc FROM fire_inspect t"; sql += " INNER JOIN OA_PATROLSENTRYTASK s ON t.sentrytaskid = s.id WHERE (REPLACE(TASKNAME,'查铺查哨任务','') between '" + startDate + "' and '" + endDate + "')"; sql += " GROUP BY t.org_id ) c ON c.org_id = b.org_id ORDER BY b.ORG_ID = '" + orgId + "' desc"; sql1 += " SELECT b.orgid, b.Id Task_ID, b.TASKNAME, b.PATROLLER, date_format(b.BEGINDATE, '%Y-%m-%d') InspectDate,"; sql1 += " date_format(b.BEGINDATE, '%H:%i:%s') BEGINDATE, date_format(b.ENDDATE, '%H:%i:%s') ENDDATE,IFNULL(placeZS, 0) placeZS,"; sql1 += " IFNULL(placeYXC, 0) placeYXC,( IFNULL(placeZS, 0) - IFNULL(placeYXC, 0)) placeWXC, IFNULL(zs, 0) zs, IFNULL(zw, 0) zw,"; sql1 += " IFNULL(wd, 0) wd, IFNULL(wc, 0) wc FROM OA_PATROLSENTRYTASK b LEFT JOIN("; sql1 += " SELECT count(1) placeZS, SENTRYTASKID FROM fire_inspect t GROUP BY SENTRYTASKID ) a ON a.SENTRYTASKID = b.id"; sql1 += " LEFT JOIN( SELECT count(1) placeYXC,SENTRYTASKID FROM fire_inspect t WHERE EXTENDCODE2 IS NOT NULL GROUP BY"; sql1 += " SENTRYTASKID ) d ON d.SENTRYTASKID = b.id LEFT JOIN( SELECT t.SENTRYTASKID,sum(EXTENDCODE6) zs, sum(EXTENDCODE2) zw,"; sql1 += " sum(EXTENDCODE4) wd, sum(LEAVE_NUM) wc FROM fire_inspect t GROUP BY t.SENTRYTASKID ) c ON c.SENTRYTASKID = b.id"; sql1 += " WHERE b.orgid = '" + orgId + "' AND (REPLACE(TASKNAME,'查铺查哨任务','') between '" + startDate + "'and '" + endDate + "' )"; sql1 += " ORDER BY createdate DESC "; FangYar.OracleDAL.FIRE.FIRE_ORG orgDal = new FangYar.OracleDAL.FIRE.FIRE_ORG(); FangYar.BLL.FIRE.FIRE_INSPECT inspectBLL = new FangYar.BLL.FIRE.FIRE_INSPECT(); returnstr = "{\"code\":0,\"msg\":\"\""; returnstr += ",\"orgData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(new CommomBLL().GetTableList(sql)); returnstr += ",\"taskData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(new CommomBLL().GetTableList(sql1)); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "查铺查哨(机构和任务)异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "查铺查哨(机构和任务)"); return returnstr; } #endregion #region 请假统计 /// /// 请假统计 /// /// /// private string AppCountLeave(HttpContext context) { string returnstr = ""; try { string org_id = context.Request.Params["org_id"];//机构id string stime = context.Request.Params["stime"];//stime string etime = context.Request.Params["etime"];//etime string islower = context.Request.Params["islower"];//islower 0 本级 1多级 FangYar.BLL.FIRE.FIRE_ORG orgBll = new FangYar.BLL.FIRE.FIRE_ORG(); FangYar.BLL.TBL.SysEmpBLL empBll = new FangYar.BLL.TBL.SysEmpBLL(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; string sql = " SELECT o.org_id, o.org_name,IFNULL(sj + bj + nj + cj + phj + lx + tqj, 0) qjzs,IFNULL(sj, 0) sj,IFNULL(bj, 0) bj,"; sql += " IFNULL(nj, 0) nj,IFNULL(cj, 0) cj,IFNULL(phj, 0) phj,IFNULL(lx, 0) lx,IFNULL(tqj, 0) tqj FROM"; sql += " (SELECT org_id, org_name FROM fire_org, (SELECT get_Org_child_list('" + org_id + "') cids) s"; sql += " WHERE type = 0 "; if (!string.IsNullOrEmpty(islower) && islower == "1") { sql += " AND find_in_set(org_id, cids) "; } else { sql += " and org_id ='" + org_id + "' "; } sql += " ) o LEFT JOIN( SELECT org_id, "; sql += " sum(case when l_type = 'a1e92887-8230-4aba-8a06-bebffdee8043' then 1 else 0 end) as sj,"; sql += " sum(case when l_type = 'd0b8d5f6-b708-4bec-ba2f-f4bd15d274e4' then 1 else 0 end) as bj,"; sql += " sum(case when l_type = '88f884d7-4b8e-441a-a3f5-b9192629d4e0' then 1 else 0 end) as nj,"; sql += " sum(case when l_type = 'd2122199-23a7-4b59-87d4-b9b60e17735b' then 1 else 0 end) as cj,"; sql += " sum(case when l_type = 'f594d6d0-4ad7-4695-ad2e-6a06c870b25d' then 1 else 0 end) as phj,"; sql += " sum(case when l_type = '16c2c5d0-bd9f-efa9-b9af-6f71ab17f8ba' then 1 else 0 end) as lx,"; sql += " sum(case when l_type = '1cc3d849-b755-4f2c-8fc7-d47610030373' then 1 else 0 end) as tqj"; sql += " FROM (SELECT users_uid,org_id,l_type FROM OA_LEAVE a LEFT JOIN TBL_SYS_EMP b ON b.IS_ADMIN='0' and b.users_uid = a.ppl_id"; sql += " WHERE STATE = '1'AND STR_TO_DATE( S_TIME,'%Y-%m-%d') >= STR_TO_DATE('" + stime + "', '%Y-%m-%d')"; sql += " AND STR_TO_DATE(E_TIME,'%Y-%m-%d') <= STR_TO_DATE('" + etime + "', '%Y-%m-%d')) a GROUP BY org_id) k ON o.org_id = k.org_id"; sql += " ORDER BY o.ORG_ID = '" + org_id + "' desc "; DataTable data = new CommomBLL().GetTableList(sql); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "请假统计异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "请假统计"); return returnstr; } #endregion #region 获取机构 private string AppGetOrgNodeTree(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["OrgId"]; string type = context.Request.Params["Type"]; string deptId = context.Request.Params["DeptId"]; if (deptId == "0192a6228fca4ed2bea225ad3bbf0dc9") { orgId = deptId; } returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; var data = GetNode(orgId); returnstr += FangYar.Common.JsonManager.Serialize(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取机构异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取机构"); return returnstr; } private Model.TreeNodeModel GetNode(string Pid) { FangYar.BLL.FIRE.FIRE_ORG bll = new FangYar.BLL.FIRE.FIRE_ORG(); var org = bll.GetModel(Pid); var node = GetTreeNodeModel(org); node.childs = GetChildList(node.id); return node; } public Model.TreeNodeModel GetTreeNodeModel(DataRow dr) { Model.TreeNodeModel childViewModel = new Model.TreeNodeModel(); childViewModel.id = dr["ORG_ID"].ToString(); childViewModel.pId = dr["PID"].ToString(); childViewModel.name = dr["ORG_NAME"].ToString(); childViewModel.extend = dr["TYPE"].ToString(); return childViewModel; } public Model.TreeNodeModel GetTreeNodeModel(FangYar.Model.FIRE.FIRE_ORG org) { Model.TreeNodeModel childViewModel = new Model.TreeNodeModel(); childViewModel.id = org.ORG_ID; childViewModel.pId = org.PID; childViewModel.name = org.ORG_NAME; childViewModel.extend = org.TYPE; return childViewModel; } public List GetChildList(string Pid) { FangYar.BLL.FIRE.FIRE_ORG bll = new FangYar.BLL.FIRE.FIRE_ORG(); var orgList = bll.GetModelList(" pid='" + Pid + "'"); List list = new List(); if (orgList.Count > 0) { foreach (var org in orgList) { Model.TreeNodeModel node = GetTreeNodeModel(org); node.childs = GetChildList(node.id); list.Add(node); } } else { return null; } return list; } #endregion #region 统计 #region 人员统计 /// /// 人员统计 /// /// /// private string AppCountEmp(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["OrgId"]; FangYar.BLL.FIRE.FIRE_ORG orgBll = new FangYar.BLL.FIRE.FIRE_ORG(); FangYar.BLL.TBL.SysEmpBLL empBll = new FangYar.BLL.TBL.SysEmpBLL(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; string sql = " select b.org_id,b.org_name,ifnull(zs,0) zs,ifnull(zg,0) zg,ifnull(zs,0)-ifnull(zg,0)-ifnull(qj,0) qt,ifnull(qj,0) qj,CONCAT(round((ifnull(zg,0)/ifnull(zs,0))*100,2),'%') zgl from (select org_id,org_name from fire_org o,(select get_Org_child_list('" + orgId + "') cids ) s where o.type=0 and find_in_set(o.org_id,cids) ) b "; sql += " left join (select count(1) zs,org_id from TBL_SYS_EMP where IS_ADMIN='0' and (IS_DEL ='0' or IS_DEL is null ) group by org_id)c on b.org_id=c.org_id "; sql += " left join (select count(1) qj,org_id from TBL_SYS_EMP where IS_ADMIN='0' and is_work='4' and (IS_DEL ='0' or IS_DEL is null ) group by org_id)d on b.org_id=d.org_id "; sql += " left join (select count(1) zg,org_id from TBL_SYS_EMP where IS_ADMIN='0' and is_work='1' and (IS_DEL ='0' or IS_DEL is null ) group by org_id)e on b.org_id=e.org_id "; DataTable data = new CommomBLL().GetTableList(sql); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "人员统计异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "人员统计"); return returnstr; } #endregion #region 车辆统计 /// /// 车辆统计 /// /// /// private string AppCountCar(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["OrgId"]; FangYar.BLL.FIRE.FIRE_ORG orgBll = new FangYar.BLL.FIRE.FIRE_ORG(); FangYar.BLL.TBL.SysEmpBLL empBll = new FangYar.BLL.TBL.SysEmpBLL(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; string sql = " select b.org_id,b.org_name,ifnull(zs,0) zs,ifnull(zg,0)+ifnull(sqz,0) zg ,ifnull(zs,0)-ifnull(zg,0)-ifnull(sqz,0)-ifnull(ly,0) qt,ifnull(ly,0) ly,CONCAT(round((ifnull(zg,0)/ifnull(zs,0))*100,2),'%') zgl from (select org_id,org_name from fire_org o,(select get_Org_child_list('" + orgId + "') cids ) s where o.type=0 and find_in_set(o.org_id,cids) ) b "; sql += " left join (select count(1) zs,org_id from TBL_SYS_CAR where (IS_DEL ='0' or IS_DEL is null ) group by org_id)c on b.org_id=c.org_id "; sql += " left join (select count(1) zg,org_id from TBL_SYS_CAR where ISAPPLY='0' and (IS_DEL ='0' or IS_DEL is null ) group by org_id)d on b.org_id=d.org_id "; sql += " left join (select count(1) sqz,org_id from TBL_SYS_CAR where ISAPPLY='1' and (IS_DEL ='0' or IS_DEL is null ) group by org_id)f on b.org_id=f.org_id "; sql += " left join (select count(1) ly,org_id from TBL_SYS_CAR where ISAPPLY='2' and (IS_DEL ='0' or IS_DEL is null ) group by org_id)e on b.org_id=e.org_id "; DataTable data = new CommomBLL().GetTableList(sql); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "车辆统计异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "车辆统计"); return returnstr; } #endregion #region 查铺查哨(地点) /// /// 查铺查哨(地点) /// /// /// private string AppCountFireInspectPlace(HttpContext context) { string returnstr = ""; try { string taskId = context.Request.Params["taskId"];//任务Id string sn_Id = context.Request.Params["sn_Id"];//1.查铺2.查哨 string sql = ""; FangYar.BLL.FIRE.FIRE_ORG orgBll = new FangYar.BLL.FIRE.FIRE_ORG(); FangYar.BLL.FIRE.FIRE_INSPECT inspectBLL = new FangYar.BLL.FIRE.FIRE_INSPECT(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; //任务列表 sql = "select (select spot.NAME from oa_patrol_spot spot where spot.SPOT_NO = t.FID) as ADDR,t.L_TIME,t.CN_NAME,ifnull(t.EXTENDCODE6,0) zs,ifnull(t.EXTENDCODE2,0) zw,ifnull(t.EXTENDCODE4,0) wd,ifnull(t.LEAVE_NUM,0) wc from FIRE_INSPECT t " + "where t.SENTRYTASKID = '" + taskId + "' "; DataTable data = new CommomBLL().GetTableList(sql); //图表 sql = ""; sql += "select b.id,b.TASKNAME,ifnull(placeZS,0) placeZS,ifnull(placeYXC,0) placeYXC,(ifnull(placeZS,0)-ifnull(placeYXC,0)) placeWXC,"; sql += "ifnull(zs,0) zs,ifnull(zw,0) zw,ifnull(wd,0) wd,ifnull(wc,0) wc from "; sql += " OA_PATROLSENTRYTASK b"; sql += " left join (select t.SENTRYTASKID,ifnull(sum(t.EXTENDCODE6),0) zs,ifnull(sum(t.EXTENDCODE2),0) zw,ifnull(sum(t.EXTENDCODE4),0) wd,ifnull(sum(t.LEAVE_NUM),0) wc "; sql += " from FIRE_INSPECT t"; sql += " group by t.SENTRYTASKID) a on a.SENTRYTASKID=b.id"; sql += " left join (select count(1) placeZS,SENTRYTASKID from fire_inspect t group by SENTRYTASKID)c on c.SENTRYTASKID=b.id "; sql += " left join (select count(1) placeYXC,SENTRYTASKID from fire_inspect t where EXTENDCODE2 is not null group by SENTRYTASKID)d on d.SENTRYTASKID=b.id"; sql += " where b.id='" + taskId + "'"; sql += ""; DataTable data2 = new CommomBLL().GetTableList(sql); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += ",\"echartsData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data2); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "查铺查哨(地点)异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "查铺查哨(地点)"); return returnstr; } #endregion #region 巡查巡检任务列表 /// /// 巡查巡检任务列表 /// /// /// private string AppCountPatrolTaskList(HttpContext context) { string returnstr = ""; try { string task_Id = context.Request.Params["task_Id"];//机构id string sql = ""; string sql1 = ""; FangYar.BLL.FIRE.FIRE_ORG orgBll = new FangYar.BLL.FIRE.FIRE_ORG(); FangYar.BLL.FIRE.FIRE_INSPECT inspectBLL = new FangYar.BLL.FIRE.FIRE_INSPECT(); returnstr = "{\"code\":0,\"msg\":\"\""; sql += " select (select spot.NAME from oa_patrol_spot spot where spot.ID = t.SPOT_ID) as ADDR,t.EXTENDCODE2 EMP_NAME,TIME from oa_patrol_trajectory t where t.task_id='" + task_Id + "'"; sql1 += "select '" + task_Id + "' task_id,(select name from oa_patrol_task t where t.id='" + task_Id + "') taskname"; sql1 += ",ifnull(wxc,0)+ifnull(yxc,0) zs,ifnull(wxc,0) wxc,ifnull(yxc,0) yxc,CONCAT(round(ifnull((ifnull(yxc,0)/(case when ifnull(wxc+yxc,0)=0 then 1 else ifnull(wxc+yxc,0) end))*100,0),2),'%') xcl"; sql1 += " from(select sum(case state when '0' then 1 else 0 end) wxc,sum(case state when '1' then 1 else 0 end) yxc from oa_patrol_trajectory where task_id='" + task_Id + "')"; sql1 += " t "; returnstr += ",\"Data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(new CommomBLL().GetTableList(sql)); returnstr += ",\"echartsData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(new CommomBLL().GetTableList(sql1)); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "巡查巡检任务列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "巡查巡检任务列表"); return returnstr; } #endregion #region 巡查巡检任务点数据 /// /// 巡查巡检任务点数据 /// /// /// private string AppGetPartolTaskTrajectory(HttpContext context) { string returnstr = ""; try { string org_id = context.Request.Params["org_id"];//机构id string taskdate = context.Request.Params["taskdate"];//taskdate string type = context.Request.Params["type"];//type string islower = context.Request.Params["islower"];//islower string page = context.Request.Params["page"];//page string limit = context.Request.Params["limit"];//limit int pageIndex = 1; int pageSize = 10; int satrtNum = 1, endNum = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } satrtNum = (pageIndex - 1) * pageSize + 1; endNum = pageIndex * pageSize; string sql = ""; returnstr = "{\"code\":0,\"msg\":\"\""; sql += " select * from (select rownum as rn, t.name, opt.* from OA_PATROL_TASK t inner join OA_PATROL_TRAJECTORY opt on t.id = opt.task_id "; sql += " where "; if (islower == "0") { sql += " t.org_id = '" + org_id + "' "; } else if (islower == "1") { sql += " t.org_id in ( select o.org_id from fire_org o,(select get_Org_child_list('" + org_id + "') cids ) s WHERE find_in_set(org_id,cids))"; } sql += "and date_format(t.s_time,'%Y-%m-%d')= date_format('" + taskdate + "', '%Y-%m-%d')"; if (!string.IsNullOrEmpty(type)) { if (type == "0") //未完成 { sql += " and opt.state! = '1'"; } else { sql += " and opt.state = '1'"; } } sql += " ) where rn>= " + satrtNum + " and rn<= " + endNum; returnstr += ",\"Data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(new CommomBLL().GetTableList(sql)); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "巡查巡检任务点数据异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "巡查巡检任务点数据"); return returnstr; } #endregion #region 公差统计列表 /// /// 公差统计列表 /// /// /// private string AppGetToleranceStaList(HttpContext context) { string returnstr = ""; try { string org_id = context.Request.Params["org_id"];//机构id string ppl_name = context.Request.Params["ppl_name"];//ppl_name string l_type = context.Request.Params["l_type"];//l_type string stime = context.Request.Params["stime"];//stime string etime = context.Request.Params["etime"];//etime string islower = context.Request.Params["islower"];//islower 0 本级 1多级 string page = context.Request.Params["page"];//page string limit = context.Request.Params["limit"];//limit int pageIndex = 1; int pageSize = 10; int satrtNum = 1, endNum = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } satrtNum = (pageIndex - 1) * pageSize + 1; endNum = pageIndex * pageSize; string sql = ""; returnstr = "{\"code\":0,\"msg\":\"\""; sql += " select * from ( select ROW_NUMBER() over(order by date_format(a.s_time, '%Y-%m-%d %H:%i:%s') desc) as rn ,a.* ,b.org_name from("; sql += " select t.*,e.org_id , d.title as dtitle from OA_TOLERANCE t left"; sql += " join tbl_sys_emp e on e.IS_ADMIN='0' and t.ppl_id = e.users_uid left join dictionary d on t.l_type = d.id"; sql += " where 1 = 1"; if (!string.IsNullOrEmpty(ppl_name)) { sql += " and ppl_name like '%" + ppl_name + "%'"; } if (!string.IsNullOrEmpty(l_type)) { sql += " and l_type = '" + l_type + "'"; } sql += " and date_format('" + stime + "', '%Y-%m-%d') <= date_format(t.S_TIME, '%Y-%m-%d %H:%i:%s') "; sql += " and date_format('" + etime + "', '%Y-%m-%d') >= date_format(t.E_TIME, '%Y-%m-%d %H:%i:%s')"; sql += " )a left join fire_org b on a.org_id = b.org_id "; sql += " where "; if (islower == "1") { sql += " a.org_id in (select o.org_id from fire_org o,(select get_Org_child_list('" + org_id + "') cids ) s WHERE find_in_set(org_id,cids) and o.type = '0' )"; } else if (islower == "0") { sql += " a.org_id ='" + org_id + "'"; } sql += " )asd where rn>= " + satrtNum + " and rn<= " + endNum; returnstr += ",\"Data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(new CommomBLL().GetTableList(sql)); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "公差统计列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "公差统计列表"); return returnstr; } #endregion #region 用车统计 /// /// 用车统计 /// /// /// private string AppCountCarApply(HttpContext context) { string returnstr = ""; try { string org_id = context.Request.Params["org_id"];//机构id string stime = context.Request.Params["stime"];//stime string etime = context.Request.Params["etime"];//etime string islower = context.Request.Params["islower"];//islower 0 本级 1多级 FangYar.BLL.FIRE.FIRE_ORG orgBll = new FangYar.BLL.FIRE.FIRE_ORG(); FangYar.BLL.TBL.SysEmpBLL empBll = new FangYar.BLL.TBL.SysEmpBLL(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; string sql = "select o.org_id,o.org_name,ifnull(k.zs,0) from "; sql += " (select org_id,org_name from fire_org "; if (!string.IsNullOrEmpty(islower) && islower == "1") { sql += " ,(select get_Org_child_list('" + org_id + "') cids ) s WHERE find_in_set(org_id,cids) "; } else { sql += " where org_id ='" + org_id + "' "; } sql += " and type=0"; sql += ") o left join "; sql += " (select org_id,count(1) zs from ( "; sql += " select USERID,org_id from TBL_SYS_CARAPPLY a left join TBL_SYS_EMP b on b.IS_ADMIN='0' and b.users_uid=a.userid "; sql += " where STATE='1' AND date_format(STARTTIME,'%Y-%m-%d') >= date_format('" + stime + "', '%Y-%m-%d') "; sql += " and date_format(FINISHTIME,'%Y-%m-%d') <= date_format('" + etime + "', '%Y-%m-%d') )"; sql += " group by org_id) k on o.org_id=k.org_id"; DataTable data = new CommomBLL().GetTableList(sql); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "用车统计异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "用车统计"); return returnstr; } #endregion #endregion #region 信息列表 //人员列表查询 private string AppGetOrgEmpList(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["orgId"]; string keyword = context.Request.Params["keywords"]; string iswork = context.Request.Params["iswork"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; string islower = context.Request.Params["islower"]; string sdate = context.Request.Params["sdate"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } string where = ""; if (!string.IsNullOrEmpty(islower) && islower == "1") { where = " org_id in ( select o.org_id from fire_org o,(select get_Org_child_list('" + OrgId + "') cids ) s WHERE find_in_set(org_id,cids)) "; } else { where = " ORG_ID = '" + OrgId + "' "; } if (!string.IsNullOrEmpty(iswork)) { if (iswork == "1") { //where += " and IS_WORK='1' "; where += "and USERS_UID not in ( select PPL_ID from OA_LEAVE where STATE='1' AND date_format(s_time, '%Y-%m-%d') >= date_format('" + sdate + "', '%Y-%m-%d') and date_format( e_time, '%Y-%m-%d') <= date_format('" + sdate + "', '%Y-%m-%d')) "; where += "and USERS_UID not in ( select PPL_ID from OA_TOLERANCE where STATE='1' AND date_format(s_time, '%Y-%m-%d') >= date_format('" + sdate + "', '%Y-%m-%d') and date_format( e_time, '%Y-%m-%d') <= date_format('" + sdate + "', '%Y-%m-%d')) "; } else if (iswork == "2") { //where += " and IS_WORK='4' "; where += "and USERS_UID in ( select PPL_ID from OA_LEAVE where STATE='1' AND date_format(s_time, '%Y-%m-%d') >= date_format('" + sdate + "', '%Y-%m-%d') and date_format( e_time, '%Y-%m-%d') <= date_format('" + sdate + "', '%Y-%m-%d')) "; } else if (iswork == "3") { // where += " and IS_WORK != '1' and IS_WORK != '4' "; where += "and USERS_UID in ( select PPL_ID from OA_TOLERANCE where STATE='1' AND date_format( s_time, '%Y-%m-%d') >= date_format('" + sdate + "', '%Y-%m-%d') and date_format(e_time, '%Y-%m-%d') <= date_format('" + sdate + "', '%Y-%m-%d')) "; } } if (!string.IsNullOrEmpty(keyword)) { where += " and ( emp_name like '%" + keyword + "%' or idnumber like '%" + keyword + "%')"; } where += " and (IS_DEL ='0' or IS_DEL is null ) "; returnstr = "{\"code\":0,\"msg\":\"\","; FangYar.BLL.TBL.SysEmpBLL bll = new FangYar.BLL.TBL.SysEmpBLL(); int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = bll.QueryList(pageIndex, pageSize, where, " to_number(sort) desc , emp_num "); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "人员列表查询异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "人员列表查询"); return returnstr; } //车辆列表查询 private string AppGetOrgCarList(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["orgId"]; string keyword = context.Request.Params["keywords"]; string iswork = context.Request.Params["iswork"]; string type = context.Request.Params["type"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; string islower = context.Request.Params["islower"]; string sdate = context.Request.Params["sdate"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } string where = ""; if (!string.IsNullOrEmpty(islower) && islower == "1") { where = " org_id in ( select o.org_id from fire_org o,(select get_Org_child_list('" + OrgId + "') cids ) s WHERE find_in_set(org_id,cids)) "; } else { where = " ORG_ID = '" + OrgId + "' "; } if (!string.IsNullOrEmpty(iswork)) { if (iswork == "1") //在营 { where += " and ISRUN ='0'"; } else if (iswork == "2") //离营 { where += " and ISRUN ='1'"; } else if (iswork == "3") { where += " "; } } if (!string.IsNullOrEmpty(type)) { where += "and CLASS='" + type + "' "; } if (!string.IsNullOrEmpty(keyword)) { where += " and ( CAR_NUM like '%" + keyword + "%' or CAR_NO like '%" + keyword + "%' or CAR_NAME like '%" + keyword + "%')"; } where += " and (IS_DEL ='0' or IS_DEL is null ) AND CLASS IN ( '0', '1' ) "; FangYar.BLL.TBL_SYS_CAR bll = new FangYar.BLL.TBL_SYS_CAR(); returnstr = "{\"code\":0,\"msg\":\"\","; int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = bll.QueryList(pageIndex, pageSize, where, ""); returnstr += Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "车辆列表查询异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "车辆列表查询"); return returnstr; #region 老版方法 //string returnstr = ""; //try //{ // string OrgId = context.Request.Params["orgId"]; // string keyword = context.Request.Params["keywords"]; // string iswork = context.Request.Params["iswork"]; // string type = context.Request.Params["type"]; // string page = context.Request.Params["page"]; // string limit = context.Request.Params["limit"]; // string islower = context.Request.Params["islower"]; // string sdate = context.Request.Params["sdate"]; // int pageIndex = 1; // int pageSize = 10; // if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } // if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } // string where = ""; // if (!string.IsNullOrEmpty(islower) && islower == "1") // { // where = " org_id in ( select o.org_id from fire_org o,(select get_Org_child_list('" + OrgId + "') cids ) s WHERE find_in_set(org_id,cids)) "; // } // else // { // where = " ORG_ID = '" + OrgId + "' "; // } // if (!string.IsNullOrEmpty(iswork)) // { // if (iswork == "1") // { // //where += " and (ISAPPLY='0' or ISAPPLY='1' ) "; // where += " and CAR_NUM not in (select CARNUM from tbl_sys_carapply where STATE='1' AND date_format(STARTTIME, '%Y-%m-%d') >= date_format('" + sdate + "', '%Y-%m-%d') and date_format(FINISHTIME,'%Y-%m-%d') <= date_format('" + sdate + "', '%Y-%m-%d'))"; // } // else if (iswork == "2") // { // //where += " and ISAPPLY='2' "; // where += "and CAR_NUM in (select CARNUM from tbl_sys_carapply where STATE='1' AND date_format(STARTTIME , '%Y-%m-%d') >= date_format('" + sdate + "', '%Y-%m-%d') and date_format(FINISHTIME, '%Y-%m-%d') <= date_format('" + sdate + "', '%Y-%m-%d'))"; // } // else if (iswork == "3") // { // where += " and ISAPPLY != '0' and ISAPPLY != '1' "; // } // } // if (!string.IsNullOrEmpty(type)) // { // where += "and CLASS='" + type + "' "; // } // if (!string.IsNullOrEmpty(keyword)) // { // where += " and ( CAR_NUM like '%" + keyword + "%' or CAR_NO like '%" + keyword + "%' or CAR_NAME like '%" + keyword + "%')"; // } // where += " and (IS_DEL ='0' or IS_DEL is null ) "; // FangYar.BLL.TBL_SYS_CAR bll = new FangYar.BLL.TBL_SYS_CAR(); // returnstr = "{\"code\":0,\"msg\":\"\","; // int count = bll.GetRecordCount(where); // returnstr += "\"count\":" + count + ",\"data\":"; // if (count == 0) // { // returnstr += "[]"; // } // else // { // List list = bll.QueryList(pageIndex, pageSize, where, ""); // returnstr += Common.JsonHelper.ToJson(list); // } // returnstr += "}"; //} //catch (Exception e) //{ // returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // // 记录操作日志 // BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "车辆列表查询异常:" + e); //} //// 记录操作日志 //BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "车辆列表查询"); //return returnstr; #endregion } //请假列表查询 private string AppGetOrgLeaveList(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["org_id"]; string keyword = context.Request.Params["keywords"]; string type = context.Request.Params["type"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; string islower = context.Request.Params["islower"]; string stime = context.Request.Params["stime"];//stime string etime = context.Request.Params["etime"];//etime int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } string where = ""; if (!string.IsNullOrEmpty(islower) && islower == "1") { where = " ppl_id in(select users_uid from TBL_SYS_EMP where IS_ADMIN='0' and org_id in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + OrgId + "') cids ) s WHERE find_in_set(org_id,cids))) "; } else { where = "ppl_id in(select users_uid from TBL_SYS_EMP where IS_ADMIN='0' and ORG_ID = '" + OrgId + "') "; } if (!string.IsNullOrEmpty(type)) { where += "and L_TYPE='" + type + "' "; } if (!string.IsNullOrEmpty(keyword)) { where += " and (PPL_NAME like '%" + keyword + "%' or TITLE like '%" + keyword + "%' or L_OUT like '%" + keyword + "%' or L_REASON like '%" + keyword + "%') "; } where += " and date_format(S_TIME, '%Y-%m-%d') >= date_format('" + stime + "', '%Y-%m-%d') "; where += " and date_format(E_TIME, '%Y-%m-%d') <= date_format('" + etime + "', '%Y-%m-%d') "; where += " and STATE='1' "; FangYar.BLL.OA_LEAVE bll = new FangYar.BLL.OA_LEAVE(); returnstr = "{\"code\":0,\"msg\":\"\","; int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = bll.QueryList(pageIndex, pageSize, where, ""); returnstr += Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "请假列表查询异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "请假列表查询"); return returnstr; } //战训副支队长步骤:只获取值班领导人员列表 private string AppGetDutyLeaderListByOrgId(HttpContext context) { string returnstr = ""; try { //string orgId = context.Request.Params["orgId"]; //目前只有石河子支队在用这个接口;为了避免传过来orgId不是石河子支队,所以直接固定ID了 string orgId = "fbbb44bb458c4336a84e009df74c8598";//石河子支队机构ID FangYar.BLL.TBL.SysEmpBLL bll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.BLL.FIRE.FIRE_ORG bll_org = new FangYar.BLL.FIRE.FIRE_ORG(); List list = new List(); var listuser = bll.QueryListByOrgIdOrDeptId(orgId); if (listuser != null && listuser.Count > 0) { foreach (var model in listuser) { if (model.TAGS != null && ("," + model.TAGS + ",").Contains(",当日总指挥,")) { list.Add(model); } } } returnstr = "{\"code\":0,\"msg\":\"操作成功!\",\"data\":"; returnstr += Common.JsonHelper.ToJson(list) + "}"; } catch (Exception e) { var a = Regex.Replace(e.Message, @"\r", ""); var b = Regex.Replace(a, @"\n", ""); returnstr = "{\"code\":-1,\"msg\":\"error\",\"error\":\"" + b + "\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "战训副支队长步骤:只获取值班领导人员列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "战训副支队长步骤:只获取值班领导人员列表"); return returnstr; } #endregion #region 考勤模块 //用车记录列表 private string AppGetOaAttendanceRecord(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["org_id"]; string recordtime = context.Request.Params["recordtime"]; string up_state = context.Request.Params["up_state"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } int startIndex = (pageIndex - 1) * pageSize + 1; int endIndex = pageIndex * pageSize; FangYar.BLL.OA.OA_ATTENDANCE_RECORD arBll = new FangYar.BLL.OA.OA_ATTENDANCE_RECORD(); string where = " 1=1 "; where += " and org_id ='" + OrgId + "'"; if (!string.IsNullOrEmpty(recordtime)) { where += " and date_format(attendance_date, '%Y-%m-%d') = date_format('" + recordtime + "', '%Y-%m-%d') "; } if (!string.IsNullOrEmpty(up_state)) { if (up_state == "0") { where += " and((up_state = '0' or up_state is null) or (down_state = '0' or down_state is null)) "; //未打卡 } else { where += " and ( up_state = '" + up_state + "' or down_state = '" + up_state + "')"; // 0未打卡 -- 1 正常 '2'-- 迟到 '3'-- 外勤 } } returnstr = "{\"code\":0,\"msg\":\"\","; int count = arBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { DataTable dt = arBll.GetListByPage(where, " up_report_time ", startIndex, endIndex).Tables[0]; returnstr += FangYar.Common.JsonHelper.ToJson(dt); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "用车记录列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "用车记录列表"); return returnstr; } #endregion #region 人员通讯录 //获取人员通讯录 private string AppGetEmpCIDListByOrgId(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["OrgId"]; string islower = context.Request.Params["islower"];//islower 0 本级 1多级 string sql = "select USERS_UID,EMP_NAME,ORG_ID,CID from TBL_SYS_EMP where IS_ADMIN='0' "; if (islower == "1") { sql += " and org_id in (select o.org_id from fire_org o where o.type = '0',(select get_Org_child_list('" + orgId + "') cids ) s WHERE find_in_set(org_id,cids) )"; } else if (islower == "0") { sql += " and org_id ='" + orgId + "'"; } sql += " and CID !='null' and CID is not null "; returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; DataTable data = FangYar.Common.MySqlHelper.QueryTable(sql); returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "获取人员通讯录异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "获取人员通讯录"); return returnstr; } #endregion #region 用车记录管理 /// /// 用车记录管理 /// 开发人员:wangwenan /// 开发时间:2021-11-30 /// /// /// private string AppGetCarApplyListByOrgIdManagement(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["org_id"]; string keywords = context.Request.Params["keywords"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; string stime = context.Request.Params["stime"]; string etime = context.Request.Params["etime"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } FangYar.BLL.TBL_SYS_CARAPPLY carBll = new FangYar.BLL.TBL_SYS_CARAPPLY(); string where = null; where = " USERID in ( select USERS_UID from TBL_SYS_EMP where IS_ADMIN='0' and org_id ='" + OrgId + "' )"; where += " AND (t.state!='1' OR extendcode2!='2') "; if (!string.IsNullOrEmpty(keywords)) { where += " and ( USERNAME like '%" + keywords + "%' or TITLE like '%" + keywords + "%' or carnum like '%" + keywords + "%' ) "; } if (!string.IsNullOrEmpty(stime)) { where += " and date_format(STARTTIME,'%Y-%m-%d') >= date_format('" + stime + "', '%Y-%m-%d') "; } if (!string.IsNullOrEmpty(etime)) { where += " and date_format(FINISHTIME,'%Y-%m-%d') <= date_format('" + etime + "', '%Y-%m-%d') "; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = carBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = carBll.QueryList(pageIndex, pageSize, where, " STARTTIME desc"); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "用车记录管理异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "用车记录管理"); return returnstr; } #endregion #region 公差记录管理 /// /// 公差记录管理 /// 开发人员:wangwenan /// 开发时间:2021-11-30 /// /// /// private string AppGetToleranceListByOrgIdManagement(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["orgid"]; string keyword = context.Request.Params["keywords"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } FangYar.BLL.OA.OA_TOLERANCE toleranceBll = new FangYar.BLL.OA.OA_TOLERANCE(); string where = null; where = " PPL_ID in ( select USERS_UID from TBL_SYS_EMP where IS_ADMIN='0' and org_id ='" + OrgId + "' ) "; //where = " ORG_ID = '" + OrgId + "'"; //where = "(PPL_ID = '" + uid + "' or PPL_ID = 'u_" + uid + "') "; if (!string.IsNullOrEmpty(keyword)) { where += " and (PPL_NAME like '%" + keyword + "%' or TITLE like '%" + keyword + "%' or L_OUT like '%" + keyword + "' or L_REASON like '%" + keyword + "%') "; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = toleranceBll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = toleranceBll.QueryList(pageIndex, pageSize, where, " s_time desc"); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "公差记录管理异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "公差记录管理"); return returnstr; } #endregion public string AppSoftDeleteTaskById(HttpContext context) { return ""; } /// /// 人脸识别装备安装位置 /// /// /// public string AppQueryFaceRecognitionEquipment(HttpContext context) { TBL_EPUIP_ORG equip = new TBL_EPUIP_ORG(); string OrgId = context.Request.Params["OrgId"]?.Trim(); string condition = " 1=1 "; string returnStr = string.Empty; if (!String.IsNullOrEmpty(OrgId)) { try { condition += $" And ORG_ID ='{OrgId}' AND EXTEND2 ='0' AND EPUIP_ID !='0'"; int count = equip.GetRecordCount(condition); returnStr = "{\"code\":0,\"msg\":\"\","; returnStr += "\"count\":" + count + ",\"data\":"; if (count > 0) { returnStr += Common.JsonHelper.ToJson(equip.QueryFaceRecognitionEquipmentByOrgId(condition)); } else { returnStr += "[]"; } returnStr += "}"; } catch (Exception e) { returnStr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "人脸识别装备安装位置异常:" + e); } } else { returnStr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "人脸识别装备安装位置"); return returnStr; } #region APP 角标汇总统计 public string AppGetCornerMarkSta(HttpContext context) { //return "{\"code\":0,\"msg\":\"\",\"count\":1,\"data\":[{\"DBCOUNT\":0,\"FKCOUNT\":0,\"JHXCCOUNT\":0,\"YHZGCOUNT\":0,\"CPCSCOUNT\":0,\"XJCOUNT\":0}]}"; string returnstr = ""; try { string userUid = context.Request.Params["userUid"]; string orgId = context.Request.Params["orgId"]; string sqlStr = " with t1 as ( SELECT count(1) as dbCount FROM WorkFlowTask t WHERE ReceiveID = '" + userUid + "' AND STATUS IN(0, 1)),"; sqlStr += " t2 as ( SELECT count(1) as fkCount FROM TBL_VISITOR_REG WHERE state = '0' AND ved_id = '" + userUid + "'),"; sqlStr += " t3 as ( SELECT count(1) as jhxcCount FROM OA_PATROL_TASK WHERE state = '0' AND instr(CONCAT( ',', EMP_ID, ',' ),CONCAT(',', '" + userUid + "', ',')) <> 0),"; sqlStr += " t4 as ( SELECT count(1) as yhzgCount FROM OA_PATROL_DANGER WHERE state = '0' AND ORG_ID = '" + orgId + "'),"; sqlStr += " t5 as ( SELECT count(1) as cpcsCount FROM OA_PATROLSENTRYTASK WHERE instr(CONCAT(',', PATROLLERID, ','),CONCAT(',', '" + userUid + "', ',')) <> 0 AND date_format(ENDDATE, '%Y-%m-%d %H:%i:%s' ) >= date_format(now(), '%Y-%m-%d %H:%i:%s')),"; sqlStr += " t6 as ( SELECT count(1) xjCount from oa_vacation WHERE Emp_Manage in (SELECT id from tbl_sys_emp WHERE users_uid = '" + userUid + "' ) and Info_State = '0' ) "; sqlStr += " select t1.*,t2.*,t3.*,t4.*,t5.*,t6.* from t1,t2,t3,t4,t5,t6 "; DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sqlStr); returnstr = "{\"code\":0,\"msg\":\"\","; returnstr += "\"count\":1,\"data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(dt); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "app队伍管理角标汇总统计异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "app队伍管理角标汇总统计"); return returnstr; } /// /// 定期更新角标缓存 /// /// public string AppGetCornerMarkStaRedisReplace(HttpContext context) { try { new System.Threading.Thread(() => { string sql = @"WITH e as( SELECT id,USERS_UID u from tbl_sys_emp,(select get_Org_child_list('D8DC637B8B984848A63F82A018AFAEB0') cids ) s WHERE IS_DEL ='0' and IS_ADMIN='0' and find_in_set(org_id,cids) ) ,t1 as( SELECT ReceiveID u, count(1) as c FROM WorkFlowTask WHERE STATUS IN(0, 1) GROUP BY ReceiveID ) ,t2 as( SELECT ved_id u, count(1) as c FROM TBL_VISITOR_REG WHERE state = '0' GROUP BY ved_id ) ,t3 as( SELECT EMP_ID u, count(1) as c FROM OA_PATROL_TASK WHERE state = '0' GROUP BY EMP_ID ) ,t4 as( SELECT PATROLLERID u,count(1) as c FROM OA_PATROLSENTRYTASK WHERE date_format(ENDDATE, '%Y-%m-%d %H:%i:%s' ) >= date_format(now(), '%Y-%m-%d %H:%i:%s') GROUP BY PATROLLERID ) ,t5 as( SELECT Emp_Manage ue,count(1) c from oa_vacation WHERE Info_State = '0' GROUP BY Emp_Manage ) ,t6 as( SELECT e.*,IFNULL(t1.c,0) dbCount ,IFNULL(t2.c,0) fkCount,IFNULL(t3.c,0) jhxcCount,0 yhzgCount,IFNULL(t4.c,0) cpcsCount,IFNULL(t5.c,0) xjCount from e LEFT JOIN t1 on t1.u=e.u LEFT JOIN t2 on t2.u=e.u LEFT JOIN t3 on LOCATE(e.u, t3.u) > 0 LEFT JOIN t4 on LOCATE(e.u, t4.u) > 0 LEFT JOIN t5 on LOCATE(e.id, t5.ue) > 0 ) SELECT u,SUM(dbCount) dbCount,SUM(fkCount) fkCount,SUM(jhxcCount) jhxcCount,SUM(yhzgCount) yhzgCount,SUM(cpcsCount) cpcsCount,SUM(xjCount) xjCount from t6 GROUP BY u"; var dt = FangYar.Common.MySqlHelper.QueryTable(sql); for (int i = 0; i < dt.Rows.Count; i++) { try { string userUid = dt.Rows[i]["u"] + ""; string returnstr = "{\"code\":0,\"msg\":\"\",\"count\":1,\"data\":[{" + "\"DBCOUNT\":" + dt.Rows[i]["dbCount"] + ",\"FKCOUNT\":" + dt.Rows[i]["fkCount"] + ",\"JHXCCOUNT\":" + dt.Rows[i]["jhxcCount"] + ",\"YHZGCOUNT\":" + dt.Rows[i]["yhzgCount"] + ",\"CPCSCOUNT\":" + dt.Rows[i]["cpcsCount"] + ",\"XJCOUNT\":" + dt.Rows[i]["xjCount"] + "}]}"; } catch (Exception ex) { string str = "更新APP角标缓存信息循环内异常:" + ex; FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = str, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error, path = "RedisLogCornerMarkSta" }); } } }).Start(); } catch (Exception ex) { string str = "更新APP角标缓存信息异常:" + ex; FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = str, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error, path = "RedisLogCornerMarkSta" }); } FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = "更新APP角标缓存信息完成", msgType = FangYar.Common.EnumLogMsgTypeEnum.Error, path = "RedisLogCornerMarkSta" }); return "OK"; } #endregion #region APP查询出操统计数据 /// /// 出操统计列表--只获取本机构 /// /// /// private string getExerciseSta(HttpContext context) { string returnstr = ""; try { string findOrgId = context.Request.Params["orgId"]; findOrgId = FangYar.Common.WebCommonUtil.GetOrgIdUpLevelToDownLevel(findOrgId); if (string.IsNullOrEmpty(findOrgId)) { return "{\"code\":-1,\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"orgId参数不能为空!\",\"data\":[]}"; } string findDate = context.Request.Params["findDate"]; if (string.IsNullOrEmpty(findDate)) { findDate = DateTime.Now.ToString("yyyy-MM-dd"); } else { if (DateTime.TryParse(findDate, out DateTime dtm)) { findDate = dtm.ToString("yyyy-MM-dd"); } else { findDate = DateTime.Now.ToString("yyyy-MM-dd"); } } #region 数据查询 //本级机构 点名信息 string orgSql = @"SELECT o.org_id,o.org_name,o.pid AS pid,o.all_num FROM fire_org o WHERE TYPE = 0 AND o.org_id = '" + findOrgId + @"'"; string rcSql = @"WITH t1 as( SELECT ID,ORG_ID,ORG_NAME,USERS_UID,TIME_TYPE,FACE_READ_STATE STATE,TASK_ID from oa_Exercise_record r WHERE TASK_ID in ( SELECT id from oa_Exercise_task tk "; rcSql += " WHERE tk.org_id='" + findOrgId + @"' and date_format( tk.report_time, '%Y-%m-%d' ) = date_format( '" + findDate + @"', '%Y-%m-%d' ) "; rcSql += @" ) ) SELECT t1.*,tk.REPORT_TIME ,if (if ((SELECT count(1) from oa_tolerance WHERE (PPL_ID = t1.USERS_UID or find_in_set(t1.USERS_UID, ACC_PPL)) and STATE = '1' and date_format( S_TIME, '%Y-%m-%d %H') <= date_format( tk.REPORT_TIME , '%Y-%m-%d %H') and date_format(E_TIME, '%Y-%m-%d %H') >= date_format( tk.REPORT_TIME , '%Y-%m-%d %H') )>0,4, if(((SELECT count(1) from oa_leave WHERE PPL_ID = t1.USERS_UID and STATE = '1' AND L_TYPE != '8fb6e5cc-419d-45a6-9926-ce8f704dc4d7' and ((date_format( S_TIME, '%Y-%m-%d %H') <= date_format( tk.REPORT_TIME , '%Y-%m-%d %H') and date_format(E_TIME, '%Y-%m-%d %H') >= date_format( tk.REPORT_TIME , '%Y-%m-%d %H') ) or ( date_format( tk.EXTEND2 , '%Y-%m-%d %H') <= date_format( S_TIME, '%Y-%m-%d %H') and date_format( tk.EXTEND3 , '%Y-%m-%d %H') >= date_format( S_TIME, '%Y-%m-%d %H')) or ( date_format( tk.EXTEND2 , '%Y-%m-%d %H') <= date_format( E_TIME, '%Y-%m-%d %H') and date_format( tk.EXTEND3 , '%Y-%m-%d %H') >= date_format( E_TIME, '%Y-%m-%d %H')) ))+ (SELECT count(1) from oa_vacation v LEFT JOIN tbl_sys_emp e on v.PPL_ID=e.ID WHERE v.Info_State='1' and e.USERS_UID=t1.USERS_UID and date_format( v.S_TIME, '%Y-%m-%d %H') <= date_format( tk.EXTEND2 , '%Y-%m-%d %H') and date_format(v.E_TIME, '%Y-%m-%d %H') >= date_format(tk.EXTEND3 , '%Y-%m-%d %H')) )>0,3, if((SELECT count(1) from oa_leave WHERE PPL_ID = t1.USERS_UID and STATE = '1' AND L_TYPE = '8fb6e5cc-419d-45a6-9926-ce8f704dc4d7' and ((date_format( S_TIME, '%Y-%m-%d %H') <= date_format( tk.REPORT_TIME , '%Y-%m-%d %H') and date_format(E_TIME, '%Y-%m-%d %H') >= date_format( tk.REPORT_TIME , '%Y-%m-%d %H') ) or ( date_format( tk.EXTEND2 , '%Y-%m-%d %H') <= date_format( S_TIME, '%Y-%m-%d %H') and date_format( tk.EXTEND3 , '%Y-%m-%d %H') >= date_format( S_TIME, '%Y-%m-%d %H')) or ( date_format( tk.EXTEND2 , '%Y-%m-%d %H') <= date_format( E_TIME, '%Y-%m-%d %H') and date_format( tk.EXTEND3 , '%Y-%m-%d %H') >= date_format( E_TIME, '%Y-%m-%d %H')) ) )>0,5,0) )) = 0,STATE,if ((SELECT count(1) from oa_tolerance WHERE (PPL_ID = t1.USERS_UID or find_in_set(t1.USERS_UID, ACC_PPL)) and STATE = '1' and date_format( S_TIME, '%Y-%m-%d %H') <= date_format( tk.REPORT_TIME , '%Y-%m-%d %H') and date_format(E_TIME, '%Y-%m-%d %H') >= date_format( tk.REPORT_TIME , '%Y-%m-%d %H') )>0,4, if(((SELECT count(1) from oa_leave WHERE PPL_ID = t1.USERS_UID and STATE = '1' AND L_TYPE != '8fb6e5cc-419d-45a6-9926-ce8f704dc4d7' and ((date_format( S_TIME, '%Y-%m-%d %H') <= date_format( tk.REPORT_TIME , '%Y-%m-%d %H') and date_format(E_TIME, '%Y-%m-%d %H') >= date_format( tk.REPORT_TIME , '%Y-%m-%d %H') ) or ( date_format( tk.EXTEND2 , '%Y-%m-%d %H') <= date_format( S_TIME, '%Y-%m-%d %H') and date_format( tk.EXTEND3 , '%Y-%m-%d %H') >= date_format( S_TIME, '%Y-%m-%d %H')) or ( date_format( tk.EXTEND2 , '%Y-%m-%d %H') <= date_format( E_TIME, '%Y-%m-%d %H') and date_format( tk.EXTEND3 , '%Y-%m-%d %H') >= date_format( E_TIME, '%Y-%m-%d %H')) ))+ (SELECT count(1) from oa_vacation v LEFT JOIN tbl_sys_emp e on v.PPL_ID=e.ID WHERE v.Info_State='1' and e.USERS_UID=t1.USERS_UID and date_format( v.S_TIME, '%Y-%m-%d %H') <= date_format( tk.EXTEND2 , '%Y-%m-%d %H') and date_format(v.E_TIME, '%Y-%m-%d %H') >= date_format(tk.EXTEND3 , '%Y-%m-%d %H')) )>0,3, if((SELECT count(1) from oa_leave WHERE PPL_ID = t1.USERS_UID and STATE = '1' AND L_TYPE = '8fb6e5cc-419d-45a6-9926-ce8f704dc4d7' and ((date_format( S_TIME, '%Y-%m-%d %H') <= date_format( tk.REPORT_TIME , '%Y-%m-%d %H') and date_format(E_TIME, '%Y-%m-%d %H') >= date_format( tk.REPORT_TIME , '%Y-%m-%d %H') ) or ( date_format( tk.EXTEND2 , '%Y-%m-%d %H') <= date_format( S_TIME, '%Y-%m-%d %H') and date_format( tk.EXTEND3 , '%Y-%m-%d %H') >= date_format( S_TIME, '%Y-%m-%d %H')) or ( date_format( tk.EXTEND2 , '%Y-%m-%d %H') <= date_format( E_TIME, '%Y-%m-%d %H') and date_format( tk.EXTEND3 , '%Y-%m-%d %H') >= date_format( E_TIME, '%Y-%m-%d %H')) ) )>0,5,0) ))) WORKSTATE from t1 LEFT JOIN oa_Exercise_task tk on t1.TASK_ID=tk.ID "; DataTable orgDt = FangYar.Common.MySqlHelper.QueryTable(orgSql); DataTable rcDt = FangYar.Common.MySqlHelper.QueryTable(rcSql); #endregion //点名信息 存入缓存 List list = new List(); for (int i = 0; i < rcDt.Rows.Count; i++) { list.Add(new RollcallMo() { orgId = rcDt.Rows[i]["ORG_ID"] + "", timeType = rcDt.Rows[i]["TIME_TYPE"] + "", userId = rcDt.Rows[i]["USERS_UID"] + "", state = rcDt.Rows[i]["WORKSTATE"] + "", WORKSTATE = rcDt.Rows[i]["STATE"] + "" }); } returnstr = "{\"code\":0,\"msg\":\"操作成功!\",\"data\":["; string[] xAxisData = new string[orgDt.Rows.Count]; //应到 int[] totalData = new int[orgDt.Rows.Count]; //请假 int[] leaveData = new int[orgDt.Rows.Count]; //实到 int[] arriveData = new int[orgDt.Rows.Count]; //未到 int[] noArriveData = new int[orgDt.Rows.Count]; //公差 int[] toleranceData = new int[orgDt.Rows.Count]; //迟到 int[] lateData = new int[orgDt.Rows.Count]; //站岗 int[] dutyData = new int[orgDt.Rows.Count]; #region 循环处理数据 for (int i = 0; i < orgDt.Rows.Count; i++) { int totalSum = 0, leaveSum = 0, arriveSum = 0, noArriveSum = 0, toleranceSum = 0, lateSum = 0, dutySum = 0; if (i != 0) returnstr += ","; string _orgId = orgDt.Rows[i]["ORG_ID"].ToString(); string _pId = orgDt.Rows[i]["PID"].ToString(); string _orgName = orgDt.Rows[i]["ORG_NAME"].ToString(); string _allNum = orgDt.Rows[i]["ALL_NUM"].ToString() == "" ? "0" : orgDt.Rows[i]["ALL_NUM"].ToString(); string orgMo = "{\"findDate\":\"" + findDate + "\",\"orgId\":\"" + _orgId + "\",\"pId\":\"" + _pId + "\",\"orgName\":\"" + _orgName + "\",\"allNum\":\"" + _allNum + "\""; xAxisData[i] = "\"" + _orgName + "\""; //早点名 var mornList = list.Where(p => p.orgId == _orgId && p.timeType == "1"); // 按人分组 var userGroup = mornList.GroupBy(p => p.userId); // 应到 int mornTotal = userGroup.Count(); // 未识别 int mornNoArrive = userGroup.Where(p => p.Where(s => s.state == "0").Count() == p.Count()).Count(); // 已识别 => 正常 int mornArrive = userGroup.Where(p => p.Where(s => s.state == "1").Any()).Count(); // 迟到 int mornLate = userGroup.Where(p => p.Where(s => s.state == "2").Count() == p.Count()).Count(); // 请假 int mornLeave = userGroup.Where(p => p.Where(s => s.state == "3").Count() == p.Count()).Count(); // 公差 int mornTolerance = userGroup.Where(p => p.Where(s => s.state == "4").Count() == p.Count()).Count(); // 站岗值班 int mornDuty = userGroup.Where(p => p.Where(s => s.state == "5").Count() == p.Count()).Count(); orgMo += ",\"mornTotal\":\"" + mornTotal + "\",\"mornLeave\":\"" + mornLeave + "\",\"mornArrive\":\"" + mornArrive + "\",\"mornNoArrive\":\"" + mornNoArrive + "\",\"mornTolerance\":\"" + mornTolerance + "\",\"mornLate\":\"" + mornLate + "\",\"mornDuty\":\"" + mornDuty + "\""; totalSum += mornTotal; leaveSum += mornLeave; arriveSum += mornArrive; noArriveSum += mornNoArrive; toleranceSum += mornTolerance; lateSum += mornLate; dutySum += mornDuty; //午点名 var noonList = list.Where(p => p.orgId == _orgId && p.timeType == "3"); // 按人分组 var noonUserGroup = noonList.GroupBy(p => p.userId); // 应到 int noonTotal = noonUserGroup.Count(); // 未识别 int noonNoArrive = noonUserGroup.Where(p => p.Where(s => s.state == "0").Count() == p.Count()).Count(); // 已识别 => 正常 int noonArrive = noonUserGroup.Where(p => p.Where(s => s.state == "1").Any()).Count(); // 迟到 int noonLate = noonUserGroup.Where(p => p.Where(s => s.state == "2").Count() == p.Count()).Count(); // 请假 int noonLeave = noonUserGroup.Where(p => p.Where(s => s.state == "3").Count() == p.Count()).Count(); // 公差 int noonTolerance = noonUserGroup.Where(p => p.Where(s => s.state == "4").Count() == p.Count()).Count(); // 站岗值班 int noonDuty = noonUserGroup.Where(p => p.Where(s => s.state == "5").Count() == p.Count()).Count(); orgMo += ",\"noonTotal\":\"" + noonTotal + "\",\"noonLeave\":\"" + noonLeave + "\",\"noonArrive\":\"" + noonArrive + "\",\"noonNoArrive\":\"" + noonNoArrive + "\",\"noonTolerance\":\"" + noonTolerance + "\",\"noonLate\":\"" + noonLate + "\",\"noonDuty\":\"" + noonDuty + "\""; totalSum += noonTotal; leaveSum += noonLeave; arriveSum += noonArrive; noArriveSum += noonNoArrive; toleranceSum += noonTolerance; lateSum += noonLate; dutySum += noonDuty; //晚点名 var nightList = list.Where(p => p.orgId == _orgId && p.timeType == "5"); // 按人分组 var nightUserGroup = nightList.GroupBy(p => p.userId); // 应到 int nightTotal = nightUserGroup.Count(); // 未识别 int nightNoArrive = nightUserGroup.Where(p => p.Where(s => s.state == "0").Count() == p.Count()).Count(); // 已识别 => 正常 int nightArrive = nightUserGroup.Where(p => p.Where(s => s.state == "1").Any()).Count(); // 迟到 int nightLate = nightUserGroup.Where(p => p.Where(s => s.state == "2").Count() == p.Count()).Count(); // 请假 int nightLeave = nightUserGroup.Where(p => p.Where(s => s.state == "3").Count() == p.Count()).Count(); // 公差 int nightTolerance = nightUserGroup.Where(p => p.Where(s => s.state == "4").Count() == p.Count()).Count(); // 站岗值班 int nightDuty = nightUserGroup.Where(p => p.Where(s => s.state == "5").Count() == p.Count()).Count(); orgMo += ",\"nightTotal\":\"" + nightTotal + "\",\"nightLeave\":\"" + nightLeave + "\",\"nightArrive\":\"" + nightArrive + "\",\"nightNoArrive\":\"" + nightNoArrive + "\",\"nightTolerance\":\"" + nightTolerance + "\",\"nightLate\":\"" + nightLate + "\",\"nightDuty\":\"" + nightDuty + "\"}"; totalSum += nightTotal; leaveSum += nightLeave; arriveSum += nightArrive; noArriveSum += nightNoArrive; toleranceSum += nightTolerance; lateSum += nightLate; dutySum += nightDuty; totalData[i] = totalSum; leaveData[i] = leaveSum; arriveData[i] = arriveSum; noArriveData[i] = noArriveSum; toleranceData[i] = toleranceSum; lateData[i] = lateSum; dutyData[i] = dutySum; returnstr += orgMo; } #endregion returnstr += "]"; if (totalData.Length > 0) { int n1 = totalData[0] - arriveData[0]; double d1 = 0; double d2 = 0; try { d1 = totalData[0] - leaveData[0] - toleranceData[0] - dutyData[0]; d2 = arriveData[0] * 100 / d1; } catch (Exception ex) { } returnstr += ",\"ExerciseData\":{\"totalData\":" + totalData[0] + ",\"leaveData\":" + leaveData[0] + ",\"arriveData\":" + arriveData[0] + ",\"noArriveData\":" + noArriveData[0] + ",\"toleranceData\":" + toleranceData[0] + ",\"dutyData\":" + dutyData[0] + ",\"noExercise\":" + n1 + ",\"arriveRate\":" + Math.Round(d2, 2) + "}"; //查询出操上传文件 string sqlVideo = " SELECT * FROM oa_exercise_file WHERE ORG_ID='" + findOrgId + "' and FILE_STATE='0' and EXERCISE_DATE='" + findDate + "' order by createtime DESC "; var dtVideo = FangYar.Common.MySqlHelper.QueryTable(sqlVideo); returnstr += ",\"ExerciseFile\":["; for (int i = 0; i < dtVideo.Rows.Count; i++) { if (i > 0) { returnstr += ","; } returnstr += "\"" + dtVideo.Rows[i]["FILE_URL"] + "\""; } returnstr += "]"; } else { returnstr += ",\"ExerciseData\":{\"totalData\":0,\"leaveData\":0,\"arriveData\":0,\"noArriveData\":0,\"toleranceData\":0,\"dutyData\":0}"; returnstr += ",\"ExerciseFile\":[]"; } returnstr += "}"; } catch (Exception e) { var a = Regex.Replace(e.Message, @"\r", ""); var b = Regex.Replace(a, @"\n", ""); returnstr = "{\"code\":-1,\"msg\":\"请求异常,请联系平台管理员!\",\"error\":\"" + b + "\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP查询出操统计数据", "出操统计列表-只获取本机构异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP查询出操统计数据", "出操统计列表-只获取本机构"); return returnstr; } /// /// 出操统计详情 /// /// /// private string getExerciseStaItem(HttpContext context) { string returnstr = ""; try { //机构信息ID string findOrgId = context.Request.Params["orgId"]; if (string.IsNullOrEmpty(findOrgId)) { return "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"orgId参数不能为空!\",\"data\":[]}"; } findOrgId = FangYar.Common.WebCommonUtil.GetOrgIdUpLevelToDownLevel(findOrgId); //查询日期 string findDate = context.Request.Params["findDate"]; if (string.IsNullOrEmpty(findDate)) { findDate = DateTime.Now.ToString("yyyy-MM-dd"); } else { if (DateTime.TryParse(findDate, out DateTime dtm)) { findDate = dtm.ToString("yyyy-MM-dd"); } else { findDate = DateTime.Now.ToString("yyyy-MM-dd"); } } string findTimeType = "1"; ////信息类型:0、未识别;1、实到人员;3、请假;4、公差;5、站岗值班 //string infoType = context.Request.Params["infoType"]; //查询点名信息详情 string sql = "WITH t1 as( SELECT r.ORG_ID,r.id,r.USERS_UID,r.USERS_NAME,date_format(r.FACE_READ_START_TIME,'%Y-%m-%d %H:%i:%s') REPORT_TIME, " + " t.REPORT_TIME setTime,r.FACE_READ_STATE STATE, " + " date_format(t.EXTEND2,'%Y-%m-%d %H:%i:%s') EXTEND2,date_format(t.EXTEND3,'%Y-%m-%d %H:%i:%s') EXTEND3, " + " IFNULL(IFNULL(r.FACE_READ_SMALL_IMG,CONCAT('/',e.PHOTO)),'/images/imgPerDefaut.jpg') FACE_READ_SMALL_IMG, " + " IFNULL(IFNULL(r.FACE_READ_BIG_IMG,CONCAT('/',e.PHOTO)),'/images/imgPerDefaut.jpg') FACE_READ_BIG_IMG FROM oa_Exercise_task t " + " LEFT JOIN oa_Exercise_record r ON t.id = r.task_id LEFT JOIN tbl_sys_emp e on e.USERS_UID=r.USERS_UID WHERE t.ORG_ID = '" + findOrgId + "' and date_format( t.report_time, '%Y-%m-%d' ) = date_format( '" + findDate + "', '%Y-%m-%d' ) AND r.TIME_TYPE = '" + findTimeType + "' order BY r.FACE_READ_START_TIME )" + @" ,t2 as ( SELECT ORG_ID,id,USERS_NAME,REPORT_TIME ,if(if ((SELECT count(1) from oa_tolerance WHERE (PPL_ID = t1.USERS_UID or find_in_set(t1.USERS_UID, ACC_PPL)) and STATE = '1' and date_format( S_TIME, '%Y-%m-%d %H') <= date_format( setTime , '%Y-%m-%d %H') and date_format(E_TIME, '%Y-%m-%d %H') >= date_format( setTime , '%Y-%m-%d %H') )>0,4, if(((SELECT count(1) from oa_leave WHERE PPL_ID = t1.USERS_UID and STATE = '1' AND L_TYPE != '8fb6e5cc-419d-45a6-9926-ce8f704dc4d7' and ((date_format( S_TIME, '%Y-%m-%d %H') <= date_format( setTime , '%Y-%m-%d %H') and date_format(E_TIME, '%Y-%m-%d %H') >= date_format( setTime , '%Y-%m-%d %H') ) or ( date_format( t1.EXTEND2 , '%Y-%m-%d %H') <= date_format( S_TIME, '%Y-%m-%d %H') and date_format( t1.EXTEND3 , '%Y-%m-%d %H') >= date_format( S_TIME, '%Y-%m-%d %H')) or ( date_format( t1.EXTEND2 , '%Y-%m-%d %H') <= date_format( E_TIME, '%Y-%m-%d %H') and date_format( t1.EXTEND3 , '%Y-%m-%d %H') >= date_format( E_TIME, '%Y-%m-%d %H')) ))+ (SELECT count(1) from oa_vacation v LEFT JOIN tbl_sys_emp e on v.PPL_ID=e.ID WHERE v.Info_State='1' and e.USERS_UID=t1.USERS_UID and date_format( v.S_TIME, '%Y-%m-%d %H') <= date_format( t1.EXTEND2 , '%Y-%m-%d %H') and date_format(v.E_TIME, '%Y-%m-%d %H') >= date_format(t1.EXTEND3 , '%Y-%m-%d %H')) )>0,3, if((SELECT count(1) from oa_leave WHERE PPL_ID = t1.USERS_UID and STATE = '1' AND L_TYPE = '8fb6e5cc-419d-45a6-9926-ce8f704dc4d7' and ((date_format( S_TIME, '%Y-%m-%d %H') <= date_format( setTime , '%Y-%m-%d %H') and date_format(E_TIME, '%Y-%m-%d %H') >= date_format( setTime , '%Y-%m-%d %H') ) or ( date_format( t1.EXTEND2 , '%Y-%m-%d %H') <= date_format( S_TIME, '%Y-%m-%d %H') and date_format( t1.EXTEND3 , '%Y-%m-%d %H') >= date_format( S_TIME, '%Y-%m-%d %H')) or ( date_format( t1.EXTEND2 , '%Y-%m-%d %H') <= date_format( E_TIME, '%Y-%m-%d %H') and date_format( t1.EXTEND3 , '%Y-%m-%d %H') >= date_format( E_TIME, '%Y-%m-%d %H')) ) )>0,5,0) ))=0,STATE,if ((SELECT count(1) from oa_tolerance WHERE (PPL_ID = t1.USERS_UID or find_in_set(t1.USERS_UID, ACC_PPL)) and STATE = '1' and date_format( S_TIME, '%Y-%m-%d %H') <= date_format( setTime , '%Y-%m-%d %H') and date_format(E_TIME, '%Y-%m-%d %H') >= date_format( setTime , '%Y-%m-%d %H') )>0,4, if(((SELECT count(1) from oa_leave WHERE PPL_ID = t1.USERS_UID and STATE = '1' AND L_TYPE != '8fb6e5cc-419d-45a6-9926-ce8f704dc4d7' and ((date_format( S_TIME, '%Y-%m-%d %H') <= date_format( setTime , '%Y-%m-%d %H') and date_format(E_TIME, '%Y-%m-%d %H') >= date_format( setTime , '%Y-%m-%d %H') ) or ( date_format( t1.EXTEND2 , '%Y-%m-%d %H') <= date_format( S_TIME, '%Y-%m-%d %H') and date_format( t1.EXTEND3 , '%Y-%m-%d %H') >= date_format( S_TIME, '%Y-%m-%d %H')) or ( date_format( t1.EXTEND2 , '%Y-%m-%d %H') <= date_format( E_TIME, '%Y-%m-%d %H') and date_format( t1.EXTEND3 , '%Y-%m-%d %H') >= date_format( E_TIME, '%Y-%m-%d %H')) ))+ (SELECT count(1) from oa_vacation v LEFT JOIN tbl_sys_emp e on v.PPL_ID=e.ID WHERE v.Info_State='1' and e.USERS_UID=t1.USERS_UID and date_format( v.S_TIME, '%Y-%m-%d %H') <= date_format( t1.EXTEND2 , '%Y-%m-%d %H') and date_format(v.E_TIME, '%Y-%m-%d %H') >= date_format(t1.EXTEND3 , '%Y-%m-%d %H')) )>0,3, if((SELECT count(1) from oa_leave WHERE PPL_ID = t1.USERS_UID and STATE = '1' AND L_TYPE = '8fb6e5cc-419d-45a6-9926-ce8f704dc4d7' and ((date_format( S_TIME, '%Y-%m-%d %H') <= date_format( setTime , '%Y-%m-%d %H') and date_format(E_TIME, '%Y-%m-%d %H') >= date_format( setTime , '%Y-%m-%d %H') ) or ( date_format( t1.EXTEND2 , '%Y-%m-%d %H') <= date_format( S_TIME, '%Y-%m-%d %H') and date_format( t1.EXTEND3 , '%Y-%m-%d %H') >= date_format( S_TIME, '%Y-%m-%d %H')) or ( date_format( t1.EXTEND2 , '%Y-%m-%d %H') <= date_format( E_TIME, '%Y-%m-%d %H') and date_format( t1.EXTEND3 , '%Y-%m-%d %H') >= date_format( E_TIME, '%Y-%m-%d %H')) ) )>0,5,0) ))) FACE_READ_STATE,FACE_READ_BIG_IMG,FACE_READ_SMALL_IMG from t1 ) SELECT * from t2 ORDER BY report_time DESC "; // WHERE face_read_state = '" + infoType + @"' ORDER BY report_time DESC DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sql); returnstr = "{\"code\":\"200\",\"msg\":\"操作成功!\",\"data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(dt); returnstr += "}"; } catch (Exception e) { var a = Regex.Replace(e.Message, @"\r", ""); var b = Regex.Replace(a, @"\n", ""); returnstr = "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员!\",\"error\":\"" + b + "\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人脸点名统计操作请求", "出操统计详情异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人脸点名统计操作请求", "出操统计详情"); return returnstr; } /// /// 提交出操现场文件 /// /// /// private string PostExerciseFile(HttpContext context) { string returnstr = ""; try { //机构ID string findOrgId = context.Request.Params["orgId"]; findOrgId = FangYar.Common.WebCommonUtil.GetOrgIdUpLevelToDownLevel(findOrgId); if (string.IsNullOrEmpty(findOrgId)) { return "{\"code\":-1,\"msg\":\"orgId参数不能为空。\",\"error\":\"orgId参数不能为空!\",\"data\":[]}"; } //时间 string findDate = context.Request.Params["findDate"]; if (string.IsNullOrEmpty(findDate)) { findDate = DateTime.Now.ToString("yyyy-MM-dd"); } else { if (DateTime.TryParse(findDate, out DateTime dtm)) { findDate = dtm.ToString("yyyy-MM-dd"); } else { findDate = DateTime.Now.ToString("yyyy-MM-dd"); } } //文件地址 string fileUrl = context.Request.Params["fileUrl"]; //登录用户账号 string usersUid = context.Request.Params["usersUid"]; if (string.IsNullOrWhiteSpace(fileUrl)) { return "{\"code\":-1,\"msg\":\"文件路径不能为空。\",\"error\":\"文件路径不能为空!\",\"data\":[]}"; } //查询文件是否上传过 string sqlQuery = " select * from oa_exercise_file where FILE_STATE='0' and FILE_URL='" + fileUrl + "' "; var dtQuery = FangYar.Common.MySqlHelper.QueryTable(sqlQuery); if (dtQuery.Rows.Count > 0) { return "{\"code\":-1,\"msg\":\"文件不能重复上传。\",\"error\":\"文件不能重复上传!\",\"data\":[]}"; } //插入日志信息ID string guid = Guid.NewGuid().ToString("N"); string sql = " insert INTO oa_exercise_file (ID,ORG_ID,EXERCISE_DATE,FILE_URL,FILE_STATE,usersUid) VALUES ('" + guid + "','" + findOrgId + "','" + findDate + "','" + fileUrl + "',0,'" + usersUid + "') "; FangYar.Common.MySqlHelper.Execute(sql); returnstr = "{\"code\":0,\"msg\":\"操作成功!\",\"data\":[]}"; } catch (Exception e) { var a = Regex.Replace(e.Message, @"\r", ""); var b = Regex.Replace(a, @"\n", ""); returnstr = "{\"code\":-1,\"msg\":\"请求异常,请联系平台管理员!\",\"error\":\"" + b + "\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP出操上传文件", "上传出操视频文件异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP出操上传文件", "上传出操文件"); return returnstr; } #endregion #region 西藏总队APP餐厅跳转地址 private string getDiningUrl(HttpContext context) { string returnstr = ""; try { //餐厅APP跳转地址 string DiningUrlAPP = System.Configuration.ConfigurationManager.AppSettings["DiningUrlAPP"] + ""; //用户账号 string usersUid = context.Request.Params["usersUid"]; string sql = " SELECT USERS_UID,ORG_ID from tbl_sys_emp WHERE USERS_UID='" + usersUid + "' "; var dt = FangYar.Common.MySqlHelper.QueryTable(sql); //跳转到大华 var str = dt.Rows[0]["ORG_ID"] + "&" + usersUid; var pwdStr = Common.AesHelper.Encrypt(str); //URL转码 pwdStr = System.Web.HttpUtility.UrlEncode(pwdStr, Encoding.GetEncoding("GB2312")); var strUrl = DiningUrlAPP + pwdStr; returnstr = "{\"code\":0,\"msg\":\"\",\"data\":\"" + strUrl + "\"}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP操作请求", "APP获取餐厅跳转地址异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP操作请求", "APP获取餐厅跳转地址"); return returnstr; } #endregion #region IsReusable public bool IsReusable { get { return false; } } #endregion } }