You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1052 lines
51 KiB

using FactorySystemCommon;
using FactorySystemModel.EnumModel;
using FactorySystemModel.RequestModel;
using FactorySystemModel.ResponseModel;
using FactorySystemModel.SqlSugarModel;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Security.Cryptography;
using static FactorySystemModel.EnumModel.Constant;
namespace FactorySystemBll
{
public class MaterialTeamworkBll
{
/// <summary>
/// 获取路线列表
/// </summary>
public List<MaterialTeamworkRow> GetList(MaterialTeamworkQuery mtq, out int totalNumber)
{
totalNumber = 0;
var db = AppSettingsHelper.GetSqlSugar();
return db.Queryable<TFS_FMaterialTeamwork, TUser, TFS_Factory>((a, b, c) => new JoinQueryInfos(JoinType.Left, a.FAddUser == b.FID, JoinType.Left, a.FCreateFactoryID == c.FID))
// 事项状态
.WhereIF(mtq.FState > 0 && mtq.FState != 99, a => a.FState == mtq.FState)
// 物料号
.WhereIF(!string.IsNullOrEmpty(mtq.FMaterialCode), a => a.FMaterialCode.Equals(mtq.FMaterialCode))
// 类型
.WhereIF(mtq.FTeamworkType > 0, a => a.FTeamworkType == mtq.FTeamworkType)
// 发起时间
.WhereIF(mtq.FDateRange != null && mtq.FDateRange[0] != "",a => a.FAddDate >= DateTime.Parse(mtq.FDateRange[0]))
.WhereIF(mtq.FDateRange != null && mtq.FDateRange[1] != "", a => a.FAddDate <= DateTime.Parse(mtq.FDateRange[1]))
// 责任人
//.WhereIF(mtq.FUserID != null, (a, b) => (',' + a.FUserID + ',').Contains(',' + mtq.FUserID + ',') || a.FAddUser.Equals(mtq.FUserID))
//// 协同
//.WhereIF(mtq.FMaterialTeamID > 0, (a, b) => a.FMaterialTeamID == mtq.FMaterialTeamID).OrderBy((a, b) => a.FID, OrderByType.Desc)
.Select<MaterialTeamworkRow>("a.* ,c.FName as FCreateFactoryName, b.FName as FAddUserName").OrderBy((a) => a.FID, OrderByType.Desc)
.ToPageList(mtq.FPageIndex, mtq.FPageSize, ref totalNumber);
}
/// <summary>
/// 获取视图编辑列
/// </summary>
public List<Dictionary<string, object>> GetColumns()
{
List<TFS_ViewFieldInfo> fieldList = AppSettingsHelper.GetSqlSugar().Queryable<TFS_ViewFieldInfo>()
.Where(it => it.FType == (int)Constant.ViewType. || it.FType == (int)Constant.ViewType.)
.OrderBy(it => it.FType, OrderByType.Desc)
.OrderBy(it => it.FOrder)
.ToList();
List<Dictionary<string, object>> dicList = new List<Dictionary<string, object>>();
foreach (var field in fieldList)
{
Dictionary<string, object> dic = new Dictionary<string, object> { { "id", field.FID } };
string[] fArr = field.FField.Split('.');
dic.Add("key", fArr.Last());
dic.Add("table", fArr.First());
string[] nArr = field.FName.Split('.');
dic.Add("title", nArr.Last());
dic.Add("category", nArr.First());
dic.Add("width", field.FWidth);
dic.Add("align", field.FAlign);
dic.Add("dataType", field.FDataType);
if (field.FName.Equals("基本视图.大小/量纲(规格)") || field.FName.Equals("基本视图.毛重") || field.FName.Equals("基本视图.净重"))
{
dic.Add("fieldType", 7);
}
else
{
dic.Add("fieldType", field.FType);
}
dicList.Add(dic);
}
return dicList;
}
public string GetViewColumns()
{
string cols = "";
string sql = "SELECT COLUMN_NAME FROM information_schema.columns where table_name = 'TFS_ViewMaterial'";
var db = AppSettingsHelper.GetSqlSugar();
DataTable table = db.Ado.GetDataTable(sql);
foreach (DataRow row in table.Rows)
{
cols = cols + row[0].ToString() + ",";
}
return cols;
}
/// <summary>
/// 获取视图
/// </summary>
public List<Dictionary<string, object>> GetMaterialViewsByTeamId(int teamId, int teamworkType, int teamType, int currUserId, bool byFactory, out List<int> materialId)
{
TUser currUser = null;
if (byFactory == true) currUser = BaseBll.GetTempModel<TUser>(currUserId, "FFactoryID");
var db = AppSettingsHelper.GetSqlSugar();
List<Dictionary<string, object>> viewList = new List<Dictionary<string, object>>();
if (teamworkType == 2)
{
viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) =>
new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID))
.Where((a, b) => a.FMdfMaterialTeamID == teamId)
.Where((a, b) => a.FTeamType == teamType)
//.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID)
.Select<object>("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," +
"b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield," +
"b.FQualityTest1,b.FQualityTest2").ToDictionaryList();
}
else
{
viewList = db.Queryable<TFS_ViewMaterial, TFS_Material>((a, b) =>
new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID))
.Where((a, b) => a.FTeamID == teamId)
.Where((a, b) => a.FTeamType == teamType)
//.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID)
.Select<object>("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," +
"b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield," +
"b.FQualityTest1,b.FQualityTest2").ToDictionaryList();
}
materialId = viewList.GroupBy(s => s["FMaterialID"]).Select(s => int.Parse(s.Key.ToString())).ToList();
return viewList;
}
/// <summary>
/// 根据模式和物料获取视图
/// </summary>
public TFS_ViewMaterial GetMaterialViewsByFactoryAndMaterial(int factoryId, int materialId)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
TFS_ViewMaterial view = db.Queryable<TFS_ViewMaterial>().Where(s => s.FMaterialID == materialId && s.FFactoryID == factoryId).First();
return view;
}
/// <summary>
/// 根据物料获取基本信息
/// </summary>
public List<TFS_MaterialInfo> GetMaterialInfoList(List<int> materialIds, int userId)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
List<TFS_MaterialInfo> infoList = db.Queryable<TFS_MaterialInfo>().Where(s => materialIds.Contains(s.FDataID) && s.FType == 2).ToList();
if (infoList.Count != materialIds.Count)
{
materialIds = materialIds.Where(s => infoList.Find(f => f.FDataID == s) == null).ToList();
foreach (int materialId in materialIds)
{
TFS_Material temp = db.Queryable<TFS_Material>().Where(s => s.FID == materialId).First();
TFS_MaterialInfo info = new TFS_MaterialInfo()
{
FType = 2,
FDataID = materialId,
FAddUser = userId,
FMaterialGroup = temp.FMaterialGroup,
FMaterialType = temp.FMaterialType
};
db.Insertable(info).IgnoreColumns(true).ExecuteCommand();
infoList.Add(info);
}
}
return infoList;
}
/// <summary>
/// 根据物料分类集合信息
/// </summary>
public object GetMaterialTypeList()
{
return AppSettingsHelper.GetSqlSugar().Queryable<TFS_MaterialType>().Where(s => s.FDeleted != 1 && s.FState == 1)
.OrderBy("FDepth,FID").Select<dynamic>("FID,FName,FID FValue,FDepth,FParentID").ToList();
}
public int InsertMaterialView(TFS_ViewMaterial view)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
return db.Insertable(view).IgnoreColumns(true).ExecuteReturnIdentity();
}
public int InsertMaterial(TFS_Material material)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
return db.Insertable(material).IgnoreColumns(true).ExecuteReturnIdentity();
}
public int UpdateMaterial(TFS_Material material)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
return db.Updateable(material).IgnoreColumns(true).Where("FID").ExecuteCommand();
}
public int UpdateMaterialViewById(List<Dictionary<string, object>> viewList, int userId, int teamId, int teamworkType)
{
int result = 0;
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
3 years ago
MaterialTypeBll materialTypeBll = new MaterialTypeBll();
if (viewList != null && viewList.Count > 0)
{
for(int i = 0; i < viewList.Count; i++)
{
viewList[i]["FEditUser"] = userId;
viewList[i]["FEditDate"] = DateTime.Now;
}
string sqlWhere = "";
if (teamworkType == 2)
{
sqlWhere = string.Format("FMdfMaterialTeamId={0} and FTeamType={1}", teamId, 1);
}
else
{
sqlWhere = string.Format("FTeamID={0} and FTeamType={1}", teamId, 1);
}
3 years ago
for (int i = 0; i < viewList.Count; i++)
{
2 years ago
if (!viewList[i].ContainsKey("FK3Code") && viewList[i].ContainsKey("FSAPCode"))
{
viewList[i].Add("FK3Code", viewList[i]["FSAPCode"]);
}
else if(viewList[i].ContainsKey("FK3Code") && !viewList[i].ContainsKey("FSAPCode"))
{
viewList[i].Add("FSAPCode", viewList[i]["FK3Code"]);
}
if (!viewList[i].ContainsKey("FK3Name") && viewList[i].ContainsKey("FSAPDescription"))
{
viewList[i].Add("FK3Name", viewList[i]["FSAPDescription"]);
}
else if (viewList[i].ContainsKey("FK3Name") && !viewList[i].ContainsKey("FSAPDescription"))
{
viewList[i].Add("FSAPDescription", viewList[i]["FK3Name"]);
}
// 设置成成品视图
if (viewList[i]["FMRP1ProductType"].ToString() == "10")
{
if (viewList[i].ContainsKey("FViewType"))
{
viewList[i]["FViewType"] = (int)Constant.ViewType.;
}
else
{
viewList[i].Add("FViewType", (int)Constant.ViewType.);
}
}
// 设置成半成品视图
if (viewList[i]["FMRP1ProductType"].ToString() == "20")
{
if (viewList[i].ContainsKey("FViewType"))
{
viewList[i]["FViewType"] = (int)Constant.ViewType.;
}
else
{
viewList[i].Add("FViewType", (int)Constant.ViewType.);
}
}
//设置成中间品视图或香基视图,判断是否等于中间品
if (viewList[i]["FMRP1ProductType"].ToString() == "30")
3 years ago
{
3 years ago
TFS_MaterialType materialType = materialTypeBll.GetMaterialTypeByID(int.Parse(viewList[i]["FTypeID2"].ToString())).LastOrDefault();
3 years ago
if (materialType.FName.Contains("香基"))
3 years ago
{
if (viewList[i].ContainsKey("FViewType"))
{
viewList[i]["FViewType"] = (int)Constant.ViewType.;
}
else
{
viewList[i].Add("FViewType", (int)Constant.ViewType.);
}
}
else
{
if (viewList[i].ContainsKey("FViewType"))
{
viewList[i]["FViewType"] = (int)Constant.ViewType.;
}
else
{
viewList[i].Add("FViewType", (int)Constant.ViewType.);
}
}
}
// 设置成原料视图
if (viewList[i]["FMRP1ProductType"].ToString() == "40")
{
if (viewList[i].ContainsKey("FViewType"))
{
viewList[i]["FViewType"] = (int)Constant.ViewType.;
}
else
{
viewList[i].Add("FViewType", (int)Constant.ViewType.);
}
}
viewList[i].Remove("FTypeID2");
// 更新视图
//db.Updateable(viewList[i]).AS("TFS_ViewMaterial").WhereColumns("FMaterialID").Where(sqlWhere).ExecuteCommand();
db.Updateable(viewList[i]).AS("TFS_ViewMaterial").IgnoreColumns("FID").WhereColumns("FID").ExecuteCommand();
int.TryParse(viewList[i]["FMRP1ProductType"].ToString(), out result);
3 years ago
}
UnionModifyData(viewList, "TFS_ViewMaterial", teamId, teamworkType, db, "FMaterialID");
}
return result;
}
public string UpdateMaterialById(List<Dictionary<string, object>> materialList, int userId, int teamId, int teamworkType)
{
string result = "";
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
if (materialList != null && materialList.Count > 0)
{
for (int i = 0; i < materialList.Count; i++)
{
materialList[i]["FID"] = materialList[i]["FMaterialID"];
materialList[i]["FEditUser"] = userId;
materialList[i]["FEditDate"] = DateTime.Now;
materialList[i].Remove("FMaterialID");
if (materialList[i].TryGetValue("FK3Code", out object k3Code))
{
if (materialList[i].ContainsKey("FK3ShortCode"))
{
materialList[i]["FK3ShortCode"] = k3Code.ToString().Split('.').Last();
}
else
{
materialList[i].Add("FK3ShortCode", k3Code.ToString().Split('.').Last());
}
}
db.Updateable(materialList[i]).AS("TFS_Material").WhereColumns("FID").ExecuteCommand();
if (materialList[i].ContainsKey("FCode"))
{
result = materialList[i]["FCode"].ToString();
}
}
UnionModifyData(materialList, "TFS_Material", teamId, teamworkType, db);
}
return result;
}
public int UpdateMaterialInfoById(List<Dictionary<string, object>> infoList, int userId, int teamId, int teamworkType)
{
int result = 0;
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
if (infoList != null && infoList.Count > 0)
{
for (int i = 0; i < infoList.Count; i++)
{
infoList[i]["FDataID"] = infoList[i]["FMaterialID"];
infoList[i]["FEditUser"] = userId;
infoList[i]["FEditDate"] = DateTime.Now;
infoList[i].Remove("FMaterialID");
infoList[i].Add("FType", 2);
result += db.Updateable(infoList[i]).IgnoreColumns(true).AS("TFS_MaterialInfo").WhereColumns("FDataID", "FType").ExecuteCommand();
}
result += UnionModifyData(infoList, "TFS_MaterialInfo", teamId, teamworkType, db, "FDataID");
}
return result;
}
public int UpdateMaterialView(TFS_ViewMaterial view)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
return db.Updateable(view).IgnoreColumns(true).WhereColumns("FID").ExecuteCommand();
}
private int UnionModifyData(List<Dictionary<string, object>> dataList, string srcTable, int teamId, int teamworkType, SqlSugarClient db = null, string colName = "FID")
{
int result = 0;
if (dataList != null && dataList.Count > 0)
{
if (db == null) db = AppSettingsHelper.GetSqlSugar();
List<TFS_UnionModify> unionList = db.Queryable<TFS_UnionModify>().Where(s => s.FDeleted != 1 && s.FTableOriginal == srcTable).ToList();
if (unionList.Count > 0)
{
List<string> sqlList = new List<string>() { "update {0} set {0}.{1}={2}.{3} from {0} left join {2} on {4} where {2}.{5}='{6}' {7}" };
foreach (Dictionary<string, object> data in dataList)
{
foreach (TFS_UnionModify union in unionList)
{
if (data.TryGetValue(union.FColumnOriginal, out object srcVal))
{
string sqlWhere = "";
if (union.FTableTarget == "TFS_ViewMaterial" || union.FTableOriginal == "TFS_ViewMaterial")
{
if (teamworkType == 2)
{
sqlWhere = " and TFS_ViewMaterial.FMdfMaterialTeamID=" + teamId;
}
else
{
sqlWhere = " and TFS_ViewMaterial.FTeamID=" + teamId;
}
}
sqlList.Add(string.Format(sqlList[0], union.FTableTarget, union.FColumnTarget,
union.FTableOriginal, union.FColumnOriginal, union.FUnionCondition, colName,
data[colName], sqlWhere));
}
}
}
sqlList.RemoveAt(0);
if (sqlList.Count > 0)
{
string updateSql = string.Join(";", sqlList);
try {
result = db.Ado.ExecuteCommand(updateSql);
}
catch (Exception ex) {
}
}
}
}
return result;
}
public int CloseMaterialTeamwork(int teamId, int userId)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
List<TFS_FMaterialTeamwork> teamworkList = db.Queryable<TFS_FMaterialTeamwork>().Where(s => s.FID == teamId && s.FState == 1).ToList();
int result = 0;
if (teamworkList != null && teamworkList.Count > 0)
{
TFS_FMaterialTeamwork fmt = teamworkList[0];
fmt.FState = 2;
fmt.FEditUser = userId;
fmt.FEditDate = DateTime.Now;
result = db.Updateable(fmt).IgnoreColumns(true).WhereColumns("FID").ExecuteCommand();
}
return result;
}
public TFS_FMaterialTeamwork GetMaterialTeamworkById(int teamId)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
TFS_FMaterialTeamwork teamwork = null;
List<TFS_FMaterialTeamwork> teamworkList = db.Queryable<TFS_FMaterialTeamwork>().Where(s => s.FID == teamId && s.FState == 1).ToList();
if (teamworkList != null && teamworkList.Count > 0)
{
teamwork = teamworkList[0];
}
return teamwork;
}
public int UpdateMaterialTeamwork(TFS_FMaterialTeamwork teamwork)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
int result = 0;
result = db.Updateable(teamwork).IgnoreColumns(true).WhereColumns("FID").ExecuteCommand();
return result;
}
public List<TFS_Material> SearchMaterialsByFactory(string materialName, int pageNumber, int pageSize, out int totalNumber)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
totalNumber = 0;
List<TFS_Material> materialList = db.Queryable<TFS_Material>()
.WhereIF(!string.IsNullOrEmpty(materialName.Trim()), a => a.FName.Contains(materialName) || a.FCode.Contains(materialName))
.OrderBy((a) => a.FID, OrderByType.Desc)
.ToPageList(pageNumber, pageSize, ref totalNumber);
return materialList;
}
public List<TFS_ViewMaterial> GetViewMaterialByTeamId(int teamworkId, int teamworkType)
{
List<TFS_ViewMaterial> viewList = null;
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
if (teamworkType == 1)
{
viewList = db.Queryable<TFS_ViewMaterial>().Where(s => s.FTeamID == teamworkId && s.FTeamType == 1).ToList();
}
2 years ago
else if (teamworkType == 3)
{
viewList = db.Queryable<TFS_ViewMaterial>().Where(s => s.FHalfMaterialTeamID == teamworkId).ToList();
}
else
{
viewList = db.Queryable<TFS_ViewMaterial>().Where(s => s.FMdfMaterialTeamID == teamworkId && s.FTeamType == 1).ToList();
}
return viewList;
}
public List<object> GetViewPower(int userId)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
List<object> powers = db.Queryable<TRole_Right, FPower>((a, b) => new JoinQueryInfos(
JoinType.Full, b.FRole.Equals(a.FRoleID.ToString())
))
.Where((a, b) => b.FUserID.Equals(userId.ToString()))
.Where((a, b) => a.FType == 3)
.Select<object>("a.FRoleID, a.FType, a.FFunctionID, b.FFactoryID").Distinct()
.ToList();
return powers;
}
public DataTable GetViewMaterialSAP(string teamworkId, string teamworkType)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
string strSql = @"
SELECT
2 years ago
isnull(replace(FOrganizeIndustryField,'()',''), '') AS '
Industry Sector',
2 years ago
isnull(replace(FOrganizeMaterialType,'()',''), '') AS '
(Material Type)',
2 years ago
isnull(replace(FOrganizeFactory,'()',''), '') AS '
(Plant)',
2 years ago
isnull(replace(FOrganizeInventoryLocation,'()',''), '') AS '
(Stock Location)',
2 years ago
isnull(replace(FOrganizeSalesOrganize,'()',''), '') AS '
(Sales Organization)',
2 years ago
isnull(replace(FOrganizeDistributionChannel,'()',''), '') AS '
(distribution Channel',
2 years ago
isnull(replace(FBaseMaterialCode,'()',''), '') AS '
(Material NO.)',
2 years ago
isnull(replace(FBaseTestCode,'()',''), '') AS '
(Test NO.)',
2 years ago
isnull(replace(FBaseBasicMeter,'()',''), '') AS '
(Base Unit of Measure)',
2 years ago
isnull(replace(FBaseMaterialDesc,'()',''), '') AS '
Material Description',
2 years ago
isnull(replace(FBaseMaterialGroup,'()',''), '') AS '
(Material Group)',
2 years ago
isnull(replace(FBaseSpecification,'()',''), '') AS '/
(Specifications)',
2 years ago
isnull(replace(FBaseMaterialText,'()',''), '') AS '
(Basic Data Text)',
2 years ago
isnull(replace(FBaseIdentifier,'()',''), '') AS '\://
(In bulk/liquid)',
2 years ago
isnull(replace(FBaseVolumeUnit,'()',''), '') AS '
(Volume Unit)',
2 years ago
isnull(replace(FBaseGrossWeight,'()',''), '') AS '
(Gross weight)',
2 years ago
isnull(replace(FBaseNetWeight,'()',''), '') AS '
(Net weight)',
2 years ago
isnull(replace(FBaseWeightUnit,'()',''), '') AS '
(Weight unit)',
2 years ago
isnull(replace(FBaseFameCode,'()',''), '') AS 'fame',
isnull(replace(FBaseBusinessVolume,'()',''), '') AS '
(Volume)',
2 years ago
isnull(replace(FPurchaseGroup,'()',''), '') AS '
(Purchasing Group)',
2 years ago
isnull(replace(FPurchaseCompany,'()',''), '') AS '
(Order Unit)',
2 years ago
isnull(replace(FPurchaseCompanyCount,'()',''), '') AS '
(Quantity Conversion of procument)',
2 years ago
isnull(replace(FPurchaseBaseCompanyCount,'()',''), '') AS '
(Quantity Conversion of basic unit of measure)',
2 years ago
isnull(replace(FPurchaseValueCode,'()',''), '') AS '
(Purchasing value key)',
2 years ago
isnull(replace(FPurchaseFactorySpecificStatus,'()',''), '') AS '
(Plant-Specific Material Status)',
2 years ago
isnull(replace(FPurchaseAutoOrder,'()',''), '') AS '
automatic purchase order allowed',
2 years ago
isnull(replace(FPurchaseGoodsSource,'()',''), '') AS '
Source list requirement',
2 years ago
isnull(replace(FTypeCategoryType,'()',''), '') AS '
Class Type',
2 years ago
isnull(replace(FTypeType,'()',''), '') AS '
Class',
2 years ago
isnull(replace(FSaleDeliveryFactory,'()',''), '') AS '
(Delivering Plant)',
2 years ago
isnull(replace(FSaleTaxType,'()',''), '') AS '
(Tax classification material)',
2 years ago
isnull(replace(FSaleMaterialStatisticsGroup,'()',''), '') AS '
(Material statistics group)',
2 years ago
isnull(replace(FSaleSalesCompany,'()',''), '') AS '
(Sales unit)',
2 years ago
isnull(replace(FSaleBaseCompanyCount,'()',''), '') AS '
(Quantity Conversion of basic unit of measure)',
2 years ago
isnull(replace(FSaleSalesCompanyCount,'()',''), '') AS '
(Quantity Conversion of Sales)',
2 years ago
isnull(replace(FSaleAccountSettingGroup,'()',''), '') AS '
(Account Assignment Group for Material)',
2 years ago
isnull(replace(FSaleGeneralProjectCategoryGroup,'()',''), '') AS '
(General item category group)',
2 years ago
isnull(replace(FSaleProjectCategoryGroup,'()',''), '') AS '
(Item Category Group)',
2 years ago
isnull(replace(FSaleAvailabilityCheck,'()',''), '') AS '
(Availability check)',
2 years ago
isnull(replace(FSaleOutfitGroup,'()',''), '') AS '
(Loading Group)',
2 years ago
isnull(replace(FSaleOldMaterialCode,'()',''), '') AS '
old material number',
2 years ago
isnull(replace(FStorageConditions,'()',''), '') AS '
Storage conditions',
2 years ago
isnull(replace(FStorageBatchManage,'()',''), '') AS '
Batch Management Requirement Indicator',
2 years ago
isnull(replace(FStorageMaxStoragePeriod,'()',''), '') AS '
Maximum Storage Period',
2 years ago
isnull(replace(FStorageTimeUnit,'()',''), '') AS '
Time unit',
2 years ago
isnull(replace(FStorageMinSurplusShelfLife,'()',''), '') AS '寿(Minimum Remaining Shelf Life)',
isnull(replace(FStorageTotalShelfLife,'()',''), '') AS '寿
(Total shelf life)',
2 years ago
isnull(replace(FStorageSLEDCode,'()',''), '') AS 'SLED
(Period Indicator for Shelf Life Expiration Date)',
2 years ago
isnull(replace(FMRP1Type,'()',''), '') AS 'MRP
(MRP Type)',
2 years ago
isnull(replace(FMRP1ReorderLocation,'()',''), '') AS '',
isnull(replace(FMRP1RegularBatchSize,'()',''), '') AS '',
isnull(replace(FMRP1MaxInventorySize,'()',''), '') AS '',
isnull(replace(FMRP1Controller,'()',''), '') AS 'MRP
MRP Controller',
2 years ago
isnull(replace(FMRP1BatchSize,'()',''), '') AS '
Lot Sizing Procedure within Materials Planning',
2 years ago
isnull(replace(FMRP1MinBatchSize,'()',''), '') AS '
Maximum Lot Size',
2 years ago
isnull(replace(FMRP1MaxBatchSize,'()',''), '') AS '
Minimum Lot Size',
2 years ago
isnull(replace(FMRP1Group,'()',''), '') AS 'MRP
MRP Group',
2 years ago
isnull(replace(FMRP1RoundValue,'()',''), '') AS '
Rounding value for purchase order quantity',
2 years ago
isnull(replace(FMRP1ProductType,'()',''), '') AS '
Product classification',
2 years ago
isnull(replace(FMRP1CustomerCode,'()',''), '') AS '',
isnull(replace(FMRP1SizeMaterial,'()',''), '') AS '',
isnull(replace(FMRP1IgnoreLack,'()',''), '') AS '',
isnull(replace(FMRP1laminated,'()',''), '') AS '',
isnull(replace(FMRP1SafeStock,'()',''), '') AS '',
isnull(replace(FMRP1RequireCount,'()',''), '') AS '',
isnull(replace(FMRP1SmallMaterialStandard,'()',''), '') AS ' ',
isnull(replace(FMRP2PurchaseType,'()',''), '') AS '
Procurement Type',
2 years ago
isnull(replace(FMRP2PlanMarginalCode,'()',''), '') AS '
SchedMargin key',
2 years ago
isnull(replace(FMRP2SpecialProcurement,'()',''), '') AS '
Special procurement',
2 years ago
isnull(replace(FMRP2Recoil,'()',''), '') AS '
Backflush',
2 years ago
isnull(replace(FMRP2SelfProductTime,'()',''), '') AS '
In-house production time',
2 years ago
isnull(replace(FMRP2PlannDeliveryTime,'()',''), '') AS '
Planned Delivery Time in Days',
2 years ago
isnull(replace(FMRP2ReceiveProcessTime,'()',''), '') AS '
Goods receipt processing time in days',
2 years ago
isnull(replace(FMRP2SafeStock,'()',''), '') AS '
Safety Stock',
2 years ago
isnull(replace(FMRP2DeliveryInventoryPlace,'()',''), '') AS '
Issue Storage Location',
2 years ago
isnull(replace(FMRP2ExternalStoragePlace,'()',''), '') AS '
Default storage location for external procurement',
2 years ago
isnull(replace(FMRP3PolicyGroup,'()',''), '') AS '
Strategy Group',
2 years ago
isnull(replace(FMRP3ConsumePattern,'()',''), '') AS '
Consumption Mode',
2 years ago
isnull(replace(FMRP3ForwardConsumePeriod,'()',''), '') AS '
Consumption period: forward',
2 years ago
isnull(replace(FMRP3ReverseConsumePeriod,'()',''), '') AS '
Consumption period: backward',
2 years ago
isnull(replace(FMRP3BlendMRP,'()',''), '') AS 'MRP
Mixed MRP indicator',
2 years ago
isnull(replace(FMRP3AvailabilityCheck,'()',''), '') AS '
Availability check',
2 years ago
isnull(replace(FMRP4AloneOrFocus,'()',''), '') AS '
Individual requirements/Collective requirements',
2 years ago
isnull(replace(FMRP4DiscontinuousIidentifier,'()',''), '') AS '',
isnull(replace(FMRP4EffectivePeriod,'()',''), '') AS '',
isnull(replace(FMRP4FollowMaterial,'()',''), '') AS '',
isnull(replace(FPlanProductPlanParam,'()',''), '') AS '
Production Scheduling Profile',
2 years ago
isnull(replace(FPlanUnlimitedOverDelivery,'()',''), '') AS '
Indicator: Unlimited Overdelivery Allowed',
2 years ago
isnull(replace(FPlanUnderDeliveryTolerance,'()',''), '') AS '
Underdelivery tolerance limit',
2 years ago
isnull(replace(FPlanOverDeliveryTolerance,'()',''), '') AS '
Overdelivery tolerance limit',
2 years ago
isnull(replace(FPlanDeliverCompany,'()',''), '') AS '
Unit of issue',
2 years ago
isnull(replace(FPlanDeliverCompanyCount,'()',''), '') AS '
(Quantity Conversion of Delivery)',
2 years ago
isnull(replace(FPlanBaseCompanyCount,'()',''), '') AS '
(Quantity Conversion of basic unit of measure)',
2 years ago
isnull(replace(FQualityType1,'()',''), '') AS '1
Inspection Type 1',
2 years ago
isnull(replace(FQualityType2,'()',''), '') AS '2
Inspection Type 2',
2 years ago
isnull(replace(FQualityType3,'()',''), '') AS '3
Inspection Type 3',
2 years ago
isnull(replace(FQualityType4,'()',''), '') AS '4
Inspection Type 4',
2 years ago
isnull(replace(FQualityType5,'()',''), '') AS '5
Inspection Type 5',
2 years ago
isnull(replace(FQualityType6,'()',''), '') AS '6
Inspection Type 6',
2 years ago
isnull(replace(FAccountPriceControl,'()',''), '') AS '
(Price control indicator)',
2 years ago
isnull(replace(FAccountPriceDetermine,'()',''), '') AS '
(Material Price Determination: Control)',
2 years ago
isnull(replace(FAccountPriceUnit,'()',''), '') AS '
(Price Unit)',
2 years ago
isnull(replace(FAccountAccessType,'()',''), '') AS '
Valuation Class',
2 years ago
isnull(replace(FAccountSaleOrderInventory,'()',''), '') AS 'VC:
Valuation Class for Sales Order Stock',
2 years ago
isnull(replace(FAccountStandardPrice,'()',''), '') AS '
Standard Price',
2 years ago
isnull(replace(FAccountProfitCenter,'()',''), '') AS '
Profit Center',
2 years ago
isnull(replace(FAccountCostAccountBatch,'()',''), '') AS '
Lot Size for Product Costing'
FROM TFS_ViewMaterial";
if ("2".Equals(teamworkType))
{
string whereSql = string.Format(" Where FTeamType=1 And FMdfMaterialTeamID={0}", teamworkId);
strSql = strSql + whereSql;
}
2 years ago
else if ("3".Equals(teamworkType))
{
string whereSql = string.Format(" Where FHalfMaterialTeamID={0}", teamworkId);
strSql = strSql + whereSql;
}
else
{
string whereSql = string.Format(" Where FTeamType=1 And FTeamID={0}", teamworkId);
strSql = strSql + whereSql;
}
DataTable data = db.Ado.GetDataTable(strSql);
return data;
}
public DataTable GetViewMaterial(string FID)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
string strSql = string.Format(@"select
iif(m.FTypeID1 is null, '', (select FName from TFS_MaterialType where fid = m.FTypeID1)) as '',
iif(m.FTypeID2 is null, '', (select FName from TFS_MaterialType where fid = m.FTypeID2)) as '',
isnull(m.FK3Code, '') as 'K3',
isnull(m.FK3Name, '') as 'K3',
isnull(m.FK3ShortCode, '') as 'K3',
isnull(m.FTestCode, '') as '',
isnull(m.FRelationCode, '') as '',
isnull(m.FRelationName, '') as '',
isnull(m.FSAPCode, '') as 'SAP',
isnull(m.FSAPDescription, '') as 'SAP',
isnull(i.FMaterialGroup, '') as '',
isnull(i.FMaterialType, '') as '',
isnull(i.FCustomerCode, '') as '',
isnull(i.FStoreHouse, '') as '',
isnull(i.FBomEntry, '') as 'BOM',
isnull(i.FLineHouse, '') as '线',
isnull(i.FProductDesc, '') as '',
isnull(i.FWorkCenter, '') as '',
isnull(i.FCraftExplain, '') as '',
isnull(i.FIidentifier, '') as '',
isnull(i.FGuaranteePeriod, '') as '',
isnull(i.FBStorageConditions, '') as '',
isnull(i.FSafetyStock, '') as '',
isnull(i.FTriggerRatio, '') as '',
isnull(i.FMinAmount, '') as '',
isnull(i.FMaxAmount, '') as '',
isnull(i.FYield, '') as '',
isnull(i.FFixedLoss, '') as '',
isnull(i.FTheoryYield, '') as '',
isnull(i.FQualityTest1, '') as '',
isnull(i.FQualityTest2, '') as '',
isnull(v.FOrganizeIndustryField, '') as '
Industry Sector',
isnull(v.FOrganizeMaterialType, '') as '
(Material Type)',
isnull(v.FOrganizeFactory, '') as '
(Plant)',
isnull(v.FOrganizeInventoryLocation, '') as '
(Stock Location)',
isnull(v.FOrganizeSalesOrganize, '') as '
(Sales Organization)',
isnull(v.FOrganizeDistributionChannel, '') as '
(distribution Channel)',
isnull(v.FBaseMaterialCode, '') as '
(Material NO.)',
isnull(v.FBaseTestCode, '') as '
(Test NO.)',
isnull(v.FBaseBasicMeter, '') as '
(Base Unit of Measure)',
isnull(v.FBaseMaterialDesc, '') as '
Material Description',
isnull(v.FBaseMaterialGroup, '') as '
(Material Group)',
isnull(v.FBaseSpecification, '') as '/
(Specifications)',
isnull(v.FBaseMaterialText, '') as '
(Basic Data Text)',
isnull(v.FBaseIdentifier, '') as '\://
(In bulk/liquid)',
isnull(v.FBaseVolumeUnit, '') as '
(Volume Unit)',
isnull(v.FBaseGrossWeight, '') as '
(Gross weight)',
isnull(v.FBaseNetWeight, '') as '
(Net weight)',
isnull(v.FBaseWeightUnit, '') as '
(Weight unit)',
isnull(v.FBaseFameCode, '') as 'fame',
isnull(v.FBaseBusinessVolume, '') as '
(Volume)',
isnull(v.FPurchaseGroup, '') as '
(Purchasing Group)',
isnull(v.FPurchaseCompany, '') as '
(Order Unit)',
isnull(v.FPurchaseCompanyCount, '') as '
(Quantity Conversion of procument)',
isnull(v.FPurchaseBaseCompanyCount, '') as '
(Quantity Conversion of basic unit of measure)',
isnull(v.FPurchaseValueCode, '') as '
(Purchasing value key)',
isnull(v.FPurchaseFactorySpecificStatus, '') as '
(Plant-Specific Material Status)',
isnull(v.FPurchaseAutoOrder, '') as '
automatic purchase order allowed',
isnull(v.FPurchaseGoodsSource, '') as '
Source list requirement',
isnull(v.FTypeCategoryType, '') as '
Class Type',
isnull(v.FTypeType, '') as '
Class',
isnull(v.FSaleDeliveryFactory, '') as '
(Delivering Plant)',
isnull(v.FSaleTaxType, '') as '
(Tax classification material)',
isnull(v.FSaleMaterialStatisticsGroup, '') as '
(Material statistics group)',
isnull(v.FSaleSalesCompany, '') as '
(Sales unit)',
isnull(v.FSaleBaseCompanyCount, '') as '
(Quantity Conversion of basic unit of measure)',
isnull(v.FSaleSalesCompanyCount, '') as '
(Quantity Conversion of Sales)',
isnull(v.FSaleAccountSettingGroup, '') as '
(Account Assignment Group for Material)',
isnull(v.FSaleGeneralProjectCategoryGroup, '') as '
(General item category group)',
isnull(v.FSaleProjectCategoryGroup, '') as '
(Item Category Group)',
isnull(v.FSaleAvailabilityCheck, '') as '
(Availability check)',
isnull(v.FSaleOutfitGroup, '') as '
(Loading Group)',
isnull(v.FSaleOldMaterialCode, '') as '
old material number
',
isnull(v.FStorageConditions, '') as '
Storage conditions',
isnull(v.FStorageBatchManage, '') as '
Batch Management Requirement Indicator',
isnull(v.FStorageMaxStoragePeriod, '') as '
Maximum Storage Period',
isnull(v.FStorageTimeUnit, '') as '
Time unit',
isnull(v.FStorageMinSurplusShelfLife, '') as '寿(Minimum Remaining Shelf Life)',
isnull(v.FStorageTotalShelfLife, '') as '寿
(Total shelf life)',
isnull(v.FStorageSLEDCode, '') as 'SLED
(Period Indicator for Shelf Life Expiration Date)',
isnull(v.FMRP1Type, '') as 'MRP
(MRP Type)',
isnull(v.FMRP1ReorderLocation, '') as '',
isnull(v.FMRP1RegularBatchSize, '') as '',
isnull(v.FMRP1MaxInventorySize, '') as '',
isnull(v.FMRP1Controller, '') as 'MRP
MRP Controller',
isnull(v.FMRP1BatchSize, '') as '
Lot Sizing Procedure within Materials Planning',
isnull(v.FMRP1MinBatchSize, '') as '
Maximum Lot Size',
isnull(v.FMRP1MaxBatchSize, '') as '
Minimum Lot Size',
isnull(v.FMRP1Group, '') as 'MRP
MRP Group',
isnull(v.FMRP1RoundValue, '') as '
Rounding value for purchase order quantity',
isnull(v.FMRP1ProductType, '') as '
Product classification',
isnull(v.FMRP1CustomerCode, '') as '',
isnull(v.FMRP1SizeMaterial, '') as '',
isnull(v.FMRP1IgnoreLack, '') as ' ',
isnull(v.FMRP1laminated, '') as '',
isnull(v.FMRP1SafeStock, '') as '',
isnull(v.FMRP1RequireCount, '') as '',
isnull(v.FMRP1SmallMaterialStandard, '') as ' ',
isnull(v.FMRP2PurchaseType, '') as '
Procurement Type',
isnull(v.FMRP2PlanMarginalCode, '') as '
SchedMargin key',
isnull(v.FMRP2SpecialProcurement, '') as '
Special procurement',
isnull(v.FMRP2Recoil, '') as '
Backflush',
isnull(v.FMRP2SelfProductTime, '') as '
In-house production time',
isnull(v.FMRP2PlannDeliveryTime, '') as '
Planned Delivery Time in Days',
isnull(v.FMRP2ReceiveProcessTime, '') as '
Goods receipt processing time in days',
isnull(v.FMRP2SafeStock, '') as '
Safety Stock',
isnull(v.FMRP2DeliveryInventoryPlace, '') as '
Issue Storage Location',
isnull(v.FMRP2ExternalStoragePlace, '') as '
Default storage location for external procurement',
isnull(v.FMRP3PolicyGroup, '') as '
Strategy Group',
isnull(v.FMRP3ConsumePattern, '') as '
Consumption Mode',
isnull(v.FMRP3ForwardConsumePeriod, '') as '
Consumption period: forward',
isnull(v.FMRP3ReverseConsumePeriod, '') as '
Consumption period: backward',
isnull(v.FMRP3BlendMRP, '') as 'MRP
Mixed MRP indicator',
isnull(v.FMRP3AvailabilityCheck, '') as '
Availability check',
isnull(v.FMRP4AloneOrFocus, '') as '
Individual requirements/Collective requirements',
isnull(v.FMRP4DiscontinuousIidentifier, '') as '',
isnull(v.FMRP4EffectivePeriod, '') as '',
isnull(v.FMRP4FollowMaterial, '') as '',
isnull(v.FPlanProductPlanParam, '') as '
Production Scheduling Profile',
isnull(v.FPlanUnlimitedOverDelivery, '') as '
Indicator: Unlimited Overdelivery Allowed',
isnull(v.FPlanUnderDeliveryTolerance, '') as '
Underdelivery tolerance limit',
isnull(v.FPlanOverDeliveryTolerance, '') as '
Overdelivery tolerance limit',
isnull(v.FPlanDeliverCompany, '') as '
Unit of issue',
isnull(v.FPlanDeliverCompanyCount, '') as '
(Quantity Conversion of Delivery)',
isnull(v.FPlanBaseCompanyCount, '') as '
(Quantity Conversion of basic unit of measure)',
isnull(v.FQualityType1, '') as '1
Inspection Type 1',
isnull(v.FQualityType2, '') as '2
Inspection Type 2',
isnull(v.FQualityType3, '') as '3
Inspection Type 3',
isnull(v.FQualityType4, '') as '4
Inspection Type 4',
isnull(v.FQualityType5, '') as '5
Inspection Type 5',
isnull(v.FQualityType6, '') as '6
Inspection Type 6',
isnull(v.FAccountPriceControl, '') as '
(Price control indicator)',
isnull(v.FAccountPriceDetermine, '') as '
(Material Price Determination: Control)',
isnull(v.FAccountPriceUnit, '') as '
(Price Unit)',
isnull(v.FAccountAccessType, '') as '
Valuation Class',
isnull(v.FAccountSaleOrderInventory, '') as 'VC:
Valuation Class for Sales Order Stock',
isnull(v.FAccountStandardPrice, '') as '
Standard Price',
isnull(v.FAccountProfitCenter, '') as '
Profit Center',
isnull(v.FAccountCostAccountBatch, '') as '
Lot Size for Product Costing'
from
TFS_ViewMaterial v
left join TFS_Material m on
v.FMaterialID = m.FID
left join TFS_MaterialInfo i on
v.FMaterialID = i.FDataID
where
i.FType = 2
and v.FMaterialID in ({0})", FID);
DataTable data = db.Ado.GetDataTable(strSql);
return data;
}
}
}