398 lines
19 KiB
C#
398 lines
19 KiB
C#
using Aspose.Words;
|
||
using NPOI.SS.Formula.Functions;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Web.UI.WebControls;
|
||
using Model;
|
||
|
||
namespace BLL
|
||
{
|
||
|
||
public static class PHTGL_SetSubReviewService
|
||
{
|
||
/// <summary>
|
||
/// 类型综合评估法
|
||
/// </summary>
|
||
public const int Type_ConEvaluation = 2;
|
||
/// <summary>
|
||
/// 类型用于经评审的最低投标报价法
|
||
/// </summary>
|
||
public const int Type_MinPrice = 1;
|
||
|
||
public const string BidReport = "SetSubReview_sch";
|
||
public static ListItem[] GetCreateType()
|
||
{
|
||
ListItem[] list = new ListItem[2];
|
||
list[0] = new ListItem("综合评估法", Type_ConEvaluation.ToString());
|
||
list[1] = new ListItem("经评审的最低投标报价法", Type_MinPrice.ToString());
|
||
return list;
|
||
}
|
||
/// <summary>
|
||
/// 根据主键获取实体
|
||
/// </summary>
|
||
/// <param name="SetSubReviewID"></param>
|
||
/// <returns></returns>
|
||
public static Model.PHTGL_SetSubReview GetPHTGL_SetSubReviewById(string SetSubReviewID)
|
||
{
|
||
return Funs.DB.PHTGL_SetSubReview.FirstOrDefault(e => e.SetSubReviewID == SetSubReviewID);
|
||
}
|
||
/// <summary>
|
||
/// 根据编号获得实体
|
||
/// </summary>
|
||
/// <param name="setSubReviewCode"></param>
|
||
/// <returns></returns>
|
||
public static Model.PHTGL_SetSubReview GetPHTGL_SetSubReviewBySetSubReviewCode(string setSubReviewCode)
|
||
{
|
||
return Funs.DB.PHTGL_SetSubReview.FirstOrDefault(e => e.SetSubReviewCode == setSubReviewCode);
|
||
}
|
||
|
||
|
||
public static void AddPHTGL_SetSubReview(Model.PHTGL_SetSubReview newtable)
|
||
{
|
||
Model.PHTGL_SetSubReview table = new Model.PHTGL_SetSubReview();
|
||
table.SetSubReviewID = newtable.SetSubReviewID;
|
||
table.DeputyGeneralManager = newtable.DeputyGeneralManager;
|
||
table.ApproveUserReviewID = newtable.ApproveUserReviewID;
|
||
table.ActionPlanID = newtable.ActionPlanID;
|
||
table.SetSubReviewCode = newtable.SetSubReviewCode;
|
||
table.CreateUser = newtable.CreateUser;
|
||
table.State = newtable.State;
|
||
table.Type = newtable.Type;
|
||
table.ConstructionManager = newtable.ConstructionManager;
|
||
table.ProjectManager = newtable.ProjectManager;
|
||
table.Approval_Construction = newtable.Approval_Construction;
|
||
table.IsOwenerApprove = newtable.IsOwenerApprove;
|
||
table.DepartId = newtable.DepartId;
|
||
table.BidDocumentsReviewId = newtable.BidDocumentsReviewId;
|
||
Funs.DB.PHTGL_SetSubReview.InsertOnSubmit(table);
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
|
||
|
||
public static void UpdatePHTGL_SetSubReview(Model.PHTGL_SetSubReview newtable)
|
||
{
|
||
Model.PHTGL_SetSubReview table = Funs.DB.PHTGL_SetSubReview.FirstOrDefault(e => e.SetSubReviewID == newtable.SetSubReviewID
|
||
);
|
||
|
||
if (table != null)
|
||
{
|
||
table.SetSubReviewID = newtable.SetSubReviewID;
|
||
table.DeputyGeneralManager = newtable.DeputyGeneralManager;
|
||
table.ApproveUserReviewID = newtable.ApproveUserReviewID;
|
||
table.ActionPlanID = newtable.ActionPlanID;
|
||
table.SetSubReviewCode = newtable.SetSubReviewCode;
|
||
table.CreateUser = newtable.CreateUser;
|
||
table.State = newtable.State;
|
||
table.Type = newtable.Type;
|
||
table.ConstructionManager = newtable.ConstructionManager;
|
||
table.ProjectManager = newtable.ProjectManager;
|
||
table.Approval_Construction = newtable.Approval_Construction;
|
||
table.IsOwenerApprove = newtable.IsOwenerApprove;
|
||
table.DepartId = newtable.DepartId;
|
||
table.BidDocumentsReviewId = newtable.BidDocumentsReviewId;
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
|
||
}
|
||
public static void DeletePHTGL_SetSubReviewById(string SetSubReviewID
|
||
)
|
||
{
|
||
Model.PHTGL_SetSubReview table = Funs.DB.PHTGL_SetSubReview.FirstOrDefault(e => e.SetSubReviewID == SetSubReviewID
|
||
);
|
||
if (table != null)
|
||
{
|
||
Funs.DB.PHTGL_SetSubReview.DeleteOnSubmit(table);
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
|
||
}
|
||
|
||
public static Dictionary<int, string> Get_DicApproveman(string SetSubReviewID)
|
||
{
|
||
Dictionary<int, string> Dic_Approveman = new Dictionary<int, string>();
|
||
|
||
Model.PHTGL_SetSubReview table = GetPHTGL_SetSubReviewById(SetSubReviewID);
|
||
|
||
Dic_Approveman.Add(1, table.ConstructionManager);
|
||
Dic_Approveman.Add(2, table.Approval_Construction);
|
||
Dic_Approveman.Add(3, table.ProjectManager);
|
||
Dic_Approveman.Add(4, table.DeputyGeneralManager);
|
||
|
||
return Dic_Approveman;
|
||
}
|
||
public static List<ApproveManModel> GetApproveManModels(string SetSubReviewID)
|
||
{
|
||
|
||
Model.PHTGL_SetSubReview table = GetPHTGL_SetSubReviewById(SetSubReviewID);
|
||
|
||
List<ApproveManModel> approveManModels = new List<ApproveManModel>();
|
||
approveManModels.Add(new ApproveManModel { Number = 1, userid = table.ConstructionManager, Rolename = "施工经理" });
|
||
approveManModels.Add(new ApproveManModel { Number = 2, userid = table.Approval_Construction, Rolename = "施工管理部" });
|
||
approveManModels.Add(new ApproveManModel { Number = 3, userid = table.ProjectManager, Rolename = "项目经理" });
|
||
approveManModels.Add(new ApproveManModel { Number = 4, userid = table.DeputyGeneralManager, Rolename = "分管副总经理" });
|
||
return approveManModels;
|
||
}
|
||
public static void InitGetSetSubCompleteDropDownList(FineUIPro.DropDownList dropName, string userid, string ProjectId, bool isShowPlease)
|
||
{
|
||
dropName.DataValueField = "SetSubReviewCode";
|
||
dropName.DataTextField = "SetSubReviewCode";
|
||
if (userid == Const.sysglyId || userid == Const.hfnbdId)
|
||
{
|
||
dropName.DataSource = GetCompleteSetSubReview();
|
||
}
|
||
else
|
||
{
|
||
dropName.DataSource = GetMySelfCompleteSetSubReview(userid, ProjectId);
|
||
|
||
}
|
||
dropName.DataBind();
|
||
if (isShowPlease)
|
||
{
|
||
Funs.FineUIPleaseSelect(dropName);
|
||
}
|
||
}
|
||
|
||
public static object GetCompleteSetSubReview()
|
||
{
|
||
var list = (from x in Funs.DB.PHTGL_SetSubReview
|
||
where x.State == Const.ContractReview_Complete
|
||
select x).ToList();
|
||
return list;
|
||
}
|
||
public static object GetMySelfCompleteSetSubReview(string userid, string ProjectId)
|
||
{
|
||
/*var list = (from x in Funs.DB.PHTGL_SetSubReview
|
||
join y in Funs.DB.PHTGL_BidApproveUserReview on x.ApproveUserReviewID equals y.ApproveUserReviewID
|
||
where x.State == Const.ContractReview_Complete && x.CreateUser == userid
|
||
&& y.ProjectId == ProjectId
|
||
select x).ToList();*/
|
||
var list = (from x in Funs.DB.PHTGL_SetSubReview
|
||
join y in Funs.DB.PHTGL_BidDocumentsReview on x.BidDocumentsReviewId equals y.BidDocumentsReviewId
|
||
where x.State == Const.ContractReview_Complete && x.CreateUser == userid
|
||
&& y.ProjectId == ProjectId
|
||
select x).ToList();
|
||
return list;
|
||
}
|
||
public static Document Print(string SetSubReviewID)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
|
||
string initTemplatePath = string.Empty;
|
||
string uploadfilepath = string.Empty;
|
||
string newUrl = string.Empty;
|
||
string filePath = string.Empty;
|
||
string strSql = "";
|
||
var getFireWork = PHTGL_SetSubReviewService.GetPHTGL_SetSubReviewById(SetSubReviewID);
|
||
var BidDoc = PHTGL_BidDocumentsReviewService.GetPHTGL_BidDocumentsReviewById(getFireWork.BidDocumentsReviewId);
|
||
var Act = BLL.PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(BidDoc.ActionPlanID);
|
||
|
||
|
||
switch (getFireWork.Type)
|
||
{
|
||
case PHTGL_SetSubReviewService.Type_ConEvaluation:
|
||
if (Act != null)
|
||
{
|
||
if (PHTGL_ActionPlanReviewService.IsSpecialProject(Act.ProjectID))
|
||
{
|
||
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于综合评估法)LW.docx";
|
||
|
||
}
|
||
else
|
||
{
|
||
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于综合评估法).docx";
|
||
|
||
}
|
||
}
|
||
strSql = @" SELECT
|
||
Sch2.Company as Company
|
||
,Sch2.Price_ReviewResults as Price_ReviewResults
|
||
,Sch2.Skill_ReviewResults as Skill_ReviewResults
|
||
,Sch2.Business_ReviewResults as Business_ReviewResults
|
||
,Sch2.Synthesize_ReviewResults as Synthesize_ReviewResults
|
||
,Sch2.Remarks as Remarks "
|
||
+ @" FROM PHTGL_SetSubReview_Sch2 AS Sch2 "
|
||
+ @"where 1=1 AND SetSubReviewID = @SetSubReviewID order by SortIndex ";
|
||
break;
|
||
case PHTGL_SetSubReviewService.Type_MinPrice:
|
||
if (Act != null)
|
||
{
|
||
if (PHTGL_ActionPlanReviewService.IsSpecialProject(Act.ProjectID))
|
||
{
|
||
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于经评审的最低投标报价法)LW.docx";
|
||
|
||
}
|
||
else
|
||
{
|
||
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于经评审的最低投标报价法).docx";
|
||
|
||
}
|
||
}
|
||
strSql = @" SELECT
|
||
Sch1.Company as Company
|
||
,Sch1.ReviewResults as ReviewResults
|
||
,Sch1.Remarks as Remarks "
|
||
+ @" FROM PHTGL_SetSubReview_Sch1 AS Sch1 "
|
||
+ @"where 1=1 AND SetSubReviewID = @SetSubReviewID order by SortIndex ";
|
||
break;
|
||
|
||
}
|
||
uploadfilepath = rootPath + initTemplatePath;
|
||
newUrl = uploadfilepath.Replace(".docx", string.Format("{0:yyyy-MM}", DateTime.Now) + ".docx");
|
||
filePath = initTemplatePath.Replace(".docx", string.Format("{0:yyyy-MM}", DateTime.Now) + ".pdf");
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
File.Copy(uploadfilepath, newUrl);
|
||
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@SetSubReviewID", SetSubReviewID));
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||
tb.TableName = "Table";
|
||
Document doc = new Aspose.Words.Document(newUrl);
|
||
doc.MailMerge.ExecuteWithRegions(tb);
|
||
|
||
var model_ConstructionManager = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(SetSubReviewID, getFireWork.ConstructionManager);
|
||
var model_ProjectManager = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(SetSubReviewID, getFireWork.ProjectManager);
|
||
var model_Approval_Construction = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(SetSubReviewID, getFireWork.Approval_Construction);
|
||
var model_DeputyGeneralManager = PHTGL_ApproveService.GetPHTGL_ApproveByContractIdandUserId(SetSubReviewID, getFireWork.DeputyGeneralManager);
|
||
|
||
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
|
||
Dic_File.Add("txtSetSubReviewCode", getFireWork.SetSubReviewCode);
|
||
Dic_File.Add("txtBidDocumentsCode", BidDoc.BidDocumentsCode);
|
||
Dic_File.Add("txtProjectName", Act.ProjectShortName);
|
||
Dic_File.Add("txtBidContent", BidDoc.BidContent);
|
||
Dic_File.Add("txtBidding_StartTime", string.Format("{0:D}", BidDoc.Bidding_StartTime));
|
||
|
||
if (getFireWork.State == Const.ContractReview_Complete)
|
||
{
|
||
|
||
Dic_File.Add("txtConstructionManagerIdea", model_ConstructionManager.ApproveIdea.Length > 3 ? model_ConstructionManager.ApproveIdea : "同意");
|
||
Dic_File.Add("ConstructionManagerTime", string.Format("{0:D}", DateTime.Parse(model_ConstructionManager.ApproveDate)));
|
||
|
||
Dic_File.Add("txtApproval_ConstructionIdea", model_Approval_Construction.ApproveIdea.Length > 3 ? model_Approval_Construction.ApproveIdea : "同意");
|
||
Dic_File.Add("Approval_ConstructionTime", string.Format("{0:D}", DateTime.Parse(model_Approval_Construction.ApproveDate)));
|
||
|
||
Dic_File.Add("ProjectManagerIdea", model_ProjectManager.ApproveIdea.Length > 3 ? model_ProjectManager.ApproveIdea : "同意");
|
||
Dic_File.Add("ProjectManagerTime", string.Format("{0:D}", DateTime.Parse(model_ProjectManager.ApproveDate)));
|
||
|
||
Dic_File.Add("txtDeputyGeneralManagerIdea", model_DeputyGeneralManager.ApproveIdea.Length > 3 ? model_DeputyGeneralManager.ApproveIdea : "同意");
|
||
Dic_File.Add("DeputyGeneralManagerTime", string.Format("{0:D}", DateTime.Parse(model_DeputyGeneralManager.ApproveDate)));
|
||
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "Approval_Construction", getFireWork.Approval_Construction, "");
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "ConstructionManager", getFireWork.ConstructionManager, "");
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "DeputyGeneralManager", getFireWork.DeputyGeneralManager, "");
|
||
AsposeWordHelper.InsertImg(doc, rootPath, "ProjectManager", getFireWork.ProjectManager, "");
|
||
|
||
}
|
||
else
|
||
{
|
||
Dic_File.Add("txtConstructionManagerIdea", "");
|
||
Dic_File.Add("ConstructionManagerTime", " 年 月 日");
|
||
|
||
Dic_File.Add("txtApproval_ConstructionIdea", "");
|
||
Dic_File.Add("Approval_ConstructionTime", " 年 月 日");
|
||
|
||
Dic_File.Add("ProjectManagerIdea", "");
|
||
Dic_File.Add("ProjectManagerTime", " 年 月 日");
|
||
|
||
Dic_File.Add("txtDeputyGeneralManagerIdea", "");
|
||
Dic_File.Add("DeputyGeneralManagerTime", " 年 月 日");
|
||
|
||
}
|
||
foreach (var item in Dic_File)
|
||
{
|
||
string[] key = { item.Key };
|
||
object[] value = { item.Value };
|
||
doc.MailMerge.Execute(key, value);
|
||
}
|
||
|
||
|
||
doc.Save(newUrl);
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
|
||
File.Delete(newUrl);
|
||
return doc1;
|
||
}
|
||
public static void PrintFile(string Id)
|
||
{
|
||
string rootPath = Funs.RootPath;
|
||
|
||
string newUrl = string.Empty;
|
||
string initTemplatePath = string.Empty;
|
||
var getFireWork = PHTGL_SetSubReviewService.GetPHTGL_SetSubReviewById(Id);
|
||
var BidDoc = PHTGL_BidDocumentsReviewService.GetPHTGL_BidDocumentsReviewById(getFireWork.BidDocumentsReviewId);
|
||
var Act = BLL.PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(BidDoc.ActionPlanID);
|
||
|
||
switch (getFireWork.Type)
|
||
{
|
||
case PHTGL_SetSubReviewService.Type_ConEvaluation:
|
||
if (Act != null)
|
||
{
|
||
if (PHTGL_ActionPlanReviewService.IsSpecialProject(Act.ProjectID))
|
||
{
|
||
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于综合评估法)LW.docx";
|
||
|
||
}
|
||
else
|
||
{
|
||
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于综合评估法).docx";
|
||
|
||
}
|
||
}
|
||
|
||
break;
|
||
case PHTGL_SetSubReviewService.Type_MinPrice:
|
||
if (Act != null)
|
||
{
|
||
if (PHTGL_ActionPlanReviewService.IsSpecialProject(Act.ProjectID))
|
||
{
|
||
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于经评审的最低投标报价法)LW.docx";
|
||
|
||
}
|
||
else
|
||
{
|
||
initTemplatePath = "File\\Word\\PHTGL\\确定分包商审批表(用于经评审的最低投标报价法).docx";
|
||
|
||
}
|
||
}
|
||
|
||
break;
|
||
|
||
}
|
||
|
||
newUrl = rootPath + initTemplatePath;
|
||
newUrl = newUrl.Replace(".docx", string.Format("{0:yyyy-MM}", DateTime.Now) + ".docx");
|
||
if (File.Exists(newUrl))
|
||
{
|
||
File.Delete(newUrl);
|
||
}
|
||
var doc = Print(Id);
|
||
doc.Save(newUrl);
|
||
|
||
//生成PDF文件
|
||
string pdfUrl = newUrl.Replace(".docx", ".pdf");
|
||
Document doc1 = new Aspose.Words.Document(newUrl);
|
||
//验证参数
|
||
if (doc1 == null) { throw new Exception("Word文件无效"); }
|
||
doc1.Save(pdfUrl, Aspose.Words.SaveFormat.Pdf);//还可以改成其它格式
|
||
string fileName = Path.GetFileName(pdfUrl);
|
||
FileInfo info = new FileInfo(pdfUrl);
|
||
long fileSize = info.Length;
|
||
System.Web.HttpContext.Current.Response.Clear();
|
||
System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
|
||
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
|
||
System.Web.HttpContext.Current.Response.TransmitFile(pdfUrl, 0, fileSize);
|
||
System.Web.HttpContext.Current.Response.Flush();
|
||
System.Web.HttpContext.Current.Response.Close();
|
||
File.Delete(newUrl);
|
||
File.Delete(pdfUrl);
|
||
}
|
||
}
|
||
} |