fix(print): 避免 FastReport 模板重复写入
仅在报表连接串与系统连接串不一致时才更新并保存模板, 同时增加模板文件存在性校验,减少打印时因模板文件异常导致的报错。 2.修复无损检测委托单生成逻辑
This commit is contained in:
parent
ecd2d00ef7
commit
453d1d5a3b
|
|
@ -418,37 +418,35 @@ namespace BLL
|
|||
Model.HJGL_Batch_PointBatch batch = BLL.PointBatchService.GetPointBatchById(pointBatchId);
|
||||
if (batch != null)
|
||||
{
|
||||
Model.HJGL_Batch_BatchTrust newBatchTrust = new Model.HJGL_Batch_BatchTrust();
|
||||
var project = BLL.ProjectService.GetProjectByProjectId(batch.ProjectId);
|
||||
var unit = BLL.UnitService.GetUnitByUnitId(batch.UnitId);
|
||||
var area = BLL.UnitWorkService.getUnitWorkByUnitWorkId(batch.UnitWorkId);
|
||||
var ndt = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(batch.DetectionTypeId);
|
||||
var rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(batch.DetectionRateId);
|
||||
|
||||
string perfix = string.Empty;
|
||||
|
||||
newBatchTrust.TrustBatchCode = batch.PointBatchCode.Replace("-DK-", "-WT-");
|
||||
string trustBatchId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrust));
|
||||
newBatchTrust.TrustBatchId = trustBatchId;
|
||||
|
||||
newBatchTrust.TrustDate = DateTime.Now;
|
||||
newBatchTrust.ProjectId = batch.ProjectId;
|
||||
newBatchTrust.PointBatchId = batch.PointBatchId;
|
||||
newBatchTrust.UnitId = batch.UnitId;
|
||||
newBatchTrust.UnitWorkId = batch.UnitWorkId;
|
||||
newBatchTrust.DetectionTypeId = batch.DetectionTypeId;
|
||||
newBatchTrust.DetectionRateId = batch.DetectionRateId;
|
||||
newBatchTrust.NDEUnit = nDEUnit;
|
||||
newBatchTrust.PointBatchId = pointBatchId;
|
||||
BLL.Batch_BatchTrustService.AddBatchTrust(newBatchTrust); // 新增委托单
|
||||
|
||||
// 生成委托条件对比
|
||||
var generateTrustItem = from x in db.View_GenerateTrustItem
|
||||
where x.PointBatchId == pointBatchId
|
||||
select x;
|
||||
var generateTrustItem = (from x in db.View_GenerateTrustItem
|
||||
where x.PointBatchId == pointBatchId
|
||||
select x).ToList();
|
||||
if (generateTrustItem.Count == 0)
|
||||
{
|
||||
return "当前检验批没有可生成的委托明细!";
|
||||
}
|
||||
|
||||
List<string> toPointBatchList = generateTrustItem.Select(x => x.PointBatchId).Distinct().ToList();
|
||||
|
||||
Model.HJGL_Batch_BatchTrust newBatchTrust = new Model.HJGL_Batch_BatchTrust
|
||||
{
|
||||
TrustBatchId = trustBatchId,
|
||||
TrustBatchCode = batch.PointBatchCode.Replace("-DK-", "-WT-"),
|
||||
TrustDate = DateTime.Now,
|
||||
ProjectId = batch.ProjectId,
|
||||
PointBatchId = pointBatchId,
|
||||
UnitId = batch.UnitId,
|
||||
UnitWorkId = batch.UnitWorkId,
|
||||
DetectionTypeId = batch.DetectionTypeId,
|
||||
DetectionRateId = batch.DetectionRateId,
|
||||
NDEUnit = nDEUnit,
|
||||
IsAudit = true
|
||||
};
|
||||
db.HJGL_Batch_BatchTrust.InsertOnSubmit(newBatchTrust);
|
||||
|
||||
// 生成委托明细,并回写点口明细信息
|
||||
foreach (var item in generateTrustItem)
|
||||
{
|
||||
|
|
@ -460,15 +458,15 @@ namespace BLL
|
|||
TrustBatchId = trustBatchId,
|
||||
PointBatchItemId = item.PointBatchItemId,
|
||||
WeldJointId = item.WeldJointId,
|
||||
CreateDate = DateTime.Now
|
||||
CreateDate = DateTime.Now,
|
||||
TrustNum = 1
|
||||
};
|
||||
Batch_BatchTrustItemService.AddBatchTrustItem(trustItem);
|
||||
db.HJGL_Batch_BatchTrustItem.InsertOnSubmit(trustItem);
|
||||
}
|
||||
|
||||
Model.HJGL_Batch_PointBatchItem pointBatchItem = db.HJGL_Batch_PointBatchItem.First(x => x.PointBatchItemId == item.PointBatchItemId);
|
||||
|
||||
pointBatchItem.IsBuildTrust = true;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -476,14 +474,9 @@ namespace BLL
|
|||
if (toPointBatchList.Count() > 0)
|
||||
{
|
||||
string toPointBatch = String.Join(",", toPointBatchList);
|
||||
|
||||
var updateTrut = BLL.Batch_BatchTrustService.GetBatchTrustById(trustBatchId);
|
||||
if (updateTrut != null)
|
||||
{
|
||||
updateTrut.TopointBatch = toPointBatch;
|
||||
BLL.Batch_BatchTrustService.UpdateBatchTrust(updateTrut);
|
||||
}
|
||||
newBatchTrust.TopointBatch = toPointBatch;
|
||||
}
|
||||
db.SubmitChanges();
|
||||
result = "委托成功!";
|
||||
}
|
||||
}
|
||||
|
|
@ -542,29 +535,33 @@ namespace BLL
|
|||
|
||||
string perfix = string.Empty;
|
||||
perfix = unit.UnitCode + "-" + ndt.DetectionTypeCode + "-" + rate.DetectionRateValue.ToString() + "%-";
|
||||
newBatchTrust.TrustBatchCode = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.HJGL_Batch_BatchTrust", "TrustBatchCode", project.ProjectId, perfix);
|
||||
|
||||
string trustBatchId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrust));
|
||||
newBatchTrust.TrustBatchId = trustBatchId;
|
||||
|
||||
// 生成委托条件对比
|
||||
var generateTrustItem = (from x in db.View_GenerateTrustItem
|
||||
where x.ProjectId == trust.ProjectId
|
||||
&& x.UnitWorkId == trust.UnitWorkId && x.UnitId == trust.UnitId
|
||||
&& x.DetectionTypeId == trust.DetectionTypeId
|
||||
&& x.DetectionRateId == trust.DetectionRateId
|
||||
select x).ToList();
|
||||
if (generateTrustItem.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
List<string> toPointBatchList = generateTrustItem.Select(x => x.PointBatchId).Distinct().ToList();
|
||||
|
||||
newBatchTrust.TrustBatchCode = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.HJGL_Batch_BatchTrust", "TrustBatchCode", project.ProjectId, perfix);
|
||||
newBatchTrust.TrustBatchId = trustBatchId;
|
||||
newBatchTrust.TrustDate = DateTime.Now;
|
||||
newBatchTrust.ProjectId = trust.ProjectId;
|
||||
newBatchTrust.UnitId = trust.UnitId;
|
||||
newBatchTrust.UnitWorkId = trust.UnitWorkId;
|
||||
newBatchTrust.DetectionTypeId = trust.DetectionTypeId;
|
||||
newBatchTrust.NDEUnit = unitWork.NDEUnit;
|
||||
|
||||
BLL.Batch_BatchTrustService.AddBatchTrust(newBatchTrust); // 新增委托单
|
||||
|
||||
// 生成委托条件对比
|
||||
var generateTrustItem = from x in db.View_GenerateTrustItem
|
||||
where x.ProjectId == trust.ProjectId
|
||||
&& x.UnitWorkId == trust.UnitWorkId && x.UnitId == trust.UnitId
|
||||
&& x.DetectionTypeId == trust.DetectionTypeId
|
||||
&& x.DetectionRateId == trust.DetectionRateId
|
||||
select x;
|
||||
|
||||
List<string> toPointBatchList = generateTrustItem.Select(x => x.PointBatchId).Distinct().ToList();
|
||||
newBatchTrust.DetectionRateId = trust.DetectionRateId;
|
||||
newBatchTrust.IsAudit = true;
|
||||
db.HJGL_Batch_BatchTrust.InsertOnSubmit(newBatchTrust);
|
||||
|
||||
// 生成委托明细,并回写点口明细信息
|
||||
foreach (var item in generateTrustItem)
|
||||
|
|
@ -577,15 +574,18 @@ namespace BLL
|
|||
TrustBatchId = trustBatchId,
|
||||
PointBatchItemId = item.PointBatchItemId,
|
||||
WeldJointId = item.WeldJointId,
|
||||
CreateDate = DateTime.Now
|
||||
CreateDate = DateTime.Now,
|
||||
TrustNum = 1
|
||||
};
|
||||
Batch_BatchTrustItemService.AddBatchTrustItem(trustItem);
|
||||
db.HJGL_Batch_BatchTrustItem.InsertOnSubmit(trustItem);
|
||||
}
|
||||
|
||||
Model.HJGL_Batch_PointBatchItem pointBatchItem = db.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == item.PointBatchItemId);
|
||||
|
||||
pointBatchItem.IsBuildTrust = true;
|
||||
db.SubmitChanges();
|
||||
if (pointBatchItem != null)
|
||||
{
|
||||
pointBatchItem.IsBuildTrust = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -593,14 +593,9 @@ namespace BLL
|
|||
if (toPointBatchList.Count() > 0)
|
||||
{
|
||||
string toPointBatch = String.Join(",", toPointBatchList);
|
||||
|
||||
var updateTrut = BLL.Batch_BatchTrustService.GetBatchTrustById(trustBatchId);
|
||||
if (updateTrut != null)
|
||||
{
|
||||
updateTrut.TopointBatch = toPointBatch;
|
||||
BLL.Batch_BatchTrustService.UpdateBatchTrust(updateTrut);
|
||||
}
|
||||
newBatchTrust.TopointBatch = toPointBatch;
|
||||
}
|
||||
db.SubmitChanges();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -683,8 +678,8 @@ namespace BLL
|
|||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getDataLists = (from x in db.View_GenerateTrustItem
|
||||
where x.PointBatchId == trustBatchId
|
||||
var getDataLists = (from x in db.View_Batch_BatchTrustItem
|
||||
where x.TrustBatchId == trustBatchId
|
||||
orderby x.WeldJointCode
|
||||
select new Model.NDETrustItem
|
||||
{
|
||||
|
|
@ -1061,7 +1056,12 @@ namespace BLL
|
|||
newRepairTrust.UnitId = repairRecord.UnitId;
|
||||
newRepairTrust.UnitWorkId = repairRecord.UnitWorkId;
|
||||
newRepairTrust.DetectionTypeId = repairRecord.DetectionTypeId;
|
||||
var oldTrust = (from x in Funs.DB.HJGL_Batch_BatchTrust
join y in Funs.DB.HJGL_Batch_BatchTrustItem on x.TrustBatchId equals y.TrustBatchId
join z in Funs.DB.HJGL_Batch_NDEItem on y.TrustBatchItemId equals z.TrustBatchItemId
where z.NDEItemID == repairRecord.NDEItemID
select x).FirstOrDefault();
newRepairTrust.DetectionRateId = oldTrust.DetectionRateId;
|
||||
var oldTrust = (from x in Funs.DB.HJGL_Batch_BatchTrust
|
||||
join y in Funs.DB.HJGL_Batch_BatchTrustItem on x.TrustBatchId equals y.TrustBatchId
|
||||
join z in Funs.DB.HJGL_Batch_NDEItem on y.TrustBatchItemId equals z.TrustBatchItemId
|
||||
where z.NDEItemID == repairRecord.NDEItemID
|
||||
select x).FirstOrDefault();
|
||||
newRepairTrust.DetectionRateId = oldTrust.DetectionRateId;
|
||||
newRepairTrust.TrustType = "R";
|
||||
|
||||
BLL.Batch_BatchTrustService.AddBatchTrust(newRepairTrust); // 新增返修委托单
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ namespace FineUIPro.Web.Controls
|
|||
{
|
||||
ReportPath = Request.Params["ReportPath"];
|
||||
WebReport1.StartReport += WebReport1_StartReport;
|
||||
if (string.IsNullOrEmpty(ReportPath) || !System.IO.File.Exists(ReportPath))
|
||||
{
|
||||
throw new System.IO.FileNotFoundException("打印模板不存在!", ReportPath);
|
||||
}
|
||||
if (dataTables != null && dataTables.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < dataTables.Count; i++)
|
||||
|
|
@ -49,8 +53,12 @@ namespace FineUIPro.Web.Controls
|
|||
WebReport1.Report.Load(ReportPath);
|
||||
if (WebReport1.Report.Dictionary.Connections.Count > 0)
|
||||
{
|
||||
WebReport1.Report.Dictionary.Connections[0].ConnectionString = Funs.ConnString;
|
||||
WebReport1.Report.Save(ReportPath);
|
||||
var reportConnection = WebReport1.Report.Dictionary.Connections[0];
|
||||
if (reportConnection.ConnectionString != Funs.ConnString)
|
||||
{
|
||||
reportConnection.ConnectionString = Funs.ConnString;
|
||||
WebReport1.Report.Save(ReportPath);
|
||||
}
|
||||
}
|
||||
WebReport1.ReportFile = ReportPath;
|
||||
WebReport1.Prepare();
|
||||
|
|
|
|||
Loading…
Reference in New Issue