Browse Source

小件装配和冲孔,视频检测等功能项目.整体上传

master
wrx 4 months ago
parent
commit
e83f0e9dbe
  1. 42
      SjMes/PunchAssemble/BBMPT.sln
  2. 20
      SjMes/PunchAssemble/MESClassLibrary/App.config
  3. 42
      SjMes/PunchAssemble/MESClassLibrary/BLL/Andon/AndonButtonRecordBLL.cs
  4. 31
      SjMes/PunchAssemble/MESClassLibrary/BLL/Andon/AndonButtonTypeBLL.cs
  5. 178
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicBLL.cs
  6. 44
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/BadInjectionBLL.cs
  7. 174
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/BarCodeBLL.cs
  8. 271
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/BomBLL.cs
  9. 184
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/BucketInfoBLL.cs
  10. 198
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/CheckItemBLL.cs
  11. 214
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ColorBLL.cs
  12. 181
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/DefectBLL.cs
  13. 144
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/DeptBLL.cs
  14. 251
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/DeviceBLL.cs
  15. 148
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/FactoryBLL.cs
  16. 141
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ImgVideoBLL.cs
  17. 391
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/InjectionPlanBLL.cs
  18. 170
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/LineBLL.cs
  19. 184
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/MachineBLL.cs
  20. 208
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ModelInfoBLL.cs
  21. 137
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ModelUpdateBLL.cs
  22. 185
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/OperatorBLL.cs
  23. 335
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/PaintInfoBLL.cs
  24. 165
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/PlaceBLL.cs
  25. 238
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/PlasticBLL.cs
  26. 443
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ProductBLL.cs
  27. 83
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ProductOfInjectionBLL.cs
  28. 182
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ProductTypeBLL.cs
  29. 195
      SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/StationBLL.cs
  30. 1506
      SjMes/PunchAssemble/MESClassLibrary/BLL/Check/InspectResultBLL.cs
  31. 29
      SjMes/PunchAssemble/MESClassLibrary/BLL/ExchangeCenter/GetNewTasksBLL.cs
  32. 29
      SjMes/PunchAssemble/MESClassLibrary/BLL/ExchangeCenter/PartMstrBLL.cs
  33. 29
      SjMes/PunchAssemble/MESClassLibrary/BLL/ExchangeCenter/PartRecordBLL.cs
  34. 58
      SjMes/PunchAssemble/MESClassLibrary/BLL/ExchangeCenter/TESBomBLL.cs
  35. 28
      SjMes/PunchAssemble/MESClassLibrary/BLL/ExchangeCenter/TESPartDetBLL.cs
  36. 29
      SjMes/PunchAssemble/MESClassLibrary/BLL/Injection/DownReasonBLL.cs
  37. 891
      SjMes/PunchAssemble/MESClassLibrary/BLL/Injection/InjectionDownRecordBLL.cs
  38. 1979
      SjMes/PunchAssemble/MESClassLibrary/BLL/Injection/InjectionRecordBLL.cs
  39. 596
      SjMes/PunchAssemble/MESClassLibrary/BLL/Inspection/CommonlyInspectionBLL.cs
  40. 208
      SjMes/PunchAssemble/MESClassLibrary/BLL/Inspection/CommonlyInspectionVersionBLL.cs
  41. 100
      SjMes/PunchAssemble/MESClassLibrary/BLL/Mistake247/AssemblyBLL.cs
  42. 86
      SjMes/PunchAssemble/MESClassLibrary/BLL/Mistake247/BoxBLL.cs
  43. 72
      SjMes/PunchAssemble/MESClassLibrary/BLL/Mistake247/MistakeBLL.cs
  44. 101
      SjMes/PunchAssemble/MESClassLibrary/BLL/Mistake247/Plan247BLL.cs
  45. 171
      SjMes/PunchAssemble/MESClassLibrary/BLL/Mistake247/RecordBLL.cs
  46. 29
      SjMes/PunchAssemble/MESClassLibrary/BLL/Painting/InspectResultBLL.cs
  47. 72
      SjMes/PunchAssemble/MESClassLibrary/BLL/Painting/PaintBarCodeBLL.cs
  48. 114
      SjMes/PunchAssemble/MESClassLibrary/BLL/Painting/StockInBLL.cs
  49. 399
      SjMes/PunchAssemble/MESClassLibrary/BLL/Plan247/Plan247BLL.cs
  50. 451
      SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PlanPunchBLL.cs
  51. 29
      SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchAdressBLL.cs
  52. 182
      SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchAndStationBLL.cs
  53. 42
      SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchDeviceBLL.cs
  54. 29
      SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchPartBLL.cs
  55. 94
      SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchPlanBLL.cs
  56. 44
      SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchRecordBLL.cs
  57. 29
      SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchValueRecordBLL.cs
  58. 81
      SjMes/PunchAssemble/MESClassLibrary/BLL/Record247/Record247BLL.cs
  59. 190
      SjMes/PunchAssemble/MESClassLibrary/BLL/Report/FiveScreenBLL.cs
  60. 153
      SjMes/PunchAssemble/MESClassLibrary/BLL/Report/FiveScreenLastBLL.cs
  61. 161
      SjMes/PunchAssemble/MESClassLibrary/BLL/Report/FiveScreenStandardBLL.cs
  62. 57
      SjMes/PunchAssemble/MESClassLibrary/BLL/Show/AnalysisBLL.cs
  63. 156
      SjMes/PunchAssemble/MESClassLibrary/BLL/Stock/StockInBLL.cs
  64. 45
      SjMes/PunchAssemble/MESClassLibrary/BLL/User/Sys_ButtonsService.cs
  65. 83
      SjMes/PunchAssemble/MESClassLibrary/BLL/User/Sys_NavMenuService.cs
  66. 304
      SjMes/PunchAssemble/MESClassLibrary/BLL/User/UserBLL.cs
  67. 68
      SjMes/PunchAssemble/MESClassLibrary/DAL/Andon/AndonButtonRecordDAL.cs
  68. 34
      SjMes/PunchAssemble/MESClassLibrary/DAL/Andon/AndonButtonTypeDAL.cs
  69. 199
      SjMes/PunchAssemble/MESClassLibrary/DAL/BaseDAL.cs
  70. 51
      SjMes/PunchAssemble/MESClassLibrary/DAL/BasicDAL.cs
  71. 92
      SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/BadInjectionDAL.cs
  72. 440
      SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/BarCodeDAl.cs
  73. 150
      SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/BomDAL.cs
  74. 55
      SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/ColorDAL.cs
  75. 35
      SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/DefectDAL.cs
  76. 199
      SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/InjectionPlanDAL.cs
  77. 73
      SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/OperatorDAL.cs
  78. 245
      SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/ProductDAL.cs
  79. 265
      SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/ProductOfInjectionDAL.cs
  80. 210
      SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/ProductTypeDAL.cs
  81. 38
      SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/StationDAL.cs
  82. 253
      SjMes/PunchAssemble/MESClassLibrary/DAL/Check/InspectResultDAL.cs
  83. 80
      SjMes/PunchAssemble/MESClassLibrary/DAL/DataTableExtend.cs
  84. 123
      SjMes/PunchAssemble/MESClassLibrary/DAL/ExchangeCenter/GetNewTasksDAL.cs
  85. 110
      SjMes/PunchAssemble/MESClassLibrary/DAL/ExchangeCenter/PartMstrDAL.cs
  86. 46
      SjMes/PunchAssemble/MESClassLibrary/DAL/ExchangeCenter/PartRecordDAL.cs
  87. 177
      SjMes/PunchAssemble/MESClassLibrary/DAL/ExchangeCenter/TESBomDAL.cs
  88. 93
      SjMes/PunchAssemble/MESClassLibrary/DAL/ExchangeCenter/TESPartDetDAL.cs
  89. 31
      SjMes/PunchAssemble/MESClassLibrary/DAL/Injection/DownReasonDAL.cs
  90. 159
      SjMes/PunchAssemble/MESClassLibrary/DAL/Injection/InjectionDownRecordDAL.cs
  91. 113
      SjMes/PunchAssemble/MESClassLibrary/DAL/Injection/InjectionRecordDAL.cs
  92. 202
      SjMes/PunchAssemble/MESClassLibrary/DAL/Mistake247/AssemblyDAL.cs
  93. 168
      SjMes/PunchAssemble/MESClassLibrary/DAL/Mistake247/BoxDAL.cs
  94. 104
      SjMes/PunchAssemble/MESClassLibrary/DAL/Mistake247/MistakeDAL.cs
  95. 214
      SjMes/PunchAssemble/MESClassLibrary/DAL/Mistake247/Plan247DAL.cs
  96. 311
      SjMes/PunchAssemble/MESClassLibrary/DAL/Mistake247/RecordDAL.cs
  97. 13
      SjMes/PunchAssemble/MESClassLibrary/DAL/Plan247/Plan247DAL.cs
  98. 37
      SjMes/PunchAssemble/MESClassLibrary/DAL/PunchAndWeld/PunchAdressDAL.cs
  99. 42
      SjMes/PunchAssemble/MESClassLibrary/DAL/PunchAndWeld/PunchAndStationDAL.cs
  100. 51
      SjMes/PunchAssemble/MESClassLibrary/DAL/PunchAndWeld/PunchDeviceDAL.cs

42
SjMes/PunchAssemble/BBMPT.sln

@ -0,0 +1,42 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MESClassLibrary", "MESClassLibrary\MESClassLibrary.csproj", "{867989D8-6837-41DC-9BF1-4658F5D6CFEF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0D128182-FB8C-4E0B-A42F-DF3767E4DE39}"
ProjectSection(SolutionItems) = preProject
数据结构修改记录.txt = 数据结构修改记录.txt
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PunchAndWeld", "PunchAndWeld\PunchAndWeld.csproj", "{D6371D99-5220-4A51-A72C-966FB4BFCD2C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{867989D8-6837-41DC-9BF1-4658F5D6CFEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{867989D8-6837-41DC-9BF1-4658F5D6CFEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{867989D8-6837-41DC-9BF1-4658F5D6CFEF}.Debug|x86.ActiveCfg = Debug|Any CPU
{867989D8-6837-41DC-9BF1-4658F5D6CFEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{867989D8-6837-41DC-9BF1-4658F5D6CFEF}.Release|Any CPU.Build.0 = Release|Any CPU
{867989D8-6837-41DC-9BF1-4658F5D6CFEF}.Release|x86.ActiveCfg = Release|Any CPU
{D6371D99-5220-4A51-A72C-966FB4BFCD2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6371D99-5220-4A51-A72C-966FB4BFCD2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6371D99-5220-4A51-A72C-966FB4BFCD2C}.Debug|x86.ActiveCfg = Debug|Any CPU
{D6371D99-5220-4A51-A72C-966FB4BFCD2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6371D99-5220-4A51-A72C-966FB4BFCD2C}.Release|Any CPU.Build.0 = Release|Any CPU
{D6371D99-5220-4A51-A72C-966FB4BFCD2C}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {52EF8F7E-6AC9-4400-82F1-31F70143C867}
EndGlobalSection
EndGlobal

20
SjMes/PunchAssemble/MESClassLibrary/App.config

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
<connectionStrings>
<add name="BBMPTEntities" connectionString="metadata=res://*/EFModel.BBMPT.csdl|res://*/EFModel.BBMPT.ssdl|res://*/EFModel.BBMPT.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=10.60.101.9;initial catalog=BBMPT;user id=sa;password=a1+;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
</connectionStrings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

42
SjMes/PunchAssemble/MESClassLibrary/BLL/Andon/AndonButtonRecordBLL.cs

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.Andon;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.Andon
{
public class AndonButtonRecordBLL
{
AndonButtonRecordDAL da=new AndonButtonRecordDAL();
public bool InsertInfo(AndonRecordModel md)
{
try
{
return da.InsertInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateInfo(AndonRecordModel md)
{
try
{
return da.UpdateInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

31
SjMes/PunchAssemble/MESClassLibrary/BLL/Andon/AndonButtonTypeBLL.cs

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL;
using MESClassLibrary.DAL.Andon;
namespace MESClassLibrary.BLL.Andon
{
public class AndonButtonTypeBLL
{
public DataTable SearchInfoByName(string buttonName)
{
try
{
AndonButtonTypeDAL da = new AndonButtonTypeDAL();
return da.SearchInfoByName(buttonName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

178
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicBLL.cs

@ -0,0 +1,178 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL
{
public class BasicBLL<T> where T : class, new()
{
BaseDAL<T> db = new BaseDAL<T>();
/// 新增信息
public bool AddInfo(T md)
{
try
{
if (db.Add(md) > 0)
{
return true;
}
return false;
}
catch (Exception ex)
{
//LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// 修改信息
public bool UpdateInfo(T md, params string[] proNames)
{
try
{
//T u = new T() { uId = 1, uLoginName = "asdfasdf" };
if (db.Modify(md, proNames) > 0)
{
return true;
}
return false;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// 删除信息
public bool DelInfo(T md)
{
try
{
if (db.Del(md) > 0)
{
return true;
}
return false;
}
catch (Exception ex)
{
//LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public List<T> SearchInfo(int page, int pagesize, out int total)
{
try
{
var list = db.GetListBy(LambdaHelper.CreateEqual<T>("IsUseing", 1)).ToList();
total = list.Count;
int Skipcount = (page - 1) * pagesize;
return list.Skip(Skipcount).Take(pagesize).ToList();
}
catch (Exception ex)
{
total = 0;
//LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public List<T> SearchInfoByKey(string keyname, object keyvalue)
{
try
{
var list = db.GetListBy(LambdaHelper.CreateEqual<T>(keyname, keyvalue)).ToList();
return list;
}
catch (Exception)
{
return new List<T>();
//return null;
}
}
public List<T> SearchInfoContains(string keyname, string keyvalue)
{
try
{
var list = db.GetListBy(LambdaHelper.GetContains<T>(keyname, keyvalue)).ToList();
return list;
}
catch (Exception)
{
return new List<T>();
//return null;
}
}
public List<T> SearchInfoAll(int page, int pagesize, out int total)
{
try
{
var list = db.GetListBy(LambdaHelper.True<T>()).ToList();
total = list.Count;
int Skipcount = (page - 1) * pagesize;
return list.Skip(Skipcount).Take(pagesize).ToList();
}
catch (Exception ex)
{
total = 0;
//LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public T SearchInfoByID(string ID)
{
try
{
var list = db.Find(ID);
return list;
}
catch (Exception ex)
{
return null;
}
}
public List<T> SearchAllInfo()
{
try
{
return db.GetListBy(LambdaHelper.True<T>()).ToList();
}
catch (Exception ex)
{
//LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public List<T> SearchInfoByTime(string cname, DateTime stime, DateTime etime)
{
try
{
IQueryable<T> list = db.GetListBy(LambdaHelper.CreateCompareToLater<T>(cname, stime)).AsQueryable();
list = list.Where(LambdaHelper.CreateCompareToEarlier<T>(cname, etime));
return list.ToList();
}
catch (Exception)
{
return new List<T>();
//return null;
}
}
}
}

44
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/BadInjectionBLL.cs

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.BasicInfo;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.BasicInfo
{
public class BadInjectionBLL
{
BadInjectionDAL db=new BadInjectionDAL();
public bool Add_Info(BadInjectionModel md)
{
try
{
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchByCode(string code)
{
try
{
return db.SearchByCode(code);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

174
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/BarCodeBLL.cs

@ -0,0 +1,174 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.BasicInfo;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.BasicInfo
{
public class BarCodeBLL
{
BarCodeDAl db = new BarCodeDAl();
public DataTable SearchInfoByStock(string StockNo)
{
try
{
return db.SearchInfoByStock(StockNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool Add_Info(BarCodeModel md)
{
try
{
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchInfo(string stationNo)
{
try
{
return db.SearchInfo(stationNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoAll()
{
try
{
return db.SearchInfoAll();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCode()
{
try
{
return db.SearchBarCode();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCodeByOne(string OneBarCode)
{
try
{
return db.SearchBarCodeByOne(OneBarCode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCodeByTwo(string BarCode)
{
try
{
return db.SearchBarCodeByTwo(BarCode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchSerialNoByBarCode(string Code)
{
try
{
return db.SearchSerialNoByBarCode(Code);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByBarCode(string BarCode)
{
try
{
return db.SearchInfoByBarCode(BarCode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool Update_Info(BarCodeModel md)
{
try
{
return db.UpdateInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool DelBarCode(BarCodeModel md)
{
try
{
return db.DelBarCode(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchOneBarCode(string barCode,int a)
{
try
{
return db.SearchOneBarCode(barCode,a);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

271
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/BomBLL.cs

@ -0,0 +1,271 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.DAL.BasicInfo;
namespace MESClassLibrary.BLL.BasicInfo
{
public class BomBLL
{
BasicBLL<tb_Bom> db = new BasicBLL<tb_Bom>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_Bom md)
{
try
{
var list = db.SearchInfoByKey("PartNo1", md.PartNo1);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.BomID != md.BomID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_Bom md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.PartNo1 == md.PartNo1 && p.BomID != md.BomID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[2];
proNames[0] = "PartNo1";
proNames[1] = "PartNo2";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_Bom md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string partNo1)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Bom> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(partNo1))
{
list = list.Where(p => p.PartNo1.Contains(partNo1)).ToList();
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
List<BomModel> modelList = new List<BomModel>();
BasicBLL<tb_Product> s_db = new BasicBLL<tb_Product>();
var s_list = s_db.SearchAllInfo();
foreach (var item in list)
{
BomModel dm = Tool.Mapper<BomModel, tb_Bom>(item);
var info = s_list.FirstOrDefault(p => p.PartNo == item.PartNo1);
if (info != null)
{
dm.ProductName1 = info.ProductName;
}
var info2 = s_list.FirstOrDefault(p => p.PartNo == item.PartNo2);
if (info2 != null)
{
dm.ProductName2 = info2.ProductName;
}
modelList.Add(dm);
}
JsonDataModel<BomModel> md = new JsonDataModel<BomModel>();
md.total = total.ToString();
md.rows = modelList;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<BomModel>>(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 查询全部信息
/// </summary>
/// <returns></returns>
public List<tb_Bom> SearchAll()
{
try
{
var s_list = db.SearchAllInfo().ToList();
return s_list;
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_Bom SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBom(string PartNo)
{
BomDAL dal=new BomDAL();
try
{
return dal.SearchBom(PartNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable Search(string partNo1, string partNo2)
{
BomDAL dal = new BomDAL();
try
{
return dal.Search(partNo1, partNo2);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool AddInfo(BomModel md)
{
BomDAL dal = new BomDAL();
try
{
return dal.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool updateInfo(BomModel md)
{
BomDAL dal = new BomDAL();
try
{
return dal.updateInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool DelInfo(BomModel md)
{
BomDAL dal = new BomDAL();
try
{
return dal.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

184
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/BucketInfoBLL.cs

@ -0,0 +1,184 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.BasicInfo
{
public class BucketInfoBLL
{
BasicBLL<tb_BucketInfo> db = new BasicBLL<tb_BucketInfo>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_BucketInfo md)
{
try
{
var list = db.SearchInfoByKey("BucketCode", md.BucketCode);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.ID != md.ID && p.IsUsing == 1).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_BucketInfo md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.BucketCode == md.BucketCode && p.ID != md.ID && p.IsUsing == 1).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[3];
proNames[0] = "BucketCode";
proNames[1] = "BucketName";
proNames[2] = "IsUsing";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_BucketInfo md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string BucketCode)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_BucketInfo> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(BucketCode))
{
list = list.Where(p => p.BucketCode.Contains(BucketCode)).ToList();
}
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<tb_BucketInfo> md = new JsonDataModel<tb_BucketInfo>();
md.total = total.ToString();
md.rows = list;
return JSONTools.ScriptSerialize(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_BucketInfo SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().ToList();//判断是否有重复数据
List<SelectModel> sl = new List<SelectModel>();
foreach (var item in list)
{
SelectModel md = new SelectModel();
md.textField = item.BucketCode+"--"+ item.BucketName;
md.valueField = item.ID;
sl.Add(md);
}
jsonStr = JSONTools.ScriptSerialize(sl);
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
}
}

198
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/CheckItemBLL.cs

@ -0,0 +1,198 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.BasicInfo
{
public class CheckItemBLL
{
BasicBLL<tb_CheckItem> db = new BasicBLL<tb_CheckItem>();
/// <summary>
/// 查询信息
/// </summary>
/// <returns></returns>
public string SearchInfo(string page, string pagesize, string CheckContent, string DeviceID)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_CheckItem> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(DeviceID))
{
list = list.Where(p => p.DeviceID == DeviceID).ToList();
}
if (!String.IsNullOrEmpty(CheckContent))
{
list = list.Where(p => p.CheckContent.Contains(CheckContent)).ToList();
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
#region 联查
List<CheckItemModel> ModelList = new List<CheckItemModel>();
BasicBLL<tb_Device> p_db = new BasicBLL<tb_Device>();
var p_list = p_db.SearchAllInfo().ToList();
foreach (var item in list)
{
CheckItemModel dm = Tool.Mapper<CheckItemModel, tb_CheckItem>(item);
var info = p_list.FirstOrDefault(p => p.DeviceID == item.DeviceID);
if (info != null)
{
dm.DeviceName = info.DeviceName;
}
ModelList.Add(dm);
}
#endregion
JsonDataModel<CheckItemModel> md = new JsonDataModel<CheckItemModel>();
md.total = total.ToString();
md.rows = ModelList;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<CheckItemModel>>(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
/// <summary>
/// 添加信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool AddInfo(tb_CheckItem md)
{
try
{
var list = db.SearchInfoByKey("CheckContent", md.CheckContent);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.DeviceID.Equals(md.DeviceID)).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool UpdateInfo(tb_CheckItem md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.CheckContent == md.CheckContent && p.DeviceID == md.DeviceID && p.ID != md.ID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[3];
proNames[0] = "DeviceID";
proNames[1] = "CheckContent";
proNames[2] = "CheckVersion";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// 删除生产线信息
public bool DelInfo(tb_CheckItem md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize<List<tb_CheckItem>>(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
public string GetTreeData(string deviceID)
{
try
{
string jsonStr = "[]";
BasicBLL<tb_CheckItem> li_db = new BasicBLL<tb_CheckItem>();
List<TreeModel> trlist = new List<TreeModel>();
TreeModel tr = new TreeModel();
tr.id = "-1";
tr.text = "点检项";
tr.state = "open";
var li_list = li_db.SearchAllInfo().Where(p => p.DeviceID.Equals(deviceID)).ToList();
var queryData = from a in li_list
select new ChildTreeModel
{
id = a.ID,
text = a.CheckContent
};
List<ChildTreeModel> clist = queryData.ToList();
if (clist.Count > 0)
{
tr.children = clist;
trlist.Add(tr);
}
jsonStr = JSONTools.ScriptSerialize<List<TreeModel>>(trlist);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
}
}

214
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ColorBLL.cs

@ -0,0 +1,214 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using MESClassLibrary.DAL.BasicInfo;
namespace MESClassLibrary.BLL.BasicInfo
{
public class ColorBLL
{
BasicBLL<tb_Color> db = new BasicBLL<tb_Color>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_Color md)
{
try
{
//var list = db.SearchInfoByKey("ColorCode", md.ColorCode);//判断是否有重复数据
//if (list != null)
//{
// if (list.Where(p => p.ID != md.ID).Count() > 0)
// {
// return false;
// }
//}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_Color md)
{
try
{
//var list = db.SearchAllInfo().Where(p => p.ColorCode == md.ColorCode && p.ID != md.ID).ToList();//判断是否有重复数据
//if (list.Count > 0)
//{
// return false;
//}
//初始化要更新的字段
string[] proNames = new string[5];
proNames[0] = "ColorCode";
proNames[1] = "ColorNo";
proNames[2] = "ColorQQCode";
proNames[3] = "Des";
proNames[4] = "ColorDQCode";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_Color md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize,string ColorCode)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Color> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(ColorCode))
{
list = list.Where(p => p.ColorCode.Contains(ColorCode)).ToList();
}
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<tb_Color> md = new JsonDataModel<tb_Color>();
md.total = total.ToString();
md.rows = list;
return JSONTools.ScriptSerialize(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_Color SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().Select(p=>p.Des).Distinct().ToList();//判断是否有重复数据
List<SelectModel> sl = new List<SelectModel>();
foreach (var item in list)
{
SelectModel md = new SelectModel();
md.textField = item;
md.valueField = item;
sl.Add(md);
}
jsonStr = JSONTools.ScriptSerialize(sl);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
public DataTable SearchAll()
{
ColorDAL da = new ColorDAL();
try
{
return da.SearchInfoAll();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchByName(string color)
{
ColorDAL da = new ColorDAL();
try
{
return da.SearchByName(color);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

181
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/DefectBLL.cs

@ -0,0 +1,181 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.DAL.BasicInfo;
namespace MESClassLibrary.BLL.BasicInfo
{
public class DefectBLL
{
BasicBLL<tb_Defect> db = new BasicBLL<tb_Defect>();
/// <summary>
/// 查询信息
/// </summary>
/// <returns></returns>
public string SearchInfo(string page, string pagesize, string DefectName, string LineID)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Defect> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(LineID))
{
list = list.Where(p => p.LineID == LineID).ToList();
}
if (!String.IsNullOrEmpty(DefectName))
{
list = list.Where(p => p.DefectName.Contains(DefectName)).ToList();
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
#region 联查
List<DefectModel> ModelList = new List<DefectModel>();
BasicBLL<tb_Line> p_db = new BasicBLL<tb_Line>();
var p_list = p_db.SearchAllInfo().ToList();
foreach (var item in list)
{
DefectModel dm = Tool.Mapper<DefectModel, tb_Defect>(item);
var info = p_list.FirstOrDefault(p => p.LineID == item.LineID);
if (info != null)
{
dm.LineName = info.LineName;
}
ModelList.Add(dm);
}
#endregion
JsonDataModel<DefectModel> md = new JsonDataModel<DefectModel>();
md.total = total.ToString();
md.rows = ModelList;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<DefectModel>>(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
/// <summary>
/// 添加信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool AddInfo(tb_Defect md)
{
try
{
var list = db.SearchInfoByKey("DefectName", md.DefectName);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.ID != md.ID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool UpdateInfo(tb_Defect md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.DefectName == md.DefectName && p.ID != md.ID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[3];
proNames[0] = "LineID";
proNames[1] = "DefectName";
proNames[2] = "Des";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// 删除生产线信息
public bool DelInfo(tb_Defect md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize<List<tb_Defect>>(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
public DataTable SearchInfo(string LineID)
{
DefectDAL da=new DefectDAL();
try
{
return da.SearchInfoAll(LineID);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

144
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/DeptBLL.cs

@ -0,0 +1,144 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.BasicInfo
{
public class DeptBLL
{
BasicBLL<TA_DEPT> db = new BasicBLL<TA_DEPT>();
/// <summary>
/// 查询信息
/// </summary>
/// <returns></returns>
public string SearchInfo(string page, string pagesize, string DeptName)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<TA_DEPT> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(DeptName))
{
list = list.Where(p => p.DeptName.Contains(DeptName)).ToList();//按条件分页查询
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<TA_DEPT> md = new JsonDataModel<TA_DEPT>();
md.total = total.ToString();
md.rows = list;
jsonStr = JSONTools.ScriptSerialize(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
/// <summary>
/// 添加信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool AddInfo(TA_DEPT md)
{
try
{
var list = db.SearchInfoByKey("LineName", md.DeptName);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.GUID != md.GUID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool UpdateInfo(TA_DEPT md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.DeptName == md.DeptName && p.GUID != md.GUID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[3];
proNames[0] = "DeptCode";
proNames[1] = "DeptName";
proNames[2] = "Remark";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// 删除生产线信息
public bool DelInfo(TA_DEPT md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize<List<TA_DEPT>>(list);
return jsonStr;
}
catch (Exception ex)
{
return "";
}
}
}
}

251
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/DeviceBLL.cs

@ -0,0 +1,251 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.BasicInfo
{
public class DeviceBLL
{
BasicBLL<tb_Device> db = new BasicBLL<tb_Device>();
/// <summary>
/// 查询信息
/// </summary>
/// <returns></returns>
public string SearchInfo(string page, string pagesize, string DeviceNo, string StationID)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Device> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(StationID))
{
list = list.Where(p => p.StationID == StationID).ToList();//按条件分页查询
}
if (!String.IsNullOrEmpty(DeviceNo))
{
list = list.Where(p => p.DeviceNo.Contains(DeviceNo)).ToList();//按条件分页查询
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
#region 联查
List<DeviceModel> StationList = new List<DeviceModel>();
BasicBLL<tb_Station> pl_db = new BasicBLL<tb_Station>();
var pl_list = pl_db.SearchAllInfo().ToList();
foreach (var item in list)
{
DeviceModel dm = Tool.Mapper<DeviceModel, tb_Device>(item);
var info = pl_list.FirstOrDefault(p => p.StationID == item.StationID);
if (info != null)
{
dm.StationNo = info.StationNo;
}
StationList.Add(dm);
}
#endregion
JsonDataModel<DeviceModel> md = new JsonDataModel<DeviceModel>();
md.total = total.ToString();
md.rows = StationList;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<DeviceModel>>(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
public string SearchInfoByID(string DeviceID) {
try
{
string jsonStr = "[]";
tb_Device info = db.SearchInfoByID(DeviceID);
jsonStr = JSONTools.ScriptSerialize<tb_Device>(info);
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
/// <summary>
/// 添加信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool AddInfo(tb_Device md)
{
try
{
var list = db.SearchInfoByKey("DeviceNo", md.DeviceNo);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.DeviceID != md.DeviceID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool UpdateInfo(tb_Device md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.DeviceNo == md.DeviceNo && p.DeviceID != md.DeviceID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[6];
proNames[0] = "StationID";
proNames[1] = "DeviceNo";
proNames[2] = "DeviceName";
proNames[3] = "FixNo";
proNames[4] = "Des";
proNames[5] = "DeviceModel";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// 删除生产线信息
public bool DelInfo(tb_Device md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().ToList();//判断是否有重复数据
foreach (var item in list)
{
item.DeviceName = item.DeviceNo + "----" + item.DeviceName;
}
jsonStr = JSONTools.ScriptSerialize<List<tb_Device>>(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
public string QueryForComboboxByLineID(string fl_id)
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().ToList();//判断是否有重复数据
if (fl_id != null && fl_id != "")
{
BasicBLL<tb_Station> s_db = new BasicBLL<tb_Station>();
var s_list = s_db.SearchAllInfo().Where(p => p.LineID == fl_id).ToList();//判断是否有重复数据
if (s_list.Count > 0)
{
string[] arr = s_list.Select(p => p.StationID).ToArray();
list = list.Where(p => arr.Contains(p.StationID)).ToList();
foreach (var item in list)
{
item.DeviceName = item.DeviceNo + "----" + item.DeviceName;
}
jsonStr = JSONTools.ScriptSerialize<List<tb_Device>>(list);
return jsonStr;
}
}
return "";
}
catch (Exception)
{
return "";
}
}
public string QueryForComboboxByStationID(string fl_id)
{
try
{
string jsonStr = "[]";
if (fl_id != null && fl_id != "")
{
var list = db.SearchAllInfo().Where(p => p.StationID == fl_id).ToList();//判断是否有重复数据
foreach (var item in list)
{
item.DeviceName = item.DeviceNo + "----" + item.DeviceName;
}
jsonStr = JSONTools.ScriptSerialize<List<tb_Device>>(list);
return jsonStr;
}
return "";
}
catch (Exception)
{
return "";
}
}
}
}

148
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/FactoryBLL.cs

@ -0,0 +1,148 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.BasicInfo
{
public class FactoryBLL
{
BasicBLL<tb_Factory> db = new BasicBLL<tb_Factory>();
/// <summary>
/// 查询信息
/// </summary>
/// <returns></returns>
public string SearchInfo(string page, string pagesize, string FactoryName)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Factory> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(FactoryName))
{
list = list.Where(p => p.FactoryName.Contains(FactoryName)).ToList();//按条件分页查询
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<tb_Factory> md = new JsonDataModel<tb_Factory>();
md.total = total.ToString();
md.rows = list;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<tb_Factory>>(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
/// <summary>
/// 添加信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool AddInfo(tb_Factory md)
{
try
{
var list = db.SearchInfoByKey("FactoryName", md.FactoryName);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.FactoryID != md.FactoryID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool UpdateInfo(tb_Factory md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.FactoryName == md.FactoryName && p.FactoryID != md.FactoryID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[2];
proNames[0] = "FactoryName";
proNames[1] = "Des";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// 删除生产线信息
public bool DelInfo(tb_Factory md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize<List<tb_Factory>>(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
}
}

141
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ImgVideoBLL.cs

@ -0,0 +1,141 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace MESClassLibrary.BLL.BasicInfo
{
public class ImgVideoBLL
{
BBMPTEntities ef = new BBMPTEntities();
BasicBLL<tb_ImgVideo> db = new BasicBLL<tb_ImgVideo>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_ImgVideo md)
{
try
{
var list = db.SearchInfoByKey("fileName", md.fileName);//判断是否有重复数据
if (list != null)
{
return false;
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_ImgVideo md)
{
try
{
//初始化要更新的字段
string[] proNames = new string[3];
proNames[0] = "fileUrl";
proNames[1] = "fileName";
proNames[2] = "UpdateTime";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_ImgVideo md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_ImgVideo> list = ef.tb_ImgVideo.OrderByDescending(p=>p.CreateTime).ToList();
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<tb_ImgVideo> md = new JsonDataModel<tb_ImgVideo>();
md.total = total.ToString();
md.rows = list;
return JSONTools.ScriptSerialize(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_ImgVideo SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

391
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/InjectionPlanBLL.cs

@ -0,0 +1,391 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using MESClassLibrary.DAL.BasicInfo;
namespace MESClassLibrary.BLL.BasicInfo
{
public class InjectionPlanBLL
{
BBMPTEntities ef = new BBMPTEntities();
BasicBLL<tb_InjectionPlan> db = new BasicBLL<tb_InjectionPlan>();
InjectionPlanDAL dal = new InjectionPlanDAL();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_InjectionPlan md)
{
try
{
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_InjectionPlan md)
{
try
{
//初始化要更新的字段
string[] proNames = new string[8];
proNames[0] = "StationID";
proNames[1] = "BeginTime";
proNames[2] = "StockNo";
proNames[3] = "PlanCount";
proNames[4] = "EndTime";
proNames[5] = "PlanDate";
proNames[6] = "RealCycle";
proNames[7] = "PartNo";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_InjectionPlan md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string stationID, string stockNo)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_InjectionPlan> list = db.SearchAllInfo().Where(p => p.IsFinish != 1).ToList();
if (!String.IsNullOrEmpty(stationID))
{
list = list.Where(p => p.StationID.Equals(stationID)).ToList();
}
if (!String.IsNullOrEmpty(stockNo))
{
list = list.Where(p => p.StockNo.Contains(stockNo)).ToList();
}
list = list.OrderBy(p => p.BeginTime).ToList();
List<InjectionPlanModel> modelList = new List<InjectionPlanModel>();
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
#region 联查
BasicBLL<tb_Product> product_db = new BasicBLL<tb_Product>();
var product_list = product_db.SearchAllInfo();
BasicBLL<tb_Station> station_db = new BasicBLL<tb_Station>();
var station_list = station_db.SearchAllInfo();
foreach (var item in list)
{
InjectionPlanModel dm = Tool.Mapper<InjectionPlanModel, tb_InjectionPlan>(item);
var product_info = product_list.FirstOrDefault(p => p.StockNo == item.StockNo);
if (product_info != null)
{
dm.PartNo = product_info.PartNo;
dm.ProductName = product_info.ProductName;
}
var station_info = station_list.FirstOrDefault(p => p.StationID == item.StationID);
if (station_info != null)
{
dm.StationNo = station_info.StationNo;
}
modelList.Add(dm);
}
#endregion
JsonDataModel<InjectionPlanModel> md = new JsonDataModel<InjectionPlanModel>();
md.total = total.ToString();
md.rows = modelList;
jsonStr = JSONTools.ScriptSerialize(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public string SearchInfoAll2(string page, string pagesize, string stationID, string stockNo, string StartTime, string EndTime)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
total = dal.SearchByTimeCount(stationID, stockNo, StartTime, EndTime);
DataTable dt = dal.SearchByTime(Convert.ToInt32(page), Convert.ToInt32(pagesize), stationID, stockNo, StartTime, EndTime);
List<tb_InjectionPlan> list = Tool.ConvertTo<tb_InjectionPlan>(dt).ToList();
//List<tb_InjectionPlan> list = ef.tb_InjectionPlan.Where(p => DateTime.Parse(p.BeginTime) >= stime && DateTime.Parse(p.EndTime) <= etime).ToList();
if (!String.IsNullOrEmpty(stationID))
{
list = list.Where(p => p.StationID.Equals(stationID)).ToList();
}
if (!String.IsNullOrEmpty(stockNo))
{
list = list.Where(p => p.StockNo.Contains(stockNo)).ToList();
}
list = list.OrderBy(p => p.BeginTime).ToList();
List<InjectionPlanModel> modelList = new List<InjectionPlanModel>();
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
#region 联查
BasicBLL<tb_Product> product_db = new BasicBLL<tb_Product>();
var product_list = product_db.SearchAllInfo();
BasicBLL<tb_Station> station_db = new BasicBLL<tb_Station>();
var station_list = station_db.SearchAllInfo();
foreach (var item in list)
{
InjectionPlanModel dm = Tool.Mapper<InjectionPlanModel, tb_InjectionPlan>(item);
var product_info = product_list.FirstOrDefault(p => p.StockNo == item.StockNo);
if (product_info != null)
{
dm.PartNo = product_info.PartNo;
dm.ProductName = product_info.ProductName;
}
var station_info = station_list.FirstOrDefault(p => p.StationID == item.StationID);
if (station_info != null)
{
dm.StationNo = station_info.StationNo;
}
modelList.Add(dm);
}
#endregion
JsonDataModel<InjectionPlanModel> md = new JsonDataModel<InjectionPlanModel>();
md.total = total.ToString();
md.rows = modelList;
jsonStr = JSONTools.ScriptSerialize(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdateInfo2(tb_InjectionPlan md)
{
try
{
//初始化要更新的字段
string[] proNames = new string[3];
proNames[0] = "workClass";
proNames[1] = "JK_Weight";
proNames[2] = "Waste_Weight";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息
/// </summary>
/// <returns></returns>
public List<tb_InjectionPlan> SearchAll()
{
try
{
var s_list = db.SearchAllInfo().ToList();
return s_list;
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_InjectionPlan SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public String GetEndTime(tb_InjectionPlan md)
{
try
{
BasicBLL<tb_Plastic> Plastic_db = new BasicBLL<tb_Plastic>();
var info = from c in Plastic_db.SearchAllInfo()
where c.StockNo == md.StockNo && c.StationID == md.StationID && c.IsBackup == 1
select c.CycleTime;
if (info.FirstOrDefault() != null)
{
double seconds = Convert.ToDouble(info.FirstOrDefault().Value) * Convert.ToDouble(md.PlanCount);
return Convert.ToDateTime(md.BeginTime).AddSeconds(seconds).ToString("yyyy-MM-dd HH:mm:ss");
}
return md.BeginTime;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByName(string StationID)
{
try
{
return dal.SearchPlanByStation(StationID);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable NextSearchInfoByName(string StationID)
{
try
{
return dal.NextSearchPlanByStation(StationID);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdateFinish(InjectionPlanModel md)
{
InjectionPlanDAL dal = new InjectionPlanDAL();
try
{
return dal.UpdateFinish(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string GetStartTime(string StationID)
{
var bf = db.SearchInfoByKey("StationID", StationID).OrderByDescending(p => p.EndTime).FirstOrDefault();
if (bf != null)
{
return bf.EndTime;
}
return "";
}
}
}

170
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/LineBLL.cs

@ -0,0 +1,170 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.BasicInfo
{
public class LineBLL
{
BasicBLL<tb_Line> db = new BasicBLL<tb_Line>();
/// <summary>
/// 查询信息
/// </summary>
/// <returns></returns>
public string SearchInfo(string page, string pagesize, string LineName, string PlaceID, string userID)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Line> list = db.SearchAllInfo();
//数据权限
//BasicBLL<T_Sys_Users> userdb = new BasicBLL<T_Sys_Users>();
//T_Sys_Users user = userdb.SearchInfoByID(userID);
//List<tb_Line> list = db.SearchInfoContains("LineName", user.Department);
if (!String.IsNullOrEmpty(PlaceID))
{
list = list.Where(p => p.PlaceID == PlaceID).ToList();//按条件分页查询
}
if (!String.IsNullOrEmpty(LineName))
{
list = list.Where(p => p.LineName.Contains(LineName)).ToList();//按条件分页查询
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
#region 联查
List<LineModel> ModelList = new List<LineModel>();
BasicBLL<tb_Place> p_db = new BasicBLL<tb_Place>();
var p_list = p_db.SearchAllInfo().ToList();
foreach (var item in list)
{
LineModel dm = Tool.Mapper<LineModel, tb_Line>(item);
var info = p_list.FirstOrDefault(p => p.PlaceID == item.PlaceID);
if (info != null)
{
dm.PlaceName = info.PlaceName;
}
ModelList.Add(dm);
}
#endregion
JsonDataModel<LineModel> md = new JsonDataModel<LineModel>();
md.total = total.ToString();
md.rows = ModelList;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<LineModel>>(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
/// <summary>
/// 添加信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool AddInfo(tb_Line md)
{
try
{
var list = db.SearchInfoByKey("LineName", md.LineName);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.LineID != md.LineID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool UpdateInfo(tb_Line md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.LineName == md.LineName && p.LineID != md.LineID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[3];
proNames[0] = "PlaceID";
proNames[1] = "LineName";
proNames[2] = "Des";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// 删除生产线信息
public bool DelInfo(tb_Line md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize<List<tb_Line>>(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
}
}

184
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/MachineBLL.cs

@ -0,0 +1,184 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.BasicInfo
{
public class MachineBLL
{
BasicBLL<tb_Machine> db = new BasicBLL<tb_Machine>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_Machine md)
{
try
{
var list = db.SearchInfoByKey("MachineNo", md.MachineNo);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.MachineID != md.MachineID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_Machine md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.MachineNo == md.MachineNo && p.MachineID != md.MachineID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[2];
proNames[0] = "MachineNo";
proNames[1] = "Des";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_Machine md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string machineNo)
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Machine> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(machineNo))
{
list = list.Where(p => p.MachineNo.Contains(machineNo)).ToList();
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<tb_Machine> md = new JsonDataModel<tb_Machine>();
md.total = total.ToString();
md.rows = list;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<tb_Machine>>(md);
}
return jsonStr;
}
/// <summary>
/// 查询全部信息
/// </summary>
/// <returns></returns>
public List<tb_Machine> SearchAll()
{
try
{
var s_list = db.SearchAllInfo().ToList();
return s_list;
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_Machine SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//下拉框查询方法
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().ToList();
jsonStr = JSONTools.ScriptSerialize<List<tb_Machine>>(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
}
}

208
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ModelInfoBLL.cs

@ -0,0 +1,208 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.BasicInfo
{
public class ModelInfoBLL
{
BasicBLL<tb_ModelInfo> db = new BasicBLL<tb_ModelInfo>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_ModelInfo md)
{
try
{
var list = db.SearchInfoByKey("ModelNo", md.ModelNo);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.ID != md.ID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_ModelInfo md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.ModelNo == md.ModelNo && p.ID != md.ID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[14];
proNames[0] = "ModelName";
proNames[1] = "ModelNo";
proNames[2] = "PermanentAssetsNo";
proNames[3] = "Tonnage";
proNames[4] = "ServiceLife";
proNames[5] = "Supplier";
proNames[6] = "PartWeight";
proNames[7] = "InjectionPeriod";
proNames[8] = "LocatingRingSize";
proNames[9] = "OutForm";
proNames[10] = "ModelWeight";
proNames[11] = "RunnerForm";
proNames[12] = "ModelCavityNo";
proNames[13] = "ModelSize";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_ModelInfo md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string ModelNo)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_ModelInfo> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(ModelNo))
{
list = list.Where(p => p.ModelNo.Contains(ModelNo)).ToList();
}
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<tb_ModelInfo> md = new JsonDataModel<tb_ModelInfo>();
md.total = total.ToString();
md.rows = list;
return JSONTools.ScriptSerialize(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_ModelInfo SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().OrderBy(p => p.ModelNo).ToList();//判断是否有重复数据
List<SelectModel> sl = new List<SelectModel>();
foreach (var item in list)
{
SelectModel md = new SelectModel();
md.textField = item.ModelName;
md.valueField = item.ID;
sl.Add(md);
}
jsonStr = JSONTools.ScriptSerialize(sl);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
//public DataTable SearchAll()
//{
// ColorDAL da = new ColorDAL();
// try
// {
// return da.SearchInfoAll();
// }
// catch (Exception ex)
// {
// LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
// return null;
// }
//}
}
}

137
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ModelUpdateBLL.cs

@ -0,0 +1,137 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.BasicInfo
{
public class ModelUpdateBLL
{
BasicBLL<tb_Model_Update> db = new BasicBLL<tb_Model_Update>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddUpdateInfo(tb_Model_Update md)
{
try
{
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_Model_Update md)
{
try
{
//初始化要更新的字段
string[] proNames = new string[5];
proNames[0] = "Purpose";
proNames[1] = "State";
proNames[2] = "Supplier";
proNames[3] = "Remarks";
proNames[4] = "AddTime";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_Model_Update md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string ModelID)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Model_Update> list = db.SearchInfoByKey("ModelID", ModelID).OrderByDescending(p => p.AddTime).ToList();
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<tb_Model_Update> md = new JsonDataModel<tb_Model_Update>();
md.total = total.ToString();
md.rows = list;
return JSONTools.ScriptSerialize(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_Model_Update SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

185
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/OperatorBLL.cs

@ -0,0 +1,185 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
using MESClassLibrary.DAL.BasicInfo;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
using MESClassLibrary.EFModel;
namespace MESClassLibrary.BLL.BasicInfo
{
public class OperatorBLL
{
BasicBLL<tb_Operator> db = new BasicBLL<tb_Operator>();
OperatorDAL dal = new OperatorDAL();
public DataTable SearchInfoByName(string OperatorName, string StationID)
{
try
{
return dal.SearchInfoByName(OperatorName, StationID);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByNameAndPsw(string OperatorName, string StationID, string psw)
{
try
{
return dal.SearchInfoByNameAndPsw(OperatorName, StationID, psw);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 查询信息
/// </summary>
/// <returns></returns>
public string SearchInfo(string page, string pagesize, string OperatorName, string StationID)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Operator> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(StationID))
{
list = list.Where(p => p.StationID.Equals(StationID)).ToList();//按条件分页查询
}
if (!String.IsNullOrEmpty(OperatorName))
{
list = list.Where(p => p.OperatorName.Contains(OperatorName)).ToList();//按条件分页查询
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
#region 联查
List<OperatorModel> StationList = new List<OperatorModel>();
BasicBLL<tb_Station> pl_db = new BasicBLL<tb_Station>();
var pl_list = pl_db.SearchAllInfo().ToList();
foreach (var item in list)
{
OperatorModel dm = Tool.Mapper<OperatorModel, tb_Operator>(item);
var info = pl_list.FirstOrDefault(p => p.StationID == item.StationID);
if (info != null)
{
dm.StationNo = info.StationNo;
}
StationList.Add(dm);
}
#endregion
JsonDataModel<OperatorModel> md = new JsonDataModel<OperatorModel>();
md.total = total.ToString();
md.rows = StationList;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<OperatorModel>>(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
/// <summary>
/// 添加信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool AddInfo(tb_Operator md)
{
try
{
var list = db.SearchInfoByKey("OperatorNo", md.OperatorNo);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.OperatorID != md.OperatorID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool UpdateInfo(tb_Operator md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.OperatorNo == md.OperatorNo && p.OperatorID != md.OperatorID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[5];
proNames[0] = "StationID";
proNames[1] = "OperatorNo";
proNames[2] = "OperatorName";
proNames[3] = "OperatorPsw";
proNames[4] = "Des";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// 删除生产线信息
public bool DelInfo(tb_Operator md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

335
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/PaintInfoBLL.cs

@ -0,0 +1,335 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.BasicInfo
{
public class PaintInfoBLL
{
BasicBLL<tb_Paint_Bucket> dbPB = new BasicBLL<tb_Paint_Bucket>();
BasicBLL<tb_PaintInfo> db = new BasicBLL<tb_PaintInfo>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_PaintInfo md)
{
try
{
var list = db.SearchInfoByKey("PaintCode", md.PaintCode);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.ID != md.ID && p.IsUsing == 1).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_PaintInfo md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.PaintCode == md.PaintCode && p.ID != md.ID && p.IsUsing == 1).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[5];
proNames[0] = "PaintCode";
proNames[1] = "PaintName";
proNames[2] = "PaintModel";
//proNames[3] = "UnitCode";
proNames[3] = "CarModelCode";
proNames[4] = "IsUsing";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_PaintInfo md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string PaintCode)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_PaintInfo> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(PaintCode))
{
list = list.Where(p => p.PaintCode.Contains(PaintCode)).ToList();
}
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<tb_PaintInfo> md = new JsonDataModel<tb_PaintInfo>();
md.total = total.ToString();
md.rows = list;
return JSONTools.ScriptSerialize(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_PaintInfo SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().ToList();//判断是否有重复数据
List<SelectModel> sl = new List<SelectModel>();
foreach (var item in list)
{
SelectModel md = new SelectModel();
md.textField = item.PaintCode + "--" + item.PaintName;
md.valueField = item.ID;
sl.Add(md);
}
jsonStr = JSONTools.ScriptSerialize(sl);
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
public string SearchRelation(string page, string pagesize, string PaintID, string BucketID)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Paint_Bucket> list = dbPB.SearchAllInfo();
if (!String.IsNullOrEmpty(PaintID))
{
list = list.Where(p => p.PaintID == PaintID).ToList();
}
if (!String.IsNullOrEmpty(BucketID))
{
list = list.Where(p => p.BucketID == BucketID).ToList();
}
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
List<Paint_BucketModel> modelList = new List<Paint_BucketModel>();
#region 联查
BasicBLL<tb_PaintInfo> PaintInfo_db = new BasicBLL<tb_PaintInfo>();
var PaintInfo_list = PaintInfo_db.SearchAllInfo();
BasicBLL<tb_BucketInfo> BucketInfo_db = new BasicBLL<tb_BucketInfo>();
var BucketInfo_list = BucketInfo_db.SearchAllInfo();
foreach (var item in list)
{
Paint_BucketModel dm = Tool.Mapper<Paint_BucketModel, tb_Paint_Bucket>(item);
var PaintInfo_info = PaintInfo_list.FirstOrDefault(p => p.ID == item.PaintID);
if (PaintInfo_info != null)
{
dm.PaintCode = PaintInfo_info.PaintCode;
dm.PaintName = PaintInfo_info.PaintName;
}
var BucketInfo_info = BucketInfo_list.FirstOrDefault(p => p.ID == item.BucketID);
if (BucketInfo_info != null)
{
dm.BucketCode = BucketInfo_info.BucketCode;
dm.BucketName = BucketInfo_info.BucketName;
}
modelList.Add(dm);
}
#endregion
JsonDataModel<Paint_BucketModel> md = new JsonDataModel<Paint_BucketModel>();
md.total = total.ToString();
md.rows = modelList;
return JSONTools.ScriptSerialize(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddRelation(tb_Paint_Bucket md)
{
try
{
var list = dbPB.SearchAllInfo().Where(p => p.PaintID == md.PaintID && p.BucketID == md.BucketID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
return dbPB.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateRelation(tb_Paint_Bucket md)
{
try
{
var list = dbPB.SearchAllInfo().Where(p => p.PaintID == md.PaintID && p.ID != md.ID && p.BucketID == md.BucketID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[2];
proNames[0] = "PaintID";
proNames[1] = "BucketID";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return dbPB.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool DeleteRelation(tb_Paint_Bucket md)
{
try
{
List<tb_Paint_Bucket> ef = dbPB.SearchInfoByKey("ID", md.ID);
if (ef!=null && ef.Count>0)
{
return dbPB.DelInfo(ef.First());
}
return false;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

165
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/PlaceBLL.cs

@ -0,0 +1,165 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.BasicInfo
{
public class PlaceBLL
{
BasicBLL<tb_Place> db = new BasicBLL<tb_Place>();
/// <summary>
/// 查询信息
/// </summary>
/// <returns></returns>
public string SearchInfo(string page, string pagesize, string PlaceName, string FactoryID)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Place> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(FactoryID))
{
list = list.Where(p => p.FactoryID == FactoryID).ToList();//按条件分页查询
}
if (!String.IsNullOrEmpty(PlaceName))
{
list = list.Where(p => p.PlaceName.Contains(PlaceName)).ToList();//按条件分页查询
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
#region 联查
List<PlaceModel> ModelList = new List<PlaceModel>();
BasicBLL<tb_Factory> p_db = new BasicBLL<tb_Factory>();
var p_list = p_db.SearchAllInfo().ToList();
foreach (var item in list)
{
PlaceModel dm = Tool.Mapper<PlaceModel, tb_Place>(item);
var info = p_list.FirstOrDefault(p => p.FactoryID == item.FactoryID);
if (info != null)
{
dm.FactoryName = info.FactoryName;
}
ModelList.Add(dm);
}
#endregion
JsonDataModel<PlaceModel> md = new JsonDataModel<PlaceModel>();
md.total = total.ToString();
md.rows = ModelList;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<PlaceModel>>(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
/// <summary>
/// 添加信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool AddInfo(tb_Place md)
{
try
{
var list = db.SearchInfoByKey("PlaceName", md.PlaceName);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.PlaceID != md.PlaceID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool UpdateInfo(tb_Place md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.PlaceName == md.PlaceName && p.PlaceID != md.PlaceID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[3];
proNames[0] = "FactoryID";
proNames[1] = "PlaceName";
proNames[2] = "Des";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// 删除生产线信息
public bool DelInfo(tb_Place md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize<List<tb_Place>>(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
}
}

238
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/PlasticBLL.cs

@ -0,0 +1,238 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.BasicInfo
{
public class PlasticBLL
{
BBMPTEntities ef = new BBMPTEntities();
BasicBLL<tb_Plastic> db = new BasicBLL<tb_Plastic>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_Plastic md)
{
try
{
var list = db.SearchInfoByKey("StationID", md.StationID);//判断是否有重复数据
if (list != null && list.Count > 0)
{
if (list.Where(p => p.StockNo.Equals(md.StockNo)).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_Plastic md)
{
try
{
//初始化要更新的字段
string[] proNames = new string[5];
proNames[0] = "CycleTime";
proNames[1] = "StationID";
proNames[2] = "IsBackup";
proNames[3] = "Weight";
proNames[4] = "OpenDebugTime";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_Plastic md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string stockNo, string partNo, string StationID)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Plastic> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(stockNo))
{
list = list.Where(p => p.StockNo != null && p.StockNo.Contains(stockNo)).ToList();
}
if (!String.IsNullOrEmpty(StationID))
{
list = list.Where(p => p.StationID.Equals(StationID)).ToList();
}
List<PlasticModel> modelList = new List<PlasticModel>();
if (list.Count > 0)
{
#region 联查
BasicBLL<tb_Product> product_db = new BasicBLL<tb_Product>();
var product_list = product_db.SearchAllInfo();
BasicBLL<tb_Station> machine_db = new BasicBLL<tb_Station>();
var machine_list = machine_db.SearchAllInfo();
foreach (var item in list)
{
PlasticModel dm = Tool.Mapper<PlasticModel, tb_Plastic>(item);
var product_info = product_list.FirstOrDefault(p => p.StockNo == item.StockNo);
if (product_info != null)
{
dm.PartNo = product_info.PartNo;
}
var machine_info = machine_list.FirstOrDefault(p => p.StationID == item.StationID);
if (machine_info != null)
{
dm.StationNo = machine_info.StationNo;
}
modelList.Add(dm);
}
#endregion
if (!String.IsNullOrEmpty(partNo))
{
modelList = modelList.Where(p => p.PartNo != null && p.PartNo.Contains(partNo)).ToList();
}
total = modelList.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
modelList = modelList.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<PlasticModel> md = new JsonDataModel<PlasticModel>();
md.total = total.ToString();
md.rows = modelList;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<PlasticModel>>(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 查询全部信息
/// </summary>
/// <returns></returns>
public List<tb_Plastic> SearchAll()
{
try
{
var s_list = db.SearchAllInfo().ToList();
return s_list;
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_Plastic SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public string QueryForCombobox(string StationID)
{
try
{
var info = from m in ef.tb_Plastic
join s in ef.tb_Product on m.StockNo equals s.StockNo into val2Grp
from grp in val2Grp.DefaultIfEmpty()
where m.StationID == StationID
select new { c_id = grp.StockNo, c_text = grp.PartNo + "--" + grp.ProductName, c_name = grp.StockNo + "--" + grp.ProductName };
string jsonStr = "[]";
jsonStr = JSONTools.ScriptSerialize(info);
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
}
}

443
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ProductBLL.cs

@ -0,0 +1,443 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using MESClassLibrary.DAL.BasicInfo;
namespace MESClassLibrary.BLL.BasicInfo
{
public class ProductBLL
{
BasicBLL<tb_Product> db = new BasicBLL<tb_Product>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_Product md)
{
try
{
var list = db.SearchInfoByKey("StockNo", md.StockNo);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.ProductID != md.ProductID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_Product md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.StockNo == md.StockNo && p.ProductID != md.ProductID && p.ProductID != md.ProductID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[10];
proNames[0] = "ProductTypeID";
proNames[1] = "PartName";
proNames[2] = "ProductName";
proNames[3] = "ColorName";
proNames[4] = "PartNo";
proNames[5] = "Rows";
proNames[6] = "Cols";
proNames[7] = "Layers";
proNames[8] = "Des";
proNames[9] = "isImport";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
md.PicturePath = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_Product md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string stockNo, string productTypeID, string productName, string partNo)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Product> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(stockNo))
{
list = list.Where(p => p.StockNo != null && p.StockNo.Contains(stockNo)).ToList();
}
if (!String.IsNullOrEmpty(productTypeID))
{
list = list.Where(p => p.ProductTypeID.Equals(productTypeID)).ToList();
}
if (!String.IsNullOrEmpty(productName))
{
list = list.Where(p => p.ProductName != null && p.ProductName.Contains(productName)).ToList();
}
if (!String.IsNullOrEmpty(partNo))
{
list = list.Where(p => p.PartNo != null && p.PartNo.Contains(partNo)).ToList();
}
List<ProductModel> modelList = new List<ProductModel>();
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
#region 联查
BasicBLL<tb_ProductType> s_db = new BasicBLL<tb_ProductType>();
var s_list = s_db.SearchAllInfo();
foreach (var item in list)
{
ProductModel dm = Tool.Mapper<ProductModel, tb_Product>(item);
var info = s_list.FirstOrDefault(p => p.ProductTypeID == item.ProductTypeID);
if (info != null)
{
dm.ProductTypeName = info.ProductTypeName;
}
modelList.Add(dm);
}
#endregion
JsonDataModel<ProductModel> md = new JsonDataModel<ProductModel>();
md.total = total.ToString();
md.rows = modelList;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<ProductModel>>(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 查询全部信息
/// </summary>
/// <returns></returns>
public List<tb_Product> SearchAll()
{
try
{
var s_list = db.SearchAllInfo().ToList();
return s_list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_Product SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public string GetComboboxData(string productTypeNo, string productTypeNo1)
{
try
{
string jsonStr = "[]";
BasicBLL<tb_ProductType> productTypeDB = new BasicBLL<tb_ProductType>();
if (productTypeNo1 != "")
{
var info = from m in db.SearchAllInfo().ToList()
join s in productTypeDB.SearchAllInfo().ToList() on m.ProductTypeID equals s.ProductTypeID into
val2Grp
from grp in val2Grp.DefaultIfEmpty()
where grp.ProductTypeNo == productTypeNo || grp.ProductTypeNo == productTypeNo1
select new {m.PartNo, PartName = m.PartNo + "----" + m.ProductName};
jsonStr = JSONTools.ScriptSerialize(info);
}
else
{
var info = from m in db.SearchAllInfo().ToList()
join s in productTypeDB.SearchAllInfo().ToList() on m.ProductTypeID equals s.ProductTypeID into
val2Grp
from grp in val2Grp.DefaultIfEmpty()
where grp.ProductTypeNo == productTypeNo
select new { m.PartNo, PartName = m.PartNo + "----" + m.ProductName };
jsonStr = JSONTools.ScriptSerialize(info);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
public string GetComboboxProduct(string productTypeNo)
{
try
{
BasicBLL<tb_ProductType> productTypeDB = new BasicBLL<tb_ProductType>();
var info = from m in db.SearchAllInfo().ToList()
join s in productTypeDB.SearchAllInfo().ToList() on m.ProductTypeID equals s.ProductTypeID into val2Grp
from grp in val2Grp.DefaultIfEmpty()
where grp.ProductTypeNo == productTypeNo
select new { m.ProductID, m.ProductName };
string jsonStr = "[]";
jsonStr = JSONTools.ScriptSerialize(info);
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
public string GetComboboxDataForStockNo(string productTypeNo)
{
try
{
BasicBLL<tb_ProductType> productTypeDB = new BasicBLL<tb_ProductType>();
var info = from m in db.SearchAllInfo().ToList()
join s in productTypeDB.SearchAllInfo().ToList() on m.ProductTypeID equals s.ProductTypeID into val2Grp
from grp in val2Grp.DefaultIfEmpty()
where grp.ProductTypeNo == productTypeNo
select new { c_id = m.StockNo, c_text = m.PartNo + "--" + m.ProductName, c_name = m.StockNo + "--" + m.ProductName, c_name2 = m.PartNo };
string jsonStr = "[]";
jsonStr = JSONTools.ScriptSerialize(info);
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
public DataTable SearchInfoByType(string type, string stationNo)
{
ProductDAL da = new ProductDAL();
try
{
return da.SearchInfoByType(type, stationNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoAllByType(string type)
{
ProductDAL da = new ProductDAL();
try
{
return da.SearchInfoAllByType(type);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByName(string productName, string ProductTypeNo)
{
ProductDAL da = new ProductDAL();
try
{
return da.SearchInfoByName(productName, ProductTypeNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByPartNo(string partNo)
{
ProductDAL da = new ProductDAL();
try
{
return da.SearchInfoByPartNo(partNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchIsImportByStockNo(string stockNo)
{
ProductDAL da = new ProductDAL();
try
{
return da.SearchIsImportByStockNo(stockNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByProductName(string ProductName)
{
ProductDAL da = new ProductDAL();
try
{
return da.SearchInfoByProductName(ProductName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdatePDF(string id, string fileName)
{
try
{
tb_Product md = new tb_Product();
md.ProductID = id;
md.PicturePath = fileName;
//初始化要更新的字段
string[] proNames = new string[1];
proNames[0] = "PicturePath";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchInfoAll()
{
ProductDAL da = new ProductDAL();
try
{
return da.SearchInfoAll();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByStock(string StockNo)
{
ProductDAL da = new ProductDAL();
try
{
return da.SearchInfoByStock(StockNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

83
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ProductOfInjectionBLL.cs

@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.BasicInfo;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.BasicInfo
{
public class ProductOfInjectionBLL
{
ProductOfInjectionDAL db=new ProductOfInjectionDAL();
public bool Add_Info(ProductOfInjectionModel md)
{
try
{
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchCountByInfo(string station, string date, string classname, string StockNo,string partno)
{
try
{
return db.SearchCountByInfo(station,date,classname,StockNo,partno);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool Update_Info(ProductOfInjectionModel md)
{
try
{
return db.UpdateInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateBad_Info(ProductOfInjectionModel md)
{
try
{
return db.UpdteBadInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool updateProductCount(ProductOfInjectionModel md)
{
try
{
return db.updateProductCount(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

182
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/ProductTypeBLL.cs

@ -0,0 +1,182 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.BasicInfo;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.BasicInfo
{
public class ProductTypeBLL
{
BasicBLL<tb_ProductType> db = new BasicBLL<tb_ProductType>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_ProductType md)
{
try
{
var list = db.SearchInfoByKey("ProductTypeNo", md.ProductTypeNo);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.ProductTypeID != md.ProductTypeID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_ProductType md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.ProductTypeNo == md.ProductTypeNo && p.ProductTypeID != md.ProductTypeID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[2];
proNames[0] = "ProductTypeName";
proNames[1] = "Des";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_ProductType md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_ProductType> list = db.SearchInfoAll(Convert.ToInt32(page), Convert.ToInt32(pagesize), out total);//按分页查询
JsonDataModel<tb_ProductType> md = new JsonDataModel<tb_ProductType>();
md.total = total.ToString();
md.rows = list;
return JSONTools.ScriptSerialize(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 查询全部信息
/// </summary>
/// <returns></returns>
public List<tb_ProductType> SearchAll()
{
try
{
var s_list = db.SearchAllInfo().ToList();
return s_list;
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_ProductType SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = db.SearchAllInfo().ToList();//判断是否有重复数据
foreach (var item in list)
{
item.ProductTypeName = item.ProductTypeNo + "----" + item.ProductTypeName;
}
jsonStr = JSONTools.ScriptSerialize<List<tb_ProductType>>(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
}
}

195
SjMes/PunchAssemble/MESClassLibrary/BLL/BasicInfo/StationBLL.cs

@ -0,0 +1,195 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using MESClassLibrary.DAL.BasicInfo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
namespace MESClassLibrary.BLL.BasicInfo
{
public class StationBLL
{
BasicBLL<tb_Station> db = new BasicBLL<tb_Station>();
/// <summary>
/// 查询信息
/// </summary>
/// <returns></returns>
public string SearchInfo(string page, string pagesize, string StationNo, string LineID)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Station> list = db.SearchAllInfo();
if (!String.IsNullOrEmpty(LineID))
{
list = list.Where(p => p.LineID == LineID).ToList();//按条件分页查询
}
if (!String.IsNullOrEmpty(StationNo))
{
list = list.Where(p => p.StationNo.Contains(StationNo)).ToList();//按条件分页查询
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
#region 联查
List<StationModel> StationList = new List<StationModel>();
BasicBLL<tb_Line> pl_db = new BasicBLL<tb_Line>();
var pl_list = pl_db.SearchAllInfo().ToList();
foreach (var item in list)
{
StationModel dm = Tool.Mapper<StationModel, tb_Station>(item);
var info = pl_list.FirstOrDefault(p => p.LineID == item.LineID);
if (info != null)
{
dm.LineName = info.LineName;
}
StationList.Add(dm);
}
#endregion
JsonDataModel<StationModel> md = new JsonDataModel<StationModel>();
md.total = total.ToString();
md.rows = StationList;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<StationModel>>(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
/// <summary>
/// 添加信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool AddInfo(tb_Station md)
{
try
{
var list = db.SearchInfoByKey("StationNo", md.StationNo);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.StationID != md.StationID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md">生产线模型对象</param>
/// <returns></returns>
public bool UpdateInfo(tb_Station md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.StationNo == md.StationNo && p.StationID != md.StationID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[3];
proNames[0] = "LineID";
proNames[1] = "StationNo";
proNames[2] = "Des";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// 删除生产线信息
public bool DelInfo(tb_Station md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string GetComboboxData(string StationNo)
{
try
{
string jsonStr = "[]";
if (StationNo == null || StationNo == "")
{
var list = db.SearchAllInfo().ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize<List<tb_Station>>(list);
}
else
{
var list = db.SearchInfoContains("StationNo", StationNo).ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize<List<tb_Station>>(list);
}
return jsonStr;
}
catch (Exception)
{
return "";
}
}
public DataTable SearchInfoByNo(string station)
{
StationDAL db = new StationDAL();
try
{
return db.SearchInfoByNo(station);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

1506
SjMes/PunchAssemble/MESClassLibrary/BLL/Check/InspectResultBLL.cs

File diff suppressed because it is too large

29
SjMes/PunchAssemble/MESClassLibrary/BLL/ExchangeCenter/GetNewTasksBLL.cs

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.ExchangeCenter;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.ExchangeCenter
{
public class GetNewTasksBLL
{
public bool AddInfo(GetNewTasksModel md)
{
GetNewTasksDAL da = new GetNewTasksDAL();
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

29
SjMes/PunchAssemble/MESClassLibrary/BLL/ExchangeCenter/PartMstrBLL.cs

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.ExchangeCenter;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.ExchangeCenter
{
public class PartMstrBLL
{
public bool AddInfo(PartMstrModel md)
{
PartMstrDAL da = new PartMstrDAL();
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

29
SjMes/PunchAssemble/MESClassLibrary/BLL/ExchangeCenter/PartRecordBLL.cs

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.BasicInfo;
using MESClassLibrary.DAL.ExchangeCenter;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.ExchangeCenter
{
public class PartRecordBLL
{
public bool AddInfo(PartRecordModel md)
{
PartRecordDAL dal = new PartRecordDAL();
try
{
return dal.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

58
SjMes/PunchAssemble/MESClassLibrary/BLL/ExchangeCenter/TESBomBLL.cs

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.ExchangeCenter;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.ExchangeCenter
{
public class TESBomBLL
{
public bool AddInfo(TESBomModel md)
{
TESBomDAL da = new TESBomDAL();
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable Search()
{
TESBomDAL da=new TESBomDAL();
try
{
return da.Search();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool updateFlag(string TaskID)
{
TESBomDAL da = new TESBomDAL();
try
{
return da.UpdateFlag(TaskID);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

28
SjMes/PunchAssemble/MESClassLibrary/BLL/ExchangeCenter/TESPartDetBLL.cs

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.ExchangeCenter;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.ExchangeCenter
{
public class TESPartDetBLL
{
public bool AddInfo(TESPartDetModel md)
{
TESPartDetDAL da = new TESPartDetDAL();
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

29
SjMes/PunchAssemble/MESClassLibrary/BLL/Injection/DownReasonBLL.cs

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.Injection;
namespace MESClassLibrary.BLL.Injection
{
public class DownReasonBLL
{
DownReasonDAL da=new DownReasonDAL();
public DataTable SearchReason()
{
try
{
return da.SearchReason();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

891
SjMes/PunchAssemble/MESClassLibrary/BLL/Injection/InjectionDownRecordBLL.cs

@ -0,0 +1,891 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.Injection;
using MESClassLibrary.DAL.painting;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.Injection
{
public class InjectionDownRecordBLL
{
BBMPTEntities ef = new BBMPTEntities();
BasicBLL<tb_Injection_DownRecord> db = new BasicBLL<tb_Injection_DownRecord>();
InjectionDownRecordDAL dal = new InjectionDownRecordDAL();
public bool AddInfo(InjectionDownRecordModel md)
{
InjectionDownRecordDAL da = new InjectionDownRecordDAL();
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateInfo(InjectionDownRecordModel md)
{
InjectionDownRecordDAL da = new InjectionDownRecordDAL();
try
{
return da.UpdateInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
#region web用方法
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string StartTime, string EndTime, string StationID)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
DateTime stime = Convert.ToDateTime(StartTime);
DateTime etime = Convert.ToDateTime(EndTime);
List<tb_Injection_DownRecord> list = ef.tb_Injection_DownRecord.Where(p => p.StartTime >= stime && p.EndTime <= etime && p.DownTime >= 60).ToList();
if (!String.IsNullOrEmpty(StationID))
{
list = list.Where(p => p.StationID.Equals(StationID)).ToList();
}
List<Injection_DownRecordModel> modelList = new List<Injection_DownRecordModel>();
if (list.Count > 0)
{
#region 联查
BasicBLL<tb_Station> machine_db = new BasicBLL<tb_Station>();
var machine_list = machine_db.SearchAllInfo();
BasicBLL<tb_Inhection_DownReason> DownReason_db = new BasicBLL<tb_Inhection_DownReason>();
var DownReason_list = DownReason_db.SearchAllInfo();
BasicBLL<tb_Injection_DownType> DownType_db = new BasicBLL<tb_Injection_DownType>();
var DownType_list = DownType_db.SearchAllInfo();
foreach (var item in list)
{
Injection_DownRecordModel dm = Tool.Mapper<Injection_DownRecordModel, tb_Injection_DownRecord>(item);
var machine_info = machine_list.FirstOrDefault(p => p.StationID == item.StationID);
if (machine_info != null)
{
dm.StationNo = machine_info.StationNo;
}
var DownReason = DownReason_list.FirstOrDefault(p => p.ID == item.DownReason);
if (DownReason != null)
{
dm.DownReasonName = DownReason.Reason;
}
var DownType = DownType_list.FirstOrDefault(p => p.ID == item.DownType);
if (DownType != null)
{
dm.DownTypeName = DownType.DownTypeName;
}
modelList.Add(dm);
}
#endregion
total = modelList.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
modelList = modelList.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<Injection_DownRecordModel> md = new JsonDataModel<Injection_DownRecordModel>();
md.total = total.ToString();
md.rows = modelList;
jsonStr = JSONTools.ScriptSerialize(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdateInfo(tb_Injection_DownRecord md)
{
try
{
//初始化要更新的字段
string[] proNames = new string[8];
proNames[0] = "StationID";
proNames[1] = "DownType";
proNames[2] = "DownReason";
proNames[3] = "Des";
proNames[4] = "StartTime";
proNames[5] = "EndTime";
proNames[6] = "DownTime";
proNames[7] = "Remark1";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string GetComboboxDataByDownType()
{
try
{
string jsonStr = "[]";
var list = ef.tb_Injection_DownType.ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
public string GetComboboxDataByDownReason()
{
try
{
string jsonStr = "[]";
var list = ef.tb_Inhection_DownReason.ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
public bool UpdateData(List<DownRecordVO> list, string DownRecordID)
{
try
{
foreach (var item in list)
{
tb_Injection_DownRecord md = new tb_Injection_DownRecord();
md.ID = Guid.NewGuid().ToString();
md.StationID = item.StationID;
//md.PlanID = item.PlanID;
md.StartTime = Convert.ToDateTime(item.StartTime);
md.EndTime = Convert.ToDateTime(item.EndTime);
TimeSpan ts = md.EndTime.Value.Subtract(md.StartTime.Value);
md.DownTime = (int)ts.TotalSeconds;
md.DownType = item.DownType;
md.DownReason = item.DownReason;
md.Des = "";
md.Remark1 = item.Remark1;
md.Remark2 = "2";
db.AddInfo(md);
}
var info = ef.tb_Injection_DownRecord.FirstOrDefault(p => p.ID == DownRecordID);
info.Remark2 = "1";
ef.SaveChanges();
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
#endregion
#region 报表
//每日平均换膜次数
public string SearchDay(string StartTime)
{
try
{
DateTime sTime = Convert.ToDateTime(StartTime);
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(sTime.Year, sTime.Month);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchByTime(Convert.ToDateTime(sTime.Year + "-" + sTime.Month + "-01 08:00:00").ToString("yyyy-MM-dd HH:mm:ss"), Convert.ToDateTime(sTime.Year + "-" + sTime.Month + "-" + days.ToString() + " 07:59:59").AddDays(1).ToString("yyyy-MM-dd HH:mm:ss"));
if (dt != null && dt.Rows.Count > 0)
{
List<string> titleList = new List<string>();
List<double> Day_totalList = new List<double>();
List<double> Night_totalList = new List<double>();
for (int i = 0; i < days; i++)
{
titleList.Add((i + 1).ToString());
DateTime dtime = Convert.ToDateTime(sTime.Year + "-" + sTime.Month + "-" + (i + 1));
//白班
var DayList = from myRow in dt.AsEnumerable()
where myRow.Field<DateTime>(5) >= Convert.ToDateTime(dtime.ToString("yyyy-MM-dd") + " 08:00:00.000") &&
myRow.Field<DateTime>(6) <= Convert.ToDateTime(dtime.ToString("yyyy-MM-dd") + " 19:59:59.999")
select myRow;
if (DayList.Count() > 0)
{
int Day_int = DayList.Sum(p => Convert.ToInt32(p.ItemArray[7]));
Day_totalList.Add(Math.Round((Day_int / (double)DayList.Count()) / 60, 2));
}
else
{
Day_totalList.Add(0);
}
//夜班
var NightList = from myRowNight in dt.AsEnumerable()
where myRowNight.Field<DateTime>(5) >= Convert.ToDateTime(dtime.ToString("yyyy-MM-dd") + " 20:00:00.000") &&
myRowNight.Field<DateTime>(6) <= Convert.ToDateTime(dtime.AddDays(1).ToString("yyyy-MM-dd") + " 07:59:59.999")
select myRowNight;
if (NightList.Count() > 0)
{
int Night_int = NightList.Sum(p => Convert.ToInt32(p.ItemArray[7]));
Night_totalList.Add(Math.Round((Night_int / (double)NightList.Count()) / 60, 2));
}
else
{
Night_totalList.Add(0);
}
}
sb.Append("<table border='1'>");
sb.Append("<tr>");
sb.Append("<td width='50'>班次/日期</td>");
foreach (var item in titleList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td width='100'>白班</td>");
foreach (var item in Day_totalList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td width='100'>夜班</td>");
foreach (var item in Night_totalList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("</table>");
}
return sb.ToString();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//每日平均换膜次数导出excel
public List<List<string>> SearchDayForExcel(string StartTime)
{
try
{
List<List<string>> list = new List<List<string>>();
DateTime sTime = Convert.ToDateTime(StartTime);
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(sTime.Year, sTime.Month);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchByTime(Convert.ToDateTime(sTime.Year + "-" + sTime.Month + "-01 08:00:00").ToString("yyyy-MM-dd HH:mm:ss"), Convert.ToDateTime(sTime.Year + "-" + sTime.Month + "-" + days.ToString() + " 07:59:59").AddDays(1).ToString("yyyy-MM-dd HH:mm:ss"));
if (dt != null && dt.Rows.Count > 0)
{
List<string> titleList = new List<string>();
List<double> Day_totalList = new List<double>();
List<double> Night_totalList = new List<double>();
for (int i = 0; i < days; i++)
{
titleList.Add((i + 1).ToString());
DateTime dtime = Convert.ToDateTime(sTime.Year + "-" + sTime.Month + "-" + (i + 1));
//白班
var DayList = from myRow in dt.AsEnumerable()
where myRow.Field<DateTime>(5) >= Convert.ToDateTime(dtime.ToString("yyyy-MM-dd") + " 08:00:00.000") &&
myRow.Field<DateTime>(6) <= Convert.ToDateTime(dtime.ToString("yyyy-MM-dd") + " 19:59:59.999")
select myRow;
if (DayList.Count() > 0)
{
int Day_int = DayList.Sum(p => Convert.ToInt32(p.ItemArray[7]));
Day_totalList.Add(Math.Round((Day_int / (double)DayList.Count()) / 60, 2));
}
else
{
Day_totalList.Add(0);
}
//夜班
var NightList = from myRowNight in dt.AsEnumerable()
where myRowNight.Field<DateTime>(5) >= Convert.ToDateTime(dtime.ToString("yyyy-MM-dd") + " 20:00:00.000") &&
myRowNight.Field<DateTime>(6) <= Convert.ToDateTime(dtime.AddDays(1).ToString("yyyy-MM-dd") + " 07:59:59.999")
select myRowNight;
if (NightList.Count() > 0)
{
int Night_int = NightList.Sum(p => Convert.ToInt32(p.ItemArray[7]));
Night_totalList.Add(Math.Round((Night_int / (double)NightList.Count()) / 60, 2));
}
else
{
Night_totalList.Add(0);
}
}
List<string> title_ = new List<string>();
title_.Add("班次/日期");
title_.AddRange(titleList);
list.Add(title_);
List<string> total_ = new List<string>();
total_.Add("白班");
foreach (var item in Day_totalList)
{
total_.Add(item.ToString());
}
list.Add(total_);
List<string> No_total_ = new List<string>();
No_total_.Add("夜班");
foreach (var item in Night_totalList)
{
No_total_.Add(item.ToString());
}
list.Add(No_total_);
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//每月平均换膜次数
public string SearchMonth(string StartTime)
{
try
{
DateTime sTime = Convert.ToDateTime(StartTime);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchByTime(sTime.Year + "-01-01", sTime.Year + "-12-31");
if (dt != null && dt.Rows.Count > 0)
{
DateTime startT = Convert.ToDateTime(sTime.Year + "-01-01");
List<string> titleList = new List<string>();
List<double> Day_totalList = new List<double>();
for (int i = 0; i < 12; i++)
{
titleList.Add((i + 1) + "月");
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(startT.Year, (i + 1));
var DayList = from myRow in dt.AsEnumerable()
where myRow.Field<DateTime>(5) >= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-01") &&
myRow.Field<DateTime>(6) <= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-" + days)
select myRow;
if (DayList.Count() > 0)
{
int Day_int = DayList.Sum(p => Convert.ToInt32(p.ItemArray[7]));
Day_totalList.Add(Math.Round((Day_int / (double)DayList.Count()) / 60, 2));
}
else
{
Day_totalList.Add(0);
}
}
sb.Append("<table border='1'>");
sb.Append("<tr>");
sb.Append("<td width='50'>月份</td>");
foreach (var item in titleList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td width='100'>平均换膜时间</td>");
foreach (var item in Day_totalList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("</table>");
}
return sb.ToString();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public List<List<string>> SearchMonthForExcel(string StartTime)
{
try
{
List<List<string>> list = new List<List<string>>();
DateTime sTime = Convert.ToDateTime(StartTime);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchByTime(sTime.Year + "-01-01", sTime.Year + "-12-31");
if (dt != null && dt.Rows.Count > 0)
{
DateTime startT = Convert.ToDateTime(sTime.Year + "-01-01");
List<string> titleList = new List<string>();
List<double> Day_totalList = new List<double>();
for (int i = 0; i < 12; i++)
{
titleList.Add((i + 1) + "月");
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(startT.Year, (i + 1));
var DayList = from myRow in dt.AsEnumerable()
where myRow.Field<DateTime>(5) >= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-01") &&
myRow.Field<DateTime>(6) <= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-" + days)
select myRow;
if (DayList.Count() > 0)
{
int Day_int = DayList.Sum(p => Convert.ToInt32(p.ItemArray[7]));
Day_totalList.Add(Math.Round((Day_int / (double)DayList.Count()) / 60, 2));
}
else
{
Day_totalList.Add(0);
}
}
List<string> title_ = new List<string>();
title_.Add("月份");
title_.AddRange(titleList);
list.Add(title_);
List<string> total_ = new List<string>();
total_.Add("平均换膜时间");
foreach (var item in Day_totalList)
{
total_.Add(item.ToString());
}
list.Add(total_);
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//每月换膜次数
public string SearchMonthTimes(string StartTime)
{
try
{
DateTime sTime = Convert.ToDateTime(StartTime);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchByTime(sTime.Year + "-01-01", sTime.Year + "-12-31");
if (dt != null && dt.Rows.Count > 0)
{
DateTime startT = Convert.ToDateTime(sTime.Year + "-01-01");
List<string> titleList = new List<string>();
List<double> Day_totalList = new List<double>();
for (int i = 0; i < 12; i++)
{
titleList.Add((i + 1) + "月");
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(startT.Year, (i + 1));
var DayList = from myRow in dt.AsEnumerable()
where myRow.Field<DateTime>(5) >= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-01") &&
myRow.Field<DateTime>(6) <= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-" + days)
select myRow;
Day_totalList.Add(DayList.Count());
}
sb.Append("<table border='1'>");
sb.Append("<tr>");
sb.Append("<td width='50'>月份</td>");
foreach (var item in titleList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td width='100'>换模次数</td>");
foreach (var item in Day_totalList)
{
sb.Append("<td width='50'>" + item + "</td>");
}
sb.Append("</tr>");
sb.Append("</table>");
}
return sb.ToString();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public List<List<string>> SearchMonthTimesForExcel(string StartTime)
{
try
{
List<List<string>> list = new List<List<string>>();
DateTime sTime = Convert.ToDateTime(StartTime);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchByTime(sTime.Year + "-01-01", sTime.Year + "-12-31");
if (dt != null && dt.Rows.Count > 0)
{
DateTime startT = Convert.ToDateTime(sTime.Year + "-01-01");
List<string> titleList = new List<string>();
List<double> Day_totalList = new List<double>();
for (int i = 0; i < 12; i++)
{
titleList.Add((i + 1) + "月");
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(startT.Year, (i + 1));
var DayList = from myRow in dt.AsEnumerable()
where myRow.Field<DateTime>(5) >= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-01") &&
myRow.Field<DateTime>(6) <= Convert.ToDateTime(sTime.Year + "-" + (i + 1) + "-" + days)
select myRow;
Day_totalList.Add(DayList.Count());
}
List<string> title_ = new List<string>();
title_.Add("月份");
title_.AddRange(titleList);
list.Add(title_);
List<string> total_ = new List<string>();
total_.Add("换模次数");
foreach (var item in Day_totalList)
{
total_.Add(item.ToString());
}
list.Add(total_);
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//换膜记录单
public string SearchChangeRecord(string StartTime, string EndTime, string ModelId)
{
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchChangeRecord(StartTime, EndTime, ModelId);
sb.Append("<table border='1'>");
sb.Append("<tr>");
sb.Append("<td width='50'>机台号</td>");
sb.Append("<td width='50'>日期</td>");
sb.Append("<td width='50'>起始时间</td>");
sb.Append("<td width='50'>总计时间</td>");
sb.Append("<td width='50'>累计合模数</td>");
sb.Append("<td width='50'>生产合模数</td>");
sb.Append("<td width='50'>日期章</td>");
sb.Append("<td width='50'>换膜人</td>");
sb.Append("</tr>");
for (int i = 0; i < dt.Rows.Count; i++)
{
sb.Append("<tr>");
sb.Append("<td width='50'>" + dt.Rows[i]["StationNo"] + "</td>");
sb.Append("<td width='50'>" + Convert.ToDateTime(dt.Rows[i]["PrintDate"]).ToString("yyyy-MM-dd") + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["StartTime"] + "</td>");
sb.Append("<td width='50'>" + Math.Round((Convert.ToDouble(dt.Rows[i]["DownTime"]) / 60), 2) + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["ModelSumCount"] + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["ModelPrintCount"] + "</td>");
sb.Append("<td width='50'>" + Convert.ToDateTime(dt.Rows[i]["PrintDate"]).Month + "月</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["remark1"] + "</td>");
sb.Append("</tr>");
}
sb.Append("</table>");
return sb.ToString();
}
public List<List<string>> SearchChangeRecordForExcel(string StartTime, string EndTime, string ModelId)
{
try
{
List<List<string>> list = new List<List<string>>();
DataTable dt = dal.SearchChangeRecord(StartTime, EndTime, ModelId);
List<string> titleList = new List<string>();
titleList.Add("机台号");
titleList.Add("日期");
titleList.Add("起始时间");
titleList.Add("总计时间");
titleList.Add("累计合模数");
titleList.Add("生产合模数");
titleList.Add("日期章");
titleList.Add("换膜人");
list.Add(titleList);
for (int i = 0; i < dt.Rows.Count; i++)
{
List<string> total_ = new List<string>();
total_.Add(dt.Rows[i]["StationNo"].ToString());
total_.Add(Convert.ToDateTime(dt.Rows[i]["PrintDate"]).ToString("yyyy-MM-dd"));
total_.Add(dt.Rows[i]["StartTime"].ToString());
total_.Add(Math.Round((Convert.ToDouble(dt.Rows[i]["DownTime"]) / 60), 2).ToString());
total_.Add(dt.Rows[i]["ModelSumCount"].ToString());
total_.Add(dt.Rows[i]["ModelPrintCount"].ToString());
total_.Add(Convert.ToDateTime(dt.Rows[i]["PrintDate"]).Month + "月</td>");
total_.Add(dt.Rows[i]["remark1"].ToString());
list.Add(total_);
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//维修记录
public string SearchRepairRecord(string StartTime, string EndTime)
{
try
{
DateTime sTime = Convert.ToDateTime(StartTime);
StringBuilder sb = new StringBuilder(100);
DataTable dt = dal.SearchRepaorByTime(StartTime, EndTime);
sb.Append("<table border='1'>");
sb.Append("<tr>");
sb.Append("<td width='50'>序号</td>");
sb.Append("<td width='50'>日期</td>");
sb.Append("<td width='50'>班次</td>");
sb.Append("<td width='50'>设备名称</td>");
sb.Append("<td width='50'>故障现象</td>");
sb.Append("<td width='50'>维修时间</td>");
sb.Append("<td width='50'>故障原因</td>");
sb.Append("<td width='100'>维修内容及更换配件</td>");
sb.Append("<td width='50'>维修人</td>");
sb.Append("</tr>");
if (dt != null && dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
sb.Append("<tr>");
sb.Append("<td width='50'>" + (i + 1) + "</td>");
sb.Append("<td width='50'>" + Convert.ToDateTime(dt.Rows[i]["StartTime"]).ToString("yyyy-MM-dd") + "</td>");
sb.Append("<td width='50'>" + CheckWorkClass(dt.Rows[i]["StartTime"].ToString()) + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["StationNo"] + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["Des"] + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["DownTime"] + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["Remark2"] + "</td>");
sb.Append("<td width='100'>" + dt.Rows[i]["Remark3"] + "</td>");
sb.Append("<td width='50'>" + dt.Rows[i]["Remark1"] + "</td>");
sb.Append("</tr>");
}
}
sb.Append("</table>");
return sb.ToString();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public List<List<string>> SearchRepairRecordForExcel(string StartTime, string EndTime)
{
try
{
List<List<string>> list = new List<List<string>>();
DataTable dt = dal.SearchRepaorByTime(StartTime, EndTime);
List<string> titleList = new List<string>();
titleList.Add("序号");
titleList.Add("日期");
titleList.Add("班次");
titleList.Add("设备名称");
titleList.Add("故障现象");
titleList.Add("维修时间");
titleList.Add("故障原因");
titleList.Add("维修内容及更换配件");
titleList.Add("维修人");
list.Add(titleList);
for (int i = 0; i < dt.Rows.Count; i++)
{
List<string> total_ = new List<string>();
total_.Add((i + 1).ToString());
total_.Add(Convert.ToDateTime(dt.Rows[i]["StartTime"]).ToString("yyyy-MM-dd"));
total_.Add(CheckWorkClass(dt.Rows[i]["StartTime"].ToString()));
total_.Add(dt.Rows[i]["StationNo"].ToString());
total_.Add(dt.Rows[i]["Des"].ToString());
total_.Add(dt.Rows[i]["DownTime"].ToString());
total_.Add(dt.Rows[i]["Remark2"].ToString());
total_.Add(dt.Rows[i]["Remark3"].ToString());
total_.Add(dt.Rows[i]["Remark1"].ToString());
list.Add(total_);
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
private string CheckWorkClass(string StartTime)
{
try
{
if (true)
{
string time = StartTime.Substring(0, StartTime.IndexOf(" "));
if (DateTime.Compare(Convert.ToDateTime(StartTime), Convert.ToDateTime(time + " 08:00:00")) > 0 && DateTime.Compare(Convert.ToDateTime(time + " 19:59:59"), Convert.ToDateTime(StartTime)) > 0)
{
return "A";
}
return "B";
}
}
catch (Exception ex)
{
}
return "";
}
#endregion
}
}

1979
SjMes/PunchAssemble/MESClassLibrary/BLL/Injection/InjectionRecordBLL.cs

File diff suppressed because it is too large

596
SjMes/PunchAssemble/MESClassLibrary/BLL/Inspection/CommonlyInspectionBLL.cs

@ -0,0 +1,596 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.Inspection
{
public class CommonlyInspectionBLL
{
BasicBLL<tb_CommonlyInspection> db = new BasicBLL<tb_CommonlyInspection>();
/// <summary>
/// 查询信息
/// </summary>
/// <returns></returns>
public string SearchInfo(string versionID, string checkDate)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_CommonlyInspection> list = null;
list = db.SearchInfoByKey("IsUseing", 1).Where(p => p.VersionID.Equals(versionID)).ToList();
if (list.Count > 0)
{
BasicBLL<tb_CheckItem> CheckItem_db = new BasicBLL<tb_CheckItem>();
var CheckItemList = CheckItem_db.SearchAllInfo().ToList();
List<CommonlyInspectionModel> CommonlyInspectionList = new List<CommonlyInspectionModel>();
foreach (var item in list)
{
CommonlyInspectionModel dm = Tool.Mapper<CommonlyInspectionModel, tb_CommonlyInspection>(item);
dm.InspectionContent = CheckItemList.FirstOrDefault(p => p.ID == item.InspectionContentID).CheckContent;
CommonlyInspectionList.Add(dm);
}
jsonStr = JSONTools.ScriptSerialize<List<CommonlyInspectionModel>>(CommonlyInspectionList);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
/// <summary>
/// 添加信息
/// </summary>
/// <returns></returns>
public bool AddInfo(string CommonlyInspection, string CheckUserID, string ConfirmUserID, string UserID, string CheckDate, string CheckType, string ErrMes)
{
try
{
BasicBLL<tb_CommonlyInspectionRecord> Recorddb = new BasicBLL<tb_CommonlyInspectionRecord>();
DateTime dtime = DateTime.Now;
DateTime checktime = Convert.ToDateTime(CheckDate);
string[] arr = CommonlyInspection.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < arr.Length - 1; i++)
{
int index = arr[i].IndexOf(":");
tb_CommonlyInspectionRecord md = new tb_CommonlyInspectionRecord();
md.ID = Guid.NewGuid().ToString();
md.CommonlyInspectionID = arr[i].Substring(0, index);
md.CheckResult = arr[i].Substring(index + 1, arr[i].Length - index - 1);
md.CheckUser = CheckUserID;
md.ConfirmUser = CheckUserID;
md.CreateUserID = UserID;
md.CheckDate = checktime;
md.CheckType = CheckType;
md.ErrMes = ErrMes;
md.ConfirmUserDate = dtime;
md.CreateTime = dtime;
md.IsUseing = 1;
Recorddb.AddInfo(md);
}
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateInfo(string CommonlyInspection, string CheckUserID, string ConfirmUserID, string UserID, string CheckDate, string CheckType, string ErrMes)
{
try
{
string[] proNames = new string[9];
proNames[0] = "CheckResult";
proNames[1] = "CheckUser";
proNames[2] = "CheckDate";
proNames[3] = "ConfirmUser";
proNames[4] = "ConfirmUserDate";
proNames[5] = "UpdateUserID";
proNames[6] = "UpdateTime";
proNames[7] = "CheckType";
proNames[8] = "ErrMes";
BasicBLL<tb_CommonlyInspectionRecord> Recorddb = new BasicBLL<tb_CommonlyInspectionRecord>();
DateTime dtime = DateTime.Now;
DateTime checktime = Convert.ToDateTime(CheckDate);
string[] arr = CommonlyInspection.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < arr.Length - 3; i++)
{
int index = arr[i].IndexOf(":");
tb_CommonlyInspectionRecord md = new tb_CommonlyInspectionRecord();
md.ID = arr[i].Substring(0, index);
md.CheckResult = arr[i].Substring(index + 1, arr[i].Length - index - 1);
md.CheckUser = CheckUserID;
md.CheckDate = checktime;
md.CheckType = CheckType;
md.ErrMes = ErrMes;
md.ConfirmUser = ConfirmUserID;
md.ConfirmUserDate = dtime;
md.UpdateUserID = UserID;
md.UpdateTime = dtime;
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
md.CreateUserID = "";
md.CommonlyInspectionID = "";
Recorddb.UpdateInfo(md, proNames);
}
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string GetDate(string VersionID, string CheckDate, string CheckType)
{
try
{
string str = "";
string CheckUserID = "";
string ConfirmUserID = "";
string ErrMes = "";
BasicBLL<tb_CommonlyInspection> db = new BasicBLL<tb_CommonlyInspection>();
string jsonStr = "[]";
List<tb_CommonlyInspection> list = null;
list = db.SearchInfoByKey("IsUseing", 1).Where(p => p.VersionID.Equals(VersionID)).ToList();
if (list.Count > 0)
{
BasicBLL<tb_CheckItem> CheckItem_db = new BasicBLL<tb_CheckItem>();
var CheckItemList = CheckItem_db.SearchAllInfo().ToList();
string[] arr_id = list.Select(s => s.ID).ToArray();
BasicBLL<tb_CommonlyInspectionRecord> CommonlyInspectionRecord_db = new BasicBLL<tb_CommonlyInspectionRecord>();
var _info = CommonlyInspectionRecord_db.SearchInfoByKey("CheckDate", Convert.ToDateTime(CheckDate)).Where(p => arr_id.Contains(p.CommonlyInspectionID) && p.CheckType.Equals(CheckType)).ToList();
if (_info.Count > 0)
{
#region 修改
List<CommonlyInspectionModel> CommonlyInspectionList = new List<CommonlyInspectionModel>();
foreach (var item in list)
{
CommonlyInspectionModel dm = Tool.Mapper<CommonlyInspectionModel, tb_CommonlyInspection>(item);
dm.InspectionContent = CheckItemList.FirstOrDefault(p => p.ID.Equals(item.InspectionContentID)).CheckContent;
CommonlyInspectionList.Add(dm);
}
str = "<table border='1' width='900' cellspacing='0' cellpadding='2' id='InspectionContentTable' name='1'>";
str += "<tr>";
str += "<td width='200'>点检内容</td>";
str += "<td width='200'>检查结果</td>";
str += "</tr>";
for (int j = 0; j < CommonlyInspectionList.Count; j++)
{
str += "<tr>";
str += "<td>" + CommonlyInspectionList[j].InspectionContent + "</td>";
var R_info = _info.FirstOrDefault(p => p.CommonlyInspectionID == CommonlyInspectionList[j].ID);
CheckUserID = R_info.CheckUser;
ConfirmUserID = R_info.ConfirmUser;
ErrMes = R_info.ErrMes;
switch (R_info.CheckResult)
{
case "0":
str += "<td><select class=\"easyui-combobox\" name='" + R_info.ID + "'><option value='1'>良好</option><option value='0' selected = 'selected'>故障</option><option value='2'>作业员调整后正常</option><option value='3'>需修理</option><option value='4'>确认修理完成</option></select></td>";
break;
case "1":
str += "<td><select class=\"easyui-combobox\" name='" + R_info.ID + "'><option value='1' selected = 'selected'>良好</option><option value='0'>故障</option><option value='2'>作业员调整后正常</option><option value='3'>需修理</option><option value='4'>确认修理完成</option></select></td>";
break;
case "2":
str += "<td><select class=\"easyui-combobox\" name='" + R_info.ID + "'><option value='1'>良好</option><option value='0'>故障</option><option value='2' selected = 'selected'>作业员调整后正常</option><option value='3'>需修理</option><option value='4'>确认修理完成</option></select></td>";
break;
case "3":
str += "<td><select class=\"easyui-combobox\" name='" + R_info.ID + "'><option value='1'>良好</option><option value='0'>故障</option><option value='2'>作业员调整后正常</option><option value='3' selected = 'selected'>需修理</option><option value='4'>确认修理完成</option></select></td>";
break;
case "4":
str += "<td><select class=\"easyui-combobox\" name='" + R_info.ID + "'><option value='1'>良好</option><option value='0'>故障</option><option value='2'>作业员调整后正常</option><option value='3'>需修理</option><option value='4' selected = 'selected'>确认修理完成</option></select></td>";
break;
}
str += "</tr>";
}
str += "<tr>";
str += "<td width='200'>异常情况描述</td>";
str += "<td><input class='easyui-textbox' id='ErrMes' value='" + ErrMes + "'/></td>";
str += "</tr>";
str += "</table>";
str += "<input id='CheckUserID' type='text' hidden='hidden' value='" + CheckUserID + "'/>";
str += "<input id='ConfirmUserID' type='text' hidden='hidden' value='" + ConfirmUserID + "'/>";
str += "<input id='InspectionContentFlag' type='text' hidden='hidden' value='1'/>";
#endregion
}
else
{
#region 新增
List<CommonlyInspectionModel> CommonlyInspectionList = new List<CommonlyInspectionModel>();
foreach (var item in list)
{
CommonlyInspectionModel dm = Tool.Mapper<CommonlyInspectionModel, tb_CommonlyInspection>(item);
dm.InspectionContent = CheckItemList.FirstOrDefault(p => p.ID.Equals(item.InspectionContentID)).CheckContent;
CommonlyInspectionList.Add(dm);
}
str = "<table border='1' width='900' cellspacing='0' cellpadding='2' id='InspectionContentTable' name='0'>";
str += "<tr>";
str += "<td width='200'>点检内容</td>";
str += "<td width='200'>检查结果</td>";
str += "</tr>";
for (int j = 0; j < CommonlyInspectionList.Count; j++)
{
str += "<tr>";
str += "<td>" + CommonlyInspectionList[j].InspectionContent + "</td>";
str += "<td><select class=\"easyui-combobox\" name='" + CommonlyInspectionList[j].ID + "'>" +
"<option value='1'>良好</option>" +
"<option value='0'>故障</option>" +
"<option value='2'>作业员调整后正常</option>" +
"<option value='3'>需修理</option>" +
"<option value='4'>确认修理完成</option>" +
"</select>" +
"</td>";
str += "</tr>";
}
str += "<tr>";
str += "<td width='200'>异常情况描述</td>";
str += "<td><input class='easyui-textbox' id='ErrMes' value=''/></td>";
str += "</tr>";
str += "</table>";
str += "<input id='InspectionContentFlag' type='text' hidden='hidden' value='0'/>";
#endregion
}
}
return str;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
public string GetReportDate(string VersionID, string CheckDate)
{
try
{
string str = "";
List<String> ErrMesList = new List<String>();
BasicBLL<T_Sys_Users> dbUser = new BasicBLL<T_Sys_Users>();
BasicBLL<tb_CommonlyInspection> db = new BasicBLL<tb_CommonlyInspection>();
string jsonStr = "[]";
List<tb_CommonlyInspection> list = null;
list = db.SearchInfoByKey("IsUseing", 1).Where(p => p.VersionID.Equals(VersionID)).ToList();
if (list.Count > 0)
{
BasicBLL<tb_CheckItem> CheckItem_db = new BasicBLL<tb_CheckItem>();
var CheckItemList = CheckItem_db.SearchAllInfo().ToList();
string[] arr_id = list.Select(s => s.ID).ToArray();
BasicBLL<tb_CommonlyInspectionRecord> CommonlyInspectionRecord_db = new BasicBLL<tb_CommonlyInspectionRecord>();
DateTime StartTime = Convert.ToDateTime(CheckDate + "-01 00:00:00");
DateTime EndTime = StartTime.AddMonths(1);
int daynum = GetDays(Convert.ToInt32(CheckDate.Substring(0, 4)), Convert.ToInt32(CheckDate.Substring(5, 2)));
var _info = CommonlyInspectionRecord_db.SearchInfoByKey("IsUseing", 1).Where(p => p.CheckDate >= StartTime && p.CheckDate < EndTime && arr_id.Contains(p.CommonlyInspectionID)).ToList();
var userList = dbUser.SearchAllInfo().ToList();
if (_info.Count > 0)
{
#region 有记录
List<CommonlyInspectionModel> CommonlyInspectionList = new List<CommonlyInspectionModel>();
foreach (var item in list)
{
CommonlyInspectionModel dm = Tool.Mapper<CommonlyInspectionModel, tb_CommonlyInspection>(item);
var IC_info = CheckItemList.FirstOrDefault(p => p.ID.Equals(item.InspectionContentID));
if (IC_info != null)
{
dm.InspectionContent = IC_info.CheckContent;
CommonlyInspectionList.Add(dm);
}
}
str = "<table border='1' cellspacing='0' cellpadding='5' id='InspectionContentTable' name='1' width='100%'>";
str += "<tr>";
str += "<td width='40'>序号</td>";
str += "<td width='250'>点检内容</td>";
for (int i = 1; i <= daynum; i++)
{
str += "<td width='30'>" + i + "</td>";
}
str += "</tr>";
var info = CommonlyInspectionList.ToList();
for (int j = 0; j < info.Count; j++)
{
str += "<tr>";
str += "<td rowspan='2'>" + (j + 1).ToString() + "</td>";
str += "<td rowspan='2'>" + info[j].InspectionContent + "</td>";
var R_info = _info.Where(p => p.CommonlyInspectionID == info[j].ID);
for (int k = 1; k <= daynum; k++)
{
DateTime dtime = StartTime.AddDays(k - 1);
var info_R = R_info.FirstOrDefault(p => p.CheckDate == dtime && p.CheckType.Equals("0"));
string CheckResult = "";
if (info_R != null)
{
if (!String.IsNullOrEmpty(info_R.ErrMes) && !ErrMesList.Contains(dtime.ToString("yyyy-MM-dd") + ":" + info_R.ErrMes))
{
ErrMesList.Add(dtime.ToString("yyyy-MM-dd") + ":" + info_R.ErrMes);
}
//select
switch (info_R.CheckResult)
{
case "0":
CheckResult = "▲";
break;
case "1":
CheckResult = "√";
break;
case "2":
CheckResult = "◎";
break;
case "3":
CheckResult = "X";
break;
case "4":
CheckResult = "☆";
break;
}
}
str += "<td width='30'>" + CheckResult + "</td>";
}
str += "</tr>";
str += "<tr>";
for (int k = 1; k <= daynum; k++)
{
DateTime dtime = StartTime.AddDays(k - 1);
var info_R = R_info.FirstOrDefault(p => p.CheckDate == dtime && p.CheckType.Equals("1"));
string CheckResult = "";
if (info_R != null)
{
//是否有异常记录并且没有加入到列表中
if (!String.IsNullOrEmpty(info_R.ErrMes) && !ErrMesList.Contains(dtime.ToString("yyyy-MM-dd") + ":" + info_R.ErrMes))
{
ErrMesList.Add(dtime.ToString("yyyy-MM-dd") + ":" + info_R.ErrMes);
}
switch (info_R.CheckResult)
{
case "0":
CheckResult = "▲";
break;
case "1":
CheckResult = "√";
break;
case "2":
CheckResult = "◎";
break;
case "3":
CheckResult = "X";
break;
case "4":
CheckResult = "☆";
break;
}
}
str += "<td width='30'>" + CheckResult + "</td>";
}
str += "</tr>";
}
str += "<tr>";
str += "<td rowspan='4'>日点检确认</td>";
str += "<td>点检人(白 班)确认签名</td>";
for (int i = 1; i <= daynum; i++)
{
DateTime dtime = StartTime.AddDays(i - 1);
var infoUser = _info.FirstOrDefault(p => p.CheckDate == dtime);
if (infoUser != null)
{
str += "<td width='30'>" + userList.FirstOrDefault(p => p.UserID.ToString().ToUpper().Equals(infoUser.CheckUser.ToUpper())).RealName + "</td>";
}
else
{
str += "<td width='30'></td>";
}
}
str += "</tr>";
str += "<tr>";
//str += "<td>日点检确认</td>";
str += "<td>点检人(夜 班)确认签名</td>";
for (int i = 1; i <= daynum; i++)
{
DateTime dtime = StartTime.AddDays(i - 1);
var infoUser = _info.FirstOrDefault(p => p.CheckDate == dtime);
if (infoUser != null)
{
str += "<td width='30'>" + userList.FirstOrDefault(p => p.UserID.ToString().ToUpper().Equals(infoUser.CheckUser.ToUpper())).RealName + "</td>";
}
else
{
str += "<td width='30'></td>";
}
}
str += "</tr>";
str += "<tr>";
//str += "<td>日点检确认</td>";
str += "<td>点检人(白班班长)确认签名</td>";
for (int i = 1; i <= daynum; i++)
{
DateTime dtime = StartTime.AddDays(i - 1);
var infoUser = _info.FirstOrDefault(p => p.CheckDate == dtime);
if (infoUser != null)
{
str += "<td width='30'>" + userList.FirstOrDefault(p => p.UserID.ToString().ToUpper().Equals(infoUser.ConfirmUser.ToUpper())).RealName + "</td>";
}
else
{
str += "<td width='30'></td>";
}
}
str += "</tr>";
str += "<tr>";
//str += "<td>日点检确认</td>";
str += "<td>点检人(夜班班长)确认签名</td>";
for (int i = 1; i <= daynum; i++)
{
DateTime dtime = StartTime.AddDays(i - 1);
var infoUser = _info.FirstOrDefault(p => p.CheckDate == dtime);
if (infoUser != null)
{
str += "<td width='30'>" + userList.FirstOrDefault(p => p.UserID.ToString().ToUpper().Equals(infoUser.ConfirmUser.ToUpper())).RealName + "</td>";
}
else
{
str += "<td width='30'></td>";
}
}
str += "</tr>";
str += "</table>";
if (ErrMesList.Count > 0)
{
#region 异常情况描述
str += "</table>";
str += "<table border='1' cellspacing='0' cellpadding='5' id='InspectionContentTable2' name='2' width='100%'>";
str += "<tr>";
str += "<td rowspan='" + ErrMesList.Count.ToString() + "' width='40'>异常情况描述</td>";
str += "<td>" + ErrMesList[0] + "</td>";
str += "</tr>";
for (int i = 1; i < ErrMesList.Count; i++)
{
str += "<tr>";
str += "<td>" + ErrMesList[i] + "</td>";
str += "</tr>";
}
str += "</table>";
#endregion
}
#endregion
}
else
{
#region 无记录
List<CommonlyInspectionModel> CommonlyInspectionList = new List<CommonlyInspectionModel>();
foreach (var item in list)
{
CommonlyInspectionModel dm = Tool.Mapper<CommonlyInspectionModel, tb_CommonlyInspection>(item);
var IC_info = CheckItemList.FirstOrDefault(p => p.ID.Equals(item.InspectionContentID));
if (IC_info != null)
{
dm.InspectionContent = IC_info.CheckContent;
CommonlyInspectionList.Add(dm);
}
}
str = "<table border='1' cellspacing='0' cellpadding='5' id='InspectionContentTable' name='1'>";
str += "<tr>";
str += "<td width='40'>序号</td>";
str += "<td width='250'>点检内容</td>";
for (int i = 1; i <= daynum; i++)
{
str += "<td width='30'>" + i + "</td>";
}
str += "</tr>";
var info = CommonlyInspectionList.ToList();
for (int j = 0; j < info.Count; j++)
{
str += "<tr>";
str += "<td rowspan='2'>" + (j + 1).ToString() + "</td>";
str += "<td rowspan='2'>" + info[j].InspectionContent + "</td>";
for (int k = 1; k <= daynum; k++)
{
str += "<td width='30'></td>";
}
str += "</tr>";
str += "<tr>";
for (int k = 1; k <= daynum; k++)
{
str += "<td width='30'></td>";
}
str += "</tr>";
}
#endregion
}
}
return str;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
public static int GetDays(int year, int month)
{
int days = 0;
if (month != 2)
{
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
days = 31;
break;
case 4:
case 6:
case 9:
case 11:
days = 30; break;
}
}
else
{
// 闰年
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
days = 29;
else
days = 28;
}
return days;
}
}
}

208
SjMes/PunchAssemble/MESClassLibrary/BLL/Inspection/CommonlyInspectionVersionBLL.cs

@ -0,0 +1,208 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.Inspection
{
public class CommonlyInspectionVersionBLL
{
BasicBLL<tb_CommonlyInspectionVersion> db = new BasicBLL<tb_CommonlyInspectionVersion>();
/// <summary>
/// 查询信息
/// </summary>
/// <returns></returns>
public string SearchInfo(string page, string pagesize,string deviceID)
{
try
{
BasicBLL<tb_Station> station_db = new BasicBLL<tb_Station>();
BasicBLL<tb_Device> device_db = new BasicBLL<tb_Device>();
var station_list = station_db.SearchAllInfo().ToList();
var device_list = device_db.SearchAllInfo().ToList();
string jsonStr = "[]";
int total = 0;//总行数
List<tb_CommonlyInspectionVersion> list = null;
list = db.SearchAllInfo().ToList();
if (deviceID != "")
{
list = list.Where(p => p.DeviceID.Equals(deviceID)).ToList();
}
List<CommonlyInspectionVersionModel> CommonlyInspectionVersionList = new List<CommonlyInspectionVersionModel>();
if (list.Count > 0)
{
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
total = list.Count;
#region 联查
foreach (var item in list)
{
CommonlyInspectionVersionModel dm = Tool.Mapper<CommonlyInspectionVersionModel, tb_CommonlyInspectionVersion>(item);
var info = device_list.FirstOrDefault(p => p.DeviceID.Equals(item.DeviceID));
if (info != null)
{
dm.DeviceID = info.DeviceID;
dm.DeviceName = info.DeviceNo + "----" + info.DeviceName;
}
if (item.IsUseing == 1)
{
dm.IsUseingName = "启用";
}
CommonlyInspectionVersionList.Add(dm);
}
#endregion
JsonDataModel<CommonlyInspectionVersionModel> md = new JsonDataModel<CommonlyInspectionVersionModel>();
md.total = total.ToString();
md.rows = CommonlyInspectionVersionList;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<CommonlyInspectionVersionModel>>(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
/// <summary>
/// 添加信息
/// </summary>
/// <param name="md">模型对象</param>
/// <returns></returns>
public bool AddInfo(tb_CommonlyInspectionVersion md, string s)
{
try
{
var list = db.SearchInfoByKey("DeviceID", md.DeviceID).Where(p => p.Version == md.Version).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
if (db.AddInfo(md))
{
BasicBLL<tb_CommonlyInspection> CommonlyInspection_db = new BasicBLL<tb_CommonlyInspection>();
string[] arry = s.Split(',');
for (int i = 0; i < arry.Length; i++)
{
tb_CommonlyInspection m = new tb_CommonlyInspection();
m.ID = Guid.NewGuid().ToString();
m.VersionID = md.ID;
m.InspectionContentID = arry[i];
m.CreateUserID = md.CreateUserID;
m.CreateTime = md.CreateTime;
m.IsUseing = 1;
CommonlyInspection_db.AddInfo(m);
}
return true;
}
return false;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md">模型对象</param>
/// <returns></returns>
public bool UpdateInfo(tb_CommonlyInspectionVersion md)
{
try
{
//var list = db.SearchInfoByKey("ProductionLineID", md.ProductionLineID).Where(p => p.DeviceNo == md.DeviceNo).ToList();//判断是否有重复数据
//if (list.Count > 0)
//{
// return false;
//}
////初始化要更新的字段
//string[] proNames = new string[6];
//proNames[0] = "ProductionLineID";
//proNames[1] = "DeviceNo";
//proNames[2] = "DeviceName";
//proNames[3] = "Description";
//proNames[4] = "UpdateUserID";
//proNames[5] = "UpdateTime";
////必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
////如果没有初始化必填字段,更新会报错
//md.CreateUserID = "";
//return db.UpdateInfo(md, proNames);
return false;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// 删除生产线信息
public bool DelInfo(tb_CommonlyInspectionVersion md)
{
try
{
////初始化要更新的字段
//string[] proNames = new string[3];
//proNames[0] = "IsUseing";
//proNames[1] = "DisableTime";
//proNames[2] = "DisableUserID";
////必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
////如果没有初始化必填字段,更新会报错
//md.ProductionLineID = 0;
//md.DeviceNo = "";
//md.DeviceName = "";
//md.CreateUserID = "";
//return db.UpdateInfo(md, proNames);
return false;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string GetComboboxData(string deviceID)
{
try
{
string jsonStr = "[]";
var list = db.SearchInfoByKey("IsUseing", 1).ToList();//判断是否有重复数据
if (deviceID != null && deviceID != "")
{
list = list.Where(p => p.DeviceID.Equals(deviceID)).ToList();
}
jsonStr = JSONTools.ScriptSerialize<List<tb_CommonlyInspectionVersion>>(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
}
}

100
SjMes/PunchAssemble/MESClassLibrary/BLL/Mistake247/AssemblyBLL.cs

@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.Mistake247;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.Mistake247
{
public class AssemblyBLL
{
public bool AddInfo(AssemblyModel md)
{
AssemblyDAL da = new AssemblyDAL();
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateInfo(AssemblyModel md)
{
AssemblyDAL da = new AssemblyDAL();
try
{
return da.UpdateInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchCount( string PartNo)
{
AssemblyDAL da = new AssemblyDAL();
try
{
return da.SearchCount(PartNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdatePrintFlag(AssemblyModel md)
{
AssemblyDAL da = new AssemblyDAL();
try
{
return da.UpdatePrintFlag(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdatePrintFlag1(string partno)
{
AssemblyDAL da = new AssemblyDAL();
try
{
return da.UpdatePrintFlag1(partno);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable searchPartNo(string partno)
{
AssemblyDAL da = new AssemblyDAL();
try
{
return da.searchPartNo(partno);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

86
SjMes/PunchAssemble/MESClassLibrary/BLL/Mistake247/BoxBLL.cs

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.Mistake247;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.Mistake247
{
public class BoxBLL
{
public bool AddInfo(BoxModel md)
{
BoxDAL da = new BoxDAL();
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchByNo(string PartNo, string BatchNo)
{
BoxDAL da = new BoxDAL();
try
{
return da.SearchByNo(PartNo, BatchNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdateInfo(BoxModel md)
{
BoxDAL da = new BoxDAL();
try
{
return da.UpdateInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable searchBox(string partno)
{
BoxDAL da = new BoxDAL();
try
{
return da.SearchBox(partno);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBoxIsExsit(string box)
{
BoxDAL da = new BoxDAL();
try
{
return da.SearchBoxIsExsit(box);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

72
SjMes/PunchAssemble/MESClassLibrary/BLL/Mistake247/MistakeBLL.cs

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.Mistake247;
using MESClassLibrary.DAL.painting;
namespace MESClassLibrary.BLL.Mistake247
{
public class MistakeBLL
{
public DataTable IsMath(string DeviceNo, string PartNo)
{
MistakeDAL da = new MistakeDAL();
try
{
return da.IsMath(DeviceNo, PartNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchByNo(string PartNo,string deviceNo)
{
MistakeDAL da = new MistakeDAL();
try
{
return da.SearchByNo(PartNo, deviceNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchPartName(string PartNo)
{
MistakeDAL da = new MistakeDAL();
try
{
return da.SearchPartName(PartNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchPartNoByDecice(string deviceNo)
{
MistakeDAL da = new MistakeDAL();
try
{
return da.SearchPartNoByDecice(deviceNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

101
SjMes/PunchAssemble/MESClassLibrary/BLL/Mistake247/Plan247BLL.cs

@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL;
using MESClassLibrary.DAL.Mistake247;
namespace MESClassLibrary.BLL.Mistake247
{
public class Plan247BLL
{
public DataTable SearhByOrderNo(string OrderNo)
{
Plan247DAL da = new Plan247DAL();
try
{
return da.SearhByOrderNo(OrderNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable DetailOrderNo(string OrderNo)
{
Plan247DAL da = new Plan247DAL();
try
{
return da.DetailOrderNo(OrderNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable IsHavePlan(string partNo1, string orderNo)
{
Plan247DAL da = new Plan247DAL();
try
{
return da.IsHavePlan(partNo1, orderNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearhCountByOrderNo(string OrderNo, string partNo)
{
Plan247DAL da = new Plan247DAL();
try
{
return da.SearhCountByOrderNo(OrderNo, partNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdateCount(string partNo, string orderNo)
{
Plan247DAL da = new Plan247DAL();
try
{
return da.UpdateCount(partNo, orderNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchPlanIDByOrderNo(string partNo, string orderNo)
{
Plan247DAL da = new Plan247DAL();
try
{
return da.SearchPlanIDByOrderNo(partNo, orderNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

171
SjMes/PunchAssemble/MESClassLibrary/BLL/Mistake247/RecordBLL.cs

@ -0,0 +1,171 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.Mistake247;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.Mistake247
{
public class RecordBLL
{
public DataTable SearchByPartNo1(string PartNo)
{
RecordDAL da = new RecordDAL();
try
{
return da.SearchByPartNo1(PartNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchCountByBox(string boxNo)
{
RecordDAL da = new RecordDAL();
try
{
return da.SearchCountByBox(boxNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool AddInfo(RecordModel md)
{
RecordDAL da = new RecordDAL();
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool updateBoxInfo(RecordModel md)
{
RecordDAL da = new RecordDAL();
try
{
return da.updateBoxInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchState(int type1,int type2,int type3)
{
RecordDAL da = new RecordDAL();
try
{
return da.SearchState(type1,type2,type3);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool DelInfo(RecordModel md)
{
RecordDAL da = new RecordDAL();
try
{
return da.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchBoxByPart(string part)
{
RecordDAL da = new RecordDAL();
try
{
return da.SearchBoxByPart(part);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchByPartNo2(string partno)
{
RecordDAL da = new RecordDAL();
try
{
return da.SearchByPartNo2(partno);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable GetCount(string part,string batch)
{
RecordDAL da = new RecordDAL();
try
{
return da.GetCount(part,batch);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable GetRecord(string boxNo)
{
RecordDAL da = new RecordDAL();
try
{
return da.GetRecord(boxNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable GetOrderNum(string orderno)
{
RecordDAL da = new RecordDAL();
try
{
return da.GetOrderNum(orderno);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

29
SjMes/PunchAssemble/MESClassLibrary/BLL/Painting/InspectResultBLL.cs

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.painting;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.Painting
{
public class InspectResultBLL
{
public bool AddInfo(InspectResultModel md)
{
InspectResultDAL da = new InspectResultDAL();
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

72
SjMes/PunchAssemble/MESClassLibrary/BLL/Painting/PaintBarCodeBLL.cs

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.painting;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.Painting
{
public class PaintBarCodeBLL
{
public DataTable SearchAll(string banci,string productdate)
{
PaintBarCodeDAL da=new PaintBarCodeDAL();
try
{
return da.SearchInfoAll(banci, productdate);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCode(string banci, string productdate, string ProductID)
{
PaintBarCodeDAL da = new PaintBarCodeDAL();
try
{
return da.SearchBarCode(banci, productdate, ProductID);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool AddInfo(PaintBarCodeModel md)
{
PaintBarCodeDAL da = new PaintBarCodeDAL();
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdatePrintTime(PaintBarCodeModel md)
{
PaintBarCodeDAL da = new PaintBarCodeDAL();
try
{
return da.UpdatePrintTime(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

114
SjMes/PunchAssemble/MESClassLibrary/BLL/Painting/StockInBLL.cs

@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.BasicInfo;
using MESClassLibrary.DAL.painting;
namespace MESClassLibrary.BLL.Painting
{
public class StockInBLL
{
public DataTable SearchInfoA()
{
StockInDAL da = new StockInDAL();
try
{
return da.SearchInfoA();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoB()
{
StockInDAL da = new StockInDAL();
try
{
return da.SearchInfoB();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoBByA()
{
StockInDAL da = new StockInDAL();
try
{
return da.SearchInfoBByA();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoAByB()
{
StockInDAL da = new StockInDAL();
try
{
return da.SearchInfoAByB();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchDetailA()
{
StockInDAL da = new StockInDAL();
try
{
return da.SearchDetailA();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchDetailB()
{
StockInDAL da = new StockInDAL();
try
{
return da.SearchDetailB();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchColor(string barCode)
{
StockInDAL da = new StockInDAL();
try
{
return da.SearchColor(barCode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

399
SjMes/PunchAssemble/MESClassLibrary/BLL/Plan247/Plan247BLL.cs

@ -0,0 +1,399 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace MESClassLibrary.BLL.Plan247
{
public class Plan247BLL
{
BBMPTEntities ef = new BBMPTEntities();
BasicBLL<tb_Plan_247> db = new BasicBLL<tb_Plan_247>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_Plan_247 md)
{
try
{
var list = ef.tb_Plan_247.Where(p => p.OrderNo == md.OrderNo).ToList();
if (list != null && list.Count > 0)
{
return false;
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateAddInfo(tb_Plan_247 md)
{
try
{
var list = ef.tb_Plan_247.Where(p => p.OrderNo==md.OrderNo && p.PartNo == md.PartNo).ToList();
if (list != null && list.Count > 0)
{
return false;
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_Plan_247 md)
{
try
{
//初始化要更新的字段
string[] proNames = new string[1];
proNames[0] = "OrderCount";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_Plan_247 md)
{
try
{
if (ef.tb_Plan_247.Where(p => p.ID == md.ID && p.CompleteCount > 0).Count() > 0)
{
return false;
}
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string StartTime, string EndTime, string OrderNo)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
DateTime stime = Convert.ToDateTime(StartTime + " 00:00:00");
DateTime etime = Convert.ToDateTime(EndTime + " 23:59:59");
List<tb_Plan_247> list = ef.tb_Plan_247.Where(p => p.CreateTime >= stime && p.CreateTime <= etime).OrderBy(p => p.CreateTime).ToList();
if (!String.IsNullOrEmpty(OrderNo))
{
list = list.Where(p => p.OrderNo.Contains(OrderNo)).OrderBy(p => p.CreateTime).ToList();
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
List<tb_Plan_247Model> modelList = new List<tb_Plan_247Model>();
#region 联查
var listModel = ef.tb_Mistake_247.ToList();
foreach (var item in list)
{
tb_Plan_247Model dm = Tool.Mapper<tb_Plan_247Model, tb_Plan_247>(item);
var machine_info = listModel.FirstOrDefault(p => p.PartNo2 == item.PartNo);
if (machine_info != null)
{
dm.PartName = machine_info.PartName2;
}
modelList.Add(dm);
}
#endregion
JsonDataModel<tb_Plan_247Model> md = new JsonDataModel<tb_Plan_247Model>();
md.total = total.ToString();
md.rows = modelList;
jsonStr = JSONTools.ScriptSerialize(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public string SearchOrderNo(string StartTime)
{
try
{
string jsonStr = "";
string orderNo = Convert.ToDateTime(StartTime).ToString("yyyyMMdd");
var info = ef.tb_Plan_247.Where(p => p.OrderNo.Contains(orderNo)).OrderByDescending(p => p.OrderNo).FirstOrDefault();
if (info != null)
{
return (Convert.ToInt64(info.OrderNo) + 1).ToString();
}
else
{
return orderNo + "0001";
}
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = ef.tb_Mistake_247.ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
public string GetMistake(string id)
{
try
{
string jsonStr = "[]";
var list = ef.tb_Mistake_247.Where(p => p.ID.Equals(id)).FirstOrDefault();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize(list);
return jsonStr;
}
catch (Exception)
{
return null;
}
}
public string QueryForComboboxOrderNo(string StartTime)
{
try
{
string jsonStr = "[]";
List<SelectModel> list = new List<SelectModel>();
string orderNo = Convert.ToDateTime(StartTime).ToString("yyyyMMdd");
var info = ef.tb_Plan_247.Where(p => p.OrderNo.Contains(orderNo)).GroupBy(p => p.OrderNo).Select(p => p.Key).ToList();//判断是否有重复数据
foreach (var item in info)
{
SelectModel md = new SelectModel();
md.textField = item;
md.valueField = item;
list.Add(md);
}
jsonStr = JSONTools.ScriptSerialize(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
public string QueryForItem(string OrderNo)
{
try
{
var info = ef.tb_Plan_247.Where(p => p.OrderNo.Equals(OrderNo)).OrderByDescending(p => p.Item).FirstOrDefault();//判断是否有重复数据
return (info.Item + 1).ToString();
}
catch (Exception)
{
return "";
}
}
//校验是否生成计划单号日期部分+零件号有相同的计划
public bool QueryByOrderNo(string OrderNo, string PartNo)
{
try
{
var info = ef.tb_Plan_247.Where(p => p.OrderNo.Contains(OrderNo) && p.PartNo.Equals(PartNo));
if (info.Count() > 0)
{
return true;
}
return false;
}
catch (Exception)
{
return false;
}
}
//校验是否同一个生成计划单号下有相同序号的计划
public bool QueryByOrderNoAndItem(string OrderNo, int Item)
{
try
{
var info = ef.tb_Plan_247.Where(p => p.OrderNo.Equals(OrderNo) && p.Item == Item);
if (info.Count() > 0)
{
return true;
}
return false;
}
catch (Exception)
{
return false;
}
}
public List<List<string>> SearchForExcel(string StartTime, string EndTime, string OrderNo)
{
try
{
List<List<string>> list = new List<List<string>>();
DateTime stime = Convert.ToDateTime(StartTime + " 00:00:00");
DateTime etime = Convert.ToDateTime(EndTime + " 23:59:59");
List<string> titleList = new List<string>();
titleList.Add("生产计划单号");
titleList.Add("序号");
titleList.Add("零件号");
titleList.Add("零件名称");
titleList.Add("数量");
titleList.Add("领用数量");
titleList.Add("完成数量");
titleList.Add("返修数量");
titleList.Add("成品报废");
titleList.Add("半成品报废");
titleList.Add("备注");
titleList.Add("创建时间");
list.Add(titleList);
List<tb_Plan_247> Plan_247_list = ef.tb_Plan_247.Where(p => p.CreateTime >= stime && p.CreateTime <= etime).OrderBy(p => p.CreateTime).ToList();
if (!String.IsNullOrEmpty(OrderNo))
{
Plan_247_list = Plan_247_list.Where(p => p.OrderNo.Contains(OrderNo)).OrderBy(p => p.CreateTime).ToList();
}
if (Plan_247_list.Count > 0)
{
List<tb_Plan_247Model> modelList = new List<tb_Plan_247Model>();
var listModel = ef.tb_Mistake_247.ToList();
foreach (var item in Plan_247_list)
{
tb_Plan_247Model dm = Tool.Mapper<tb_Plan_247Model, tb_Plan_247>(item);
var machine_info = listModel.FirstOrDefault(p => p.PartNo2 == item.PartNo);
if (machine_info != null)
{
dm.PartName = machine_info.PartName2;
}
modelList.Add(dm);
}
for (int i = 0; i < modelList.Count; i++)
{
List<string> rowList = new List<string>();
rowList.Add(modelList[i].OrderNo);
rowList.Add(modelList[i].Item == null ? "" : modelList[i].Item.ToString());
rowList.Add(modelList[i].PartNo);
rowList.Add(modelList[i].PartName == null ? "" : modelList[i].PartName.ToString());
rowList.Add(modelList[i].OrderCount == null ? "" : modelList[i].OrderCount.ToString());
rowList.Add(modelList[i].LyCount == null ? "" : modelList[i].LyCount.ToString());
rowList.Add(modelList[i].CompleteCount == null ? "" : modelList[i].CompleteCount.ToString());
rowList.Add(modelList[i].RepairCount == null ? "" : modelList[i].RepairCount.ToString());
rowList.Add(modelList[i].ScrapCount1 == null ? "" : modelList[i].ScrapCount1.ToString());
rowList.Add(modelList[i].ScrapCount2 == null ? "" : modelList[i].ScrapCount2.ToString());
rowList.Add(modelList[i].Des);
rowList.Add(modelList[i].CreateTime == null ? "" : modelList[i].CreateTime.ToString());
list.Add(rowList);
}
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

451
SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PlanPunchBLL.cs

@ -0,0 +1,451 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.PunchAndWeld
{
public class PlanPunchBLL
{
BBMPTEntities ef = new BBMPTEntities();
BasicBLL<tb_Plan_Punch> db = new BasicBLL<tb_Plan_Punch>();
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string StartTime, string EndTime, string OrderNo)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
DateTime stime = Convert.ToDateTime(StartTime + " 00:00:00");
DateTime etime = Convert.ToDateTime(EndTime + " 23:59:59");
List<tb_Plan_Punch> list = ef.tb_Plan_Punch.Where(p => p.CreateTime >= stime && p.CreateTime <= etime).OrderBy(p => p.CreateTime).ToList();
if (!String.IsNullOrEmpty(OrderNo))
{
list = list.Where(p => p.OrderNo.Contains(OrderNo)).OrderBy(p => p.CreateTime).ToList();
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
List<tb_Plan_PunchModel> modelList = new List<tb_Plan_PunchModel>();
#region 联查
var listModel = ef.tb_Product.ToList();
foreach (var item in list)
{
tb_Plan_PunchModel dm = Tool.Mapper<tb_Plan_PunchModel, tb_Plan_Punch>(item);
var machine_info = listModel.FirstOrDefault(p => p.PartNo == item.PartNo);
if (machine_info != null)
{
dm.PartName = machine_info.ProductName;
}
modelList.Add(dm);
}
#endregion
JsonDataModel<tb_Plan_PunchModel> md = new JsonDataModel<tb_Plan_PunchModel>();
md.total = total.ToString();
md.rows = modelList;
jsonStr = JSONTools.ScriptSerialize(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_Plan_Punch md)
{
try
{
var list = ef.tb_Plan_Punch.Where(p => p.OrderNo == md.OrderNo && p.Item==md.Item && p.PartNo==md.PartNo).ToList();
if (list != null && list.Count > 0)
{
return false;
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateAddInfo(tb_Plan_Punch md)
{
try
{
var list = ef.tb_Plan_Punch.Where(p => p.OrderNo == md.OrderNo && p.PartNo == md.PartNo).ToList();
if (list != null && list.Count > 0)
{
return false;
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_Plan_Punch md)
{
try
{
//初始化要更新的字段
string[] proNames = new string[1];
proNames[0] = "OrderCount";
string sql = "select * from tb_Plan_Punch where OrderNo='" + md.OrderNo + "' and PartNo='"+ md.PartNo+"'";
SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.GetConnSting(), CommandType.Text, sql);
if (dr.Read())
{
if (md.OrderCount < Convert.ToInt32(dr["CompleteCount"]))
{
return false;
}
else
{
return db.UpdateInfo(md, proNames);
}
}
else
{
return false;
}
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string SearchOrderNo(string StartTime, string Banci)
{
try
{
string jsonStr = "";
string orderNo = Convert.ToDateTime(StartTime).ToString("yyyyMMdd");
var info = ef.tb_Plan_Punch.Where(p => p.OrderNo.Contains(Banci.Substring(0, 1) + orderNo)).OrderByDescending(p => p.OrderNo).FirstOrDefault();
if (info != null)
{
return info.OrderNo.Substring(0, info.OrderNo.Length - 4) + (Convert.ToInt32(info.OrderNo.Substring(info.OrderNo.Length - 1, 1)) + 1).ToString()
.PadLeft(4, '0');
//if (Banci.Contains("A"))
//{
// return "A" + (Convert.ToInt64(info.OrderNo.Substring(1, info.OrderNo.Length-1)) + 1).ToString();
//}
//else
//{
// return "B" + (Convert.ToInt64(info.OrderNo.Substring(1, info.OrderNo.Length - 1)) + 1).ToString();
//}
}
else
{
if (Banci.Contains("A"))
{
return "A" + orderNo + "0001";
}
else
{
return "B" + orderNo + "0001";
}
}
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
var list = ef.tb_Product.Where(p => p.ProductTypeID == "3a8545ee-5979-4780-a5ca-6c5e75685ae2" || p.ProductTypeID == "69ec20f1-dab5-4caf-b81e-1c65b38b9e34").ToList();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
public string GetMistake(string id)
{
try
{
string jsonStr = "[]";
var list = ef.tb_Product.Where(p => p.PartNo.Equals(id)).FirstOrDefault();//判断是否有重复数据
jsonStr = JSONTools.ScriptSerialize(list);
return jsonStr;
}
catch (Exception)
{
return null;
}
}
public string QueryForComboboxOrderNo(string StartTime)
{
try
{
string jsonStr = "[]";
List<SelectModel> list = new List<SelectModel>();
string orderNo = Convert.ToDateTime(StartTime).ToString("yyyyMMdd");
var info = ef.tb_Plan_Punch.Where(p => p.OrderNo.Contains(orderNo)).GroupBy(p => p.OrderNo).Select(p => p.Key).ToList();//判断是否有重复数据
foreach (var item in info)
{
SelectModel md = new SelectModel();
md.textField = item;
md.valueField = item;
list.Add(md);
}
jsonStr = JSONTools.ScriptSerialize(list);
return jsonStr;
}
catch (Exception)
{
return "";
}
}
public string QueryForItem(string OrderNo)
{
try
{
var info = ef.tb_Plan_Punch.Where(p => p.OrderNo.Equals(OrderNo)).OrderByDescending(p => p.Item).FirstOrDefault();//判断是否有重复数据
return (info.Item + 1).ToString();
}
catch (Exception)
{
return "";
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_Plan_Punch md)
{
try
{
if (ef.tb_Plan_Punch.Where(p => p.ID == md.ID && p.CompleteCount > 0).Count() > 0)
{
return false;
}
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public List<List<string>> SearchForExcel(string StartTime, string EndTime, string OrderNo)
{
try
{
List<List<string>> list = new List<List<string>>();
DateTime stime = Convert.ToDateTime(StartTime + " 00:00:00");
DateTime etime = Convert.ToDateTime(EndTime + " 23:59:59");
List<string> titleList = new List<string>();
titleList.Add("生产计划单号");
titleList.Add("序号");
titleList.Add("零件号");
titleList.Add("零件名称");
titleList.Add("数量");
titleList.Add("领用数量");
titleList.Add("完成数量");
titleList.Add("不良数量");
titleList.Add("备注");
titleList.Add("创建时间");
list.Add(titleList);
List<tb_Plan_Punch> Plan_list = ef.tb_Plan_Punch.Where(p => p.CreateTime >= stime && p.CreateTime <= etime).OrderBy(p => p.CreateTime).ToList();
if (!String.IsNullOrEmpty(OrderNo))
{
Plan_list = Plan_list.Where(p => p.OrderNo.Contains(OrderNo)).OrderBy(p => p.CreateTime).ToList();
}
if (Plan_list.Count > 0)
{
List<tb_Plan_PunchModel> modelList = new List<tb_Plan_PunchModel>();
var listModel = ef.tb_Product.ToList();
foreach (var item in Plan_list)
{
tb_Plan_PunchModel dm = Tool.Mapper<tb_Plan_PunchModel, tb_Plan_Punch>(item);
var machine_info = listModel.FirstOrDefault(p => p.PartNo == item.PartNo);
if (machine_info != null)
{
dm.PartName = machine_info.ProductName;
}
modelList.Add(dm);
}
for (int i = 0; i < modelList.Count; i++)
{
List<string> rowList = new List<string>();
rowList.Add(modelList[i].OrderNo);
rowList.Add(modelList[i].Item == null ? "" : modelList[i].Item.ToString());
rowList.Add(modelList[i].PartNo);
rowList.Add(modelList[i].PartName == null ? "" : modelList[i].PartName.ToString());
rowList.Add(modelList[i].OrderCount == null ? "" : modelList[i].OrderCount.ToString());
rowList.Add(modelList[i].LyCount == null ? "" : modelList[i].LyCount.ToString());
rowList.Add(modelList[i].CompleteCount == null ? "" : modelList[i].CompleteCount.ToString());
rowList.Add(modelList[i].BadCount == null ? "" : modelList[i].BadCount.ToString());
rowList.Add(modelList[i].Des);
rowList.Add(modelList[i].CreateTime == null ? "" : modelList[i].CreateTime.ToString());
list.Add(rowList);
}
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//校验是否生成计划单号日期部分+零件号有相同的计划
public bool QueryByOrderNo(string OrderNo, string PartNo)
{
try
{
var info = ef.tb_Plan_Punch.Where(p => p.OrderNo.Contains(OrderNo) && p.PartNo.Equals(PartNo));
if (info.Count() > 0)
{
return true;
}
return false;
}
catch (Exception)
{
return false;
}
}
//校验是否同一个生成计划单号下有相同序号的计划
public bool QueryByOrderNoAndItem(string OrderNo, int Item)
{
try
{
var info = ef.tb_Plan_Punch.Where(p => p.OrderNo.Equals(OrderNo) && p.Item == Item);
if (info.Count() > 0)
{
return true;
}
return false;
}
catch (Exception)
{
return false;
}
}
public string GetOrderNo(string banci,string date)
{
try
{
//string order = banci + DateTime.Now.ToString("yyyyMMdd");
string order = banci + date;
var info = ef.tb_Plan_Punch.Where(p => p.OrderNo.Contains(order)).OrderBy(p => p.CreateTime)
.FirstOrDefault();
if (info != null)
{
return order + (Convert.ToInt32(info.OrderNo.Substring(info.OrderNo.Length - 4, 4)) + 1).ToString()
.PadLeft(4, '0');
}
else
{
return order + "0001";
}
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return banci + date +"0001";
}
}
}
}

29
SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchAdressBLL.cs

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.PunchAndWeld;
namespace MESClassLibrary.BLL.PunchAndWeld
{
public class PunchAdressBLL
{
PunchAdressDAL da=new PunchAdressDAL();
public DataTable SearchInfo(string deviceNo,int i)
{
try
{
return da.SearchInfo(deviceNo,i);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

182
SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchAndStationBLL.cs

@ -0,0 +1,182 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL;
using MESClassLibrary.DAL.PunchAndWeld;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.PunchAndWeld
{
public class PunchAndStationBLL
{
BasicBLL<tb_PunchAndStation> db = new BasicBLL<tb_PunchAndStation>();
public bool AddInfo(tb_PunchAndStation md)
{
try
{
BBMPTEntities ef = new BBMPTEntities();
List<tb_PunchAndStation> list1 = ef.tb_PunchAndStation.Where(p =>
p.StationID == md.StationID && p.ProductID1 == md.ProductID1 && p.ProductID2 == md.ProductID2)
.ToList();
if (list1 != null)
{
if (list1.Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public string SearchInfoAll(string page, string pagesize, string partNo1)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<PunchAndStationModel1> list = new List<PunchAndStationModel1>();
string sql = @"SELECT dbo.tb_PunchAndStation.ID, dbo.tb_Station.StationNo, tb_Product_1.PartNo AS PartNo1,
tb_Product_1.ProductName AS ProductName1, tb_Product_2.PartNo AS PartNo2,
tb_Product_2.ProductName AS ProductName2, tb_Product_3.PartNo AS PartNo3,
tb_Product_3.ProductName AS ProductName3, tb_Product_4.PartNo AS PartNo4,
tb_Product_4.ProductName AS ProductName4, dbo.tb_Product.PartNo AS PartNo5,
dbo.tb_Product.ProductName AS ProductName5
FROM dbo.tb_Product AS tb_Product_3 RIGHT OUTER JOIN
dbo.tb_PunchAndStation LEFT OUTER JOIN
dbo.tb_Product ON dbo.tb_PunchAndStation.ProductID5 = dbo.tb_Product.ProductID LEFT OUTER JOIN
dbo.tb_Product AS tb_Product_4 ON dbo.tb_PunchAndStation.ProductID4 = tb_Product_4.ProductID ON
tb_Product_3.ProductID = dbo.tb_PunchAndStation.ProductID3 LEFT OUTER JOIN
dbo.tb_Product AS tb_Product_2 ON dbo.tb_PunchAndStation.ProductID2 = tb_Product_2.ProductID LEFT OUTER JOIN
dbo.tb_Station ON dbo.tb_PunchAndStation.StationID = dbo.tb_Station.StationID LEFT OUTER JOIN
dbo.tb_Product AS tb_Product_1 ON dbo.tb_PunchAndStation.ProductID1 = tb_Product_1.ProductID where 1=1";
if (!string.IsNullOrWhiteSpace(partNo1))
{
sql += " And tb_Product_1.PartNo like '%" + partNo1 + "%' ";
}
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
list = Tool.ConvertTo<PunchAndStationModel1>(dt).ToList();
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<PunchAndStationModel1> md = new JsonDataModel<PunchAndStationModel1>();
md.total = total.ToString();
md.rows = list;
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<PunchAndStationModel1>>(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdateInfo(tb_PunchAndStation md)
{
try
{
List<PunchAndStationModel> list = new List<PunchAndStationModel>();
string sql = @"SELECT dbo.tb_PunchAndStation.ID, dbo.tb_Station.StationNo, tb_Product_1.PartNo AS PartNo1,
tb_Product_1.ProductName AS ProductName1, tb_Product_2.PartNo AS PartNo2,
tb_Product_2.ProductName AS ProductName2, tb_Product_3.PartNo AS PartNo3,
tb_Product_3.ProductName AS ProductName3, tb_Product_4.PartNo AS PartNo4,
tb_Product_4.ProductName AS ProductName4, dbo.tb_Product.PartNo AS PartNo5,
dbo.tb_Product.ProductName AS ProductName5,dbo.tb_PunchAndStation.ProductID1,
dbo.tb_PunchAndStation.ProductID2,dbo.tb_PunchAndStation.ProductID3,
dbo.tb_PunchAndStation.ProductID4,dbo.tb_PunchAndStation.ProductID5
FROM dbo.tb_Product AS tb_Product_3 RIGHT OUTER JOIN
dbo.tb_PunchAndStation LEFT OUTER JOIN
dbo.tb_Product ON dbo.tb_PunchAndStation.ProductID5 = dbo.tb_Product.ProductID LEFT OUTER JOIN
dbo.tb_Product AS tb_Product_4 ON dbo.tb_PunchAndStation.ProductID4 = tb_Product_4.ProductID ON
tb_Product_3.ProductID = dbo.tb_PunchAndStation.ProductID3 LEFT OUTER JOIN
dbo.tb_Product AS tb_Product_2 ON dbo.tb_PunchAndStation.ProductID2 = tb_Product_2.ProductID LEFT OUTER JOIN
dbo.tb_Station ON dbo.tb_PunchAndStation.StationID = dbo.tb_Station.StationID LEFT OUTER JOIN
dbo.tb_Product AS tb_Product_1 ON dbo.tb_PunchAndStation.ProductID1 = tb_Product_1.ProductID where 1=1 and
ProductID1='"+md.ProductID1+"' and ProductID2='"+md.ProductID2+"' and ProductID3='"+md.ProductID3+"' and ProductID4='"+md.ProductID4 +"' and ProductID5='"+md.ProductID5+"' and ID <> '"+ md.ID+"' ";
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[6];
proNames[0] = "StationID";
proNames[1] = "ProductID1";
proNames[2] = "ProductID2";
proNames[3] = "ProductID3";
proNames[4] = "ProductID4";
proNames[5] = "ProductID5";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool DeleteInfo(tb_PunchAndStation md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable IsMath(string partNo1, string partNo2)
{
try
{
PunchAndStationDAL da=new PunchAndStationDAL();
return da.IsMath(partNo1, partNo2);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

42
SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchDeviceBLL.cs

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.PunchAndWeld;
namespace MESClassLibrary.BLL.PunchAndWeld
{
public class PunchDeviceBLL
{
PunchDeviceDAL da=new PunchDeviceDAL();
public DataTable SearchInfo()
{
try
{
return da.SearchInfo();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchDeviceNo(string deviceName)
{
try
{
return da.SearchDeviceNo(deviceName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

29
SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchPartBLL.cs

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.PunchAndWeld;
namespace MESClassLibrary.BLL.PunchAndWeld
{
public class PunchPartBLL
{
PunchPartDAL da=new PunchPartDAL();
public DataTable SearchPunchPart(string deviceNo)
{
try
{
return da.SearchPunchPart(deviceNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

94
SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchPlanBLL.cs

@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.PunchAndWeld
{
public class PunchPlanBLL
{
PunchPlanDAL da=new PunchPlanDAL();
public DataTable SearchPlan(string deviceNo)
{
try
{
return da.SearchPlan(deviceNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchAllPlan()
{
try
{
return da.SearchAllPlan();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool AddInfo(PunchPlanModel md)
{
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateInfo(PunchPlanModel md)
{
try
{
return da.UpdateInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool DelInfo(PunchPlanModel md)
{
try
{
return da.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateDty(PunchPlanModel md)
{
try
{
return da.UpdateDty(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

44
SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchRecordBLL.cs

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.PunchAndWeld;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.PunchAndWeld
{
public class PunchRecordBLL
{
PunchRecordDAL da=new PunchRecordDAL();
public bool AddInfo(PunchRecordModel md)
{
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchInfo(string barCode)
{
try
{
return da.SearchInfo(barCode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

29
SjMes/PunchAssemble/MESClassLibrary/BLL/PunchAndWeld/PunchValueRecordBLL.cs

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.PunchAndWeld;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.PunchAndWeld
{
public class PunchValueRecordBLL
{
PunchValueRecordDAL da = new PunchValueRecordDAL();
public bool AddInfo(PunchValueRecordModel md)
{
try
{
return da.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

81
SjMes/PunchAssemble/MESClassLibrary/BLL/Record247/Record247BLL.cs

@ -0,0 +1,81 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace MESClassLibrary.BLL.Record247
{
public class Record247BLL
{
BBMPTEntities ef = new BBMPTEntities();
BasicBLL<tb_Record_247> db = new BasicBLL<tb_Record_247>();
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize, string StartTime, string EndTime, string BoxNo, string PartNo2, string PartNo1, string OrderNo)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
DateTime stime = Convert.ToDateTime(StartTime + " 00:00:00");
DateTime etime = Convert.ToDateTime(EndTime + " 23:59:59");
List<tb_Record_247> list = ef.tb_Record_247.Where(p => p.CreateTime1 >= stime && p.CreateTime1 <= etime && p.Flag == 1).ToList();
if (!String.IsNullOrEmpty(BoxNo))
{
list = list.Where(p => p.BoxNo != null && p.BoxNo.Contains(BoxNo)).ToList();
}
if (!String.IsNullOrEmpty(PartNo2))
{
list = list.Where(p => p.PartNo2 != null && p.PartNo2.Contains(PartNo2)).ToList();
}
if (!String.IsNullOrEmpty(PartNo1))
{
list = list.Where(p => p.PartNo1 != null && p.PartNo1.Contains(PartNo1)).ToList();
}
if (!String.IsNullOrEmpty(OrderNo))
{
list = list.Where(p => p.OrderNo != null && p.OrderNo.Contains(OrderNo)).ToList();
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.OrderBy(p => p.CreateTime1).Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<tb_Record_247> md = new JsonDataModel<tb_Record_247>();
md.total = total.ToString();
md.rows = list;
jsonStr = JSONTools.ScriptSerialize(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

190
SjMes/PunchAssemble/MESClassLibrary/BLL/Report/FiveScreenBLL.cs

@ -0,0 +1,190 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.Report
{
public class FiveScreenBLL
{
BasicBLL<tb_Report_FiveScreen> db = new BasicBLL<tb_Report_FiveScreen>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_Report_FiveScreen md)
{
try
{
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_Report_FiveScreen md)
{
try
{
//初始化要更新的字段
string[] proNames = new string[45];
proNames[0] = "Name";
proNames[1] = "LastYear";
proNames[2] = "Jan";
proNames[3] = "Feb";
proNames[4] = "Mar";
proNames[5] = "Apr";
proNames[6] = "May";
proNames[7] = "Jun";
proNames[8] = "Jul";
proNames[9] = "Aug";
proNames[10] = "Sept";
proNames[11] = "Oct";
proNames[12] = "Nov";
proNames[13] = "Dec";
proNames[14] = "day1";
proNames[15] = "day2";
proNames[16] = "day3";
proNames[17] = "day4";
proNames[18] = "day5";
proNames[19] = "day6";
proNames[20] = "day7";
proNames[21] = "day8";
proNames[22] = "day9";
proNames[23] = "day10";
proNames[24] = "day11";
proNames[25] = "day12";
proNames[26] = "day13";
proNames[27] = "day14";
proNames[28] = "day15";
proNames[29] = "day16";
proNames[30] = "day17";
proNames[31] = "day18";
proNames[32] = "day19";
proNames[33] = "day20";
proNames[34] = "day21";
proNames[35] = "day22";
proNames[36] = "day23";
proNames[37] = "day24";
proNames[38] = "day25";
proNames[39] = "day26";
proNames[40] = "day27";
proNames[41] = "day28";
proNames[42] = "day29";
proNames[43] = "day30";
proNames[44] = "day31";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_Report_FiveScreen md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Report_FiveScreen> list = db.SearchAllInfo();
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<tb_Report_FiveScreen> md = new JsonDataModel<tb_Report_FiveScreen>();
md.total = total.ToString();
md.rows = list;
return JSONTools.ScriptSerialize(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_Report_FiveScreen SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public tb_Report_FiveScreen SearchInfoByNameLast(string name) {
var info = db.SearchInfoByKey("Name", name).OrderByDescending(p=>p.CreateTime).FirstOrDefault();//判断是否有重复数据
if (info != null)
{
return info;
}
return null;
}
}
}

153
SjMes/PunchAssemble/MESClassLibrary/BLL/Report/FiveScreenLastBLL.cs

@ -0,0 +1,153 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.Report
{
public class FiveScreenLastBLL
{
BasicBLL<tb_Report_FiveScreenLast> db = new BasicBLL<tb_Report_FiveScreenLast>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_Report_FiveScreenLast md)
{
try
{
var list = db.SearchInfoByKey("StationID", md.StationID);//判断是否有重复数据
if (list != null)
{
if (list.Where(p => p.ID != md.ID).Count() > 0)
{
return false;
}
}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_Report_FiveScreenLast md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.StationID == md.StationID && p.ID != md.ID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[5];
proNames[0] = "StationID";
proNames[1] = "StationNo";
proNames[2] = "UseRate";
proNames[3] = "PassRate";
proNames[4] = "Remark1";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_Report_FiveScreenLast md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Report_FiveScreenLast> list = db.SearchAllInfo();
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<tb_Report_FiveScreenLast> md = new JsonDataModel<tb_Report_FiveScreenLast>();
md.total = total.ToString();
md.rows = list;
return JSONTools.ScriptSerialize(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_Report_FiveScreenLast SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

161
SjMes/PunchAssemble/MESClassLibrary/BLL/Report/FiveScreenStandardBLL.cs

@ -0,0 +1,161 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.Report
{
public class FiveScreenStandardBLL
{
BasicBLL<tb_Report_FiveScreenStandard> db = new BasicBLL<tb_Report_FiveScreenStandard>();
/// <summary>
/// 新增信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddInfo(tb_Report_FiveScreenStandard md)
{
try
{
//var list = db.SearchInfoByKey("Name", md.Name);//判断是否有重复数据
//if (list != null)
//{
// if (list.Where(p => p.ID != md.ID).Count() > 0)
// {
// return false;
// }
//}
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(tb_Report_FiveScreenStandard md)
{
try
{
var list = db.SearchAllInfo().Where(p => p.Name == md.Name && p.ID != md.ID).ToList();//判断是否有重复数据
if (list.Count > 0)
{
return false;
}
//初始化要更新的字段
string[] proNames = new string[14];
proNames[0] = "Name";
proNames[1] = "LastYear";
proNames[2] = "Jan";
proNames[3] = "Feb";
proNames[4] = "Mar";
proNames[5] = "Apr";
proNames[6] = "May";
proNames[7] = "Jun";
proNames[8] = "Jul";
proNames[9] = "Aug";
proNames[10] = "Sept";
proNames[11] = "Oct";
proNames[12] = "Nov";
proNames[13] = "Dec";
//必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化
//如果没有初始化必填字段,更新会报错
//md.Des = "";
return db.UpdateInfo(md, proNames);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool DeleteInfo(tb_Report_FiveScreenStandard md)
{
try
{
return db.DelInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 查询全部信息分页
/// </summary>
/// <returns></returns>
public string SearchInfoAll(string page, string pagesize)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_Report_FiveScreenStandard> list = db.SearchAllInfo();
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<tb_Report_FiveScreenStandard> md = new JsonDataModel<tb_Report_FiveScreenStandard>();
md.total = total.ToString();
md.rows = list;
return JSONTools.ScriptSerialize(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据ID查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public tb_Report_FiveScreenStandard SearchInfoByID(string id)
{
try
{
return db.SearchInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

57
SjMes/PunchAssemble/MESClassLibrary/BLL/Show/AnalysisBLL.cs

@ -0,0 +1,57 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.Show
{
public class AnalysisBLL
{
BBMPTEntities dbe = new BBMPTEntities();
BasicBLL<tb_InspectResult> db = new BasicBLL<tb_InspectResult>();
public List<tb_InspectResult> SearchInfo(string ProductName)
{
List<tb_InspectResult> list = new List<tb_InspectResult>();
try
{
DateTime date = DateTime.Now;
//DateTime date = Convert.ToDateTime("2019-07-08 10:00:00");
string nowTime = date.ToString("yyyy-MM-dd");
DateTime startTime = Convert.ToDateTime(nowTime + " 08:00:00");//班次开始时间
DateTime endTime = Convert.ToDateTime(nowTime + " 19:59:59");//班次结束时间
var info = dbe.tb_InspectResult.Where(p => p.productInfo.Contains(ProductName));
if (DateTime.Compare(date, startTime) < 0)
{
//昨天夜班
list = info.Where(p => p.createTime > endTime.AddDays(-1) && p.createTime < startTime).ToList();
}
if (DateTime.Compare(date, endTime) > 0)
{
//今天夜班
list = info.Where(p => p.createTime > endTime && p.createTime <= date).ToList();
}
if (DateTime.Compare(date, startTime) >= 0 && DateTime.Compare(date, endTime) <= 0)
{
//今天白班
list = info.Where(p => p.createTime >= startTime && p.createTime <= endTime).ToList();
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return list;
}
}
}
}

156
SjMes/PunchAssemble/MESClassLibrary/BLL/Stock/StockInBLL.cs

@ -0,0 +1,156 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.BLL.Stock
{
public class StockInBLL
{
BBMPTEntities dbe = new BBMPTEntities();
BasicBLL<tb_StockIn> db = new BasicBLL<tb_StockIn>();
BasicBLL<tb_InspectResult> Resultdb = new BasicBLL<tb_InspectResult>();
/// <summary>
/// 查询信息
/// </summary>
/// <returns></returns>
public string SearchInfo(string page, string pagesize, string StartTime, string EndTime, string workClass, string color, string productInfo)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
//List<tb_StockIn> list = db.SearchAllInfo();
DateTime start = Convert.ToDateTime(StartTime);
DateTime end = Convert.ToDateTime(EndTime);
List<tb_StockIn> list = dbe.tb_StockIn.Where(p => p.createTime >= start && p.createTime <= end && "1".Equals(p.pass)).ToList();
//list = list.Where(p => p.createTime >= start && p.createTime <= end && "1".Equals(p.pass)).ToList();
List<string> barcodeList = list.Select(m => m.barcode).ToList();
var resultList = dbe.tb_InspectResult.Where(p => barcodeList.Contains(p.barcode) && p.inspectResult.Contains("合格")).ToList();
if (!String.IsNullOrEmpty(workClass))
{
resultList = resultList.Where(p => p.workClass.Contains(workClass)).ToList();
}
if (!String.IsNullOrEmpty(color))
{
resultList = resultList.Where(p => p.productInfo.Contains(color)).ToList();
}
if (!String.IsNullOrEmpty(productInfo))
{
resultList = resultList.Where(p => p.productInfo.Contains(productInfo)).ToList();
}
list = list.Where(p => resultList.Select(m => m.barcode).ToList().Contains(p.barcode)).ToList();
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.OrderByDescending(p => p.createTime).Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
List<StockInModel> StockInList = new List<StockInModel>();
foreach (var item in list)
{
StockInModel dm = Tool.Mapper<StockInModel, tb_StockIn>(item);
var info = resultList.FirstOrDefault(p => p.barcode == item.barcode);
if (info != null)
{
dm.workClass = info.workClass;
dm.productInfo = info.productInfo;
}
StockInList.Add(dm);
}
JsonDataModel<StockInModel> md = new JsonDataModel<StockInModel>();
md.total = total.ToString();
md.rows = StockInList;
jsonStr = JSONTools.ScriptSerialize(md);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
/// <summary>
/// 查询信息
/// </summary>
/// <returns></returns>
public List<StockInModel> SearchInfoAll(string StartTime, string EndTime, string workClass, string color, string productInfo)
{
try
{
List<tb_StockIn> list = db.SearchAllInfo();
DateTime start = Convert.ToDateTime(StartTime);
DateTime end = Convert.ToDateTime(EndTime);
list = list.Where(p => p.createTime >= start && p.createTime <= end && "1".Equals(p.pass)).ToList();
List<string> barcodeList = list.Select(m => m.barcode).ToList();
var resultList = dbe.tb_InspectResult.Where(p => barcodeList.Contains(p.barcode) && p.inspectResult.Contains("合格")).ToList();
if (!String.IsNullOrEmpty(workClass))
{
resultList = resultList.Where(p => p.workClass.Contains(workClass)).ToList();
}
if (!String.IsNullOrEmpty(color))
{
resultList = resultList.Where(p => p.productInfo.Contains(color)).ToList();
}
if (!String.IsNullOrEmpty(productInfo))
{
resultList = resultList.Where(p => p.productInfo.Contains(productInfo)).ToList();
}
list = list.Where(p => resultList.Select(m => m.barcode).ToList().Contains(p.barcode)).ToList();
List<StockInModel> StockInList = new List<StockInModel>();
if (list.Count > 0)
{
foreach (var item in list)
{
StockInModel dm = Tool.Mapper<StockInModel, tb_StockIn>(item);
var info = resultList.FirstOrDefault(p => p.barcode == item.barcode);
if (info != null)
{
dm.workClass = info.workClass;
dm.productInfo = info.productInfo;
}
StockInList.Add(dm);
}
}
return StockInList;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

45
SjMes/PunchAssemble/MESClassLibrary/BLL/User/Sys_ButtonsService.cs

@ -0,0 +1,45 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.User;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
namespace MESClassLibrary.BLL.User
{
/// <summary>
/// 用户按钮
/// lx 2017-06-28
/// </summary>
public class Sys_ButtonsService
{
/// <summary>
/// 获取用户有权限的按钮
/// </summary>
/// <param name="menuID"></param>
/// <param name="userID"></param>
/// <returns></returns>
public List<Sys_Buttons> GetUserButtons(string menuID, string userID)
{
try
{
List<Sys_Buttons> returnList = new List<Sys_Buttons>();
Sys_ButtonsData dal = new Sys_ButtonsData();
DataTable dt = new DataTable();
dt = dal.GetUserButtons(menuID, userID);
returnList = Tool.ConvertTo<Sys_Buttons>(dt).ToList<Sys_Buttons>();
return returnList;
}
catch(Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return new List<Sys_Buttons>();
}
}
}
}

83
SjMes/PunchAssemble/MESClassLibrary/BLL/User/Sys_NavMenuService.cs

@ -0,0 +1,83 @@
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MESClassLibrary.BLL.Log;
using System.Reflection;
using System.Data;
using MESClassLibrary.DAL.User;
namespace MESClassLibrary.BLL.User
{
public class Sys_NavMenuService
{
/// <summary>
/// 根据userID查询用户菜单
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>
public List<Sys_NavMenuInfo> BuilderLeftMenu(string userID)
{
try
{
List<Sys_NavMenuInfo> returnList = new List<Sys_NavMenuInfo>();
Sys_NavMenuData dal = new Sys_NavMenuData();
DataTable dt = new DataTable();
List<Sys_NavMenuInfo> navList = new List<Sys_NavMenuInfo>();
dt = dal.BuilderLeftMenu(userID);
navList = Tool.ConvertTo<Sys_NavMenuInfo>(dt).ToList<Sys_NavMenuInfo>();
foreach (Sys_NavMenuInfo item in navList)
{
Sys_NavMenuInfo menuItem = BuilderItem(item, navList);
if (menuItem != null)
returnList.Add(menuItem);
}
return returnList;
}
catch(Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 生成菜单list
/// </summary>
/// <param name="powers"></param>
/// <param name="item"></param>
/// <param name="allItem"></param>
/// <returns></returns>
public Sys_NavMenuInfo BuilderItem(Sys_NavMenuInfo item, List<Sys_NavMenuInfo> allItem)
{
Sys_NavMenuInfo returnItem = new Sys_NavMenuInfo();
returnItem.ItemPic = item.ItemPic;
returnItem.MenuID = item.MenuID;
returnItem.MenuName = item.MenuName;
returnItem.OrderNum = item.OrderNum;
returnItem.ParentMenuID = item.ParentMenuID;
returnItem.PowerID = item.PowerID;
returnItem.URLStr = item.URLStr;
List<Sys_NavMenuInfo> subItemList = new List<Sys_NavMenuInfo>();
StringBuilder sb = new StringBuilder();
List<Sys_NavMenuInfo> subList = allItem.FindAll(p => p.ParentMenuID == item.MenuID);
if (subList.Count > 0)
{
foreach (Sys_NavMenuInfo subItem in subList.OrderBy(p => p.OrderNum))
{
returnItem.SubNavMenuList.Add(subItem);
}
}
if (returnItem.SubNavMenuList.Count == 0)
return null;
else
return returnItem;
}
}
}

304
SjMes/PunchAssemble/MESClassLibrary/BLL/User/UserBLL.cs

@ -0,0 +1,304 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL.User;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
namespace MESClassLibrary.BLL.User
{
public class UserBLL
{
UserDAL db = new UserDAL();
//用户登录
public bool Login(UserModel md)
{
try
{
#region 入参校验
if (string.IsNullOrWhiteSpace(md.Username) || string.IsNullOrWhiteSpace(md.Password))
{
return false;
}
#endregion
#region 登陆
//DataTable dt = db.Search_UserInfoByUP(md.Username, Tool.MD5encryption(md.Password));
DataTable dt = db.Search_UserInfoByUP(md.Username, md.Password);
if (dt != null && dt.Rows.Count > 0)
{
#region 记录用户登录日志-暂注销
//md.ID = dt.Rows[0]["ID"].ToString();
//md.TrueName = dt.Rows[0]["TrueName"].ToString();
//md.FaceURL = dt.Rows[0]["FaceURL"].ToString();
//md.RoleID = dt.Rows[0]["RoleID"].ToString();
//md.RoleName = dt.Rows[0]["RoleName"].ToString();
//md.RoleJurisdiction = dt.Rows[0]["RoleJurisdiction"].ToString();
//md.CompanyPost = dt.Rows[0]["CompanyPost"].ToString();
//md.ContactWay = dt.Rows[0]["ContactWay"].ToString();
//md.CreateUserID = dt.Rows[0]["CreateUserID"].ToString();
//md.IsUseing = (int)dt.Rows[0]["IsUseing"];
//db.Add_UserLoginInfo(md.ID);
#endregion
return true;
}
else
{
return false;
}
#endregion
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 新增用户信息
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool AddUserInfo(UserModel md)
{
//try
//{
// DataTable dt = db.Search_UserInfoByUserName(md.ID, md.Username);
// if (dt != null && dt.Rows.Count > 0)
// {
// return false;
// }
// md.Password = Tool.MD5encryption(md.Password);
// return db.Add_UserInfo(md);
//}
//catch (Exception ex)
//{
// LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
// return false;
//}
return false;
}
/// <summary>
/// 修改用户信息
/// </summary>
/// <param name="md"></param>
/// <param name="flag"></param>
/// <returns></returns>
public bool UpdateUserInfo(UserModel md, int flag)
{
try
{
//DataTable dt = db.Search_UserInfoByUserName(md.ID, md.Username);
//if (dt != null && dt.Rows.Count > 0)
//{
// return false;
//}
//if (flag == 1)
//{
// md.Password = Tool.MD5encryption(md.Password);
//}
//return db.Update_UserInfo(md);
return false;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 修改用户密码
/// </summary>
/// <param name="oldpassword"></param>
/// <param name="newpassword"></param>
/// <param name="id"></param>
/// <returns></returns>
public bool UpdateUserPassword(string oldpassword, string newpassword, string id)
{
try
{
DataTable dt = db.Search_UserInfoByID_v2(id);
if (dt != null && dt.Rows.Count > 0)
{
if (dt.Rows[0]["Password"].ToString() == oldpassword)
{
return db.Update_Password(id, oldpassword, newpassword);
}
}
return false;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <param name="userid"></param>
/// <returns></returns>
public bool DelUserInfoByID(string id, string userid)
{
try
{
return db.Del_Info(db.GetTableName(), id, userid);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
#region 查询用户信息
/// <summary>
/// 查询全部用户信息
/// </summary>
/// <returns></returns>
public DataTable SearchUserInfo()
{
try
{
return db.Search_UserInfo();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据ID查询用户信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataTable SearchUserInfoByID(string id)
{
try
{
return db.Search_UserInfoByID(id);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据登录账号查询用户信息
/// </summary>
/// <param name="username"></param>
/// <returns></returns>
public DataTable SearchUserInfoByUserName(string username)
{
try
{
DataTable dt = db.Search_UserInfoByUserName(username);
if (dt != null && dt.Rows.Count > 0)
{
return dt;
}
return null;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据角色ID查询用户信息
/// </summary>
/// <param name="roleid">角色主键ID</param>
/// <returns></returns>
public DataTable SearchUserInfoByRoleID(string roleid)
{
try
{
DataTable dt = db.Search_UserInfoByRoleID(roleid);
if (dt != null && dt.Rows.Count > 0)
{
return dt;
}
return null;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 查询用户登录记录
/// </summary>
/// <returns></returns>
public DataTable SearchUserLoginInfo()
{
try
{
return db.Search_UserLoginInfo();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public string GetComboboxData()
{
try
{
string jsonStr = "[]";
DataTable dt = db.Search_UserInfo();
if (dt != null && dt.Rows.Count > 0)
{
List<T_Sys_Users> list = new List<T_Sys_Users>();
for (int i = 0; i < dt.Rows.Count; i++)
{
T_Sys_Users md = new T_Sys_Users();
md.UserID = (Guid)dt.Rows[i]["UserID"];
md.RealName = dt.Rows[i]["RealName"].ToString();
list.Add(md);
}
jsonStr = JSONTools.ScriptSerialize<List<T_Sys_Users>>(list);
}
return jsonStr;
}
catch (Exception ex)
{
return "";
}
}
#endregion
}
}

68
SjMes/PunchAssemble/MESClassLibrary/DAL/Andon/AndonButtonRecordDAL.cs

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.Andon
{
public class AndonButtonRecordDAL
{
public bool InsertInfo(AndonRecordModel md)
{
try
{
string sql = "";
SqlParameter[] param = null;
sql = " insert into tb_AndonRecord(ID,ButtonTypeID";
sql += ") VALUES (";
sql += "@ID,";
sql += "@ButtonTypeID)";
param = new SqlParameter[2];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@ButtonTypeID", SqlDbType.VarChar);
param[1].Value = md.ButtonTypeID;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateInfo(AndonRecordModel md)
{
try
{
string sql = "";
SqlParameter[] param = null;
sql =@"update tb_AndonRecord set EndTime=getdate() where ButtonTypeID=@ButtonTypeID and EndTime is null";
param=new SqlParameter[1];
param[0] = new SqlParameter("@ButtonTypeID", SqlDbType.VarChar);
param[0].Value = md.ButtonTypeID;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

34
SjMes/PunchAssemble/MESClassLibrary/DAL/Andon/AndonButtonTypeDAL.cs

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
using MESClassLibrary.BLL.Log;
namespace MESClassLibrary.DAL.Andon
{
public class AndonButtonTypeDAL
{
public DataTable SearchInfoByName(string buttonName)
{
try
{
string sql = @"select * from tb_AndonButtonType where ButtonName=@ButtonName";
SqlParameter[] param=new SqlParameter[1];
param[0] = new SqlParameter("@ButtonName", SqlDbType.VarChar);
param[0].Value = buttonName;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

199
SjMes/PunchAssemble/MESClassLibrary/DAL/BaseDAL.cs

@ -0,0 +1,199 @@
using MESClassLibrary.EFModel;
using System;
using System.Collections.Generic;
using System.Data.Entity.Infrastructure;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.DAL
{
public class BaseDAL<T> where T : class, new()
{
/// <summary>
/// 数据上下文对象
/// </summary>
BBMPTEntities db = new BBMPTEntities();
#region 1.0 新增 实体 +int Add(T model)
/// <summary>
/// 新增 实体
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int Add(T model)
{
db.Set<T>().Add(model);
return db.SaveChanges();//保存成功后,会将自增的id设置给 model的 主键属性,并返回受影响行数
}
#endregion
#region 2.0 根据 id 删除 +int Del(T model)
/// <summary>
/// 根据 id 删除
/// </summary>
/// <param name="model">包含要删除id的对象</param>
/// <returns></returns>
public int Del(T model)
{
db.Set<T>().Attach(model);
db.Set<T>().Remove(model);
return db.SaveChanges();
}
#endregion
#region 3.0 根据条件删除 +int DelBy(Expression<Func<T, bool>> delWhere)
/// <summary>
/// 3.0 根据条件删除
/// </summary>
/// <param name="delWhere"></param>
/// <returns></returns>
public int DelBy(Expression<Func<T, bool>> delWhere)
{
//3.1查询要删除的数据
List<T> listDeleting = db.Set<T>().Where(delWhere).ToList();
//3.2将要删除的数据 用删除方法添加到 EF 容器中
listDeleting.ForEach(u =>
{
db.Set<T>().Attach(u);//先附加到 EF容器
db.Set<T>().Remove(u);//标识为 删除 状态
});
//3.3一次性 生成sql语句到数据库执行删除
return db.SaveChanges();
}
#endregion
#region 4.0 修改 +int Modify(T model, params string[] proNames)
/// <summary>
/// 4.0 修改,如:
/// T u = new T() { uId = 1, uLoginName = "asdfasdf" };
/// this.Modify(u, "uLoginName");
/// </summary>
/// <param name="model">要修改的实体对象</param>
/// <param name="proNames">要修改的 属性 名称</param>
/// <returns></returns>
public int Modify(T model, params string[] proNames)
{
//4.1将 对象 添加到 EF中
DbEntityEntry entry = db.Entry<T>(model);
//4.2先设置 对象的包装 状态为 Unchanged
entry.State = System.Data.EntityState.Unchanged;
//4.3循环 被修改的属性名 数组
foreach (string proName in proNames)
{
//4.4将每个 被修改的属性的状态 设置为已修改状态;后面生成update语句时,就只为已修改的属性 更新
entry.Property(proName).IsModified = true;
}
//4.4一次性 生成sql语句到数据库执行
return db.SaveChanges();
}
#endregion
#region 4.0 批量修改 +int Modify(T model, Expression<Func<T, bool>> whereLambda, params string[] modifiedProNames)
/// <summary>
/// 4.0 批量修改
/// </summary>
/// <param name="model">要修改的实体对象</param>
/// <param name="whereLambda">查询条件</param>
/// <param name="proNames">要修改的 属性 名称</param>
/// <returns></returns>
public int ModifyBy(T model, Expression<Func<T, bool>> whereLambda, params string[] modifiedProNames)
{
//4.1查询要修改的数据
List<T> listModifing = db.Set<T>().Where(whereLambda).ToList();
//获取 实体类 类型对象
Type t = typeof(T); // model.GetType();
//获取 实体类 所有的 公有属性
List<PropertyInfo> proInfos = t.GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList();
//创建 实体属性 字典集合
Dictionary<string, PropertyInfo> dictPros = new Dictionary<string, PropertyInfo>();
//将 实体属性 中要修改的属性名 添加到 字典集合中 键:属性名 值:属性对象
proInfos.ForEach(p =>
{
if (modifiedProNames.Contains(p.Name))
{
dictPros.Add(p.Name, p);
}
});
//4.3循环 要修改的属性名
foreach (string proName in modifiedProNames)
{
//判断 要修改的属性名是否在 实体类的属性集合中存在
if (dictPros.ContainsKey(proName))
{
//如果存在,则取出要修改的 属性对象
PropertyInfo proInfo = dictPros[proName];
//取出 要修改的值
object newValue = proInfo.GetValue(model, null); //object newValue = model.uName;
//4.4批量设置 要修改 对象的 属性
foreach (T usrO in listModifing)
{
//为 要修改的对象 的 要修改的属性 设置新的值
proInfo.SetValue(usrO, newValue, null); //usrO.uName = newValue;
}
}
}
//4.4一次性 生成sql语句到数据库执行
return db.SaveChanges();
}
#endregion
#region 5.0 根据条件查询 +List<T> GetListBy(Expression<Func<T,bool>> whereLambda)
/// <summary>
/// 5.0 根据条件查询 +List<T> GetListBy(Expression<Func<T,bool>> whereLambda)
/// </summary>
/// <param name="whereLambda"></param>
/// <returns></returns>
public List<T> GetListBy(Expression<Func<T, bool>> whereLambda)
{
return db.Set<T>().AsNoTracking().Where(whereLambda).ToList();
}
#endregion
#region 5.1 根据条件 排序 和查询 + List<T> GetListBy<TKey>
/// <summary>
/// 5.1 根据条件 排序 和查询
/// </summary>
/// <typeparam name="TKey">排序字段类型</typeparam>
/// <param name="whereLambda">查询条件 lambda表达式</param>
/// <param name="orderLambda">排序条件 lambda表达式</param>
/// <returns></returns>
public List<T> GetListBy<TKey>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, TKey>> orderLambda)
{
return db.Set<T>().Where(whereLambda).OrderBy(orderLambda).ToList();
}
#endregion
#region 6.0 分页查询 + List<T> GetPagedList<TKey>
/// <summary>
/// 6.0 分页查询 + List<T> GetPagedList<TKey>
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">页容量</param>
/// <param name="whereLambda">条件 lambda表达式</param>
/// <param name="orderBy">排序 lambda表达式</param>
/// <returns></returns>
public List<T> GetPagedList<TKey>(int pageIndex, int pageSize, Expression<Func<T, bool>> whereLambda, Expression<Func<T, TKey>> orderBy)
{
// 分页 一定注意: Skip 之前一定要 OrderBy
return db.Set<T>().Where(whereLambda).OrderBy(orderBy).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
}
#endregion
public T Find(params object[] keyValues)
{
return db.Set<T>().Find(keyValues);
}
public List<T> FindAll()
{
return db.Set<T>().ToList();
}
}
}

51
SjMes/PunchAssemble/MESClassLibrary/DAL/BasicDAL.cs

@ -0,0 +1,51 @@
using MESClassLibrary.BLL.Log;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
namespace MESClassLibrary.DAL
{
public class BasicDAL
{
public bool Del_Info(string tableName,string id, string userid)
{
try
{
string sql = @"update " + tableName + @" set
IsUseing = @IsUseing,
DisableUserID = @DisableUserID,
DisableTime = @DisableTime
where ID=@ID";
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@IsUseing", SqlDbType.Int);
param[0].Value = 0;
param[1] = new SqlParameter("@DisableUserID", SqlDbType.VarChar);
param[1].Value = userid;
param[2] = new SqlParameter("@DisableTime", SqlDbType.DateTime);
param[2].Value = DateTime.Now;
param[3] = new SqlParameter("@ID", SqlDbType.VarChar);
param[3].Value = id;
if (SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param) > 0)
{
return true;
}
return false;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

92
SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/BadInjectionDAL.cs

@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.BasicInfo
{
public class BadInjectionDAL
{
public static string TableName = "tb_Bad_Injection";
public bool AddInfo(BadInjectionModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (ID,OneBarCode,[BarCode],[BadPosition],[BadReason]";
sql += ") VALUES (";
sql += "@ID,";
sql += "@OneBarCode,";
sql += "@BarCode,";
sql += "@BadPosition,";
sql += "@BadReason)";
#region 添加参数
param = new SqlParameter[5];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@OneBarCode", SqlDbType.VarChar);
param[1].Value = md.OneBarCode;
param[2] = new SqlParameter("@BarCode", SqlDbType.VarChar);
param[2].Value = md.BarCode;
param[3] = new SqlParameter("@BadPosition", SqlDbType.VarChar);
param[3].Value = md.BadPosition;
param[4] = new SqlParameter("@BadReason", SqlDbType.VarChar);
param[4].Value = md.BadReason;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchByCode(string code)
{
try
{
string sql = "";
if (code.Contains("."))
{
sql = @"select * from " + TableName + " where BarCode=@BarCode";
}
else
{
sql = @"select * from " + TableName + " where OneBarCode=@BarCode";
}
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@BarCode", SqlDbType.VarChar);
param[0].Value = code;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

440
SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/BarCodeDAl.cs

@ -0,0 +1,440 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.BasicInfo
{
public class BarCodeDAl
{
public static string TableName = "tb_BarCode";
public DataTable SearchInfoByStock(string StockNo)
{
string sql = "";
DateTime time;
try
{
time = GetDateTime();
if (time.Hour>=8 &&time.Hour<=23)
{
sql = @"select top 1 * from " + TableName + " where StockNo=@StockNo and PrintType <>2 and " +
"substring([BarCode],len( [BarCode])-10,6)= right(DATENAME(yy, GETDATE()),2)+ RIGHT('00'+CAST(MONTH(GETDATE()) AS VARCHAR(2)),2)+RIGHT('00'+CAST(Day(GETDATE()) AS VARCHAR(2)),2)" +
" order by [CreateTime] desc";
}
else
{
sql = @"select top 1 * from " + TableName + " where StockNo=@StockNo and PrintType <>2 and " +
"substring([BarCode],len( [BarCode])-10,6)= right(DATENAME(yy, DATEADD(dd,-1, GETDATE())),2)+ RIGHT('00'+CAST(MONTH(DATEADD(dd,-1, GETDATE())) AS VARCHAR(2)),2)+RIGHT('00'+CAST(Day(DATEADD(dd,-1, GETDATE())) AS VARCHAR(2)),2)" +
" order by [CreateTime] desc";
}
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[0].Value = StockNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool AddInfo(BarCodeModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (ID,StationID,OneBarCode,[BarCode],[StockNo],[PrintType],[CreateTime],[IsImport],StationID2,PlanID";
sql += ") VALUES (";
sql += "@ID,";
sql += "@StationID,";
sql += "@OneBarCode,";
sql += "@BarCode,";
sql += "@StockNo,";
sql += "@PrintType,";
//sql += "@CreateTime,";
sql += "(select getdate()),";
sql += "@IsImport,";
sql += "@StationID2,";
sql += "@PlanID)";
#region 添加参数
param = new SqlParameter[9];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[1].Value = md.StationID;
param[2] = new SqlParameter("@OneBarCode", SqlDbType.VarChar);
param[2].Value = md.OneBarCode;
param[3] = new SqlParameter("@BarCode", SqlDbType.VarChar);
param[3].Value = md.BarCode;
param[4] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[4].Value = md.StockNo;
param[5] = new SqlParameter("@PrintType", SqlDbType.Int);
param[5].Value =md.PrintType;
//param[6] = new SqlParameter("@CreateTime", SqlDbType.DateTime);
//param[6].Value = md.CreateTime;
param[6] = new SqlParameter("@IsImport", SqlDbType.Text);
param[6].Value = md.Import;
param[7] = new SqlParameter("@StationID2", SqlDbType.VarChar);
param[7].Value = md.StationID2;
param[8] = new SqlParameter("@PlanID", SqlDbType.VarChar);
param[8].Value = md.PlanID;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchInfo(string stationNo)
{
try
{
string sql = @"SELECT top 100 dbo.tb_BarCode.BarCode, dbo.tb_Product.ProductName,
CASE dbo.tb_BarCode.PrintType WHEN 0 THEN '' when 1 then '' when 2 then '' END AS PrintType,
dbo.tb_BarCode.CreateTime
FROM dbo.tb_BarCode LEFT OUTER JOIN
dbo.tb_Product ON dbo.tb_BarCode.StockNo = dbo.tb_Product.StockNo LEFT OUTER JOIN
dbo.tb_Station ON dbo.tb_BarCode.StationID = dbo.tb_Station.StationID
where dbo.tb_Station.StationNo=@stationNo and IsDel=0 " +
//" and substring([BarCode],len( [BarCode])-10,6)= right(DATENAME(yy, GETDATE()),2)+ RIGHT('00'+CAST(MONTH(GETDATE()) AS VARCHAR(2)),2)+RIGHT('00'+CAST(Day(GETDATE()) AS VARCHAR(2)),2)" +
" order by [CreateTime] desc";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@stationNo", SqlDbType.VarChar);
param[0].Value = stationNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoAll()
{
try
{
string sql = @"SELECT dbo.tb_BarCode.BarCode, dbo.tb_Product.ProductName,
CASE dbo.tb_BarCode.PrintType WHEN 0 THEN '' when 1 then '' when 2 then '' END AS PrintType,
dbo.tb_BarCode.PrintTime
FROM dbo.tb_BarCode LEFT OUTER JOIN
dbo.tb_Product ON dbo.tb_BarCode.StockNo = dbo.tb_Product.StockNo LEFT OUTER JOIN
dbo.tb_Station ON dbo.tb_BarCode.StationID = dbo.tb_Station.StationID
where dbo.tb_Station.StationNo=@stationNo and IsDel=0 " +
//" and substring([BarCode],len( [BarCode])-10,6)= right(DATENAME(yy, GETDATE()),2)+ RIGHT('00'+CAST(MONTH(GETDATE()) AS VARCHAR(2)),2)+RIGHT('00'+CAST(Day(GETDATE()) AS VARCHAR(2)),2)" +
" order by [CreateTime] desc";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCode()
{
try
{
string sql = @"SELECT TOP (1000) dbo.tb_BarCode.BarCode, dbo.tb_Product.ProductName,
CASE dbo.tb_BarCode.PrintType WHEN 0 THEN '' WHEN 1 THEN '' WHEN 2 THEN '' END AS PrintType,
dbo.tb_BarCode.PrintTime, dbo.tb_BarCode.OneBarCode, dbo.tb_BarCode.PlanID,
dbo.tb_InjectPlanReport.MaterialName, dbo.tb_InjectPlanReport.BatchNo
FROM dbo.tb_BarCode LEFT OUTER JOIN
dbo.tb_InjectPlanReport ON dbo.tb_BarCode.PlanID = dbo.tb_InjectPlanReport.InjectionPlanID LEFT OUTER JOIN
dbo.tb_Product ON dbo.tb_BarCode.StockNo = dbo.tb_Product.StockNo LEFT OUTER JOIN
dbo.tb_Station ON dbo.tb_BarCode.StationID = dbo.tb_Station.StationID
WHERE (dbo.tb_BarCode.IsDel = 0)
ORDER BY dbo.tb_BarCode.CreateTime DESC";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCodeByOne(string oneBarCode)
{
try
{
string sql = @"SELECT dbo.tb_BarCode.BarCode, dbo.tb_Product.ProductName,
CASE dbo.tb_BarCode.PrintType WHEN 0 THEN '' WHEN 1 THEN '' WHEN 2 THEN '' END AS PrintType,
dbo.tb_BarCode.PrintTime, dbo.tb_BarCode.OneBarCode,dbo.tb_BarCode.PlanID,
dbo.tb_InjectPlanReport.MaterialName, dbo.tb_InjectPlanReport.BatchNo
FROM dbo.tb_BarCode LEFT OUTER JOIN
dbo.tb_InjectPlanReport ON dbo.tb_BarCode.PlanID = dbo.tb_InjectPlanReport.InjectionPlanID LEFT OUTER JOIN
dbo.tb_Product ON dbo.tb_BarCode.StockNo = dbo.tb_Product.StockNo LEFT OUTER JOIN
dbo.tb_Station ON dbo.tb_BarCode.StationID = dbo.tb_Station.StationID
WHERE dbo.tb_BarCode.IsDel = 0 and dbo.tb_BarCode.OneBarCode=@OneBarCode
ORDER BY dbo.tb_BarCode.CreateTime DESC";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@OneBarCode", SqlDbType.VarChar);
param[0].Value = oneBarCode;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCodeByTwo(string BarCode)
{
try
{
// string sql = @"SELECT dbo.tb_BarCode.BarCode, dbo.tb_Product.ProductName,
// CASE dbo.tb_BarCode.PrintType WHEN 0 THEN '自动打印' WHEN 1 THEN '手动打印' WHEN 2 THEN '补打' END AS PrintType,
// dbo.tb_BarCode.PrintTime, dbo.tb_BarCode.OneBarCode
// FROM dbo.tb_BarCode LEFT OUTER JOIN
// dbo.tb_Product ON dbo.tb_BarCode.StockNo = dbo.tb_Product.StockNo LEFT OUTER JOIN
// dbo.tb_Station ON dbo.tb_BarCode.StationID = dbo.tb_Station.StationID
// WHERE dbo.tb_BarCode.IsDel = 0 and dbo.tb_BarCode.BarCode=@BarCode
// ORDER BY dbo.tb_BarCode.CreateTime DESC";
string sql = @"SELECT dbo.tb_BarCode.BarCode, dbo.tb_Product.ProductName,
CASE dbo.tb_BarCode.PrintType WHEN 0 THEN '' WHEN 1 THEN '' WHEN 2 THEN '' END AS PrintType,
dbo.tb_BarCode.PrintTime, dbo.tb_BarCode.OneBarCode,dbo.tb_BarCode.PlanID,
dbo.tb_InjectPlanReport.MaterialName, dbo.tb_InjectPlanReport.BatchNo
FROM dbo.tb_BarCode LEFT OUTER JOIN
dbo.tb_InjectPlanReport ON dbo.tb_BarCode.PlanID = dbo.tb_InjectPlanReport.InjectionPlanID LEFT OUTER JOIN
dbo.tb_Product ON dbo.tb_BarCode.StockNo = dbo.tb_Product.StockNo LEFT OUTER JOIN
dbo.tb_Station ON dbo.tb_BarCode.StationID = dbo.tb_Station.StationID
WHERE dbo.tb_BarCode.IsDel = 0 and dbo.tb_BarCode.BarCode=@BarCode
ORDER BY dbo.tb_BarCode.CreateTime DESC";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@BarCode", SqlDbType.VarChar);
param[0].Value = BarCode;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 查找流水号
/// </summary>
/// <param name="Code">零件号.批次</param>
/// <returns></returns>
public DataTable SearchSerialNoByBarCode(string Code)
{
try
{
string sql = @"select top 1 * from " + TableName + " where left([BarCode],len([BarCode])-5)=@Code and PrintType <> 2" +
" order by [CreateTime] desc";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@Code", SqlDbType.VarChar);
param[0].Value = Code;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByBarCode(string BarCode)
{
try
{
string sql = @"select top 1 * from " + TableName + " where BarCode=@BarCode order by [CreateTime] desc ";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@BarCode", SqlDbType.VarChar);
param[0].Value = BarCode;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 更改打印时间
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool UpdateInfo(BarCodeModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = @"update tb_BarCode set PrintTime=(select getdate()) where [StationID]=@StationID and PrintTime is null";
#region 添加参数
param = new SqlParameter[1];
param[0] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[0].Value = md.StationID;
//param[1] = new SqlParameter("@PrintTime", SqlDbType.DateTime);
//param[1].Value = md.PrintTime;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 删除手工打印条码
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool DelBarCode(BarCodeModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = @"update tb_BarCode set IsDel=0 where BarCode=@BarCode";
#region 添加参数
param = new SqlParameter[1];
param[0] = new SqlParameter("@BarCode", SqlDbType.VarChar);
param[0].Value = md.BarCode;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DateTime GetDateTime()
{
string sql = "";
DateTime time;
DataTable dt;
try
{
sql = @"select getdate() as time";
dt= SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
time = Convert.ToDateTime(dt.Rows[0]["time"].ToString());
}
else
{
time=DateTime.Now;
}
return time;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return DateTime.Now;
}
}
/// <summary>
/// 根据二维码查找一维码,并查找一维码是否存在
/// </summary>
/// <param name="BarCode"></param>
/// <returns></returns>
public DataTable SearchOneBarCode(string BarCode,int a)
{
try
{
string sql = "";
SqlParameter[] param = new SqlParameter[1];
if (a == 1)
{
sql = @"select OneBarCode
from tb_BarCode
where OneBarCode = @barcode";
param[0] = new SqlParameter("@barcode", SqlDbType.VarChar);
param[0].Value = BarCode;
}
if (a == 2)
{
sql = @"select *
from tb_BarCode
where barcode = @barcode";
param[0] = new SqlParameter("@barcode", SqlDbType.VarChar);
param[0].Value = BarCode;
}
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

150
SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/BomDAL.cs

@ -0,0 +1,150 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.BasicInfo
{
public class BomDAL
{
public DataTable SearchBom(string PartNo)
{
try
{
string sql = @"SELECT dbo.tb_Product.ProductName, dbo.tb_ProductType.ProductTypeName, dbo.tb_ProductType.ProductTypeNo,
dbo.tb_Product.PartNo, dbo.tb_Bom.PartNo2, dbo.tb_Product.StockNo
FROM dbo.tb_Bom RIGHT OUTER JOIN
dbo.tb_Product ON dbo.tb_Bom.PartNo1 = dbo.tb_Product.PartNo LEFT OUTER JOIN
dbo.tb_ProductType ON dbo.tb_Product.ProductTypeID = dbo.tb_ProductType.ProductTypeID
WHERE PartNo=@PartNo";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = PartNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable Search(string partNo1, string partNo2)
{
try
{
string sql = "select * from tb_Bom where PartNo1=@partNo1,PartNo2=@partNo2";
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@@partNo1", SqlDbType.VarChar);
param[0].Value = partNo1;
param[1] = new SqlParameter("@@partNo2", SqlDbType.VarChar);
param[1].Value = partNo2;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool AddInfo(BomModel md)
{
string sql = "";
SqlParameter[] param = null;
try
{
sql = "insert into tb_Bom(ID,,PartNo1,PartNo2) values(@ID,@partNo1,@partNo2)";
param = new SqlParameter[3];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.BomID;
param[1] = new SqlParameter("@partNo1", SqlDbType.VarChar);
param[1].Value = md.PartNo1;
param[2] = new SqlParameter("@partNo2", SqlDbType.VarChar);
param[2].Value = md.PartNo2;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool updateInfo(BomModel md)
{
string sql = "";
SqlParameter[] param = null;
try
{
sql = "update tb_Bom set PartNo2=@partNo2 where PartNo1=@partNo1";
param = new SqlParameter[2];
param[0] = new SqlParameter("@partNo1", SqlDbType.VarChar);
param[0].Value = md.PartNo1;
param[1] = new SqlParameter("@partNo2", SqlDbType.VarChar);
param[1].Value = md.PartNo2;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool DelInfo(BomModel md)
{
string sql = "";
SqlParameter[] param = null;
try
{
sql = "delete from tb_Bom where PartNo1=@partNo1 and PartNo2=@partNo2 ";
param = new SqlParameter[2];
param[0] = new SqlParameter("@partNo1", SqlDbType.VarChar);
param[0].Value = md.PartNo1;
param[1] = new SqlParameter("@partNo2", SqlDbType.VarChar);
param[1].Value = md.PartNo2;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

55
SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/ColorDAL.cs

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.Model;
using MESClassLibrary.BLL.Log;
namespace MESClassLibrary.DAL.BasicInfo
{
public class ColorDAL
{
public DataTable SearchInfoAll()
{
try
{
string sql = @"select * from [tb_Color]";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchByName(string color)
{
try
{
string sql = @"select distinct [ColorNo] from [tb_Color] where [Des] like @Des";
SqlParameter[] param=new SqlParameter[1];
param[0] = new SqlParameter("@Des", SqlDbType.VarChar);
param[0].Value = color;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

35
SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/DefectDAL.cs

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.BasicInfo
{
public class DefectDAL
{
public DataTable SearchInfoAll(string LineID)
{
try
{
string sql = @"SELECT * from tb_Defect where LineID=@LineID";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@LineID", SqlDbType.VarChar);
param[0].Value = LineID;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

199
SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/InjectionPlanDAL.cs

@ -0,0 +1,199 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using System.Reflection;
namespace MESClassLibrary.DAL.BasicInfo
{
public class InjectionPlanDAL
{
public static string TableName = "tb_InjectionPlan";
/// <summary>
/// 获取当前计划
/// </summary>
/// <param name="StationID"></param>
/// <returns></returns>
public DataTable SearchPlanByStation(string StationID)
{
try
{
string sql = @"SELECT top 1 dbo.tb_InjectionPlan.InjectionPlanID, dbo.tb_Product.ProductName, dbo.tb_Station.StationNo, dbo.tb_InjectionPlan.BeginTime, dbo.tb_InjectionPlan.PlanCount,
dbo.tb_InjectionPlan.EndTime, dbo.tb_InjectionPlan.StockNo, dbo.tb_InjectionPlan.PlanDate,
dbo.tb_InjectionPlan.CompleteCount, dbo.tb_Product.PartNo, dbo.tb_Product.ProductName, dbo.tb_Product.ColorName,
dbo.tb_Product.Rows, dbo.tb_Product.Cols, dbo.tb_Product.Layers, dbo.tb_Product.PicturePath,dbo.tb_Station.StationID
FROM dbo.tb_InjectionPlan LEFT OUTER JOIN
dbo.tb_Station ON dbo.tb_InjectionPlan.StationID = dbo.tb_Station.StationID LEFT OUTER JOIN
dbo.tb_Product ON dbo.tb_InjectionPlan.StockNo = dbo.tb_Product.StockNo
WHERE (dbo.tb_Station.StationNo = @StationID) AND ((dbo.tb_InjectionPlan.IsFinish IS NULL OR dbo.tb_InjectionPlan.IsFinish=0))
ORDER BY dbo.tb_InjectionPlan.BeginTime";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[0].Value = StationID;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 获取下一计划
/// </summary>
/// <param name="StationID"></param>
/// <returns></returns>
public DataTable NextSearchPlanByStation(string StationID)
{
try
{
string sql = @"SELECT top 2 dbo.tb_Product.ProductName, dbo.tb_Station.StationNo, dbo.tb_InjectionPlan.BeginTime, dbo.tb_InjectionPlan.PlanCount,
dbo.tb_InjectionPlan.EndTime, dbo.tb_InjectionPlan.StockNo, dbo.tb_InjectionPlan.PlanDate,
dbo.tb_InjectionPlan.CompleteCount, dbo.tb_Product.PartNo, dbo.tb_Product.ProductName, dbo.tb_Product.ColorName,
dbo.tb_Product.Rows, dbo.tb_Product.Cols, dbo.tb_Product.Layers, dbo.tb_Product.PicturePath,dbo.tb_Station.StationID
FROM dbo.tb_InjectionPlan LEFT OUTER JOIN
dbo.tb_Station ON dbo.tb_InjectionPlan.StationID = dbo.tb_Station.StationID LEFT OUTER JOIN
dbo.tb_Product ON dbo.tb_InjectionPlan.StockNo = dbo.tb_Product.StockNo
WHERE (dbo.tb_Station.StationNo = @StationID) AND ((dbo.tb_InjectionPlan.IsFinish IS NULL OR dbo.tb_InjectionPlan.IsFinish=0))
ORDER BY dbo.tb_InjectionPlan.BeginTime";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[0].Value = StationID;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdateFinish(InjectionPlanModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = @"update tb_InjectionPlan set IsFinish=1 ,FinishTime=getdate()
where [InjectionPlanID]=( select top 1 [InjectionPlanID] from [dbo].[tb_InjectionPlan] where (IsFinish is null or IsFinish=0 )and StationID=@StationID order by BeginTime asc)";
#region 添加参数
param = new SqlParameter[1];
param[0] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[0].Value = md.StationID;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchByPage(int pageIndex, int pageSize, string stationID, string stockNo)
{
try
{
string sql = "select * FROM[dbo].[tb_InjectionPlan] ";
sql += " where 1=1 ";
if (!string.IsNullOrEmpty(stationID))
{
sql += " and StationID = '" + stationID + "' ";
}
if (!string.IsNullOrEmpty(stockNo))
{
sql += " and StockNo like '%" + stockNo + "%' ";
}
sql += " order by BeginTime ";
sql += " offset " + ((pageIndex - 1) * pageSize) + " rows ";
sql += " fetch next " + pageSize + " rows only ";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchByTime(int pageIndex, int pageSize, string stationID, string stockNo, string StartTime, string EndTime)
{
try
{
string sql = "select * FROM[dbo].[tb_InjectionPlan] where BeginTime>='" + StartTime + "' and BeginTime<='" + EndTime + "' ";
if (!string.IsNullOrEmpty(stationID))
{
sql += " and StationID = '" + stationID + "' ";
}
if (!string.IsNullOrEmpty(stockNo))
{
sql += " and StockNo like '%" + stockNo + "%' ";
}
sql += " order by BeginTime ";
sql += " offset " + ((pageIndex - 1) * pageSize) + " rows ";
sql += " fetch next " + pageSize + " rows only ";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public int SearchByTimeCount(string stationID, string stockNo, string StartTime, string EndTime)
{
try
{
string sql = "select * FROM[dbo].[tb_InjectionPlan] where BeginTime>='" + StartTime + "' and EndTime<='" + EndTime + "' ";
if (!string.IsNullOrEmpty(stationID))
{
sql += " and StationID = '" + stationID + "' ";
}
if (!string.IsNullOrEmpty(stockNo))
{
sql += " and StockNo like '%" + stockNo + "%' ";
}
return SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return 0;
}
}
}
}

73
SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/OperatorDAL.cs

@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
namespace MESClassLibrary.DAL.BasicInfo
{
public class OperatorDAL
{
public static string TableName = "tb_Operator";
/// <summary>
/// 根据操作员姓名和工位查询
/// </summary>
/// <param name="OperatorName"></param>
/// <returns></returns>
public DataTable SearchInfoByName(string OperatorName,string StationID)
{
try
{
string sql = @"select * from " + TableName + " where OperatorName=@OperatorName and StationID=@StationID";
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@OperatorName", SqlDbType.VarChar);
param[0].Value = OperatorName;
param[1] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[1].Value = StationID;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByNameAndPsw(string OperatorName, string StationID,string OperatorPsw)
{
try
{
string sql = @"select * from " + TableName + " where OperatorName=@OperatorName and StationID=@StationID and OperatorPsw=@OperatorPsw";
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@OperatorName", SqlDbType.VarChar);
param[0].Value = OperatorName;
param[1] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[1].Value = StationID;
param[2] = new SqlParameter("@OperatorPsw", SqlDbType.VarChar);
param[2].Value = OperatorPsw;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

245
SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/ProductDAL.cs

@ -0,0 +1,245 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
using MESClassLibrary.Model;
using MESClassLibrary.BLL.Log;
namespace MESClassLibrary.DAL.BasicInfo
{
public class ProductDAL
{
public static string TableName = "tb_ProductType";
public DataTable SearchInfoByType(string type, string stationNo)
{
try
{
string sql =
@"SELECT
dbo.tb_Product.PartName,
dbo.tb_Product.ProductName,
dbo.tb_ProductType.ProductTypeName,
dbo.tb_ProductType.ProductTypeNo,
dbo.tb_Product.PartNo,
dbo.tb_Station.StationNo,
dbo.tb_Plastic.StockNo
FROM dbo.tb_Plastic
LEFT OUTER JOIN dbo.tb_Station ON dbo.tb_Plastic.StationID = dbo.tb_Station.StationID
LEFT OUTER JOIN dbo.tb_Product ON dbo.tb_Plastic.StockNo = dbo.tb_Product.StockNo
LEFT OUTER JOIN dbo.tb_ProductType ON dbo.tb_Product.ProductTypeID = dbo.tb_ProductType.ProductTypeID
WHERE
dbo.tb_ProductType.ProductTypeNo = @ProductTypeNo
and StationNo = @StationNo";
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ProductTypeNo", SqlDbType.VarChar);
param[0].Value = type;
param[1] = new SqlParameter("@StationNo", SqlDbType.VarChar);
param[1].Value = stationNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoAllByType(string type)
{
try
{
string sql =
@"SELECT
DISTINCT dbo.tb_Product.ProductName,
dbo.tb_ProductType.ProductTypeName,
dbo.tb_ProductType.ProductTypeNo,
dbo.tb_Product.PartNo,
dbo.tb_Bom.PartNo2,
dbo.tb_Product.StockNo
FROM dbo.tb_Bom
RIGHT OUTER JOIN dbo.tb_Product ON dbo.tb_Bom.PartNo1 = dbo.tb_Product.PartNo
LEFT OUTER JOIN dbo.tb_ProductType ON dbo.tb_Product.ProductTypeID = dbo.tb_ProductType.ProductTypeID
WHERE
dbo.tb_ProductType.ProductTypeNo = @ProductTypeNo
ORDER BY
StockNo";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@ProductTypeNo", SqlDbType.VarChar);
param[0].Value = type;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByName(string ProductName, string ProductTypeNo)
{
try
{
string sql =
@"SELECT
dbo.tb_Product.PartName,
dbo.tb_Product.ProductName,
dbo.tb_ProductType.ProductTypeName,
dbo.tb_ProductType.ProductTypeNo,
dbo.tb_Product.PartNo,
dbo.tb_Product.StockNo
FROM dbo.tb_ProductType
RIGHT OUTER JOIN dbo.tb_Product ON dbo.tb_ProductType.ProductTypeID = dbo.tb_Product.ProductTypeID
where
dbo.tb_Product.ProductName = @ProductName
and dbo.tb_ProductType.ProductTypeNo = @ProductTypeNo
ORDER BY
SUBSTRING(ProductName, 0, 4)";
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@ProductName", SqlDbType.VarChar);
param[0].Value = ProductName;
param[1] = new SqlParameter("@ProductTypeNo", SqlDbType.VarChar);
param[1].Value = ProductTypeNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByPartNo(string partNo)
{
try
{
string sql = @"select * from [tb_Product] where [PartNo]=@partNo";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@partNo", SqlDbType.VarChar);
param[0].Value = partNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchIsImportByStockNo(string StockNo)
{
try
{
string sql = @"select * from [tb_Product] where [StockNo]=@StockNo";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[0].Value = StockNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByProductName(string ProductName)
{
try
{
string sql = @"select * from [tb_Product] where [ProductName]=@ProductName";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@ProductName", SqlDbType.VarChar);
param[0].Value = ProductName;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoAll()
{
try
{
string sql = @"select * from [tb_Product] where ProductTypeID='f3bbde11-7188-4910-855d-806d92d142b9' and StockNo is not null order by StockNo";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//public DataTable SearchInfoByType(string list)
//{
// try
// {
// string sql = @"select StockNo+'-'+ProductName AS aa from [tb_Product] where StockNo+'-'+ProductName like '%' + @list + '%' and [StockNo] like '2%'";
// SqlParameter[] param = new SqlParameter[1];
// param[0] = new SqlParameter("@list", SqlDbType.VarChar);
// param[0].Value = list;
// return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
// }
// catch (Exception ex)
// {
// LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
// return null;
// }
//}
public DataTable SearchInfoByStock(string StockNo)
{
try
{
string sql = @"select * from [tb_Product] where [StockNo]=@StockNo";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[0].Value = StockNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

265
SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/ProductOfInjectionDAL.cs

@ -0,0 +1,265 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
namespace MESClassLibrary.DAL.BasicInfo
{
public class ProductOfInjectionDAL
{
public static string TableName = "tb_Product_Injection";
public bool AddInfo(ProductOfInjectionModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (ID,PlanID,StationID,ProductDate,ClassName,StockNo,PartNo,ProductCount,BadCount)";
sql += " VALUES (";
sql += "@ID,";
sql += "@PlanID,";
sql += "@StationID,";
sql += "@ProductDate,";
sql += "@ClassName,";
sql += "@StockNo,";
sql += "@PartNo,";
sql += "@ProductCount,";
sql += "@BadCount)";
#region 添加参数
param = new SqlParameter[9];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@PlanID", SqlDbType.VarChar);
param[1].Value = md.PlanID;
param[2] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[2].Value = md.StationID;
param[3] = new SqlParameter("@ProductDate", SqlDbType.VarChar);
param[3].Value = md.ProductDate;
param[4] = new SqlParameter("@ClassName", SqlDbType.VarChar);
param[4].Value = md.ClassName;
param[5] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[5].Value = md.StockNo;
param[6] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[6].Value = md.PartNo;
param[7] = new SqlParameter("@ProductCount", SqlDbType.Int);
param[7].Value = md.ProductCount;
param[8] = new SqlParameter("@BadCount", SqlDbType.Int);
param[8].Value = md.BadCount;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchCountByInfo(string station,string date,string classname,string StockNo,string PartNo)
{
try
{
string sql = @"select * from " + TableName + " where StationID=@StationID and " +
"ProductDate=@ProductDate and ClassName=@ClassName and StockNo=@StockNo and PartNo=@PartNo";
SqlParameter[] param = new SqlParameter[5];
param[0] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[0].Value = station;
param[1] = new SqlParameter("@ProductDate", SqlDbType.VarChar);
param[1].Value = date;
param[2] = new SqlParameter("@ClassName", SqlDbType.VarChar);
param[2].Value = classname;
param[3] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[3].Value = StockNo;
param[4] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[4].Value = PartNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdateInfo(ProductOfInjectionModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = @"update " + TableName + " set ProductCount=ProductCount+@ProductCount,BadCount=BadCount+@BadCount where StationID=@StationID and ProductDate=@ProductDate and ClassName=@ClassName and StockNo=@StockNo and PartNo=@PartNo and PlanID=@PlanID";
#region 添加参数
param = new SqlParameter[8];
param[0] = new SqlParameter("@ProductCount", SqlDbType.Int);
param[0].Value = md.ProductCount;
param[1] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[1].Value = md.StationID;
param[2] = new SqlParameter("@ProductDate", SqlDbType.VarChar);
param[2].Value = md.ProductDate;
param[3] = new SqlParameter("@ClassName", SqlDbType.VarChar);
param[3].Value = md.ClassName;
param[4] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[4].Value = md.StockNo;
param[5] = new SqlParameter("@BadCount", SqlDbType.Int);
param[5].Value = md.BadCount;
param[6] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[6].Value = md.PartNo;
param[7] = new SqlParameter("@PlanID", SqlDbType.VarChar);
param[7].Value = md.PlanID;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdteBadInfo(ProductOfInjectionModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
if (md.StockNo != "")
{
sql = @"update " + TableName + " set BadCount=BadCount+@BadCount where StationID=@StationID and ProductDate=@ProductDate and ClassName=@ClassName and StockNo=@StockNo ";
}
else
{
sql = @"update " + TableName + " set BadCount=BadCount+@BadCount where StationID=@StationID and ProductDate=@ProductDate and ClassName=@ClassName and PartNo=@PartNo";
}
#region 添加参数
param = new SqlParameter[6];
param[0] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[0].Value = md.StationID;
param[1] = new SqlParameter("@ProductDate", SqlDbType.VarChar);
param[1].Value = md.ProductDate;
param[2] = new SqlParameter("@ClassName", SqlDbType.VarChar);
param[2].Value = md.ClassName;
param[3] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[3].Value = md.StockNo;
param[4] = new SqlParameter("@BadCount", SqlDbType.Int);
param[4].Value = md.BadCount;
param[5] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[5].Value = md.PartNo;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 开机报废减产量
/// </summary>
/// <param name="md"></param>
/// <returns></returns>
public bool updateProductCount(ProductOfInjectionModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
if (md.StockNo != "")
{
sql = @"update " + TableName + " set ProductCount=ProductCount-@ProductCount where StationID=@StationID and ProductDate=@ProductDate and ClassName=@ClassName and StockNo=@StockNo ";
}
else
{
sql = @"update " + TableName + " set ProductCount=ProductCount-@ProductCount where StationID=@StationID and ProductDate=@ProductDate and ClassName=@ClassName and PartNo=@PartNo";
}
#region 添加参数
param = new SqlParameter[6];
param[0] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[0].Value = md.StationID;
param[1] = new SqlParameter("@ProductDate", SqlDbType.VarChar);
param[1].Value = md.ProductDate;
param[2] = new SqlParameter("@ClassName", SqlDbType.VarChar);
param[2].Value = md.ClassName;
param[3] = new SqlParameter("@StockNo", SqlDbType.VarChar);
param[3].Value = md.StockNo;
param[4] = new SqlParameter("@ProductCount", SqlDbType.Int);
param[4].Value = md.ProductCount;
param[5] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[5].Value = md.PartNo;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

210
SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/ProductTypeDAL.cs

@ -0,0 +1,210 @@
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.DAL.BasicInfo
{
public class ProductTypeDAL
{
public static string TableName = "tb_ProductType";
public string GetTableName()
{
return TableName;
}
/// <summary>
/// 获取全部信息
/// </summary>
/// <returns></returns>
public DataTable SearchInfo()
{
try
{
string sql = @"select * from "+ TableName;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据id查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataTable SearchInfoByID(string ProductTypeID)
{
try
{
string sql = @"select * from "+ TableName + " where ProductTypeID=@ProductTypeID";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@ProductTypeID", SqlDbType.VarChar);
param[0].Value = ProductTypeID;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据ProductTypeNo查询信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataTable SearchByProductTypeNo(string ProductTypeNo)
{
try
{
string sql = @"select * from " + TableName + " where ProductTypeNo=@ProductTypeNo";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@ProductTypeNo", SqlDbType.VarChar);
param[0].Value = ProductTypeNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 添加信息
/// </summary>
/// <param name="mod">模型</param>
/// <returns></returns>
public bool AddInfo(ProductTypeModel mod)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (ProductTypeID,ProductTypeNo,ProductTypeName,Des";
sql += ") VALUES (";
sql += "@ProductTypeID,";
sql += "@ProductTypeNo,";
sql += "@ProductTypeName,";
sql += "@Des)";
#region 添加参数
param = new SqlParameter[4];
param[0] = new SqlParameter("@ProductTypeID", SqlDbType.VarChar);
param[0].Value = mod.ProductTypeID;
param[1] = new SqlParameter("@ProductTypeNo", SqlDbType.VarChar);
param[1].Value = mod.ProductTypeNo;
param[2] = new SqlParameter("@ProductTypeName", SqlDbType.VarChar);
param[2].Value = mod.ProductTypeName;
param[3] = new SqlParameter("@Des", SqlDbType.VarChar);
param[3].Value = mod.Des;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 更新信息
/// </summary>
/// <param name="md">模型对象</param>
/// <returns></returns>
public bool UpdateInfo(ProductTypeModel md)
{
try
{
string sql = @"update " + TableName + @" set
ProductTypeNo = @ProductTypeNo,
ProductTypeName = @ProductTypeName,
Des = @Des
where ProductTypeID=@ProductTypeID";
SqlParameter[] param = new SqlParameter[4];
param[0] = new SqlParameter("@ProductTypeNo", SqlDbType.VarChar);
param[0].Value = md.ProductTypeNo;
param[1] = new SqlParameter("@ProductTypeName", SqlDbType.VarChar);
param[1].Value = md.ProductTypeName;
param[2] = new SqlParameter("@Des", SqlDbType.VarChar);
param[2].Value = md.Des;
param[3] = new SqlParameter("@ProductTypeID", SqlDbType.VarChar);
param[3].Value = md.ProductTypeID;
if (SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param) > 0)
{
return true;
}
return false;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 更新信息
/// </summary>
/// <param name="md">模型对象</param>
/// <returns></returns>
public bool DeleteInfo(string ProductTypeID)
{
try
{
string sql = @"delete from " + TableName + @" where ProductTypeID=@ProductTypeID";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@ProductTypeID", SqlDbType.VarChar);
param[0].Value = ProductTypeID;
if (SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param) > 0)
{
return true;
}
return false;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

38
SjMes/PunchAssemble/MESClassLibrary/DAL/BasicInfo/StationDAL.cs

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
namespace MESClassLibrary.DAL.BasicInfo
{
public class StationDAL
{
public static string TableName = "tb_Station";
public DataTable SearchInfoByNo(string station)
{
try
{
string sql = @"select * from " + TableName + " where StationNo=@StationNo";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@StationNo", SqlDbType.VarChar);
param[0].Value = station;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

253
SjMes/PunchAssemble/MESClassLibrary/DAL/Check/InspectResultDAL.cs

@ -0,0 +1,253 @@
using MESClassLibrary.BLL.Log;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.DAL.Check
{
public class InspectResultDAL
{
public DataTable SearchByPage(int pageIndex, int pageSize, string StartTime, string EndTime, string position, string inspectResult)
{
try
{
//string sql = @"select top " + pageSize + " * from (select row_number() over(order by createTime desc) as rownumber,* from tb_InspectResult) temp_row ";
//sql += " where createTime>='"+ StartTime + "' and createTime<='" + EndTime + "'";
//if (!string.IsNullOrEmpty(position))
//{
// sql += " and position = '" + position+"'";
//}
//if (!string.IsNullOrEmpty(inspectResult))
//{
// sql += " and inspectResult like '%" + inspectResult + "%'";
//}
//sql += " and rownumber > " + ((pageIndex - 1) * pageSize);
string sql = "select * FROM[dbo].[tb_InspectResult] where barcode in ";
sql += "(select barcode from(select distinct barcode, createTime from [dbo].[tb_InspectResult] ";
sql += " where barcode is not null and createTime>='" + StartTime + "' and createTime<='" + EndTime + "' ";
if (!string.IsNullOrEmpty(position))
{
sql += " and position = '" + position + "' ";
}
if (!string.IsNullOrEmpty(inspectResult))
{
sql += " and inspectResult like '%" + inspectResult + "%' ";
}
sql += " order by createTime ";
sql += " offset " + ((pageIndex - 1) * pageSize) + " rows ";
sql += " fetch next " + pageSize + " rows only) temp_row) ";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchRepairByPage(int pageIndex, int pageSize, string StartTime, string EndTime, string inspectResult)
{
try
{
string sql = @" SELECT * FROM dbo.tb_InspectResult ";
//sql += "(select barcode from(select distinct barcode, createTime from [dbo].[tb_InspectResult] ";
sql += " where barcode IS NOT NULL AND createTime BETWEEN '" + StartTime + "' AND '" + EndTime + ".999' and position='下线二检 点修补'";
if (!string.IsNullOrEmpty(inspectResult))
{
sql += " and inspectResult like '%" + inspectResult + "%' ";
}
sql += " order by createTime ";
sql += " offset " + ((pageIndex - 1) * pageSize) + " rows ";
sql += " fetch next " + pageSize + " rows only ";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public int SearchCount(string StartTime, string EndTime, string position, string inspectResult)
{
try
{
string sql = "select count(1) as num from (select barcode as num FROM[dbo].[tb_InspectResult] where barcode in ";
sql += "(select distinct barcode from [dbo].[tb_InspectResult] ";
sql += " where barcode is not null and createTime>='" + StartTime + "' and createTime<='" + EndTime + "' ";
if (!string.IsNullOrEmpty(position))
{
sql += " and position = '" + position + "' ";
}
if (!string.IsNullOrEmpty(inspectResult))
{
sql += " and inspectResult like '%" + inspectResult + "%' ";
}
sql += " ) GROUP BY barcode) tem";
//string sql = "select count(1) as num FROM[dbo].[tb_InspectResult] ";
//sql += " where barcode is not null and createTime>='" + StartTime + "' and createTime<='" + EndTime + "' ";
//if (!string.IsNullOrEmpty(position))
//{
// sql += " and position = '" + position + "' ";
//}
//if (!string.IsNullOrEmpty(inspectResult))
//{
// sql += " and inspectResult like '%" + inspectResult + "%' ";
//}
return Convert.ToInt32(SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0].Rows[0]["num"].ToString());
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return 0;
}
}
public int SearchCountByRepair(string StartTime, string EndTime, string inspectResult)
{
string sql = @" SELECT COUNT(*) as num FROM dbo.tb_InspectResult ";
//sql += "(select barcode from(select distinct barcode, createTime from [dbo].[tb_InspectResult] ";
sql += " where barcode IS NOT NULL AND createTime BETWEEN '" + StartTime + "' AND '" + EndTime + ".999' and position='下线二检 点修补'";
//string sql = @" SELECT COUNT(DISTINCT barcode) as num FROM dbo.tb_InspectResult WHERE barcode IS NOT NULL AND createTime BETWEEN '"+ StartTime + "' AND '"+ EndTime + ".999' AND position='下线二检 点修补'";
if (!string.IsNullOrEmpty(inspectResult))
{
sql += " and inspectResult like '%" + inspectResult + "%' ";
}
return Convert.ToInt32(SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0].Rows[0]["num"].ToString());
}
public DataTable Search(string StartTime, string EndTime, string position, string inspectResult)
{
try
{
string sql = "select * FROM[dbo].[tb_InspectResult] where barcode in ";
sql += "(select distinct barcode from [dbo].[tb_InspectResult] ";
sql += " where barcode is not null and createTime<='" + EndTime + "' and createTime>='" + StartTime + "' ";
if (!string.IsNullOrEmpty(position))
{
sql += " and position = '" + position + "' ";
}
if (!string.IsNullOrEmpty(inspectResult))
{
sql += " and inspectResult like '%" + inspectResult + "%' ";
}
sql += " ) order by createTime";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchByRepair(string StartTime, string EndTime, string inspectResult)
{
try
{
string sql = "select * FROM dbo.tb_InspectResult ";
sql += " where barcode IS NOT NULL AND createTime BETWEEN '" + StartTime + "' AND '" + EndTime + ".999' AND position='下线二检 点修补'";
if (!string.IsNullOrEmpty(inspectResult))
{
sql += " and inspectResult like '%" + inspectResult + "%' ";
}
sql += " order by createTime";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchByPosition(string StartTime, string EndTime, string side, string product)
{
try
{
string sql = "select * FROM[dbo].[tb_InspectResult] ";
sql += " where barcode is not null and createTime BETWEEN '" + StartTime + "' AND '" + EndTime + "'";
if (!string.IsNullOrEmpty(side))
{
if ("A侧".Equals(side))
{
sql += " and (side = '" + side + "' or side ='' or side is null) ";
}
if ("B侧".Equals(side))
{
sql += " and side = '" + side + "' ";
}
}
if (!string.IsNullOrEmpty(product))
{
if ("保险杠".Equals(product))
{
sql += " and (product like '%前保%' or product like '%后保%')";
}
}
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchByResult(string StartTime, string EndTime, string side)
{
try
{
string sql = "select ID,barcode,side,position,stationNo,workClass,inspectResult,damnPosition,defectID,reason,productInfo,productOption,createTime,InspectTimes,replace(remark1,' ','') as remark1,remark2,remark3 FROM[dbo].[tb_InspectResult] ";
sql += " where barcode is not null and createTime BETWEEN '" + StartTime + "' and '" + EndTime + "' ";
sql += " and remark1 is not null and remark2 is not null";
if (!string.IsNullOrEmpty(side))
{
if ("A侧".Equals(side))
{
sql += " and (side = '" + side + "' or side ='' or side is null) ";
}
if ("B侧".Equals(side))
{
sql += " and side = '" + side + "' ";
}
}
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

80
SjMes/PunchAssemble/MESClassLibrary/DAL/DataTableExtend.cs

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace MESClassLibrary.DAL
{
public static class DataTableExtend
{
/// <summary>
/// 返回执行Select distinct后的DataTable
/// </summary>
/// <param name="SourceTable">源数据表</param>
/// <param name="FieldNames">字段集</param>
/// <returns></returns>
public static DataTable SelectDistinct(DataTable SourceTable, params string[] FieldNames)
{
object[] lastValues;
DataTable newTable;
DataRow[] orderedRows;
if (FieldNames == null || FieldNames.Length == 0)
throw new ArgumentNullException("FieldNames");
lastValues = new object[FieldNames.Length];
newTable = new DataTable();
foreach (string fieldName in FieldNames)
newTable.Columns.Add(fieldName, SourceTable.Columns[fieldName].DataType);
orderedRows = SourceTable.Select("", string.Join(",", FieldNames));
foreach (DataRow row in orderedRows)
{
if (!fieldValuesAreEqual(lastValues, row, FieldNames))
{
newTable.Rows.Add(createRowClone(row, newTable.NewRow(), FieldNames));
setLastValues(lastValues, row, FieldNames);
}
}
return newTable;
}
private static bool fieldValuesAreEqual(object[] lastValues, DataRow currentRow, string[] fieldNames)
{
bool areEqual = true;
for (int i = 0; i < fieldNames.Length; i++)
{
//if (lastValues[i] == null || !lastValues[i].Equals(currentRow[fieldNames[i]]))
//品牌字母有的大写,有的小写
//if(lastValues[i] == null || lastValues[i].ToString().ToUpper()!= currentRow[fieldNames[i]].ToString().ToUpper())
if(lastValues[i] == null || lastValues[i].ToString()!= currentRow[fieldNames[i]].ToString())
{
areEqual = false;
break;
}
}
return areEqual;
}
private static DataRow createRowClone(DataRow sourceRow, DataRow newRow, string[] fieldNames)
{
foreach (string field in fieldNames)
newRow[field] = sourceRow[field].ToString();//品牌字母有的大写,有的小写
return newRow;
}
private static void setLastValues(object[] lastValues, DataRow sourceRow, string[] fieldNames)
{
for (int i = 0; i < fieldNames.Length; i++)
lastValues[i] = sourceRow[fieldNames[i]];
}
}
}

123
SjMes/PunchAssemble/MESClassLibrary/DAL/ExchangeCenter/GetNewTasksDAL.cs

@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.ExchangeCenter
{
public class GetNewTasksDAL
{
public static string TableName = "tb_GetNewTasks";
public bool AddInfo(GetNewTasksModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " ([TaskState] ,[TaskID] ,[TableName],[TableName2],[TableName3],[Creator],[DataCount],[Subscriber] ,[FailedCount],[FailedInfo],[Domain],[Site],[GUID] ,[UID],[CreateUser],[CreateTime],[Remark],[UpdateUser] ,[UpdateTime],[IsChecked]";
sql += ") VALUES (";
sql += "@TaskState,";
sql += "@TaskID,";
sql += "@TableName,";
sql += "@TableName2,";
sql += "@TableName3,";
sql += "@Creator,";
sql += "@DataCount,";
sql += "@Subscriber,";
sql += "@FailedCount,";
sql += "@FailedInfo,";
sql += "@Domain,";
sql += "@Site,";
sql += "@GUID,";
sql += "@UID,";
sql += "@CreateUser,";
sql += "@CreateTime,";
sql += "@Remark,";
sql += "@UpdateUser,";
sql += "@UpdateTime,";
sql += "@IsChecked)";
#region 添加参数
param = new SqlParameter[20];
param[0] = new SqlParameter("@TaskState", SqlDbType.VarChar);
param[0].Value = md.TaskState;
param[1] = new SqlParameter("@TaskID", SqlDbType.VarChar);
param[1].Value = md.TaskID;
param[2] = new SqlParameter("@TableName", SqlDbType.VarChar);
param[2].Value = md.TableName;
param[3] = new SqlParameter("@TableName2", SqlDbType.VarChar);
param[3].Value = md.TableName2;
param[4] = new SqlParameter("@TableName3", SqlDbType.VarChar);
param[4].Value = md.TableName3;
param[5] = new SqlParameter("@Creator", SqlDbType.VarChar);
param[5].Value = md.Creator;
param[6] = new SqlParameter("@DataCount", SqlDbType.VarChar);
param[6].Value = md.DataCount;
param[7] = new SqlParameter("@Subscriber", SqlDbType.VarChar);
param[7].Value = md.Subscriber;
param[8] = new SqlParameter("@FailedCount", SqlDbType.VarChar);
param[8].Value = md.FailedCount;
param[9] = new SqlParameter("@FailedInfo", SqlDbType.VarChar);
param[9].Value = md.FailedInfo;
param[10] = new SqlParameter("@Domain", SqlDbType.VarChar);
param[10].Value = md.Domain;
param[11] = new SqlParameter("@Site", SqlDbType.VarChar);
param[11].Value = md.Site;
param[12] = new SqlParameter("@GUID", SqlDbType.VarChar);
param[12].Value = md.GUID;
param[13] = new SqlParameter("@UID", SqlDbType.VarChar);
param[13].Value = md.UID;
param[14] = new SqlParameter("@CreateUser", SqlDbType.VarChar);
param[14].Value = md.CreateUser;
param[15] = new SqlParameter("@CreateTime", SqlDbType.VarChar);
param[15].Value = md.CreateTime;
param[16] = new SqlParameter("@Remark", SqlDbType.VarChar);
param[16].Value = md.Remark;
param[17] = new SqlParameter("@UpdateUser", SqlDbType.VarChar);
param[17].Value = md.UpdateUser;
param[18] = new SqlParameter("@UpdateTime", SqlDbType.VarChar);
param[18].Value = md.UpdateTime;
param[19] = new SqlParameter("@IsChecked", SqlDbType.VarChar);
param[19].Value = md.IsChecked;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

110
SjMes/PunchAssemble/MESClassLibrary/DAL/ExchangeCenter/PartMstrDAL.cs

@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.ExchangeCenter
{
public class PartMstrDAL
{
public static string TableName = "TES_PART_MSTR";
public bool AddInfo(PartMstrModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (GUID,PartCode,Desc1,Desc2,Um,ProdLine,AddDate,PartType,Status,Qgrade,InventoryCode,UID,Remark,TaskID,CommandType,Domain,Site";
sql += ") VALUES (";
sql += "@GUID,";
sql += "@PartCode,";
sql += "@Desc1,";
sql += "@Desc2,";
sql += "@Um,";
sql += "@ProdLine,";
sql += "@AddDate,";
sql += "@PartType,";
sql += "@Status,";
sql += "@Qgrade,";
sql += "@InventoryCode,";
sql += "@UID,";
sql += "@Remark,";
sql += "@TaskID,";
sql += "@CommandType,";
sql += "@Domain,";
sql += "@Site)";
#region 添加参数
param = new SqlParameter[17];
param[0] = new SqlParameter("@GUID", SqlDbType.VarChar);
param[0].Value = md.GUID;
param[1] = new SqlParameter("@PartCode", SqlDbType.VarChar);
param[1].Value = md.PartCode;
param[2] = new SqlParameter("@Desc1", SqlDbType.VarChar);
param[2].Value = md.Desc1;
param[3] = new SqlParameter("@Desc2", SqlDbType.VarChar);
param[3].Value = md.Desc2;
param[4] = new SqlParameter("@Um", SqlDbType.VarChar);
param[4].Value = md.Um;
param[5] = new SqlParameter("@ProdLine", SqlDbType.VarChar);
param[5].Value = md.ProdLine;
param[6] = new SqlParameter("@AddDate", SqlDbType.VarChar);
param[6].Value = md.AddDate;
param[7] = new SqlParameter("@PartType", SqlDbType.VarChar);
param[7].Value = md.PartType;
param[8] = new SqlParameter("@Status", SqlDbType.VarChar);
param[8].Value = md.Status;
param[9] = new SqlParameter("@Qgrade", SqlDbType.VarChar);
param[9].Value = md.Qgrade;
param[10] = new SqlParameter("@InventoryCode", SqlDbType.VarChar);
param[10].Value = md.InventoryCode;
param[11] = new SqlParameter("@UID", SqlDbType.VarChar);
param[11].Value = md.UID;
param[12] = new SqlParameter("@Remark", SqlDbType.VarChar);
param[12].Value = md.Remark;
param[13] = new SqlParameter("@TaskID", SqlDbType.VarChar);
param[13].Value = md.TaskID;
param[14] = new SqlParameter("@CommandType", SqlDbType.VarChar);
param[14].Value = md.CommandType;
param[15] = new SqlParameter("@Domain", SqlDbType.VarChar);
param[15].Value = md.Domain;
param[16] = new SqlParameter("@Site", SqlDbType.VarChar);
param[16].Value = md.Site;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

46
SjMes/PunchAssemble/MESClassLibrary/DAL/ExchangeCenter/PartRecordDAL.cs

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.ExchangeCenter
{
public class PartRecordDAL
{
public bool AddInfo(PartRecordModel md)
{
try
{
string sql =@"insert into tb_PartRecord (ID,PartNo,TaskID,CommandType) values(@ID,@PartNo,@TaskID,@CommandType)";
SqlParameter[] param=new SqlParameter[4];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[1].Value = md.PartNo;
param[3] = new SqlParameter("@TaskID", SqlDbType.VarChar);
param[3].Value = md.TaskID;
param[4] = new SqlParameter("@CommandType", SqlDbType.VarChar);
param[4].Value = md.CommandType;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

177
SjMes/PunchAssemble/MESClassLibrary/DAL/ExchangeCenter/TESBomDAL.cs

@ -0,0 +1,177 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.ExchangeCenter
{
public class TESBomDAL
{
public static string TableName = "TES_BOM";
public bool AddInfo(TESBomModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (ParentPart,ComponentPart,Reference,StartEffective,QuantityPer,StructureType,EndEffective,Remarks,Scrap,LeadTimeOffset,Operation,SequenceNumber,FporecastPercent,OptionGroup,Process,GUID,UID,CreateUser,CreateTime,Remark,TaskID,CommandType,DataID,Domain,Site";
sql += ") VALUES (";
sql += "@ParentPart,";
sql += "@ComponentPart,";
sql += "@Reference,";
sql += "@StartEffective,";
sql += "@QuantityPer,";
sql += "@StructureType,";
sql += "@EndEffective,";
sql += "@Remarks,";
sql += "@Scrap,";
sql += "@LeadTimeOffset,";
sql += "@Operation,";
sql += "@SequenceNumber,";
sql += "@FporecastPercent,";
sql += "@OptionGroup,";
sql += "@Process,";
sql += "@GUID,";
sql += "@UID,";
sql += "@CreateUser,";
sql += "@CreateTime,";
sql += "@Remark,";
sql += "@TaskID,";
sql += "@CommandType,";
sql += "@DataID,";
sql += "@Domain,";
sql += "@Site)";
#region 添加参数
param = new SqlParameter[25];
param[0] = new SqlParameter("@ParentPart", SqlDbType.VarChar);
param[0].Value = md.ParentPart;
param[1] = new SqlParameter("@ComponentPart", SqlDbType.VarChar);
param[1].Value = md.ComponentPart;
param[2] = new SqlParameter("@Reference", SqlDbType.VarChar);
param[2].Value = md.Reference;
param[3] = new SqlParameter("@StartEffective", SqlDbType.VarChar);
param[3].Value = md.StartEffective;
param[4] = new SqlParameter("@QuantityPer", SqlDbType.VarChar);
param[4].Value = md.QuantityPer;
param[5] = new SqlParameter("@StructureType", SqlDbType.VarChar);
param[5].Value = md.StructureType;
param[6] = new SqlParameter("@EndEffective", SqlDbType.VarChar);
param[6].Value = md.EndEffective;
param[7] = new SqlParameter("@Remarks", SqlDbType.VarChar);
param[7].Value = md.Remarks;
param[8] = new SqlParameter("@Scrap", SqlDbType.VarChar);
param[8].Value = md.Scrap;
param[9] = new SqlParameter("@LeadTimeOffset", SqlDbType.VarChar);
param[9].Value = md.LeadTimeOffset;
param[10] = new SqlParameter("@Operation", SqlDbType.VarChar);
param[10].Value = md.Operation;
param[11] = new SqlParameter("@SequenceNumber", SqlDbType.VarChar);
param[11].Value = md.SequenceNumber;
param[12] = new SqlParameter("@FporecastPercent", SqlDbType.VarChar);
param[12].Value = md.FporecastPercent;
param[13] = new SqlParameter("@OptionGroup", SqlDbType.VarChar);
param[13].Value = md.OptionGroup;
param[14] = new SqlParameter("@Process", SqlDbType.VarChar);
param[14].Value = md.Process;
param[15] = new SqlParameter("@GUID", SqlDbType.VarChar);
param[15].Value = md.GUID;
param[16] = new SqlParameter("@UID", SqlDbType.VarChar);
param[16].Value = md.UID;
param[17] = new SqlParameter("@CreateUser", SqlDbType.VarChar);
param[17].Value = md.CreateUser;
param[18] = new SqlParameter("@CreateTime", SqlDbType.VarChar);
param[18].Value = md.CreateTime;
param[19] = new SqlParameter("@Remark", SqlDbType.VarChar);
param[19].Value = md.Remark;
param[20] = new SqlParameter("@TaskID", SqlDbType.VarChar);
param[20].Value = md.TaskID;
param[21] = new SqlParameter("@CommandType", SqlDbType.VarChar);
param[21].Value = md.CommandType;
param[22] = new SqlParameter("@DataID", SqlDbType.VarChar);
param[22].Value = md.DataID;
param[23] = new SqlParameter("@Domain", SqlDbType.VarChar);
param[23].Value = md.Domain;
param[24] = new SqlParameter("@Site", SqlDbType.VarChar);
param[24].Value = md.Site;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable Search()
{
try
{
string sql = "select * from " + TableName + " where ParentPart like '%-P' and ComponentPart like 'ROH%' and Flag=0";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdateFlag(string TaskID)
{
try
{
string sql = "update " + TableName + " set Flag=1 where TaskID=@TaskID";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@TaskID", SqlDbType.VarChar);
param[0].Value = TaskID;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

93
SjMes/PunchAssemble/MESClassLibrary/DAL/ExchangeCenter/TESPartDetDAL.cs

@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.ExchangeCenter
{
public class TESPartDetDAL
{
public static string TableName = "TES_PART_DET";
public bool AddInfo(TESPartDetModel md)
{
try
{
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " ([GUID],[PartCode],[Site],[KeyPart],SetupTime,UID,CreateUser,CreateTime,Remark,TaskID,CommandType,DataID,Domain";
sql += ") VALUES (";
sql += "@GUID,";
sql += "@PartCode,";
sql += "@Site,";
sql += "@KeyPart,";
sql += "@SetupTime,";
sql += "@UID,";
sql += "@CreateUser,";
sql += "@CreateTime,";
sql += "@Remark,";
sql += "@TaskID,";
sql += "@CommandType,";
sql += "@DataID,";
sql += "@Domain)";
#region 添加参数
param = new SqlParameter[13];
param[0] = new SqlParameter("@GUID", SqlDbType.VarChar);
param[0].Value = md.GUID;
param[1] = new SqlParameter("@PartCode", SqlDbType.VarChar);
param[1].Value = md.PartCode;
param[2] = new SqlParameter("@Site", SqlDbType.VarChar);
param[2].Value = md.Site;
param[3] = new SqlParameter("@KeyPart", SqlDbType.VarChar);
param[3].Value = md.KeyPart;
param[4] = new SqlParameter("@SetupTime", SqlDbType.VarChar);
param[4].Value = md.SetupTime;
param[5] = new SqlParameter("@UID", SqlDbType.VarChar);
param[5].Value = md.UID;
param[6] = new SqlParameter("@CreateUser", SqlDbType.VarChar);
param[6].Value = md.CreateUser;
param[7] = new SqlParameter("@CreateTime", SqlDbType.VarChar);
param[7].Value = md.CreateTime;
param[8] = new SqlParameter("@Remark", SqlDbType.VarChar);
param[8].Value = md.Remark;
param[9] = new SqlParameter("@TaskID", SqlDbType.VarChar);
param[9].Value = md.TaskID;
param[10] = new SqlParameter("@CommandType", SqlDbType.VarChar);
param[10].Value = md.CommandType;
param[11] = new SqlParameter("@DataID", SqlDbType.VarChar);
param[11].Value = md.DataID;
param[12] = new SqlParameter("@Domain", SqlDbType.VarChar);
param[12].Value = md.Domain;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}

31
SjMes/PunchAssemble/MESClassLibrary/DAL/Injection/DownReasonDAL.cs

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
namespace MESClassLibrary.DAL.Injection
{
public class DownReasonDAL
{
public DataTable SearchReason()
{
try
{
string sql = @"select * from tb_Inhection_DownReason";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

159
SjMes/PunchAssemble/MESClassLibrary/DAL/Injection/InjectionDownRecordDAL.cs

@ -0,0 +1,159 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.Injection
{
public class InjectionDownRecordDAL
{
public static string TableName = "tb_Injection_DownRecord";
public bool AddInfo(InjectionDownRecordModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = " IF NOT EXISTS (SELECT * FROM tb_Injection_DownRecord WHERE StationID=@StationID AND EndTime IS NULL ) INSERT INTO " + TableName + " ([ID] ,[StationID] ,[DownType],[DownReason],[Des],[StartTime]";
sql += ") VALUES (";
sql += "@ID,";
sql += "@StationID,";
sql += "@DownType,";
sql += "@DownReason,";
sql += "@Des,";
sql += "@StartTime)";
#region 添加参数
param = new SqlParameter[6];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[1].Value = md.StationID;
param[2] = new SqlParameter("@DownType", SqlDbType.VarChar);
param[2].Value = md.DownType;
param[3] = new SqlParameter("@DownReason", SqlDbType.VarChar);
param[3].Value = md.DownReason;
param[4] = new SqlParameter("@Des", SqlDbType.VarChar);
param[4].Value = md.Des;
param[5] = new SqlParameter("@StartTime", SqlDbType.DateTime);
param[5].Value = md.StartTime;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateInfo(InjectionDownRecordModel md)
{
try
{
#region 添加数据
//string sql = @"update " + TableName + " set EndTime=@EndTime WHERE [StationID]=@StationID AND EndTime IS NULL ";
string sql = @"update " + TableName + " set DownType=@DownType,DownReason=@DownReason,Des=@Des WHERE ID=(select top 1 ID from tb_Injection_DownRecord where [StationID]=@StationID AND EndTime IS NULL order by StartTime DESC)";
SqlParameter[] param = null;
#region 添加参数
param = new SqlParameter[4];
param[0] = new SqlParameter("@StationID", SqlDbType.VarChar);
param[0].Value = md.StationID;
param[1] = new SqlParameter("@DownType", SqlDbType.VarChar);
param[1].Value = md.DownType;
param[2] = new SqlParameter("@DownReason", SqlDbType.VarChar);
param[2].Value = md.DownReason;
param[3] = new SqlParameter("@Des", SqlDbType.VarChar);
param[3].Value = md.Des;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchByTime(string StartTime, string EndTime)
{
try
{
string sql = @" SELECT * FROM dbo.tb_Injection_DownRecord ";
sql += " where StationID is not null and StartTime>='" + StartTime + "' and EndTime<='" + EndTime + "'";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchChangeRecord(string StartTime, string EndTime, string ModelId)
{
try
{
string sql = @" SELECT s.StationNo,m.PrintDate,d.StartTime,d.DownTime,d.EndTime,m.ModelSumCount,m.ModelPrintCount,d.remark1 FROM (SELECT * FROM [dbo].[tb_ModelCount] WHERE ";
sql += "ModelID = '" + ModelId + "' and PrintDate>= '"+ StartTime + "' and PrintDate<= '"+ EndTime + "') as m ";
sql += "left join (SELECT* FROM [dbo].[tb_Injection_DownRecord] where StationID is not null and StartTime>='" + StartTime + "' and EndTime<='" + EndTime + "') as d on m.StationID = d.StationID left join tb_Station s on d.StationID = s.StationID";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
//故障停机查询
public DataTable SearchRepaorByTime(string StartTime, string EndTime)
{
try
{
string sql = @" SELECT d.StationID,s.StationNo,d.StartTime,d.EndTime,d.DownTime,d.Des,d.Remark1,d.Remark2,d.Remark3 FROM dbo.tb_Injection_DownRecord d ";
sql += " left join tb_Station s on d.StationID = s.StationID ";
sql += " where d.StationID is not null and d.StartTime>='" + StartTime + "' and d.EndTime<='" + EndTime + "' and d.DownType='F1F851FB-8913-40B7-A992-F28A3FD25054' order by d.StartTime";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

113
SjMes/PunchAssemble/MESClassLibrary/DAL/Injection/InjectionRecordDAL.cs

@ -0,0 +1,113 @@
using MESClassLibrary.BLL.Log;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MESClassLibrary.DAL.Injection
{
public class InjectionRecordDAL
{
public DataTable SearchByTime(string StartTime, string EndTime)
{
try
{
string sql = "select * FROM [dbo].[tb_Product_Injection] ";
sql += " where ProductDate is not null and ProductDate>='" + StartTime + "' and ProductDate<='" + EndTime + "'";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchProductInjectionRecord(string StartTime, string EndTime) {
string sql = "SELECT t.PlanID,t.ProductDate,t.ClassName,s.StationNo,p.ProductName,r.MaterialName,r.BatchNo,pl.OpenDebugTime,pl.CycleTime,i.RealCycle,i.PlanCount,t.ProductCount,t.BadCount,pl.Weight,ir.Waste_Weight,ir.JK_Weight,i.BeginTime,i.EndTime ";
sql += " FROM[dbo].[tb_Product_Injection] t ";
sql += " left join tb_Product p on t.PartNo = p.PartNo ";
sql += " left join tb_Station s on t.StationID = s.StationID ";
sql += " left join tb_InjectPlanReport r on t.PlanID = r.InjectionPlanID ";
sql += " left join tb_Plastic pl on t.StockNo = pl.StockNo and t.StationID = pl.StationID ";
sql += " left join tb_InjectionPlan i on t.PlanID = i.InjectionPlanID ";
sql += " left join tb_Injection_Record ir on t.PlanID = ir.PlanID ";
sql += " where t.ProductDate >='" + StartTime + "' and t.ProductDate <='" + EndTime + "' order by t.ProductDate,t.ClassName,t.StationID";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
public DataTable SearchProductInjectionRecordBadReason(string StartTime, string EndTime)
{
string sql = "SELECT bc.PlanID,bi.BadReason from tb_Bad_Injection bi ";
sql += " left join tb_BarCode bc on bi.OneBarCode = bc.OneBarCode ";
sql += " where bc.PlanID in (SELECT PlanID FROM tb_Product_Injection t where t.ProductDate >='"+ StartTime + "' and t.ProductDate <='"+ EndTime + "')";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
public DataTable SearchProductInjectionRecordDownReason(string StartTime, string EndTime)
{
string sql = "SELECT PlanID,DownTime,DownTypeName,Reason from tb_Injection_DownRecord r ";
sql += " left join tb_Injection_DownType t on r.DownType = t.ID ";
sql += " left join tb_Inhection_DownReason s on r.DownReason = s.ID ";
sql += " where r.PlanID in (SELECT PlanID FROM tb_Product_Injection t where t.ProductDate >='" + StartTime + "' and t.ProductDate <='" + EndTime + "') and DownTime is not null";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
public DataTable SearchProductInjection(string StartTime, string EndTime,string StationID)
{
string sql = "SELECT t.ID,t.ProductDate,t.ClassName,s.StationNo,t.StockNo,t.PartNo,t.ProductCount,ir.RealCycle,ir.Waste_Weight,ir.JK_Weight ";
sql += " FROM[dbo].[tb_Product_Injection] t ";
sql += " left join tb_Station s on t.StationID = s.StationID ";
sql += " left join tb_Injection_Record ir on t.ID = ir.PI_ID ";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
public DataTable SearchRecordByPage(int pageIndex, int pageSize, string StartTime, string EndTime, string StationID)
{
try
{
string sql = @"SELECT t.ID,t.ProductDate,t.ClassName,t.StationID,s.StationNo,t.StockNo,t.PartNo,t.ProductCount,ir.RealCycle,ir.Waste_Weight,ir.JK_Weight ";
sql += " FROM[dbo].[tb_Product_Injection] t ";
sql += " left join tb_Station s on t.StationID = s.StationID ";
sql += " left join tb_Product_Injection_w ir on t.ID = ir.ID ";
sql += " where t.ProductDate >='" + StartTime + "' and t.ProductDate <='" + EndTime + "' ";
if (!string.IsNullOrEmpty(StationID))
{
sql += " and t.StationID = '" + StationID + "' ";
}
sql += " order by t.ProductDate,t.ClassName,t.StationID ";
sql += " offset " + ((pageIndex - 1) * pageSize) + " rows ";
sql += " fetch next " + pageSize + " rows only ";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

202
SjMes/PunchAssemble/MESClassLibrary/DAL/Mistake247/AssemblyDAL.cs

@ -0,0 +1,202 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.Mistake247
{
public class AssemblyDAL
{
public static string TableName = "tb_Assembly_247";
public bool AddInfo(AssemblyModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (ID,PartNo,PartName,BatchNo,Color,ColorNo,PartType,TapeBatchNo,Validity,ValidityDate,Des,Flag";
sql += ") VALUES (";
sql += "@ID,";
sql += "@PartNo,";
sql += "@PartName,";
sql += "@BatchNo,";
sql += "@Color,";
sql += "@ColorNo,";
sql += "@PartType,";
sql += "@TapeBatchNo,";
sql += "@Validity,";
sql += "@ValidityDate,";
sql += "@Des,";
sql += "@Flag)";
#region 添加参数
param = new SqlParameter[12];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[1].Value = md.PartNo;
param[2] = new SqlParameter("@PartName", SqlDbType.VarChar);
param[2].Value = md.PartName;
param[3] = new SqlParameter("@BatchNo", SqlDbType.VarChar);
param[3].Value = md.BatchNo;
param[4] = new SqlParameter("@Color", SqlDbType.VarChar);
param[4].Value = md.Color;
param[5] = new SqlParameter("@ColorNo", SqlDbType.VarChar);
param[5].Value = md.ColorNo;
param[6] = new SqlParameter("@PartType", SqlDbType.VarChar);
param[6].Value = md.PartType;
param[7] = new SqlParameter("@TapeBatchNo", SqlDbType.VarChar);
param[7].Value = md.TapeBatchNo;
param[8] = new SqlParameter("@Validity", SqlDbType.VarChar);
param[8].Value = md.Validity;
param[9] = new SqlParameter("@ValidityDate", SqlDbType.VarChar);
param[9].Value = md.ValidityDate;
param[10] = new SqlParameter("@Des", SqlDbType.VarChar);
param[10].Value = md.Des;
param[11] = new SqlParameter("@Flag", SqlDbType.Int);
param[11].Value = md.Flag;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateInfo(AssemblyModel md)
{
string sql = "";
SqlParameter[] param = null;
try
{
sql = "update " + TableName + " set PrintTime=(select getdate()) where substring (PartNo,1,11)= @PartNo and (PrintTime is null or PrintTime='')";
param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = md.PartNo.Substring(0,11);
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchCount(string PartNo)
{
try
{
string sql = @"SELECT count(*) as sum from tb_Assembly_247 where PartNo=@PartNo and IsPrintBox=0";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = PartNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdatePrintFlag(AssemblyModel md)
{
string sql = "";
SqlParameter[] param = null;
try
{
sql = "update " + TableName + " set IsPrintBox=1 where PartNo=@PartNo and IsPrintBox =0";
param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = md.PartNo;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdatePrintFlag1(string partno)
{
string sql = "";
SqlParameter[] param = null;
try
{
sql = "update " + TableName + " set IsPrintBox=1 where PartNo=@PartNo and IsPrintBox =0";
param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = partno;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable searchPartNo(string partNo)
{
try
{
string sql = @"SELECT top 1 * from tb_Assembly_247 where PartNo like '%" + partNo + "%' and Flag=0 order by CreateTime desc";
//SqlParameter[] param = new SqlParameter[1];
//param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
//param[0].Value = partNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

168
SjMes/PunchAssemble/MESClassLibrary/DAL/Mistake247/BoxDAL.cs

@ -0,0 +1,168 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.Mistake247
{
public class BoxDAL
{
public static string TableName = "tb_Box_247";
public bool AddInfo(BoxModel md)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (ID,BoxNo,PartNo,PartName,BatchNo,BoxCount,Des,Flag,Validity,ValidityDate";
sql += ") VALUES (";
sql += "@ID,";
sql += "@BoxNo,";
sql += "@PartNo,";
sql += "@PartName,";
sql += "@BatchNo,";
sql += "@BoxCount,";
sql += "@Des,";
sql += "@Flag,";
sql += "@Validity,";
sql += "@ValidityDate)";
#region 添加参数
param = new SqlParameter[10];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@BoxNo", SqlDbType.VarChar);
param[1].Value = md.BoxNo;
param[2] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[2].Value = md.PartNo;
param[3] = new SqlParameter("@PartName", SqlDbType.VarChar);
param[3].Value = md.PartName;
param[4] = new SqlParameter("@BatchNo", SqlDbType.VarChar);
param[4].Value = md.BatchNo;
param[5] = new SqlParameter("@BoxCount", SqlDbType.Int);
param[5].Value = md.BoxCount;
param[6] = new SqlParameter("@Des", SqlDbType.VarChar);
param[6].Value = md.Des;
param[7] = new SqlParameter("@Flag", SqlDbType.Int);
param[7].Value = md.Flag;
param[8] = new SqlParameter("@Validity", SqlDbType.VarChar);
param[8].Value = md.Validity;
param[9] = new SqlParameter("@ValidityDate", SqlDbType.VarChar);
param[9].Value = md.ValidityDate;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchByNo(string PartNo,string BatchNo)
{
try
{
string sql = @"SELECT top 1 * from " + TableName + " where PartNo=@PartNo and SUBSTRING(BoxNo,13,6)=@BatchNo order by CreateTime";
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = PartNo;
param[1] = new SqlParameter("@BatchNo", SqlDbType.VarChar);
param[1].Value = BatchNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdateInfo(BoxModel md)
{
try
{
string sql = "";
SqlParameter[] param = null;
sql = "update " + TableName + " set PrintTime=(select getdate()) where PartNo=@PartNo and PrintTime is null";
param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = md.PartNo;
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchBox(string partno)
{
try
{
string sql = @"SELECT top 1 * from " + TableName + " where PartNo=@PartNo and Flag=0 order by CreateTime";
SqlParameter[] param = null;
param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = partno;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBoxIsExsit(string box)
{
try
{
string sql = @"SELECT * from " + TableName + " where BoxNo=@BoxNo";
SqlParameter[] param = null;
param = new SqlParameter[1];
param[0] = new SqlParameter("@BoxNo", SqlDbType.VarChar);
param[0].Value = box;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

104
SjMes/PunchAssemble/MESClassLibrary/DAL/Mistake247/MistakeDAL.cs

@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
namespace MESClassLibrary.DAL.Mistake247
{
public class MistakeDAL
{
public DataTable IsMath(string DeviceNo, string PartNo)
{
try
{
string sql = @"SELECT * from tb_Mistake_247 where DeviceNo=@DeviceNo and PartNo1=@PartNo";
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@DeviceNo", SqlDbType.VarChar);
param[0].Value = DeviceNo;
param[1] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[1].Value = PartNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchByNo(string PartNo, string deviceNo)
{
try
{
string sql = @"SELECT * from tb_Mistake_247 where PartNo1=@PartNo and DeviceNo=@deviceNo";
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = PartNo;
param[1] = new SqlParameter("@deviceNo", SqlDbType.VarChar);
param[1].Value = deviceNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchPartName(string PartNo)
{
try
{
string sql = @"SELECT * from tb_Mistake_247 where [PartNo2]=@PartNo ";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = PartNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchPartNoByDecice(string deviceNo)
{
try
{
string sql = @"SELECT * from tb_Mistake_247 where DeviceNo=@DeviceNo ";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@DeviceNo", SqlDbType.VarChar);
param[0].Value = deviceNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

214
SjMes/PunchAssemble/MESClassLibrary/DAL/Mistake247/Plan247DAL.cs

@ -0,0 +1,214 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
namespace MESClassLibrary.DAL.Mistake247
{
public class Plan247DAL
{
public static string TableName = "tb_Plan_247";
public DataTable SearhByOrderNo(string OrderNo)
{
try
{
string sql = @"SELECT dbo.tb_Plan_247.OrderNo, dbo.tb_Plan_247.PartNo, dbo.tb_Mistake_247.PartName2,
dbo.tb_Plan_247.OrderCount,dbo.tb_Plan_247.IsFinish,dbo.tb_Plan_247.CompleteCount
FROM dbo.tb_Plan_247 LEFT OUTER JOIN
dbo.tb_Mistake_247 ON dbo.tb_Plan_247.PartNo = dbo.tb_Mistake_247.PartNo2
where dbo.tb_Plan_247.OrderNo=@OrderNo
ORDER BY dbo.tb_Plan_247.CreateTime";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@OrderNo", SqlDbType.VarChar);
param[0].Value = OrderNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable DetailOrderNo(string OrderNo)
{
try
{
string sql = @"SELECT dbo.tb_Plan_247.Item, dbo.tb_Plan_247.PartNo, dbo.tb_Mistake_247.PartName2,
dbo.tb_Plan_247.OrderCount
FROM dbo.tb_Plan_247 LEFT OUTER JOIN
dbo.tb_Mistake_247 ON dbo.tb_Plan_247.PartNo = dbo.tb_Mistake_247.PartNo2
where dbo.tb_Plan_247.OrderNo=@OrderNo
ORDER BY dbo.tb_Plan_247.CreateTime";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@OrderNo", SqlDbType.VarChar);
param[0].Value = OrderNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据半成品零件号查找扫描的订单中是否有此产品的生产计划
/// </summary>
/// <param name="Part1"></param>
/// <returns></returns>
public DataTable IsHavePlan(string partNo1,string orderNo)
{
try
{
string sql = @"SELECT top 1 dbo.tb_Plan_247.OrderNo, dbo.tb_Plan_247.Item, dbo.tb_Plan_247.PartNo,
dbo.tb_Plan_247.OrderCount, dbo.tb_Plan_247.CompleteCount, dbo.tb_Mistake_247.PartNo1
FROM dbo.tb_Plan_247 LEFT OUTER JOIN
dbo.tb_Mistake_247 ON dbo.tb_Plan_247.PartNo = dbo.tb_Mistake_247.PartNo2
where PartNo1=@PartNo1 and OrderNo =@orderNo and IsFinish =0
ORDER BY dbo.tb_Plan_247.CreateTime";
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@PartNo1", SqlDbType.VarChar);
param[0].Value = partNo1;
param[1] = new SqlParameter("@orderNo", SqlDbType.VarChar);
param[1].Value = orderNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 根据半成品零件号查找订单号
/// </summary>
/// <param name="partNo1"></param>
/// <returns></returns>
public DataTable SearchOrderNoByPart1(string partNo1)
{
try
{
string sql = @"SELECT top 1 dbo.tb_Plan_247.OrderNo, dbo.tb_Plan_247.Item, dbo.tb_Plan_247.PartNo,
dbo.tb_Plan_247.OrderCount, dbo.tb_Plan_247.CompleteCount, dbo.tb_Mistake_247.PartNo1
FROM dbo.tb_Plan_247 LEFT OUTER JOIN
dbo.tb_Mistake_247 ON dbo.tb_Plan_247.PartNo = dbo.tb_Mistake_247.PartNo2
where PartNo1=@PartNo1 and IsFinish =0
ORDER BY dbo.tb_Plan_247.CreateTime ";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo1", SqlDbType.VarChar);
param[0].Value = partNo1;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearhCountByOrderNo(string OrderNo,string partNo)
{
try
{
string sql = @"SELECT dbo.tb_Plan_247.OrderNo, dbo.tb_Plan_247.PartNo, dbo.tb_Mistake_247.PartName2,
dbo.tb_Plan_247.OrderCount,dbo.tb_Plan_247.IsFinish
FROM dbo.tb_Plan_247 LEFT OUTER JOIN
dbo.tb_Mistake_247 ON dbo.tb_Plan_247.PartNo = dbo.tb_Mistake_247.PartNo2
where dbo.tb_Plan_247.OrderNo=@OrderNo and dbo.tb_Plan_247.PartNo=@PartNo
ORDER BY dbo.tb_Plan_247.CreateTime";
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@OrderNo", SqlDbType.VarChar);
param[0].Value = OrderNo;
param[1] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[1].Value = partNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 更新订单完成数
/// </summary>
/// <param name="partno"></param>
/// <param name="orderNo"></param>
/// <returns></returns>
public bool UpdateCount(string partNo, string orderNo)
{
try
{
string sql = "update tb_Plan_247 set [CompleteCount]=[CompleteCount]+1 where OrderNo=@OrderNo and PartNo =@PartNo";
SqlParameter[] param = null;
#region 添加参数
param = new SqlParameter[2];
param[0] = new SqlParameter("@OrderNo", SqlDbType.VarChar);
param[0].Value = orderNo;
param[1] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[1].Value = partNo;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchPlanIDByOrderNo(string partNo, string orderNo)
{
try
{
string sql = @"select ID from tb_Plan_247 where OrderNo=@OrderNo and PartNo =@PartNo";
SqlParameter[] param = null;
#region 添加参数
param = new SqlParameter[2];
param[0] = new SqlParameter("@OrderNo", SqlDbType.VarChar);
param[0].Value = orderNo;
param[1] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[1].Value = partNo;
#endregion
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

311
SjMes/PunchAssemble/MESClassLibrary/DAL/Mistake247/RecordDAL.cs

@ -0,0 +1,311 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
namespace MESClassLibrary.DAL.Mistake247
{
public class RecordDAL
{
public static string TableName = "tb_Record_247";
/// <summary>
/// 查找半成品是否已经装配
/// </summary>
/// <param name="PartNo"></param>
/// <returns></returns>
public DataTable SearchByPartNo1(string PartNo)
{
try
{
string sql = @"SELECT * from " + TableName + " where PartNo1=@PartNo";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = PartNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchCountByBox(string boxNo)
{
try
{
string sql = @"SELECT count(*) as sum from " + TableName + " where BoxNo=@BoxNo and Flag <>2";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@BoxNo", SqlDbType.VarChar);
param[0].Value = boxNo;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool AddInfo(RecordModel md)
{
try
{
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (ID,PartNo1,PartNo2,OrderNo,Type";
sql += ") VALUES (";
sql += "@ID,";
sql += "@PartNo1,";
sql += "@PartNo2,";
sql += "@OrderNo,";
sql += "@Type)";
#region 添加参数
param = new SqlParameter[5];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = md.ID;
param[1] = new SqlParameter("@PartNo1", SqlDbType.VarChar);
param[1].Value = md.PartNo1;
param[2] = new SqlParameter("@PartNo2", SqlDbType.VarChar);
param[2].Value = md.PartNo2;
param[3] = new SqlParameter("@OrderNo", SqlDbType.VarChar);
param[3].Value = md.OrderNo;
param[4] = new SqlParameter("@Type", SqlDbType.Int);
param[4].Value = md.Type;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool updateBoxInfo(RecordModel md)
{
try
{
string sql = "";
SqlParameter[] param = null;
sql = @"update " + TableName + " set BoxNo=@BoxNo,CreateTime2=(select getdate()),Flag=@Flag where PartNo2=@PartNo2";
#region 添加参数
param = new SqlParameter[3];
param[0] = new SqlParameter("@BoxNo", SqlDbType.VarChar);
param[0].Value = md.BoxNo;
param[1] = new SqlParameter("@Flag", SqlDbType.Int);
param[1].Value = md.Flag;
param[2] = new SqlParameter("@PartNo2", SqlDbType.VarChar);
param[2].Value = md.PartNo2;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchState(int type1,int type2,int type3)
{
try
{
//string sql = @"SELECT * from " + TableName + " where Type in (@type1,@type2,@type3) and Flag =0 order by CreateTime1";
//string sql = @"SELECT * from " + TableName + " where Type in (@type1,@type2,@type3) and Flag =0 order by CreateTime1";
//string sql = @"SELECT * from " + TableName + " where Type in (@type1,@type2,@type3) and Flag =0 order by CreateTime1";
string sql = @"
SELECT * from tb_record_247 where Type in (@type1,@type2,@type3) and Flag =0 AND CreateTime1 >= CONVERT(VARCHAR(10),GETDATE(),120) AND CreateTime1 < (CONVERT(VARCHAR(10),GETDATE(),120)+' 23:59:59') order by CreateTime1
";
SqlParameter[] param = new SqlParameter[3];
param[0] = new SqlParameter("@type1", SqlDbType.Int);
param[0].Value = type1;
param[1] = new SqlParameter("@type2", SqlDbType.Int);
param[1].Value = type2;
param[2] = new SqlParameter("@type3", SqlDbType.Int);
param[2].Value = type3;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool DelInfo(RecordModel md)
{
try
{
string sql = "";
SqlParameter[] param = null;
sql = @"update " + TableName + " set Flag=@Flag where PartNo2=@PartNo2";
#region 添加参数
param = new SqlParameter[2];
param[0] = new SqlParameter("@Flag", SqlDbType.Int);
param[0].Value = md.Flag;
param[1] = new SqlParameter("@PartNo2", SqlDbType.VarChar);
param[1].Value = md.PartNo2;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SearchBoxByPart(string part)
{
try
{
string sql = @"SELECT top 1 * from " + TableName + " where SUBSTRING(PartNo2,1,11)=@PartNo2 order by CreateTime2 desc";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo2", SqlDbType.VarChar);
param[0].Value = part;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchByPartNo2(string partno)
{
try
{
string sql = @"SELECT * from " + TableName + " where PartNo2=@PartNo";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@PartNo", SqlDbType.VarChar);
param[0].Value = partno;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable GetCount(string part,string batch)
{
try
{
string sql = @"SELECT count(*) as sum from " + TableName + " where SUBSTRING(PartNo2,1,11)=@PartNo2 and SUBSTRING(PartNo2,13,6)=@batch ";
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@PartNo2", SqlDbType.VarChar);
param[0].Value = part;
param[1] = new SqlParameter("@batch", SqlDbType.VarChar);
param[1].Value = batch;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable GetRecord(string boxNo)
{
try
{
string sql = @"
SELECT PartNo2,CreateTime1 FROM tb_record_247 WHERE boxno = '" + boxNo + @"' ORDER BY createtime1
";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
///根据改订单的生产数量
/// </summary>
/// <param name="orderno"></param>
/// <returns></returns>
public DataTable GetOrderNum(string orderno)
{
try
{
string sql = @"SELECT count(*) as sum from tb_record_247 where OrderNo=@OrderNo";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@OrderNo", SqlDbType.VarChar);
param[0].Value = orderno;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

13
SjMes/PunchAssemble/MESClassLibrary/DAL/Plan247/Plan247DAL.cs

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MESClassLibrary.DAL.Plan247
{
public class Plan247DAL
{
}
}

37
SjMes/PunchAssemble/MESClassLibrary/DAL/PunchAndWeld/PunchAdressDAL.cs

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
namespace MESClassLibrary.DAL.PunchAndWeld
{
public class PunchAdressDAL
{
public DataTable SearchInfo(string deviceNo ,int i)
{
try
{
string sql = @"SELECT * from tb_PunchAddress where DeviceNo=@DeviceNo and RW=@RW order by ID";
SqlParameter[] param = null;
param = new SqlParameter[2];
param[0] = new SqlParameter("@DeviceNo", SqlDbType.VarChar);
param[0].Value = deviceNo;
param[1] = new SqlParameter("@RW", SqlDbType.Int);
param[1].Value = i;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

42
SjMes/PunchAssemble/MESClassLibrary/DAL/PunchAndWeld/PunchAndStationDAL.cs

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
namespace MESClassLibrary.DAL.PunchAndWeld
{
public class PunchAndStationDAL
{
public DataTable IsMath(string partNo1, string partNo2)
{
try
{
string sql = @"SELECT tb_Product_1.PartNo AS PartNo1, tb_Product_1.ProductName AS ProductName1, dbo.tb_Product.PartNo AS PartNo2,
dbo.tb_Product.ProductName AS ProductName2
FROM dbo.tb_PunchAndStation LEFT OUTER JOIN
dbo.tb_Product ON dbo.tb_PunchAndStation.ProductID2 = dbo.tb_Product.ProductID LEFT OUTER JOIN
dbo.tb_Product AS tb_Product_1 ON dbo.tb_PunchAndStation.ProductID1 = tb_Product_1.ProductID
where tb_Product_1.PartNo=@partNo1 and dbo.tb_Product.PartNo =@partNo2";
SqlParameter[] param = null;
param = new SqlParameter[2];
param[0] = new SqlParameter("@partNo1", SqlDbType.VarChar);
param[0].Value = partNo1;
param[1] = new SqlParameter("@partNo2", SqlDbType.VarChar);
param[1].Value = partNo2;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

51
SjMes/PunchAssemble/MESClassLibrary/DAL/PunchAndWeld/PunchDeviceDAL.cs

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
namespace MESClassLibrary.DAL.PunchAndWeld
{
public class PunchDeviceDAL
{
public DataTable SearchInfo()
{
try
{
string sql = @"select * from tb_PunchDevice ";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchDeviceNo(string deviceName)
{
try
{
string sql = @"select * from tb_PunchDevice where DeviceName=@DeviceName";
SqlParameter[] param = null;
param = new SqlParameter[1];
param[0] = new SqlParameter("@DeviceName", SqlDbType.VarChar);
param[0].Value = deviceName;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save