ab56a9bcf7
SVN-Revision: r240
453 lines
21 KiB
C#
453 lines
21 KiB
C#
/******************************
|
|
* 说明:附件相关接口实现
|
|
* 创建人:龚宇超
|
|
* 创建日期:2018-01-08
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本:1.0.0.0
|
|
******************************/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Lskj.Core;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using Lskj.Model;
|
|
using System.Web;
|
|
|
|
namespace Lskj.Business.Impl
|
|
{
|
|
/// <summary>
|
|
/// 附件相关接口实现
|
|
/// </summary>
|
|
public class AttachImpl : BaseImpl
|
|
{
|
|
/// <summary>
|
|
/// <para>说明:获取审核明细</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-01-18 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
/// <returns>DataRow.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static DataTable GetAttachDetilTab(string typeCode, string StepCode)
|
|
{
|
|
string sqlValue = string.Format("select * from p_SystemDlltabDetailFlowTab where isnull(isvisible,0)!=1 and typecode='{0}' and stepcode='{1}'", typeCode, StepCode);
|
|
DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue);
|
|
return dtTable;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取附件目录ID</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="parentId">The parent identifier.</param>
|
|
/// <param name="objectId">主键值.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static int GetAttachDirectoryId(string parentId, string objectId)
|
|
{
|
|
try
|
|
{
|
|
string sqlValue = "select dirid from P_fm_DirectoryTab where ParentId=@ParentId and PID=@PID";
|
|
string dirId = GetResult(sqlValue, new SqlParameter[] {
|
|
new SqlParameter("@ParentId", parentId),
|
|
new SqlParameter("@PID",objectId)
|
|
}) + "";
|
|
|
|
if (string.IsNullOrEmpty(dirId) || "0".Equals(dirId))
|
|
{
|
|
// 插入新目录
|
|
sqlValue = string.Format("insert into P_fm_DirectoryTab (sName,ParentId,creator,SpeciesNo,relationCode,PID) values('{0}','{1}',1,'0201',0,'{0}');select @@identity", objectId, parentId);
|
|
dirId = GetResult(sqlValue) + "";
|
|
}
|
|
return Convert.ToInt32(dirId);
|
|
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
return 0;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:锁定附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="fileIds">The file ids.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static int LockFiles(string fileIds)
|
|
{
|
|
if (string.IsNullOrEmpty(fileIds)) return 0;
|
|
|
|
string sqlValue = string.Format("update P_fm_FileTab set A1=1 where fileId in ({0})", fileIds.TrimEnd(','));
|
|
return SqlHelper.ExecuteNonQuery(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:解锁附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="fileIds">The file ids.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static int UnLockFiles(string fileIds)
|
|
{
|
|
if (string.IsNullOrEmpty(fileIds)) return 0;
|
|
|
|
string sqlValue = string.Format("update P_fm_FileTab set A1=0 where fileId in ({0})", fileIds.TrimEnd(','));
|
|
return SqlHelper.ExecuteNonQuery(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-17 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="operType">1=上传,2=下载,3=删除,4=锁定,5=解除锁定 必填</param>
|
|
/// <param name="speciesNo">The species no.</param>
|
|
/// <param name="fileId">The file id.</param>
|
|
/// <param name="fileName">Name of the file.</param>
|
|
/// <param name="fileSize">Size of the field.</param>
|
|
/// <param name="tipMsg">返回提示信息</param>
|
|
/// <returns>System.Int32.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static int CheckAttachOperation(int operType, string speciesNo, int fileId, string fileName, int fileSize, out string tipMsg)
|
|
{
|
|
try
|
|
{
|
|
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
|
pMsg.Direction = ParameterDirection.Output;
|
|
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
|
|
returnValue.Direction = ParameterDirection.ReturnValue;
|
|
SqlParameter[] param =
|
|
{
|
|
new SqlParameter("@opertype",SqlDbType.Int),
|
|
new SqlParameter("@operatorid",SqlDbType.Int),
|
|
new SqlParameter("@operatorname",SqlDbType.VarChar,50),
|
|
new SqlParameter("@fileSpecisNo",SqlDbType.VarChar,50),
|
|
new SqlParameter("@fileid",SqlDbType.Int),
|
|
new SqlParameter("@filename",SqlDbType.VarChar,200),
|
|
new SqlParameter("@filesize",SqlDbType.Int),
|
|
pMsg,
|
|
returnValue
|
|
};
|
|
|
|
param[0].Value = operType;
|
|
param[1].Value = ERPInfo.Instance.UserId;
|
|
param[2].Value = ERPInfo.Instance.UserName;
|
|
param[3].Value = speciesNo;
|
|
param[4].Value = fileId;
|
|
param[5].Value = fileName;
|
|
param[6].Value = fileSize;
|
|
DataSet ds = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_SystemAttachOperation", "attach", param);
|
|
|
|
tipMsg = pMsg.Value + "";
|
|
return Convert.ToInt32(returnValue.Value + "");
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
|
|
tipMsg = string.Empty;
|
|
return 1;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:删除签名</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-06-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="signId">The sign identifier.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
public static int DeleteSignPoint(int signId)
|
|
{
|
|
string sqlValue = string.Format("delete from P_PDFSignTab where id='{0}'", signId);
|
|
return SqlHelper.ExecuteNonQuery(sqlValue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:添加上传附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-06-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.Int32.</returns>
|
|
public static int InsertUpLoadFile(string fileName, string DirId, long fileSize, string speciesno)
|
|
{
|
|
string sqlValue = string.Format("INSERT INTO P_fm_FileTab(sName,ParentID,fileSize,creator,speciesno,CreateTime) " +
|
|
"VALUES('{0}',{1},'{2}',{3},'{4}','{5}')", fileName, DirId, fileSize, ERPInfo.Instance.UserId, speciesno, DateTime.Now);
|
|
return SqlHelper.ExecuteNonQuery(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:插入签名点</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-06-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">模块属性</param>
|
|
/// <param name="byPic">签名图片字节</param>
|
|
/// <param name="imageX">X坐标.</param>
|
|
/// <param name="imageY">Y坐标</param>
|
|
/// <param name="pageNo">文档页码</param>
|
|
/// <returns>System.Int32.</returns>
|
|
public static int InsertSignPoint(DynamicPdfViewerModel model, Byte[] byPic, float imageX, float imageY, int pageNo)
|
|
{
|
|
//存流会出现保存进去的流变化分两次处理,先添加,流通过更新进去正常
|
|
string sqlValue = string.Format(@"insert into P_PDFSignTab (FileId,BillId,BillDetailId,StepCode,OperatorId,OperateDate,Image,ImageX,ImageY,Page)
|
|
VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','','{6}','{7}','{8}');Select @@IDENTITY;", model.PdfFileId, model.BillDocumentId, model.BillDeatilId, model.stepCode, ERPInfo.Instance.UserId, DateTime.Now, imageX, imageY, pageNo);
|
|
int resultId = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sqlValue));
|
|
|
|
if (resultId > 0)
|
|
{
|
|
string sqlValue2 = string.Format("update P_PDFSignTab set Image=@Pic where id='{0}'", resultId);
|
|
SqlParameter parameter = new SqlParameter("@Pic", SqlDbType.Image);
|
|
parameter.Value = byPic;
|
|
int result = SqlHelper.ExecuteNonQuery(CommandType.Text, sqlValue2, parameter);
|
|
if (result <= 0) return 0;
|
|
}
|
|
return resultId;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取(解除)锁定成功的数据条数</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="dtFiles">The dt files.</param>
|
|
/// <param name="LockFlag">锁定标记</param>
|
|
/// <returns>DataTable.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static int GetLockDataCount(DataTable dtFiles, string lockFlag)
|
|
{
|
|
int Count = 0;
|
|
for (int i = 0; i < dtFiles.Rows.Count; i++)
|
|
{
|
|
string sqlValue = "update P_fm_FileTab set A1=@LockFlag where fileId=@fileId";
|
|
Count += ExecSqlValue(sqlValue, new SqlParameter[] { new SqlParameter("@fileId", dtFiles.Rows[i]["fileId"]), new SqlParameter("LockFlag", lockFlag) });
|
|
}
|
|
return Count;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:更新附件关联</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tableName">Name of the table.</param>
|
|
/// <param name="fieldName">Name of the field.</param>
|
|
/// <param name="fieldValue">The field value.</param>
|
|
/// <param name="condKey">The cond key.</param>
|
|
/// <param name="condValue">The cond value.</param>
|
|
/// <returns>System.Int32.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static int UpdateUnionAttach(string tableName, string fieldName, string fieldValue, string condKey, string condValue)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(tableName) ||
|
|
string.IsNullOrWhiteSpace(fieldName) ||
|
|
string.IsNullOrWhiteSpace(condKey))
|
|
return 0;
|
|
string sqlValue = string.Format("update {0} set {1}='{2}' where {3}='{4}'", tableName, fieldName, fieldValue, condKey, condValue); ;
|
|
|
|
return SqlHelper.ExecuteNonQuery(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取附件信息目录Id菜单编号</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public static string GetFilesTab(int dirId, string fileId, string txtKey)
|
|
{
|
|
string strWhere = string.Format(" where parentId='{0}'", dirId);
|
|
string sqlValue = "select * from P_fm_filetab";
|
|
if (!string.IsNullOrEmpty(txtKey)) strWhere += string.Format(" and {0} like '%{1}%'", fileId, txtKey);
|
|
sqlValue += strWhere;
|
|
return sqlValue;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取系统信息</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public static DataRow GetSystemModule(string menuCode)
|
|
{
|
|
string sqlValue = "select * from v_systemdlltab where DllCoid=@DllCoid";
|
|
DataTable dt = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@DllCoid", menuCode) });
|
|
return dt.Rows.Count > 0 ? dt.Rows[0] : null;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:根据附件编号获取附件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-06-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataRow GetTempletFile(int fileNo)
|
|
{
|
|
string sqlValue = "select * from P_fm_FileTab where fileId=@fileNo";
|
|
DataTable dt = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@fileNo", fileNo) });
|
|
return dt.Rows.Count > 0 ? dt.Rows[0] : null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:根据附件名字获取附件</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2019-12-13 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataRow GetTempletFile(string sName, string webpath = "")
|
|
{
|
|
string sqlValue = "select * from P_fm_FileTab where sName=@sName";
|
|
DataTable dt = SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@sName", sName) });
|
|
if (dt.Rows.Count > 1)
|
|
{
|
|
//if (!webpath.StartsWith("%")) webpath = "%" + webpath;
|
|
sqlValue = string.Format("select * from P_fm_FileTab where sName='{0}' and (webpath like '%{1}' or webpath like '%{2}')", sName, webpath, HttpUtility.UrlDecode(webpath).Replace("#", "%23").Replace("%2f", "/"));
|
|
dt = SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
return dt.Rows.Count > 0 ? dt.Rows[0] : null;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取附件左侧树结构数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="speciesNo">The species no.</param>
|
|
/// <returns>DataTable.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static DataTable GetAttachSpecies(string speciesNo)
|
|
{
|
|
string sqlValue = string.Format("select * from bmp_ProductSpeciesTab where SpeciesNo like '{0}%'", speciesNo);
|
|
return GetDataTableResult(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取符合锁定解锁条件的文件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="fileNo">附件Id.</param>
|
|
/// <returns>DataTable.</returns>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
public static DataTable GetMatchConditionFiles(string fileNo)
|
|
{
|
|
string sqlValue = @"select a.fileId from P_fm_FileTab a
|
|
inner join bmp_ProductSpeciesTab b on a.speciesno=b.SpeciesNo
|
|
where charindex(','+cast(fileid as varchar)+',','," + fileNo + ",')>0 and (charindex('," + ERPInfo.Instance.UserName + ",',','+b.str4+',')>0 or charindex('|" + ERPInfo.Instance.UserName + "|','|'+b.str4+'|')>0 or a.creator='" + ERPInfo.Instance.UserId + "')";
|
|
object obj = SqlHelper.ExecuteScalar(CommandType.Text, "select 1 as zt from sys.columns where object_id=object_id('bmp_ProductSpeciesTab') and name='str4'");
|
|
if ((obj == null) || (obj.ToString() != "1"))
|
|
sqlValue = @"select a.fileId from P_fm_FileTab a
|
|
inner join bmp_ProductSpeciesTab b on a.speciesno=b.SpeciesNo
|
|
where charindex(','+cast(fileid as varchar)+',','," + fileNo + ",')>0 and ( a.creator='" + ERPInfo.Instance.UserId + "')";
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取附件的签名集</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-06-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetSignSources(int fileNo)
|
|
{
|
|
string sqlValue = "select * from P_PDFSignTab where FileId=@FileNo";
|
|
return SqlHelper.ExecuteDataTable(sqlValue, new SqlParameter[] { new SqlParameter("@FileNo", fileNo) });
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取拍照文件列</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-06-11 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataTable.</returns>
|
|
public static DataTable GetCameraFileData()
|
|
{
|
|
string sqlValue = @" select '1' id , 'stepCode' fieldName, 65 width, '' sysname , '编号' username, '' dataFormat union
|
|
select '2' , 'Name' ,148 , '' , '文件名' , '' union
|
|
select '3' , 'Created' ,120 , '' , '时间' , '' union
|
|
select '4' , 'key' ,67 , '' , '隐藏字段' , '' ";
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取附件条数</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-08-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>System.Int32.</returns>
|
|
public static int GetFileCount(string dirid, string pid)
|
|
{
|
|
DataTable dt = SqlHelper.ExecuteDataTable(string.Format("select 1 from P_fm_FileTab where parentId='{0}'", GetAttachDirectoryId(dirid, pid)));
|
|
return dt == null ? 0 : Convert.ToInt32(dt.Rows.Count);
|
|
}
|
|
}
|
|
}
|