public string GetYsIncome([FromUri] BaseListModel param) { if (param.orgid == 0 || string.IsNullOrEmpty(param.orgCode)) { return(DCHelper.ErrorMessage("组织信息不能为空!")); } if (string.IsNullOrEmpty(param.Year)) { return(DCHelper.ErrorMessage("年度信息不能为空!")); } try { //存主信息 YsIncomeMstModel ysIncomeMst = new YsIncomeMstModel(); //预算部门集合(收入归属) IList <OrganizeModel> organizes = new List <OrganizeModel>(); organizes = this.YsIncomeMstService.GetAllOrganize(); //存明细信息 IList <YsIncomeDtlModel> ysIncomeDtls = new List <YsIncomeDtlModel>(); var ysIncomeMsts = this.YsIncomeMstService.Find(t => t.FOrgID == param.orgid && t.FYear == param.Year).Data; if (ysIncomeMsts != null && ysIncomeMsts.Count > 0) { ysIncomeMst = ysIncomeMsts[0]; ysIncomeDtls = this.YsIncomeMstService.FindYsIncomeDtlByForeignKey(ysIncomeMsts[0].PhId).Data; } else { ysIncomeMst.FOrgID = param.orgid; ysIncomeMst.FOrgcode = param.orgCode; ysIncomeMst.FYear = param.Year; //预算科目的基本信息 IList <BudgetAccountsModel> budgetAccounts = new List <BudgetAccountsModel>(); budgetAccounts = this.BudgetAccountsService.Find(t => t.PhId > 0).Data; if (budgetAccounts == null || budgetAccounts.Count <= 0) { return(DCHelper.ErrorMessage("预算科目基础配置信息为空!")); } //获取该组织的所对应的所有预算科目 IList <CorrespondenceSettingsModel> correspondenceSettingss = new List <CorrespondenceSettingsModel>(); correspondenceSettingss = this.CorrespondenceSettingsService.Find(t => t.Dylx == "02" && t.Dwdm == param.orgid.ToString()).Data; if (correspondenceSettingss != null && correspondenceSettingss.Count > 0) { foreach (var corr in correspondenceSettingss) { YsIncomeDtlModel ysIncomeDtl = new YsIncomeDtlModel(); ysIncomeDtl.FSubjectCode = corr.Dydm; ysIncomeDtl.FSubjectname = budgetAccounts.ToList().Find(t => t.KMDM == corr.Dydm) == null ? "" : budgetAccounts.ToList().Find(t => t.KMDM == corr.Dydm).KMMC; ysIncomeDtl.FProcessStatus = "";//进度控制暂定 ysIncomeDtls.Add(ysIncomeDtl); } } else { return(DCHelper.ErrorMessage("此单位对应的预算科目信息为空!")); } } if (ysIncomeDtls != null && ysIncomeDtls.Count > 0) { foreach (var dtl in ysIncomeDtls) { if (ysIncomeDtls.ToList().Find(t => t.FSubjectCode.StartsWith(dtl.FSubjectCode) && t.FSubjectCode != dtl.FSubjectCode) == null) { dtl.IsLast = 1; } if (organizes != null && organizes.Count > 0) { dtl.FBudgetName = organizes.ToList().Find(t => t.OCode == dtl.FBudgetcode) == null ? "" : organizes.ToList().Find(t => t.OCode == dtl.FBudgetcode).OName; } } } if (!string.IsNullOrEmpty(param.Search) && ysIncomeDtls != null && ysIncomeDtls.Count > 0) { ysIncomeDtls = ysIncomeDtls.ToList().FindAll(t => (t.FSubjectCode.Contains(param.Search) || t.FSubjectname.Contains(param.Search))); } var data = new { Status = ResponseStatus.Success, Msg = "获取成功!", Mst = ysIncomeMst, Dtls = ysIncomeDtls.OrderBy(t => t.FSubjectCode).ToList() }; return(DataConverterHelper.SerializeObject(data)); } catch (Exception ex) { return(DCHelper.ErrorMessage(ex.Message)); } }
public string PostSave([FromBody] AllYsIncomeRequestModel param) { if (param.YsIncomeMst == null || param.YsIncomeDtls == null || param.YsIncomeDtls.Count <= 0) { return(DCHelper.ErrorMessage("传递的收入预算信息不能为空!")); } if (param.orgid == 0 || param.YsIncomeMst.FOrgID == 0) { return(DCHelper.ErrorMessage("组织信息不能为空!")); } if (string.IsNullOrEmpty(param.Year) || string.IsNullOrEmpty(param.YsIncomeMst.FYear)) { return(DCHelper.ErrorMessage("年度信息不能为空!")); } try { if (param.YsIncomeMst.FApproval != 0 || param.YsIncomeMst.FIsbudget != 0) { return(DCHelper.ErrorMessage("只有待送审,未生成预算的收入预算可以进行修改!")); } IList <YsIncomeDtlModel> ysIncomeDtls = new List <YsIncomeDtlModel>(); //先进行数据调整 if (param.YsIncomeMst.PhId == 0) { param.YsIncomeMst.FDeclareTime = DateTime.Now; param.YsIncomeMst.PersistentState = PersistentState.Added; foreach (var dtl in param.YsIncomeDtls) { if (dtl.PhId == 0) { if (dtl.PersistentState == PersistentState.Deleted) { continue; } dtl.PersistentState = PersistentState.Added; } else { if (dtl.PersistentState != PersistentState.Deleted) { dtl.PersistentState = PersistentState.Modified; } } ysIncomeDtls.Add(dtl); } } else { param.YsIncomeMst.FDeclareTime = DateTime.Now; //没打上删除标记的都是修改 if (param.YsIncomeMst.PersistentState != PersistentState.Deleted) { param.YsIncomeMst.PersistentState = PersistentState.Modified; foreach (var dtl in param.YsIncomeDtls) { if (dtl.PhId == 0) { if (dtl.PersistentState == PersistentState.Deleted) { continue; } dtl.PersistentState = PersistentState.Added; } else { if (dtl.PersistentState != PersistentState.Deleted) { dtl.PersistentState = PersistentState.Modified; } } ysIncomeDtls.Add(dtl); } } else { foreach (var dtl in param.YsIncomeDtls) { if (dtl.PhId == 0) { continue; } dtl.PersistentState = PersistentState.Deleted; ysIncomeDtls.Add(dtl); } } } param.YsIncomeMst.FDeclareAmount = ysIncomeDtls.ToList().FindAll(t => t.PersistentState != PersistentState.Deleted).Sum(t => t.FBudgetamount); SavedResult <long> savedResult = new SavedResult <long>(); savedResult = this.YsIncomeMstService.SaveYsIncome(param.YsIncomeMst, ysIncomeDtls); return(DataConverterHelper.SerializeObject(savedResult)); } catch (Exception ex) { return(DCHelper.ErrorMessage(ex.Message)); } }
public string GetDescriptionDocx([FromUri] BaseListModel parameter) { if (parameter == null) { return(DCHelper.ErrorMessage("请求参数为空!")); } if (parameter.orgid == 0) { return(DCHelper.ErrorMessage("组织id为空!")); } if (parameter.uid == 0) { return(DCHelper.ErrorMessage("用户id为空!")); } if (String.IsNullOrEmpty(parameter.Year)) { return(DCHelper.ErrorMessage("年度为空!")); } //value来判断是年初,年中,年末预算说明说 if (String.IsNullOrEmpty(parameter.value)) { return(DCHelper.ErrorMessage("判断年初,年中,年末的value条件为空!")); } //查询预算主表对象,获取预算说明书 string description = ""; try { IList <YsAccountMstModel> mstModels = YsAccountMstService.Find(t => t.Orgid == parameter.orgid && t.Uyear == parameter.Year).Data; if (mstModels != null && mstModels.Count > 0) { if ("1".Equals(parameter.value)) { description = mstModels[0].DescriptionStart; } else if ("2".Equals(parameter.value)) { description = mstModels[0].DescriptionMiddle; } else if ("3".Equals(parameter.value)) { description = mstModels[0].DescriptionEnd; } } else { description = ""; } } catch (Exception e) { return(DCHelper.ErrorMessage("预算主表对象失败!")); } FileStream fs = null; FileStream output = null; try { string filename = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".docx"; string filePath = HostingEnvironment.MapPath("~/DownLoadFiles/SubjectBudget"); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } File.Copy(HostingEnvironment.MapPath("~" + "/DownLoadFiles/template/预算说明书.docx"), filePath + "/" + filename, true); fs = new FileStream(filePath + "/" + filename, FileMode.Open, FileAccess.Read); XWPFDocument document = new XWPFDocument(fs); foreach (var para in document.Paragraphs) { string oldContext = para.ParagraphText; if (String.IsNullOrEmpty(oldContext)) { continue; } string context = para.ParagraphText; if (context.Contains("{$date}")) { context = context.Replace("{$date}", DateTime.Now.ToString("yyyy/MM/dd")); } if (context.Contains("{$content}")) { context = context.Replace("{$content}", description); } if (oldContext != context) { para.ReplaceText(oldContext, context); } } output = new FileStream(filePath + "/" + filename, FileMode.Create); document.Write(output); fs.Close(); fs.Dispose(); output.Close(); output.Dispose(); return(DataConverterHelper.SerializeObject(new { path = filePath, filename = filename })); } catch (Exception e) { if (fs != null) { fs.Close(); fs.Dispose(); } if (output != null) { output.Close(); output.Dispose(); } return(DCHelper.ErrorMessage("导出预算说明书失败!" + e.Message)); } }
public string GetYearStartCover([FromUri] BaseListModel parameter) { if (parameter == null) { return(DCHelper.ErrorMessage("请求参数为空!")); } if (parameter.orgid == 0) { return(DCHelper.ErrorMessage("组织id为空!")); } if (parameter.uid == 0) { return(DCHelper.ErrorMessage("用户id为空!")); } if (String.IsNullOrEmpty(parameter.Year)) { return(DCHelper.ErrorMessage("年度为空!")); } //value来判断是年初,年中,年末预算说明说 if (String.IsNullOrEmpty(parameter.value)) { return(DCHelper.ErrorMessage("判断年初,年中,年末的value条件为空!")); } //获取组织和用户信息 User2Model userModel = new User2Model(); OrganizeModel organizeModel = new OrganizeModel(); try { userModel = this.BudgetMstService.GetUser(parameter.uid); } catch (Exception e) { return(DCHelper.ErrorMessage("获取用户信息失败!")); } try { organizeModel = this.BudgetMstService.GetOrganize(parameter.orgid); } catch (Exception e) { return(DCHelper.ErrorMessage("获取组织信息失败!")); } FileStream fs = null; FileStream output = null; try { string title = ""; string content1 = ""; string content2 = ""; if ("1".Equals(parameter.value)) { title = "预算表"; content1 = "预算说明书"; content2 = "经费收支预算表"; } else if ("2".Equals(parameter.value)) { title = "预算表(年中调整)"; content1 = "预算说明书(年中调整)"; content2 = "经费收支预算表(年中调整)"; } else if ("3".Equals(parameter.value)) { title = "决算表"; content1 = "决算说明书"; content2 = "经费决算预算表"; } string filename = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".docx"; string filePath = HostingEnvironment.MapPath("~/DownLoadFiles/SubjectBudget"); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } File.Copy(HostingEnvironment.MapPath("~" + "/DownLoadFiles/template/预算封面.docx"), filePath + "/" + filename, true); fs = new FileStream(filePath + "/" + filename, FileMode.Open, FileAccess.Read); XWPFDocument document = new XWPFDocument(fs); foreach (var para in document.Paragraphs) { string oldContext = para.ParagraphText; if (String.IsNullOrEmpty(oldContext)) { continue; } string context = para.ParagraphText; if (context.Contains("{$date}")) { context = context.Replace("{$date}", DateTime.Now.ToString("yyyy/MM/dd")); } if (context.Contains("{$chairman}")) { context = context.Replace("{$chairman}", userModel.UserName); } if (context.Contains("{$treasurer}")) { context = context.Replace("{$treasurer}", userModel.UserName); } if (context.Contains("{$maker}")) { context = context.Replace("{$maker}", userModel.UserName); } if (context.Contains("{$checker}")) { context = context.Replace("{$checker}", ""); } if (context.Contains("{$year}")) { context = context.Replace("{$year}", DateTime.Now.Year.ToString()); } if (context.Contains("{$month}")) { context = context.Replace("{$month}", DateTime.Now.Month.ToString()); } if (context.Contains("{$day}")) { context = context.Replace("{$day}", DateTime.Now.Day.ToString()); } if (context.Contains("{$title}")) { context = context.Replace("{$title}", title); } if (context.Contains("{$content1}")) { context = context.Replace("{$content1}", content1); } if (context.Contains("{$content2}")) { context = context.Replace("{$content2}", content2); } if (oldContext != context) { para.ReplaceText(oldContext, context); } } output = new FileStream(filePath + "/" + filename, FileMode.Create); document.Write(output); fs.Close(); fs.Dispose(); output.Close(); output.Dispose(); return(DataConverterHelper.SerializeObject(new { path = filePath, filename = filename })); } catch (Exception ex) { if (fs != null) { fs.Close(); fs.Dispose(); } if (output != null) { output.Close(); output.Dispose(); } return(DCHelper.ErrorMessage("导出年初申报的封面失败!" + ex.Message)); } }
public string PostSaveAccountList([FromBody] BaseInfoModel <YsAccountMstModel> param) { if (param.uid == 0) { return(DCHelper.ErrorMessage("用户id不能为空!")); } if (param.orgid == 0) { return(DCHelper.ErrorMessage("组织id不能为空!")); } if (param.infoData == null) { return(DCHelper.ErrorMessage("参数传递有误!")); } try { if (param.infoData.YsAccounts != null && param.infoData.YsAccounts.Count > 0) { IList <YsAccountModel> ysAccounts = new List <YsAccountModel>(); foreach (var acc in param.infoData.YsAccounts) { ysAccounts.Add(acc); GetYsAccountsChilds(acc, ysAccounts); } if (ysAccounts != null && ysAccounts.Count > 0) { //后端重新算一遍数据(防止前端传入错误数据) foreach (var ysAcc in ysAccounts) { if (ysAcc.SUBJECTCODE == "4BNHJSR") { ysAcc.FINALACCOUNTSTOTAL = ysAccounts.ToList().FindAll(t => (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).StartsWith("4") && (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).Length == 3) == null ? 0 : ysAccounts.ToList().FindAll(t => (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).StartsWith("4") && (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).Length == 3).Sum(t => t.FINALACCOUNTSTOTAL); ysAcc.BUDGETTOTAL = ysAccounts.ToList().FindAll(t => (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).StartsWith("4") && (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).Length == 3) == null ? 0 : ysAccounts.ToList().FindAll(t => (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).StartsWith("4") && (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).Length == 3).Sum(t => t.BUDGETTOTAL); ysAcc.ADJUSTMENT = ysAccounts.ToList().FindAll(t => (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).StartsWith("4") && (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).Length == 3) == null ? 0 : ysAccounts.ToList().FindAll(t => (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).StartsWith("4") && (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).Length == 3).Sum(t => t.ADJUSTMENT); ysAcc.APPROVEDBUDGETTOTAL = ysAccounts.ToList().FindAll(t => (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).StartsWith("4") && (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).Length == 3) == null ? 0 : ysAccounts.ToList().FindAll(t => (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).StartsWith("4") && (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).Length == 3).Sum(t => t.APPROVEDBUDGETTOTAL); ysAcc.ThisaccountsTotal = ysAccounts.ToList().FindAll(t => (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).StartsWith("4") && (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).Length == 3) == null ? 0 : ysAccounts.ToList().FindAll(t => (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).StartsWith("4") && (t.SUBJECTCODE == null ? "" : t.SUBJECTCODE).Length == 3).Sum(t => t.ThisaccountsTotal); } if (ysAcc.SUBJECTCODE == "5QM1") { ysAcc.FINALACCOUNTSTOTAL = (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "4BNHJSR") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "4BNHJSR").FINALACCOUNTSTOTAL) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5BNHJZC") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5BNHJZC").FINALACCOUNTSTOTAL); ysAcc.BUDGETTOTAL = (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "4BNHJSR") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "4BNHJSR").BUDGETTOTAL) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5BNHJZC") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5BNHJZC").BUDGETTOTAL); ysAcc.ADJUSTMENT = (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "4BNHJSR") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "4BNHJSR").ADJUSTMENT) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5BNHJZC") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5BNHJZC").ADJUSTMENT); ysAcc.APPROVEDBUDGETTOTAL = (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "4BNHJSR") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "4BNHJSR").APPROVEDBUDGETTOTAL) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5BNHJZC") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5BNHJZC").APPROVEDBUDGETTOTAL); ysAcc.ThisaccountsTotal = (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "4BNHJSR") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "4BNHJSR").ThisaccountsTotal) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5BNHJZC") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5BNHJZC").ThisaccountsTotal); } if (ysAcc.SUBJECTCODE == "5QM6") { ysAcc.FINALACCOUNTSTOTAL = (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM1") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM1").FINALACCOUNTSTOTAL) + (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM2") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM2").FINALACCOUNTSTOTAL) + (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM3") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM3").FINALACCOUNTSTOTAL) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM4") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM4").FINALACCOUNTSTOTAL) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM5") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM5").FINALACCOUNTSTOTAL); ysAcc.BUDGETTOTAL = (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM1") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM1").BUDGETTOTAL) + (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM2") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM2").BUDGETTOTAL) + (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM3") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM3").BUDGETTOTAL) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM4") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM4").BUDGETTOTAL) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM5") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM5").BUDGETTOTAL); ysAcc.ADJUSTMENT = (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM1") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM1").ADJUSTMENT) + (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM2") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM2").ADJUSTMENT) + (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM3") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM3").ADJUSTMENT) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM4") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM4").ADJUSTMENT) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM5") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM5").ADJUSTMENT); ysAcc.APPROVEDBUDGETTOTAL = (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM1") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM1").APPROVEDBUDGETTOTAL) + (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM2") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM2").APPROVEDBUDGETTOTAL) + (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM3") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM3").APPROVEDBUDGETTOTAL) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM4") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM4").APPROVEDBUDGETTOTAL) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM5") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM5").APPROVEDBUDGETTOTAL); ysAcc.ThisaccountsTotal = (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM1") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM1").ThisaccountsTotal) + (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM2") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM2").ThisaccountsTotal) + (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM3") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM3").ThisaccountsTotal) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM4") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM4").ThisaccountsTotal) - (ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM5") == null ? 0 : ysAccounts.ToList().Find(t => t.SUBJECTCODE == "5QM5").ThisaccountsTotal); } if (ysAcc.BUDGETTOTAL == 0) { ysAcc.BudgetComplete = 100; } else { ysAcc.BudgetComplete = ysAcc.APPROVEDBUDGETTOTAL / ysAcc.BUDGETTOTAL * 100; } if (ysAcc.APPROVEDBUDGETTOTAL == 0) { ysAcc.COMPLETE = 100; } else { ysAcc.COMPLETE = ysAcc.ThisaccountsTotal / ysAcc.APPROVEDBUDGETTOTAL * 100; } } } param.infoData.YsAccounts = ysAccounts; } //if ("1".Equals(param.value)) //{ // if(param.infoData.VerifyStart == 1) // { // return DCHelper.ErrorMessage("年初申报数据已上报,不能修改!"); // } //} //else if ("2".Equals(param.value)) //{ // if (param.infoData.VerifyMiddle == 1) // { // return DCHelper.ErrorMessage("年中调整数据已上报,不能修改!"); // } //} //else if ("3".Equals(param.value)) //{ // if (param.infoData.VerifyEnd == 1) // { // return DCHelper.ErrorMessage("年末决算数据已上报,不能修改!"); // } //} SavedResult <long> savedResult = new SavedResult <long>(); savedResult = this.YsAccountMstService.SaveYsAccount(param.infoData, param.orgid, param.orgCode, param.Year, param.uid, param.value); return(DataConverterHelper.SerializeObject(savedResult)); } catch (Exception ex) { return(DCHelper.ErrorMessage(ex.Message)); } }
public async Task <string> PostSave2() { List <QtAttachmentModel> attachmentModels = new List <QtAttachmentModel>(); List <QtAttachmentModel> oldattachmentModels = new List <QtAttachmentModel>(); //具体数据对象 long expensePhid = 0; //判断form表单类型是否正确 if (!Request.Content.IsMimeMultipartContent()) { var data1 = new { Status = ResponseStatus.Error, Msg = "请求数据不是multipart/form-data类型", Data = "" }; return(DataConverterHelper.SerializeObject(data1)); } //I6WebAppInfo i6AppInfo = (I6WebAppInfo)HttpContext.Current.Session["NGWebAppInfo"] ?? null; //获取AppInfo值 头部信息记录 var base64EncodedBytes = Convert.FromBase64String(HttpContext.Current.Request.Headers.GetValues("AppInfo").First()); var jsonText = Encoding.UTF8.GetString(base64EncodedBytes); var AppInfo = JsonConvert.DeserializeObject <AppInfoBase>(jsonText); //如果路径不存在,创建路径 var root = System.Web.Hosting.HostingEnvironment.MapPath("~/UpLoadFiles/ExpenseMst/"); string date = DateTime.Now.ToString("yyyy-MM-dd"); string filePath = Path.Combine(root, date); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } var multipartMemoryStreamProvider = await Request.Content.ReadAsMultipartAsync(); var contentsList = multipartMemoryStreamProvider.Contents; foreach (var content in contentsList) { //通过判断fileName是否为空,是否为文件 if (!string.IsNullOrEmpty(content.Headers.ContentDisposition.FileName)) { //处理文件名字符串 string fileName = content.Headers.ContentDisposition.FileName.Replace("\"", string.Empty); using (Stream stream = await content.ReadAsStreamAsync()) { //文件如果大于100MB 提示不允许 if (stream.Length > 104857600) { return(DCHelper.ErrorMessage("上传的文件不能大于100MB!")); } byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); stream.Seek(0, SeekOrigin.Begin); //获取对应文件后缀名 string extension = Path.GetExtension(fileName); //获取文件名 string b_name = Path.GetFileName(fileName); //修改文件名 string newFileName = Guid.NewGuid().ToString("N") + extension; string uploadPath = Path.Combine(filePath, newFileName); //保存文件 MemoryStream ms = new MemoryStream(bytes); FileStream fs = new FileStream(uploadPath, FileMode.Create); ms.WriteTo(fs); ms.Close(); fs.Close(); string b_urlpath = "/UpLoadFiles/ExpenseMst/" + date + "/" + newFileName; QtAttachmentModel attachmentModel = new QtAttachmentModel(); attachmentModel.BName = b_name; attachmentModel.BSize = decimal.Round((decimal)stream.Length / 1024, 2); attachmentModel.BTable = "YS3_EXPENSEMST"; attachmentModel.BType = extension; attachmentModel.BUrlpath = b_urlpath; attachmentModel.PersistentState = PersistentState.Added; attachmentModels.Add(attachmentModel); } } else { //获取键值对值,并通过反射获取对象中的属性 string key = content.Headers.ContentDisposition.Name.Replace("\"", string.Empty); string value = await content.ReadAsStringAsync(); //取项目主键 //projectPhid = long.Parse(value); //取用款计划主键 if (key == "PhId") { expensePhid = long.Parse(value); } else if (key == "OldAttachments") { var value2 = JsonConvert.DeserializeObject <List <QtAttachmentModel> >(value); oldattachmentModels = value2; } ////取用款计划主键 //expensePhid = long.Parse(value); } } if (expensePhid <= 0) { return(DCHelper.ErrorMessage("用款计划保存附件失败!")); } try { SavedResult <long> savedResult = new SavedResult <long>(); //原有的附件要删除 IList <QtAttachmentModel> oldAttachments = new List <QtAttachmentModel>(); oldAttachments = this.QtAttachmentService.Find(t => t.BTable == "YS3_EXPENSEMST" && t.RelPhid == expensePhid).Data; if (oldAttachments != null && oldAttachments.Count > 0) { foreach (var oldAtt in oldAttachments) { oldAtt.PersistentState = PersistentState.Deleted; } this.QtAttachmentService.Save <long>(oldAttachments, ""); } if (attachmentModels != null && attachmentModels.Count > 0) { foreach (var att in attachmentModels) { att.RelPhid = expensePhid; att.BTable = "YS3_EXPENSEMST"; att.PersistentState = PersistentState.Added; } //savedResult = this.QtAttachmentService.Save<long>(attachmentModels, ""); } if (oldattachmentModels != null && oldattachmentModels.Count > 0) { foreach (var oldAtt in oldattachmentModels) { oldAtt.RelPhid = expensePhid; oldAtt.BTable = "YS3_EXPENSEMST"; oldAtt.PersistentState = PersistentState.Added; attachmentModels.Add(oldAtt); } } if (attachmentModels != null && attachmentModels.Count > 0) { savedResult = this.QtAttachmentService.Save <long>(attachmentModels, ""); } return(DataConverterHelper.SerializeObject(savedResult)); } catch (Exception ex) { return(DCHelper.ErrorMessage(ex.Message)); } }