20260807 批量生成二维码
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
alter table HJGL_PW_JointInfo add QRCodeAttachUrl nvarchar(200)
|
||||||
|
go
|
||||||
|
|
||||||
|
CREATE view [dbo].[View_PrintJointInfo]
|
||||||
|
as
|
||||||
|
select joint.JOT_ID,
|
||||||
|
joint.ProjectId,
|
||||||
|
joint.ISO_ID,
|
||||||
|
unit.UnitName,
|
||||||
|
installation.InstallationName,
|
||||||
|
iso.ISO_IsoNo,
|
||||||
|
joint.JOT_JointNo,
|
||||||
|
joint.JOT_JointDesc,
|
||||||
|
Steel.STE_Code,
|
||||||
|
joint.QRCodeAttachUrl
|
||||||
|
from HJGL_PW_JointInfo as joint
|
||||||
|
left join HJGL_PW_IsoInfo as iso on iso.ISO_ID = joint.ISO_ID
|
||||||
|
left join Project_Installation as installation on installation.InstallationId = joint.InstallationId
|
||||||
|
left join Base_Unit as unit on unit.UnitId = iso.BSU_ID
|
||||||
|
LEFT JOIN HJGL_BS_Steel AS Steel ON Steel.STE_ID = joint.STE_ID
|
||||||
|
GO
|
||||||
@@ -112,6 +112,9 @@
|
|||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="ThoughtWorks.QRCode, Version=1.0.4778.30637, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\ThoughtWorks.QRCode.1.1.0\lib\ThoughtWorks.QRCode.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="API\APIBaseServices.cs" />
|
<Compile Include="API\APIBaseServices.cs" />
|
||||||
@@ -135,6 +138,7 @@
|
|||||||
<Compile Include="Common\CacheHelper.cs" />
|
<Compile Include="Common\CacheHelper.cs" />
|
||||||
<Compile Include="Common\ChartControlService.cs" />
|
<Compile Include="Common\ChartControlService.cs" />
|
||||||
<Compile Include="Common\ConstValue.cs" />
|
<Compile Include="Common\ConstValue.cs" />
|
||||||
|
<Compile Include="Common\CreateQRCodeService.cs" />
|
||||||
<Compile Include="Common\FastReportService.cs" />
|
<Compile Include="Common\FastReportService.cs" />
|
||||||
<Compile Include="Common\FileManage\Common_FileManageService.cs" />
|
<Compile Include="Common\FileManage\Common_FileManageService.cs" />
|
||||||
<Compile Include="Common\JsonHelper.cs" />
|
<Compile Include="Common\JsonHelper.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using ThoughtWorks.QRCode.Codec;
|
||||||
|
using System.Web.UI;
|
||||||
|
|
||||||
|
namespace BLL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 上传附件相关
|
||||||
|
/// </summary>
|
||||||
|
public class CreateQRCodeService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 生成二维码方法一
|
||||||
|
/// </summary>
|
||||||
|
public static string CreateCode_Simple(string nr)
|
||||||
|
{
|
||||||
|
string imageUrl = string.Empty;
|
||||||
|
if (!string.IsNullOrEmpty(nr))
|
||||||
|
{
|
||||||
|
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder
|
||||||
|
{
|
||||||
|
QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE,
|
||||||
|
QRCodeScale = nr.Length,
|
||||||
|
QRCodeVersion = 0,
|
||||||
|
QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M
|
||||||
|
};
|
||||||
|
System.Drawing.Image image = qrCodeEncoder.Encode(nr, Encoding.UTF8);
|
||||||
|
string filepath = Funs.RootPath + UploadFileService.QRCodeImageFilePath;
|
||||||
|
//如果文件夹不存在,则创建
|
||||||
|
if (!Directory.Exists(filepath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(filepath);
|
||||||
|
}
|
||||||
|
string filename = DateTime.Now.ToString("yyyymmddhhmmssfff").ToString() + ".jpg";
|
||||||
|
FileStream fs = new FileStream(filepath + filename, FileMode.OpenOrCreate, FileAccess.Write);
|
||||||
|
image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||||
|
fs.Close();
|
||||||
|
image.Dispose();
|
||||||
|
imageUrl= UploadFileService.QRCodeImageFilePath + filename;
|
||||||
|
}
|
||||||
|
return imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static string CreateCode_Simple2(string nr)
|
||||||
|
//{
|
||||||
|
// string imageUrl = string.Empty;
|
||||||
|
// if (!string.IsNullOrEmpty(nr))
|
||||||
|
// {
|
||||||
|
// QRCodeEncoder qrCodeEncoder = new QRCodeEncoder
|
||||||
|
// {
|
||||||
|
// QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE,
|
||||||
|
// QRCodeScale = nr.Length,
|
||||||
|
// QRCodeVersion = 0,
|
||||||
|
// QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M
|
||||||
|
// };
|
||||||
|
// System.Drawing.Image image = qrCodeEncoder.Encode(nr, Encoding.UTF8);
|
||||||
|
// string filepath = Funs.RootPath + UploadFileService.WelderQRCodeImageFilePath;
|
||||||
|
// //如果文件夹不存在,则创建
|
||||||
|
// if (!Directory.Exists(filepath))
|
||||||
|
// {
|
||||||
|
// Directory.CreateDirectory(filepath);
|
||||||
|
// }
|
||||||
|
// string filename = DateTime.Now.ToString("yyyymmddhhmmssfff").ToString() + ".jpg";
|
||||||
|
// FileStream fs = new FileStream(filepath + filename, FileMode.OpenOrCreate, FileAccess.Write);
|
||||||
|
// image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||||
|
// fs.Close();
|
||||||
|
// image.Dispose();
|
||||||
|
// imageUrl = UploadFileService.WelderQRCodeImageFilePath + filename;
|
||||||
|
// }
|
||||||
|
// return imageUrl;
|
||||||
|
//}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool isHaveImage(string url)
|
||||||
|
{
|
||||||
|
string filepath = Funs.RootPath + url;
|
||||||
|
return File.Exists(filepath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,4 +5,5 @@
|
|||||||
<package id="Portable.BouncyCastle" version="1.8.9" targetFramework="net461" />
|
<package id="Portable.BouncyCastle" version="1.8.9" targetFramework="net461" />
|
||||||
<package id="SharpZipLib" version="1.3.2" targetFramework="net461" />
|
<package id="SharpZipLib" version="1.3.2" targetFramework="net461" />
|
||||||
<package id="System.Runtime.Caching" version="4.7.0" targetFramework="net461" />
|
<package id="System.Runtime.Caching" version="4.7.0" targetFramework="net461" />
|
||||||
|
<package id="ThoughtWorks.QRCode" version="1.1.0" targetFramework="net461" />
|
||||||
</packages>
|
</packages>
|
||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 3.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 879 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB |
BIN
Binary file not shown.
@@ -124,6 +124,12 @@
|
|||||||
<f:RadioItem Text="全部" Value="0" Selected="true" />
|
<f:RadioItem Text="全部" Value="0" Selected="true" />
|
||||||
<f:RadioItem Text="合格" Value="1" />
|
<f:RadioItem Text="合格" Value="1" />
|
||||||
</f:RadioButtonList>
|
</f:RadioButtonList>
|
||||||
|
<f:ToolbarFill ID="ToolbarFill3" runat="server"></f:ToolbarFill>
|
||||||
|
<f:Button ID="btnQR" ToolTip="批量生成二维码" Text="批量生成二维码" Icon="TableRefresh" runat="server" OnClick="btnQR_Click">
|
||||||
|
</f:Button>
|
||||||
|
<f:Button ID="btnPrintJoint" Text="打印二维码" Icon="Printer" runat="server"
|
||||||
|
OnClick="btnPrintJoint_Click">
|
||||||
|
</f:Button>
|
||||||
</Items>
|
</Items>
|
||||||
</f:Toolbar>
|
</f:Toolbar>
|
||||||
<f:Toolbar ID="Toolbar5" Position="Top" runat="server" ToolbarAlign="Left">
|
<f:Toolbar ID="Toolbar5" Position="Top" runat="server" ToolbarAlign="Left">
|
||||||
|
|||||||
@@ -1538,5 +1538,108 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
|||||||
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量生成二维码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
protected void btnQR_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Model.SGGLDB db = Funs.DB;
|
||||||
|
var p = db.HJGL_PW_IsoInfo.Where(x => x.ISO_ID == this.tvControlItem.SelectedNodeID).FirstOrDefault();
|
||||||
|
if (p != null)
|
||||||
|
{
|
||||||
|
var getJoints = from x in db.HJGL_PW_JointInfo
|
||||||
|
where x.ProjectId == this.ProjectId && x.ISO_ID == this.tvControlItem.SelectedNodeID
|
||||||
|
select x;
|
||||||
|
int num = 0;
|
||||||
|
if (getJoints.Any())
|
||||||
|
{
|
||||||
|
foreach (var item in getJoints)
|
||||||
|
{
|
||||||
|
string url = CreateQRCodeService.CreateCode_Simple(item.JOT_ID);
|
||||||
|
if (!string.IsNullOrEmpty(url))
|
||||||
|
{
|
||||||
|
item.QRCodeAttachUrl = url;
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
db.SubmitChanges();
|
||||||
|
}
|
||||||
|
ShowNotify("操作完成,新生成二维码" + num.ToString() + "条", MessageBoxIcon.Success);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Alert.ShowInTop("请选择一条管线!", MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 打印二维码
|
||||||
|
protected void btnPrintJoint_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
||||||
|
{
|
||||||
|
string initTemplatePath = "";
|
||||||
|
string rootPath = Server.MapPath("~/");
|
||||||
|
BLL.Common.FastReportService.ResetData();
|
||||||
|
|
||||||
|
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
||||||
|
//keyValuePairs.Add("ProjectName", projectName);
|
||||||
|
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
|
||||||
|
|
||||||
|
string strSql = "select * from View_PrintJointInfo where ProjectId=@projectId and ISO_ID =@isoId";
|
||||||
|
|
||||||
|
List<SqlParameter> listStr = new List<SqlParameter>
|
||||||
|
{
|
||||||
|
new SqlParameter("@projectId", this.CurrUser.LoginProjectId),
|
||||||
|
new SqlParameter("@isoId", this.tvControlItem.SelectedNodeID),
|
||||||
|
};
|
||||||
|
|
||||||
|
SqlParameter[] parameter = listStr.ToArray();
|
||||||
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||||
|
|
||||||
|
DataTable dt = new DataTable();
|
||||||
|
dt.TableName = "Table1";
|
||||||
|
dt.Columns.Add("UnitName");
|
||||||
|
dt.Columns.Add("WorkAreaCode");
|
||||||
|
dt.Columns.Add("ISO_IsoNo");
|
||||||
|
dt.Columns.Add("JOT_JointNo");
|
||||||
|
dt.Columns.Add("JOT_JointDesc");
|
||||||
|
dt.Columns.Add("STE_Code");
|
||||||
|
dt.Columns.Add("QRCodeAttachUrl");
|
||||||
|
|
||||||
|
DataView dv = tb.DefaultView;//获取表视图
|
||||||
|
dv.Sort = "JOT_JointNo ASC";//按照ID排序
|
||||||
|
tb = dv.ToTable();//转为表
|
||||||
|
DataRow[] rows = tb.DefaultView.ToTable().Select();
|
||||||
|
foreach (var row in rows)
|
||||||
|
{
|
||||||
|
var newRow = dt.NewRow();
|
||||||
|
newRow["ISO_IsoNo"] = row["ISO_IsoNo"].ToString();
|
||||||
|
newRow["UnitName"] = row["UnitName"].ToString();
|
||||||
|
newRow["WorkAreaCode"] = row["InstallationName"].ToString();
|
||||||
|
newRow["JOT_JointNo"] = row["JOT_JointNo"].ToString();
|
||||||
|
newRow["JOT_JointDesc"] = row["JOT_JointDesc"].ToString();
|
||||||
|
newRow["STE_Code"] = row["STE_Code"].ToString();
|
||||||
|
newRow["QRCodeAttachUrl"] = Funs.RootPath + row["QRCodeAttachUrl"].ToString();
|
||||||
|
dt.Rows.Add(newRow);
|
||||||
|
}
|
||||||
|
BLL.Common.FastReportService.AddFastreportTable(dt);
|
||||||
|
initTemplatePath = "File\\Fastreport\\焊口打印.frx";
|
||||||
|
|
||||||
|
if (File.Exists(rootPath + initTemplatePath))
|
||||||
|
{
|
||||||
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../common/ReportPrint/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Alert.ShowInTop("请选择要打印的管线!", MessageBoxIcon.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -365,6 +365,33 @@ namespace FineUIPro.Web.HJGL.WeldingManage
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected global::FineUIPro.RadioButtonList rbHotProessResult;
|
protected global::FineUIPro.RadioButtonList rbHotProessResult;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ToolbarFill3 控件。
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// 自动生成的字段。
|
||||||
|
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||||
|
/// </remarks>
|
||||||
|
protected global::FineUIPro.ToolbarFill ToolbarFill3;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// btnQR 控件。
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// 自动生成的字段。
|
||||||
|
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||||
|
/// </remarks>
|
||||||
|
protected global::FineUIPro.Button btnQR;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// btnPrintJoint 控件。
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// 自动生成的字段。
|
||||||
|
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||||
|
/// </remarks>
|
||||||
|
protected global::FineUIPro.Button btnPrintJoint;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Toolbar5 控件。
|
/// Toolbar5 控件。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -48941,6 +48941,8 @@ namespace Model
|
|||||||
|
|
||||||
private string _Y2;
|
private string _Y2;
|
||||||
|
|
||||||
|
private string _QRCodeAttachUrl;
|
||||||
|
|
||||||
private EntityRef<HJGL_BO_BatchDetail> _HJGL_BO_BatchDetail;
|
private EntityRef<HJGL_BO_BatchDetail> _HJGL_BO_BatchDetail;
|
||||||
|
|
||||||
private EntitySet<HJGL_BO_PreWeldReportMain> _HJGL_BO_PreWeldReportMain;
|
private EntitySet<HJGL_BO_PreWeldReportMain> _HJGL_BO_PreWeldReportMain;
|
||||||
@@ -49201,6 +49203,8 @@ namespace Model
|
|||||||
partial void OnX2Changed();
|
partial void OnX2Changed();
|
||||||
partial void OnY2Changing(string value);
|
partial void OnY2Changing(string value);
|
||||||
partial void OnY2Changed();
|
partial void OnY2Changed();
|
||||||
|
partial void OnQRCodeAttachUrlChanging(string value);
|
||||||
|
partial void OnQRCodeAttachUrlChanged();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public HJGL_PW_JointInfo()
|
public HJGL_PW_JointInfo()
|
||||||
@@ -51303,6 +51307,26 @@ namespace Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_QRCodeAttachUrl", DbType="NVarChar(200)")]
|
||||||
|
public string QRCodeAttachUrl
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._QRCodeAttachUrl;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if ((this._QRCodeAttachUrl != value))
|
||||||
|
{
|
||||||
|
this.OnQRCodeAttachUrlChanging(value);
|
||||||
|
this.SendPropertyChanging();
|
||||||
|
this._QRCodeAttachUrl = value;
|
||||||
|
this.SendPropertyChanged("QRCodeAttachUrl");
|
||||||
|
this.OnQRCodeAttachUrlChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_HJGL_BO_BatchDetail_HJGL_PW_JointInfo", Storage="_HJGL_BO_BatchDetail", ThisKey="JOT_ID", OtherKey="JOT_ID", IsUnique=true, IsForeignKey=false, DeleteRule="NO ACTION")]
|
[global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_HJGL_BO_BatchDetail_HJGL_PW_JointInfo", Storage="_HJGL_BO_BatchDetail", ThisKey="JOT_ID", OtherKey="JOT_ID", IsUnique=true, IsForeignKey=false, DeleteRule="NO ACTION")]
|
||||||
public HJGL_BO_BatchDetail HJGL_BO_BatchDetail
|
public HJGL_BO_BatchDetail HJGL_BO_BatchDetail
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user