/// <summary> /// 创建表单和当事人 /// </summary> /// <param name="TaskSurvey"></param> /// <param name="law_Parties"></param> /// <returns></returns> private void CreateInfo(law_punishmentInfo lawpunishmentInfo, List <law_party> law_Parties, List <attachment> attachments) { var lawpunishment_Info = base.Create(lawpunishmentInfo) as string;//保存原始信息 lawpunishmentInfo.ID = lawpunishment_Info; if (law_Parties != null && law_Parties.Count > 0)//创建当事人 { foreach (var l in law_Parties) { l.Associatedobjecttype = "law_punishmentInfo"; l.AssociationobjectID = lawpunishment_Info; l.ID = Guid.NewGuid().ToString(); l.CreateDate = DateTime.Now; l.CreateUserID = SysContext.WanJiangUserID; QueryDb.Insert(l); } } if (attachments != null && attachments.Count > 0) { foreach (var a in attachments) { a.Associatedobjecttype = "law_punishmentInfo"; a.AssociationobjectID = lawpunishment_Info; a.ID = Guid.NewGuid().ToString(); a.CreateDate = DateTime.Now; a.CreateUserID = SysContext.WanJiangUserID; QueryDb.Insert(a); } } //更新案件信息 if (string.IsNullOrEmpty(lawpunishmentInfo.TaskId)) { if (!string.IsNullOrEmpty(lawpunishmentInfo.CaseId)) { var caseinfo = QueryDb.FirstOrDefault <case_Info>("where Id=@0", lawpunishmentInfo.CaseId); if (caseinfo != null) { caseinfo.CaseStatus = "做出处罚决定"; QueryDb.Update(caseinfo); } } } else { var tasknow = ServiceHelper.GetService("work_task").GetDetailData(lawpunishmentInfo.TaskId, null); if (tasknow != null) { var caseid = (string)tasknow["CaseID"]; if (!string.IsNullOrEmpty(caseid)) { var caseinfo = QueryDb.FirstOrDefault <case_Info>("where Id=@0", caseid); if (caseinfo != null) { caseinfo.CaseStatus = "做出处罚决定"; QueryDb.Update(caseinfo); } } } } }
private void task_surveyService_OnAfterGetDetailData(object query, object data) { var o = data as Dictionary <string, object>; string taskType = o["ProcessingDecisions"].ToString(); if (taskType == "1") { o["ProcessingDecisions"] = "不予处罚"; } if (taskType == "2") { o["ProcessingDecisions"] = "移送其他部门"; } if (taskType == "3") { o["ProcessingDecisions"] = "处罚程序"; } var res_dictionary = QueryDb.FirstOrDefault <res_dictionary>("where DicCode=@0", "EventType"); var dicItems = QueryDb.Query <res_dictionaryItems>("SELECT * FROM res_dictionaryitems where DicID=@0", res_dictionary.ID).ToDictionary(k => k.ID, v => v.Title); var eventType = o["EventType"].ToString(); if (dicItems.ContainsKey(eventType)) { o["EventType"] = dicItems[eventType]; } }
/// <summary> /// 获取执法人员 /// </summary> /// <param name="aPIContext"></param> /// <returns></returns> private Model.Entity.loc_field_staff GetStaff(APIContext aPIContext) { var locationKey = aPIContext.Context;//根据地址关键词获取用户 Model.Entity.loc_field_staff rev = QueryDb.FirstOrDefault <Model.Entity.loc_field_staff>("where Lawenforcer=1 and EnforcementScope like @0", new object[] { $"%{locationKey}%" }); return(rev); }
private void Case_InfoService_GetDetail(object query, object data) { //var caseinfo = data as Dictionary<string, object>; //var userid = caseinfo["CreateUser"] as List<string>; //if (userid != null) //{ // ServiceConfig userServiceConfig = ServiceHelper.GetServiceConfig("user"); // var user = SysContext.GetOtherDB(userServiceConfig.model.dbName).First<user>($"select * from user where Id={userid[0] }"); // caseinfo.Add("Jobnumber",user.Jobnumber); //} var caseinfo = data as Dictionary <string, object>; var res_dictionary = QueryDb.FirstOrDefault <res_dictionary>("where DicCode=@0", "CaseType"); var dicItems = QueryDb.Query <res_dictionaryItems>("SELECT * FROM res_dictionaryitems where DicID=@0", res_dictionary.ID).ToDictionary(k => k.ItemCode, v => v.Title); var caseType = caseinfo["CaseType"].ToString(); if (dicItems.ContainsKey(caseType)) { caseinfo["CaseType"] = dicItems[caseType]; } }
/// <summary> /// 创建表单 /// </summary> /// <param name="TaskSurvey"></param> /// <param name="law_Parties"></param> /// <returns></returns> private void CreateInfo(case_cover casecover) { var CaseInfoSource = base.Create(casecover) as string; ///更新案件信息 var tasknow = ServiceHelper.GetService("work_task").GetDetailData(casecover.TaskId, null); if (tasknow != null) { var caseid = (string)tasknow["CaseID"]; if (string.IsNullOrEmpty(caseid)) { var caseinfo = QueryDb.FirstOrDefault <case_Info>("where CaseId=@0", caseid); if (caseinfo != null) { caseinfo.CaseStatus = "已归档"; QueryDb.Update(caseinfo); } } } }
/* * * /// <summary> * /// 简易流程 * /// </summary> * /// <returns></returns> * private object EasyProcess(case_Info caseInfo,List<law_party> law_Parties) * { * QueryDb.BeginTransaction(); * try * { * CreateInfo(caseInfo, law_Parties); * //结束当前任务 * _sHBaseService.UpdateWorkTaskState(caseInfo.TaskId,WorkTaskStatus.Close); * //TODO 创建简易流程任务处罚决定书 * _sHBaseService.CreateSaveWorkTask(caseInfo.TaskId, TaskType.law_punishmentInfo); * ////修改事件状态 * //if(!string.IsNullOrEmpty(caseInfo.EventInfoId)) * //_sHBaseService.UpdateEventState(caseInfo.EventInfoId,EventStatus.); * } * catch (Exception) * { * QueryDb.AbortTransaction(); * return false; * } * QueryDb.CompleteTransaction(); * return true; * } * * //一般程序 * private object NormalProcess(case_Info caseInfo) * { * return null; * } * */ /// <summary> /// 创建表单和当事人 /// </summary> /// <param name="TaskSurvey"></param> /// <param name="law_Parties"></param> /// <returns></returns> private string CreateInfo(case_Info caseInfo, List <law_party> law_Parties) { caseInfo.CaseStatus = "已建档"; var CaseInfoSource = base.Create(caseInfo) as string;//保存原始信息 var CaseInfoTemp = caseInfo; CaseInfoTemp.PreviousformID = CaseInfoSource; var CaseInfoNew = base.Create(CaseInfoTemp) as string; //可变更的信息 if (law_Parties != null && law_Parties.Count > 0) //创建当事人 { foreach (var l in law_Parties) //原始的当事人 { l.Associatedobjecttype = "case_Info"; l.AssociationobjectID = CaseInfoSource; l.ID = Guid.NewGuid().ToString(); l.CreateDate = DateTime.Now; l.CreateUserID = SysContext.WanJiangUserID; QueryDb.Insert(l); } foreach (var l in law_Parties)//创建新建的 { l.Associatedobjecttype = "case_Info"; l.AssociationobjectID = CaseInfoNew; l.ID = Guid.NewGuid().ToString(); l.CreateDate = DateTime.Now; l.CreateUserID = SysContext.WanJiangUserID; QueryDb.Insert(l); } } //将Caseid更新到本次任务上 var tasknow = QueryDb.FirstOrDefault <work_task>("where Id=@0", caseInfo.TaskId); if (tasknow != null) { tasknow.CaseID = CaseInfoNew; QueryDb.Update(tasknow); } return(CaseInfoNew); }
private object Getpunishattchment(string formId) { var filter = new FilterGroup(); var law = QueryDb.FirstOrDefault <law_punishmentInfo>("select * from law_punishmentInfo where CaseId=@0", formId); if (law == null) { return(null); } string publishtype = ""; if (law.IsConfiscationgoods)//1为真 { publishtype = "没收物品"; } if (law.Isfine) { publishtype = publishtype + " " + "罚款"; } publishtypet = publishtype; publishTitle = law.PunishmentTitle; filter.rules.Add(new FilterRule("AssociationobjectID", law.ID, "equal")); return(ServiceHelper.GetService("attachment").GetListData(filter)); }
private void Formwith_eventcaseService_OnAfterGetPagedData(object query, object data) { var filtercase = query as FilterGroup; string eventinfoid = null; try { if (filtercase != null) { if (filtercase.groups.Count > 0) { foreach (var f in filtercase.groups) { if (f.groups.Count > 0) { foreach (var f0 in f.groups) { if (f0.rules != null) { if (f0.rules[0].field == "CaseId") { var caseinfo = QueryDb.FirstOrDefault <formwith_eventcase>("where FormID=@0", f0.rules[0].value); eventinfoid = caseinfo.EventInfoId; } } } } } } } } catch { eventinfoid = null; } var lst = (data as PagedData).Records; ServiceConfig userServiceConfig = ServiceHelper.GetServiceConfig("user"); var dicUserOrg = SysContext.GetOtherDB(userServiceConfig.model.dbName).Query <FD.Model.Dto.UserOrganizationName>("SELECT a.Id AS UserId,a.`Name` as UserName,c.`Name` as OrgName FROM USER a LEFT JOIN organizationuser b ON a.Id = b.UserId LEFT JOIN organization c ON b.OrganizationId = c.Id WHERE c.Id !=1") .GroupBy(m => m.UserId).ToDictionary(g => g.Key, g => g.ToList()); for (int i = 0; i < lst.Count; i++) { var item = lst[i] as Dictionary <string, object>; string userid = item["CreateUserID"] == null ? string.Empty : item["CreateUserID"].ToString(); if (!string.IsNullOrWhiteSpace(userid) && dicUserOrg.ContainsKey(userid)) { item["handler"] = dicUserOrg[userid].FirstOrDefault()?.UserName; item["Department"] = dicUserOrg[userid].FirstOrDefault()?.OrgName; } var formType = item["FormType"].ToString().ToLower(); if (formType == "form_confiscated") // 没收清单表查询出对应的当事人姓名 { var formlawpary = QueryDb.FirstOrDefault <string>("SELECT lawpartyid FROM form_confiscated where ID=@0", item["FormID"].ToString()); if (formlawpary != null) { var lawpartyName = QueryDb.FirstOrDefault <string>("SELECT Name FROM law_party where ID=@0", formlawpary); item["FormName"] = "[" + lawpartyName + "]" + item["FormName"]; } } if (formType == "law_punishmentinfo") //当场处罚决定书 新增处罚决定书文号 { item.Add("PunishmentTitle", QueryDb.FirstOrDefault <string>("SELECT PunishmentTitle FROM law_punishmentinfo where ID=@0", item["FormID"].ToString())); } if (formType == "law_punishmentinfo" || formType == "form_inquiryrecord" || formType == "case_report") //处罚当场决定书、勘察、结案、没收、询问表单新增详情的pdf文件地址 { item.Add("PdfFilePath", QueryDb.FirstOrDefault <string>("SELECT FilePath FROM form_printpdf where FormID=@0", item["FormID"].ToString())); } if (formType == "form_inquiryrecord") { var lawpartyName = QueryDb.FirstOrDefault <string>("SELECT InquiryType FROM law_party where AssociationobjectID=@0", item["FormID"].ToString()); item["FormName"] = "[" + lawpartyName + "]" + item["FormName"]; } } //添加事件巡查勘察 if (!string.IsNullOrEmpty(eventinfoid)) { var patrol = QueryDb.FirstOrDefault <formwith_eventcase>("where EventInfoId=@0 and FormType='task_patrol'", eventinfoid); if (patrol != null) { var obj = JsonConvert.DeserializeObject <Dictionary <string, object> >(JsonConvert.SerializeObject(patrol)); var user = SysContext.GetOtherDB(userServiceConfig.model.dbName).First <user>($"select * from user where Id={obj["CreateUserID"]}"); obj["handler"] = user.Name; lst.Add(obj); } var survey = QueryDb.FirstOrDefault <formwith_eventcase>("where EventInfoId=@0 and FormType='task_survey'", eventinfoid); if (survey != null) { var obj = JsonConvert.DeserializeObject <Dictionary <string, object> >(JsonConvert.SerializeObject(survey)); var user = SysContext.GetOtherDB(userServiceConfig.model.dbName).First <user>($"select * from user where Id={obj["CreateUserID"]}"); obj["handler"] = user.Name; lst.Add(obj); } } }
private void Case_InfoService_OnAfterGetPagedData(object query, object data) { var lst = (data as PagedData).Records; var db = this.QueryDb; IService svc = ServiceHelper.GetService("law_party"); var res_dictionary = QueryDb.FirstOrDefault <res_dictionary>("where DicCode=@0", "CaseType"); var dicItems = QueryDb.Query <res_dictionaryItems>("SELECT * FROM res_dictionaryitems where DicID=@0", res_dictionary.ID).ToDictionary(k => k.ItemCode, v => v.Title); IService psm = ServiceHelper.GetService("law_punishmentInfo"); ServiceConfig userServiceConfig = ServiceHelper.GetServiceConfig("user"); for (int i = 0; i < lst.Count; i++) { var item = lst[i] as Dictionary <string, object>; FilterGroup filterGroup = new FilterGroup(); filterGroup.rules = new List <FilterRule>(); filterGroup.rules.Add(new FilterRule { field = "Associatedobjecttype", value = "case_info", op = "equal" }); filterGroup.op = "and"; filterGroup.rules.Add(new FilterRule { field = "CaseId", value = item["ID"].ToString(), op = "equal" }); if (item["CreateUserID"] != null) { string userid = item["CreateUserID"].ToString(); var user = SysContext.GetOtherDB(userServiceConfig.model.dbName).First <user>($"select * from user where Id={userid}"); item.Add("CreatUser", user.Name); item.Add("Jobnumber", user.Jobnumber); } //var partys = svc.GetListData(filterGroup) ; var partys = QueryDb.Query <law_party>("where ASSOCIATIONOBJECTID=@0", item["ID"].ToString()); //添加附件 var pulishment = QueryDb.FirstOrDefault <law_punishmentInfo>("where caseid=@0", item["ID"].ToString()); if (pulishment != null) { var atts = QueryDb.Query <attachment>("where ASSOCIATIONOBJECTID=@0", pulishment.ID); if (atts != null) { item.Add("attachments", atts); } } else { item.Add("attachments", null); } //事件图片返回 if (!string.IsNullOrEmpty((string)item["EventInfoId"])) { var eventinfo = QueryDb.FirstOrDefault <event_info>("where objId=@0", item["EventInfoId"].ToString()); if (eventinfo != null) { item.Add("evtFileUrl", eventinfo.evtFileUrl); item.Add("posFileUrl", eventinfo.posFileUrl); } } else { item.Add("evtFileUrl", null); item.Add("posFileUrl", null); } item.Add("LawPartys", partys); var caseType = item["CaseType"].ToString(); if (dicItems.ContainsKey(caseType)) // CaseType 显示中文title { item["CaseType"] = dicItems[caseType]; } } }
public object Handle(APIContext context) { var data = JsonHelper.DeserializeJsonToObject <case_reportFinishReq>(context.Data); if (data.CaseReport == null) { throw new Exception("没有主体数据"); } data.CaseReport.TaskId = data.SourceTaskId; data.CaseReport.EventInfoId = data.EventInfoId; QueryDb.BeginTransaction(); try { #region 发起钉钉的审批 并将其返回的ID写入Task内 if (data.oapiProcessinstanceCreateRequest != null) { //填值 var UsrService = SysContext.GetService <IUserServices>(); var loginClientInfo = SysContext.GetService <WanJiang.Framework.Infrastructure.Logging.ClientInfo>(); //ServiceConfig userServiceConfig = ServiceHelper.GetServiceConfig("user"); //var OTDB = SysContext.GetOtherDB(userServiceConfig.model.dbName); //var deptId = OTDB.FirstOrDefault<long>(@"SELECT org.id FROM organization org // inner join organizationuser ou on ou.OrganizationId = org.Id // inner join user usr on usr.Id = ou.UserId // where usr.AccountId = @0", loginClientInfo.AccountId); //// //if (deptId == null) // throw new Exception("无组织部门"); var usrDetail = UsrService.GetUserDetails(loginClientInfo.UserId); var ddService = SysContext.GetService <IDingDingServices>(); if (usrDetail.Result.Organizations == null || usrDetail.Result.Organizations.Count <= 0) { throw new Exception("无组织部门"); } var deptId = usrDetail.Result.Organizations[0].Id; data.oapiProcessinstanceCreateRequest.DeptId = deptId; data.oapiProcessinstanceCreateRequest.OriginatorUserId = loginClientInfo.AccountId; var result = ddService.ProcessInstaceCreateAsync(data.oapiProcessinstanceCreateRequest); var test = result.Result; if (result.Result.Errcode != 0) { throw new Exception("发起审核流失败" + result.Result.ErrMsg); } data.CaseReport.ProcessInstanceId = result.Result.ProcessInstanceId; data.CaseReport.FormState = "待审核"; //更新该Report上的信息 //var targetId = result.Result.ProcessInstanceId; //if (data.CaseReport.TaskId == null || data.CaseReport.TaskId == "") // throw new Exception("Task为空"); //var taskObj = QueryDb.FirstOrDefault<work_task>("where TaskID =@0", data.CaseReport.TaskId); //if (taskObj == null) // throw new Exception("该Task不存在"); ////更新值 //taskObj.processInstanceId = result.Result.ProcessInstanceId; //data.CaseReport.FormState = "待审批"; ////data.CaseReport. //QueryDb.Update(taskObj); //ServiceHelper.GetService("work_task").Update(taskObj); } #endregion CreateInfo(data.CaseReport); if (!string.IsNullOrEmpty(data.CaseReport.CaseId)) { var caseinfo = QueryDb.FirstOrDefault <case_Info>("select * from case_Info where Id=@0", data.CaseReport.CaseId); if (caseinfo == null) { throw new Exception("没有案件信息"); } caseinfo.CaseStatus = "完成处罚"; QueryDb.Update(caseinfo); } else { throw new Exception("没有案件信息"); } _sHBaseService.CreatTasksAndCreatWorkrecor(data.NextTasks, data.SourceTaskId); _sHBaseService.UpdateWorkTaskState(data.SourceTaskId, WorkTaskStatus.Close);//关闭任务 //打印预生成 var PDFSerivce = ServiceHelper.GetService("form_printPDFService") as form_printPDFService; PDFSerivce.AsposeToPdf(new APIContext() { Data = @"{""formId"":""" + data.CaseReport.ID + @""",""formType"":""case_report""}" }); } catch (Exception e) { QueryDb.AbortTransaction(); throw e; } QueryDb.CompleteTransaction(); return(true); }
private object GetPatrol(string taskid) { var form = QueryDb.FirstOrDefault <task_patrol>(" where TaskId=@0 and order by CreateDate desc", taskid); return(form); }
private object GetSurvey(string taskid) { var form = QueryDb.FirstOrDefault <task_survey>(" where TaskId=@0 order PreviousformID!=null by CreateDate desc", taskid); return(form); }
public object FormData(FormDataReq data) { var res_dictionarycase = QueryDb.FirstOrDefault <res_dictionary>("where DicCode=@0", "CaseType"); var dicItemscase = QueryDb.Query <res_dictionaryItems>("SELECT * FROM res_dictionaryitems where DicID=@0", res_dictionarycase.ID).ToDictionary(k => k.ItemCode, v => v.Title); if (data.Model.ToUpper() == "case_Info".ToUpper()) { data.Model = "case_Info"; } IService service = ServiceHelper.GetService(data.Model); //根据事件id或者id查询数据 var filter = new FilterGroup(); if (!string.IsNullOrEmpty(data.FormId)) { filter.rules.Add(new FilterRule("ID", data.FormId, "equal")); } if (!string.IsNullOrEmpty(data.EventInfoId)) { filter.rules.Add(new FilterRule("EventInfoId", data.EventInfoId, "equal")); } object atlist = null; //案件特殊判断 if (data.Model.ToUpper() == "case_Info".ToUpper()) { filter.rules.Add(new FilterRule("PreviousformID", "", "notequal")); atlist = Getpunishattchment(data.FormId); } ServiceConfig userServiceConfig = ServiceHelper.GetServiceConfig("user"); //查询主表数据 var obj = service.GetListData(filter).OrderByDescending(s => s.Keys.Contains("createTime") ? s["createTime"] : s["CreateDate"]).FirstOrDefault(); //查询主表单 if (obj == null) { return(null); //throw new Exception("未取得关联数据"); } obj.Add("publishtype", publishtypet); if (obj.ContainsKey("PunishmentTitle")) { obj["PunishmentTitle"] = publishTitle; } else { obj.Add("PunishmentTitle", publishTitle); } if (obj["CreateUserID"] != null) { var user = SysContext.GetOtherDB(userServiceConfig.model.dbName).First <user>($"select * from user where Id='{obj["CreateUserID"]}'"); if (user != null) { obj["CreateUserID"] = user.Name; } } if (data.Model.ToUpper() == "case_Info".ToUpper()) { if (obj.ContainsKey("CaseType")) { if (obj["CaseType"] != null) { if (dicItemscase.ContainsKey(obj["CaseType"].ToString())) // CaseType 显示中文title { obj["CaseType"] = dicItemscase[obj["CaseType"].ToString()]; } } } } string formId = obj["ID"].ToString(); //得到id string eventinfoid = null; if (obj.ContainsKey("EventInfoId")) { eventinfoid = obj["EventInfoId"] != null ? obj["EventInfoId"].ToString() : string.Empty; } if (data.Model.ToLower() == "task_survey") // 现场勘查 EventType 显示中文title { var res_dictionary = QueryDb.FirstOrDefault <res_dictionary>("where DicCode=@0", "EventType"); var dicItems = QueryDb.Query <res_dictionaryItems>("SELECT * FROM res_dictionaryitems where DicID=@0", res_dictionary.ID).ToDictionary(k => k.ItemCode, v => v.Title); var eventType = obj["EventType"].ToString(); if (dicItems.ContainsKey(eventType)) { obj["EventType"] = dicItems[eventType]; } } //构建其他需要查询的数据 var dicData = BuildData(data, formId, eventinfoid); obj.Add("closeDate", closeDate); dicData.Add("MainForm", obj); //添加处罚决定书证据附件 if (atlist != null) { if (dicData.ContainsKey("attachment")) { var als = dicData["attachment"] as List <attachment>; if (als != null) { als.AddRange(atlist as List <attachment>); dicData["attachment"] = als; } else { dicData["attachment"] = atlist; } } else { dicData.Add("attachment", atlist); } } return(dicData); }
protected work_task GetWorkTask(string taskid) { return(QueryDb.FirstOrDefault <work_task>(" where id=@0", taskid)); }