From e2a6a632bac998225c96474778d45007f1cc5b8e Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期五, 25 八月 2023 11:23:26 +0800
Subject: [PATCH] 添加项目文件。
---
VueWebCoreApi/Models/TreeObejct.cs | 23
VueWebCoreApi/Excel/往来单位.xls | 0
VueWebCoreApi/Models/RolePermission/RolePermissionSava.cs | 60
VueWebCoreApi.sln | 25
VueWebCoreApi/Models/CapacityPlanningSetup.cs | 21
VueWebCoreApi/DLL/BLL/ExcelCheckBLL.cs | 34
VueWebCoreApi/Models/RoleUserSubmit.cs | 14
VueWebCoreApi/Models/DeviceRepair.cs | 25
VueWebCoreApi/DLL/DAL/DeviceManagerDAL.cs | 2800 +++++
VueWebCoreApi/DLL/DAL/LoginDAL.cs | 498
VueWebCoreApi/Models/AppDevicecCheck.cs | 24
VueWebCoreApi/Excel/物料清单.xls | 0
VueWebCoreApi/Models/PartRout.cs | 15
VueWebCoreApi/Quartz/HttpManager.cs | 73
VueWebCoreApi/Tools/CoreHttpContext .cs | 36
VueWebCoreApi/Excel/用户清单.xls | 0
VueWebCoreApi/DLL/BLL/DeviceManagerBLL.cs | 323
VueWebCoreApi/Models/ScanStartReportDataOut.cs | 29
VueWebCoreApi/Excel/设备保养标准.xls | 0
VueWebCoreApi/Quartz/QuartzSearchData.cs | 116
VueWebCoreApi/DLL/DAL/GeneralBasicDataDAL.cs | 190
VueWebCoreApi/Excel/缺陷定义.xls | 0
VueWebCoreApi/Excel/设备清单.xls | 0
VueWebCoreApi/Models/AppLabCode.cs | 27
VueWebCoreApi/SignalR/UserIdsStore.cs | 15
VueWebCoreApi/Models/StepDefect.cs | 15
VueWebCoreApi/Properties/launchSettings.json | 38
VueWebCoreApi/Quartz/HttpContext.cs | 20
VueWebCoreApi/Models/APSList.cs | 19
VueWebCoreApi/Models/ObjectDataCont.cs | 15
VueWebCoreApi/Models/RolePermission/MenuItem.cs | 34
VueWebCoreApi/Excel/设备点检项目.xls | 0
VueWebCoreApi/Models/AppVersion.cs | 16
VueWebCoreApi/Models/ApsOrderSerch.cs | 35
VueWebCoreApi/.config/dotnet-tools.json | 5
VueWebCoreApi/Models/EqpRepair.cs | 17
VueWebCoreApi/Models/RolePermission/RolePermission.cs | 50
VueWebCoreApi/DLL/BLL/BaseDateBLL.cs | 104
VueWebCoreApi/Tools/ToMessage.cs | 24
VueWebCoreApi/Tools/DALSkillCondition.cs | 34
VueWebCoreApi/Models/BomSub.cs | 17
VueWebCoreApi/Tools/Encrypt.cs | 143
VueWebCoreApi/Tools/JwtTools.cs | 133
VueWebCoreApi/DLL/BLL/GeneralBasicDataBLL.cs | 55
VueWebCoreApi/DLL/DAL/SystemSettingDAL.cs | 355
VueWebCoreApi/Models/AppPurchOrderSave.cs | 56
VueWebCoreApi/Tools/AppLableBarCode.cs | 183
VueWebCoreApi/DLL/DAL/BasicSettingDAL.cs | 2284 ++++
VueWebCoreApi/Config/log4net.config | 38
VueWebCoreApi/Tools/ExcelModelCheck.cs | 14
VueWebCoreApi/Models/ChanjetEncryptMsg.cs | 17
VueWebCoreApi/DLL/BLL/LoginBLL.cs | 66
VueWebCoreApi/Quartz/HttpResultfulJob.cs | 94
VueWebCoreApi/Tools/ChannelActionFilterAttribute.cs | 70
VueWebCoreApi/Tools/DownLoad.cs | 572 +
VueWebCoreApi/Tools/SchedulingMethod.cs | 75
VueWebCoreApi/Tools/ScanStartReport.cs | 1185 ++
VueWebCoreApi/Quartz/QuartzNETExtension.cs | 512 +
VueWebCoreApi/Models/StepCheck.cs | 16
VueWebCoreApi/VueWebCoreApi.csproj | 60
VueWebCoreApi/Models/MaterialRout.cs | 18
VueWebCoreApi/Quartz/JobAction.cs | 18
VueWebCoreApi/Tools/DapperHelper.cs | 775 +
VueWebCoreApi/Models/CapaPlan.cs | 26
VueWebCoreApi/Models/Uom.cs | 15
VueWebCoreApi/Models/AppScheduleKanban.cs | 44
VueWebCoreApi/Tools/Regedit.cs | 573 +
VueWebCoreApi/Tools/SeachEncode.cs | 368
VueWebCoreApi/Quartz/TaskAuthorAttribute.cs | 13
VueWebCoreApi/Excel/角色清单.xls | 0
VueWebCoreApi/Models/AdvancedSchedAlready.cs | 17
VueWebCoreApi/Models/RoutEdit.cs | 18
VueWebCoreApi/Tools/ImportExcelData.cs | 4472 ++++++++
VueWebCoreApi/Tools/LogHelper.cs | 86
VueWebCoreApi/Excel/节拍工价.xls | 0
VueWebCoreApi/Quartz/QuartzFileInfo.cs | 22
VueWebCoreApi/Quartz/FileHelper.cs | 113
VueWebCoreApi/Controllers/TaskBackGroundController.cs | 137
VueWebCoreApi/Controllers/GeneralBasicDataController.cs | 93
VueWebCoreApi/Quartz/FileQuartz.cs | 130
VueWebCoreApi/appsettings.Development.json | 9
VueWebCoreApi/Controllers/BasicSettingController.cs | 491
VueWebCoreApi/Quartz/TaskOptions.cs | 21
VueWebCoreApi/Tools/DataOperator.cs | 1374 ++
VueWebCoreApi/DLL/DAL/ExcelCheckDAL.cs | 275
.dockerignore | 25
VueWebCoreApi/Models/AdvancedSchedulingDevice.cs | 28
VueWebCoreApi/SignalR/IChatClient.cs | 13
VueWebCoreApi/Tools/AppSetting.cs | 33
VueWebCoreApi/Tools/ExcelList.cs | 52
VueWebCoreApi/Controllers/SystemSettingController.cs | 163
VueWebCoreApi/Tools/ChannelActionFilterAttributeApp.cs | 38
VueWebCoreApi/DLL/DAL/BaseDateDAL.cs | 417
VueWebCoreApi/Tools/DBHelper.cs | 731 +
VueWebCoreApi/Tools/RedisHelper.cs | 267
VueWebCoreApi/DLL/DAL/ProductionManagementDAL.cs | 5214 ++++++++++
VueWebCoreApi/Models/StandEqp.cs | 25
VueWebCoreApi/Quartz/TaskLog.cs | 14
VueWebCoreApi/Models/TreeDG.cs | 16
VueWebCoreApi/Models/ObjectData.cs | 14
VueWebCoreApi/libman.json | 14
VueWebCoreApi/Quartz/IOCJobFactory.cs | 28
VueWebCoreApi/DLL/BLL/SystemSettingBLL.cs | 78
VueWebCoreApi/Models/CapacityPlanSect.cs | 15
VueWebCoreApi/Quartz/IPathProvider.cs | 48
VueWebCoreApi/Controllers/ClientHubController.cs | 31
VueWebCoreApi/Excel/设备保养项目.xls | 0
VueWebCoreApi/SignalR/ChatHub.cs | 87
VueWebCoreApi/ApiGroup/OpenApiGroup.cs | 24
VueWebCoreApi/Quartz/ConvertPath.cs | 22
VueWebCoreApi/Tools/SeachEncodeJob.cs | 265
VueWebCoreApi/Models/User.cs | 45
VueWebCoreApi/DLL/BLL/ProductionManagementBLL.cs | 441
VueWebCoreApi/Dockerfile | 25
VueWebCoreApi/appsettings.json | 32
VueWebCoreApi/Excel/仓库库位清单.xls | 0
VueWebCoreApi/Quartz/StaticHttpContextExtensions.cs | 20
VueWebCoreApi/Controllers/LoginController.cs | 280
VueWebCoreApi/Models/AnDnDate.cs | 23
VueWebCoreApi/Program.cs | 26
VueWebCoreApi/Tools/TJson.cs | 30
VueWebCoreApi/Models/AlreadyScheduling.cs | 15
VueWebCoreApi/Models/ExcelErro.cs | 15
VueWebCoreApi/Excel/设备点检标准.xls | 0
VueWebCoreApi/Models/ScanStartReportData.cs | 31
VueWebCoreApi/Models/StepEqp.cs | 23
VueWebCoreApi/DLL/BLL/BasicSettingBLL.cs | 281
VueWebCoreApi/Startup.cs | 166
VueWebCoreApi/Tools/NPOIHelper.cs | 190
VueWebCoreApi/Tools/ImportExcel.cs | 1277 ++
VueWebCoreApi/Models/TreeDM.cs | 31
VueWebCoreApi/Models/ReportDefectHandle.cs | 13
132 files changed, 30,453 insertions(+), 0 deletions(-)
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..3729ff0
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,25 @@
+**/.classpath
+**/.dockerignore
+**/.env
+**/.git
+**/.gitignore
+**/.project
+**/.settings
+**/.toolstarget
+**/.vs
+**/.vscode
+**/*.*proj.user
+**/*.dbmdl
+**/*.jfm
+**/azds.yaml
+**/bin
+**/charts
+**/docker-compose*
+**/Dockerfile*
+**/node_modules
+**/npm-debug.log
+**/obj
+**/secrets.dev.yaml
+**/values.dev.yaml
+LICENSE
+README.md
\ No newline at end of file
diff --git a/VueWebCoreApi.sln b/VueWebCoreApi.sln
new file mode 100644
index 0000000..9c1a0f8
--- /dev/null
+++ b/VueWebCoreApi.sln
@@ -0,0 +1,25 @@
+锘�
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.32002.261
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VueWebCoreApi", "VueWebCoreApi\VueWebCoreApi.csproj", "{316CBE3A-CB91-4F63-AFA4-A8C533020BD7}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {316CBE3A-CB91-4F63-AFA4-A8C533020BD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {316CBE3A-CB91-4F63-AFA4-A8C533020BD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {316CBE3A-CB91-4F63-AFA4-A8C533020BD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {316CBE3A-CB91-4F63-AFA4-A8C533020BD7}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {AA156355-614E-45A5-ABD3-8D69FE357018}
+ EndGlobalSection
+EndGlobal
diff --git a/VueWebCoreApi/.config/dotnet-tools.json b/VueWebCoreApi/.config/dotnet-tools.json
new file mode 100644
index 0000000..b0e38ab
--- /dev/null
+++ b/VueWebCoreApi/.config/dotnet-tools.json
@@ -0,0 +1,5 @@
+{
+ "version": 1,
+ "isRoot": true,
+ "tools": {}
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/ApiGroup/OpenApiGroup.cs b/VueWebCoreApi/ApiGroup/OpenApiGroup.cs
new file mode 100644
index 0000000..411f24d
--- /dev/null
+++ b/VueWebCoreApi/ApiGroup/OpenApiGroup.cs
@@ -0,0 +1,24 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.ApiGroup
+{
+ public enum OpenApiGroup
+ {
+ [Description("鐧诲綍淇℃伅")]
+ 鐧诲綍淇℃伅 = 1,
+ [Description("鍩虹璁剧疆")]
+ 鍩虹璁剧疆 = 4,
+ [Description("鍛ㄦ湡浠诲姟")]
+ 鍛ㄦ湡浠诲姟 = 9,
+ [Description("绯荤粺璁剧疆")]
+ 绯荤粺璁剧疆 = 10,
+ [Description("閫氱敤鍩虹璧勬枡")]
+ 閫氱敤鍩虹璧勬枡 = 11
+
+
+ }
+}
diff --git a/VueWebCoreApi/Config/log4net.config b/VueWebCoreApi/Config/log4net.config
new file mode 100644
index 0000000..4581595
--- /dev/null
+++ b/VueWebCoreApi/Config/log4net.config
@@ -0,0 +1,38 @@
+锘�<?xml version="1.0" encoding="utf-8"?>
+<log4net>
+ <!-- Define some output appenders -->
+ <appender name="rollingAppender" type="log4net.Appender.RollingFileAppender">
+ <file value="Logs\log.txt" />
+ <!--杩藉姞鏃ュ織鍐呭-->
+ <appendToFile value="true" />
+ <!--闃叉澶氱嚎绋嬫椂涓嶈兘鍐橪og,瀹樻柟璇寸嚎绋嬮潪瀹夊叏-->
+ <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
+ <!--鍙互涓�:Once|Size|Date|Composite-->
+ <!--Composite涓篠ize鍜孌ate鐨勭粍鍚�-->
+ <rollingStyle value="Composite" />
+ <!--褰撳浠芥枃浠舵椂,涓烘枃浠跺悕鍔犵殑鍚庣紑-->
+ <datePattern value="yyyyMMdd.txt" />
+ <!--鏃ュ織鏈�澶т釜鏁�,閮芥槸鏈�鏂扮殑-->
+ <!--rollingStyle鑺傜偣涓篠ize鏃�,鍙兘鏈塿alue涓棩蹇�-->
+ <!--rollingStyle鑺傜偣涓篊omposite鏃�,姣忓ぉ鏈塿alue涓棩蹇�-->
+ <maxSizeRollBackups value="20" />
+ <!--鍙敤鐨勫崟浣�:KB|MB|GB-->
+ <maximumFileSize value="5MB" />
+ <!--缃负true,褰撳墠鏈�鏂版棩蹇楁枃浠跺悕姘歌繙涓篺ile鑺備腑鐨勫悕瀛�-->
+ <staticLogFileName value="true" />
+ <!--杈撳嚭绾у埆鍦↖NFO鍜孍RROR涔嬮棿鐨勬棩蹇�-->
+ <!--杩囨护绾у埆 FATAL > ERROR > WARN > INFO > DEBUG-->
+ <filter type="log4net.Filter.LevelRangeFilter">
+ <param name="LevelMin" value="WARN" />
+ <param name="LevelMax" value="FATAL" />
+ </filter>
+ <layout type="log4net.Layout.PatternLayout">
+ <conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/>
+ </layout>
+ </appender>
+ <root>
+ <priority value="ALL"/>
+ <level value="ALL"/>
+ <appender-ref ref="rollingAppender" />
+ </root>
+</log4net>
\ No newline at end of file
diff --git a/VueWebCoreApi/Controllers/BasicSettingController.cs b/VueWebCoreApi/Controllers/BasicSettingController.cs
new file mode 100644
index 0000000..934dd1c
--- /dev/null
+++ b/VueWebCoreApi/Controllers/BasicSettingController.cs
@@ -0,0 +1,491 @@
+锘縰sing Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.BLL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Models.RolePermission;
+using VueWebCoreApi.Tools;
+using static VueWebCoreApi.Models.RolePermission.RolePermissionSava;
+
+namespace VueWebCoreApi.Controllers
+{
+ [ApiExplorerSettings(GroupName = "鍩虹璁剧疆")]
+ [ApiController]
+ [Route("api/[controller]")]
+ [ChannelActionFilter]
+ public class BasicSettingController : Controller
+ {
+ //瀹氫箟鍏ㄥ眬淇℃伅杩斿洖鍙橀噺
+ ToMessage mes = new ToMessage();
+ RedisHelper redis = new RedisHelper();
+
+ #region[缁勭粐鏋舵瀯,鏌ヨ缁勭粐淇℃伅]
+ /// <summary>
+ /// 缁勭粐鏋舵瀯,鏌ヨ缁勭粐淇℃伅
+ /// </summary>
+ /// <param name="storg_code">缁勭粐缂栫爜</param>
+ /// <param name="storg_name">缁勭粐鍚嶇О</param>
+ /// <param name="page">椤电爜</param>
+ /// <param name="rows">姣忛〉鏄剧ず鏉℃暟</param>
+ /// <param name="prop">鎺掑簭瀛楁</param>
+ /// <param name="order">鎺掑簭瑙勫垯</param>
+ /// <returns></returns>
+ [Route(template: "STorgData")]
+ [HttpGet]
+ public JsonResult STorgData(string storg_code,string storg_name, int page = 0, int rows = 0, string prop = null, string order = null)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ int startNum = rows * (page - 1) + 1; //璧峰璁板綍rowNum
+ int endNum = rows * page; //缁撴潫璁板綍 rowNum
+ mes = BasicSettingBLL.STorgData(storg_code,storg_name,startNum,endNum,prop,order);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[缁勭粐鏋舵瀯鏂板缂栬緫]
+ /// <summary>
+ /// 缁勭粐鏋舵瀯鏂板缂栬緫
+ /// </summary>
+ /// <param name="obj">鎻愪氦鏁版嵁瀵硅薄</param>
+ /// <returns></returns>
+ [Route(template: "AddUpdateOrganization")]
+ [HttpPost]
+ public JsonResult AddUpdateOrganization([FromBody] JObject obj)
+ {
+ var token =HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ string OrganCode = obj["OrganCode"].ToString(); //缁勭粐缂栫爜
+ string OrganName = obj["OrganName"].ToString(); //缁勭粐鍚嶇О
+ string leve = obj["leve"].ToString(); //灞傜骇缂栫爜
+ string parent_id = obj["parent_id"].ToString(); //parent_id
+ string storgcode = obj["storgcode"].ToString(); //鎵�灞炵粍缁囩紪鐮�
+ string torg_seq = obj["torg_seq"].ToString(); //鎺掑簭搴忓彿
+ string status = obj["status"].ToString(); //鐘舵��
+ string OperType = obj["OperType"].ToString(); //鎿嶄綔绫诲瀷
+ mes = BasicSettingBLL.AddUpdateOrganization(OrganCode, OrganName, leve, parent_id, storgcode, torg_seq, status, OperType, us);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[缁勭粐鏋舵瀯鍒犻櫎]
+ /// <summary>
+ /// 缁勭粐鏋舵瀯鍒犻櫎
+ /// </summary>
+ /// <param name="orgcode">缁勭粐缂栫爜</param>
+ /// <returns></returns>
+ [Route(template: "DeleteOrganization")]
+ [HttpPost]
+ public JsonResult DeleteOrganization(string orgcode)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ mes = BasicSettingBLL.DeleteOrganization(orgcode,us);
+ return Json(mes);
+ }
+ #endregion
+
+
+ #region[宀椾綅淇℃伅鍒楄〃鏌ヨ]
+ /// <summary>
+ /// 宀椾綅淇℃伅鍒楄〃鏌ヨ
+ /// </summary>
+ /// <param name="postcode">宀椾綅缂栫爜</param>
+ /// <param name="postname">宀椾綅鍚嶇О</param>
+ /// <param name="page">椤电爜</param>
+ /// <param name="rows">姣忛〉鏄剧ず鏉℃暟</param>
+ /// <param name="prop">鎺掑簭瀛楁</param>
+ /// <param name="order">鎺掑簭瑙勫垯</param>
+ /// <returns></returns>
+ [Route(template: "PostData")]
+ [HttpGet]
+ public JsonResult PostData(string postcode, string postname, int page = 0, int rows = 0, string prop = null, string order = null)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ int startNum = rows * (page - 1) + 1; //璧峰璁板綍rowNum
+ int endNum = rows * page; //缁撴潫璁板綍 rowNum
+ mes = BasicSettingBLL.PostData(postcode, postname, startNum, endNum, prop, order);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[宀椾綅鏂板缂栬緫]
+ /// <summary>
+ /// 宀椾綅鏂板缂栬緫
+ /// </summary>
+ /// <param name="obj">鎻愪氦鏁版嵁瀵硅薄</param>
+ /// <returns></returns>
+ [Route(template: "AddUpdatePost")]
+ [HttpPost]
+ public JsonResult AddUpdatePost([FromBody] JObject obj)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ string postcode = obj["postcode"].ToString(); //宀椾綅缂栫爜
+ string postname = obj["postname"].ToString(); //宀椾綅鍚嶇О
+ string description = obj["description"].ToString();//宀椾綅鎻忚堪
+ string status = obj["status"].ToString(); //鐘舵��
+ string OperType = obj["OperType"].ToString(); //鎿嶄綔绫诲瀷
+ mes = BasicSettingBLL.AddUpdatePost(postcode, postname, description, status, OperType, us);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[宀椾綅鍒犻櫎]
+ /// <summary>
+ /// 宀椾綅鍒犻櫎
+ /// </summary>
+ /// <param name="postcode">宀椾綅缂栫爜</param>
+ /// <returns></returns>
+ [Route(template: "DeletePost")]
+ [HttpPost]
+ public JsonResult DeletePost(string postcode)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ mes = BasicSettingBLL.DeletePost(postcode,us);
+ return Json(mes);
+ }
+ #endregion
+
+
+ #region[鐢ㄦ埛淇℃伅鍒楄〃鏌ヨ]
+ /// <summary>
+ /// 鐢ㄦ埛淇℃伅鍒楄〃鏌ヨ
+ /// </summary>
+ /// <param name="storgcode">宸︿晶缁勭粐缂栫爜</param>
+ /// <param name="usercode">鐢ㄦ埛缂栫爜</param>
+ /// <param name="username">鐢ㄦ埛鍚嶇О</param>
+ /// <param name="page">椤电爜</param>
+ /// <param name="rows">姣忛〉鏄剧ず鏉℃暟</param>
+ /// <param name="prop">鎺掑簭瀛楁</param>
+ /// <param name="order">鎺掑簭瑙勫垯</param>
+ /// <returns></returns>
+ [Route(template: "UserData")]
+ [HttpGet]
+ public JsonResult UserData(string storgcode, string usercode, string username, int page = 0, int rows = 0, string prop = null, string order = null)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ int startNum = rows * (page - 1) + 1; //璧峰璁板綍rowNum
+ int endNum = rows * page; //缁撴潫璁板綍 rowNum
+ mes = BasicSettingBLL.UserData(storgcode,usercode, username, startNum, endNum, prop, order);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[鐢ㄦ埛淇℃伅鏂板缂栬緫]
+ /// <summary>
+ /// 鐢ㄦ埛淇℃伅鏂板缂栬緫
+ /// </summary>
+ /// <param name="obj">鎻愪氦鏁版嵁</param>
+ /// <returns></returns>
+ [Route(template: "AddUpdateUserSave")]
+ [HttpPost]
+ public JsonResult AddUpdateUserSave([FromBody] JObject obj)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ string usercode = obj["usercode"].ToString(); //鐢ㄦ埛缂栫爜
+ string username = obj["username"].ToString(); //鐢ㄦ埛鍚嶇О
+ string password = obj["password"].ToString();//鐢ㄦ埛瀵嗙爜
+ string mobile = obj["mobile"].ToString();//鎵嬫満鍙�
+ string email = obj["email"].ToString();//閭
+ string storg_code = obj["storg_code"].ToString();//鎵�灞炵粍缁�
+ string status = obj["status"].ToString(); //鐘舵��
+ string post_code = obj["post_code"].ToString();//宀椾綅
+ string role_code = obj["role_code"].ToString();//瑙掕壊
+ string group_code = obj["group_code"].ToString();//鐝粍
+ string opertype = obj["OperType"].ToString(); //鎿嶄綔绫诲瀷
+ mes = BasicSettingBLL.AddUpdateUserSave(usercode, username, password, mobile, email, storg_code, status, post_code, role_code, group_code, opertype, us);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[鐢ㄦ埛淇℃伅鍒犻櫎]
+ /// <summary>
+ /// 鐢ㄦ埛淇℃伅鍒犻櫎
+ /// </summary>
+ /// <param name="usercode">鐢ㄦ埛缂栫爜</param>
+ /// <returns></returns>
+ [Route(template: "DeleteUserSave")]
+ [HttpPost]
+ public JsonResult DeleteUserSave(string usercode)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ mes = BasicSettingBLL.DeleteUserSave(usercode,us);
+ return Json(mes);
+ }
+ #endregion
+
+
+ #region[鐝粍淇℃伅鍒楄〃鏌ヨ]
+ /// <summary>
+ /// 鐝粍淇℃伅鍒楄〃鏌ヨ
+ /// </summary>
+ /// <param name="groupcode">鐝粍缂栫爜</param>
+ /// <param name="groupname">鐝粍鍚嶇О</param>
+ /// <param name="page">椤电爜</param>
+ /// <param name="rows">姣忛〉鏄剧ず鏉℃暟</param>
+ /// <param name="prop">鎺掑簭瀛楁</param>
+ /// <param name="order">鎺掑簭瑙勫垯</param>
+ /// <returns></returns>
+ [Route(template: "GroupData")]
+ [HttpGet]
+ public JsonResult GroupData(string groupcode, string groupname, int page = 0, int rows = 0, string prop = null, string order = null)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ int startNum = rows * (page - 1) + 1; //璧峰璁板綍rowNum
+ int endNum = rows * page; //缁撴潫璁板綍 rowNum
+ mes = BasicSettingBLL.GroupData(groupcode, groupname, startNum, endNum, prop, order);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[鐝粍鏂板缂栬緫]
+ /// <summary>
+ /// 鐝粍鏂板缂栬緫
+ /// </summary>
+ /// <param name="obj">鎻愪氦鏁版嵁瀵硅薄</param>
+ /// <returns></returns>
+ [Route(template: "AddUpdateGroup")]
+ [HttpPost]
+ public JsonResult AddUpdateGroup([FromBody] JObject obj)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ string groupcode = obj["groupcode"].ToString(); //鐝粍缂栫爜
+ string groupname = obj["groupname"].ToString(); //鐝粍鍚嶇О
+ string description = obj["description"].ToString();//鐝粍鎻忚堪
+ string status = obj["status"].ToString(); //鐘舵��
+ string OperType = obj["OperType"].ToString(); //鎿嶄綔绫诲瀷
+ mes = BasicSettingBLL.AddUpdateGroup(groupcode, groupname, description, status, OperType, us);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[鐝粍鍒犻櫎]
+ /// <summary>
+ /// 鐝粍鍒犻櫎
+ /// </summary>
+ /// <param name="groupcode">鐝粍缂栫爜</param>
+ /// <returns></returns>
+ [Route(template: "DeleteGroup")]
+ [HttpPost]
+ public JsonResult DeleteGroup(string groupcode)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ mes = BasicSettingBLL.DeleteGroup(groupcode,us);
+ return Json(mes);
+ }
+ #endregion
+
+
+ #region[瑙掕壊绠$悊鍒楄〃鏌ヨ]
+ /// <summary>
+ /// 瑙掕壊绠$悊鍒楄〃鏌ヨ
+ /// </summary>
+ /// <param name="role_code">瑙掕壊缂栫爜</param>
+ /// <param name="role_name">瑙掕壊鍚嶇О</param>
+ /// <param name="page">椤电爜</param>
+ /// <param name="rows">姣忛〉鏄剧ず鏉℃暟</param>
+ /// <param name="prop">鎺掑簭瀛楁</param>
+ /// <param name="order">鎺掑簭瑙勫垯</param>
+ /// <returns></returns>
+ [Route(template: "RoleData")]
+ [HttpGet]
+ public JsonResult RoleData(string role_code, string role_name, int page = 0, int rows = 0, string prop = null, string order = null)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ int startNum = rows * (page - 1) + 1; //璧峰璁板綍rowNum
+ int endNum = rows * page; //缁撴潫璁板綍 rowNum
+ mes = BasicSettingBLL.RoleData(role_code, role_name, startNum, endNum, prop, order);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[瑙掕壊绠$悊鏂板銆佺紪杈戜繚瀛榏
+ /// <summary>
+ /// 瑙掕壊绠$悊鏂板銆佺紪杈戜繚瀛�
+ /// </summary>
+ /// <param name="obj">鎻愪氦鏁版嵁瀵硅薄</param>
+ /// <returns></returns>
+ [Route(template: "RoleAddUpdateSava")]
+ [HttpPost]
+ public JsonResult RoleAddUpdateSava([FromBody] JObject obj)
+ {
+ var token =HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ var menucode = HttpContext.Request.Headers["Menucode"].ToString(); //鑿滃崟缂栫爜
+ string rolecode = obj["rolecode"].ToString(); //瑙掕壊缂栫爜
+ string rolename = obj["rolename"].ToString(); //瑙掕壊鍚嶇О
+ string status = obj["status"].ToString();//鐘舵��
+ string datacode = obj["datacode"].ToString(); //鏁版嵁鑼冨洿
+ string datapermissions = obj["datapermissions"].ToString(); //鏁版嵁鏉冮檺
+ string description = obj["description"].ToString(); //鎻忚堪
+ string OperType = obj["OperType"].ToString(); //鎿嶄綔绫诲瀷
+ mes = BasicSettingBLL.RoleAddUpdateSava(menucode, rolecode, rolename, status, datacode, datapermissions, description, OperType, us);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[瑙掕壊绠$悊鍒犻櫎]
+ [Route(template: "RoleDeleteSava")]
+ [HttpPost]
+ public JsonResult RoleDeleteSava(string rolecode)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ mes = BasicSettingBLL.RoleDeleteSava(rolecode, us);
+ return Json(mes);
+ }
+ #endregion
+
+
+ #region[瑙掕壊绠$悊鍒嗛厤鐢ㄦ埛,鑾峰彇宸插垎閰嶇敤鎴峰垪琛╙
+ /// <summary>
+ /// 瑙掕壊绠$悊鍒嗛厤鐢ㄦ埛,鑾峰彇宸插垎閰嶇敤鎴峰垪琛�
+ /// </summary>
+ /// <param name="flag">TRUE(宸插叧鑱�) FALSE(鏈叧鑱�)</param>
+ /// <param name="role_code">瑙掕壊缂栫爜</param>
+ /// <param name="usercode">鐢ㄦ埛缂栫爜</param>
+ /// <param name="username">鐢ㄦ埛鍚嶇О</param>
+ /// <param name="storg_code">缁勭粐缂栫爜</param>
+ /// <param name="post_code">宀椾綅缂栫爜</param>
+ /// <param name="group_code">鐝粍缂栫爜</param>
+ /// <param name="page">椤电爜</param>
+ /// <param name="rows">姣忛〉鏄剧ず鏉℃暟</param>
+ /// <param name="prop">鎺掑簭瀛楁</param>
+ /// <param name="order">鎺掑簭瑙勫垯</param>
+ /// <returns></returns>
+ [Route(template: "RoleAssignedUserData")]
+ [HttpGet]
+ public JsonResult RoleAssignedUserData(string flag, string role_code,string usercode,string username,string storg_code,string post_code,string group_code,int page = 0, int rows = 0, string prop = null, string order = null)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ int startNum = rows * (page - 1) + 1; //璧峰璁板綍rowNum
+ int endNum = rows * page; //缁撴潫璁板綍 rowNum
+ mes = BasicSettingBLL.RoleAssignedUserData(flag,role_code, usercode,username,storg_code,post_code,group_code, startNum, endNum, prop, order);
+ return Json(mes);
+ }
+
+ #endregion
+
+ #region[瑙掕壊绠$悊鍒嗛厤鐢ㄦ埛,鎵归噺鍙栨秷宸插垎閰嶇殑鐢ㄦ埛]
+ /// <summary>
+ /// 瑙掕壊缂栫爜
+ /// </summary>
+ /// <param name="role_code">瑙掕壊缂栫爜</param>
+ /// <param name="user">鐢ㄦ埛缂栫爜鏁扮粍</param>
+ /// <returns></returns>
+ [Route(template: "RoleAssignedUserBatchCancel")]
+ [HttpPost]
+ public JsonResult RoleAssignedUserBatchCancel(string role_code,string [] user)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ mes = BasicSettingBLL.RoleAssignedUserBatchCancel(role_code, user, us);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[瑙掕壊绠$悊鍒嗛厤鐢ㄦ埛,鎵归噺娣诲姞鏈垎閰嶇殑鐢ㄦ埛]
+ /// <summary>
+ /// 瑙掕壊缂栫爜
+ /// </summary>
+ /// <param name="role_code">瑙掕壊缂栫爜</param>
+ /// <param name="user">鐢ㄦ埛缂栫爜鏁扮粍</param>
+ /// <returns></returns>
+ [Route(template: "RoleAssignedUserBatchAdd")]
+ [HttpPost]
+ public JsonResult RoleAssignedUserBatchAdd(string role_code, string[] user)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ mes = BasicSettingBLL.RoleAssignedUserBatchAdd(role_code, user, us);
+ return Json(mes);
+ }
+ #endregion
+
+
+ #region[瑙掕壊鏉冮檺鏌ヨ瑙掕壊]
+ /// <summary>
+ /// 瑙掕壊鏉冮檺鏌ヨ瑙掕壊
+ /// </summary>
+ /// <returns></returns>
+ [Route(template: "RolePermissionSearchRole")]
+ [HttpGet]
+ public JsonResult RolePermissionSearchRole()
+ {
+ mes = BasicSettingBLL.RolePermissionSearchRole();
+ return Json(mes);
+ }
+ #endregion
+
+ #region[瑙掕壊鏉冮檺鏌ヨ榛樿鑿滃崟鎸夐挳鏁版嵁]
+ /// <summary>
+ /// 瑙掕壊鏉冮檺鏌ヨ榛樿鑿滃崟鎸夐挳鏁版嵁
+ /// </summary>
+ /// <param name="type">鎿嶄綔绔被鍨�(PC/APP)</param>
+ /// <returns></returns>
+ [Route(template: "RolePermissionSearchRoleMenu")]
+ [HttpGet]
+ public JsonResult RolePermissionSearchRoleMenu(string type)
+ {
+ mes = BasicSettingBLL.RolePermissionSearchRoleMenu(type);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[瑙掕壊鏉冮檺,鏍规嵁瑙掕壊鏌ユ壘鍏宠仈鏉冮檺]
+ /// <summary>
+ /// 瑙掕壊鏉冮檺,鏍规嵁瑙掕壊鏌ユ壘鍏宠仈鏉冮檺
+ /// </summary>
+ /// <param name="rolecode">瑙掕壊缂栫爜</param>
+ /// <param name="type">鑿滃崟缂栫爜</param>
+ /// <returns></returns>
+ [Route(template: "RolePermissionSearchRoleMenuButton")]
+ [HttpGet]
+ public JsonResult RolePermissionSearchRoleMenuButton(string rolecode,string type)
+ {
+ mes = BasicSettingBLL.RolePermissionSearchRoleMenuButton(rolecode, type);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[瑙掕壊鏉冮檺,鎻愪氦]
+ /// <summary>
+ /// 瑙掕壊鏉冮檺,鎻愪氦
+ /// </summary>
+ /// <param name="type">绫诲瀷</param>
+ /// <param name="rolecode">瑙掕壊缂栫爜</param>
+ /// <param name="json">鎻愪氦鏁版嵁</param>
+ /// <returns></returns>
+ [Route(template: "RolePermissionSava")]
+ [HttpPost]
+ public JsonResult RolePermissionSava([FromBody] object json, string rolecode,string type)
+ {
+ var jsonStr = JsonConvert.SerializeObject(json);
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ mes = BasicSettingBLL.RolePermissionSava(jsonStr, rolecode, type, us);
+ return Json(mes);
+ }
+ #endregion
+
+
+
+ }
+}
diff --git a/VueWebCoreApi/Controllers/ClientHubController.cs b/VueWebCoreApi/Controllers/ClientHubController.cs
new file mode 100644
index 0000000..0afcaf3
--- /dev/null
+++ b/VueWebCoreApi/Controllers/ClientHubController.cs
@@ -0,0 +1,31 @@
+锘縰sing Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.SignalR;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.SignalR;
+
+namespace VueWebCoreApi.Controllers
+{
+ [ApiExplorerSettings(GroupName = "娑堟伅鎻愰啋")]
+ [ApiController]
+ [Route("base/[controller]")]
+ public class ClientHubController : ControllerBase
+ {
+ private readonly ILogger<ClientHubController> _logger;
+ public ClientHubController(
+ ILogger<ClientHubController> logger
+ )
+ {
+ _logger = logger;
+ }
+ [Route(template: "SendMessage")]
+ [HttpGet]
+ public async Task SendMessage(string date, [FromServices] IHubContext<ChatHub, IChatClient> hubContext)
+ {
+ await hubContext.Clients.All.SendAll(date);
+ }
+ }
+}
diff --git a/VueWebCoreApi/Controllers/GeneralBasicDataController.cs b/VueWebCoreApi/Controllers/GeneralBasicDataController.cs
new file mode 100644
index 0000000..a0013d4
--- /dev/null
+++ b/VueWebCoreApi/Controllers/GeneralBasicDataController.cs
@@ -0,0 +1,93 @@
+锘縰sing Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.BLL;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.Controllers
+{
+ [ApiExplorerSettings(GroupName = "閫氱敤鍩虹璧勬枡")]
+ [ApiController]
+ [Route("api/[controller]")]
+ public class GeneralBasicDataController : Controller
+ {
+ //瀹氫箟鍏ㄥ眬淇℃伅杩斿洖鍙橀噺
+ ToMessage mes = new ToMessage();
+ RedisHelper redis = new RedisHelper();
+
+ #region[缁勭粐鏋舵瀯鍩虹璧勬枡]
+ /// <summary>
+ /// 缁勭粐鏋舵瀯鍩虹璧勬枡
+ /// </summary>
+ /// <returns></returns>
+ [Route(template: "PrentOrganization")]
+ [HttpGet]
+ public JsonResult PrentOrganization()
+ {
+ mes = GeneralBasicDataBLL.PrentOrganization();
+ return Json(mes);
+ }
+ #endregion
+
+ #region[宀椾綅鍩虹璧勬枡]
+ [Route(template: "PostPermissions")]
+ [HttpGet]
+ public JsonResult PostPermissions()
+ {
+ mes = GeneralBasicDataBLL.PostPermissions();
+ return Json(mes);
+ }
+ #endregion
+
+ #region[瑙掕壊鍩虹璧勬枡]
+ [Route(template: "RolePermissions")]
+ [HttpGet]
+ public JsonResult RolePermissions()
+ {
+ mes = GeneralBasicDataBLL.RolePermissions();
+ return Json(mes);
+ }
+ #endregion
+
+ #region[鐝粍鍩虹璧勬枡]
+ [Route(template: "GroupsPermissions")]
+ [HttpGet]
+ public JsonResult GroupsPermissions()
+ {
+ mes = GeneralBasicDataBLL.GroupsPermissions();
+ return Json(mes);
+ }
+ #endregion
+
+
+ #region[鎸夐挳鍩虹璧勬枡]
+ /// <summary>
+ /// 鎸夐挳鍩虹璧勬枡
+ /// </summary>
+ /// <returns></returns>
+ [Route(template: "ButtonData")]
+ [HttpGet]
+ public JsonResult ButtonData()
+ {
+ mes = GeneralBasicDataBLL.ButtonData();
+ return Json(mes);
+ }
+ #endregion
+
+ #region[鏁版嵁鏉冮檺鍩虹璧勬枡]
+ /// <summary>
+ /// 鏁版嵁鏉冮檺鍩虹璧勬枡
+ /// </summary>
+ /// <returns></returns>
+ [Route(template: "DataPermissions")]
+ [HttpGet]
+ public JsonResult DataPermissions()
+ {
+ mes = GeneralBasicDataBLL.DataPermissions();
+ return Json(mes);
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/Controllers/LoginController.cs b/VueWebCoreApi/Controllers/LoginController.cs
new file mode 100644
index 0000000..41c272f
--- /dev/null
+++ b/VueWebCoreApi/Controllers/LoginController.cs
@@ -0,0 +1,280 @@
+锘縰sing Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.BLL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.Controllers
+{
+ [ApiExplorerSettings(GroupName = "鐧诲綍淇℃伅")]
+ [ApiController]
+ [Route("api/[controller]")]
+ public class LoginController : Controller
+ {
+ //瀹氫箟鍏ㄥ眬淇℃伅杩斿洖鍙橀噺
+ ToMessage mes = new ToMessage();
+ RedisHelper redis = new RedisHelper();
+ //鑾峰彇浼佷笟閰嶇疆Enterprise
+ private static readonly string Enterprise = AppSetting.GetAppSetting("Enterprise");
+
+
+ #region[PC鐢ㄦ埛鐧诲綍]
+ /// <summary>
+ /// PC鐢ㄦ埛鐧诲綍
+ /// </summary>
+ /// <param name="username">鐢ㄦ埛缂栫爜</param>
+ /// <param name="password">瀵嗙爜</param>
+ /// <param name="usertype">鎿嶄綔绔被鍨�(PC APP)</param>
+ /// <returns></returns>
+ [Route(template: "LoginSave")]
+ [HttpGet]
+ public JsonResult LoginSave(string username, string password, string usertype)
+ {
+ try
+ {
+ Dictionary<string, object> payLoad = new Dictionary<string, object>();
+ mes = LoginBLL.LoginSearch(username, password);
+ if (mes.code == "200")
+ {
+ DataTable dt = (DataTable)mes.data;
+ //jwt鐢熸垚Token鍓嶇殑鐢ㄦ埛淇℃伅
+ payLoad.Add("usercode", dt.Rows[0]["usercode"].ToString());
+ payLoad.Add("username", dt.Rows[0]["username"].ToString());
+ payLoad.Add("storg_code", dt.Rows[0]["storg_code"].ToString());
+ payLoad.Add("storg_name", dt.Rows[0]["storg_name"].ToString());
+ payLoad.Add("is_system_admin", dt.Rows[0]["is_system_admin"].ToString());
+ payLoad.Add("role_code", dt.Rows[0]["role_code"].ToString());
+ payLoad.Add("role_datapermissions", dt.Rows[0]["role_datapermissions"].ToString());
+ payLoad.Add("usertype", usertype);
+ payLoad.Add("rediskey", Enterprise + "LoginUserID" + usertype + JwtTools.FindFirstKeyByValue(payLoad, "usercode"));
+ //鑾峰彇jwt鐢熸垚token
+ mes = JwtTools.Encode(payLoad);
+
+ List<User> mss = new List<User>();
+ User ms = new User();
+ ms.usercode = dt.Rows[0]["usercode"].ToString();
+ ms.username = dt.Rows[0]["username"].ToString();
+ ms.storg_code= dt.Rows[0]["storg_code"].ToString();
+ ms.storg_name = dt.Rows[0]["storg_name"].ToString();
+ ms.is_system_admin = dt.Rows[0]["is_system_admin"].ToString();
+ ms.role_code= dt.Rows[0]["role_code"].ToString();
+ ms.role_datapermissions = dt.Rows[0]["role_datapermissions"].ToString();
+ ms.usertype = usertype;
+ ms.rediskey = Enterprise + "LoginUserID" + ms.usertype + ms.usercode;
+ ms.token = mes.data.ToString();
+ mss.Add(ms);
+
+
+ User loginUser = JsonConvert.DeserializeObject<User>(JsonConvert.SerializeObject(ms));
+ //濡傛灉redis鐧诲綍鐢ㄦ埛涓笉瀛樺湪褰撳墠鐢ㄦ埛
+ if (redis.Get<User>(ms.rediskey, 0) == null)
+ {
+ //鍐欏叆redis(娉ㄦ剰锛歳edis绫婚噷闈㈢殑澶辨晥鏃堕棿蹇呴』鍦╧ey鍒涘缓瀹屾垚涔嬪悗鎵嶇敓鏁�)
+ redis.Set<User>(ms.rediskey, ms, redis.secondsTimeOut, 0);
+ //鍐欏叆鐧诲綍鎿嶄綔璁板綍
+ LogHelper.DbOperateLog(ms.usercode, "鐧诲綍", "鐧诲綍浜嗙郴缁�", ms.usertype);
+ mes.code = "200";
+ mes.Message = "鐧诲綍鎴愬姛!";
+ mes.data = ms.token.ToString();
+ }
+ else //濡傛灉瀛樺湪
+ {
+ //鑾峰彇redis涓綋鍓嶇敤鎴蜂俊鎭�
+ User r_loginUser = redis.Get<User>(ms.rediskey, 0);
+ //濡傛灉session涓殑鐢ㄦ埛usercode鍜宺edis涓殑鐢ㄦ埛usercode鍖归厤
+ if ((r_loginUser.rediskey).Equals(loginUser.rediskey))
+ {
+ mes.data = ms.token.ToString();
+ mes.code = "302";
+ mes.Message = "褰撳墠璐﹀彿宸茬櫥褰�,鏄惁寮哄埗涓嬬嚎!";
+ }
+ else
+ {
+ //閲嶇疆杩囨湡鏃堕棿(娉ㄦ剰锛歳edis绫婚噷闈㈢殑澶辨晥鏃堕棿蹇呴』鍦╧ey鍒涘缓瀹屾垚涔嬪悗鎵嶇敓鏁�)
+ redis.Set<User>(loginUser.rediskey, loginUser, redis.secondsTimeOut, 0);
+ //鍐欏叆鐧诲綍鎿嶄綔璁板綍
+ LogHelper.DbOperateLog(ms.usercode, "鐧诲綍", "鐧诲綍浜嗙郴缁�", ms.usertype);
+ mes.data = ms;
+ mes.code = "200";
+ mes.Message = "鐧诲綍鎴愬姛!";
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+
+ return Json(mes);
+ }
+ #endregion
+
+ #region[寮哄埗涓嬬嚎鎺ュ彛]
+ /// <summary>
+ /// 寮哄埗涓嬬嚎鎺ュ彛
+ /// </summary>
+ /// <param name="token">token</param>
+ /// <param name="rid">rid鏋佸厜鎺ㄩ�佽幏鍙栬澶噄d</param>
+ /// <returns></returns>
+ [Route(template: "ForcedOffline")]
+ [HttpPost]
+ public JsonResult ForcedOffline(string token, string rid)
+ {
+ string sql = "";
+ List<object> list = new List<object>();
+
+ try
+ {
+ User us = JwtTools.Denocode(token.ToString());
+ us.token = token.ToString();
+ if (us.usertype.ToString() == "APP")
+ {
+ //鏇存柊rid
+ sql = @"update [dbo].[TUser] set rid=@rid where usercode=@usercode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ rid = rid,
+ usercode = us.usercode.ToString()
+ }
+ });
+ bool aa = DapperHelper.DoTransaction(list);
+ redis.Remove(us.rediskey, 0);//鍒犻櫎redis
+ redis.Set<User>(us.rediskey, us, redis.secondsTimeOut, 0);//鍐欏叆redis
+ }
+ else
+ {
+ redis.Remove(us.rediskey, 0);//鍒犻櫎redis
+ redis.Set<User>(us.rediskey, us, redis.secondsTimeOut, 0);//鍐欏叆redis
+ }
+ //鍐欏叆鏃ュ織
+ LogHelper.DbOperateLog(us.usercode, "寮哄埗涓嬬嚎", "琚己鍒朵笅绾夸簡", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "寮哄埗涓嬬嚎鎴愬姛!";
+ mes.data = null;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return Json(mes);
+ }
+ #endregion
+
+ #region[鏌ヨ鐧诲綍鑿滃崟]
+ /// <summary>
+ /// 鏌ヨ鐧诲綍鑿滃崟
+ /// </summary>
+ /// <param name="usertype">鎿嶄綔绔被鍨�(PC APP)</param>
+ /// <param name="usercode">鐧诲綍鐢ㄦ埛缂栫爜</param>
+ /// <param name="torg_code">缁勭粐缂栫爜</param>
+ /// <returns></returns>
+ [Route(template: "LoginMenu")]
+ [HttpGet]
+ [ChannelActionFilter]
+ public JsonResult LoginMenu(string usertype, string usercode,string torg_code)
+ {
+ try
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ mes = LoginBLL.LoginMenu(usercode, usertype,us);
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.Message = e.Message;
+ }
+ return Json(mes);
+ }
+ #endregion
+
+ #region[淇敼瀵嗙爜]
+ /// <summary>
+ /// 淇敼瀵嗙爜
+ /// </summary>
+ /// <param name="password">瀵嗙爜</param>
+ /// <param name="newpassword">鏂板瘑鐮�</param>
+ /// <returns></returns>
+ [ChannelActionFilter, Route(template: "UpdateUserPassword")]
+ [HttpPost]
+ public JsonResult UpdateUserPassword(string password, string newpassword)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ mes = LoginBLL.UpdateUserPassword(us, password, newpassword);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[鐧诲嚭]
+ /// <summary>
+ /// 鐧诲嚭
+ /// </summary>
+ /// <returns></returns>
+ [Route(template: "LoginOut")]
+ [HttpPost]
+ [ChannelActionFilter]
+ public JsonResult LoginOut()
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ mes = LoginBLL.LoginOut(us);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[APP瀵嗙爜閲嶇疆]
+ /// <summary>
+ /// APP瀵嗙爜閲嶇疆
+ /// </summary>
+ /// <param name="usercode">鐢ㄦ埛缂栧彿</param>
+ /// <param name="username">鐢ㄦ埛鍚嶇О</param>
+ /// <param name="usertype">鎿嶄綔绔被鍨�(PC APP)</param>
+ /// <returns></returns>
+ [ChannelActionFilterAttributeApp, Route(template: "ResettUserPassword")]
+ [HttpPost]
+ public JsonResult ResettUserPassword(string usercode, string username, string usertype)
+ {
+ mes = LoginBLL.ResettUserPassword(usercode, username, usertype);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[App鐧诲綍鏌ヨ瀹夌伅鍛煎彨淇℃伅]
+ /// <summary>
+ /// App鐧诲綍鏌ヨ瀹夌伅鍛煎彨淇℃伅
+ /// </summary>
+ /// <param name="rid">鎵嬫満璁惧id(鏋佸厜鐢熸垚)</param>
+ /// <param name="usercode">鐢ㄦ埛缂栫爜</param>
+ /// <param name="username">鐢ㄦ埛鍚嶇О</param>
+ /// <param name="usertype">鎿嶄綔绔疨C/APP</param>
+ /// <param name="stu_torgcode">鎵�灞炵紪鐮佺粍缁�</param>
+ /// <param name="stu_torgtypecode">鎵�灞炵粍缁囩被鍨�</param>
+ /// <returns></returns>
+ [Route(template: "LoginAppAnDonMessage")]
+ [HttpPost]
+ public JsonResult LoginAppAnDonMessage(string rid, string usercode, string username, string usertype, string stu_torgcode, string stu_torgtypecode)
+ {
+ mes = LoginBLL.LoginAppAnDonMessage(rid, usercode, username, usertype, stu_torgcode, stu_torgtypecode);
+ return Json(mes);
+ //return mes.ResponseMess(mes);
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/Controllers/SystemSettingController.cs b/VueWebCoreApi/Controllers/SystemSettingController.cs
new file mode 100644
index 0000000..c0d1376
--- /dev/null
+++ b/VueWebCoreApi/Controllers/SystemSettingController.cs
@@ -0,0 +1,163 @@
+锘縰sing Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.BLL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.Controllers
+{
+ [ApiExplorerSettings(GroupName = "绯荤粺璁剧疆")]
+ [ApiController]
+ [Route("api/[controller]")]
+ [ChannelActionFilter]
+ public class SystemSettingController : Controller
+ {
+ //瀹氫箟鍏ㄥ眬淇℃伅杩斿洖鍙橀噺
+ ToMessage mes = new ToMessage();
+ RedisHelper redis = new RedisHelper();
+
+ #region[缂栫爜瑙勫垯鑾峰彇鍙缃殑鍔熻兘鑿滃崟淇℃伅]
+ /// <summary>
+ /// 缂栫爜瑙勫垯鑾峰彇鍙缃殑鍔熻兘鑿滃崟淇℃伅
+ /// </summary>
+ /// <returns></returns>
+ [Route(template: "CodeMenuSelect")]
+ [HttpGet]
+ public JsonResult CodeMenuSelect()
+ {
+ mes = SystemSettingBLL.CodeMenuSelect();
+ return Json(mes);
+ }
+ #endregion
+
+ #region[缂栫爜瑙勫垯鏌ヨ]
+ /// <summary>
+ /// 缂栫爜瑙勫垯鏌ヨ
+ /// </summary>
+ /// <param name="rightname">缂栫爜鍚嶇О</param>
+ /// <param name="prefix">鍥哄畾瀛楃</param>
+ /// <param name="page">椤电爜</param>
+ /// <param name="rows">姣忛〉鏄剧ず鏉℃暟</param>
+ /// <param name="prop">鎺掑簭瀛楁</param>
+ /// <param name="order">鎺掑簭瑙勫垯</param>
+ /// <returns></returns>
+ [Route(template: "EncodingRules")]
+ [HttpGet]
+ public JsonResult EncodingRules(string rightname = null, string prefix = null, int page = 0, int rows = 0, string prop = null, string order = null)
+ {
+ int startNum = rows * (page - 1) + 1; //璧峰璁板綍rowNum
+ int endNum = rows * page; //缁撴潫璁板綍 rowNum
+ mes = SystemSettingBLL.EncodingRules(rightname, prefix, startNum, endNum, prop, order);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[缂栫爜瑙勫垯缂栬緫淇濆瓨]
+ /// <summary>
+ /// 缂栫爜瑙勫垯缂栬緫淇濆瓨
+ /// </summary>
+ /// <param name="obj">鎻愪氦鏁版嵁瀵硅薄</param>
+ /// <returns></returns>
+ [Route(template: "SaveEncodingRules")]
+ [HttpPost]
+ public JsonResult SaveEncodingRules([FromBody] JObject obj)
+ {
+ string rightcode = obj["rightcode"].ToString(); //鍔熻兘缂栫爜
+ string rightname = obj["rightname"].ToString(); //鍔熻兘鍚嶇О
+ string prefix = obj["prefix"].ToString(); //鍥哄畾瀛楃
+ string filingdate = obj["filingdate"].ToString(); //鎻愪氦鏃ユ湡
+ string incbit = obj["incbit"].ToString(); //鑷浣嶆暟
+ string type = obj["type"].ToString(); //鎿嶄綔绔被鍨�:PC/APP
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ mes = SystemSettingBLL.SaveEncodingRules(rightcode, rightname, prefix, filingdate, incbit, type, us);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[缂栫爜瑙勫垯鍒犻櫎]
+ /// <summary>
+ /// 缂栫爜瑙勫垯鍒犻櫎
+ /// </summary>
+ /// <param name="menucode">鍔熻兘缂栫爜</param>
+ /// <returns></returns>
+ [Route(template: "DeleteEncodingRules")]
+ [HttpPost]
+ public JsonResult DeleteEncodingRules(string menucode)
+ {
+ var token = HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ mes = SystemSettingBLL.DeleteEncodingRules(menucode, us);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[鑾峰彇瑙勫垯鐢熸垚鐨勭紪鐮�(姣忔鑾峰彇鏈�鏂�)]
+ /// <summary>
+ /// 鑾峰彇瑙勫垯鐢熸垚鐨勭紪鐮�(姣忔鑾峰彇鏈�鏂�)
+ /// </summary>
+ /// <param name="rightcode">鍔熻兘缂栫爜</param>
+ /// <returns></returns>
+ [Route(template: "NewEncodingRules")]
+ [HttpGet]
+ public JsonResult NewEncodingRules(string rightcode)
+ {
+ mes = SystemSettingBLL.NewEncodingRules(rightcode);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[鑾峰彇瑙勫垯鐢熸垚鐨勭紪鐮�(鍙湁浣跨敤鎵嶈幏鍙栨渶鏂�)]
+ /// <summary>
+ /// 鑾峰彇瑙勫垯鐢熸垚鐨勭紪鐮�(鍙湁浣跨敤鎵嶈幏鍙栨渶鏂�)
+ /// </summary>
+ /// <param name="rightcode">鍔熻兘缂栫爜</param>
+ /// <returns></returns>
+ [Route(template: "OnlyEncodingRules")]
+ [HttpGet]
+ public JsonResult OnlyEncodingRules(string rightcode)
+ {
+ mes = SystemSettingBLL.OnlyEncodingRules(rightcode);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[鍥炲啓瑙勫垯鐢熸垚鐨勭紪鐮�(浣跨敤淇濆瓨)]
+ /// <summary>
+ /// 鍥炲啓瑙勫垯鐢熸垚鐨勭紪鐮�(浣跨敤淇濆瓨)
+ /// </summary>
+ /// <param name="rightcode">鍔熻兘缂栫爜</param>
+ /// <param name="incbit">娴佹按鍙�</param>
+ /// <returns></returns>
+ [Route(template: "SaveOnlyEncodingRules")]
+ [HttpPost]
+ public JsonResult SaveOnlyEncodingRules(string rightcode,string incbit)
+ {
+ mes = SystemSettingBLL.SaveOnlyEncodingRules(rightcode, incbit);
+ return Json(mes);
+ }
+ #endregion
+
+ #region[鐢熸垚鐗╂枡鏍囩鏉$爜(姣忔鑾峰彇鏈�鏂�,App鍙娇鐢�)]
+ /// <summary>
+ /// 鐢熸垚鐗╂枡鏍囩鏉$爜(姣忔鑾峰彇鏈�鏂�,App鍙娇鐢�)
+ /// </summary>
+ /// <param name="rightcode">鍔熻兘缂栫爜</param>
+ /// <param name="partcode">鐗╂枡缂栫爜</param>
+ /// <param name="qty">鏁伴噺</param>
+ /// <param name="onelabqty">鍗曟爣绛炬暟閲�</param>
+ /// <returns></returns>
+ [Route(template: "LabelBarCode")]
+ [HttpGet]
+ public JsonResult LabelBarCode(string rightcode, string partcode, string qty, string onelabqty)
+ {
+ mes = SystemSettingBLL.LabelBarCode(rightcode, partcode, qty, onelabqty);
+ return Json(mes);
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/Controllers/TaskBackGroundController.cs b/VueWebCoreApi/Controllers/TaskBackGroundController.cs
new file mode 100644
index 0000000..32509a8
--- /dev/null
+++ b/VueWebCoreApi/Controllers/TaskBackGroundController.cs
@@ -0,0 +1,137 @@
+锘縰sing Microsoft.AspNetCore.Mvc;
+using Quartz;
+using Quartz.Spi;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Extensions;
+using VueWebCoreApi.Quartz;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.Controllers
+{
+ [ApiExplorerSettings(GroupName = "鍛ㄦ湡浠诲姟")]
+ [ApiController]
+ [Route("base/[controller]")]
+ public class TaskBackGroundController : Controller
+ {
+ //瀹氫箟鍏ㄥ眬淇℃伅杩斿洖鍙橀噺
+ ToMessage mes = new ToMessage();
+ private readonly ISchedulerFactory _schedulerFactory;
+ private readonly IJobFactory _jobFactory;
+ public TaskBackGroundController(ISchedulerFactory schedulerFactory, IJobFactory jobFactory)
+ {
+ this._jobFactory = jobFactory;
+ this._schedulerFactory = schedulerFactory;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎵�鏈夌殑浣滀笟
+ /// </summary>
+ /// <returns></returns>
+ [Route(template: "GetJobs")]
+ [HttpGet]
+ public async Task<IActionResult> GetJobs()
+ {
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛锛�";
+ mes.data = await _schedulerFactory.GetJobs();
+ return Json(mes);
+ }
+
+ /// <summary>
+ /// 鑾峰彇浣滀笟杩愯鏃ュ織
+ /// </summary>
+ /// <param name="taskName"></param>
+ /// <param name="groupName"></param>
+ /// <param name="page"></param>
+ /// <returns></returns>
+ [Route(template: "GetRunLog")]
+ [HttpGet]
+ public IActionResult GetRunLog(string taskName, string groupName, int page = 1)
+ {
+ mes.code = "200";
+ mes.data = FileQuartz.GetJobRunLog(taskName, groupName, page);
+ return Json(mes);
+ }
+
+ /// <summary>
+ /// 娣诲姞浠诲姟
+ /// </summary>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ [Route(template: "Add")]
+ [HttpPost]
+ //[TaskAuthor]
+ public async Task<IActionResult> Add(TaskOptions taskOptions)
+ {
+ return Json(await taskOptions.AddJob(_schedulerFactory, jobFactory: _jobFactory));
+ }
+
+ /// <summary>
+ /// 鍒犻櫎浠诲姟
+ /// </summary>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ [Route(template: "Remove")]
+ [HttpPost]
+ //[TaskAuthor]
+ public async Task<IActionResult> Remove(TaskOptions taskOptions)
+ {
+ return Json(await _schedulerFactory.Remove(taskOptions));
+ }
+
+ /// <summary>
+ /// 淇敼浠诲姟
+ /// </summary>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ [Route(template: "Update")]
+ [HttpPost]
+ //[TaskAuthor]
+ public async Task<IActionResult> Update(TaskOptions taskOptions)
+ {
+ return Json(await _schedulerFactory.Update(taskOptions));
+ }
+
+ /// <summary>
+ /// 鏆傚仠浠诲姟
+ /// </summary>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ [Route(template: "Pause")]
+ [HttpPost]
+ //[TaskAuthor]
+ public async Task<IActionResult> Pause(TaskOptions taskOptions)
+ {
+ return Json(await _schedulerFactory.Pause(taskOptions));
+ }
+
+ /// <summary>
+ /// 寮�鍚换鍔�
+ /// </summary>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ [Route(template: "Start")]
+ [HttpPost]
+ //[TaskAuthor]
+ public async Task<IActionResult> Start(TaskOptions taskOptions)
+ {
+ return Json(await _schedulerFactory.Start(taskOptions));
+ }
+
+ /// <summary>
+ /// 绔嬪嵆鎵ц
+ /// </summary>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ [Route(template: "Run")]
+ [HttpPost]
+ //[TaskAuthor]
+ public async Task<IActionResult> Run(TaskOptions taskOptions)
+ {
+ return Json(await _schedulerFactory.Run(taskOptions));
+ }
+ }
+}
diff --git a/VueWebCoreApi/DLL/BLL/BaseDateBLL.cs b/VueWebCoreApi/DLL/BLL/BaseDateBLL.cs
new file mode 100644
index 0000000..fa108a7
--- /dev/null
+++ b/VueWebCoreApi/DLL/BLL/BaseDateBLL.cs
@@ -0,0 +1,104 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.DAL;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.BLL
+{
+ public class BaseDateBLL
+ {
+ #region[閲囪喘渚涙柟淇℃伅鏌ヨ]
+ public static ToMessage PurchSupplierSelect()
+ {
+ return BaseDateDAL.PurchSupplierSelect();
+ }
+ #endregion
+
+ #region[閮ㄩ棬淇℃伅鏌ヨ]
+ public static ToMessage DepartMentSelect()
+ {
+ return BaseDateDAL.DepartMentSelect();
+ }
+ #endregion
+
+ #region[浠撳簱淇℃伅鏌ヨ]
+ public static ToMessage StoreHouseSearch()
+ {
+ return BaseDateDAL.StoreHouseSearch();
+ }
+ #endregion
+
+ #region[搴撲綅淇℃伅鏌ヨ]
+ public static ToMessage WarehouseLocationSearch()
+ {
+ return BaseDateDAL.WarehouseLocationSearch();
+ }
+ #endregion
+
+ #region[搴撲綅鏌ヨ浠撳簱]
+ public static ToMessage WarehouseLocationSearchStoreHouse(string locationcode)
+ {
+ return BaseDateDAL.WarehouseLocationSearchStoreHouse(locationcode);
+ }
+ #endregion
+
+ #region[鍗曚綅淇℃伅鏌ヨ]
+ public static ToMessage UnitSerch()
+ {
+ return BaseDateDAL.UnitSerch();
+ }
+ #endregion
+
+ #region[璐ㄦ鏂规淇℃伅]
+ public static ToMessage QualityScheme()
+ {
+ return BaseDateDAL.QualityScheme();
+ }
+ #endregion
+
+ #region[瀛樿揣鏌ヨ]
+ public static ToMessage InventorySelect(string param)
+ {
+ return BaseDateDAL.InventorySelect(param);
+ }
+ #endregion
+
+ #region[閫氳繃閫夋嫨鐨勬墍灞炵粍缁囨煡璇㈡墍灞炵彮缁刔
+ public static ToMessage StorgGroupSelect(string stu_torgcode, string description)
+ {
+ return BaseDateDAL.StorgGroupSelect(stu_torgcode, description);
+ }
+ #endregion
+
+ #region[閫氳繃閫夋嫨鐨勬墍灞炵粍缁囨煡璇㈡墍灞炶鑹茬被鍨媇
+ public static ToMessage StorgRoleSelect(string stu_torgcode, string description)
+ {
+ return BaseDateDAL.StorgRoleSelect(stu_torgcode, description);
+ }
+ #endregion
+
+
+ #region[ERP鐢熶骇杞﹂棿/閮ㄩ棬淇℃伅鏌ヨ]
+ public static ToMessage ErpWkshopDepartmentSelect()
+ {
+ return BaseDateDAL.ErpWkshopDepartmentSelect();
+ }
+ #endregion
+
+ #region[ERP鐢熶粨搴撲俊鎭煡璇
+ public static ToMessage ErpWarehouseSelect()
+ {
+ return BaseDateDAL.ErpWarehouseSelect();
+ }
+ #endregion
+
+ #region[ERP鐢熺敤鎴蜂俊鎭煡璇
+ public static ToMessage ErpUserSelect()
+ {
+ return BaseDateDAL.ErpUserSelect();
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/BLL/BasicSettingBLL.cs b/VueWebCoreApi/DLL/BLL/BasicSettingBLL.cs
new file mode 100644
index 0000000..4b15d29
--- /dev/null
+++ b/VueWebCoreApi/DLL/BLL/BasicSettingBLL.cs
@@ -0,0 +1,281 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.DAL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Models.RolePermission;
+using VueWebCoreApi.Tools;
+using static VueWebCoreApi.Models.RolePermission.RolePermissionSava;
+
+namespace VueWebCoreApi.DLL.BLL
+{
+ public class BasicSettingBLL
+ {
+
+
+ #region[寰�鏉ュ崟浣嶆煡璇
+ public static ToMessage CurrentUnitSearch(string cuntUnitCode, string cuntUnitName, string unitAttr, string createUser, int startNum, int endNum, string prop, string order)
+ {
+ return BasicSettingDAL.CurrentUnitSearch(cuntUnitCode, cuntUnitName, unitAttr, createUser, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[寰�鏉ュ崟浣嶆柊澧炵紪杈慮
+ public static ToMessage AddUpdateCurrentUnit(string unitid, string unitcode, string unitname, string typecode, string person, string contact, string description, string usercode, string OperType)
+ {
+ return BasicSettingDAL.AddUpdateCurrentUnit(unitid, unitcode, unitname, typecode, person, contact, description, usercode, OperType);
+ }
+ #endregion
+
+ #region[寰�鏉ュ崟浣嶅垹闄
+ public static ToMessage DeleteCurrentUnit(string unitcode)
+ {
+ return BasicSettingDAL.DeleteCurrentUnit(unitcode);
+ }
+ #endregion
+
+
+
+ #region[瀹夌伅绯荤粺/杞﹂棿鏌ヨ]
+ public static ToMessage AnDengShopSearch(string stu_torgcode, string description)
+ {
+ return BasicSettingDAL.AnDengShopSearch(stu_torgcode, description);
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鑷畾涔夊畨鐏懠鍙被鍨嬫煡璇
+ public static ToMessage AnDengTypeSearch()
+ {
+ return BasicSettingDAL.AnDengTypeSearch();
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鑷畾涔夊畨鐏懠鍙被鍨嬫柊澧瀅
+ public static ToMessage AddUpdateAnDengType(List<ObjectData> json, string username)
+ {
+ return BasicSettingDAL.AddUpdateAnDengType(json, username);
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鑷畾涔夊畨鐏懠鍙被鍨嬪垹闄
+ public static ToMessage DeleteAnDengType(string andengtypecode)
+ {
+ return BasicSettingDAL.DeleteAnDengType(andengtypecode);
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鏌ヨ缁戝畾鐨勫搷搴斾汉鍛榏
+ public static ToMessage AnDengResponUserSearch(string wkshopcode, string calltypecode)
+ {
+ return BasicSettingDAL.AnDengResponUserSearch(wkshopcode, calltypecode);
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鏂板鍝嶅簲浜哄憳鏌ヨ宸茬粦瀹氱殑鍝嶅簲浜哄憳]
+ public static ToMessage AnDengDialogResponUserSearch(string wkshopcode, string calltypecode)
+ {
+ return BasicSettingDAL.AnDengDialogResponUserSearch(wkshopcode, calltypecode);
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鏂板鍝嶅簲浜哄憳鎻愪氦]
+ public static ToMessage AnDengDigoResponUserSeave(string wkshopcode, string calltypecode, string enable, string usercode, DataTable json)
+ {
+ return BasicSettingDAL.AnDengDigoResponUserSeave(wkshopcode, calltypecode, enable, usercode, json);
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鍝嶅簲浜哄憳鍏佽鍏抽棴]
+ public static ToMessage AnDengResponUserCloseSeave(string wkshopcode, string calltypecode, string enable, string usercode)
+ {
+ return BasicSettingDAL.AnDengResponUserCloseSeave(wkshopcode, calltypecode, enable, usercode);
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鍝嶅簲浜哄憳鍒犻櫎]
+ public static ToMessage AnDengResponUserDeleteSeave(string id, string ando_cogfigid)
+ {
+ return BasicSettingDAL.AnDengResponUserDeleteSeave(id, ando_cogfigid);
+ }
+ #endregion
+
+
+
+
+ #region[閫氳繃杞﹂棿缂栫爜鏌ユ壘璁惧淇℃伅]
+ public static ToMessage WhkspIsEqpSearch(string wkshpcode)
+ {
+ return BasicSettingDAL.WhkspIsEqpSearch(wkshpcode);
+ }
+ #endregion
+
+
+
+
+
+ #region[缁勭粐鏋舵瀯,鏌ヨ缁勭粐淇℃伅]
+ public static ToMessage STorgData(string storg_code, string storg_name, int startNum, int endNum, string prop, string order)
+ {
+ return BasicSettingDAL.STorgData(storg_code, storg_name, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region [缁勭粐鏋舵瀯鏂板缂栬緫]
+ public static ToMessage AddUpdateOrganization(string OrganCode, string OrganName, string leve, string parent_id,string storgcode, string torg_seq, string status, string OperType, User us)
+ {
+ return BasicSettingDAL.AddUpdateOrganization(OrganCode, OrganName, leve, parent_id, storgcode, torg_seq, status, OperType, us);
+ }
+ #endregion
+
+ #region [缁勭粐鏋舵瀯鍒犻櫎]
+ public static ToMessage DeleteOrganization(string orgcode, User us)
+ {
+ return BasicSettingDAL.DeleteOrganization(orgcode,us);
+ }
+ #endregion
+
+
+ #region[宀椾綅淇℃伅鍒楄〃鏌ヨ]
+ public static ToMessage PostData(string postcode, string postname, int startNum, int endNum, string prop, string order)
+ {
+ return BasicSettingDAL.PostData(postcode, postname, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[宀椾綅鏂板缂栬緫]
+ public static ToMessage AddUpdatePost(string postcode, string postname, string description, string status, string OperType, User us)
+ {
+ return BasicSettingDAL.AddUpdatePost(postcode, postname, description, status, OperType, us);
+ }
+ #endregion
+
+ #region[宀椾綅鍒犻櫎鍒犻櫎]
+ public static ToMessage DeletePost(string postcode, User us)
+ {
+ return BasicSettingDAL.DeletePost(postcode,us);
+ }
+ #endregion
+
+
+ #region[鐢ㄦ埛淇℃伅鍒楄〃鏌ヨ]
+ public static ToMessage UserData(string storgcode, string usercode, string username, int startNum, int endNum, string prop, string order)
+ {
+ return BasicSettingDAL.UserData(storgcode,usercode, username, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[鐢ㄦ埛淇℃伅鏂板缂栬緫]
+ public static ToMessage AddUpdateUserSave(string usercode, string username, string password, string mobile, string email, string storg_code, string status, string post_code, string role_code,string group_code, string opertype, User us)
+ {
+ return BasicSettingDAL.AddUpdateUserSave(usercode, username, password, mobile, email, storg_code, status, post_code, role_code, group_code, opertype, us);
+ }
+ #endregion
+
+ #region[鐢ㄦ埛淇℃伅鍒犻櫎]
+ public static ToMessage DeleteUserSave(string usercode, User us)
+ {
+ return BasicSettingDAL.DeleteUserSave(usercode, us);
+ }
+ #endregion
+
+
+ #region[鐝粍淇℃伅鍒楄〃鏌ヨ]
+ public static ToMessage GroupData(string groupcode, string groupname, int startNum, int endNum, string prop, string order)
+ {
+ return BasicSettingDAL.GroupData(groupcode, groupname, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[鐝粍鏂板缂栬緫]
+ public static ToMessage AddUpdateGroup(string groupcode, string groupname, string description, string status, string OperType, User us)
+ {
+ return BasicSettingDAL.AddUpdateGroup(groupcode, groupname, description, status, OperType, us);
+ }
+ #endregion
+
+ #region[鐝粍鍒犻櫎]
+ public static ToMessage DeleteGroup(string groupcode, User us)
+ {
+ return BasicSettingDAL.DeleteGroup(groupcode,us);
+ }
+ #endregion
+
+
+ #region[瑙掕壊绠$悊鍒楄〃鏌ヨ]
+ public static ToMessage RoleData(string role_code, string role_name, int startNum, int endNum, string prop, string order)
+ {
+ return BasicSettingDAL.RoleData(role_code, role_name, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[瑙掕壊绠$悊鏂板銆佺紪杈戜繚瀛榏
+ public static ToMessage RoleAddUpdateSava(string menucode,string rolecode, string rolename,string status,string datacode,string datapermissions,string description,string OperType, User us)
+ {
+ return BasicSettingDAL.RoleAddUpdateSava(menucode, rolecode, rolename, status, datacode, datapermissions, description, OperType, us);
+ }
+ #endregion
+
+ #region[瑙掕壊绠$悊鍒犻櫎]
+ public static ToMessage RoleDeleteSava(string rolecode,User us)
+ {
+ return BasicSettingDAL.RoleDeleteSava(rolecode,us);
+ }
+ #endregion
+
+
+ #region[瑙掕壊绠$悊鍒嗛厤鐢ㄦ埛,鑾峰彇宸插垎閰嶇敤鎴峰垪琛╙
+ public static ToMessage RoleAssignedUserData(string flag, string role_code,string usercode,string username,string storg_code,string post_code,string group_code, int startNum, int endNum, string prop, string order)
+ {
+ return BasicSettingDAL.RoleAssignedUserData(flag,role_code, usercode, username, storg_code, post_code, group_code, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[瑙掕壊绠$悊鍒嗛厤鐢ㄦ埛,鎵归噺鍙栨秷宸插垎閰嶇殑鐢ㄦ埛]
+ public static ToMessage RoleAssignedUserBatchCancel(string role_code, string[] user, User us)
+ {
+ return BasicSettingDAL.RoleAssignedUserBatchCancel(role_code,user,us);
+ }
+ #endregion
+
+ #region[瑙掕壊绠$悊鍒嗛厤鐢ㄦ埛,鎵归噺娣诲姞鏈垎閰嶇殑鐢ㄦ埛]
+ public static ToMessage RoleAssignedUserBatchAdd(string role_code, string[] user, User us)
+ {
+ return BasicSettingDAL.RoleAssignedUserBatchAdd(role_code, user, us);
+ }
+ #endregion
+
+
+
+ #region[瑙掕壊鏉冮檺鏌ヨ瑙掕壊]
+ public static ToMessage RolePermissionSearchRole()
+ {
+ return BasicSettingDAL.RolePermissionSearchRole();
+ }
+ #endregion
+
+ #region[瑙掕壊鏉冮檺鏌ヨ榛樿鑿滃崟鎸夐挳鏁版嵁]
+ public static ToMessage RolePermissionSearchRoleMenu(string type)
+ {
+ return BasicSettingDAL.RolePermissionSearchRoleMenu(type);
+ }
+ #endregion
+
+ #region[瑙掕壊鏉冮檺,鏍规嵁瑙掕壊鏌ユ壘鍏宠仈鏉冮檺]
+ public static ToMessage RolePermissionSearchRoleMenuButton(string rolecode,string type)
+ {
+ return BasicSettingDAL.RolePermissionSearchRoleMenuButton(rolecode, type);
+ }
+ #endregion
+
+ #region[瑙掕壊鏉冮檺,鎻愪氦]
+ public static ToMessage RolePermissionSava(string json, string rolecode,string type, User us)
+ {
+ return BasicSettingDAL.RolePermissionSava(json, rolecode, type,us);
+ }
+ #endregion
+
+
+ }
+}
diff --git a/VueWebCoreApi/DLL/BLL/DeviceManagerBLL.cs b/VueWebCoreApi/DLL/BLL/DeviceManagerBLL.cs
new file mode 100644
index 0000000..f16ac38
--- /dev/null
+++ b/VueWebCoreApi/DLL/BLL/DeviceManagerBLL.cs
@@ -0,0 +1,323 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.DAL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.BLL
+{
+ public class DeviceManagerBLL
+ {
+ #region[璁惧绫诲瀷鏌ヨ]
+ public static ToMessage DeviceTypeSearch(int startNum, int endNum, string prop, string order)
+ {
+ return DeviceManagerDAL.DeviceTypeSearch(startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[璁惧绫诲瀷鏂板]
+ public static ToMessage AddUpdateDeviceType(List<ObjectDataCont> json, string username)
+ {
+ return DeviceManagerDAL.AddUpdateDeviceType(json, username);
+ }
+ #endregion
+
+ #region[璁惧绫诲瀷鍒犻櫎]
+ public static ToMessage DeleteDeviceType(string devicetypecode)
+ {
+ return DeviceManagerDAL.DeleteDeviceType(devicetypecode);
+ }
+ #endregion
+
+
+ #region[璁惧绫诲瀷涓嬫媺妗嗘帴鍙
+ public static ToMessage DeviceTypeSelect()
+ {
+ return DeviceManagerDAL.DeviceTypeSelect();
+ }
+ #endregion
+
+ #region[璁惧缁勬煡璇
+ public static ToMessage DeviceGroupSearch(int startNum, int endNum, string prop, string order)
+ {
+ return DeviceManagerDAL.DeviceGroupSearch(startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[璁惧缁勬柊澧瀅
+ public static ToMessage AddUpdateDeviceGroup(List<ObjectDataCont> json, string username)
+ {
+ return DeviceManagerDAL.AddUpdateDeviceGroup(json, username);
+ }
+ #endregion
+
+ #region[璁惧缁勫垹闄
+ public static ToMessage DeleteDeviceGroup(string devicegroupcode)
+ {
+ return DeviceManagerDAL.DeleteDeviceGroup(devicegroupcode);
+ }
+ #endregion
+
+
+ #region[璁惧绫诲瀷鏌ユ壘璁惧缁刔
+ public static ToMessage DeviceTypeSelectGroup(string eqptypecode)
+ {
+ return DeviceManagerDAL.DeviceTypeSelectGroup(eqptypecode);
+ }
+ #endregion
+
+ #region[鎵�灞炶溅闂翠笅鎷夋帴鍙
+ public static ToMessage WorkShopSelect(string stu_torgcode, string description)
+ {
+ return DeviceManagerDAL.WorkShopSelect(stu_torgcode, description);
+ }
+ #endregion
+
+ #region[鎵�灞炶溅闂存煡鎵炬墍灞炰骇绾挎帴鍙
+ public static ToMessage WorkShopSelectLine(string workshopcode)
+ {
+ return DeviceManagerDAL.WorkShopSelectLine(workshopcode);
+ }
+ #endregion
+
+ #region [璁惧娓呭崟鏌ヨ]
+ public static ToMessage DeviceMangerSearch(string stu_torgcode, string description, string deviceCode, string deviceName, string status, string workShop, string deviceType, string deviceGroup, int startNum, int endNum, string prop, string order)
+ {
+ return DeviceManagerDAL.DeviceMangerSearch(stu_torgcode, description, deviceCode, deviceName, status, workShop, deviceType, deviceGroup, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[璁惧娓呭崟鏂板缂栬緫]
+ public static ToMessage AddUpdateDeviceManger(string deviceid, string devicecode, string devicename, string devicetype, string devicegroup, string importdate, string workshop, string linecode, string status, string ratio, string usercode, string operType)
+ {
+ return DeviceManagerDAL.AddUpdateDeviceManger(deviceid, devicecode, devicename, devicetype, devicegroup, importdate, workshop, linecode, status, ratio, usercode, operType);
+ }
+ #endregion
+
+ #region[璁惧娓呭崟鍒犻櫎]
+ public static ToMessage DeleteDeviceManger(string devicecode)
+ {
+ return DeviceManagerDAL.DeleteDeviceManger(devicecode);
+ }
+ #endregion
+
+
+
+
+ #region[璁惧鐐规椤瑰垪琛ㄦ煡璇
+ public static ToMessage DeviceCheckItemSearch(string checkitemcode, string checkitemname, string checkdescr, string isqrcode, string cycle, int startNum, int endNum, string prop, string order)
+ {
+ return DeviceManagerDAL.DeviceCheckItemSearch(checkitemcode, checkitemname, checkdescr, isqrcode, cycle, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[璁惧鐐规椤规柊澧炵紪杈慮
+ public static ToMessage AddUpdateDeviceCheckItem(string checkitemid, string checkitemcode, string checkitemname, string checkitemdescr, string cycle, string isqrcode, string usercode, string operType)
+ {
+ return DeviceManagerDAL.AddUpdateDeviceCheckItem(checkitemid, checkitemcode, checkitemname, checkitemdescr, cycle, isqrcode, usercode, operType);
+ }
+ #endregion
+
+ #region[璁惧鐐规椤瑰垹闄
+ public static ToMessage DeleteDeviceCheckItem(string checkitemcode)
+ {
+ return DeviceManagerDAL.DeleteDeviceCheckItem(checkitemcode);
+ }
+ #endregion
+
+
+ #region[璁惧淇濆吇椤瑰垪琛ㄦ煡璇
+ public static ToMessage DeviceMaiItemSearch(string maiitemcode, string maiitemname, string maidescr, string isqrcode, int startNum, int endNum, string prop, string order)
+ {
+ return DeviceManagerDAL.DeviceMaiItemSearch(maiitemcode, maiitemname, maidescr, isqrcode, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[璁惧淇濆吇椤规柊澧炵紪杈慮
+ public static ToMessage AddUpdateDeviceMaiItem(string maiitemid, string maiitemcode, string maiitemname, string maiitemdescr, string isqrcode, string usercode, string operType)
+ {
+ return DeviceManagerDAL.AddUpdateDeviceMaiItem(maiitemid, maiitemcode, maiitemname, maiitemdescr, isqrcode, usercode, operType);
+ }
+ #endregion
+
+ #region[璁惧淇濆吇椤瑰垹闄
+ public static ToMessage DeleteDeviceMaiItem(string maiitemcode)
+ {
+ return DeviceManagerDAL.DeleteDeviceMaiItem(maiitemcode);
+ }
+ #endregion
+
+
+
+ #region[璁惧鐐规鏍囧噯鍒楄〃鏌ヨ]
+ public static ToMessage DeviceCheckStandArdSearch(string stu_torgcode, string stu_torgtypecode, string checkstandcode, string checkstandname, string checkcontr, int startNum, int endNum, string prop, string order)
+ {
+ return DeviceManagerDAL.DeviceCheckStandArdSearch(stu_torgcode, stu_torgtypecode, checkstandcode, checkstandname, checkcontr, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[璁惧鐐规鏍囧噯鏂板銆佺紪杈戣幏鍙栨楠岄」鐩笅鎷夊垪琛╙
+ public static ToMessage DeviceCheckItemSelect()
+ {
+ return DeviceManagerDAL.DeviceCheckItemSelect();
+ }
+ #endregion
+
+ #region[璁惧鐐规鏍囧噯缂栬緫/鏌ョ湅鑾峰彇鏁版嵁]
+ public static ToMessage ViewDeviceCheckStanedSearch(string checkstand_code)
+ {
+ return DeviceManagerDAL.ViewDeviceCheckStanedSearch(checkstand_code);
+ }
+ #endregion
+
+ #region[璁惧鐐规鏍囧噯鏂板缂栬緫]
+ public static ToMessage AddUpdateDeviceCheckStandArd(string opertype, RoutEdit json, string username)
+ {
+ return DeviceManagerDAL.AddUpdateDeviceCheckStandArd(opertype, json, username);
+ }
+ #endregion
+
+ #region[璁惧鐐规鏍囧噯鍒犻櫎]
+ public static ToMessage DeleteDeviceCheckStaned(string checkstand_code)
+ {
+ return DeviceManagerDAL.DeleteDeviceCheckStaned(checkstand_code);
+ }
+ #endregion
+
+ #region[璁惧鐐规鏍囧噯鍏宠仈宸ヤ綔绔欐煡璇
+ public static ToMessage DeviceCheckStanedAssociationEqp(string stu_torgcode, string description, string checkstand_code)
+ {
+ return DeviceManagerDAL.DeviceCheckStanedAssociationEqp(stu_torgcode, description, checkstand_code);
+ }
+ #endregion
+
+ #region [璁惧鐐规鏍囧噯鍏宠仈宸ヤ綔绔欐彁浜
+ public static ToMessage SaveDeviceCheckStanedAssociationEqp(string stu_torgcode, string stu_torgtypecode, string checkstand_code, string username, List<ObjectData> json)
+ {
+ return DeviceManagerDAL.SaveDeviceCheckStanedAssociationEqp(stu_torgcode, stu_torgtypecode, checkstand_code, username, json);
+ }
+ #endregion
+
+
+
+ #region[璁惧淇濆吇鏍囧噯鍒楄〃鏌ヨ]
+ public static ToMessage DeviceRepairStandArdSearch(string stu_torgcode, string stu_torgtypecode, string repairstandcode, string repairstandname, string repairstanddescr, int startNum, int endNum, string prop, string order)
+ {
+ return DeviceManagerDAL.DeviceRepairStandArdSearch(stu_torgcode, stu_torgtypecode, repairstandcode, repairstandname, repairstanddescr, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[璁惧淇濆吇鏍囧噯鏂板銆佺紪杈戣幏鍙栦繚鍏婚」鐩笅鎷夊垪琛╙
+ public static ToMessage DeviceRepairItemSelect()
+ {
+ return DeviceManagerDAL.DeviceRepairItemSelect();
+ }
+ #endregion
+
+ #region[璁惧淇濆吇鏍囧噯缂栬緫/鏌ョ湅鑾峰彇鏁版嵁]
+ public static ToMessage ViewDeviceRepairStanedSearch(string repairstand_code)
+ {
+ return DeviceManagerDAL.ViewDeviceRepairStanedSearch(repairstand_code);
+ }
+ #endregion
+
+ #region[璁惧淇濆吇鏍囧噯鏂板缂栬緫]
+ public static ToMessage AddUpdateDeviceRepairStandArd(string opertype, EqpRepair json, string username)
+ {
+ return DeviceManagerDAL.AddUpdateDeviceRepairStandArd(opertype, json, username);
+ }
+ #endregion
+
+ #region[璁惧淇濆吇鏍囧噯鍒犻櫎]
+ public static ToMessage DeleteDeviceRepairStaned(string repairstand_code)
+ {
+ return DeviceManagerDAL.DeleteDeviceRepairStaned(repairstand_code);
+ }
+ #endregion
+
+ #region[璁惧淇濆吇鏍囧噯鍏宠仈宸ヤ綔绔欐煡璇
+ public static ToMessage DeviceRepairStanedAssociationEqp(string stu_torgcode, string description, string repairstand_code)
+ {
+ return DeviceManagerDAL.DeviceRepairStanedAssociationEqp(stu_torgcode, description, repairstand_code);
+ }
+ #endregion
+
+ #region [璁惧淇濆吇鏍囧噯鍏宠仈宸ヤ綔绔欐彁浜
+ public static ToMessage SaveDeviceRepairStanedAssociationEqp(string stu_torgcode, string stu_torgtypecode, string repairstand_code, string username, List<ObjectData> json)
+ {
+ return DeviceManagerDAL.SaveDeviceRepairStanedAssociationEqp(stu_torgcode, stu_torgtypecode, repairstand_code, username, json);
+ }
+ #endregion
+
+
+
+ #region[璁惧鐐规璁板綍鏌ヨ]
+ public static ToMessage DeviceCheckTakeSearch(string stu_torgcode, string description, string wkshopcode, string eqpcode, string eqpname, string stanedname, string checkuser, string checkopendate, string checkclosedate, int startNum, int endNum, string prop, string order)
+ {
+ return DeviceManagerDAL.DeviceCheckTakeSearch(stu_torgcode, description, wkshopcode, eqpcode, eqpname, stanedname, checkuser, checkopendate, checkclosedate, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[璁惧鐐规璁板綍鏄庣粏鏌ヨ]
+ public static ToMessage DeviceCheckSubTakeSearch(string djwo)
+ {
+ return DeviceManagerDAL.DeviceCheckSubTakeSearch(djwo);
+ }
+ #endregion
+
+ #region[璁惧鐐规璁板綍瀵煎嚭]
+ public static ToMessage DeviceCheckTakeOutExcel(string stu_torgcode, string description, string wkshopcode, string eqpcode, string eqpname, string stanedname, string checkuser, string checkopendate, string checkclosedate)
+ {
+ return DeviceManagerDAL.DeviceCheckTakeOutExcel(stu_torgcode, description, wkshopcode, eqpcode, eqpname, stanedname, checkuser, checkopendate, checkclosedate);
+ }
+ #endregion
+
+
+
+ #region[璁惧淇濆吇璁板綍鏌ヨ]
+ public static ToMessage DeviceRepairTakeSearch(string stu_torgcode, string description, string wkshopcode, string eqpcode, string eqpname, string stanedname, string repairuser, string repairopendate, string repairclosedate, string repairresult, int startNum, int endNum, string prop, string order)
+ {
+ return DeviceManagerDAL.DeviceCheckTakeSearch(stu_torgcode, description, wkshopcode, eqpcode, eqpname, stanedname, repairuser, repairopendate, repairclosedate, repairresult, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[璁惧淇濆吇璁板綍鏄庣粏鏌ヨ]
+ public static ToMessage DeviceRepairSubTakeSearch(string bywo)
+ {
+ return DeviceManagerDAL.DeviceRepairSubTakeSearch(bywo);
+ }
+ #endregion
+
+ #region[璁惧淇濆吇璁板綍瀵煎嚭]
+ public static ToMessage DeviceRepairTakeOutExcel(string stu_torgcode, string description, string wkshopcode, string eqpcode, string eqpname, string stanedname, string repairuser, string repairopendate, string repairclosedate, string repairresult)
+ {
+ return DeviceManagerDAL.DeviceRepairTakeOutExcel(stu_torgcode, description, wkshopcode, eqpcode, eqpname, stanedname, repairuser, repairopendate, repairclosedate, repairresult);
+ }
+ #endregion
+
+
+
+ #region[璁惧缁翠慨璁板綍鏌ヨ]
+ public static ToMessage DeviceUpdateSearch(string stu_torgcode, string description, string wkshopcode, string eqpcode, string eqpname, string reportuser, string repairuser, string vrifcatuser, string reportopendate, string reportclosedate, string repairopendate, string repairclosedate, string vrifcatopendate, string vrifcatclosedate, int startNum, int endNum, string prop, string order)
+ {
+ return DeviceManagerDAL.DeviceUpdateSearch(stu_torgcode, description, wkshopcode, eqpcode, eqpname, reportuser, repairuser, vrifcatuser, reportopendate, reportclosedate, repairopendate, repairclosedate, vrifcatopendate, vrifcatclosedate, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[璁惧缁翠慨璁板綍鏄庣粏鏌ヨ]
+ public static ToMessage DeviceUpdateSubSearch(string repair_code)
+ {
+ return DeviceManagerDAL.DeviceUpdateSubSearch(repair_code);
+ }
+ #endregion
+
+ #region[璁惧缁翠慨璁板綍瀵煎嚭]
+ public static ToMessage DeviceUpdateOutExcel(string stu_torgcode, string description, string wkshopcode, string eqpcode, string eqpname, string reportuser, string repairuser, string vrifcatuser, string reportopendate, string reportclosedate, string repairopendate, string repairclosedate, string vrifcatopendate, string vrifcatclosedate)
+ {
+ return DeviceManagerDAL.DeviceUpdateOutExcel(stu_torgcode, description, wkshopcode, eqpcode, eqpname, reportuser, repairuser, vrifcatuser, reportopendate, reportclosedate, repairopendate, repairclosedate, vrifcatopendate, vrifcatclosedate);
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/BLL/ExcelCheckBLL.cs b/VueWebCoreApi/DLL/BLL/ExcelCheckBLL.cs
new file mode 100644
index 0000000..668c121
--- /dev/null
+++ b/VueWebCoreApi/DLL/BLL/ExcelCheckBLL.cs
@@ -0,0 +1,34 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.DAL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.BLL
+{
+ public class ExcelCheckBLL
+ {
+ #region銆怑xcel瀵煎叆妯℃澘楠岃瘉銆�
+ public static ToMessage ExcelCheck(string fileCode, string savePath)
+ {
+ return ExcelCheckDAL.ExcelCheck(fileCode, savePath);
+ }
+ #endregion
+
+ #region[Excel瀵煎叆鏁版嵁楠岃瘉]
+ public static List<ExcelErro> ExcelCheckData(string fileCode, string savePath, out string stuCode, out string message, out int count)
+ {
+ return ExcelCheckDAL.ExcelCheckData(fileCode, savePath, out stuCode, out message, out count);
+ }
+ #endregion
+
+ #region[Excel瀵煎叆鏁版嵁]
+ public static ToMessage ExcelImportSubmit(string fileCode, string savePath, string username)
+ {
+ return ExcelCheckDAL.ExcelImportSubmit(fileCode, savePath, username);
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/BLL/GeneralBasicDataBLL.cs b/VueWebCoreApi/DLL/BLL/GeneralBasicDataBLL.cs
new file mode 100644
index 0000000..53b5d40
--- /dev/null
+++ b/VueWebCoreApi/DLL/BLL/GeneralBasicDataBLL.cs
@@ -0,0 +1,55 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.DAL;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.BLL
+{
+ public class GeneralBasicDataBLL
+ {
+
+ #region [缁勭粐鏋舵瀯鏌ユ壘]
+ public static ToMessage PrentOrganization()
+ {
+ return GeneralBasicDataDAL.PrentOrganization();
+ }
+ #endregion
+
+ #region[宀椾綅鍩虹璧勬枡]
+ public static ToMessage PostPermissions()
+ {
+ return GeneralBasicDataDAL.PostPermissions();
+ }
+ #endregion
+
+ #region[瑙掕壊鍩虹璧勬枡]
+ public static ToMessage RolePermissions()
+ {
+ return GeneralBasicDataDAL.RolePermissions();
+ }
+ #endregion
+
+ #region[鐝粍鍩虹璧勬枡]
+ public static ToMessage GroupsPermissions()
+ {
+ return GeneralBasicDataDAL.GroupsPermissions();
+ }
+ #endregion
+
+ #region[鎸夐挳鍩虹璧勬枡]
+ public static ToMessage ButtonData()
+ {
+ return GeneralBasicDataDAL.ButtonData();
+ }
+ #endregion
+
+ #region[鏁版嵁鏉冮檺鍩虹璧勬枡]
+ public static ToMessage DataPermissions()
+ {
+ return GeneralBasicDataDAL.DataPermissions();
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/BLL/LoginBLL.cs b/VueWebCoreApi/DLL/BLL/LoginBLL.cs
new file mode 100644
index 0000000..6589ff6
--- /dev/null
+++ b/VueWebCoreApi/DLL/BLL/LoginBLL.cs
@@ -0,0 +1,66 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.DAL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.BLL
+{
+ public class LoginBLL
+ {
+
+ #region [鐧诲綍鏌ヨ]
+ public static ToMessage LoginSearch(string username, string password)
+ {
+ return LoginDAL.LoginSearch(username, password);
+ }
+ #endregion
+
+ #region [鍐欏叆鐧诲綍璁板綍琛╙
+ public static ToMessage LoginBas(string usercode, string oper_type, string description, string type)
+ {
+ return LoginDAL.LoginBas(usercode, oper_type, description,type);
+ }
+ #endregion
+
+ #region[鏌ヨ鑿滃崟鍔熻兘]
+ public static ToMessage LoginMenu(string usercode, string usertype, User us)
+ {
+ return LoginDAL.LoginMenu(usercode, usertype, us);
+ }
+ #endregion
+
+ #region[淇敼瀵嗙爜]
+ public static ToMessage UpdateUserPassword(User us, string password, string newpassword)
+ {
+ return LoginDAL.UpdateUserPassword(us, password, newpassword);
+ }
+ #endregion
+
+ #region[鐧诲嚭]
+ public static ToMessage LoginOut(User us)
+ {
+ return LoginDAL.LoginOut(us);
+ }
+ #endregion
+
+
+
+ #region[APP瀵嗙爜閲嶇疆]
+ public static ToMessage ResettUserPassword(string usercode, string username,string usertype)
+ {
+ return LoginDAL.ResettUserPassword(usercode, username, usertype);
+ }
+ #endregion
+
+ #region[App鐧诲綍鏌ヨ瀹夌伅鍛煎彨淇℃伅]
+ public static ToMessage LoginAppAnDonMessage(string rid, string usercode, string username, string usertype, string stu_torgcode, string stu_torgtypecode)
+ {
+ return LoginDAL.LoginAppAnDonMessage(rid, usercode, username, usertype, stu_torgcode, stu_torgtypecode);
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/BLL/ProductionManagementBLL.cs b/VueWebCoreApi/DLL/BLL/ProductionManagementBLL.cs
new file mode 100644
index 0000000..acd3ba0
--- /dev/null
+++ b/VueWebCoreApi/DLL/BLL/ProductionManagementBLL.cs
@@ -0,0 +1,441 @@
+锘縰sing Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.DAL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.BLL
+{
+ public class ProductionManagementBLL
+ {
+ #region[鑾峰彇鍗曟嵁鍙穄
+ public static ToMessage ProductInHouseOrderCodeSearch(string rightcode)
+ {
+ return ProductionManagementDAL.ProductInHouseOrderCodeSearch(rightcode);
+ }
+ #endregion
+
+
+ #region[ERP璁㈠崟鏌ヨ]
+ public static ToMessage ErpOrderSearch(string stu_torgcode, string stu_torgtypecode, string erporderstus, string erpordercode, string partcode, string partname, string partspec, int startNum, string paydatestartdate, string paydateenddate, string paydatestartdate1, string paydateenddate2, string creatuser, int endNum, string prop, string order)
+ {
+ return ProductionManagementDAL.ErpOrderSearch(stu_torgcode, stu_torgtypecode, erporderstus, erpordercode, partcode, partname, partspec, startNum, paydatestartdate, paydateenddate, paydatestartdate1, paydateenddate2, creatuser, endNum, prop, order);
+ }
+ #endregion
+
+ #region[ERP璁㈠崟涓嬭揪]
+ public static ToMessage MarkSaveErpOrder(string erporderid, string erpordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string saleOrderDeliveryDate, string username)
+ {
+ return ProductionManagementDAL.MarkSaveErpOrder(erporderid, erpordercode, partcode, wkshopcode, warehousecode, erpqty, markqty, ordernum, relse_qty, saleOrderDeliveryDate, username);
+ }
+ #endregion
+
+ #region[ERP璁㈠崟鍏抽棴]
+ public static ToMessage ClosedErpOrder(string erporderid, string erpordercode, string username)
+ {
+ return ProductionManagementDAL.ClosedErpOrder(erporderid, erpordercode, username);
+ }
+ #endregion
+
+
+
+ #region[MES宸ュ崟鏌ヨ]
+ public static ToMessage MesOrderSearch(string stu_torgcode, string stu_torgtypecode, string mesorderstus, string mesordercode, string sourceorder, string ordertype, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order)
+ {
+ return ProductionManagementDAL.MesOrderSearch(stu_torgcode, stu_torgtypecode, mesorderstus, mesordercode, sourceorder, ordertype, partcode, partname, partspec, startNum, creatuser, createdate, endNum, prop, order);
+ }
+ #endregion
+
+ #region[MES鎶ュ簾琛ュ崟宸ュ崟鏌ヨ]
+ public static ToMessage MesBadOrderSearch(string mesordercode, string sourceorder, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order)
+ {
+ return ProductionManagementDAL.MesBadOrderSearch(mesordercode, sourceorder, partcode, partname, partspec, startNum, creatuser, createdate, endNum, prop, order);
+ }
+ #endregion
+
+ #region[浜у搧缂栫爜鏌ユ壘宸ヨ壓璺嚎涓嬫媺鎺ュ彛]
+ public static ToMessage PartSelectRoute(string partcode, string wkshopcode)
+ {
+ return ProductionManagementDAL.PartSelectRoute(partcode, wkshopcode);
+ }
+ #endregion
+
+ #region[宸ヨ壓璺嚎鏌ユ壘杞﹂棿涓嬫媺鎺ュ彛]
+ public static ToMessage RouteSelectWkshop(string stu_torgcode, string stu_torgtypecode, string partcode)
+ {
+ return ProductionManagementDAL.RouteSelectWkshop(stu_torgcode, stu_torgtypecode, partcode);
+ }
+ #endregion
+
+ #region[鏍规嵁閫夋嫨宸ヨ壓璺嚎鏌ョ湅宸ュ簭鎺ュ彛]
+ public static ToMessage SelectRouteStep(string routecode)
+ {
+ return ProductionManagementDAL.SelectRouteStep(routecode);
+ }
+ #endregion
+
+ #region銆愮敓浜х鐞嗐�佸伐鍗曟柊澧炪�佺紪杈戞椂,閫夋嫨鎺掔▼鏄椂鑾峰彇鐗╂枡娓呭崟鐗堟湰鍙枫��
+ public static ToMessage JobCreationSonAddVison(string partnumber)
+ {
+ return ProductionManagementDAL.JobCreationSonAddVison(partnumber);
+ }
+ #endregion
+
+ #region[宸ュ崟娲惧彂閫夋嫨宸ヨ壓璺嚎鎴栭�夋嫨鐢熶骇杞﹂棿鏃跺垽鏂粦瀹氭潯浠禲
+ public static ToMessage SelectRouteOrWkshop(string partcode, string routecode, string wkshopcode)
+ {
+ return ProductionManagementDAL.SelectRouteOrWkshop(partcode, routecode, wkshopcode);
+ }
+ #endregion
+
+ #region[MES宸ュ崟鏂板銆佽幏鍙栧伐鍗曞彿]
+ public static ToMessage AddMesOrderCodeSearch()
+ {
+ return ProductionManagementDAL.AddMesOrderCodeSearch();
+ }
+ #endregion
+
+ #region[MES宸ュ崟鏂板銆佺紪杈戞彁浜
+ public static ToMessage AddUpdateMesOrder(string mesorderstus, string mesordercode, string sourceorder, string ordertype, string partcode, string mesqty, string routecode, string wkshopcode, string planstartdate, string planenddate, string orderlev, string username, string opertype, string is_aps, string bom_id)
+ {
+ return ProductionManagementDAL.AddUpdateMesOrder(mesorderstus, mesordercode, sourceorder, ordertype, partcode, mesqty, routecode, wkshopcode, planstartdate, planenddate, orderlev, username, opertype, is_aps, bom_id);
+ }
+ #endregion
+
+ #region[MES宸ュ崟鍒犻櫎]
+ public static ToMessage DeleteMesOrder(string souceid, string wocode, string m_po, string orderqty)
+ {
+ return ProductionManagementDAL.DeleteMesOrder(souceid, wocode, m_po, orderqty);
+ }
+ #endregion
+
+ #region[MES宸ュ崟鍏抽棴]
+ public static ToMessage ClosedMesOrder(string username, string wocode, string m_po)
+ {
+ return ProductionManagementDAL.ClosedMesOrder(username, wocode, m_po);
+ }
+ #endregion
+
+ #region[MES宸ュ崟鏌ョ湅宸ュ簭浠诲姟]
+ public static ToMessage SearchWorkStep(string wo_code)
+ {
+ return ProductionManagementDAL.SearchWorkStep(wo_code);
+ }
+ #endregion
+
+
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇褰撳墠宸ュ簭瀵瑰簲鐨勮澶�(鑷埗)]
+ public static ToMessage MesOrderStepEqpSearch(string orderstepqrcode)
+ {
+ return ProductionManagementDAL.MesOrderStepEqpSearch(orderstepqrcode);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇褰撳墠宸ュ簭瀵瑰簲鐨勪緵鏂�(澶栧崗)]
+ public static ToMessage MesOrderWxStepEqpSearch(string orderstepqrcode)
+ {
+ return ProductionManagementDAL.MesOrderWxStepEqpSearch(orderstepqrcode);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟]
+ public static ToMessage MesOrderStepSearch(string stu_torgcode, string stu_torgtypecode, string orderstepqrcode, int startNum, int endNum, string prop, string order)
+ {
+ return ProductionManagementDAL.MesOrderStepSearch(stu_torgcode, stu_torgtypecode, orderstepqrcode, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟(澶栧崗)]
+ public static ToMessage MesOrderWxStepSearch(string stu_torgcode, string stu_torgtypecode, string orderstepqrcode, int startNum, int endNum, string prop, string order)
+ {
+ return ProductionManagementDAL.MesOrderWxStepSearch(stu_torgcode, stu_torgtypecode, orderstepqrcode, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟(涓嶈壇)]
+ public static ToMessage MesOrderNgStepSearch(string stu_torgcode, string stu_torgtypecode, string orderstepqrcode, int startNum, int endNum, string prop, string order)
+ {
+ return ProductionManagementDAL.MesOrderNgStepSearch(stu_torgcode, stu_torgtypecode, orderstepqrcode, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟(涓嶈壇鏄庣粏)]
+ public static ToMessage MesOrderNgSubStepSearch(string orderstepqrcode)
+ {
+ return ProductionManagementDAL.MesOrderNgSubStepSearch(orderstepqrcode);
+ }
+ #endregion
+
+ #region [鐢熶骇寮�鎶ュ伐锛氬紑宸�(寮�濮�/鎶ュ伐)/澶栧崗鍙戞枡鏃舵潯浠跺垽鏂強鏁版嵁杩斿洖鎺ュ彛]
+ public static ToMessage MesOrderStepStart(string OperType, string stu_torgcode, string SelectType, string orderstepqrcode)
+ {
+ return ProductionManagementDAL.MesOrderStepStart(OperType, stu_torgcode, SelectType, orderstepqrcode);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐锛氬紑宸ユ椂鑾峰彇璁惧涓嬫媺鍒楄〃]
+ public static ToMessage MesOrderStepStartSelectEqp(string orderstepqrcode)
+ {
+ return ProductionManagementDAL.MesOrderStepStartSelectEqp(orderstepqrcode);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐锛氭姤宸ユ椂鑾峰彇鐢熶骇鐝粍涓嬫媺妗哴
+ public static ToMessage MesOrderStepReportSelectUserGroup(string stu_torgcode, string stu_torgtypecode, string wkshopcode)
+ {
+ return ProductionManagementDAL.MesOrderStepReportSelectUserGroup(stu_torgcode, stu_torgtypecode, wkshopcode);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐锛氭牴鎹敓浜х彮缁勬煡鎵句汉鍛樺垪琛╙
+ public static ToMessage MesOrderGroupSelectUser(string stu_torgcode, string usergroupcode)
+ {
+ return ProductionManagementDAL.MesOrderGroupSelectUser(stu_torgcode, usergroupcode);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐锛氫汉鍛樹笅鎷夊垪琛╙
+ public static ToMessage MesOrderSelectUser(string usercode)
+ {
+ return ProductionManagementDAL.MesOrderSelectUser(usercode);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐锛氬彂鏂�/鏀舵枡鏃惰幏鍙栧鍗忎笅鎷夊垪琛╙
+ public static ToMessage MesOrderStepSelectWX(string orderstepqrcode)
+ {
+ return ProductionManagementDAL.MesOrderStepSelectWX(orderstepqrcode);
+ }
+ #endregion
+
+ #region[鐢熶骇鎶ュ伐锛氭姤宸�/澶栧崗鏀舵枡 鑾峰彇涓嶈壇鍘熷洜涓嬫媺鍒楄〃]
+ public static ToMessage MesOrderStepSelectCause(string orderstepqrcode)
+ {
+ return ProductionManagementDAL.MesOrderStepSelectCause(orderstepqrcode);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐,寮�宸�(寮�濮�)鎻愪氦]
+ public static ToMessage SavaMesOrderStepStart(string mesordercode, string partcode, string stepseq, string stepcode, string eqpcode, string taskqty, string startqty, string username)
+ {
+ return ProductionManagementDAL.SavaMesOrderStepStart(mesordercode, partcode, stepseq, stepcode, eqpcode, taskqty, startqty, username);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐,鎶ュ伐鎻愪氦]
+ public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string eqpcode, string inbarcode, string reckway, string usergroupcode, string reportuser, string taskqty, string startqty, string reportqty, string ngqty, string badcode, string remarks, string username)
+ {
+ return ProductionManagementDAL.SavaMesOrderStepReport(mesordercode, partcode, stepseq, stepcode, eqpcode, inbarcode, reckway, usergroupcode, reportuser, taskqty, startqty, reportqty, ngqty, badcode, remarks, username);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐,鍙戞枡鎻愪氦]
+ public static ToMessage SavaMesOrderStepOut(string mesordercode, string partcode, string stepseq, string stepcode, string wxcode, string outuser, string taskqty, string fqty, string username)
+ {
+ return ProductionManagementDAL.SavaMesOrderStepOut(mesordercode, partcode, stepseq, stepcode, wxcode, outuser, taskqty, fqty, username);
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐, 鏀舵枡鎻愪氦]
+ public static ToMessage SavaMesOrderStepIn(string mesordercode, string partcode, string stepseq, string stepcode, string wxcode, string inbarcode, string inuser, string taskqty, string sqty, string ngqty, string badcode, string remarks, string username)
+ {
+ return ProductionManagementDAL.SavaMesOrderStepIn(mesordercode, partcode, stepseq, stepcode, wxcode, inbarcode, inuser, taskqty, sqty, ngqty, badcode, remarks, username);
+ }
+ #endregion
+
+ #region[涓嶈壇澶勭悊,鎻愪氦]
+ public static ToMessage EditOrderNgStepSeave(ReportDefectHandle json, string username)
+ {
+ return ProductionManagementDAL.EditOrderNgStepSeave(json, username);
+ }
+ #endregion
+
+
+ #region[宸ュ簭妫�楠屾壂鐮佽幏鍙栦换鍔′俊鎭痌
+ public static ToMessage MesOrderStepCheckSearch(string stu_torgcode, string orderstepqrcode, string checktype)
+ {
+ return ProductionManagementDAL.MesOrderStepCheckSearch(stu_torgcode, orderstepqrcode, checktype);
+ }
+ #endregion
+
+ #region[宸ュ簭妫�楠屾牴鎹�夋嫨鐨勬楠屾柟妗堟煡鎵炬楠岄」鐩甝
+ public static ToMessage MesOrderStepCheckItemList(string checkstandcode)
+ {
+ return ProductionManagementDAL.MesOrderStepCheckItemList(checkstandcode);
+ }
+ #endregion
+
+ #region[宸ュ簭妫�楠�,鎻愪氦]
+ public static ToMessage SaveMesOrderStepCheckItem(string stu_torgcode, string wocode, string partcode, string stepcode, string checkstandcode, string check_type, string sampmethod, string qualitystatus, string labqty, string sampleqty, string goodqty, string ngqty, string checkitemcont, string username)
+ {
+ return ProductionManagementDAL.SaveMesOrderStepCheckItem(stu_torgcode, wocode, partcode, stepcode, checkstandcode, check_type, sampmethod, qualitystatus, labqty, sampleqty, goodqty, ngqty, checkitemcont, username);
+ }
+ #endregion
+
+
+
+ #region[MES宸ュ崟鎵归噺鍏抽棴鏌ヨ]
+ public static ToMessage MesOrderBitchClosedSearch(string stu_torgcode, string stu_torgtypecode, string mesorderstus, string mesordercode, string sourceorder, string ordertype, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order)
+ {
+ return ProductionManagementDAL.MesOrderBitchClosedSearch(stu_torgcode, stu_torgtypecode, mesorderstus, mesordercode, sourceorder, ordertype, partcode, partname, partspec, startNum, creatuser, createdate, endNum, prop, order);
+ }
+ #endregion
+
+ #region[MES宸ュ崟鎵归噺鍏抽棴鎻愪氦]
+ public static ToMessage MesOrderBitchClosedSeave(string username, DataTable dt)
+ {
+ return ProductionManagementDAL.MesOrderBitchClosedSeave(username, dt);
+ }
+ #endregion
+
+ #region[MES宸ュ崟鎵归噺鍙嶅叧闂璢
+ public static ToMessage MesOrderBitchAntiClosedSeave(string username, DataTable dt)
+ {
+ return ProductionManagementDAL.MesOrderBitchAntiClosedSeave(username, dt);
+ }
+ #endregion
+
+
+
+ #region[浜ц兘瑙勫垝璁剧疆鏌ヨ]
+ public static ToMessage CapacityPlanningSetupSearch()
+ {
+ return ProductionManagementDAL.CapacityPlanningSetupSearch();
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝璁剧疆鏂板]
+ public static ToMessage CapacityPlanningSetupAddUpdate(string username, List<CapacityPlanningSetup> objs)
+ {
+ return ProductionManagementDAL.CapacityPlanningSetupAddUpdate(username, objs);
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝鏂规璁剧疆鍒犻櫎]
+ public static ToMessage CapacityPlanningSetupDelete(string username, string capsetupcode)
+ {
+ return ProductionManagementDAL.CapacityPlanningSetupDelete(username, capsetupcode);
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝鏌ヨ]
+ public static ToMessage CapacityPlanningSearch(string workshop, string devicetype, string stustype, int startNum, int endNum, string prop, string order)
+ {
+ return ProductionManagementDAL.CapacityPlanningSearch(workshop, devicetype, stustype, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝榛樿鏂规淇濆瓨鎻愪氦]
+ public static ToMessage CapacityPlanSubmit(string type, string captplanid, string wkshopcode, string capunitcode, string capsetupcode, string captplantype, string username)
+ {
+ return ProductionManagementDAL.CapacityPlanSubmit(type, captplanid, wkshopcode, capunitcode, capsetupcode, captplantype, username);
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝鐐瑰嚮鏃ュ巻缁勪欢鏌ユ壘宸插叧鑱旂殑鏃ユ湡鏂规]
+ public static ToMessage CapacityPlanningCalendar(string captplanid)
+ {
+ return ProductionManagementDAL.CapacityPlanningCalendar(captplanid);
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝鏃ュ巻鍙屽嚮鏃跺甫鍑哄搴旂殑鏂规]
+ public static ToMessage CapacityPlanningOnclickSelect(string captplanid, string datetime)
+ {
+ return ProductionManagementDAL.CapacityPlanningOnclickSelect(captplanid, datetime);
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝宸ヤ綔鏃ュ巻閫夋嫨鎻愪氦]
+ public static ToMessage CapacityPlanningGivePlanSubmit(string captplanid, string wkshopcode, string capunitcode, string capsetupcode, string captplantype, List<CapaPlan> objs, string type, string username)
+ {
+ return ProductionManagementDAL.CapacityPlanningGivePlanSubmit(captplanid, wkshopcode, capunitcode, capsetupcode, captplantype, objs, type, username);
+ }
+ #endregion
+
+
+ #region[鑷姩鎺掔▼宸ュ崟鏌ヨ]
+ public static ToMessage AdvancedSchedulingSearch(string workshop, string wocode, string partcode, string partname, int startNum, int endNum, string prop, string order)
+ {
+ return ProductionManagementDAL.AdvancedSchedulingSearch(workshop, wocode, partcode, partname, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[鎺掍骇璁惧淇℃伅]
+ public static List<AdvancedSchedulingDevice> OnclickAdvancedSchedulingDevice(string wocode, string wkshpcode, string partcode, string startdate, string enddate, ref ToMessage mes)
+ {
+ return ProductionManagementDAL.OnclickAdvancedSchedulingDevice(wocode, wkshpcode, partcode, startdate, enddate, ref mes);
+ }
+ #endregion
+
+ #region[璁惧宸叉帓绋嬩俊鎭痌
+ public static DataTable AlreadyScheduling(string wocode, string wkshpcode, string partcode, string botproccode, string startdate, string enddate)
+ {
+ return ProductionManagementDAL.AlreadyScheduling(wocode, wkshpcode, partcode, botproccode, startdate, enddate);
+ }
+ #endregion
+
+ #region[NEW鎺掍骇璁惧淇℃伅]
+ public static List<AdvancedSchedulingDevice> NewOnclickAdvancedSchedulingDevice(List<ApsOrderSerch> json, ref ToMessage mes)
+ {
+ return ProductionManagementDAL.NewOnclickAdvancedSchedulingDevice(json, ref mes);
+ }
+ #endregion
+
+ #region[NEW璁惧宸叉帓绋嬩俊鎭痌
+ public static List<DataTable> NewAlreadyScheduling(List<ApsOrderSerch> json)
+ {
+ return ProductionManagementDAL.NewAlreadyScheduling(json);
+ }
+ #endregion
+
+ #region[鎺掔▼鏁版嵁鎻愪氦]
+ public static ToMessage SubmitAlreadyScheduling(string username, string wocode, string botprocecode, List<AlreadyScheduling> objs)
+ {
+ return ProductionManagementDAL.SubmitAlreadyScheduling(username, wocode, botprocecode, objs);
+ }
+ #endregion
+
+
+ #region[鐢熶骇鍏ュ簱鏉$爜琛ユ墦]
+ public static ToMessage ProductInHouseLabCode(string ordercode)
+ {
+ return ProductionManagementDAL.ProductInHouseLabCode(ordercode);
+ }
+ #endregion
+
+ #region[鐢熶骇鍏ュ簱閫氳繃杞﹂棿鏌ユ壘鐢熶骇璁㈠崟]
+ public static ToMessage ProductInHouseWkshopOrder(string ordertype, string wkshopcode)
+ {
+ return ProductionManagementDAL.ProductInHouseWkshopOrder(ordertype, wkshopcode);
+ }
+ #endregion
+
+ #region[鐢熶骇鍏ュ簱淇℃伅鏌ヨ]
+ public static ToMessage ProductInHouseOrderSearch(string wkshopcode, string erpordercode, string mesordercode, string partcode, string partname, string partspec, string startorderdate, string endorderdate)
+ {
+ return ProductionManagementDAL.ProductInHouseOrderSearch(wkshopcode, erpordercode, mesordercode, partcode, partname, partspec, startorderdate, endorderdate);
+ }
+ #endregion
+
+ #region[鐢熶骇鍏ュ簱鎻愪氦]
+ public static ToMessage ProductInHouseOrderSeave(string username, JObject obj)
+ {
+ return ProductionManagementDAL.ProductInHouseOrderSeave(username, obj);
+ }
+ #endregion
+
+
+ #region[App鐢熶骇鍏ュ簱鎵弿鏉$爜]
+ public static ToMessage MesAppProductInHouseOrderBarCodeSearch(string labcode)
+ {
+ return ProductionManagementDAL.MesAppProductInHouseOrderBarCodeSearch(labcode);
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/BLL/SystemSettingBLL.cs b/VueWebCoreApi/DLL/BLL/SystemSettingBLL.cs
new file mode 100644
index 0000000..711c8b0
--- /dev/null
+++ b/VueWebCoreApi/DLL/BLL/SystemSettingBLL.cs
@@ -0,0 +1,78 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.DAL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.BLL
+{
+ public class SystemSettingBLL
+ {
+ #region[缂栫爜瑙勫垯鑾峰彇鍙缃殑鍔熻兘鑿滃崟淇℃伅]
+ public static ToMessage CodeMenuSelect()
+ {
+ return SystemSettingDAL.CodeMenuSelect();
+ }
+ #endregion
+
+ #region[缂栫爜瑙勫垯鏌ヨ]
+ public static ToMessage EncodingRules(string rightname, string prefix, int startNum, int endNum, string prop, string order)
+ {
+ return SystemSettingDAL.EncodingRules(rightname, prefix, startNum, endNum, prop, order);
+ }
+ #endregion
+
+ #region[缂栫爜瑙勫垯缂栬緫淇濆瓨]
+ public static ToMessage SaveEncodingRules(string rightcode, string rightname, string prefix, string filingdate, string incbit,string type, User us)
+ {
+ return SystemSettingDAL.SaveEncodingRules(rightcode, rightname, prefix, filingdate, incbit, type, us);
+ }
+ #endregion
+
+ #region[缂栫爜瑙勫垯鍒犻櫎]
+ public static ToMessage DeleteEncodingRules(string menucode, User us)
+ {
+ return SystemSettingDAL.DeleteEncodingRules(menucode,us);
+ }
+ #endregion
+
+ #region[鑾峰彇瑙勫垯鐢熸垚鐨勭紪鐮�(姣忔鑾峰彇鏈�鏂�)]
+ public static ToMessage NewEncodingRules(string rightcode)
+ {
+ return SystemSettingDAL.NewEncodingRules(rightcode);
+ }
+ #endregion
+
+ #region[鑾峰彇瑙勫垯鐢熸垚鐨勭紪鐮�(鍙湁浣跨敤鎵嶈幏鍙栨渶鏂�)]
+ public static ToMessage OnlyEncodingRules(string rightcode)
+ {
+ return SystemSettingDAL.OnlyEncodingRules(rightcode);
+ }
+ #endregion
+
+ #region[鍥炲啓瑙勫垯鐢熸垚鐨勭紪鐮�(浣跨敤淇濆瓨)]
+ public static ToMessage SaveOnlyEncodingRules(string rightcode,string incbit)
+ {
+ return SystemSettingDAL.SaveOnlyEncodingRules(rightcode,incbit);
+ }
+ #endregion
+
+ #region[鐢熸垚鐗╂枡鏍囩鏉$爜(姣忔鑾峰彇鏈�鏂�,App鍙娇鐢�)]
+ public static ToMessage LabelBarCode(string rightcode, string partcode, string qty, string onelabqty)
+ {
+ return SystemSettingDAL.LabelBarCode(rightcode, partcode, qty, onelabqty);
+ }
+ #endregion
+
+
+ #region[App鐗堟湰鍗囩骇鎺ュ彛]
+ public static ToMessage AppUpgrade(string rid, string vision)
+ {
+ return SystemSettingDAL.AppUpgrade(rid, vision);
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/DAL/BaseDateDAL.cs b/VueWebCoreApi/DLL/DAL/BaseDateDAL.cs
new file mode 100644
index 0000000..c31c97b
--- /dev/null
+++ b/VueWebCoreApi/DLL/DAL/BaseDateDAL.cs
@@ -0,0 +1,417 @@
+锘縰sing Dapper;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.DAL
+{
+ public class BaseDateDAL
+ {
+ public static DataTable dt; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static bool res; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+ public static string strProcName = ""; //瀹氫箟鍏ㄥ眬sql鍙橀噺
+ public static List<SqlParameter> listStr = new List<SqlParameter>(); //瀹氫箟鍏ㄥ眬鍙傛暟闆嗗悎
+ public static SqlParameter[] parameters; //瀹氫箟鍏ㄥ眬SqlParameter鍙傛暟鏁扮粍
+
+ #region[閲囪喘渚涙柟淇℃伅鏌ヨ]
+ public static ToMessage PurchSupplierSelect()
+ {
+ string sql = "";
+ try
+ {
+ sql = @"select code,name from TCustomer
+ where type in('211','228') and is_delete='0'";
+ var data = DapperHelper.selecttable(sql);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[閮ㄩ棬淇℃伅鏌ヨ]
+ public static ToMessage DepartMentSelect()
+ {
+ string sql = "";
+ try
+ {
+ sql = @"select org_code as code,org_name as name from TOrganization
+ where description='D' and is_delete='0'";
+ var data = DapperHelper.selecttable(sql);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[浠撳簱淇℃伅鏌ヨ]
+ public static ToMessage StoreHouseSearch()
+ {
+ string sql = "";
+ try
+ {
+ sql = @"select code,name from T_Sec_Stck";
+ var data = DapperHelper.selecttable(sql);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[搴撲綅淇℃伅鏌ヨ]
+ public static ToMessage WarehouseLocationSearch()
+ {
+ string sql = "";
+ try
+ {
+ sql = @"select code,name from T_Sec_Loca";
+ var data = DapperHelper.selecttable(sql);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[搴撲綅鏌ユ壘浠撳簱]
+ public static ToMessage WarehouseLocationSearchStoreHouse(string locationcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select code,name from T_Sec_Loca";
+ var data = DapperHelper.selecttable(sql);
+ if (data.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.Message = "搴撲綅淇℃伅涓嶅瓨鍦�!";
+ mes.data = null;
+ return mes;
+ }
+ sql = @"select A.code as locationcode,A.name as locationname,B.code as warehousecode,B.name as warehousename
+ from T_Sec_Loca A
+ inner join T_Sec_Stck B on A.stock_code=B.code
+ where A.code=@locationcode";
+ dynamicParams.Add("@locationcode", locationcode);
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鍗曚綅淇℃伅鏌ヨ]
+ public static ToMessage UnitSerch()
+ {
+ string sql = "";
+ try
+ {
+ sql = @"select code,name from TUom
+ where is_delete='0'";
+ var data = DapperHelper.selecttable(sql);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璐ㄦ鏂规淇℃伅]
+ public static ToMessage QualityScheme()
+ {
+ string sql = "";
+ try
+ {
+ sql = @"select code,name,sampmethod,sampscare from TStepCheckStandard
+ where status='Y' and checktype='InCheck'";
+ var data = DapperHelper.selecttable(sql);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瀛樿揣鏌ヨ]
+ public static ToMessage InventorySelect(string param)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select * from TMateriel_Info where concat(partcode, partname,partspec) like concat('%',@param,'%');";
+ dynamicParams.Add("@param", param);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[閫氳繃閫夋嫨鐨勬墍灞炵粍缁囨煡璇㈡墍灞炵彮缁刔
+ public static ToMessage StorgGroupSelect(string stu_torgcode, string description)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ switch (description)
+ {
+ case "":
+ break;
+ case "D":
+ search += "and parent.org_code=@stu_torgcode or child.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and parent.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ var sql = @"select group_code,group_name
+ from TGroup G
+ left join TOrganization parent on G.torg_code=parent.org_code
+ left join TOrganization as child on parent.parent_id=child.id
+ where G.is_delete<>'1' " + search;
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[閫氳繃閫夋嫨鐨勬墍灞炵粍缁囨煡璇㈡墍灞炶鑹茬被鍨媇
+ public static ToMessage StorgRoleSelect(string stu_torgcode, string description)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ //鑾峰彇璁惧绫诲瀷鏁版嵁
+ switch (description)
+ {
+ case "":
+ break;
+ case "D":
+ search += "and parent.org_code=@stu_torgcode or child.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and parent.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ var sql = @"select roletype_code,roletype_name,torg_code,parent.org_name
+ from TRoleType R
+ left join TOrganization parent on R.torg_code=parent.org_code
+ left join TOrganization as child on parent.parent_id=child.id
+ where R.is_delete<>'1' " + search;
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[ERP鐢熶骇杞﹂棿/閮ㄩ棬淇℃伅鏌ヨ]
+ public static ToMessage ErpWkshopDepartmentSelect()
+ {
+ string sql = "";
+ try
+ {
+ //瀛樺偍杩囩▼鍚�
+ sql = @"h_p_BASIC_Wkshop_Department";
+ var data = DapperHelper.lissql(sql);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "erp绯荤粺涓湭缁存姢姝や俊鎭�!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[ERP鐢熶粨搴撲俊鎭煡璇
+ public static ToMessage ErpWarehouseSelect()
+ {
+ string sql = "";
+ try
+ {
+ //瀛樺偍杩囩▼鍚�
+ sql = @"h_p_BASIC_Warehouse";
+ var data = DapperHelper.lissql(sql);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "erp绯荤粺涓湭缁存姢姝や俊鎭�!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[ERP鐢熺敤鎴蜂俊鎭煡璇
+ public static ToMessage ErpUserSelect()
+ {
+ string sql = "";
+ try
+ {
+ //瀛樺偍杩囩▼鍚�
+ sql = @"h_p_BASIC_User";
+ var data = DapperHelper.lissql(sql);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "erp绯荤粺涓湭缁存姢姝や俊鎭�!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/DAL/BasicSettingDAL.cs b/VueWebCoreApi/DLL/DAL/BasicSettingDAL.cs
new file mode 100644
index 0000000..0c48ace
--- /dev/null
+++ b/VueWebCoreApi/DLL/DAL/BasicSettingDAL.cs
@@ -0,0 +1,2284 @@
+锘縰sing Dapper;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.BLL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Models.RolePermission;
+using VueWebCoreApi.Tools;
+using static VueWebCoreApi.Models.RolePermission.RolePermission;
+using static VueWebCoreApi.Models.RolePermission.RolePermissionSava;
+
+namespace VueWebCoreApi.DLL.DAL
+{
+ public class BasicSettingDAL
+ {
+ public static DataTable dt; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static bool res; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+ public static string strProcName = ""; //瀹氫箟鍏ㄥ眬sql鍙橀噺
+ public static List<SqlParameter> listStr = new List<SqlParameter>(); //瀹氫箟鍏ㄥ眬鍙傛暟闆嗗悎
+ public static SqlParameter[] parameters; //瀹氫箟鍏ㄥ眬SqlParameter鍙傛暟鏁扮粍
+ public static dynamic CompanyCode = AppSetting.GetAppSetting("CompanyCode");
+ public static dynamic CompanyName = AppSetting.GetAppSetting("CompanyName");
+
+
+
+ #region[寰�鏉ュ崟浣嶆煡璇
+ public static ToMessage CurrentUnitSearch(string cuntUnitCode, string cuntUnitName, string unitAttr, string createUser, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (cuntUnitCode != "" && cuntUnitCode != null)
+ {
+ search += "and A.code like '%'+@cuntUnitCode+'%' ";
+ dynamicParams.Add("@cuntUnitCode", cuntUnitCode);
+ }
+ if (cuntUnitName != "" && cuntUnitName != null)
+ {
+ search += "and A.name like '%'+@cuntUnitName+'%' ";
+ dynamicParams.Add("@cuntUnitName", cuntUnitName);
+ }
+ if (unitAttr != "" && unitAttr != null)
+ {
+ search += "and A.type=@unitAttr ";
+ dynamicParams.Add("@unitAttr", unitAttr);
+ }
+ if (createUser != "" && createUser != null)
+ {
+ search += "and T.username like '%'+@createUser+'%' ";
+ dynamicParams.Add("@createUser", createUser);
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.id,A.code,A.name,A.type,A.conttacts,A.conttphone,A.addr,T.username as lm_user,A.lm_date from TCustomer A
+ left join TUser T on A.lm_user=T.usercode
+ where A.is_delete<>'1' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[寰�鏉ュ崟浣嶆柊澧炵紪杈慮
+ public static ToMessage AddUpdateCurrentUnit(string unitid, string unitcode, string unitname, string typecode, string person, string contact, string description, string usercode, string OperType)
+ {
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (OperType == "Add")
+ {
+ var sql0 = @"select * from TCustomer where code=@unitcode";
+ dynamicParams.Add("@unitcode", unitcode);
+ var data = DapperHelper.selectdata(sql0, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触,缂栫爜閲嶅!";
+ mes.data = null;
+ return mes;
+ }
+ var sql = @"insert into TCustomer(code,name,type,conttacts,conttphone,addr,lm_user,lm_date)
+ values(@unitcode,@unitname,@typecode,@person,@contact,@description,@usercode,@CreateDate)";
+ dynamicParams.Add("@unitcode", unitcode);
+ dynamicParams.Add("@unitname", unitname);
+ dynamicParams.Add("@typecode", typecode);
+ dynamicParams.Add("@person", person);
+ dynamicParams.Add("@contact", contact);
+ dynamicParams.Add("@description", description);
+ dynamicParams.Add("@usercode", usercode);
+ dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (OperType == "Update")
+ {
+ var sql = @"update TCustomer set name=@unitname,type=@typecode,conttacts=@person,conttphone=@contact,addr=@description,lm_user=@usercode,lm_date=@CreateDate where id=@unitid";
+ dynamicParams.Add("@unitid", unitid);
+ dynamicParams.Add("@unitname", unitname);
+ dynamicParams.Add("@typecode", typecode);
+ dynamicParams.Add("@person", person);
+ dynamicParams.Add("@contact", contact);
+ dynamicParams.Add("@description", description);
+ dynamicParams.Add("@usercode", usercode);
+ dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[寰�鏉ュ崟浣嶅垹闄
+ public static ToMessage DeleteCurrentUnit(string unitcode)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ sql = @"select * from TFlw_Rteqp where eqp_code=@unitcode";
+ dynamicParams.Add("@unitcode", unitcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶栧崗渚涙柟宸插叧鑱斿鍗忓伐搴�,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ return mes;
+ }
+ //鍒犻櫎寰�鏉ュ崟浣嶈〃
+ sql = @"delete TCustomer where code=@unitcode";
+ list.Add(new { str = sql, parm = new { unitcode = unitcode } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[瀹夌伅绯荤粺/杞﹂棿鏌ヨ]
+ public static ToMessage AnDengShopSearch(string stu_torgcode, string description)
+ {
+ string sql = "";
+ string search = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鑾峰彇杞﹂棿淇℃伅
+ switch (description)
+ {
+ case "":
+ break;
+ case "D":
+ search += "and child.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and parent.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ sql = @"select parent.org_code,parent.org_name
+ from TOrganization parent
+ left join TOrganization as child on parent.parent_id=child.id
+ where parent.is_delete<>'1' " + search;
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鑷畾涔夊畨鐏懠鍙被鍨嬫煡璇
+ public static ToMessage AnDengTypeSearch()
+ {
+ try
+ {
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select id, code,name
+ from TAnDonType
+ where is_delete<>'1' ";
+ var data = DapperHelper.selecttable(sql);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鑷畾涔夊畨鐏懠鍙被鍨嬫柊澧瀅
+ public static ToMessage AddUpdateAnDengType(List<ObjectData> json, string username)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ //寰幆鍐欏叆鍛煎彨绫诲瀷琛�
+ for (int i = 0; i < json.Count; i++)
+ {
+ sql = @"insert into TAnDonType(code,name,lm_user,lm_date) values(@code,@name,@username,@createdate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ code = json[i].code,
+ name = json[i].name,
+ username = username,
+ createdate = DateTime.Now.ToString()
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鑷畾涔夊畨鐏懠鍙被鍨嬪垹闄
+ public static ToMessage DeleteAnDengType(string andengtypecode)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ //鍒ゆ柇鍛煎彨绫诲瀷涓嬫槸鍚﹀叧鑱�
+ sql = @"select * from TAnDon_Roul_ConFig where andotype_code=@andengtypecode and is_delete<>'1'";
+ dynamicParams.Add("@andengtypecode", andengtypecode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鍛煎彨绫诲瀷宸插叧鑱斿懠鍙厤缃�,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ }
+ else
+ {
+ sql = @"delete TAnDonType where code=@andengtypecode";
+ list.Add(new { str = sql, parm = new { andengtypecode = andengtypecode } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鏌ヨ缁戝畾鐨勫搷搴斾汉鍛榏
+ public static ToMessage AnDengResponUserSearch(string wkshopcode, string calltypecode)
+ {
+ var sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select B.id,B.ando_cogfigid,U.usercode,U.username,A.enable from TAnDon_Roul_ConFig A
+ inner join TAnDon_Roul_ConFigUser B on A.id=B.ando_cogfigid
+ left join TUser U on B.usercode=U.usercode
+ where A.wkshp_code=@wkshopcode and A.andotype_code=@calltypecode and U.is_delete=0";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ dynamicParams.Add("@calltypecode", calltypecode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鏂板鍝嶅簲浜哄憳鏌ヨ宸茬粦瀹氱殑鍝嶅簲浜哄憳]
+ public static ToMessage AnDengDialogResponUserSearch(string wkshopcode, string calltypecode)
+ {
+ var sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select A.usercode,A.username,(case when B.usercode<>'' then 'Y' else 'N' end) as flag
+ from TUser A
+ left join (
+ select B.usercode from TAnDon_Roul_ConFig A
+ inner join TAnDon_Roul_ConFigUser B on A.id=B.ando_cogfigid
+ where A.wkshp_code=@wkshopcode and A.andotype_code=@calltypecode
+ ) B on A.usercode=B.usercode
+ where A.userclassid='0'";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ dynamicParams.Add("@calltypecode", calltypecode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏆傛棤鍝嶅簲浜哄憳!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鏂板鍝嶅簲浜哄憳鎻愪氦]
+ public static ToMessage AnDengDigoResponUserSeave(string wkshopcode, string calltypecode, string enable, string usercode, DataTable json)
+ {
+ var sql = "";
+ int mid = 0;
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ //鍒ゆ柇鍛煎彨绫诲瀷涓嬫槸鍚﹀叧鑱�
+ sql = @"select isnull(id,0) id from TAnDon_Roul_ConFig where wkshp_code=@wkshopcode and andotype_code=@calltypecode and is_delete<>'1'";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ dynamicParams.Add("@calltypecode", calltypecode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mid = Convert.ToInt32(data.Rows[0]["ID"].ToString());
+ //娓呴櫎瀹夌伅銆佽澶囦换鍔¢厤缃叧鑱斾汉鍛樿〃鏁版嵁
+ sql = @"delete TAnDon_Roul_ConFigUser where ando_cogfigid=@mid";
+ list.Add(new { str = sql, parm = new { mid = mid } });
+ }
+ else
+ {
+ //鑾峰彇涓昏〃鏈�澶D
+ sql = @"select ISNULL(IDENT_CURRENT('TAnDon_Roul_ConFig')+1,1) as id";
+ var dt = DapperHelper.selecttable(sql);
+ mid = Convert.ToInt32(dt.Rows[0]["ID"].ToString());
+ //鍐欏叆瀹夌伅銆佽澶囦换鍔¢厤缃〃鏁版嵁
+ sql = @"insert into TAnDon_Roul_ConFig(wkshp_code,andotype_code,lm_user,lm_date,enable) values(@wkshp_code,@andotype_code,@lm_user,@lm_date,@enable)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ wkshp_code = wkshopcode,
+ andotype_code = calltypecode,
+ lm_user = usercode,
+ lm_date = DateTime.Now.ToString(),
+ enable = enable
+ }
+ });
+ }
+ //寰幆鍐欏叆瀹夌伅銆佽澶囦换鍔¢厤缃叧鑱斾汉鍛樿〃
+ for (int i = 0; i < json.Rows.Count; i++)
+ {
+ sql = @"insert into TAnDon_Roul_ConFigUser(ando_cogfigid,usercode) values(@ando_cogfigid,@role_code)";
+ list.Add(new { str = sql, parm = new { ando_cogfigid = mid, role_code = json.Rows[i]["CODE"].ToString() } });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鍝嶅簲浜哄憳鍏佽鍏抽棴]
+ public static ToMessage AnDengResponUserCloseSeave(string wkshopcode, string calltypecode, string enable, string usercode)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ try
+ {
+ list.Clear();
+ //鏇存柊瀹夌伅銆佽澶囦换鍔¢厤缃〃鐘舵��
+ sql = @"update TAnDon_Roul_ConFig set enable=@enable,lm_user=@lm_user,lm_date=@lm_date where wkshp_code=@wkshp_code and andotype_code=@andengtypecode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ wkshp_code = wkshopcode,
+ andengtypecode = calltypecode,
+ lm_user = usercode,
+ lm_date = DateTime.Now.ToString(),
+ enable = enable
+ }
+ });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瀹夌伅绯荤粺/鍝嶅簲浜哄憳鍒犻櫎]
+ public static ToMessage AnDengResponUserDeleteSeave(string id, string ando_cogfigid)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ //鏌ヨ瀹夌伅銆佽澶囦换鍔¢厤缃〃
+ sql = @"select id from TAnDon_Roul_ConFigUser where ando_cogfigid=@ando_cogfigid";
+ dynamicParams.Add("@ando_cogfigid", ando_cogfigid);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 1)
+ {
+ //鏍规嵁瀛愯〃id鍒犻櫎瀵瑰簲瀛愯〃浜哄憳
+ sql = @"delete TAnDon_Roul_ConFigUser where id=@id";
+ list.Add(new { str = sql, parm = new { id = id } });
+ }
+ else
+ {
+ //鏍规嵁瀛愯〃id鍒犻櫎瀵瑰簲瀛愯〃浜哄憳
+ sql = @"delete TAnDon_Roul_ConFigUser where id=@id";
+ list.Add(new { str = sql, parm = new { id = id } });
+ //鏍规嵁涓昏〃id鍒犻櫎涓昏〃鏁版嵁
+ sql = @"delete TAnDon_Roul_ConFig where id=@id";
+ list.Add(new { str = sql, parm = new { id = ando_cogfigid } });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[閫氳繃杞﹂棿缂栫爜鏌ユ壘璁惧淇℃伅]
+ public static ToMessage WhkspIsEqpSearch(string wkshpcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鑾峰彇璁惧涓嬫媺妗嗘暟鎹�
+ sql = @"select code as eqp_code,name as eqp_name
+ from TEqpInfo where wksp_code=@wkshpcode and enable='Y' ";
+ dynamicParams.Add("@wkshpcode", wkshpcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+
+ #region[缁勭粐鏋舵瀯,鏌ヨ缁勭粐淇℃伅]
+ public static ToMessage STorgData(string storg_code, string storg_name, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (storg_code != "" && storg_code != null)
+ {
+ search += "and T.torg_code like '%'+@storg_code+'%' ";
+ dynamicParams.Add("@storg_code", storg_code);
+ }
+ if (storg_name != "" && storg_name != null)
+ {
+ search += "and T.torg_name like '%'+@storg_name+'%' ";
+ dynamicParams.Add("@storg_name", storg_name);
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select T.id,T.parent_id,T.torg_code,T.torg_name,T.status,T.leve,T.torg_seq,
+ T.lm_user as usercode,U.username,T.lm_date
+ from TOrganization T
+ left join TUser U on T.lm_user=U.usercode
+ where 1=1" + search + "";
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鏂板缂栬緫缁勭粐鏋舵瀯]
+ public static ToMessage AddUpdateOrganization(string OrganCode, string OrganName, string leve, string parent_id, string storgcode, string torg_seq, string status, string OperType, User us)
+ {
+ string sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (OperType == "Add")
+ {
+ sql = @"select * from TOrganization where torg_code=@organCode";
+ dynamicParams.Add("@organCode", OrganCode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触,缂栫爜閲嶅!";
+ mes.data = null;
+ return mes;
+ }
+
+ sql = @"insert into TOrganization(parent_id,torg_code,torg_name,status,leve,torg_seq,lm_user,lm_date)
+ values(@parent_id,@torg_code,@torg_name,@status,@leve,@torg_seq,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ parent_id = storgcode,
+ torg_code = OrganCode,
+ torg_name = OrganName,
+ status = status,
+ leve = leve,
+ torg_seq = torg_seq,
+ lm_user = us.usercode,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鏂板", "鏂板浜嗙粍缁�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (OperType == "Update")
+ {
+ //鍒ゆ柇鎵�灞炵粍缁囨槸鍚︽湁鍙樻洿
+ if (parent_id != storgcode)
+ {
+ //鍒ゆ柇鏂伴�夋嫨鐨勭粍缁囨槸鍚﹁寮曠敤
+ sql = @"select * from TUser where storg_code=@storgcode and status='Y'";
+ dynamicParams.Add("@storgcode", storgcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂伴�夋嫨鐨勬墍灞炵粍缁囧凡浣跨敤涓嶅厑璁镐慨鏀�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ //鍒ゆ柇鍘熸湁缁勭粐鍙婂瓙绾ф槸鍚﹁寮曠敤
+ sql = @"with CTE as (
+ select torg_code
+ from TOrganization
+ where torg_code =@OrganCode
+ union all
+ select t.torg_code
+ from TOrganization AS t
+ inner join CTE AS c ON t.parent_id = c.torg_code
+ )
+ select * from TUser
+ where storg_code in (select torg_code from CTE)";
+ dynamicParams.Add("@OrganCode", OrganCode);
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data1.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鍘熸湁缁勭粐鎴栧瓙绾ц浣跨敤涓嶅厑璁镐慨鏀�!";
+ mes.data = null;
+ return mes;
+ }
+
+ //淇敼褰撳墠缁勭粐鏁版嵁
+ sql = @"update TOrganization set parent_id=@parent_id,torg_name=@torg_name,leve=@leve,torg_seq=@torg_seq,lm_user=@lm_user,lm_date=@lm_date
+ where torg_code=@torg_code";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ parent_id = storgcode,
+ torg_code = OrganCode,
+ torg_name = OrganName,
+ leve = leve,
+ torg_seq = torg_seq,
+ lm_user = us.usercode,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+ //閫掑綊鏇存柊鐘舵��,褰撳墠閫変腑鏁版嵁鍙婂瓙绾�
+ sql = @"with CTE as (
+ select torg_code
+ from TOrganization
+ where torg_code =@OrganCode
+ union all
+ select t.torg_code
+ from TOrganization AS t
+ inner join CTE AS c ON t.parent_id = c.torg_code
+ )
+ update TOrganization set status=@status
+ where torg_code in (select torg_code from CTE)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ OrganCode = OrganCode,
+ status = status
+ }
+ });
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "淇敼", "淇敼浜嗙粍缁�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region [缁勭粐鏋舵瀯鍒犻櫎]
+ public static ToMessage DeleteOrganization(string orgcode, User us)
+ {
+ var sql = "";
+ var cont = 0;
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select * from TOrganization where parent_id=@orgcode";
+ dynamicParams.Add(@"orgcode", orgcode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.Message = "褰撳墠缁勭粐鏈変笅绾у叧鑱�,璇峰厛鍒犻櫎涓嬬骇缁勭粐!";
+ return mes;
+ }
+ sql = @"select * from TUser where storg_code=@orgcode";
+ dynamicParams.Add("@orgcode", orgcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇ョ粍缁囦笅鏈夊叧鑱旂殑鐢ㄦ埛,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ return mes;
+ }
+ sql = @"delete TOrganization where torg_code=@orgcode";
+ dynamicParams.Add(@"orgcode", orgcode);
+ cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鏂板", "鍒犻櫎浜嗙粍缁�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[宀椾綅淇℃伅鍒楄〃鏌ヨ]
+ public static ToMessage PostData(string postcode, string postname, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (postcode != "" && postcode != null)
+ {
+ search += "and P.postcode like '%'+@postcode+'%' ";
+ dynamicParams.Add("@postcode", postcode);
+ }
+ if (postname != "" && postname != null)
+ {
+ search += "and P.postname like '%'+@postname+'%' ";
+ dynamicParams.Add("@postname", postname);
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select P.id,P.postcode,P.postname,P.status,P.description,
+ P.lm_user as usercode,U.username,P.lm_date
+ from TPost P
+ left join TUser U on P.lm_user=U.usercode
+ where 1=1 " + search + "";
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[宀椾綅鏂板缂栬緫]
+ public static ToMessage AddUpdatePost(string postcode, string postname, string description, string status, string OperType, User us)
+ {
+ string sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (OperType == "Add")
+ {
+ sql = @"select * from TPost where postcode=@postcode";
+ dynamicParams.Add("@postcode", postcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触,缂栫爜閲嶅!";
+ mes.data = null;
+ return mes;
+ }
+
+ sql = @"insert into TPost(postcode,postname,status,description,lm_user,lm_date)
+ values(@postcode,@postname,@status,@description,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ postcode = postcode,
+ postname = postname,
+ status = status,
+ description = description,
+ lm_user = us.usercode,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鏂板", "鏂板浜嗗矖浣�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (OperType == "Update")
+ {
+ if (status == "N")
+ {
+ //褰撳矖浣嶇姸鎬佷负鍋滅敤鏃�,鍒ゆ柇褰撳墠宀椾綅鏄惁琚敤鎴峰紩鐢�
+ sql = @"select * from TUser where ',' + post_code + ',' like '%,'+@postcode+',%'";
+ dynamicParams.Add("@postcode", postcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇ュ矖浣嶆湁鍏宠仈鐨勭敤鎴�,涓嶅厑璁稿仠鐢�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ sql = @"update TPost set postname=@postname,status=@status,description=@description,lm_user=@lm_user,lm_date=@lm_date
+ where postcode=@postcode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ postcode = postcode,
+ postname = postname,
+ status = status,
+ description = description,
+ lm_user = us.usercode,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "淇敼", "淇敼浜嗗矖浣�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[宀椾綅鍒犻櫎鍒犻櫎]
+ public static ToMessage DeletePost(string postcode, User us)
+ {
+ var sql = "";
+ var cont = 0;
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select * from TUser where ',' + post_code + ',' like '%,'+@postcode+',%'";
+ dynamicParams.Add("@postcode", postcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇ュ矖浣嶆湁鍏宠仈鐨勭敤鎴�,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ return mes;
+ }
+ sql = @"delete TPost where postcode=@postcode";
+ dynamicParams.Add(@"postcode", postcode);
+ cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鍒犻櫎", "鍒犻櫎浜嗗矖浣�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[鐢ㄦ埛淇℃伅鍒楄〃鏌ヨ]
+ public static ToMessage UserData(string storgcode, string usercode, string username, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search0 = "";
+ string search = "";
+ try
+ {
+ if (storgcode != "" && storgcode != null)
+ {
+ search0 += "and torg_code=@storgcode ";
+ dynamicParams.Add("@storgcode", storgcode);
+ }
+ if (usercode != "" && usercode != null)
+ {
+ search += "and U.usercode like '%'+@usercode+'%' ";
+ dynamicParams.Add("@usercode", usercode);
+ }
+ if (username != "" && username != null)
+ {
+ search += "and U.username like '%'+@username+'%' ";
+ dynamicParams.Add("@username", username);
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var withsql = @"with cte as (
+ select torg_code, torg_name, parent_id
+ from TOrganization
+ where status='Y' " + search0 + " union all select T.torg_code, T.torg_name, T.parent_id from TOrganization T inner join CTE ON T.parent_id = CTE.torg_code)";
+ var sql = @"SELECT distinct U.usercode,U.username,U.password,U.mobile,U.email,U.status,U.storg_code as storg_code,T.torg_name as storg_name,T.parent_id,
+ U.role_code,
+ STUFF((SELECT ',' + R.rolename
+ FROM TRole R
+ WHERE CHARINDEX(',' + R.rolecode + ',', ',' + U.role_code + ',') > 0
+ FOR XML PATH('')), 1, 1, '') AS rolename,
+ U.post_code,
+ STUFF((SELECT ',' + P.postname
+ FROM TPost P
+ WHERE CHARINDEX(',' + P.postcode + ',', ',' + U.post_code + ',') > 0
+ FOR XML PATH('')), 1, 1, '') AS postname,
+ U.group_code,
+ STUFF((SELECT ',' + P.usergroupname
+ FROM TGroup P
+ WHERE CHARINDEX(',' + P.usergroupcode + ',', ',' + U.group_code + ',') > 0
+ FOR XML PATH('')), 1, 1, '') AS group_name,
+ U.lm_user as createusercode,S.username as createusername,U.lm_date
+ FROM TUser U
+ inner join cte on U.storg_code=cte.torg_code
+ left join TOrganization T on U.storg_code=T.torg_code
+ left join TUser S on U.lm_user=S.usercode " + search + "";
+ var data = DapperHelper.GetPagedDataWith<object>(withsql, sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢ㄦ埛淇℃伅鏂板缂栬緫]
+ public static ToMessage AddUpdateUserSave(string usercode, string username, string password, string mobile, string email, string storg_code, string status, string post_code, string role_code, string group_code, string opertype, User us)
+ {
+ string sql = "";
+ List<object> list = new List<object>();
+ //string result = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鏌ヨ鎵�鏈夌殑缁勭粐鏁版嵁
+ //sql = @"select * from TOrganization where status='Y'";
+ //var dattorg = DapperHelper.selecttable(sql);
+
+ //鏍规嵁鏂板鐢ㄦ埛鍏宠仈鐨勮鑹叉煡鎵捐鑹茶〃瀵瑰簲鐨勬暟鎹寖鍥�
+ //string[] rolecode = Array.ConvertAll<string, string>(role_code.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString()); //string鍒嗗壊杞瑂tring[]
+ //sql = @"select R.datarange,T.dataname,R.datapermissions from TRole R
+ // inner join TData T on R.datarange=T.datacode
+ // where R.rolecode in @rolecode and R.status='Y'";
+ //dynamicParams.Add("@rolecode", rolecode);
+ //var data0 = DapperHelper.selectlist(sql, dynamicParams);
+ //浣跨敤LINQ鍘婚噸,鍚堝苟鏁版嵁鑼冨洿
+ //DataTable dtResult = data0.AsEnumerable().Distinct(DataRowComparer.Default).CopyToDataTable();
+
+ //for (int i = 0; i < dtResult.Rows.Count; i++)
+ //{
+ // switch (dtResult.Rows[i]["dataname"].ToString())
+ // {
+ // case "鍏ㄩ儴":
+ // //鏌ヨ鎵�鏈夌粍缁囩紪鐮�
+ // // 浣跨敤lambda琛ㄨ揪寮忔煡璇ame瀛楁锛屽苟閫氳繃閫楀彿闅斿紑
+ // string all = string.Join(",", dattorg.AsEnumerable().Select(row => row.Field<string>("torg_code")));
+ // result += all + ",";
+ // break;
+ // //鏌ヨ鏈儴闂ㄧ粍缁囩紪鐮�
+ // case "鏈骇":
+ // // 浣跨敤閫掑綊鍜� lambda 琛ㄨ揪寮忔煡璇㈡寚瀹� id 鐨勭埗绾х紪鐮�,leve=1 浠h〃閮ㄩ棬
+ // string leve = storg_code;
+ // result += leve + ",";
+ // break;
+ // //鏈汉缂栫爜
+ // case "鏈汉":
+ // result += usercode + ",";
+ // break;
+ // //鏌ヨ鑷畾涔夌殑缁勭粐缂栫爜
+ // case "鑷畾涔�":
+ // result += dtResult.Rows[i]["datapermissions"].ToString() + ",";
+ // break;
+ // default:
+ // break;
+ // }
+ //}
+ //// 绉婚櫎鏈�鍚庝竴涓�楀彿
+ //result = result.TrimEnd(',');
+ ////鍘婚櫎閲嶅鍊�
+ //result = string.Join(",", result.Split(',').Distinct().ToArray());
+
+ if (opertype == "Add")
+ {
+ //鏌ヨ鏂板鐢ㄦ埛缂栫爜鏄惁閲嶅
+ sql = @"select * from TUser where usercode=@usercode";
+ dynamicParams.Add("@usercode", usercode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触,缂栫爜閲嶅!";
+ mes.data = null;
+ return mes;
+ }
+ sql = @"insert into TUser(usercode,username,password,mobile,email,status,storg_code,role_code,role_datapermissions,post_code,group_code,is_system_admin,lm_user,lm_date)
+ values(@usercode,@username,@password,@mobile,@email,@status,@storg_code,@role_code,@role_datapermissions,@post_code,@group_code,@is_system_admin,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ usercode = usercode,
+ username = username,
+ password = password,
+ mobile = mobile,
+ email = email,
+ status = status,
+ storg_code = storg_code,
+ role_code = role_code,
+ role_datapermissions = "",
+ post_code = post_code,
+ group_code = group_code,
+ is_system_admin = "N",
+ lm_user = us.usercode,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鏂板", "鏂板浜嗙敤鎴�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (opertype == "Update")
+ {
+
+ sql = @"update TUser set username=@username,password=@password,mobile=@mobile,email=@email,status=@status,storg_code=@storg_code,
+ role_code=@role_code,role_datapermissions=@role_datapermissions,post_code=@post_code,group_code=@group_code,lm_user=@lm_user,lm_date=@lm_date
+ where usercode=@usercode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ usercode = usercode,
+ username = username,
+ password = password,
+ mobile = mobile,
+ email = email,
+ status = status,
+ storg_code = storg_code,
+ role_code = role_code,
+ role_datapermissions = "",
+ post_code = post_code,
+ group_code = group_code,
+ lm_user = us.usercode,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "淇敼", "淇敼浜嗙敤鎴�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢ㄦ埛淇℃伅鍒犻櫎]
+ public static ToMessage DeleteUserSave(string usercode, User us)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鍒ゆ柇褰撳墠鐢ㄦ埛鏄惁鏈夋姤宸ヨ褰�
+
+ sql = @"delete TUser where usercode=@usercode";
+ list.Add(new { str = sql, parm = new { usercode = usercode } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鍒犻櫎", "鍒犻櫎浜嗙敤鎴�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鐢ㄦ埛鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鐢ㄦ埛澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[鐝粍淇℃伅鍒楄〃鏌ヨ]
+ public static ToMessage GroupData(string groupcode, string groupname, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (groupcode != "" && groupcode != null)
+ {
+ search += "and G.usergroupcode like '%'+@groupcode+'%' ";
+ dynamicParams.Add("@groupcode", groupcode);
+ }
+ if (groupname != "" && groupname != null)
+ {
+ search += "and G.usergroupname like '%'+@groupname+'%' ";
+ dynamicParams.Add("@groupname", groupname);
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select G.usergroupcode,G.usergroupname,G.status,G.description,
+ G.lm_user as usercode,U.username,G.lm_date
+ from TGroup G
+ left join TUser U on G.lm_user=U.usercode
+ where 1=1 " + search + "";
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐝粍鏂板缂栬緫]
+ public static ToMessage AddUpdateGroup(string groupcode, string groupname, string description, string status, string OperType, User us)
+ {
+ string sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (OperType == "Add")
+ {
+ sql = @"select * from TGroup where usergroupcode=@groupcode";
+ dynamicParams.Add("@groupcode", groupcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触,缂栫爜閲嶅!";
+ mes.data = null;
+ return mes;
+ }
+
+ sql = @"insert into TGroup(usergroupcode,usergroupname,status,description,lm_user,lm_date)
+ values(@usergroupcode,@usergroupname,@status,@description,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ usergroupcode = groupcode,
+ usergroupname = groupname,
+ status = status,
+ description = description,
+ lm_user = us.usercode,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鏂板", "鏂板浜嗙彮缁�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (OperType == "Update")
+ {
+ if (status == "N")
+ {
+ //褰撶彮缁勭姸鎬佷负鍋滅敤鏃�,鍒ゆ柇褰撳墠鐝粍鏄惁琚敤鎴峰紩鐢�
+ sql = @"select * from TUser where ',' + group_code + ',' like '%,'+@groupcode+',%'";
+ dynamicParams.Add("@groupcode", groupcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇ョ彮缁勬湁鍏宠仈鐨勭敤鎴�,涓嶅厑璁稿仠鐢�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ sql = @"update TGroup set usergroupname=@usergroupname,status=@status,description=@description,lm_user=@lm_user,lm_date=@lm_date
+ where usergroupcode=@usergroupcode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ usergroupcode = groupcode,
+ usergroupname = groupname,
+ status = status,
+ description = description,
+ lm_user = us.usercode,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "淇敼", "淇敼浜嗙彮缁�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐝粍鍒犻櫎]
+ public static ToMessage DeleteGroup(string groupcode, User us)
+ {
+ var sql = "";
+ var cont = 0;
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select * from TUser where ',' + group_code + ',' like '%,'+@groupcode+',%'";
+ dynamicParams.Add("@groupcode", groupcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇ョ彮缁勬湁鍏宠仈鐨勭敤鎴�,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ return mes;
+ }
+ sql = @"delete TGroup where usergroupcode=@groupcode";
+ dynamicParams.Add(@"groupcode", groupcode);
+ cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鍒犻櫎", "鍒犻櫎浜嗙彮缁�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[瑙掕壊绠$悊鍒楄〃鏌ヨ]
+ public static ToMessage RoleData(string role_code, string role_name, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (role_code != "" && role_code != null)
+ {
+ search += "and R.rolecode like '%'+@role_code+'%' ";
+ dynamicParams.Add("@role_code", role_code);
+ }
+ if (role_name != "" && role_name != null)
+ {
+ search += "and R.rolename like '%'+@role_name+'%' ";
+ dynamicParams.Add("@role_name", role_name);
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select R.rolecode,R.rolename,R.status,R.datarange as datacode,TB.dataname,
+ R.datapermissions as datapermissionscode,R.description,
+ STUFF((SELECT ',' + P.torg_name
+ FROM TOrganization P
+ WHERE CHARINDEX(',' + P.torg_code+ ',', ',' + R.datapermissions + ',') > 0
+ FOR XML PATH('')), 1, 1, '') AS datapermissionsname,
+ R.lm_user as usercode,U.username,R.lm_date
+ from TRole R
+ left join TData TB on R.datarange=TB.datacode
+ left join TUser U on R.lm_user=U.usercode
+ where 1=1 " + search + "";
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瑙掕壊绠$悊鏂板銆佺紪杈戜繚瀛榏
+ public static ToMessage RoleAddUpdateSava(string menucode, string rolecode, string rolename, string status, string datacode, string datapermissions, string description, string OperType, User us)
+ {
+ var dynamicParams = new DynamicParameters();
+ List<object> list = new List<object>();
+ string sql = "";
+ string updatedJson = "";
+ try
+ {
+ list.Clear();
+ if (OperType == "Add")
+ {
+ //鑾峰彇瑙掕壊缂栫爜
+ mes = SeachEncodeJob.EncodingSeach(menucode);
+ if (mes.code == "300")
+ {
+ return mes;
+ }
+ //鏌ヨ瑙掕壊鍚嶇О鏄惁瀛樺湪
+ sql = @"select * from TRole where rolename=@rolename";
+ dynamicParams.Add("@rolename", rolename);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.Message = "鍚屽悕瑙掕壊宸插瓨鍦�!";
+ mes.data = null;
+ return mes;
+ }
+ //鍐欏叆瑙掕壊琛�
+ sql = @"insert into TRole(rolecode,rolename,status,datarange,datapermissions,identifying,description,lm_user,lm_date)
+ values(@rolecode,@rolename,@status,@datarange,@datapermissions,@identifying,@description,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ rolecode = ((List<string>)mes.data)[0].ToString(),
+ rolename = rolename,
+ status = status,
+ datarange = datacode,
+ datapermissions = datapermissions,
+ identifying = "2", //0(绠$悊鍛�) 1(鎵�鏈変汉) 2(鍏跺畠)
+ description = description,
+ lm_user = us.usercode,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+ //鍥炲啓缂栫爜瑙勫垯琛�
+ list.AddRange(SeachEncodeJob.StrEncodingUpdate(menucode, ((List<string>)mes.data)[1].ToString()));
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鏂板", "鏂板浜嗚鑹�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (OperType == "Update")
+ {
+ if (status == "N")
+ {
+ //褰撹鑹茬姸鎬佷负鍋滅敤鏃�,鍒ゆ柇褰撳墠瑙掕壊鏄惁琚敤鎴峰紩鐢�
+ sql = @"select * from TUser where ',' + role_code + ',' like '%,'+@rolecode+',%'";
+ dynamicParams.Add("@rolecode", rolecode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇ヨ鑹叉湁鍏宠仈鐨勭敤鎴�,涓嶅厑璁稿仠鐢�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ //閫氳繃瑙掕壊缂栫爜鏌ヨ瑙掕壊鏁版嵁鍏宠仈琛�
+ sql = @"select * from TAuthority where rolecode=@rolecode";
+ dynamicParams.Add("@rolecode", rolecode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ JArray jsonArray = JArray.Parse(data.Rows[0]["jsondate"].ToString());
+ jsonArray.Select(j => {
+ JObject jsonObject = (JObject)j;
+ if (datacode == "CUSTOM")
+ {
+ jsonObject["datacode"] = datapermissions;
+ }
+ else
+ {
+ jsonObject["datacode"] = datacode;
+ }
+ return j;
+ }).ToList();
+ updatedJson = JsonConvert.SerializeObject(jsonArray);
+ //鏇存柊瑙掕壊鏁版嵁琛�
+ sql = @"update TAuthority set jsondate=@jsondate,type=@type
+ where rolecode=@rolecode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ rolecode = rolecode,
+ jsondate = updatedJson,
+ type = us.usertype
+ }
+ });
+ }
+ //淇敼瑙掕壊琛�
+ sql = @"update TRole set rolename=@rolename,status=@status,datarange=@datarange,
+ datapermissions=@datapermissions,description=@description,lm_user=@lm_user,lm_date=@lm_date
+ where rolecode=@rolecode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ rolecode = rolecode,
+ rolename = rolename,
+ status = status,
+ datarange = datacode,
+ datapermissions = datapermissions,
+ description = description,
+ lm_user = us.usercode,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "淇敼", "淇敼浜嗚鑹插悕绉�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瑙掕壊绠$悊鍒犻櫎]
+ public static ToMessage RoleDeleteSava(string rolecode, User us)
+ {
+ var dynamicParams = new DynamicParameters();
+ List<object> list = new List<object>();
+ string sql = "";
+ try
+ {
+ list.Clear();
+ //鍒ゆ柇褰撳墠瑙掕壊鏄惁鍏宠仈鐢ㄦ埛
+ sql = @"select * from TUser where ',' + role_code + ',' like '%,'+@rolecode+',%'";
+ dynamicParams.Add("@rolecode", rolecode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇ヨ鑹叉湁鍏宠仈鐨勭敤鎴�,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ return mes;
+ }
+ //鍒犻櫎瑙掕壊鏁版嵁鍏宠仈琛� TAuthority
+ sql = @"delete TAuthority where rolecode=@rolecode";
+ list.Add(new { str = sql, parm = new { rolecode = rolecode } });
+ //鍒犻櫎瑙掕壊琛�
+ sql = @"delete TRole where rolecode=@rolecode and identifying='2'";
+ list.Add(new { str = sql, parm = new { rolecode = rolecode } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鍒犻櫎", "鍒犻櫎浜嗚鑹�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[瑙掕壊绠$悊鍒嗛厤鐢ㄦ埛,鑾峰彇宸插垎閰嶇敤鎴峰垪琛╙
+ public static ToMessage RoleAssignedUserData(string flag, string role_code, string usercode, string username, string storg_code, string post_code, string group_code, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ switch (flag)
+ {
+ case "TRUE":
+ if (role_code != "" && role_code != null)
+ {
+ search += "and ',' + U.role_code + ',' like '%,'+@role_code+',%' ";
+ dynamicParams.Add("@role_code", role_code);
+ }
+ break;
+ case "FALSE":
+ if (role_code != "" && role_code != null)
+ {
+ search += "and ',' + U.role_code + ',' not like '%,'+@role_code+',%' ";
+ dynamicParams.Add("@role_code", role_code);
+ }
+ break;
+ }
+
+ if (usercode != "" && usercode != null)
+ {
+ search += "and U.usercode like '%'+@usercode+'%' ";
+ dynamicParams.Add("@usercode", usercode);
+ }
+ if (username != "" && username != null)
+ {
+ search += "and U.username like '%'+@username+'%' ";
+ dynamicParams.Add("@username", username);
+ }
+ if (storg_code != "" && storg_code != null)
+ {
+ search += "and U.storg_code=@storg_code ";
+ dynamicParams.Add("@storg_code", storg_code);
+ }
+ if (post_code != "" && post_code != null)
+ {
+ search += "and ',' + U.post_code + ',' like '%,'+@post_code+',%' ";
+ dynamicParams.Add("@post_code", post_code);
+ }
+ if (group_code != "" && group_code != null)
+ {
+ search += "and ',' + U.group_code + ',' like '%,'+@group_code+',%' ";
+ dynamicParams.Add("@group_code", group_code);
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"SELECT distinct U.usercode,U.username,U.password,U.mobile,U.email,U.status,U.storg_code as storg_code,T.torg_name as storg_name,T.parent_id,
+ U.role_code,
+ STUFF((SELECT ',' + R.rolename
+ FROM TRole R
+ WHERE CHARINDEX(',' + R.rolecode + ',', ',' + U.role_code + ',') > 0
+ FOR XML PATH('')), 1, 1, '') AS rolename,
+ U.post_code,
+ STUFF((SELECT ',' + P.postname
+ FROM TPost P
+ WHERE CHARINDEX(',' + P.postcode + ',', ',' + U.post_code + ',') > 0
+ FOR XML PATH('')), 1, 1, '') AS postname,
+ U.group_code,
+ STUFF((SELECT ',' + P.usergroupname
+ FROM TGroup P
+ WHERE CHARINDEX(',' + P.usergroupcode + ',', ',' + U.group_code + ',') > 0
+ FOR XML PATH('')), 1, 1, '') AS group_name,
+ U.lm_user as createusercode,S.username as createusername,U.lm_date
+ FROM TUser U
+ left join TOrganization T on U.storg_code=T.torg_code
+ left join TUser S on U.lm_user=S.usercode
+ where 1=1 and U.status='Y' and U.role_code<>'' " + search + "";
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瑙掕壊绠$悊鍒嗛厤鐢ㄦ埛,鎵归噺鍙栨秷宸插垎閰嶇殑鐢ㄦ埛]
+ public static ToMessage RoleAssignedUserBatchCancel(string role_code, string[] user, User us)
+ {
+ List<object> list = new List<object>();
+ string sql = "";
+ try
+ {
+ list.Clear();
+ //鎵归噺鏇存柊鐢ㄦ埛琛ㄤ腑鍏宠仈鐨勮鑹�(鑷畾涔夊嚱鏁癟SplitString鏉ユ媶鍒嗗瓧绗︿覆)
+ sql = @"update TUser
+ set role_code = stuff(
+ (
+ select ',' + value
+ from dbo.TSplitString(role_code, ',')
+ where value <> @role_code
+ for XML PATH('')
+ ), 1, 1, ''
+ )
+ where usercode in @usercode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ role_code = role_code,
+ usercode = user
+ }
+ });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鍙栨秷", "鍙栨秷浜嗚鑹插叧鑱旂殑鐢ㄦ埛", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶辫触!";
+ mes.data = null;
+ }
+
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瑙掕壊绠$悊鍒嗛厤鐢ㄦ埛,鎵归噺娣诲姞鏈垎閰嶇殑鐢ㄦ埛]
+ public static ToMessage RoleAssignedUserBatchAdd(string role_code, string[] user, User us)
+ {
+ List<object> list = new List<object>();
+ string sql = "";
+ try
+ {
+ list.Clear();
+ //鎵归噺鏇存柊鐢ㄦ埛琛ㄤ腑鍏宠仈鐨勮鑹�
+ sql = @"update TUser
+ set role_code = case
+ when role_code IS NULL OR role_code = '' then @role_code
+ else role_code + ',' + @role_code
+ end
+ where usercode in @usercode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ role_code = role_code,
+ usercode = user
+ }
+ });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "娣诲姞", "娣诲姞浜嗚鑹插叧鑱旂殑鐢ㄦ埛", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶辫触!";
+ mes.data = null;
+ }
+
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[瑙掕壊鏉冮檺鏌ヨ瑙掕壊]
+ public static ToMessage RolePermissionSearchRole()
+ {
+ List<TRole> list = new List<TRole>();
+ var dynamicParams = new DynamicParameters();
+ string sql = "";
+ try
+ {
+ //鏌ヨ鎵�鏈夎鑹�
+ sql = @"select R.rolecode as code,R.rolename as name,R.datarange,T.dataname,R.datapermissions,R.identifying
+ from TRole R
+ left join TData T on R.datarange=T.datacode
+ where status='Y'";
+ list = DapperHelper.select<TRole>(sql, null);
+ if (list.Count > 0)
+ {
+ mes.code = "200";
+ mes.count = list.Count;
+ mes.Message = "鏌ヨ瑙掕壊鎴愬姛锛�";
+ mes.data = list;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏆傛棤瑙掕壊锛�";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瑙掕壊鏉冮檺鏌ヨ榛樿鑿滃崟鎸夐挳鏁版嵁]
+ public static ToMessage RolePermissionSearchRoleMenu(string type)
+ {
+ var dynamicParams = new DynamicParameters();
+ string sql = "";
+ try
+ {
+ //鏌ヨ鎵�鏈夐粯璁よ彍鍗曞強鎸夐挳銆佹暟鎹�
+ sql = @"select menucode,menuname,parent_id,buttoncodelist
+ from TMenu
+ where Type=@type";
+ dynamicParams.Add("@type", type);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛锛�";
+ mes.data = data;
+ return mes;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏆傛棤鑿滃崟锛�";
+ mes.data = null;
+ return mes;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瑙掕壊鏉冮檺,鏍规嵁瑙掕壊鏌ユ壘鍏宠仈鏉冮檺]
+ public static ToMessage RolePermissionSearchRoleMenuButton(string rolecode, string type)
+ {
+ var dynamicParams = new DynamicParameters();
+ string sql = "";
+ try
+ {
+ //鏌ヨ鎵�鏈夐粯璁よ彍鍗曞強鎸夐挳銆佹暟鎹�
+ sql = @"select jsondate from TAuthority where rolecode=@rolecode and type=@type";
+ dynamicParams.Add("@rolecode", rolecode);
+ dynamicParams.Add("@type", type);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛锛�";
+ mes.data = data;
+ return mes;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瑙掕壊鏉冮檺,鎻愪氦]
+ public static ToMessage RolePermissionSava(string json, string rolecode, string type, User us)
+ {
+ var dynamicParams = new DynamicParameters();
+ List<object> list = new List<object>();
+ string sql = "";
+ try
+ {
+ list.Clear();
+ //鍒犻櫎鏉冮檺鍏崇郴琛�
+ sql = @"delete from TAuthority where rolecode=@rolecode and type=@type";
+ list.Add(new { str = sql, parm = new { rolecode = rolecode.ToString(), type = type } });
+ //閲嶆柊鍐欏叆鏉冮檺鍏崇郴琛�
+ sql = @"insert into TAuthority(rolecode,jsondate,type) values(@rolecode,@jsondate,@type)";
+ list.Add(new { str = sql, parm = new { rolecode = rolecode, jsondate = json.ToString(), type = type } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鍒嗛厤", "鍒嗛厤浜嗚鑹叉潈闄�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ }
+}
diff --git a/VueWebCoreApi/DLL/DAL/DeviceManagerDAL.cs b/VueWebCoreApi/DLL/DAL/DeviceManagerDAL.cs
new file mode 100644
index 0000000..997f1d4
--- /dev/null
+++ b/VueWebCoreApi/DLL/DAL/DeviceManagerDAL.cs
@@ -0,0 +1,2800 @@
+锘縰sing Dapper;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.DAL
+{
+ public class DeviceManagerDAL
+ {
+ public static DataTable dt; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static bool res; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+ public static string strProcName = ""; //瀹氫箟鍏ㄥ眬sql鍙橀噺
+ public static List<SqlParameter> listStr = new List<SqlParameter>(); //瀹氫箟鍏ㄥ眬鍙傛暟闆嗗悎
+ public static SqlParameter[] parameters; //瀹氫箟鍏ㄥ眬SqlParameter鍙傛暟鏁扮粍
+
+ #region[璁惧绫诲瀷鏌ヨ]
+ public static ToMessage DeviceTypeSearch(int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select id, code,name,remark
+ from TEqpType
+ where is_delete<>'1' ";
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧绫诲瀷鏂板]
+ public static ToMessage AddUpdateDeviceType(List<ObjectDataCont> json, string username)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ //寰幆鍐欏叆璁惧绫诲瀷琛�
+ for (int i = 0; i < json.Count; i++)
+ {
+ sql = @"insert into TEqpType(code,name,lm_user,lm_date,remark) values(@code,@name,@username,@createdate,@description)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ code = json[i].code,
+ name = json[i].name,
+ username = username,
+ createdate = DateTime.Now.ToString(),
+ description = json[i].description
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧绫诲瀷鍒犻櫎]
+ public static ToMessage DeleteDeviceType(string devicetypecode)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ //鍒ゆ柇璁惧绫诲瀷涓嬫槸鍚﹀叧鑱旇澶囩粍
+ sql = @"select * from TEqpGroup where eqptype_code=@devicetypecode and is_delete<>'1'";
+ dynamicParams.Add("@devicetypecode", devicetypecode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠璁惧绫诲瀷宸叉湁鍏宠仈璁惧缁�,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ }
+ else
+ {
+ //鍒ゆ柇璁惧鏈夋棤鍏宠仈璁惧绫诲瀷
+ sql = @"select * from TEqpInfo where eqptype_code=@devicetypecode and is_delete<>'1'";
+ dynamicParams.Add("@devicetypecode", devicetypecode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠璁惧绫诲瀷宸叉湁鍏宠仈璁惧缁�,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ }
+ else
+ {
+ sql = @"delete TEqpType where code=@devicetypecode";
+ list.Add(new { str = sql, parm = new { devicetypecode = devicetypecode } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[璁惧绫诲瀷涓嬫媺妗嗘帴鍙
+ public static ToMessage DeviceTypeSelect()
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ List<TreeObejct> list = new List<TreeObejct>();
+ try
+ {
+ //鑾峰彇璁惧绫诲瀷鏁版嵁
+ sql = @"select code,name from TEqpType where is_delete<>'1'";
+ var data = DapperHelper.selecttable(sql);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧缁勬煡璇
+ public static ToMessage DeviceGroupSearch(int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.code,A.name,A.eqptype_code,B.name as eqptype_name,A.remark
+ from TEqpGroup A
+ inner join TEqpType B on A.eqptype_code=B.code
+ where A.is_delete<>'1' ";
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧缁勬柊澧瀅
+ public static ToMessage AddUpdateDeviceGroup(List<ObjectDataCont> json, string username)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ //寰幆鍐欏叆璁惧绫诲瀷琛�
+ for (int i = 0; i < json.Count; i++)
+ {
+ sql = @"insert into TEqpGroup(code,name,lm_user,lm_date,remark,eqptype_code) values(@code,@name,@username,@createdate,@description,@eqptype_code)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ code = json[i].code,
+ name = json[i].name,
+ username = username,
+ createdate = DateTime.Now.ToString(),
+ description = json[i].description,
+ eqptype_code = json[i].group
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧绫诲瀷鍒犻櫎]
+ public static ToMessage DeleteDeviceGroup(string devicegroupcode)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ //鍒ゆ柇璁惧缁勪笅鏄惁鍏宠仈璁惧
+ sql = @"select * from TEqpInfo where eqpgroup_code=@devicegroupcode and is_delete<>'1'";
+ dynamicParams.Add("@devicegroupcode", devicegroupcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠璁惧缁勫凡鏈夊叧鑱旇澶囩粍,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ }
+ else
+ {
+ //鍒犻櫎璁惧缁�
+ sql = @"delete TEqpGroup where code=@devicegroupcode";
+ list.Add(new { str = sql, parm = new { devicegroupcode = devicegroupcode } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[璁惧绫诲瀷鏌ユ壘璁惧缁刔
+ public static ToMessage DeviceTypeSelectGroup(string eqptypecode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ List<TreeObejct> list = new List<TreeObejct>();
+ try
+ {
+ //鑾峰彇璁惧绫诲瀷鏁版嵁
+ sql = @"select code,name from TEqpGroup where eqptype_code=@eqptypecode and is_delete<>'1'";
+ dynamicParams.Add("@eqptypecode", eqptypecode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鎵�灞炶溅闂翠笅鎷夋帴鍙
+ public static ToMessage WorkShopSelect(string stu_torgcode, string description)
+ {
+ string sql = "";
+ string search = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鑾峰彇璁惧绫诲瀷鏁版嵁
+ switch (description)
+ {
+ case "":
+ search += "and parent.description=@description ";
+ dynamicParams.Add("@description", "W");
+ break;
+ case "D":
+ search += "and child.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and parent.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ sql = @"select parent.org_code as code,parent.org_name as name
+ from TOrganization parent
+ left join TOrganization as child on parent.parent_id=child.id
+ where parent.is_delete<>'1' " + search;
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鎵�灞炶溅闂存煡鎵炬墍灞炰骇绾挎帴鍙
+ public static ToMessage WorkShopSelectLine(string workshopcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ List<TreeObejct> list = new List<TreeObejct>();
+ try
+ {
+ //鑾峰彇瑙掕壊绫诲瀷闆嗗悎(鍖呭惈缁戝畾鏍囪瘑)
+ dynamicParams.Add("@workshop_code", workshopcode);
+ var data = DapperHelper.selectProcedure("h_p_T_WorkShopSelectLine", dynamicParams);
+
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region [璁惧娓呭崟鏌ヨ]
+ public static ToMessage DeviceMangerSearch(string stu_torgcode, string description, string deviceCode, string deviceName, string status, string workShop, string deviceType, string deviceGroup, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (workShop != "" && workShop != null)
+ {
+ search += "and A.wksp_code=@workShop ";
+ dynamicParams.Add("@workShop", workShop);
+ }
+ else
+ {
+ switch (description)
+ {
+ case "":
+ search += "and T.description=@description ";
+ dynamicParams.Add("@description", "W");
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ }
+ }
+ if (deviceCode != "" && deviceCode != null)
+ {
+ search += "and A.code like '%'+@deviceCode+'%' ";
+ dynamicParams.Add("@deviceCode", deviceCode);
+ }
+ if (deviceName != "" && deviceName != null)
+ {
+ search += "and A.name like '%'+@deviceName+'%' ";
+ dynamicParams.Add("@deviceName", deviceName);
+ }
+ if (status != "" && status != null)
+ {
+ search += "and A.enable=@status ";
+ dynamicParams.Add("@status", status);
+ }
+ if (deviceType != "" && deviceType != null)
+ {
+ search += "and A.eqptype_code=@deviceType ";
+ dynamicParams.Add("@deviceType", deviceType);
+ }
+ if (deviceGroup != "" && deviceGroup != null)
+ {
+ search += "and A.eqpgroup_code=@deviceGroup ";
+ dynamicParams.Add("@deviceGroup", deviceGroup);
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ //search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.id,A.code,A.name,A.eqptype_code,B.name as eqptype_name,A.eqpgroup_code,G.name as eqpgroup_name,A.enable,
+ A.input_date,A.wksp_code,T.org_name as wksp_name,A.Line_code,L.org_name as Line_name,A.opc_uom,A.operation_ration,U.username as lm_user,A.lm_date
+ from TEqpInfo A
+ left join TEqpType B on A.eqptype_code=B.code
+ left join TEqpGroup G on A.eqpgroup_code=G.code
+ left join TOrganization T on A.wksp_code=T.org_code
+ left join TOrganization as L on T.parent_id=L.id
+ left join TUser U on A.lm_user=U.usercode
+ where A.is_delete<>'1' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧娓呭崟鏂板缂栬緫]
+ public static ToMessage AddUpdateDeviceManger(string deviceid, string devicecode, string devicename, string devicetype, string devicegroup, string importdate, string workshop, string linecode, string status, string ratio, string usercode, string operType)
+ {
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (operType == "Add")
+ {
+ var sql = @"insert into TEqpInfo(code,name,eqptype_code,eqpgroup_code,wksp_code,line_code,input_date,operation_ration,enable,opc_uom,lm_user,lm_date)
+ values(@devicecode,@devicename,@devicetype,@devicegroup,@workshop,@linecode,@importdate,@ratio,@status,@uom,@usercode,@CreateDate)";
+ dynamicParams.Add("@devicecode", devicecode);
+ dynamicParams.Add("@devicename", devicename);
+ dynamicParams.Add("@devicetype", devicetype);
+ dynamicParams.Add("@devicegroup", devicegroup);
+ dynamicParams.Add("@workshop", workshop);
+ dynamicParams.Add("@linecode", linecode);
+ dynamicParams.Add("@importdate", importdate);
+ dynamicParams.Add("@ratio", ratio);
+ dynamicParams.Add("@status", status);
+ dynamicParams.Add("@uom", "鍙�");
+ dynamicParams.Add("@usercode", usercode);
+ dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (operType == "Update")
+ {
+ var sql = @"update TEqpInfo set name=@devicename,eqptype_code=@devicetype,eqpgroup_code=@devicegroup,input_date=@importdate,
+ wksp_code=@workshop,line_code=@linecode,enable=@status,operation_ration=@ratio,lm_user=@usercode,lm_date=@CreateDate
+ where id=@deviceid";
+ dynamicParams.Add("@deviceid", deviceid);
+ dynamicParams.Add("@devicename", devicename);
+ dynamicParams.Add("@devicetype", devicetype);
+ dynamicParams.Add("@devicegroup", devicegroup);
+ dynamicParams.Add("@workshop", workshop);
+ dynamicParams.Add("@linecode", linecode);
+ dynamicParams.Add("@importdate", importdate);
+ dynamicParams.Add("@ratio", ratio);
+ dynamicParams.Add("@status", status);
+ dynamicParams.Add("@usercode", usercode);
+ dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧娓呭崟鍒犻櫎]
+ public static ToMessage DeleteDeviceManger(string devicecode)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ //鍒ゆ柇璁惧鏄惁鏈夊叧鑱斿伐鑹鸿矾绾跨殑鐢熶骇璁㈠崟(鏈叧闂�),涓嶅厑璁稿垹闄�
+ sql = @"select A.code,M.wo_code,R.name from TEqpInfo A
+ inner join TFlw_Rteqp B on A.code=B.eqp_code
+ inner join TStep C on B.step_code=C.stepcode
+ inner join TFlw_Rtdt D on C.stepcode=D.step_code
+ inner join TFlw_Rout R on D.rout_code=R.code
+ inner join TK_Wrk_Man M on R.code=M.route_code
+ where A.code=@devicecode";
+ dynamicParams.Add("@devicecode", devicecode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠璁惧琚伐鍗曞紩鐢�,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ return mes;
+ }
+ //鍒ゆ柇璁惧鏄惁鏈夊叧鑱斿伐鑹鸿矾绾垮伐搴�,涓嶅厑璁稿垹闄�
+ sql = @"select * from TFlw_Rteqp
+ where eqp_code=@devicecode";
+ dynamicParams.Add("@devicecode", devicecode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠璁惧宸插叧鑱斿伐搴�,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ return mes;
+ }
+ //鍒ゆ柇璁惧鏄惁鎸囧畾鑺傛媿宸ヤ环,涓嶅厑璁稿垹闄�
+ sql = @"select * from TPrteEqp_Stad
+ where eqp_code=@devicecode";
+ dynamicParams.Add("@devicecode", devicecode);
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠璁惧宸叉寚瀹氳妭鎷嶅伐浠�,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ return mes;
+ }
+
+ //鍒犻櫎璁惧
+ sql = @"update TEqpInfo set is_delete='1' where code=@devicecode";
+ list.Add(new { str = sql, parm = new { devicecode = devicecode } });
+ //鍒犻櫎璁惧鍏宠仈鐐规鏍囧噯琛�
+ sql = @"delete TEqpchk_Eqp where eqp_code=@devicecode";
+ list.Add(new { str = sql, parm = new { devicecode = devicecode } });
+ //鍒犻櫎璁惧缁戝畾淇濆吇鏍囧噯琛�
+ sql = @"delete TEqpmai_Eqp where eqp_code=@devicecode";
+ list.Add(new { str = sql, parm = new { devicecode = devicecode } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎澶辫触!";
+ mes.data = null;
+ }
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[璁惧鐐规椤瑰垪琛ㄦ煡璇
+ public static ToMessage DeviceCheckItemSearch(string checkitemcode, string checkitemname, string checkdescr, string isqrcode, string cycle, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (checkitemcode != "" && checkitemcode != null)
+ {
+ search += "and A.code like '%'+@checkitemcode+'%' ";
+ dynamicParams.Add("@checkitemcode", checkitemcode);
+ }
+ if (checkitemname != "" && checkitemname != null)
+ {
+ search += "and A.name like '%'+@checkitemname+'%' ";
+ dynamicParams.Add("@checkitemname", checkitemname);
+ }
+ if (checkdescr != "" && checkdescr != null)
+ {
+ search += "and A.description like '%'+@checkdescr+'%' ";
+ dynamicParams.Add("@checkdescr", checkdescr);
+ }
+ if (isqrcode != "" && isqrcode != null)
+ {
+ search += "and A.isscan=@isqrcode ";
+ dynamicParams.Add("@isqrcode", isqrcode);
+ }
+ if (cycle != "" && cycle != null)
+ {
+ search += "and A.cycle=@cycle ";
+ dynamicParams.Add("@cycle", cycle);
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ //search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.id,A.code,A.name,A.description,A.isscan,A.cycle,U.username as lm_user,A.lm_date
+ from TEqpchk_Item A
+ left join TUser U on A.lm_user=U.usercode
+ where A.is_delete<>'1' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧鐐规椤规柊澧炵紪杈慮
+ public static ToMessage AddUpdateDeviceCheckItem(string checkitemid, string checkitemcode, string checkitemname, string checkitemdescr, string cycle, string isqrcode, string usercode, string operType)
+ {
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (operType == "Add")
+ {
+ var sql = @"insert into TEqpchk_Item(code,name,description,isscan,cycle,lm_user,lm_date)
+ values(@checkitemcode,@checkitemname,@checkitemdescr,@isqrcode,@cycle,@usercode,@CreateDate)";
+ dynamicParams.Add("@checkitemcode", checkitemcode);
+ dynamicParams.Add("@checkitemname", checkitemname);
+ dynamicParams.Add("@checkitemdescr", checkitemdescr);
+ dynamicParams.Add("@isqrcode", isqrcode);
+ dynamicParams.Add("@cycle", cycle);
+ dynamicParams.Add("@usercode", usercode);
+ dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (operType == "Update")
+ {
+ var sql = @"update TEqpchk_Item set name=@checkitemname,description=@checkitemdescr,isscan=@isqrcode,cycle=@cycle,
+ lm_user=@usercode,lm_date=@CreateDate
+ where id=@checkitemid";
+ dynamicParams.Add("@checkitemid", checkitemid);
+ dynamicParams.Add("@checkitemname", checkitemname);
+ dynamicParams.Add("@checkitemdescr", checkitemdescr);
+ dynamicParams.Add("@isqrcode", isqrcode);
+ dynamicParams.Add("@cycle", cycle);
+ dynamicParams.Add("@usercode", usercode);
+ dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧鐐规椤瑰垹闄
+ public static ToMessage DeleteDeviceCheckItem(string checkitemcode)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ //鍒ゆ柇鐐规鏍囧噯椤圭洰鏄惁鏈夊叧鑱旂偣妫�鏍囧噯,涓嶅厑璁稿垹闄�
+ sql = @"select * from TEqpchk_Deta
+ where code=@checkitemcode";
+ dynamicParams.Add("@checkitemcode", checkitemcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鐐规椤圭洰宸插叧鑱旀爣鍑�,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ return mes;
+ }
+
+ //鍒犻櫎鐐规椤圭洰
+ sql = @"delete TEqpchk_Item where code=@checkitemcode";
+ list.Add(new { str = sql, parm = new { checkitemcode = checkitemcode } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎澶辫触!";
+ mes.data = null;
+ }
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[璁惧淇濆吇椤瑰垪琛ㄦ煡璇
+ public static ToMessage DeviceMaiItemSearch(string maiitemcode, string maiitemname, string maidescr, string isqrcode, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (maiitemcode != "" && maiitemcode != null)
+ {
+ search += "and A.code like '%'+@maiitemcode+'%' ";
+ dynamicParams.Add("@maiitemcode", maiitemcode);
+ }
+ if (maiitemname != "" && maiitemname != null)
+ {
+ search += "and A.name like '%'+@maiitemname+'%' ";
+ dynamicParams.Add("@maiitemname", maiitemname);
+ }
+ if (maidescr != "" && maidescr != null)
+ {
+ search += "and A.description like '%'+@maidescr+'%' ";
+ dynamicParams.Add("@maidescr", maidescr);
+ }
+ if (isqrcode != "" && isqrcode != null)
+ {
+ search += "and A.isscan=@isqrcode ";
+ dynamicParams.Add("@isqrcode", isqrcode);
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ //search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.id,A.code,A.name,A.description,A.isscan,U.username as lm_user,A.lm_date
+ from TEqpmai_Item A
+ left join TUser U on A.lm_user=U.usercode
+ where A.is_delete<>'1' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧淇濆吇椤规柊澧炵紪杈慮
+ public static ToMessage AddUpdateDeviceMaiItem(string maiitemid, string maiitemcode, string maiitemname, string maiitemdescr, string isqrcode, string usercode, string operType)
+ {
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (operType == "Add")
+ {
+ var sql = @"insert into TEqpmai_Item(code,name,description,isscan,lm_user,lm_date)
+ values(@maiitemcode,@maiitemname,@maiitemdescr,@isqrcode,@usercode,@CreateDate)";
+ dynamicParams.Add("@maiitemcode", maiitemcode);
+ dynamicParams.Add("@maiitemname", maiitemname);
+ dynamicParams.Add("@maiitemdescr", maiitemdescr);
+ dynamicParams.Add("@isqrcode", isqrcode);
+ dynamicParams.Add("@usercode", usercode);
+ dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (operType == "Update")
+ {
+ var sql = @"update TEqpmai_Item set name=@maiitemname,description=@maiitemdescr,isscan=@isqrcode,
+ lm_user=@usercode,lm_date=@CreateDate
+ where id=@maiitemid";
+ dynamicParams.Add("@maiitemid", maiitemid);
+ dynamicParams.Add("@maiitemname", maiitemname);
+ dynamicParams.Add("@maiitemdescr", maiitemdescr);
+ dynamicParams.Add("@isqrcode", isqrcode);
+ dynamicParams.Add("@usercode", usercode);
+ dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧淇濆吇椤瑰垹闄
+ public static ToMessage DeleteDeviceMaiItem(string maiitemcode)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ //鍒ゆ柇淇濆吇鏍囧噯椤圭洰鏄惁鏈夊叧鑱斾繚鍏绘爣鍑�,涓嶅厑璁稿垹闄�
+ sql = @"select * from TEqpmai_Deta
+ where code=@maiitemcode";
+ dynamicParams.Add("@maiitemcode", maiitemcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠淇濆吇椤圭洰宸插叧鑱旀爣鍑�,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ return mes;
+ }
+
+ //鍒犻櫎淇濆吇椤圭洰
+ sql = @"delete TEqpmai_Item where code=@maiitemcode";
+ list.Add(new { str = sql, parm = new { maiitemcode = maiitemcode } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎澶辫触!";
+ mes.data = null;
+ }
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[璁惧鐐规鏍囧噯鍒楄〃鏌ヨ]
+ public static ToMessage DeviceCheckStandArdSearch(string stu_torgcode, string stu_torgtypecode, string checkstandcode, string checkstandname, string checkcontr, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ string search1 = "";
+ try
+ {
+ switch (stu_torgtypecode)
+ {
+ case "":
+ break;
+ case "D":
+ search1 += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search1 += "and F.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ if (checkstandcode != "" && checkstandcode != null)
+ {
+ search += "and A.code like '%'+@checkstandcode+'%' ";
+ dynamicParams.Add("@checkstandcode", checkstandcode);
+ }
+ if (checkstandname != "" && checkstandname != null)
+ {
+ search += "and A.name like '%'+@checkstandname+'%' ";
+ dynamicParams.Add("@checkstandname", checkstandname);
+ }
+ if (checkcontr != "" && checkcontr != null)
+ {
+ search += "and A.iscontr=@checkcontr ";
+ dynamicParams.Add("@checkcontr", checkcontr);
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ //search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.id,A.code,A.name,A.description,A.iscontr,
+ (case when isnull(M.eqpchkmain_code,'')='' then 'N' else 'Y' end) as is_checkeqp,U.username as lm_user,A.lm_date
+ from TEqpchk_Main A
+ left join TUser U on A.lm_user=U.usercode
+ left join (
+ select distinct eqpchkmain_code from TEqpchk_Eqp M
+ left join TOrganization F on M.torg_code=F.org_code
+ left join TOrganization as L on F.parent_id=L.id
+ where 1=1 " + search1 + ") M on A.code=M.eqpchkmain_code where A.is_delete<>'1' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧鐐规鏍囧噯鏂板銆佺紪杈戣幏鍙栨楠岄」鐩笅鎷夊垪琛╙
+ public static ToMessage DeviceCheckItemSelect()
+ {
+ string sql = "";
+ try
+ {
+ //鑾峰彇璁惧鐐规椤圭洰鏁版嵁
+ sql = @"select code,name,description from TEqpchk_Item where is_delete<>'1' ";
+ var data = DapperHelper.selecttable(sql);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧鐐规鏍囧噯缂栬緫/鏌ョ湅鑾峰彇鏁版嵁]
+ public static ToMessage ViewDeviceCheckStanedSearch(string checkstand_code)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鑾峰彇璁惧鐐规鏍囧噯淇℃伅
+ sql = @"select code,name,description,iscontr
+ from TEqpchk_Main
+ where code=@checkstand_code and is_delete<>'1'";
+ dynamicParams.Add("@checkstand_code", checkstand_code);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ RoutEdit rout = new RoutEdit();
+ if (data.Rows.Count > 0)
+ {
+ rout.code = data.Rows[0]["CODE"].ToString();
+ rout.name = data.Rows[0]["NAME"].ToString();
+ rout.description = data.Rows[0]["DESCRIPTION"].ToString();
+ rout.enable = data.Rows[0]["ISCONTR"].ToString();
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏃犵偣妫�鏍囧噯淇℃伅!";
+ mes.data = null;
+ return mes;
+ }
+ //鏍规嵁璁惧鐐规鏍囧噯缂栫爜鑾峰彇鍏宠仈鐨勬楠岄」鐩俊鎭�
+ sql = @"select B.code,B.name,A.chkdesc,A.isscan,A.cycle from TEqpchk_Deta A
+ left join TEqpchk_Item B on A.code=B.code
+ where A.eqpchk_main_code=@checkstaned_code order by A.seq asc";
+ dynamicParams.Add("@checkstaned_code", rout.code);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ rout.Data = data0;
+
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = rout;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧鐐规鏍囧噯鏂板缂栬緫]
+ public static ToMessage AddUpdateDeviceCheckStandArd(string opertype, RoutEdit json, string username)
+ {
+ var sql = "";
+ var dynamicParams = new DynamicParameters();
+ List<object> list = new List<object>();
+ try
+ {
+ if (opertype == "Add")
+ {
+ //鏂板璁惧鐐规鏍囧噯涓昏〃
+ sql = @"insert into TEqpchk_Main(code,name,description,iscontr,lm_user,lm_date) values(@code,@name,@descr,@iscontr,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { code = json.code, name = json.name, descr = json.description, iscontr = json.enable, lm_user = username, lm_date = DateTime.Now.ToString() } });
+ for (int i = 0; i < json.Data.Rows.Count; i++)
+ {
+ //鏂板璁惧鐐规鏍囧噯鍏宠仈鐐规椤瑰瓙琛�
+ sql = @"insert TEqpchk_Deta (seq,code,name,eqpchk_main_code,cycle,chkdesc,isscan,lm_user,lm_date)
+ values(@checkitem_seq,@checkitem_code,@checkitem_name,@code,@cycle,@chkdesc,@isscan,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ checkitem_seq = Convert.ToInt32(json.Data.Rows[i]["CHECKITEM_SEQ"].ToString()),
+ checkitem_code = json.Data.Rows[i]["CHECKITEM_CODE"].ToString(),
+ checkitem_name = json.Data.Rows[i]["CHECKITEM_NAME"].ToString(),
+ code = json.code,
+ cycle = json.Data.Rows[i]["CYCLE"].ToString(),
+ chkdesc = json.Data.Rows[i]["CHECKITEM_DESCR"].ToString(),
+ isscan = json.Data.Rows[i]["ISSCAN"].ToString(),
+ lm_user = username,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (opertype == "Update")
+ {
+ //鍒犻櫎鐐规鏍囧噯鍏宠仈鐐规椤圭洰瀛愯〃
+ sql = @"delete from TEqpchk_Deta where eqpchk_main_code=@checkstaned_code";
+ list.Add(new { str = sql, parm = new { checkstaned_code = json.code } });
+ //淇敼鐐规鏍囧噯涓昏〃
+ sql = @"update TEqpchk_Main set name=@checkstaned_name,description=@checkstaned_desc,iscontr=@iscontr where code=@checkstaned_code";
+ list.Add(new { str = sql, parm = new { checkstaned_code = json.code, checkstaned_name = json.name, checkstaned_desc = json.description, iscontr = json.enable } });
+ //鏂板鐐规鏍囧噯鍏宠仈鐐规椤圭洰瀛愯〃
+ for (int i = 0; i < json.Data.Rows.Count; i++)
+ {
+ sql = @"insert TEqpchk_Deta (seq,code,name,eqpchk_main_code,cycle,chkdesc,isscan,lm_user,lm_date)
+ values(@checkitem_seq,@checkitem_code,@checkitem_name,@code,@cycle,@chkdesc,@isscan,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ checkitem_seq = Convert.ToInt32(json.Data.Rows[i]["CHECKITEM_SEQ"].ToString()),
+ checkitem_code = json.Data.Rows[i]["CHECKITEM_CODE"].ToString(),
+ checkitem_name = json.Data.Rows[i]["CHECKITEM_NAME"].ToString(),
+ code = json.code,
+ cycle = json.Data.Rows[i]["CYCLE"].ToString(),
+ chkdesc = json.Data.Rows[i]["CHECKITEM_DESCR"].ToString(),
+ isscan = json.Data.Rows[i]["ISSCAN"].ToString(),
+ lm_user = username,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+ }
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧鐐规鏍囧噯鍒犻櫎]
+ public static ToMessage DeleteDeviceCheckStaned(string checkstand_code)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select * from TEqpchk_Proc_Main where eqpchkmain_code=@checkstand_code";
+ dynamicParams.Add("@checkstand_code", checkstand_code);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鐐规鏍囧噯宸茬敓鎴愮偣妫�璁板綍,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ return mes;
+ }
+ //鍒犻櫎璁惧鐐规鏍囧噯涓昏〃
+ sql = @"delete TEqpchk_Main where code=@checkstand_code";
+ list.Add(new { str = sql, parm = new { checkstand_code = checkstand_code } });
+ //鍒犻櫎璁惧鐐规鏍囧噯鍏宠仈鐐规椤圭洰瀛愯〃
+ sql = @"delete TEqpchk_Deta where eqpchk_main_code=@checkstand_code";
+ list.Add(new { str = sql, parm = new { checkstand_code = checkstand_code } });
+ //鍒犻櫎璁惧鐐规鏍囧噯鍏宠仈璁惧琛�
+ sql = @"delete TEqpchk_Eqp where eqpchkmain_code=@checkstand_code";
+ list.Add(new { str = sql, parm = new { checkstand_code = checkstand_code } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "璁惧鐐规鏍囧噯鍒犻櫎鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璁惧鐐规鏍囧噯鍒犻櫎澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧鐐规鏍囧噯鍏宠仈宸ヤ綔绔欐煡璇
+ public static ToMessage DeviceCheckStanedAssociationEqp(string stu_torgcode, string description, string checkstand_code)
+ {
+ string sql = "";
+ string search = "";
+ var dynamicParams = new DynamicParameters();
+ List<StandEqp> list = new List<StandEqp>();
+ try
+ {
+ switch (description)
+ {
+ case "":
+ break;
+ case "D":
+ search += "and T.org_code=@stu_torgcode or child.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and T.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ //鑾峰彇宸ヤ綔绔欓泦鍚�(杞﹂棿,鍖呭惈宸茬粦瀹氬伐浣滅珯鏍囪瘑)
+ sql = @"select distinct T.org_code as wksp_code,T.org_name as wksp_name,'E' as type,(case when B.eqp_code is null then 'N' else 'Y' end) flag
+ from TOrganization T
+ left join TOrganization as child on T.parent_id=child.id
+ left join(
+ select distinct A.eqp_code,B.wksp_code from TEqpchk_Eqp A
+ inner join TEqpInfo B on A.eqp_code=B.code
+ where A.eqpchkmain_code=@checkstand_code and A.is_delete<>'1' and B.is_delete<>'1'
+ ) B on T.org_code=B.wksp_code where T.description='W' and T.is_delete<>'1' " + search;
+ dynamicParams.Add("@checkstand_code", checkstand_code);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ for (int i = 0; i < data.Rows.Count; i++)
+ {
+ StandEqp rout = new StandEqp();
+ rout.code = data.Rows[i]["WKSP_CODE"].ToString();
+ rout.name = data.Rows[i]["WKSP_NAME"].ToString();
+ rout.type = data.Rows[i]["TYPE"].ToString();
+ rout.flag = data.Rows[i]["FLAG"].ToString();
+ rout.children = new List<StandEqpCn>();
+ //鏍规嵁杞﹂棿缂栫爜鏌ユ壘璁惧(鍖呭惈宸插叧鑱旀爣璇�)
+ //sql = @"select A.code,A.name,'E' as type,(case when B.eqp_code is null then 'N' else 'Y' end) flag
+ // from TEqpInfo A
+ // left join(
+ // select distinct A.eqp_code from TEqpchk_Eqp A
+ // inner join TEqpInfo B on A.eqp_code=B.code
+ // where A.eqpchkmain_code=@checkstand_code and A.is_delete<>'1' and B.is_delete<>'1'
+ // ) B on A.code=B.eqp_code where A.wksp_code=@wkspcode and A.is_delete<>'1'";
+ sql = @"select * from(
+ select AA.code,AA.name,'E' as type,(case when BB.eqpchkmain_code is null then 'N' else 'Y' end) flag,(case when AA.eqpchkmain_code is null then 'N' else 'Y' end) flage1
+ from(
+ select A.code,A.name,'' as eqpchkmain_code
+ from TEqpInfo A
+ where A.wksp_code=@wkspcode and A.is_delete<>'1'
+ ) as AA
+ left join (
+ select A.code,A.name,B.eqpchkmain_code
+ from TEqpInfo A
+ inner join TEqpchk_Eqp B on A.code=B.eqp_code
+ where A.wksp_code=@wkspcode and B.eqpchkmain_code=@checkstand_code and A.is_delete<>'1'
+ ) as BB on AA.code=BB.code
+ ) as CC "; //where case when flag ='N' and flage1 ='Y' then 0 else 1 end=1
+ dynamicParams.Add("@checkstand_code", checkstand_code);
+ dynamicParams.Add("@wkspcode", data.Rows[i]["WKSP_CODE"].ToString());
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ for (int j = 0; j < data0.Rows.Count; j++)
+ {
+ StandEqpCn cn = new StandEqpCn();
+ cn.code = data0.Rows[j]["CODE"].ToString();//璁惧缂栫爜
+ cn.name = data0.Rows[j]["NAME"].ToString();//璁惧鍚嶇О
+ cn.type = data0.Rows[j]["TYPE"].ToString();//宸ヤ綔绔欑被鍨�(E:璁惧 W:澶栧崗渚涙柟)
+ cn.flag = data0.Rows[j]["FLAG"].ToString();//鍏宠仈鏍囪瘑
+ rout.children.Add(cn);
+ }
+ list.Add(rout);
+ }
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = list;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region [璁惧鐐规鏍囧噯鍏宠仈宸ヤ綔绔欐彁浜
+ public static ToMessage SaveDeviceCheckStanedAssociationEqp(string stu_torgcode, string stu_torgtypecode, string checkstand_code, string username, List<ObjectData> json)
+ {
+ var sql = "";
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ List<object> list = new List<object>();
+ try
+ {
+ list.Clear();
+ switch (stu_torgtypecode)
+ {
+ case "":
+ //娓呴櫎璁惧鐐规鏍囧噯鍏宠仈璁惧琛ㄦ暟鎹�
+ sql = @"delete TEqpchk_Eqp where eqpchkmain_code=@checkstand_code";
+ list.Add(new { str = sql, parm = new { checkstand_code = checkstand_code } });
+ break;
+ case "D":
+ //娓呴櫎璁惧鐐规鏍囧噯鍏宠仈璁惧琛ㄦ暟鎹�
+ sql = @"delete from TEqpchk_Eqp where id in (select A.id from TEqpchk_Eqp A
+ left join TOrganization T on A.torg_code=T.org_code
+ left join TOrganization as L on T.parent_id=L.id
+ where 1=1 and A.eqpchkmain_code=@checkstand_code and L.org_code=@stu_torgcode)";
+ list.Add(new { str = sql, parm = new { checkstand_code = checkstand_code, stu_torgcode = stu_torgcode } });
+ break;
+ case "W":
+ //娓呴櫎璁惧鐐规鏍囧噯鍏宠仈璁惧琛ㄦ暟鎹�
+ sql = @"delete from TEqpchk_Eqp where id in (select A.id from TEqpchk_Eqp A
+ left join TOrganization T on A.torg_code=T.org_code
+ left join TOrganization as L on T.parent_id=L.id
+ where 1=1 and A.eqpchkmain_code=@checkstand_code and T.org_code=@stu_torgcode)";
+ list.Add(new { str = sql, parm = new { checkstand_code = checkstand_code, stu_torgcode = stu_torgcode } });
+ break;
+ }
+ if (json != null && json.Count > 0)
+ {
+ //寰幆鍐欏叆璁惧鐐规鏍囧噯鍏宠仈璁惧琛�
+ for (int i = 0; i < json.Count; i++)
+ {
+ sql = @"insert into TEqpchk_Eqp(eqpchkmain_code,eqp_code,lm_user,lm_date,torg_code) values(@checkstand_code,@eqp_code,@lm_user,@lm_date,@torg_code)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ eqp_code = json[i].code,
+ checkstand_code = checkstand_code,
+ lm_user = username,
+ lm_date = DateTime.Now.ToString(),
+ torg_code = json[i].flag
+ }
+ });
+ }
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[璁惧淇濆吇鏍囧噯鍒楄〃鏌ヨ]
+ public static ToMessage DeviceRepairStandArdSearch(string stu_torgcode, string stu_torgtypecode, string repairstandcode, string repairstandname, string repairstanddescr, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ string search1 = "";
+ try
+ {
+ switch (stu_torgtypecode)
+ {
+ case "":
+ break;
+ case "D":
+ search1 += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search1 += "and F.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ if (repairstandcode != "" && repairstandcode != null)
+ {
+ search += "and A.code like '%'+@repairstandcode+'%' ";
+ dynamicParams.Add("@repairstandcode", repairstandcode);
+ }
+ if (repairstandname != "" && repairstandname != null)
+ {
+ search += "and A.name like '%'+@repairstandname+'%' ";
+ dynamicParams.Add("@repairstandname", repairstandname);
+ }
+ if (repairstanddescr != "" && repairstanddescr != null)
+ {
+ search += "and A.description like '%'+@repairstanddescr+'%' ";
+ dynamicParams.Add("@repairstanddescr", repairstanddescr);
+ }
+
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ //search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.id,A.code,A.name,A.description,
+ (case when isnull(M.eapmai_code,'')='' then 'N' else 'Y' end) as is_repaireqp,
+ A.main_cycle,U.username as lm_user,A.lm_date
+ from TEqpmai_Main A
+ left join TUser U on A.lm_user=U.usercode
+ left join (
+ select distinct eapmai_code from TEqpmai_Eqp M
+ left join TOrganization F on M.torg_code=F.org_code
+ left join TOrganization as L on F.parent_id=L.id
+ where 1=1 " + search1 + ") M on A.code=M.eapmai_code where A.is_delete<>'1' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧淇濆吇鏍囧噯鏂板銆佺紪杈戣幏鍙栦繚鍏婚」鐩笅鎷夊垪琛╙
+ public static ToMessage DeviceRepairItemSelect()
+ {
+ string sql = "";
+ try
+ {
+ //鑾峰彇璁惧淇濆吇椤圭洰鏁版嵁
+ sql = @"select code,name,description from TEqpmai_Item where is_delete<>'1' ";
+ var data = DapperHelper.selecttable(sql);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧淇濆吇鏍囧噯缂栬緫/鏌ョ湅鑾峰彇鏁版嵁]
+ public static ToMessage ViewDeviceRepairStanedSearch(string repairstand_code)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鑾峰彇璁惧淇濆吇鏍囧噯淇℃伅
+ sql = @"select code,name,description,main_cycle
+ from TEqpmai_Main
+ where code=@repairstand_code and is_delete<>'1'";
+ dynamicParams.Add("@repairstand_code", repairstand_code);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ EqpRepair rout = new EqpRepair();
+ if (data.Rows.Count > 0)
+ {
+ rout.code = data.Rows[0]["CODE"].ToString();
+ rout.name = data.Rows[0]["NAME"].ToString();
+ rout.repaircycle = data.Rows[0]["MAIN_CYCLE"].ToString();
+ rout.description = data.Rows[0]["DESCRIPTION"].ToString();
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏃犱繚鍏绘爣鍑嗕俊鎭�!";
+ mes.data = null;
+ return mes;
+ }
+ //鏍规嵁璁惧淇濆吇鏍囧噯缂栫爜鑾峰彇鍏宠仈鐨勪繚鍏婚」鐩俊鎭�
+ sql = @"select B.code,B.name,A.chk_desc,A.isscan,A.cycle from TEqpmai_Deta A
+ left join TEqpmai_Item B on A.code=B.code
+ where A.eapmai_code=@repairstand_code order by A.seq asc";
+ dynamicParams.Add("@repairstand_code", rout.code);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ rout.Data = data0;
+
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = rout;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧淇濆吇鏍囧噯鏂板缂栬緫]
+ public static ToMessage AddUpdateDeviceRepairStandArd(string opertype, EqpRepair json, string username)
+ {
+ var sql = "";
+ var dynamicParams = new DynamicParameters();
+ List<object> list = new List<object>();
+ try
+ {
+ if (opertype == "Add")
+ {
+ //鏂板璁惧淇濆吇鏍囧噯涓昏〃
+ sql = @"insert into TEqpmai_Main(code,name,description,main_cycle,lm_user,lm_date) values(@code,@name,@descr,@main_cycle,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { code = json.code, name = json.name, descr = json.description, main_cycle = json.repaircycle, lm_user = username, lm_date = DateTime.Now.ToString() } });
+ for (int i = 0; i < json.Data.Rows.Count; i++)
+ {
+ //鏂板璁惧淇濆吇鏍囧噯鍏宠仈淇濆吇椤瑰瓙琛�
+ sql = @"insert TEqpmai_Deta (seq,code,name,eapmai_code,chk_desc,isscan,lm_user,lm_date)
+ values(@repairitem_seq,@repairitem_code,@repairitem_name,@code,@repairdesc,@isscan,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ repairitem_seq = Convert.ToInt32(json.Data.Rows[i]["REPAIRITEM_SEQ"].ToString()),
+ repairitem_code = json.Data.Rows[i]["REPAIRITEM_CODE"].ToString(),
+ repairitem_name = json.Data.Rows[i]["REPAIRITEM_NAME"].ToString(),
+ code = json.code,
+ repairdesc = json.Data.Rows[i]["REPAIRITEM_DESCR"].ToString(),
+ isscan = json.Data.Rows[i]["ISSCAN"].ToString(),
+ lm_user = username,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (opertype == "Update")
+ {
+ //鍒犻櫎淇濆吇鏍囧噯鍏宠仈鐐规椤圭洰瀛愯〃
+ sql = @"delete from TEqpmai_Deta where eapmai_code=@repairstaned_code";
+ list.Add(new { str = sql, parm = new { repairstaned_code = json.code } });
+ //淇敼淇濆吇鏍囧噯涓昏〃
+ sql = @"update TEqpmai_Main set name=@repairstaned_name,description=@repairstaned_desc,main_cycle=@main_cycle where code=@repairstaned_code";
+ list.Add(new { str = sql, parm = new { repairstaned_code = json.code, repairstaned_name = json.name, repairstaned_desc = json.description, main_cycle = json.repaircycle } });
+ //鏂板鐐规鏍囧噯鍏宠仈鐐规椤圭洰瀛愯〃
+ for (int i = 0; i < json.Data.Rows.Count; i++)
+ {
+ sql = @"insert TEqpmai_Deta (seq,code,name,eapmai_code,chk_desc,isscan,lm_user,lm_date)
+ values(@repairitem_seq,@repairitem_code,@repairitem_name,@code,@repairdesc,@isscan,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ repairitem_seq = Convert.ToInt32(json.Data.Rows[i]["REPAIRITEM_SEQ"].ToString()),
+ repairitem_code = json.Data.Rows[i]["REPAIRITEM_CODE"].ToString(),
+ repairitem_name = json.Data.Rows[i]["REPAIRITEM_NAME"].ToString(),
+ code = json.code,
+ repairdesc = json.Data.Rows[i]["REPAIRITEM_DESCR"].ToString(),
+ isscan = json.Data.Rows[i]["ISSCAN"].ToString(),
+ lm_user = username,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+ }
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧淇濆吇鏍囧噯鍒犻櫎]
+ public static ToMessage DeleteDeviceRepairStaned(string repairstand_code)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select * from TEqpmaint_Proc_Main where eqpmaint_code=@repairstand_code";
+ dynamicParams.Add("@repairstand_code", repairstand_code);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠淇濆吇鏍囧噯宸茬敓鎴愪繚鍏昏褰�,涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ return mes;
+ }
+ //鍒犻櫎璁惧淇濆吇鏍囧噯涓昏〃
+ sql = @"delete TEqpmai_Main where code=@repairstand_code";
+ list.Add(new { str = sql, parm = new { repairstand_code = repairstand_code } });
+ //鍒犻櫎璁惧淇濆吇鏍囧噯鍏宠仈淇濆吇椤圭洰瀛愯〃
+ sql = @"delete TEqpmai_Deta where eapmai_code=@repairstand_code";
+ list.Add(new { str = sql, parm = new { repairstand_code = repairstand_code } });
+ //鍒犻櫎璁惧淇濆吇鏍囧噯鍏宠仈璁惧琛�
+ sql = @"delete TEqpmai_Eqp where eapmai_code=@repairstand_code";
+ list.Add(new { str = sql, parm = new { repairstand_code = repairstand_code } });
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "璁惧淇濆吇鏍囧噯鍒犻櫎鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璁惧淇濆吇鏍囧噯鍒犻櫎澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧淇濆吇鏍囧噯鍏宠仈宸ヤ綔绔欐煡璇
+ public static ToMessage DeviceRepairStanedAssociationEqp(string stu_torgcode, string description, string repairstand_code)
+ {
+ string sql = "";
+ string search = "";
+ var dynamicParams = new DynamicParameters();
+ List<StandEqp> list = new List<StandEqp>();
+ try
+ {
+ switch (description)
+ {
+ case "":
+ break;
+ case "D":
+ search += "and T.org_code=@stu_torgcode or child.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and T.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ //鑾峰彇宸ヤ綔绔欓泦鍚�(杞﹂棿,鍖呭惈宸茬粦瀹氬伐浣滅珯鏍囪瘑)
+ sql = @"select distinct T.org_code as wksp_code,T.org_name as wksp_name,'E' as type,(case when B.eqp_code is null then 'N' else 'Y' end) flag
+ from TOrganization T
+ left join TOrganization as child on T.parent_id=child.id
+ left join(
+ select distinct A.eqp_code,B.wksp_code from TEqpmai_Eqp A
+ inner join TEqpInfo B on A.eqp_code=B.code
+ where A.eapmai_code=@repairstand_code and A.is_delete<>'1' and B.is_delete<>'1'
+ ) B on T.org_code=B.wksp_code where T.description='W' and T.is_delete<>'1' " + search;
+
+ dynamicParams.Add("@repairstand_code", repairstand_code);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ for (int i = 0; i < data.Rows.Count; i++)
+ {
+ StandEqp rout = new StandEqp();
+ rout.code = data.Rows[i]["WKSP_CODE"].ToString();
+ rout.name = data.Rows[i]["WKSP_NAME"].ToString();
+ rout.type = data.Rows[i]["TYPE"].ToString();
+ rout.flag = data.Rows[i]["FLAG"].ToString();
+ rout.children = new List<StandEqpCn>();
+ //鏍规嵁杞﹂棿缂栫爜鏌ユ壘璁惧(鍖呭惈宸插叧鑱旀爣璇�)
+ //sql = @"select A.code,A.name,'E' as type,(case when B.eqp_code is null then 'N' else 'Y' end) flag
+ // from TEqpInfo A
+ // left join(
+ // select distinct A.eqp_code from TEqpmai_Eqp A
+ // inner join TEqpInfo B on A.eqp_code=B.code
+ // where A.eapmai_code=@repairstand_code and A.is_delete<>'1' and B.is_delete<>'1'
+ // ) B on A.code=B.eqp_code where A.wksp_code=@wkspcode and A.is_delete<>'1'";
+ sql = @"select * from(
+ select AA.code,AA.name,'E' as type,(case when BB.eapmai_code is null then 'N' else 'Y' end) flag,(case when AA.eapmai_code is null then 'N' else 'Y' end) flage1
+ from(
+ select A.code,A.name,'' as eapmai_code
+ from TEqpInfo A
+ where A.wksp_code=@wkspcode and A.is_delete<>'1'
+ ) as AA
+ left join (
+ select A.code,A.name,B.eapmai_code
+ from TEqpInfo A
+ inner join TEqpmai_Eqp B on A.code=B.eqp_code
+ where A.wksp_code=@wkspcode and B.eapmai_code=@repairstand_code and A.is_delete<>'1'
+ ) as BB on AA.code=BB.code
+ ) as CC "; //where case when flag ='N' and flage1 ='Y' then 0 else 1 end=1
+ dynamicParams.Add("@repairstand_code", repairstand_code);
+ dynamicParams.Add("@wkspcode", data.Rows[i]["WKSP_CODE"].ToString());
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ for (int j = 0; j < data0.Rows.Count; j++)
+ {
+ StandEqpCn cn = new StandEqpCn();
+ cn.code = data0.Rows[j]["CODE"].ToString();//璁惧缂栫爜
+ cn.name = data0.Rows[j]["NAME"].ToString();//璁惧鍚嶇О
+ cn.type = data0.Rows[j]["TYPE"].ToString();//宸ヤ綔绔欑被鍨�(E:璁惧 W:澶栧崗渚涙柟)
+ cn.flag = data0.Rows[j]["FLAG"].ToString();//鍏宠仈鏍囪瘑
+ rout.children.Add(cn);
+ }
+ list.Add(rout);
+ }
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = list;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region [璁惧淇濆吇鏍囧噯鍏宠仈宸ヤ綔绔欐彁浜
+ public static ToMessage SaveDeviceRepairStanedAssociationEqp(string stu_torgcode, string stu_torgtypecode, string repairstand_code, string username, List<ObjectData> json)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ try
+ {
+ list.Clear();
+ switch (stu_torgtypecode)
+ {
+ case "":
+ //娓呴櫎璁惧淇濆吇鏍囧噯鍏宠仈璁惧琛ㄦ暟鎹�
+ sql = @"delete TEqpmai_Eqp where eapmai_code=@repairstand_code";
+ list.Add(new { str = sql, parm = new { repairstand_code = repairstand_code } });
+ break;
+ case "D":
+ //娓呴櫎璁惧淇濆吇鏍囧噯鍏宠仈璁惧琛ㄦ暟鎹�
+ sql = @"delete from TEqpmai_Eqp where id in (select A.id from TEqpmai_Eqp A
+ left join TOrganization T on A.torg_code=T.org_code
+ left join TOrganization as L on T.parent_id=L.id
+ where 1=1 and A.eapmai_code=@repairstand_code and L.org_code=@stu_torgcode)";
+ list.Add(new { str = sql, parm = new { repairstand_code = repairstand_code, stu_torgcode = stu_torgcode } });
+ break;
+ case "W":
+ //娓呴櫎璁惧淇濆吇鏍囧噯鍏宠仈璁惧琛ㄦ暟鎹�
+ sql = @"delete from TEqpmai_Eqp where id in (select A.id from TEqpmai_Eqp A
+ left join TOrganization T on A.torg_code=T.org_code
+ left join TOrganization as L on T.parent_id=L.id
+ where 1=1 and A.eapmai_code=@repairstand_code and L.org_code=@stu_torgcode)";
+ list.Add(new { str = sql, parm = new { repairstand_code = repairstand_code, stu_torgcode = stu_torgcode } });
+ break;
+ }
+ if (json != null && json.Count > 0)
+ {
+ //寰幆鍐欏叆璁惧淇濆吇鏍囧噯鍏宠仈璁惧琛�
+ for (int i = 0; i < json.Count; i++)
+ {
+ sql = @"insert into TEqpmai_Eqp(eapmai_code,eqp_code,lm_user,lm_date,torg_code) values(@repairstand_code,@eqp_code,@lm_user,@lm_date,@torg_code)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ eqp_code = json[i].code,
+ repairstand_code = repairstand_code,
+ lm_user = username,
+ lm_date = DateTime.Now.ToString(),
+ torg_code = json[i].flag
+ }
+ });
+ }
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[璁惧鐐规璁板綍鏌ヨ]
+ public static ToMessage DeviceCheckTakeSearch(string stu_torgcode, string description, string wkshopcode, string eqpcode, string eqpname, string stanedname, string checkuser, string checkopendate, string checkclosedate, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (wkshopcode != "" && wkshopcode != null)
+ {
+ search += "and T.org_code=@wkshopcode ";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ }
+ else
+ {
+ switch (description)
+ {
+ case "":
+ search += "and T.description=@description ";
+ dynamicParams.Add("@description", "W");
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ }
+ }
+ if (eqpcode != "" && eqpcode != null)
+ {
+ search += "and A.eqp_code like '%'+@eqpcode+'%' ";
+ dynamicParams.Add("@eqpcode", eqpcode);
+ }
+ if (eqpname != "" && eqpname != null)
+ {
+ search += "and E.name like '%'+@eqpname+'%' ";
+ dynamicParams.Add("@eqpname", eqpname);
+ }
+ if (stanedname != "" && stanedname != null)
+ {
+ search += "and M.name like '%'+@stanedname+'%' ";
+ dynamicParams.Add("@stanedname", stanedname);
+ }
+ if (checkuser != "" && checkuser != null)
+ {
+ search += "and A.chk_user like '%'+@checkuser+'%' ";
+ dynamicParams.Add("@checkuser", checkuser);
+ }
+ if (checkopendate != "" && checkopendate != null)
+ {
+ search += "and A.chk_date between @checkopendate and @checkclosedate ";
+ dynamicParams.Add("@checkopendate", checkopendate + " 00:00:00");
+ dynamicParams.Add("@checkclosedate", checkclosedate + " 23:59:59");
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ //search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.djwo,T.org_code,T.org_name,A.eqp_code,E.name as eqp_name,M.code as stanedcode,M.name as stanedname,
+ A.chk_user,A.chk_result,A.chk_date
+ from TEqpchk_Proc_Main A
+ left join TEqpInfo E on A.eqp_code=E.code
+ left join TEqpchk_Main M on A.eqpchkmain_code=M.code
+ left join TOrganization T on E.wksp_code=T.org_code
+ left join TOrganization as L on T.parent_id=L.id
+ where T.description='W' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧鐐规璁板綍鏄庣粏鏌ヨ]
+ public static ToMessage DeviceCheckSubTakeSearch(string djwo)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select A.seq,T.code as itemcode,T.name as itemname,A.result,A.chk_value,A.remark
+ from TEqpchk_Proc_Deta A
+ left join TEqpchk_Item T on A.eqpchkdeta_code=T.code
+ where A.djwo=@djwo";
+ dynamicParams.Add("@djwo", djwo);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧鐐规璁板綍瀵煎嚭]
+ public static ToMessage DeviceCheckTakeOutExcel(string stu_torgcode, string description, string wkshopcode, string eqpcode, string eqpname, string stanedname, string checkuser, string checkopendate, string checkclosedate)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (wkshopcode != "" && wkshopcode != null)
+ {
+ search += "and T.org_code=@wkshopcode ";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ }
+ else
+ {
+ switch (description)
+ {
+ case "":
+ search += "and T.description=@description ";
+ dynamicParams.Add("@description", "W");
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ }
+ }
+ if (eqpcode != "" && eqpcode != null)
+ {
+ search += "and A.eqp_code like '%'+@eqpcode+'%' ";
+ dynamicParams.Add("@eqpcode", eqpcode);
+ }
+ if (eqpname != "" && eqpname != null)
+ {
+ search += "and E.name like '%'+@eqpname+'%' ";
+ dynamicParams.Add("@eqpname", eqpname);
+ }
+ if (stanedname != "" && stanedname != null)
+ {
+ search += "and M.name like '%'+@stanedname+'%' ";
+ dynamicParams.Add("@stanedname", stanedname);
+ }
+ if (checkuser != "" && checkuser != null)
+ {
+ search += "and A.chk_user like '%'+@checkuser+'%' ";
+ dynamicParams.Add("@checkuser", checkuser);
+ }
+ if (checkopendate != "" && checkopendate != null)
+ {
+ search += "and A.chk_date between @checkopendate and @checkclosedate ";
+ dynamicParams.Add("@checkopendate", checkopendate + " 00:00:00");
+ dynamicParams.Add("@checkclosedate", checkclosedate + " 23:59:59");
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ //search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.djwo ORDER BY B.eqpchkdeta_code) = 1 THEN A.djwo
+ ELSE ''END AS '鐐规鍗曞彿',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY E.wksp_code ORDER BY B.eqpchkdeta_code) = 1 THEN T.org_name
+ ELSE ''END AS '鐢熶骇杞﹂棿',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.eqp_code ORDER BY B.eqpchkdeta_code) = 1 THEN A.eqp_code
+ ELSE ''END AS '璁惧缂栧彿',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.eqp_code ORDER BY B.eqpchkdeta_code) = 1 THEN E.name
+ ELSE ''END AS '璁惧鍚嶇О',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.eqpchkmain_code ORDER BY B.eqpchkdeta_code) = 1 THEN A.eqpchkmain_code
+ ELSE ''END AS '鐐规鏍囧噯缂栫爜',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.eqpchkmain_code ORDER BY B.eqpchkdeta_code) = 1 THEN M.name
+ ELSE ''END AS '鐐规鏍囧噯鍚嶇О',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.chk_user ORDER BY B.eqpchkdeta_code) = 1 THEN A.chk_user
+ ELSE ''END AS '妫�楠屼汉鍛�',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.chk_result ORDER BY B.eqpchkdeta_code) = 1 THEN A.chk_result
+ ELSE ''END AS '妫�楠岀粨鏋�',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.chk_date ORDER BY B.eqpchkdeta_code) = 1 THEN A.chk_date
+ END AS '妫�楠屾椂闂�',
+ B.seq as '鐐规閮ㄤ綅搴忓彿',H.code '鐐规閮ㄤ綅缂栫爜',H.name '鐐规閮ㄤ綅鍚嶇О',B.result '鐐规缁撴灉',B.chk_value '鏁板��',B.remark '澶囨敞'
+ from TEqpchk_Proc_Main A
+ left join TEqpchk_Proc_Deta B on A.djwo=B.djwo
+ left join TEqpInfo E on A.eqp_code=E.code
+ left join TEqpchk_Main M on A.eqpchkmain_code=M.code
+ left join TOrganization T on E.wksp_code=T.org_code
+ left join TOrganization as L on T.parent_id=L.id
+ left join TEqpchk_Item H on B.eqpchkdeta_code=H.code
+ where T.description='W' " + search;
+ DataTable data = DapperHelper.selectdata(sql, dynamicParams);
+ data.TableName = "Table"; //璁剧疆DataTable鐨勫悕绉�
+ string msg = DownLoad.DataTableToExcel(data, "宸ュ簭妫�楠岃褰�");
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = msg;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[璁惧淇濆吇璁板綍鏌ヨ]
+ public static ToMessage DeviceCheckTakeSearch(string stu_torgcode, string description, string wkshopcode, string eqpcode, string eqpname, string stanedname, string repairuser, string repairopendate, string repairclosedate, string repairresult, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (wkshopcode != "" && wkshopcode != null)
+ {
+ search += "and T.org_code=@wkshopcode ";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ }
+ else
+ {
+ switch (description)
+ {
+ case "":
+ search += "and T.description=@description ";
+ dynamicParams.Add("@description", "W");
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ }
+ }
+ if (eqpcode != "" && eqpcode != null)
+ {
+ search += "and A.eqp_code like '%'+@eqpcode+'%' ";
+ dynamicParams.Add("@eqpcode", eqpcode);
+ }
+ if (eqpname != "" && eqpname != null)
+ {
+ search += "and E.name like '%'+@eqpname+'%' ";
+ dynamicParams.Add("@eqpname", eqpname);
+ }
+ if (stanedname != "" && stanedname != null)
+ {
+ search += "and M.name like '%'+@stanedname+'%' ";
+ dynamicParams.Add("@stanedname", stanedname);
+ }
+ if (repairuser != "" && repairuser != null)
+ {
+ search += "and A.maint_user like '%'+@repairuser+'%' ";
+ dynamicParams.Add("@repairuser", repairuser);
+ }
+ if (repairopendate != "" && repairopendate != null)
+ {
+ search += "and A.maint_date between @repairopendate and @repairclosedate ";
+ dynamicParams.Add("@repairopendate", repairopendate + " 00:00:00");
+ dynamicParams.Add("@repairclosedate", repairclosedate + " 23:59:59");
+ }
+ if (repairresult != "" && repairresult != null)
+ {
+ search += "and A.maint_result=@repairresult ";
+ dynamicParams.Add("@repairresult", repairresult);
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ //search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.bywo,T.org_code,T.org_name,A.eqp_code,E.name as eqp_name,M.code as stanedcode,M.name as stanedname,A.maint_cyc,
+ A.maint_user,A.maint_result,A.maint_date
+ from TEqpmaint_Proc_Main A
+ left join TEqpInfo E on A.eqp_code=E.code
+ left join TEqpmai_Main M on A.eqpmaint_code=M.code
+ left join TOrganization T on E.wksp_code=T.org_code
+ left join TOrganization as L on T.parent_id=L.id
+ where T.description='W' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧淇濆吇璁板綍鏄庣粏鏌ヨ]
+ public static ToMessage DeviceRepairSubTakeSearch(string bywo)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select A.seq,T.code as itemcode,T.name as itemname,A.result,A.maint_value,A.remark
+ from TEqpmaint_Proc_Deta A
+ left join TEqpmai_Item T on A.eqpmaideta_code=T.code
+ where A.bywo=@bywo";
+ dynamicParams.Add("@bywo", bywo);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧淇濆吇璁板綍瀵煎嚭]
+ public static ToMessage DeviceRepairTakeOutExcel(string stu_torgcode, string description, string wkshopcode, string eqpcode, string eqpname, string stanedname, string repairuser, string repairopendate, string repairclosedate, string repairresult)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (wkshopcode != "" && wkshopcode != null)
+ {
+ search += "and T.org_code=@wkshopcode ";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ }
+ else
+ {
+ switch (description)
+ {
+ case "":
+ search += "and T.description=@description ";
+ dynamicParams.Add("@description", "W");
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ }
+ }
+ if (eqpcode != "" && eqpcode != null)
+ {
+ search += "and A.eqp_code like '%'+@eqpcode+'%' ";
+ dynamicParams.Add("@eqpcode", eqpcode);
+ }
+ if (eqpname != "" && eqpname != null)
+ {
+ search += "and E.name like '%'+@eqpname+'%' ";
+ dynamicParams.Add("@eqpname", eqpname);
+ }
+ if (stanedname != "" && stanedname != null)
+ {
+ search += "and M.name like '%'+@stanedname+'%' ";
+ dynamicParams.Add("@stanedname", stanedname);
+ }
+ if (repairuser != "" && repairuser != null)
+ {
+ search += "and A.maint_user like '%'+@repairuser+'%' ";
+ dynamicParams.Add("@repairuser", repairuser);
+ }
+ if (repairopendate != "" && repairopendate != null)
+ {
+ search += "and A.chk_date between @repairopendate and @repairclosedate ";
+ dynamicParams.Add("@repairopendate", repairopendate + " 00:00:00");
+ dynamicParams.Add("@repairclosedate", repairclosedate + " 23:59:59");
+ }
+ if (repairresult != "" && repairresult != null)
+ {
+ search += "and A.maint_result=@repairresult ";
+ dynamicParams.Add("@repairresult", repairresult);
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ //search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.bywo ORDER BY B.eqpmaideta_code) = 1 THEN A.bywo
+ ELSE ''END AS '淇濆吇鍗曞彿',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY E.wksp_code ORDER BY B.eqpmaideta_code) = 1 THEN T.org_name
+ ELSE ''END AS '鐢熶骇杞﹂棿',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.eqp_code ORDER BY B.eqpmaideta_code) = 1 THEN A.eqp_code
+ ELSE ''END AS '璁惧缂栧彿',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.eqp_code ORDER BY B.eqpmaideta_code) = 1 THEN E.name
+ ELSE ''END AS '璁惧鍚嶇О',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.eqpmaint_code ORDER BY B.eqpmaideta_code) = 1 THEN A.eqpmaint_code
+ ELSE ''END AS '淇濆吇鏍囧噯缂栫爜',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.eqpmaint_code ORDER BY B.eqpmaideta_code) = 1 THEN M.name
+ ELSE ''END AS '淇濆吇鏍囧噯鍚嶇О',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.maint_cyc ORDER BY B.eqpmaideta_code) = 1 THEN A.maint_cyc
+ ELSE ''END AS '淇濆吇鍛ㄦ湡',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.maint_user ORDER BY B.eqpmaideta_code) = 1 THEN A.maint_user
+ ELSE ''END AS '淇濆吇浜哄憳',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.maint_result ORDER BY B.eqpmaideta_code) = 1 THEN A.maint_result
+ ELSE ''END AS '淇濆吇缁撴灉',
+ CASE WHEN
+ ROW_NUMBER() OVER (PARTITION BY A.maint_date ORDER BY B.eqpmaideta_code) = 1 THEN A.maint_date
+ END AS '淇濆吇鏃堕棿',
+ B.seq as '淇濆吇閮ㄤ綅搴忓彿',H.code '淇濆吇閮ㄤ綅缂栫爜',H.name '淇濆吇閮ㄤ綅鍚嶇О',B.result '淇濆吇缁撴灉',B.maint_value '鏁板��',B.remark '澶囨敞'
+ from TEqpmaint_Proc_Main A
+ left join TEqpmaint_Proc_Deta B on A.bywo=B.bywo
+ left join TEqpInfo E on A.eqp_code=E.code
+ left join TEqpmai_Main M on A.eqpmaint_code=M.code
+ left join TOrganization T on E.wksp_code=T.org_code
+ left join TOrganization as L on T.parent_id=L.id
+ left join TEqpmai_Item H on B.eqpmaideta_code=H.code
+ where T.description='W' " + search;
+ DataTable data = DapperHelper.selectdata(sql, dynamicParams);
+ data.TableName = "Table"; //璁剧疆DataTable鐨勫悕绉�
+ string msg = DownLoad.DataTableToExcel(data, "宸ュ簭妫�楠岃褰�");
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = msg;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[璁惧缁翠慨璁板綍鏌ヨ]
+ public static ToMessage DeviceUpdateSearch(string stu_torgcode, string description, string wkshopcode, string eqpcode, string eqpname, string reportuser, string repairuser, string vrifcatuser, string reportopendate, string reportclosedate, string repairopendate, string repairclosedate, string vrifcatopendate, string vrifcatclosedate, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (wkshopcode != "" && wkshopcode != null)
+ {
+ search += "and A.wksp_code=@wkshopcode ";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ }
+ else
+ {
+ switch (description)
+ {
+ case "":
+ search += "and T.description=@description ";
+ dynamicParams.Add("@description", "W");
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ }
+ }
+ if (eqpcode != "" && eqpcode != null)
+ {
+ search += "and A.eqp_code like '%'+@eqpcode+'%' ";
+ dynamicParams.Add("@eqpcode", eqpcode);
+ }
+ if (eqpname != "" && eqpname != null)
+ {
+ search += "and E.name like '%'+@eqpname+'%' ";
+ dynamicParams.Add("@eqpname", eqpname);
+ }
+ if (reportuser != "" && reportuser != null)
+ {
+ search += "and B.request_person like '%'+@reportuser+'%' ";
+ dynamicParams.Add("@reportuser", reportuser);
+ }
+ if (repairuser != "" && repairuser != null)
+ {
+ search += "and A.repair_person like '%'+@repairuser+'%' ";
+ dynamicParams.Add("@repairuser", repairuser);
+ }
+ if (vrifcatuser != "" && vrifcatuser != null)
+ {
+ search += "and A.verify_person like '%'+@vrifcatuser+'%' ";
+ dynamicParams.Add("@vrifcatuser", vrifcatuser);
+ }
+ if (reportopendate != "" && reportopendate != null)
+ {
+ search += "and B.request_date between @reportopendate and @reportclosedate ";
+ dynamicParams.Add("@reportopendate", reportopendate + " 00:00:00");
+ dynamicParams.Add("@reportclosedate", reportclosedate + " 23:59:59");
+ }
+ if (repairopendate != "" && repairopendate != null)
+ {
+ search += "and A.repair_date between @repairopendate and @repairclosedate ";
+ dynamicParams.Add("@repairopendate", repairopendate + " 00:00:00");
+ dynamicParams.Add("@repairclosedate", repairclosedate + " 23:59:59");
+ }
+ if (vrifcatopendate != "" && vrifcatopendate != null)
+ {
+ search += "and A.verify_date between @vrifcatopendate and @vrifcatclosedate ";
+ dynamicParams.Add("@vrifcatopendate", vrifcatopendate + " 00:00:00");
+ dynamicParams.Add("@vrifcatclosedate", vrifcatclosedate + " 23:59:59");
+ }
+
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ //search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.repair_code,A.wksp_code,T.org_name as wksp_name,A.eqp_code,E.name as eqp_name,B.request_person,B.request_date,
+ A.repair_person,A.repair_date,CAST(datediff(minute, B.request_date,A.repair_date)/60.0 AS decimal(9,1)) as cycleDate,
+ A.verify_person,A.verify_date,(case when A.verify_result='OK' then '閫氳繃' when A.verify_result='NG' then '涓嶉�氳繃' end)as verify_result
+ from TEqp_Repair A
+ left join TEqp_RepairRequest B on A.source_wo=B.docu_code
+ left join TEqpInfo E on A.eqp_code=E.code
+ left join TOrganization T on A.wksp_code=T.org_code
+ left join TOrganization as L on T.parent_id=L.id
+ where T.description='W' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧缁翠慨璁板綍鏄庣粏鏌ヨ]
+ public static ToMessage DeviceUpdateSubSearch(string repair_code)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ Dictionary<object, object> Dict = new Dictionary<object, object>();
+ try
+ {
+ //鑾峰彇璁惧鎶ヤ慨鐢宠鏁版嵁
+ sql = @"select B.docu_code,
+ (
+ case when B.source='A' then '璁惧鐐规'
+ when B.source='B' then '璁惧淇濆吇'
+ when B.source='C' then '瀹夌伅鍛煎彨'
+ when B.source='C' then '鎵嬪伐鍒涘缓' end
+ ) as source,B.failure_descript from TEqp_Repair A
+ left join TEqp_RepairRequest B on A.source_wo=B.docu_code
+ where A.repair_code=@repair_code";
+ dynamicParams.Add("@repair_code", repair_code);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ DeviceReport report = new DeviceReport();
+ report.faultsource = data.Rows[0]["source"].ToString();
+ report.faultdescr = data.Rows[0]["failure_descript"].ToString();
+ //鑾峰彇璁惧鎶ヤ慨鐢宠鍥剧墖鏁版嵁
+ sql = @"select M.img1url from TEqp_Repair A
+ left join TEqp_RepairRequest B on A.source_wo=B.docu_code
+ left join TEqp_RepairImage M on B.docu_code=M.source_wo
+ where A.repair_code=@repair_code and M.wo_type='REPA'";
+ dynamicParams.Add("@repair_code", repair_code);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ report.faultimage = data0;
+ Dict.Add("data1", report);
+
+ //鑾峰彇璁惧缁翠慨鏁版嵁
+ sql = @"select A.failure_descript,A.is_shutdown,A.repair_content,A.repair_part from TEqp_Repair A
+ left join TEqp_RepairRequest B on A.source_wo=B.docu_code
+ where A.repair_code=@repair_code";
+ dynamicParams.Add("@repair_code", repair_code);
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ DeviceRepair repair = new DeviceRepair();
+ repair.faultdescr = data1.Rows[0]["failure_descript"].ToString();
+ repair.isstoprepair = data1.Rows[0]["is_shutdown"].ToString();
+ repair.repaircontent = data1.Rows[0]["repair_content"].ToString();
+ repair.repairpart = data1.Rows[0]["repair_part"].ToString();
+ //鑾峰彇璁惧缁翠慨鍥剧墖鏁版嵁
+ sql = @"select M.img1url,M.img2url from TEqp_Repair A
+ left join TEqp_RepairImage M on A.repair_code=M.source_wo
+ where A.repair_code=@repair_code and M.wo_type='COMP'";
+ dynamicParams.Add("@repair_code", repair_code);
+ var data3 = DapperHelper.selectdata(sql, dynamicParams);
+ repair.repairimage = data3;
+ Dict.Add("data2", repair);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = Dict;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[璁惧缁翠慨璁板綍瀵煎嚭]
+ public static ToMessage DeviceUpdateOutExcel(string stu_torgcode, string description, string wkshopcode, string eqpcode, string eqpname, string reportuser, string repairuser, string vrifcatuser, string reportopendate, string reportclosedate, string repairopendate, string repairclosedate, string vrifcatopendate, string vrifcatclosedate)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (wkshopcode != "" && wkshopcode != null)
+ {
+ search += "and A.wksp_code=@wkshopcode ";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ }
+ else
+ {
+ switch (description)
+ {
+ case "":
+ search += "and T.description=@description ";
+ dynamicParams.Add("@description", "W");
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ }
+ }
+ if (eqpcode != "" && eqpcode != null)
+ {
+ search += "and A.eqp_code like '%'+@eqpcode+'%' ";
+ dynamicParams.Add("@eqpcode", eqpcode);
+ }
+ if (eqpname != "" && eqpname != null)
+ {
+ search += "and E.name like '%'+@eqpname+'%' ";
+ dynamicParams.Add("@eqpname", eqpname);
+ }
+ if (reportuser != "" && reportuser != null)
+ {
+ search += "and B.request_person like '%'+@reportuser+'%' ";
+ dynamicParams.Add("@reportuser", reportuser);
+ }
+ if (repairuser != "" && repairuser != null)
+ {
+ search += "and A.repair_person like '%'+@repairuser+'%' ";
+ dynamicParams.Add("@repairuser", repairuser);
+ }
+ if (vrifcatuser != "" && vrifcatuser != null)
+ {
+ search += "and A.verify_person like '%'+@vrifcatuser+'%' ";
+ dynamicParams.Add("@vrifcatuser", vrifcatuser);
+ }
+ if (reportopendate != "" && reportopendate != null)
+ {
+ search += "and B.request_date between @reportopendate and @reportclosedate ";
+ dynamicParams.Add("@reportopendate", reportopendate + " 00:00:00");
+ dynamicParams.Add("@reportclosedate", reportclosedate + " 23:59:59");
+ }
+ if (repairopendate != "" && repairopendate != null)
+ {
+ search += "and A.repair_date between @repairopendate and @repairclosedate ";
+ dynamicParams.Add("@repairopendate", repairopendate + " 00:00:00");
+ dynamicParams.Add("@repairclosedate", repairclosedate + " 23:59:59");
+ }
+ if (vrifcatopendate != "" && vrifcatopendate != null)
+ {
+ search += "and A.verify_date between @vrifcatopendate and @vrifcatclosedate ";
+ dynamicParams.Add("@vrifcatopendate", vrifcatopendate + " 00:00:00");
+ dynamicParams.Add("@vrifcatclosedate", vrifcatclosedate + " 23:59:59");
+ }
+
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ //search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select
+ A.repair_code as '缁翠慨鍗曞彿',
+ T.org_name as '鎵�灞炶溅闂�',
+ A.eqp_code as '璁惧缂栫爜',
+ E.name as '璁惧鍚嶇О',
+ B.request_person as '鎶ヤ慨浜哄憳',
+ B.request_date as '鎶ヤ慨鏃堕棿',
+ A.repair_person as '缁翠慨浜哄憳',
+ A.repair_date as '缁翠慨鏃堕棿',
+ CAST(datediff(minute, B.request_date,A.repair_date)/60.0 AS decimal(9,1)) as '缁翠慨鏃堕暱(灏忔椂)',
+ A.verify_person as '楠岃瘉浜哄憳',
+ A.verify_date as '楠岃瘉鏃堕棿',
+ (case when A.verify_result='OK' then '閫氳繃' when A.verify_result='NG' then '涓嶉�氳繃' end)as '楠岃瘉缁撴灉'
+ from TEqp_Repair A
+ left join TEqp_RepairRequest B on A.source_wo=B.docu_code
+ left join TEqpInfo E on A.eqp_code=E.code
+ left join TOrganization T on A.wksp_code=T.org_code
+ left join TOrganization as L on T.parent_id=L.id
+ where T.description='W'" + search;
+ DataTable data = DapperHelper.selectdata(sql, dynamicParams);
+ data.TableName = "Table"; //璁剧疆DataTable鐨勫悕绉�
+ string msg = DownLoad.DataTableToExcel(data, "璁惧缁翠慨璁板綍");
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = msg;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/DAL/ExcelCheckDAL.cs b/VueWebCoreApi/DLL/DAL/ExcelCheckDAL.cs
new file mode 100644
index 0000000..e6fbee6
--- /dev/null
+++ b/VueWebCoreApi/DLL/DAL/ExcelCheckDAL.cs
@@ -0,0 +1,275 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.DAL
+{
+ public class ExcelCheckDAL
+ {
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+
+ #region銆怑xcel瀵煎叆妯℃澘楠岃瘉銆�
+ public static ToMessage ExcelCheck(string fileCode, string savePath)
+ {
+ string StuCode = "";
+ string Message = "";
+ switch (fileCode)
+ {
+ case "1": //瑙掕壊鏉冮檺
+ Message = ImportExcelData.One(savePath, out StuCode);
+ break;
+ case "2"://鐢ㄦ埛瑙掕壊
+ Message = ImportExcelData.Two(savePath, out StuCode);
+ break;
+ case "3"://宸ヤ綅娓呭崟
+ Message = ImportExcelData.Three(savePath, out StuCode);
+ break;
+ case "4"://寰�鏉ュ崟浣�
+ Message = ImportExcelData.Four(savePath, out StuCode);
+ break;
+ case "6"://浠撳簱銆佸簱浣嶅畾涔�
+ Message = ImportExcelData.SixOne(savePath, out StuCode);
+ break;
+ case "7"://瀹瑰櫒瀹氫箟
+ Message = ImportExcelData.Seven(savePath, out StuCode);
+ break;
+ case "8"://瀛樿揣妗f
+ Message = ImportExcelData.Eight(savePath, out StuCode);
+ break;
+ case "9"://璁惧娓呭崟
+ Message = ImportExcelData.Nine(savePath, out StuCode);
+ break;
+ case "10"://璁惧鐐规椤圭洰
+ Message = ImportExcelData.Ten(savePath, out StuCode);
+ break;
+ case "22"://璁惧鐐规鏍囧噯
+ Message = ImportExcelData.TwentyTwo(savePath, out StuCode);
+ break;
+ case "11"://璁惧淇濆吇椤圭洰
+ Message = ImportExcelData.Eleven(savePath, out StuCode);
+ break;
+ case "23"://璁惧淇濆吇鏍囧噯
+ Message = ImportExcelData.TwentyThree(savePath, out StuCode);
+ break;
+ case "12"://宸ヨ娓呭崟
+ Message = ImportExcelData.Twelve(savePath, out StuCode);
+ break;
+ case "13"://宸ヨ鐐规
+ Message = ImportExcelData.Thirteen(savePath, out StuCode);
+ break;
+ case "14"://宸ヨ淇濆吇
+ Message = ImportExcelData.Fourteen(savePath, out StuCode);
+ break;
+ case "15"://宸ュ簭瀹氫箟
+ Message = ImportExcelData.Fifteen(savePath, out StuCode);
+ break;
+ case "16"://宸ヨ壓璺嚎
+ Message = ImportExcelData.Sixteen(savePath, out StuCode);
+ break;
+ case "24"://鑺傛媿宸ヤ环
+ Message = ImportExcelData.TwentyFour(savePath, out StuCode);
+ break;
+ case "17"://璐ㄦ鏍囧噯
+ Message = ImportExcelData.Seventeen(savePath, out StuCode);
+ break;
+ case "18"://缂洪櫡瀹氫箟
+ Message = ImportExcelData.Eighteen(savePath, out StuCode);
+ break;
+ case "19"://鐢熶骇璁㈠崟
+ Message = ImportExcelData.Nineteen(savePath, out StuCode);
+ break;
+ case "20"://搴撳瓨鏌ヨ
+ Message = ImportExcelData.Twenty(savePath, out StuCode);
+ break;
+ case "21"://鐗╂枡娓呭崟
+ Message = ImportExcelData.TwentyOne(savePath, out StuCode);
+ break;
+ default:
+ StuCode = "300";
+ Message = "妯℃澘缂栫爜閿欒锛�";
+ break;
+ }
+
+
+ mes.code = StuCode;
+ mes.Message = Message;
+
+ return mes;
+ }
+ #endregion
+
+ #region銆怑xcel瀵煎叆鏁版嵁楠岃瘉銆�
+ public static List<ExcelErro> ExcelCheckData(string fileCode, string savePath, out string stuCode, out string message, out int count)
+ {
+ stuCode = "";
+ message = "";
+ count = 0;
+ List<ExcelErro> list = new List<ExcelErro>();
+ switch (fileCode)
+ {
+ case "1": //瑙掕壊鏉冮檺
+ list = ImportExcelData.OneData(savePath, out stuCode, out message, out count);
+ break;
+ case "2"://鐢ㄦ埛瑙掕壊
+ list = ImportExcelData.TwoData(savePath, out stuCode, out message, out count);
+ break;
+ case "3"://宸ヤ綅娓呭崟
+ list = ImportExcelData.ThreeData(savePath, out stuCode, out message, out count);
+ break;
+ case "4"://寰�鏉ュ崟浣嶆竻鍗�
+ list = ImportExcelData.FourData(savePath, out stuCode, out message, out count);
+ break;
+ case "6"://浠撳簱銆佸簱浣嶅畾涔�
+ list = ImportExcelData.SixOneData(savePath, out stuCode, out message, out count);
+ break;
+ case "7"://瀹瑰櫒瀹氫箟
+ list = ImportExcelData.SevenData(savePath, out stuCode, out message, out count);
+ break;
+ case "8"://瀛樿揣妗f
+ list = ImportExcelData.EightData(savePath, out stuCode, out message, out count);
+ break;
+ case "9"://璁惧娓呭崟
+ list = ImportExcelData.NineData(savePath, out stuCode, out message, out count);
+ break;
+ case "10"://璁惧鐐规椤圭洰
+ list = ImportExcelData.TenData(savePath, out stuCode, out message, out count);
+ break;
+ case "22"://璁惧鐐规鏍囧噯
+ list = ImportExcelData.TwentyTwoData(savePath, out stuCode, out message, out count);
+ break;
+ case "11"://璁惧淇濆吇椤圭洰
+ list = ImportExcelData.ElevenData(savePath, out stuCode, out message, out count);
+ break;
+ case "23"://璁惧淇濆吇鏍囧噯
+ list = ImportExcelData.TwentyThreeData(savePath, out stuCode, out message, out count);
+ break;
+ case "12"://宸ヨ娓呭崟
+ list = ImportExcelData.TwelveData(savePath, out stuCode, out message, out count);
+ break;
+ case "13"://宸ヨ鐐规
+ list = ImportExcelData.ThirteenData(savePath, out stuCode, out message, out count);
+ break;
+ case "14"://宸ヨ淇濆吇
+ list = ImportExcelData.FourteenData(savePath, out stuCode, out message, out count);
+ break;
+ case "15"://宸ュ簭瀹氫箟
+ list = ImportExcelData.FifteenData(savePath, out stuCode, out message, out count);
+ break;
+ case "16"://宸ヨ壓璺嚎
+ list = ImportExcelData.SixteenData(savePath, out stuCode, out message, out count);
+ break;
+ case "24"://鑺傛媿宸ヤ环
+ list = ImportExcelData.TwentyFourData(savePath, out stuCode, out message, out count);
+ break;
+ case "17"://璐ㄦ鏍囧噯
+ list = ImportExcelData.SeventeenData(savePath, out stuCode, out message, out count);
+ break;
+ case "18"://缂洪櫡瀹氫箟
+ list = ImportExcelData.EighteenData(savePath, out stuCode, out message, out count);
+ break;
+ case "19"://鐢熶骇璁㈠崟
+ list = ImportExcelData.NineteenData(savePath, out stuCode, out message, out count);
+ break;
+ case "20"://搴撳瓨鏌ヨ
+ list = ImportExcelData.TwentyData(savePath, out stuCode, out message, out count);
+ break;
+ case "21"://鐗╂枡娓呭崟
+ list = ImportExcelData.TwentyOneData(savePath, out stuCode, out message, out count);
+ break;
+ default:
+ break;
+ }
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel瀵煎叆鏁版嵁楠岃瘉銆�
+ public static ToMessage ExcelImportSubmit(string FileCode, string savePath, string User)
+ {
+ string StuCode = "";
+ string Message = "";
+ switch (FileCode)
+ {
+ case "1": //瑙掕壊鏉冮檺
+ Message = ImportExcelData.OneSubmit(savePath, User, out StuCode);
+ break;
+ case "2"://鐢ㄦ埛瑙掕壊
+ Message = ImportExcelData.TwoSubmit(savePath, User, out StuCode);
+ break;
+ case "3"://宸ヤ綅娓呭崟
+ Message = ImportExcelData.ThreeSubmit(savePath, User, out StuCode);
+ break;
+ case "4"://寰�鏉ュ崟浣嶆竻鍗�
+ Message = ImportExcelData.FourSubmit(savePath, User, out StuCode);
+ break;
+ case "6"://浠撳簱銆佸簱浣嶅畾涔�
+ Message = ImportExcelData.SixOneSubmit(savePath, User, out StuCode);
+ break;
+ case "7"://瀹瑰櫒瀹氫箟
+ Message = ImportExcelData.SevenSubmit(savePath, User, out StuCode);
+ break;
+ case "8"://瀛樿揣妗f
+ Message = ImportExcelData.EightSubmit(savePath, User, out StuCode);
+ break;
+ case "9"://璁惧娓呭崟
+ Message = ImportExcelData.NineSubmit(savePath, User, out StuCode);
+ break;
+ case "10"://璁惧鐐规椤圭洰
+ Message = ImportExcelData.TenSubmit(savePath, User, out StuCode);
+ break;
+ case "22"://璁惧鐐规鏍囧噯
+ Message = ImportExcelData.TwentyTwoSubmit(savePath, User, out StuCode);
+ break;
+ case "11"://璁惧淇濆吇椤圭洰
+ Message = ImportExcelData.ElevenSubmit(savePath, User, out StuCode);
+ break;
+ case "23"://璁惧淇濆吇鏍囧噯
+ Message = ImportExcelData.TwentyThreeSubmit(savePath, User, out StuCode);
+ break;
+ case "12"://宸ヨ娓呭崟
+ Message = ImportExcelData.TwelveSubmit(savePath, User, out StuCode);
+ break;
+ case "13"://宸ヨ鐐规
+ Message = ImportExcelData.ThirteenSubmit(savePath, User, out StuCode);
+ break;
+ case "14"://宸ヨ淇濆吇
+ Message = ImportExcelData.FourteenSubmit(savePath, User, out StuCode);
+ break;
+ case "15"://宸ュ簭瀹氫箟
+ Message = ImportExcelData.FifteenSubmit(savePath, User, out StuCode);
+ break;
+ case "16"://宸ヨ壓璺嚎
+ Message = ImportExcelData.SixteenSubmit(savePath, User, out StuCode);
+ break;
+ case "24"://鑺傛媿宸ヤ环
+ Message = ImportExcelData.TwentyFourSubmit(savePath, User, out StuCode);
+ break;
+ case "17"://璐ㄦ鏍囧噯
+ Message = ImportExcelData.SeventeenSubmit(savePath, User, out StuCode);
+ break;
+ case "18"://缂洪櫡瀹氫箟
+ Message = ImportExcelData.EighteenSubmit(savePath, User, out StuCode);
+ break;
+ case "19"://鐢熶骇璁㈠崟
+ Message = ImportExcelData.NineteenSubmit(savePath, User, out StuCode);
+ break;
+ case "20"://搴撳瓨鏌ヨ
+ Message = ImportExcelData.TwentySubmit(savePath, User, out StuCode);
+ break;
+ case "21"://鐗╂枡娓呭崟
+ Message = ImportExcelData.TwentyOneSubmit(savePath, User, out StuCode);
+ break;
+ default:
+ break;
+ }
+
+ mes.code = StuCode;
+ mes.Message = Message;
+ return mes;
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/DAL/GeneralBasicDataDAL.cs b/VueWebCoreApi/DLL/DAL/GeneralBasicDataDAL.cs
new file mode 100644
index 0000000..07e77e2
--- /dev/null
+++ b/VueWebCoreApi/DLL/DAL/GeneralBasicDataDAL.cs
@@ -0,0 +1,190 @@
+锘縰sing Dapper;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.DAL
+{
+ public class GeneralBasicDataDAL
+ {
+ public static DataTable dt; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static bool res; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+ public static string strProcName = ""; //瀹氫箟鍏ㄥ眬sql鍙橀噺
+ public static List<SqlParameter> listStr = new List<SqlParameter>(); //瀹氫箟鍏ㄥ眬鍙傛暟闆嗗悎
+ public static SqlParameter[] parameters; //瀹氫箟鍏ㄥ眬SqlParameter鍙傛暟鏁扮粍
+ public static dynamic CompanyCode = AppSetting.GetAppSetting("CompanyCode");
+ public static dynamic CompanyName = AppSetting.GetAppSetting("CompanyName");
+
+
+ #region [缁勭粐鏋舵瀯鏌ユ壘]
+ public static ToMessage PrentOrganization()
+ {
+ var sql = "";
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ sql = @"select * from TOrganization where status='Y'";
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region [宀椾綅鍩虹璧勬枡]
+ public static ToMessage PostPermissions()
+ {
+ var sql = "";
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ sql = @"select postcode,postname from TPost where status='Y'";
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region [瑙掕壊鍩虹璧勬枡]
+ public static ToMessage RolePermissions()
+ {
+ var sql = "";
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ sql = @"select rolecode,rolename from TRole where status='Y'";
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region [鐝粍鍩虹璧勬枡]
+ public static ToMessage GroupsPermissions()
+ {
+ var sql = "";
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ sql = @"select usergroupcode,usergroupname from TGroup where status='Y'";
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鎸夐挳鍩虹璧勬枡]
+ public static ToMessage ButtonData()
+ {
+ string sql = "";
+ try
+ {
+ sql = @"select buttoncode,buttonname from TButton";
+ var data = DapperHelper.selecttable(sql);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏃犳寜閽。妗堟暟鎹�!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鏁版嵁鏉冮檺鍩虹璧勬枡]
+ public static ToMessage DataPermissions()
+ {
+ string sql = "";
+ try
+ {
+ sql = @"select datacode,dataname from TData";
+ var data = DapperHelper.selecttable(sql);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏃犳暟鎹潈闄愭。妗堟暟鎹�!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/DAL/LoginDAL.cs b/VueWebCoreApi/DLL/DAL/LoginDAL.cs
new file mode 100644
index 0000000..330b9c1
--- /dev/null
+++ b/VueWebCoreApi/DLL/DAL/LoginDAL.cs
@@ -0,0 +1,498 @@
+锘縰sing Dapper;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.BLL;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Models.RolePermission;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.DAL
+{
+ public class LoginDAL
+ {
+ public static DataTable dt; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static bool res; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+ public static SqlParameter[] parameters; //瀹氫箟鍏ㄥ眬SqlParameter鍙傛暟鏁扮粍
+ public static string fileip = AppSetting.GetAppSetting("FileIP");
+ //鑾峰彇浼佷笟閰嶇疆Enterprise
+ private static readonly string Enterprise = AppSetting.GetAppSetting("Enterprise");
+
+ #region [鐧诲綍鏌ヨ]
+ public static ToMessage LoginSearch(string usercode, string password)
+ {
+ string strProcName = ""; //瀹氫箟灞�閮╯ql鍙橀噺
+ List<SqlParameter> listStr = new List<SqlParameter>(); //瀹氫箟鍙傛暟闆嗗悎
+ try
+ {
+ //鏌ヨ璐﹀彿鏄惁瀛樺湪
+ strProcName = @"select U.id,U.usercode,U.username,U.password,U.storg_code,T.torg_name as storg_name,U.role_code,U.role_datapermissions,U.post_code,U.is_system_admin,U.status
+ from TUser U
+ left join TOrganization T on U.storg_code=T.torg_code
+ where usercode =@usercode and password=@password";
+ //鍒涘缓鍙傛暟
+ listStr.Add(new SqlParameter("@usercode", usercode));
+ listStr.Add(new SqlParameter("@password", password));
+ parameters = listStr.ToArray();
+ listStr.Clear();
+ DataTable dt_ = DBHelper.GetTable(strProcName, parameters);
+ if (dt_.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.Message = "璐﹀彿瀵嗙爜涓嶆纭�!";
+ mes.data = null;
+ return mes;
+ }
+ if (dt_.Rows[0]["status"].ToString() == "N")
+ {
+ mes.code = "300";
+ mes.Message = "褰撳墠璐﹀彿宸插仠鐢�!";
+ mes.data = null;
+ return mes;
+ }
+ //鍒ゆ柇璐﹀彿鏄惁绯荤粺绠$悊鍛樿处鍙�
+ if (dt_.Rows[0]["is_system_admin"].ToString() == "Y")
+ {
+ mes.code = "200";
+ mes.data = dt_;
+ return mes;
+ }
+ //鎵цsql鏌ヨ鐢ㄦ埛鏄惁鎸囧畾缁勭粐
+ if (dt_.Rows[0]["storg_code"].ToString() == "" || dt_.Rows[0]["storg_code"].ToString() == null)
+ {
+ mes.code = "300";
+ mes.Message = "褰撳墠鐢ㄦ埛鏈寚瀹氱粍缁�!";
+ mes.data = null;
+ return mes;
+ }
+ //鎵цsql鏌ヨ鐢ㄦ埛鏄惁鎸囧畾宀椾綅
+ if (dt_.Rows[0]["post_code"].ToString() == "" || dt_.Rows[0]["post_code"].ToString() == null)
+ {
+ mes.code = "300";
+ mes.Message = "褰撳墠鐢ㄦ埛鏈寚瀹氬矖浣�!";
+ mes.data = null;
+ return mes;
+ }
+ //鎵цsql鏌ヨ鐢ㄦ埛鏄惁鎸囧畾瑙掕壊
+ if (dt_.Rows[0]["role_code"].ToString() == "" || dt_.Rows[0]["role_code"].ToString() == null)
+ {
+ mes.code = "300";
+ mes.Message = "褰撳墠鐢ㄦ埛鏈寚瀹氳鑹�!";
+ mes.data = null;
+ return mes;
+ }
+ mes.code = "200";
+ mes.data = dt_;
+ return mes;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.Message = e.Message;
+ mes.data = null;
+ return mes;
+ }
+
+ }
+ #endregion
+
+ #region [鍐欏叆鐧诲綍璁板綍琛╙
+ public static ToMessage LoginBas(string usercode, string oper_type, string description, string type)
+ {
+ var sql = "";
+ var cont = 0;
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"insert into T_Bas_User_Operlog(usercode,oper_date,oper_type,description,origin)
+ values(@usercode,@oper_date,@oper_type,@description,@origin)";
+ dynamicParams.Add("@usercode", usercode);
+ dynamicParams.Add("@oper_date", DateTime.Now.ToString());
+ dynamicParams.Add("@oper_type", oper_type);
+ dynamicParams.Add("@description", description);
+ dynamicParams.Add("@origin", type);
+ cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "璁板綍鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璁板綍澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鏌ヨ鑿滃崟鍔熻兘]
+ public static ToMessage LoginMenu(string usercode, string usertype, User us)
+ {
+ string sql = ""; string strProcName = ""; string result = ""; //瀹氫箟灞�閮╯ql鍙橀噺
+ var dynamicParams = new DynamicParameters();
+ List<SqlParameter> listStr = new List<SqlParameter>(); //瀹氫箟鍙傛暟闆嗗悎
+ try
+ {
+ listStr.Clear();
+ //鏌ヨ鎵�鏈夌殑缁勭粐鏁版嵁
+ sql = @"select * from TOrganization where status='Y' and parent_id<>'0'";
+ var dattorg = DapperHelper.selecttable(sql);
+ if (us.is_system_admin == "Y") //绠$悊鍛樿处鍙�
+ {
+ //鑾峰彇鏉冮檺鍏宠仈琛ㄦ暟鎹�(绠$悊鍛樿处鍙�)
+ sql = @"select jsondate from TRole TR
+ inner join TAuthority TA on TR.rolecode=TA.rolecode
+ where TR.identifying='0' and TA.type=@usertype";
+ dynamicParams.Add("@usertype", usertype);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ List<MenuItem> items = JsonConvert.DeserializeObject<List<MenuItem>>(data.Rows[0]["jsondate"].ToString());
+ // 鑾峰彇鎵�鏈夌殑menucode
+ List<string> menuCodes = items.Select(item => item.MenuCode).ToList();
+ string codeString = string.Join(",", menuCodes);
+ //鏌ヨ鑿滃崟鏁版嵁
+ sql = @"select menucode,menuname,menu_seq,imgurl,'0' as flag,parent_id,is_show
+ from TMenu where Type=@usertype order by menu_seq";
+ dynamicParams.Add("@usertype", usertype);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ string[] codes = codeString.Split(',');
+ // 浣跨敤lambda琛ㄨ揪寮忔煡璇㈠搴旂埗绾х紪鐮佺殑鐖剁骇鑿滃崟鏁版嵁娣诲姞鍒癓ist
+ List<TreeOne> parentMenus = data0.AsEnumerable()
+ .Where(row => codes.Contains(row.Field<string>("menucode")))
+ .Select(row => row.Field<string>("parent_id"))
+ .Distinct()
+ .Select(parentMenuCode => data0.AsEnumerable()
+ .FirstOrDefault(row => row.Field<string>("menucode") == parentMenuCode))
+ .Where(row => row != null).Select(row => new TreeOne
+ {
+ code = row.Field<string>("menucode"),
+ name = row.Field<string>("menuname"),
+ flag = "0",
+ imgurl = fileip + row.Field<string>("imgurl"),
+ is_show= row.Field<string>("is_show")
+ }).ToList(); //.CopyToDataTable();
+ //娣诲姞瀛愯彍鍗曟暟鎹�
+ for (int i = 0; i < parentMenus.Count; i++)
+ {
+ parentMenus[i].children = data0.AsEnumerable().Where(row => codes.Contains(row.Field<string>("menucode")) && row.Field<string>("parent_id") == parentMenus[i].code)
+ .Select(row => new TreeTwo
+ {
+ code = row.Field<string>("menucode"),
+ name = row.Field<string>("menuname"),
+ flag = "0",
+ imgurl = fileip + row.Field<string>("imgurl"),
+ buttoncode = items.Where(m => m.MenuCode == row.Field<string>("menucode")).Select(m => m.ButtonCode).FirstOrDefault(),
+ datacode = items.Where(m => m.MenuCode == row.Field<string>("menucode")).Select(m => m.DataCode).FirstOrDefault(),
+ is_show = row.Field<string>("is_show")
+ }).ToList();
+
+ }
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = parentMenus;
+ return mes;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.Message = "绯荤粺鏈缃彍鍗曡祫鏂�,璇疯仈绯荤鐞嗗憳!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.Message = "褰撳墠璐﹀彿瀵瑰簲瑙掕壊鏈缃姛鑳芥潈闄�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ else
+ {
+ string[] rolecode = Array.ConvertAll<string, string>(us.role_code.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString()); //string鍒嗗壊杞瑂tring[]
+ //鑾峰彇褰撳墠鐢ㄦ埛鎵�灞炲矖浣嶅搴旂殑瑙掕壊鍏宠仈琛ㄦ暟鎹�
+ sql = @"select TD.jsondate from TRole R
+ inner join TAuthority TD on R.rolecode=TD.rolecode
+ where R.rolecode in @rolecode
+ and TD.type=@usertype";
+ dynamicParams.Add("@rolecode", rolecode);
+ dynamicParams.Add("@usertype", usertype);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ List<MenuItem> item = new List<MenuItem>();
+ for (int i = 0; i < data.Rows.Count; i++)
+ {
+ var aa = JsonConvert.DeserializeObject<List<MenuItem>>(data.Rows[i]["jsondate"].ToString());
+ for (int j = 0; j < aa.Count; j++)
+ {
+ item.Add(aa[j]);
+ }
+ }
+ // 鍙栧苟闆�
+ var items = item.GroupBy(m => m.MenuCode).Select(g => new MenuItem
+ {
+ MenuCode = g.Key,
+ ButtonCode = string.Join(",", string.Join(",", g.Select(m => m.ButtonCode)).Split(',').Distinct()),
+ DataCode = string.Join(",", string.Join(",", g.Select(m => m.DataCode=="LEVEL"?us.storg_code:m.DataCode == "PERSON"?us.usercode:m.DataCode)).Split(',')
+ .Distinct().Contains("ALL") ? "ALL": string.Join(",", string.Join(",", g.Select(m => m.DataCode == "LEVEL" ? us.storg_code : m.DataCode == "PERSON" ? us.usercode : m.DataCode)).Split(',').Distinct()))
+ //DataCode = string.Join(",", string.Join(",", g.Select(m => m.DataCode)).Split(',').Distinct().Contains("ALL") ? "ALL" : (string.Join(",", string.Join(",", g.Select(m => m.DataCode)).Split(',').Distinct().Contains("DEPT") ? "DEPT" : (string.Join(",", string.Join(",", g.Select(m => m.DataCode)).Split(',').Distinct().Contains("PERSON") ? "PERSON" : "")))))
+ }).ToList();
+
+ // 鑾峰彇鎵�鏈夌殑menucode
+ List<string> menuCodes = items.Select(item => item.MenuCode).ToList();
+ string codeString = string.Join(",", menuCodes);
+ //鏌ヨ鑿滃崟鏁版嵁
+ sql = @"select menucode,menuname,menu_seq,imgurl,'0' as flag,parent_id,is_show
+ from TMenu where Type=@usertype order by menu_seq";
+ dynamicParams.Add("@usertype", usertype);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ string[] codes = codeString.Split(',');
+ // 浣跨敤lambda琛ㄨ揪寮忔煡璇㈠搴旂埗绾х紪鐮佺殑鐖剁骇鑿滃崟鏁版嵁娣诲姞鍒癓ist
+ List<TreeOne> parentMenus = data0.AsEnumerable()
+ .Where(row => codes.Contains(row.Field<string>("menucode")))
+ .Select(row => row.Field<string>("parent_id"))
+ .Distinct()
+ .Select(parentMenuCode => data0.AsEnumerable()
+ .FirstOrDefault(row => row.Field<string>("menucode") == parentMenuCode))
+ .Where(row => row != null).Select(row => new TreeOne
+ {
+ code = row.Field<string>("menucode"),
+ name = row.Field<string>("menuname"),
+ flag = "0",
+ imgurl = fileip + row.Field<string>("imgurl"),
+ is_show = row.Field<string>("is_show")
+ }).ToList(); //.CopyToDataTable();
+ //娣诲姞瀛愯彍鍗曟暟鎹�
+ for (int i = 0; i < parentMenus.Count; i++)
+ {
+ parentMenus[i].children = data0.AsEnumerable().Where(row => codes.Contains(row.Field<string>("menucode")) && row.Field<string>("parent_id") == parentMenus[i].code)
+ .Select(row => new TreeTwo
+ {
+ code = row.Field<string>("menucode"),
+ name = row.Field<string>("menuname"),
+ flag = "0",
+ imgurl = fileip + row.Field<string>("imgurl"),
+ buttoncode = items.Where(m => m.MenuCode == row.Field<string>("menucode")).Select(m => m.ButtonCode).FirstOrDefault(),
+ datacode = items.Where(m => m.MenuCode == row.Field<string>("menucode")).Select(m => m.DataCode).FirstOrDefault(),
+ is_show = row.Field<string>("is_show")
+ }).ToList();
+ }
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = parentMenus;
+ return mes;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.Message = "绯荤粺鏈缃彍鍗曡祫鏂�,璇疯仈绯荤鐞嗗憳!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.Message = "褰撳墠璐﹀彿瀵瑰簲瑙掕壊鏈缃姛鑳芥潈闄�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[淇敼瀵嗙爜]
+ public static ToMessage UpdateUserPassword(User us, string password, string newpassword)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+
+ sql = @"select * from [dbo].[TUser] where usercode=@usercode and password=@password";
+ dynamicParams.Add("@usercode", us.usercode);
+ dynamicParams.Add("@password", password);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "杈撳叆鐨勫瘑鐮佷笉姝g‘,璇烽噸鏂拌緭鍏ワ紒";
+ mes.data = null;
+ }
+ else
+ {
+ //淇敼瀵嗙爜
+ sql = @"update [dbo].[TUser] set password=@newpassword where usercode=@usercode and password=@password";
+ list.Add(new { str = sql, parm = new { usercode = us.usercode, password = password, newpassword = newpassword } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ //鍐欏叆鏃ュ織
+ LogHelper.DbOperateLog(us.usercode, "淇敼", "淇敼浜嗗瘑鐮�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "淇敼瀵嗙爜鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "淇敼瀵嗙爜澶辫触!";
+ mes.data = null;
+ }
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐧诲嚭]
+ public static ToMessage LoginOut(User us)
+ {
+ RedisHelper redis = new RedisHelper();
+ try
+ {
+ //鍒犻櫎redis
+ redis.Remove(Enterprise + "LoginUserID" + us.usertype + us.usercode, 0);
+ //鍐欏叆鏃ュ織
+ LogHelper.DbOperateLog(us.usercode, "閫�鍑�", "閫�鍑轰簡绯荤粺", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鐧诲嚭鎴愬姛!";
+ mes.data = null;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[瀵嗙爜閲嶇疆]
+ public static ToMessage ResettUserPassword(string usercode, string username, string usertype)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+
+ //閲嶇疆瀵嗙爜
+ sql = @"update [dbo].[TUser] set password=@newpassword where usercode=@usercode and username=@username";
+ list.Add(new { str = sql, parm = new { usercode = usercode, username = username, newpassword = "123456" } });
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(usercode, "閲嶇疆", "閲嶇疆浜嗗瘑鐮�", usertype);
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "閲嶇疆瀵嗙爜鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "閲嶇疆瀵嗙爜澶辫触!";
+ mes.data = null;
+ }
+
+ return mes;
+ }
+ #endregion
+
+ #region[App鐧诲綍鏌ヨ瀹夌伅鍛煎彨淇℃伅]
+ public static ToMessage LoginAppAnDonMessage(string rid, string usercode, string username, string usertype, string stu_torgcode, string stu_torgtypecode)
+ {
+ var sql = "";
+ string search = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ switch (stu_torgtypecode)
+ {
+ case "":
+ search += "and T.description=@description ";
+ dynamicParams.Add("@description", "W");
+ break;
+ case "D":
+ search += "and child.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and T.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ sql = @"select B.eqp_code,E.name as eqp_name,B.wkshp_code,T.org_name as wkshp_name,
+ A.type as typecode,D.name as typename,B.start_user,B.start_date
+ from TAnDnMessagePush A
+ inner join TAnDon_Task_Info B on A.m_id=B.id
+ left join TEqpInfo E on B.eqp_code=E.code
+ left join TOrganization T on B.wkshp_code=T.org_code
+ left join TAnDonType D on A.type=d.code
+ left join TUser U on A.resp_user=U.usercode
+ left join TOrganization as child on T.parent_id=child.id
+ where A.resp_user=@usercode and B.status='START' and U.rid=@rid " + search;
+ dynamicParams.Add("@usercode", usercode);
+ dynamicParams.Add("@rid", rid);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/DAL/ProductionManagementDAL.cs b/VueWebCoreApi/DLL/DAL/ProductionManagementDAL.cs
new file mode 100644
index 0000000..0fcd0c3
--- /dev/null
+++ b/VueWebCoreApi/DLL/DAL/ProductionManagementDAL.cs
@@ -0,0 +1,5214 @@
+锘縰sing Dapper;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.DAL
+{
+ public class ProductionManagementDAL
+ {
+ public static DataTable dt; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static bool res; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+ public static string strProcName = ""; //瀹氫箟鍏ㄥ眬sql鍙橀噺
+ public static List<SqlParameter> listStr = new List<SqlParameter>(); //瀹氫箟鍏ㄥ眬鍙傛暟闆嗗悎
+ public static SqlParameter[] parameters; //瀹氫箟鍏ㄥ眬SqlParameter鍙傛暟鏁扮粍
+
+
+ #region[鑾峰彇鍗曟嵁鍙穄
+ public static ToMessage ProductInHouseOrderCodeSearch(string rightcode)
+ {
+ try
+ {
+ mes = SeachEncodeJob.EncodingSeach(rightcode);
+ return mes;
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[ERP璁㈠崟鏌ヨ]
+ public static ToMessage ErpOrderSearch(string stu_torgcode, string stu_torgtypecode, string erporderstus, string erpordercode, string partcode, string partname, string partspec, int startNum, string paydatestartdate, string paydateenddate, string paydatestartdate1, string paydateenddate2, string creatuser, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ switch (stu_torgtypecode)
+ {
+ case "":
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and C.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ if (erporderstus != "" && erporderstus != null)
+ {
+ search += "and A.status=@erporderstus ";
+ dynamicParams.Add("@erporderstus", erporderstus);
+ }
+ if (erpordercode != "" && erpordercode != null)
+ {
+ search += "and A.wo like '%'+@erpordercode+'%' ";
+ dynamicParams.Add("@erpordercode", erpordercode);
+ }
+ if (partcode != "" && partcode != null)
+ {
+ search += "and A.materiel_code like '%'+@partcode+'%' ";
+ dynamicParams.Add("@partcode", partcode);
+ }
+ if (partname != "" && partname != null)
+ {
+ search += "and B.partname like '%'+@partname+'%' ";
+ dynamicParams.Add("@partname", partname);
+ }
+ if (partspec != "" && partspec != null)
+ {
+ search += "and B.partspec like '%'+@partspec+'%' ";
+ dynamicParams.Add("@partspec", partspec);
+ }
+ if (paydatestartdate != "" && paydatestartdate != null)
+ {
+ search += "and A.planstartdate between @paydatestartdate and @paydateenddate ";
+ dynamicParams.Add("@paydatestartdate", paydatestartdate + " 00:00:00");
+ dynamicParams.Add("@paydateenddate", paydateenddate + " 23:59:59");
+ }
+ if (paydatestartdate1 != "" && paydatestartdate1 != null)
+ {
+ search += "and A.planenddate between @paydatestartdate1 and @paydateenddate2 ";
+ dynamicParams.Add("@paydatestartdate1", paydatestartdate1);
+ dynamicParams.Add("@paydateenddate2", paydateenddate2 + " 23:59:59");
+ }
+ if (creatuser != "" && creatuser != null)
+ {
+ search += "and U.username like '%'+@creatuser+'%' ";
+ dynamicParams.Add("@creatuser", creatuser);
+ }
+
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.id, A.status,A.wo,A.materiel_code as partcode,B.partname,B.partspec,A.qty,A.relse_qty,A.wkshp_code,C.org_name as wkshp_name,
+ A.stck_code,D.name as stck_name,saleOrderDeliveryDate,A.planstartdate,A.planenddate,U.username as createuser,A.createdate
+ from TKimp_Ewo A
+ left join TMateriel_Info B on A.materiel_code=B.partcode
+ left join TOrganization C on A.wkshp_code=C.org_code
+ left join T_Sec_Stck D on A.stck_code=D.code
+ left join TUser U on A.createuser=U.usercode
+ left join TOrganization L on C.parent_id=L.id
+ where A.is_delete<>'1' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[ERP璁㈠崟涓嬭揪]
+ public static ToMessage MarkSaveErpOrder(string erporderid, string erpordercode, string partcode, string wkshopcode, string warehousecode, string erpqty, string markqty, string ordernum, string relse_qty, string saleOrderDeliveryDate, string username)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+
+ try
+ {
+ list.Clear();
+ //鑾峰彇鎷嗗崟鏁伴噺:鍚戜笅鍙栨暣
+ decimal cdqty = Math.Floor(decimal.Parse(markqty) / decimal.Parse(ordernum));
+ //瀹氫箟绱涓嬪崟鏁伴噺
+ decimal sumqty = 0;
+ //瀹氫箟鏈�鏂扮敓鎴愮殑宸ュ崟鍙�
+ string wo = "";
+ //瀹氫箟宸ュ崟娴佹按鍙�
+ int num = 0;
+ //寰幆涓嬪崟鍗曟暟(鐢熸垚瀵瑰簲鍑犲紶MES宸ュ崟)
+ for (int i = 1; i <= Convert.ToInt32(ordernum); i++)
+ {
+ sumqty += cdqty;
+ //鑾峰彇鏈�澶у崟鎹彿
+ if (i == 1) //棣栧崟鑾峰彇宸ュ崟鍙�
+ {
+ sql = @"select isnull(max(cast(substring(wo_code,charindex('_',wo_code)+1,len(wo_code)-charindex('_',wo_code)) as numeric)),0)+1 as worknumb
+ from TK_Wrk_Man where m_po=@erpordercode";
+ dynamicParams.Add("@erpordercode", erpordercode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ num = Convert.ToInt32(data.Rows[0]["WORKNUMB"].ToString());
+ wo = erpordercode + "_" + num;
+ }
+ else
+ {
+ num = num + 1;
+ wo = erpordercode + "_" + num;
+ }
+ if (i == Convert.ToInt32(ordernum)) //鏈�鍚庝竴鍗曟椂
+ {
+ sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,stck_code,materiel_code,sourceid,m_po,lm_user,lm_date,saleOrderDeliveryDate) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@materiel_code,@sourceid,@m_po,@username,@CreateDate,@saleOrderDeliveryDate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ wo_code = wo,
+ wotype = "PO",
+ status = "NEW",
+ wkshp_code = wkshopcode,
+ plan_qty = cdqty + (decimal.Parse(markqty) - sumqty), //鏈崟涓嬪崟鏁伴噺=鍒囧垎鏁伴噺+(涓嬪崟鏁伴噺-绱鍒囧垎涓嬪崟鏁伴噺)
+ stck_code = warehousecode,
+ materiel_code = partcode,
+ sourceid = erporderid,
+ m_po = erpordercode,
+ username = username,
+ CreateDate = DateTime.Now.ToString(),
+ saleOrderDeliveryDate = Convert.ToDateTime(saleOrderDeliveryDate)
+ }
+ });
+ sumqty = sumqty + (decimal.Parse(markqty) - sumqty);
+ }
+ else
+ {
+
+ sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,stck_code,materiel_code,sourceid,m_po,lm_user,lm_date,saleOrderDeliveryDate) values(@wo_code,@wotype,@status,@wkshp_code,@plan_qty,@stck_code,@materiel_code,@sourceid,@m_po,@username,@CreateDate,@saleOrderDeliveryDate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ wo_code = wo,
+ wotype = "PO",
+ status = "NEW",
+ wkshp_code = wkshopcode,
+ plan_qty = cdqty,
+ stck_code = warehousecode,
+ materiel_code = partcode,
+ sourceid = erporderid,
+ m_po = erpordercode,
+ username = username,
+ CreateDate = DateTime.Now.ToString(),
+ saleOrderDeliveryDate = Convert.ToDateTime(saleOrderDeliveryDate)
+ }
+ });
+ }
+ }
+ if (decimal.Parse(erpqty) == decimal.Parse(markqty) + decimal.Parse(relse_qty)) //濡傛灉ERP璁㈠崟=涓嬪崟鏁伴噺+宸蹭笅鍗曟暟閲�,鍒欐洿鏂癊RP璁㈠崟琛ㄧ姸鎬佷负CREATED:宸插垱寤�
+ {
+ sql = @"update TKimp_Ewo set status='CREATED',saleOrderDeliveryDate=@saleOrderDeliveryDate,relse_qty=relse_qty+@sumqty where wo=@wo and id=@erporderid";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ wo = erpordercode,
+ erporderid = erporderid,
+ sumqty = sumqty,
+ saleOrderDeliveryDate = Convert.ToDateTime(saleOrderDeliveryDate)
+ }
+ });
+ }
+ else //鏇存柊ERP璁㈠崟琛ㄧ姸鎬佷负CREATING:鍒涘缓涓�
+ {
+ sql = @"update TKimp_Ewo set status='CREATING',saleOrderDeliveryDate=@saleOrderDeliveryDate,relse_qty=relse_qty+@sumqty where wo=@wo and id=@erporderid";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ wo = erpordercode,
+ erporderid = erporderid,
+ sumqty = sumqty,
+ saleOrderDeliveryDate = Convert.ToDateTime(saleOrderDeliveryDate)
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "涓嬭揪MES宸ュ崟鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "涓嬭揪MES宸ュ崟鎴愬姛澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[ERP璁㈠崟鍏抽棴]
+ public static ToMessage ClosedErpOrder(string erporderid, string erpordercode, string username)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select * from TK_Wrk_Man where m_po=@erpordercode and status<> 'CLOSED'";
+ dynamicParams.Add("@erpordercode", erpordercode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠璁㈠崟鏈変笅杈炬湭鍏抽棴鐨凪ES宸ュ崟,璁㈠崟涓嶅厑璁稿叧闂�,璇峰厛鍒犻櫎鎴栧叧闂浉鍏冲伐鍗�!";
+ mes.data = null;
+ }
+ else
+ {
+ //鍏抽棴璁㈠崟
+ sql = @"update TKimp_Ewo set status='CLOSED' where wo=@wo and id=@erporderid";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ wo = erpordercode,
+ erporderid = erporderid
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "璁㈠崟鍏抽棴鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璁㈠崟鍏抽棴澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[MES宸ュ崟鏌ヨ]
+ public static ToMessage MesOrderSearch(string stu_torgcode, string stu_torgtypecode, string mesorderstus, string mesordercode, string sourceorder, string ordertype, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ switch (stu_torgtypecode)
+ {
+ case "":
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and C.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ if (mesorderstus != "" && mesorderstus != null)
+ {
+ search += "and A.status=@mesorderstus ";
+ dynamicParams.Add("@mesorderstus", mesorderstus);
+ }
+ if (mesordercode != "" && mesordercode != null)
+ {
+ search += "and A.wo_code like '%'+@mesordercode+'%' ";
+ dynamicParams.Add("@mesordercode", mesordercode);
+ }
+ if (sourceorder != "" && sourceorder != null)
+ {
+ search += "and A.m_po like '%'+@sourceorder+'%' ";
+ dynamicParams.Add("@sourceorder", sourceorder);
+ }
+ if (ordertype != "" && ordertype != null)
+ {
+ search += "and A.wotype like '%'+@ordertype+'%' ";
+ dynamicParams.Add("@ordertype", ordertype);
+ }
+ if (partcode != "" && partcode != null)
+ {
+ search += "and A.materiel_code like '%'+@partcode+'%' ";
+ dynamicParams.Add("@partcode", partcode);
+ }
+ if (partname != "" && partname != null)
+ {
+ search += "and B.partname like '%'+@partname+'%' ";
+ dynamicParams.Add("@partname", partname);
+ }
+ if (partspec != "" && partspec != null)
+ {
+ search += "and B.partspec like '%'+@partspec+'%' ";
+ dynamicParams.Add("@partspec", partspec);
+ }
+ if (createdate != "" && createdate != null)
+ {
+ search += "and CONVERT(varchar(100),A.lm_date,23)=@createdate ";
+ dynamicParams.Add("@createdate", createdate);
+ }
+ if (creatuser != "" && creatuser != null)
+ {
+ search += "and U.username like '%'+@creatuser+'%' ";
+ dynamicParams.Add("@creatuser", creatuser);
+ }
+
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.plan_qty,A.wkshp_code,C.org_name as wkshp_name,
+ A.route_code,E.name as route_name,A.stck_code,F.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,U.username as lm_user,A.lm_date
+ from TK_Wrk_Man A
+ left join TMateriel_Info B on A.materiel_code=B.partcode
+ left join TOrganization C on A.wkshp_code=C.org_code
+ left join T_Sec_Stck D on A.stck_code=D.code
+ left join TFlw_Rout E on A.route_code=E.code
+ left join T_Sec_Stck F on A.stck_code=F.code
+ left join TUser U on A.lm_user=U.usercode
+ left join TOrganization L on C.parent_id=L.id
+ where A.is_delete<>'1' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[MES鎶ュ簾琛ュ崟宸ュ崟鏌ヨ]
+ public static ToMessage MesBadOrderSearch(string mesordercode, string sourceorder, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (mesordercode != "" && mesordercode != null)
+ {
+ search += "and A.wo_code like '%'+@mesordercode+'%' ";
+ dynamicParams.Add("@mesordercode", mesordercode);
+ }
+ if (sourceorder != "" && sourceorder != null)
+ {
+ search += "and A.m_po like '%'+@sourceorder+'%' ";
+ dynamicParams.Add("@sourceorder", sourceorder);
+ }
+ if (partcode != "" && partcode != null)
+ {
+ search += "and A.materiel_code like '%'+@partcode+'%' ";
+ dynamicParams.Add("@partcode", partcode);
+ }
+ if (partname != "" && partname != null)
+ {
+ search += "and B.partname like '%'+@partname+'%' ";
+ dynamicParams.Add("@partname", partname);
+ }
+ if (partspec != "" && partspec != null)
+ {
+ search += "and B.partspec like '%'+@partspec+'%' ";
+ dynamicParams.Add("@partspec", partspec);
+ }
+ if (createdate != "" && createdate != null)
+ {
+ search += "and CONVERT(varchar(100),A.lm_date,23)=@createdate ";
+ dynamicParams.Add("@createdate", createdate);
+ }
+ if (creatuser != "" && creatuser != null)
+ {
+ search += "and U.username like '%'+@creatuser+'%' ";
+ dynamicParams.Add("@creatuser", creatuser);
+ }
+
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.plan_qty,A.wkshp_code,C.org_name as wkshp_name,
+ A.route_code,E.name as route_name,A.stck_code,F.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,U.username as lm_user,A.lm_date,S.bad_qty
+ from TK_Wrk_Man A
+ left join (select wo_code,sum(bad_qty) as bad_qty from TK_Wrk_Step where bad_qty>0 group by wo_code) S on A.wo_code=S.wo_code
+ left join TMateriel_Info B on A.materiel_code=B.partcode
+ left join TOrganization C on A.wkshp_code=C.org_code
+ left join T_Sec_Stck D on A.stck_code=D.code
+ left join TFlw_Rout E on A.route_code=E.code
+ left join T_Sec_Stck F on A.stck_code=F.code
+ left join TUser U on A.lm_user=U.usercode
+ where A.is_delete<>'1' and A.status='START' and A.wotype='PO' and S.bad_qty>0 " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[浜у搧缂栫爜鏌ユ壘宸ヨ壓璺嚎涓嬫媺鎺ュ彛]
+ public static ToMessage PartSelectRoute(string partcode, string wkshopcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鑾峰彇杞﹂棿涓嬫媺妗嗘暟鎹�
+ sql = @"select R.code,R.name,A.default_route from TMateriel_Info A
+ inner join TMateriel_Route M on A.partcode=M.materiel_code
+ inner join TFlw_Rout R on M.route_code=R.code
+ where A.partcode=@partcode and M.torg_code=@torg_code";
+ dynamicParams.Add("@partcode", partcode);
+ dynamicParams.Add("@torg_code", wkshopcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[宸ヨ壓璺嚎鏌ユ壘杞﹂棿涓嬫媺鎺ュ彛]
+ public static ToMessage RouteSelectWkshop(string stu_torgcode, string stu_torgtypecode, string partcode)
+ {
+ string sql = "";
+ string search = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ switch (stu_torgtypecode)
+ {
+ case "":
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and F.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ //鑾峰彇杞﹂棿涓嬫媺妗嗘暟鎹�
+ sql = @"select distinct F.org_code,F.org_name from TMateriel_Route M
+ inner join TFlw_Rtdt B on M.route_code=B.rout_code
+ inner join TStep C on B.step_code=C.stepcode
+ inner join TFlw_Rteqp D on C.stepcode=D.step_code
+ inner join TEqpInfo E on D.eqp_code=E.code
+ left join TOrganization F on E.wksp_code=F.org_code
+ left join TOrganization L on F.parent_id=L.id
+ where M.materiel_code=@partcode and E.enable='Y' " + search;
+ dynamicParams.Add("@partcode", partcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鏍规嵁閫夋嫨宸ヨ壓璺嚎鏌ョ湅宸ュ簭鎺ュ彛]
+ public static ToMessage SelectRouteStep(string routecode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鑾峰彇宸ヨ壓璺嚎瀵瑰簲宸ュ簭淇℃伅
+ sql = @"select A.seq,T.stepcode,T.stepname,T.flwtype,T.descr from TFlw_Rtdt A
+ left join TStep T on A.step_code=T.stepcode
+ where A.rout_code=@partcode ";
+ dynamicParams.Add("@partcode", routecode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region銆愮敓浜х鐞嗐�佸伐鍗曟柊澧炪�佺紪杈戞椂,閫夋嫨鎺掔▼鏄椂鑾峰彇鐗╂枡娓呭崟鐗堟湰鍙枫��
+ public static ToMessage JobCreationSonAddVison(string partnumber)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @" select id,version from TBom_Main where materiel_code=@partnumber and status='Y' order by version desc ";
+ dynamicParams.Add("@partnumber", partnumber);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[宸ュ崟娲惧彂閫夋嫨宸ヨ壓璺嚎鎴栭�夋嫨鐢熶骇杞﹂棿鏃跺垽鏂粦瀹氭潯浠禲
+ public static ToMessage SelectRouteOrWkshop(string partcode, string routecode, string wkshopcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ mes.code = "200";
+ mes.Message = "";
+ mes.data = null;
+ //鍒ゆ柇宸ヨ壓璺嚎瀵瑰簲宸ュ簭鏄惁閮芥湁鍏宠仈宸ヤ綔绔�
+ sql = @"select B.step_code,C.eqp_code from TFlw_Rout A
+ inner join TFlw_Rtdt B on A.code=B.rout_code
+ left join TFlw_Rteqp C on B.step_code=C.step_code
+ where A.code=@routecode and A.torg_code=@wkshopcode";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ dynamicParams.Add("@routecode", routecode);
+ var dtck = DapperHelper.selectdata(sql, dynamicParams);
+ for (int i = 0; i < dtck.Rows.Count; i++)
+ {
+ if (dtck.Rows[i].IsNull("eqp_code"))
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ヨ壓璺嚎瀵瑰簲宸ュ簭銆�" + dtck.Rows[i]["step_code"].ToString() + "銆戯紝鏈叧鑱旇澶囷紝璇峰叧鑱旀墍鏈夊伐搴忓搴旇澶�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ //鍒ゆ柇宸ヤ綔绔�(璁惧)鏄惁鍙敤
+ sql = @"select B.step_code from TFlw_Rout A
+ inner join TFlw_Rtdt B on A.code=B.rout_code
+ where A.code=@routecode and A.torg_code=@wkshopcode";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ dynamicParams.Add("@routecode", routecode);
+ var dtck1 = DapperHelper.selectdata(sql, dynamicParams);
+ for (int i = 0; i < dtck1.Rows.Count; i++)
+ {
+ //宸ュ簭鏌ユ壘璁惧
+ sql = @"select E.code,E.name,E.enable
+ from TFlw_Rteqp C
+ left join TEqpInfo E on C.eqp_code=E.code
+ where C.step_code=@step_code and C.torg_code=@wkshopcode";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ dynamicParams.Add("@step_code", dtck1.Rows[i]["step_code"].ToString());
+ var dtck2 = DapperHelper.selectdata(sql, dynamicParams);
+ int query = dtck2.AsEnumerable().Where<DataRow>(a => a["enable"].ToString() == "N").Count();
+ if (dtck2.Rows.Count == query)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ヨ壓璺嚎瀵瑰簲宸ュ簭銆�" + dtck.Rows[i]["step_code"].ToString() + "銆戯紝璁惧涓嶅彲鐢�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ //鍒ゆ柇宸ヨ壓璺嚎瀵瑰簲宸ュ簭鍏宠仈鐨勫伐浣滅珯鏄惁鏈夎缃妭鎷嶅伐浠�
+ sql = @"select AA.step_code,AA.eqp_code,AA.flwtype,S.unprice from (
+ select A.code,B.step_code,C.eqp_code,S.flwtype from TFlw_Rout A
+ inner join TFlw_Rtdt B on A.code=B.rout_code
+ left join TFlw_Rteqp C on B.step_code=C.step_code
+ left join TStep S on B.step_code=S.stepcode
+ where A.code=@route_code and A.torg_code=@wkshopcode
+ ) as AA
+ left join (select * from TPrteEqp_Stad where materiel_code=@partcode and route_code=@route_code and wkspcode=@wkshopcode) as S on
+ AA.code=S.route_code and AA.step_code=S.step_code and AA.eqp_code=S.eqp_code";
+ dynamicParams.Add("@partcode", partcode);
+ dynamicParams.Add("@route_code", routecode);
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ var dtc = DapperHelper.selectdata(sql, dynamicParams);
+ for (int i = 0; i < dtc.Rows.Count; i++)
+ {
+ if (dtc.Rows[i]["flwtype"].ToString() == "Z") //鍒ゆ柇宸ュ簭鏄惁涓鸿嚜鍒�
+ {
+ if (dtc.Rows[i].IsNull("unprice") || decimal.Parse(dtc.Rows[i]["unprice"].ToString()) == 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鑺傛媿宸ヤ环涓細褰撳墠浜у搧銆�" + partcode + "銆戯紝瀵瑰簲宸ヨ壓璺嚎銆�" + routecode + "銆戞湭璁剧疆(鎴栨湭璁剧疆鍏�)鎴栧伐浠峰皬浜庣瓑浜�0!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[MES宸ュ崟鏂板銆佽幏鍙栧伐鍗曞彿]
+ public static ToMessage AddMesOrderCodeSearch()
+ {
+ string sql = "";
+ string wo_code = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鑾峰彇鍗曟嵁鍙�
+ sql = @"SELECT 'SGPO'+CONVERT(varchar(12) , getdate(), 112 )+'_'+cast(isnull(max(cast(substring(wo_code,charindex('_',wo_code)+1,len(wo_code)-charindex('_',wo_code)) as numeric)),0)+1 as varchar) as numct
+ FROM TK_Wrk_Man where wo_code like '%SGPO%'";
+ var data = DapperHelper.selecttable(sql);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data.Rows[0]["numct"].ToString();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[MES宸ュ崟鏂板銆佺紪杈戞彁浜
+ public static ToMessage AddUpdateMesOrder(string mesorderstus, string sourceorder, string ordertype, string mesordercode, string partcode, string mesqty, string routecode, string wkshopcode, string planstartdate, string planenddate, string orderlev, string username, string opertype, string is_aps, string bom_id)
+ {
+ string sql = "", wo_status = "", wrk_status = "";
+ var dynamicParams = new DynamicParameters();
+ List<object> list = new List<object>();
+ try
+ {
+ //鑾峰彇宸ヨ壓璺嚎棣栭亾宸ュ簭ID
+ sql = @"select distinct B.id from TFlw_Rout A
+ left join TFlw_Rtdt B on A.code=B.rout_code and b.first_choke='Y'
+ where A.code=@routecode";
+ dynamicParams.Add("@routecode", routecode);
+ var dtck = DapperHelper.selectdata(sql, dynamicParams);
+ if (dtck.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ュ崟瀵瑰簲宸ヨ壓璺嚎娌℃湁缁戝畾宸ュ簭!";
+ mes.data = null;
+ return mes;
+ }
+
+ if (opertype == "Add")
+ {
+ if (is_aps == "Y") //鏄惁鎺掔▼(鏄�)
+ {
+ //鍒ゆ柇鐗╂枡娓呭崟
+ sql = "select id from TBom_Main where materiel_code=@partcode and status='Y' and id=@bom_id";
+ dynamicParams.Add("@partcode", partcode);
+ dynamicParams.Add("@bom_id", bom_id);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ュ崟瀵瑰簲鐨勪骇鍝佹病鏈夊缓绔婤OM鎴朆OM鏈鏍革紒";
+ mes.data = null;
+ return mes;
+ }
+ //澧炲姞宸ュ崟鐢ㄦ枡琛紙瀛愪欢锛�
+ sql = @"insert into TK_Wrk_Allo(wo_code, seq, materiel_code, basqty, qty,bom_id,materieltype,stck_code,stopfeed,base_quantity,loss_quantity,m_quantity)
+ select @wocode,A.seq,A.smateriel_code,A.total_quantity,(convert(decimal(18, 0), @uomqty)*A.Base_Quantity*(1+A.LOSS_QUANTITY/100))/C.quantity,
+ A.m_id,A.pn_type,'','N',A.base_quantity,A.loss_quantity,C.quantity
+ from TBom_Deta A left join TBom_Main C on A.m_Id=C.id
+ left join TMateriel_Info B on A.smateriel_code = B.partcode
+ where A.m_id=@bom_id";
+ list.Add(new { str = sql, parm = new { wocode = mesordercode, uomqty = mesqty, bom_id = bom_id } });
+
+ wo_status = "NOSCHED";
+ wrk_status = "NOSCHED";
+ }
+ else //鍚�
+ {
+ wo_status = "ALLO";
+ wrk_status = "ALLO";
+ }
+ //鍐欏叆宸ュ崟琛�
+ sql = @"insert into TK_Wrk_Man(wo_code,wotype,status,wkshp_code,plan_qty,plan_startdate,plan_enddate,route_code,stck_code,lm_user,lm_date,materiel_code,m_po,piroque,isaps)
+ values(@mesordercode,@wotype,@mesorderstus,@wkshopcode,@mesqty,@planstartdate,@planenddate,@routecode,@stck_code,@username,@CreateDate,@materiel_code,@m_po,@orderlev,@isaps)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ mesordercode = mesordercode,
+ wotype = ordertype,
+ m_po = sourceorder,
+ mesorderstus = wo_status, //鍗曟嵁鐘舵��
+ wkshopcode = wkshopcode,
+ mesqty = mesqty,
+ planstartdate = planstartdate,
+ planenddate = planenddate,
+ routecode = routecode,
+ stck_code = "",
+ username = username,
+ CreateDate = DateTime.Now.ToString(),
+ materiel_code = partcode,
+ orderlev = orderlev,
+ isaps = is_aps
+ }
+ });
+ //鍐欏叆宸ュ簭浠诲姟琛�
+ sql = @"insert into TK_Wrk_Step(wo_code,seq,step_code,plan_qty,plan_startdate,plan_enddate,status,isbott,isend,route_code,lm_user,lm_date)
+ select @mesordercode as wo_code,A.seq,A.step_code,@mesqty as plan_qty,@planstartdate as plan_startdate,@planenddate as plan_enddate,@status as status,
+ A.first_choke,A.last_choke,A.rout_code,@username,@CreateDate
+ from TFlw_Rtdt A
+ left join TStep B on A.step_code=B.stepcode
+ left join TFlw_Rout C on A.rout_code=C.code
+ where A.rout_code=@routecode
+ and B.is_delete<>'1' and C.enable='Y' and C.is_delete<>'1'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ mesordercode = mesordercode,
+ mesqty = mesqty,
+ planstartdate = planstartdate,
+ planenddate = planenddate,
+ routecode = routecode,
+ status = wrk_status, //宸ュ簭鐘舵��
+ username = username,
+ CreateDate = DateTime.Now.ToString()
+ }
+ });
+ //鍐欏叆宸ュ崟宸ヨ壓璺嚎宸ュ簭宸ヤ环澶嶅埗琛�
+ sql = @"insert into TWoPrteEqp_Stad(wo,materiel_code,eqp_code,stand_value,opc_conver,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,torg_code,is_delete,step_code)
+ select distinct @mesordercode as wo,S.materiel_code,S.eqp_code,S.stand_value,S.opc_conver,S.route_code,S.unprice,
+ S.eqp_value,S.cavity_qty,S.wkspcode,S.lm_user,S.lm_date,S.torg_code,S.is_delete,S.step_code
+ from TFlw_Rtdt A
+ inner join TFlw_Rteqp C on A.step_code=C.step_code
+ inner join (select * from TPrteEqp_Stad where materiel_code=@materiel_code and route_code=@routecode) as S on C.step_code=S.step_code and C.eqp_code=S.eqp_code";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ mesordercode = mesordercode,
+ materiel_code = partcode,
+ routecode = routecode
+ }
+ });
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "MES宸ュ崟鏂板缓娲惧彂鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "MES宸ュ崟鏂板缓娲惧彂澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (opertype == "Update")
+ {
+ if (is_aps == "Y") //鏄惁鎺掔▼(鏄�)
+ {
+ //鍒ゆ柇鐗╂枡娓呭崟
+ sql = "select id from TBom_Main where materiel_code=@partcode and status='Y' and id=@bom_id";
+ dynamicParams.Add("@partcode", partcode);
+ dynamicParams.Add("@bom_id", bom_id);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ュ崟瀵瑰簲鐨勪骇鍝佹病鏈夊缓绔婤OM鎴朆OM鏈鏍革紒";
+ mes.data = null;
+ return mes;
+ }
+ //澧炲姞宸ュ崟鐢ㄦ枡琛紙瀛愪欢锛�
+ sql = @"insert into TK_Wrk_Allo(wo_code, seq, materiel_code, basqty, qty,bom_id,materieltype,stck_code,stopfeed,base_quantity,loss_quantity,m_quantity)
+ select @wocode,A.seq,A.smateriel_code,A.total_quantity,(convert(decimal(18, 0), @uomqty)*A.Base_Quantity*(1+A.LOSS_QUANTITY/100))/C.quantity,
+ A.m_id,A.pn_type,'','N',A.base_quantity,A.loss_quantity,C.quantity
+ from TBom_Deta A left join TBom_Main C on A.m_Id=C.id
+ left join TMateriel_Info B on A.smateriel_code = B.partcode
+ where A.m_id=@bom_id";
+ list.Add(new { str = sql, parm = new { wocode = mesordercode, uomqty = mesqty, bom_id = bom_id } });
+
+ wo_status = "NOSCHED";
+ wrk_status = "NOSCHED";
+ }
+ else //鍚�
+ {
+ wo_status = "ALLO";
+ wrk_status = "ALLO";
+ }
+ sql = @"update TK_Wrk_Man set route_code=@routecode,wkshp_code=@wkshopcode,plan_startdate=@planstartdate,plan_enddate=@planenddate,status=@status,piroque=@orderlev,lm_user=@username,lm_date=@CreateDate,isaps=@isaps where wo_code=@mesordercode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ mesordercode = mesordercode,
+ wkshopcode = wkshopcode,
+ planstartdate = planstartdate,
+ planenddate = planenddate,
+ status = wo_status,
+ routecode = routecode,
+ username = username,
+ CreateDate = DateTime.Now.ToString(),
+ orderlev = orderlev,
+ isaps = is_aps
+ }
+ });
+ //鍐欏叆宸ュ簭浠诲姟琛�
+ sql = @"insert into TK_Wrk_Step(wo_code,seq,step_code,plan_qty,plan_startdate,plan_enddate,status,isbott,isend,route_code,lm_user,lm_date)
+ select @mesordercode as wo_code,A.seq,A.step_code,@mesqty as plan_qty,@planstartdate as plan_startdate,@planenddate as plan_enddate,@status as status,
+ A.first_choke,A.last_choke,A.rout_code,@username,@CreateDate
+ from TFlw_Rtdt A
+ left join TStep B on A.step_code=B.stepcode
+ left join TFlw_Rout C on A.rout_code=C.code
+ where A.rout_code=@routecode
+ and B.is_delete<>'1' and C.enable='Y' and C.is_delete<>'1'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ mesordercode = mesordercode,
+ mesqty = mesqty,
+ planstartdate = planstartdate,
+ planenddate = planenddate,
+ status = wo_status,
+ username = username,
+ routecode = routecode,
+ CreateDate = DateTime.Now.ToString()
+ }
+ });
+ //鍒犻櫎宸ュ崟宸ヨ壓璺嚎宸ュ簭宸ヤ环澶嶅埗琛�
+ sql = @"delete TWoPrteEqp_Stad where wo=@mesordercode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ mesordercode = mesordercode
+ }
+ });
+ //鍐欏叆宸ュ崟宸ヨ壓璺嚎宸ュ簭宸ヤ环澶嶅埗琛�
+ sql = @"insert into TWoPrteEqp_Stad(wo,materiel_code,eqp_code,stand_value,opc_conver,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,torg_code,is_delete,step_code)
+ select distinct @mesordercode as wo,S.materiel_code,S.eqp_code,S.stand_value,S.opc_conver,S.route_code,S.unprice,
+ S.eqp_value,S.cavity_qty,S.wkspcode,S.lm_user,S.lm_date,S.torg_code,S.is_delete,S.step_code
+ from TFlw_Rtdt A
+ inner join TFlw_Rteqp C on A.step_code=C.step_code
+ inner join (select * from TPrteEqp_Stad where materiel_code=@materiel_code and route_code=@routecode) as S on C.step_code=S.step_code and C.eqp_code=S.eqp_code";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ mesordercode = mesordercode,
+ materiel_code = partcode,
+ routecode = routecode
+ }
+ });
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[MES宸ュ崟鍒犻櫎]
+ public static ToMessage DeleteMesOrder(string souceid, string wocode, string m_po, string orderqty)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鍒ゆ柇宸ュ崟鏄惁涓烘湭寮�濮嬬姸鎬佹垨鑰呭凡娲惧彂鎴栧緟鎺掔▼鐘舵��(婊¤冻鍏朵腑涓�绉嶉兘鍙垹闄わ紝鍚﹀垯涓嶅厑璁稿垹闄�)
+ sql = @"select * from TK_Wrk_Man where wo_code=@wocode and status in('NEW','ALLO','NOSCHED')";
+ dynamicParams.Add("@wocode", wocode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ if (m_po != "" && m_po != null)
+ {
+ //鏌ヨ鐢熶骇璁㈠崟琛ㄦ暟鎹�
+ sql = @"select * from TKimp_Ewo where wo=@m_po and id=@souceid";
+ dynamicParams.Add("@m_po", m_po);
+ dynamicParams.Add("@souceid", souceid);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ decimal relse_qty = decimal.Parse(data0.Rows[0]["RELSE_QTY"].ToString());//浠ヤ笅鍗曟暟閲�
+ if ((relse_qty - decimal.Parse(orderqty)) == 0) //鍏ㄩ儴鎾ら攢 璁㈠崟鐘舵�佸洖鍐欐湭寮�濮�,宸蹭笅鍗曟暟閲忎负0
+ {
+ //鍥炲啓璁㈠崟琛ㄧ姸鎬佸強宸蹭笅鍗曟暟閲�
+ sql = @"update TKimp_Ewo set status='NEW',relse_qty=0 where wo=@m_po and id=@souceid";
+ list.Add(new { str = sql, parm = new { m_po = m_po, souceid = souceid } });
+ }
+ else
+ {
+ //鍥炲啓璁㈠崟琛ㄧ姸鎬佸強宸蹭笅鍗曟暟閲�
+ sql = @"update TKimp_Ewo set status='CREATING',relse_qty=relse_qty-@orderqty where wo=@m_po and id=@souceid";
+ list.Add(new { str = sql, parm = new { m_po = m_po, souceid = souceid, orderqty = decimal.Parse(orderqty) } });
+ }
+ }
+ //鍒犻櫎宸ュ崟宸ュ簭琛�
+ sql = @"delete TK_Wrk_Step where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode } });
+
+ //鍒犻櫎鍔犲伐鍗曠敤鏂欒〃(瀛愪欢)
+ sql = @"delete TK_Wrk_Allo where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode } });
+
+ //鍒犻櫎宸ュ崟琛�
+ sql = @"update TK_Wrk_Man set is_delete='1' where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode } });
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ュ崟鎵ц涓垨宸插叧闂紝涓嶅厑璁稿垹闄�!";
+ mes.data = null;
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[MES宸ュ崟鍏抽棴]
+ public static ToMessage ClosedMesOrder(string username, string wocode, string m_po)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鍏抽棴宸ュ崟瀵瑰簲宸ュ簭浠诲姟
+ sql = @"update TK_Wrk_Step set status='CLOSED' where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode } });
+ //鍥炲啓宸ュ崟琛ㄧ姸鎬佷负(鍏抽棴)
+ sql = @"update TK_Wrk_Man set status='CLOSED',closeuser=@username,closedate=@closedate where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode, username = username, closedate = DateTime.Now.ToString() } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "宸ュ崟鍏抽棴鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ュ崟鍏抽棴澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[MES宸ュ崟鏌ョ湅宸ュ簭浠诲姟]
+ public static ToMessage SearchWorkStep(string wo_code)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鑾峰彇宸ュ簭浠诲姟淇℃伅
+ sql = @"select A.wo_code,P.partcode,P.partname,P.partspec,A.seq,B.stepcode,B.stepname,A.plan_qty,A.good_qty,A.ng_qty from TK_Wrk_Step A
+ left join TStep B on A.step_code=B.stepcode
+ left join TK_Wrk_Man M on A.wo_code=M.wo_code
+ left join TMateriel_Info P on M.materiel_code=P.partcode
+ where A.wo_code=@wo_code order by A.seq";
+ dynamicParams.Add("@wo_code", wo_code);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇褰撳墠宸ュ簭瀵瑰簲鐨勮澶�(鑷埗)]
+ public static ToMessage MesOrderStepEqpSearch(string orderstepqrcode)
+ {
+ var sql = "";
+ string search = "";//瀹氫箟涓�涓煡璇㈠弬鏁�,鏌ヨ鏉′欢鏈夊墠绔紶鍏�
+ string ordercode = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.Split(';');
+ if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇锋壂鎻忓伐搴忎簩缁寸爜!";
+ mes.data = null;
+ return mes;
+ }
+ if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ }
+ if (stepcode != "")
+ {
+ //鏌ユ壘褰撳墠宸ュ簭灞炴��
+ sql = @"select * from TStep where stepcode=@stepcode";
+ dynamicParams.Add("@stepcode", stepcode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "W")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭浠诲姟涓哄鍗忓伐搴忎换鍔�,璇峰墠寰�澶栧崗鎿嶄綔椤电鎵ц!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ //鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭璁惧(鑷埗宸ュ簭)
+ sql = @"select B.eqp_code,E.name as eqp_name from TK_Wrk_Step A
+ inner join TFlw_Rteqp B on A.step_code=B.step_code
+ left join TEqpInfo E on B.eqp_code=E.code
+ where B.style='E' and A.wo_code=@ordercode and A.step_code=@stepcode
+ order by B.eqp_code";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ return mes;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭浠诲姟鏃犲彲鎵ц璁惧!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇褰撳墠宸ュ簭瀵瑰簲鐨勪緵鏂�(澶栧崗)]
+ public static ToMessage MesOrderWxStepEqpSearch(string orderstepqrcode)
+ {
+ var sql = "";
+ string search = "";
+ string ordercode = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.Split(';');
+ if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇锋壂鎻忓伐搴忎簩缁寸爜!";
+ mes.data = null;
+ return mes;
+ }
+ if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ }
+ if (stepcode != "")
+ {
+ //鏌ユ壘褰撳墠宸ュ簭灞炴��
+ sql = @"select * from TStep where stepcode=@stepcode";
+ dynamicParams.Add("@stepcode", stepcode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "Z")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭浠诲姟涓鸿嚜鍒跺伐搴忎换鍔�,璇峰墠寰�鑷埗鎿嶄綔椤电鎵ц!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ //鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭澶栧崗渚涙柟(澶栧崗宸ュ簭)
+ sql = @"select B.eqp_code as customercode,C.name as customername from TK_Wrk_Step A
+ inner join TFlw_Rteqp B on A.step_code=B.step_code
+ left join TCustomer C on B.eqp_code=C.code
+ where B.style='W' and A.wo_code=@ordercode and A.step_code=@stepcode
+ order by B.eqp_code";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ return mes;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭鏃犲彲鎵ц澶栧崗渚涙柟!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟(鑷埗)]
+ public static ToMessage MesOrderStepSearch(string stu_torgcode, string stu_torgtypecode, string orderstepqrcode, int startNum, int endNum, string prop, string order)
+ {
+ var sql = "";
+ string search = "";
+ string ordercode = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ var total = 0; //鎬绘潯鏁�
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.Split(';');
+ if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇锋壂鎻忓伐搴忎簩缁寸爜!";
+ mes.data = null;
+ return mes;
+ }
+ if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+
+ if (ordercode != "" && stepcode == null) //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂负绌�
+ {
+ search += "and A.wo_code=@ordercode ";
+ dynamicParams.Add("@ordercode", ordercode);
+ }
+ if (ordercode != "" && stepcode != "") //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂笉涓虹┖
+ {
+ search += "and A.wo_code=@ordercode ";
+ dynamicParams.Add("@ordercode", ordercode);
+ search += "and S.stepcode=@stepcode ";
+ dynamicParams.Add("@stepcode", stepcode);
+ }
+ }
+ //else
+ //{
+ // mes.code = "300";
+ // mes.count = 0;
+ // mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
+ // mes.data = null;
+ // return mes;
+ //}
+ if (stepcode != "")
+ {
+ //鏌ユ壘褰撳墠宸ュ簭灞炴��
+ sql = @"select * from TStep where stepcode=@stepcode";
+ dynamicParams.Add("@stepcode", stepcode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "W")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭浠诲姟涓哄鍗忓伐搴忎换鍔�,璇峰墠寰�澶栧崗鎿嶄綔椤电鎵ц!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ switch (stu_torgtypecode)
+ {
+ case "":
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and F.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ //鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭浠诲姟(鑷埗宸ュ簭)
+ sql = @"select A.status,A.wo_code,B.route_code,M.partcode,M.partname,M.partspec,A.seq,A.isbott,A.isend,
+ S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate,B.lm_date
+ from TK_Wrk_Step A
+ left join TK_Wrk_Man B on A.wo_code=B.wo_code
+ left join TMateriel_Info M on B.materiel_code=M.partcode
+ left join TStep S on A.step_code=S.stepcode
+ left join TOrganization F on B.wkshp_code=F.org_code
+ left join TOrganization L on F.parent_id=L.id
+ where A.status in('ALLO','START') and S.flwtype='Z' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ if (data.ToList().Count > 0)
+ {
+ mes.code = "200";
+ mes.count = total;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data.ToList();
+ return mes;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏃犲彲鎵ц鐨勭敓浜т换鍔�,浠诲姟宸插畬鎴愭垨宸插叧闂�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟(澶栧崗)]
+ public static ToMessage MesOrderWxStepSearch(string stu_torgcode, string stu_torgtypecode, string orderstepqrcode, int startNum, int endNum, string prop, string order)
+ {
+ var sql = "";
+ string search = "";
+ string ordercode = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ var total = 0; //鎬绘潯鏁�
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.Split(';');
+ if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇锋壂鎻忓伐搴忎簩缁寸爜!";
+ mes.data = null;
+ return mes;
+ }
+ if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ if (ordercode != "" && stepcode == null) //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂负绌�
+ {
+ search += "and A.wo_code=@ordercode ";
+ dynamicParams.Add("@ordercode", ordercode);
+ }
+ if (ordercode != "" && stepcode != "") //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂笉涓虹┖
+ {
+ search += "and A.wo_code=@ordercode ";
+ dynamicParams.Add("@ordercode", ordercode);
+ search += "and S.stepcode=@stepcode ";
+ dynamicParams.Add("@stepcode", stepcode);
+ }
+ }
+ //else
+ //{
+ // mes.code = "300";
+ // mes.count = 0;
+ // mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
+ // mes.data = null;
+ // return mes;
+ //}
+ if (stepcode != "")
+ {
+ //鏌ユ壘褰撳墠宸ュ簭灞炴��
+ sql = @"select * from TStep where stepcode=@stepcode";
+ dynamicParams.Add("@stepcode", stepcode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "Z")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭浠诲姟涓鸿嚜鍒跺伐搴忎换鍔�,璇峰墠寰�鑷埗鎿嶄綔椤电鎵ц!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ switch (stu_torgtypecode)
+ {
+ case "":
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and F.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ //鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭浠诲姟(澶栧崗宸ュ簭)
+ sql = @"select A.status,A.wo_code,B.route_code,M.partcode,M.partname,M.partspec,A.seq,A.isbott,A.isend,
+ S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.plan_startdate,A.plan_enddate,B.lm_date
+ from TK_Wrk_Step A
+ left join TK_Wrk_Man B on A.wo_code=B.wo_code
+ left join TMateriel_Info M on B.materiel_code=M.partcode
+ left join TStep S on A.step_code=S.stepcode
+ left join TOrganization F on B.wkshp_code=F.org_code
+ left join TOrganization L on F.parent_id=L.id
+ where A.status in('ALLO','START') and S.flwtype='W' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ if (data.ToList().Count > 0)
+ {
+ mes.code = "200";
+ mes.count = total;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data.ToList();
+ return mes;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏃犲彲鎵ц鐨勭敓浜т换鍔�,浠诲姟宸插畬鎴愭垨宸插叧闂�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟(涓嶈壇)]
+ public static ToMessage MesOrderNgStepSearch(string stu_torgcode, string stu_torgtypecode, string orderstepqrcode, int startNum, int endNum, string prop, string order)
+ {
+ var sql = "";
+ string search = "";
+ string ordercode = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ var total = 0; //鎬绘潯鏁�
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.Split(';');
+ if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇锋壂鎻忓伐搴忎簩缁寸爜!";
+ mes.data = null;
+ return mes;
+ }
+ if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ if (ordercode != "" && stepcode == null) //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂负绌�
+ {
+ search += "and A.wo_code=@ordercode ";
+ dynamicParams.Add("@ordercode", ordercode);
+ }
+ if (ordercode != "" && stepcode != "") //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂笉涓虹┖
+ {
+ search += "and A.wo_code=@ordercode ";
+ dynamicParams.Add("@ordercode", ordercode);
+ search += "and S.stepcode=@stepcode ";
+ dynamicParams.Add("@stepcode", stepcode);
+ }
+ }
+ if (stepcode != "")
+ {
+ //鏌ユ壘褰撳墠宸ュ簭浠诲姟
+ sql = @"select * from TK_Wrk_Step where step_code=@stepcode and wo_code=@ordercode";
+ dynamicParams.Add("@stepcode", stepcode);
+ dynamicParams.Add("@ordercode", ordercode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭浠诲姟涓嶅瓨鍦�,鏃犳晥鏉$爜!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ switch (stu_torgtypecode)
+ {
+ case "":
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and F.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ //鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭浠诲姟,涓斾笉鑹暟閲忓ぇ浜�0
+ sql = @"select A.wo_code,M.partcode,M.partname,M.partspec,A.seq,A.isend,
+ S.stepcode,S.stepname,S.descr,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,B.lm_date
+ from TK_Wrk_Step A
+ left join TK_Wrk_Man B on A.wo_code=B.wo_code
+ left join TMateriel_Info M on B.materiel_code=M.partcode
+ left join TStep S on A.step_code=S.stepcode
+ left join TOrganization F on B.wkshp_code=F.org_code
+ left join TOrganization L on F.parent_id=L.id
+ where A.status in('ALLO','START') and A.ng_qty>0 " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ if (data.ToList().Count > 0)
+ {
+ mes.code = "200";
+ mes.count = total;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data.ToList();
+ return mes;
+ }
+ else
+ {
+ mes.code = "301";
+ mes.count = 0;
+ mes.Message = "鏃犲彲鎵ц鐨勭敓浜т换鍔�,浠诲姟宸插畬鎴愭垨宸插叧闂�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐鎵爜鑾峰彇宸ュ崟瀵瑰簲宸ュ簭浠诲姟(涓嶈壇鏄庣粏)]
+ public static ToMessage MesOrderNgSubStepSearch(string orderstepqrcode)
+ {
+ var sql = "";
+ string search = "";
+ string ordercode = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ var dynamicParams1 = new DynamicParameters();
+ Dictionary<string, object> list = new Dictionary<string, object>();
+ ScanStartReportData rt = new ScanStartReportData();
+ var total = 0; //鎬绘潯鏁�
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.Split(';');
+ if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇锋壂鎻忓伐搴忎簩缁寸爜!";
+ mes.data = null;
+ return mes;
+ }
+ if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ }
+ //1.鏍规嵁宸ュ崟+宸ュ簭鏌ユ壘褰撳墠宸ュ簭鏄惁棣栭亾宸ュ簭
+ sql = @"select A.wo_code,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.seq,T.flwtype,T.descr,A.status,A.plan_qty,A.good_qty,A.ng_qty,A.bad_qty,A.isbott,A.isend
+ from TK_Wrk_Step A
+ left join TStep T on A.step_code=T.stepcode
+ left join TK_Wrk_Man M on A.wo_code=M.wo_code
+ left join TMateriel_Info P on M.materiel_code=P.partcode
+ where A.wo_code=@ordercode and A.step_code=@stepcode";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ rt.wo_code = data.Rows[0]["WO_CODE"].ToString(); //宸ュ崟鍙�
+ rt.partnumber = data.Rows[0]["PARTCODE"].ToString(); //浜у搧缂栫爜
+ rt.partname = data.Rows[0]["PARTNAME"].ToString(); //浜у搧鍚嶇О
+ rt.partspec = data.Rows[0]["PARTSPEC"].ToString(); //浜у搧瑙勬牸
+ rt.stepcode = data.Rows[0]["STEPCODE"].ToString(); //宸ュ簭缂栫爜
+ rt.stepname = data.Rows[0]["STEPNAME"].ToString(); //宸ュ簭鍚嶇О
+ rt.stepdesc = data.Rows[0]["DESCR"].ToString(); //宸ュ簭鎻忚堪
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.noreportqty = decimal.Parse(data.Rows[0]["GOOD_QTY"].ToString()); //鎶ュ伐鏁伴噺
+ rt.noputqty = decimal.Parse(data.Rows[0]["NG_QTY"].ToString()); //涓嶈壇鏁伴噺
+ string isend = data.Rows[0]["ISEND"].ToString();//鏈亾宸ュ簭
+ rt.seq = data.Rows[0]["SEQ"].ToString();//宸ュ簭搴忓彿
+
+ //鑾峰彇褰撳墠宸ュ簭涓嬮亾宸ュ簭
+ sql = @"select A.isbott,A.isend,T.stepcode,T.stepname from TK_Wrk_Step A
+ left join TStep T on A.step_code=T.stepcode
+ where A.wo_code=@ordercode and A.seq=@seq+1 ";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@seq", decimal.Parse(data.Rows[0]["SEQ"].ToString()));
+ var dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count > 0) //鏈変笅閬撳伐搴�
+ {
+ rt.nextstepcode = dt0.Rows[0]["STEPCODE"].ToString();//涓嬮亾宸ュ簭缂栫爜
+ rt.nextstepname = dt0.Rows[0]["STEPNAME"].ToString();//涓嬮亾宸ュ簭鍚嶇О
+ }
+ if (isend == "Y") //褰撳墠宸ュ簭鏄湯閬撳伐搴�
+ {
+ rt.nextstepcode = "";//璧嬬┖
+ rt.nextstepname = "";//璧嬬┖
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鎵爜宸ュ簭浠诲姟涓嶅瓨鍦�!";
+ mes.data = null;
+ return mes;
+ }
+ //鏍规嵁鏉′欢鏌ヨ宸ュ崟宸ュ簭鎶ュ伐(鏀舵枡)璁板綍,涓斾笉鑹暟閲忓ぇ浜�0
+ //瀛樺偍杩囩▼鍚�
+ sql = @"h_p_IFCLD_MesReportDefectHandleSelect";
+ dynamicParams1.Add("@ordercode", ordercode);
+ dynamicParams1.Add("@stepcode", stepcode);
+ DataTable dt = DapperHelper.selectProcedure(sql, dynamicParams1);
+ if (dt.Rows.Count > 0)
+ {
+ list.Add("data1", rt);
+ list.Add("data2", dt);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = list;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏃犲彲鎵ц鐨勭敓浜т换鍔�,浠诲姟宸插畬鎴愭垨宸插叧闂�!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region [鐢熶骇寮�鎶ュ伐锛氬紑宸�(寮�濮�/鎶ュ伐)/澶栧崗鍙戞枡鏃舵潯浠跺垽鏂強鏁版嵁杩斿洖鎺ュ彛]
+ public static ToMessage MesOrderStepStart(string OperType, string stu_torgcode, string SelectType, string orderstepqrcode)
+ {
+ var sql = "";
+ string search = "";
+ string ordercode = "";
+ string serialnumber = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.Split(';');
+ if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇锋壂鎻忓伐搴忔潯鐮�!";
+ mes.data = null;
+ return mes;
+ }
+ if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ switch (OperType)
+ {
+ case "ZZ":
+ mes = ScanStartReport.ZZEncodingSeach(stu_torgcode, ordercode, stepcode);
+ break;
+ case "WX":
+ mes = ScanStartReport.WXEncodingSeach(stu_torgcode, SelectType, ordercode, stepcode);
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐锛氬紑宸ユ椂鑾峰彇璁惧涓嬫媺鍒楄〃]
+ public static ToMessage MesOrderStepStartSelectEqp(string orderstepqrcode)
+ {
+ string sql = "";
+ string ordercode = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.Split(';');
+ if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
+ mes.data = null;
+ return mes;
+ }
+ //鑾峰彇宸ュ簭鍏宠仈鐨勮澶�
+ sql = @"select B.code,B.name from TK_Wrk_Man M
+ inner join TFlw_Rtdt R on M.route_code=R.rout_code
+ inner join TFlw_Rteqp A on R.step_code=A.step_code
+ left join TEqpInfo B on A.eqp_code=B.code
+ where A.style='E' and M.wo_code=@wo_code and A.step_code=@stepcode and B.enable='Y'";
+ dynamicParams.Add("@wo_code", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐锛氭姤宸ユ椂鑾峰彇鐢熶骇鐝粍涓嬫媺妗哴
+ public static ToMessage MesOrderStepReportSelectUserGroup(string stu_torgcode, string stu_torgtypecode, string wkshopcode)
+ {
+ string sql = "";
+ string search = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (wkshopcode != "" && wkshopcode != null)
+ {
+ search += "and A.torg_code=@workShop ";
+ dynamicParams.Add("@workShop", wkshopcode);
+ }
+ else
+ {
+ switch (stu_torgtypecode)
+ {
+ case "":
+ search += "and T.description=@description ";
+ dynamicParams.Add("@description", "W");
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ }
+ }
+ //鑾峰彇鐢ㄦ埛缁�
+ sql = @"select group_code,group_name from TGroup A
+ left join TOrganization T on A.torg_code=T.org_code
+ left join TOrganization as L on T.parent_id=L.id
+ where 1=1 " + search;
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐锛氭牴鎹敓浜х彮缁勬煡鎵句汉鍛樺垪琛╙
+ public static ToMessage MesOrderGroupSelectUser(string stu_torgcode, string usergroupcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鐝粍鑾峰彇浜哄憳鍒楄〃
+ sql = @"select usercode,username from TUser where stu_torgcode=@stu_torgcode and usergroup_code=@usergroupcode and is_delete<>'1'";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ dynamicParams.Add("@usergroupcode", usergroupcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐锛氫汉鍛樹笅鎷夊垪琛╙
+ public static ToMessage MesOrderSelectUser(string usercode)
+ {
+ string sql = "";
+ string search = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (usercode != "" && usercode != null) //宸ュ崟鍙蜂笉涓虹┖,宸ュ簭鍙蜂负绌�
+ {
+ search += "and usercode=@usercode ";
+ dynamicParams.Add("@usercode", usercode);
+ }
+ //鐝粍鑾峰彇浜哄憳鍒楄〃
+ sql = @"select usercode,username from TUser where is_delete<>'1' and usercode<>'9999'" + search;
+ dynamicParams.Add("@usercode", usercode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐锛氬彂鏂�/鏀舵枡鏃惰幏鍙栧鍗忎笅鎷夊垪琛╙
+ public static ToMessage MesOrderStepSelectWX(string orderstepqrcode)
+ {
+ string sql = "";
+ string ordercode = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.Split(';');
+ if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
+ mes.data = null;
+ return mes;
+ }
+ //鑾峰彇澶栧崗涓嬫媺妗�
+ sql = @"select C.code,C.name from TFlw_Rteqp A
+ left join TCustomer C on A.eqp_code=C.code
+ where A.step_code=@stepcode and A.style='W'";
+ dynamicParams.Add("@stepcode", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇鎶ュ伐锛氭姤宸�/澶栧崗鏀舵枡 鑾峰彇涓嶈壇鍘熷洜涓嬫媺鍒楄〃]
+ public static ToMessage MesOrderStepSelectCause(string orderstepqrcode)
+ {
+ string sql = "";
+ string ordercode = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.Split(';');
+ if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
+ mes.data = null;
+ return mes;
+ }
+ //鑾峰彇宸ュ簭鍏宠仈缂洪櫡
+ sql = @"select B.code,B.name from TDefect_Step A
+ left join TDefect B on A.defect_code=B.code
+ where A.step_code=@stepcode";
+ dynamicParams.Add("@stepcode", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐,寮�宸�(寮�濮�)鎻愪氦]
+ public static ToMessage SavaMesOrderStepStart(string mesordercode, string partcode, string stepseq, string stepcode, string eqpcode, string taskqty, string startqty, string username)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ string date = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
+ list.Clear();
+ //鍒ゆ柇鏄惁鏈夊紑宸ヨ褰�
+ sql = @"select * from TK_Wrk_Record where wo_code=@wo_code and step_code=@step_code and style='S'";
+ dynamicParams.Add("@wo_code", mesordercode);
+ dynamicParams.Add("@step_code", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭浠诲姟宸插紑宸�!";
+ mes.data = null;
+ return mes;
+ }
+
+ //鍐欏叆寮�鎶ュ伐璁板綍琛�
+ sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,open_person,open_time,task_qty,start_qty,style,lm_user,lm_date)
+ values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@username,@opentime,@taskqty,@startqty,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, username = username, opentime = date, taskqty = taskqty, startqty = startqty, style = "S", lm_user = username, lm_date = date } });
+ //鍥炲啓宸ュ崟宸ュ簭琛ㄧ姸鎬佷负START: 寮�宸�
+ sql = @"update TK_Wrk_Step set status='START' where wo_code=@mesordercode and step_code=@stepcode";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode } });
+
+ //鍥炲啓宸ュ崟宸ュ簭琛ㄧ姸鎬佷负宸插紑宸�
+ sql = @"update TK_Wrk_Step set status='START' where wo_code=@mesordercode and step_code=@stepcode";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode } });
+ //鍥炲啓宸ュ崟琛ㄧ姸鎬佷负锛� 寮�宸ワ細START
+ sql = @"update TK_Wrk_Man set status='START' where wo_code=@mesordercode";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode } });
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "寮�宸ユ垚鍔�!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "寮�宸ュけ璐�!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐,鎶ュ伐鎻愪氦]
+ public static ToMessage SavaMesOrderStepReport(string mesordercode, string partcode, string stepseq, string stepcode, string eqpcode, string inbarcode, string reckway, string usergroupcode, string reportuser, string taskqty, string startqty, string reportqty, string ngqty, string badcode, string remarks, string username)
+ {
+ var sql = "";
+ //string[] arra = new string[] { };
+ string[] arra1 = new string[] { };
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ string date = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
+ //鑾峰彇鎶ュ伐浜哄憳銆佸垎閰嶆瘮渚�
+ JArray arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(reportuser);
+ if (ngqty != "" || ngqty != "0")
+ {
+ //鎴彇涓嶈壇鍘熷洜
+ arra1 = badcode.Split(';');
+ }
+
+ list.Clear();
+ //鍒ゆ柇鏄惁鏈夋姤宸ヨ褰�(鏈夛細淇敼 鏃狅細鏂板)
+ sql = @"select * from TK_Wrk_Record where wo_code=@wo_code and step_code=@step_code and style='B'";
+ dynamicParams.Add("@wo_code", mesordercode);
+ dynamicParams.Add("@step_code", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ //鑾峰彇寮�宸ヨ褰曠殑榛樿閫変腑鐨勮澶�(浜х嚎)涓庢姤宸ユ椂鐨勮澶囦骇绾垮仛瀵规瘮鍒ゆ柇
+ sql = @"select A.eqp_code,B.name from TK_Wrk_Record A
+ inner join TEqpInfo B on A.eqp_code=B.code
+ where A.wo_code=@wo_code and A.step_code=@step_code and A.style='S'";
+ dynamicParams.Add("@wo_code", mesordercode);
+ dynamicParams.Add("@step_code", stepcode);
+ var da = DapperHelper.selectdata(sql, dynamicParams);
+ if (da.Rows[0]["EQP_CODE"].ToString() != eqpcode)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触,褰撳墠鎶ュ伐浜х嚎搴斾负锛�" + da.Rows[0]["NAME"].ToString() + "!";
+ mes.data = null;
+ return mes;
+ }
+ if (data.Rows.Count > 0)
+ {
+ //鑾峰彇涓昏〃鏈�澶D
+ sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_Record')+1,1) as id";
+ var dt = DapperHelper.selecttable(sql);
+ //鍐欏叆寮�鎶ュ伐璁板綍琛�
+ sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date,inbarcode)
+ values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@taskqty,@startqty,@reportqty,@ngqty,@style,@lm_user,@lm_date,@inbarcode)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, taskqty = taskqty, startqty = startqty, reportqty = reportqty, ngqty = ngqty, style = "B", lm_user = username, lm_date = date, inbarcode = inbarcode } });
+
+ //鍐欏叆瀛愯〃
+ for (int i = 0; i < arra.Count; i++)
+ {
+ sql = @"insert into TK_Wrk_RecordSub(m_id,eqp_code,report_person,report_date,report_qty,reckway,usergroup_code,ratio,ng_qty,style,lm_user,lm_date)
+ values(@m_id,@eqp_code,@report_person,@report_date,@report_qty,@reckway,@usergroup_code,@ratio,@ng_qty,@style,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ m_id = int.Parse(dt.Rows[0]["ID"].ToString()),
+ eqp_code = eqpcode,
+ report_person = arra[i]["usercode"].ToString(),
+ report_date = date,
+ report_qty = reportqty,
+ reckway = reckway,
+ usergroup_code = usergroupcode,
+ ratio = decimal.Parse(arra[i]["ratio"].ToString()),
+ ng_qty = ngqty,
+ style = "B",
+ lm_user = username,
+ lm_date = date
+ }
+ });
+
+ }
+ if (badcode != "" && ngqty != "0")
+ {
+ //鍐欏叆缂洪櫡璁板綍琛�
+ for (int i = 0; i < arra1.Length; i++)
+ {
+ sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,remarks,style,lm_user,lm_date)
+ values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@remarks,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], remarks = remarks, style = "B", lm_user = username, lm_date = date } });
+
+ }
+ }
+ ////淇敼鎶ュ伐璁板綍
+ //sql = @"update TK_Wrk_Record set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty,
+ // lm_user=@username,lm_date=@CreateDate where wo_code=@mesordercode and step_code=@stepcode and style='B'";
+ //list.Add(new { str = sql, parm = new { reportqty = decimal.Parse(reportqty), ngqty = decimal.Parse(ngqty), mesordercode = mesordercode, stepcode = stepcode, username = username, CreateDate = date } });
+ ////鍐欏叆瀛愯〃
+ //for (int i = 0; i < arra.Length; i++)
+ //{
+ // sql = @"insert into TK_Wrk_RecordSub(m_id,eqp_code,report_person,report_date,report_qty,usergroup_code,ng_qty,style,lm_user,lm_date)
+ // values(@m_id,@eqp_code,@report_person,@report_date,@report_qty,@usergroup_code,@ng_qty,@style,@lm_user,@lm_date)";
+ // list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), eqp_code = eqpcode, report_person = arra[i], report_date = date, report_qty = reportqty, usergroup_code = usergroupcode, ng_qty = ngqty, style = "B", lm_user = username, lm_date = date } });
+
+ //}
+ //if (badcode != "" && ngqty != "0")
+ //{
+ // //鍐欏叆缂洪櫡璁板綍琛�
+ // for (int i = 0; i < arra1.Length; i++)
+ // {
+ // sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date)
+ // values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)";
+ // list.Add(new { str = sql, parm = new { record_id = int.Parse(data.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "B", lm_user = username, lm_date = date } });
+
+ // }
+ //}
+ }
+ else
+ {
+ //鑾峰彇涓昏〃鏈�澶D
+ sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_Record')+1,1) as id";
+ var dt = DapperHelper.selecttable(sql);
+ //鍐欏叆寮�鎶ュ伐璁板綍琛�
+ sql = @"insert into TK_Wrk_Record(wo_code,step_seq,step_code,eqp_code,materiel_code,task_qty,start_qty,good_qty,ng_qty,style,lm_user,lm_date,inbarcode)
+ values(@mesordercode,@stepseq,@stepcode,@eqpcode,@partcode,@taskqty,@startqty,@reportqty,@ngqty,@style,@lm_user,@lm_date,@inbarcode)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, eqpcode = eqpcode, partcode = partcode, taskqty = taskqty, startqty = startqty, reportqty = reportqty, ngqty = ngqty, style = "B", lm_user = username, lm_date = date, inbarcode = inbarcode } });
+
+ //鍐欏叆瀛愯〃
+ for (int i = 0; i < arra.Count; i++)
+ {
+ sql = @"insert into TK_Wrk_RecordSub(m_id,eqp_code,report_person,report_date,report_qty,reckway,usergroup_code,ratio,ng_qty,style,lm_user,lm_date)
+ values(@m_id,@eqp_code,@report_person,@report_date,@report_qty,@reckway,@usergroup_code,@ratio,@ng_qty,@style,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ m_id = int.Parse(dt.Rows[0]["ID"].ToString()),
+ eqp_code = eqpcode,
+ report_person = arra[i]["usercode"].ToString(),
+ report_date = date,
+ report_qty = reportqty,
+ reckway = reckway,
+ usergroup_code = usergroupcode,
+ ratio = decimal.Parse(arra[i]["ratio"].ToString()),
+ ng_qty = ngqty,
+ style = "B",
+ lm_user = username,
+ lm_date = date
+ }
+ });
+
+ }
+ if (badcode != "" && ngqty != "0")
+ {
+ //鍐欏叆缂洪櫡璁板綍琛�
+ for (int i = 0; i < arra1.Length; i++)
+ {
+ sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,remarks,style,lm_user,lm_date)
+ values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@remarks,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], remarks = remarks, style = "B", lm_user = username, lm_date = date } });
+
+ }
+ }
+ }
+
+
+ //鍥炲啓宸ュ崟宸ュ簭琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲�
+ sql = @"update TK_Wrk_Step set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode and step_code=@stepcode";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, reportqty = reportqty, ngqty = ngqty } });
+
+ //鍥炲啓宸ュ崟琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲�
+ //sql = @"update TK_Wrk_Man set good_qty=good_qty+@reportqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode";
+ //list.Add(new { str = sql, parm = new { mesordercode = mesordercode, reportqty = reportqty, ngqty = ngqty } });
+
+ //鍐欏叆ERP鍏ュ簱鍗�
+
+ //鍒ゆ柇鏄惁鏈亾宸ュ簭瀹屽伐鎶ュ伐(鑷姩鍏抽棴宸ュ崟鍙婂伐搴忎换鍔�)
+ //list = AutosCloseOrder.AutosColseOrderReport(list,mesordercode, partcode, stepseq,stepcode,reportqty,ngqty);
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐,鍙戞枡鎻愪氦]
+ public static ToMessage SavaMesOrderStepOut(string mesordercode, string partcode, string stepseq, string stepcode, string wxcode, string outuser, string taskqty, string fqty, string username)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ string date = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
+ list.Clear();
+ //鍒ゆ柇鏄惁鏈夊彂鏂欒褰�(鏈�(鍚屽伐鍗�+宸ュ簭+澶栧崗渚涙柟淇敼) 鏃狅細鏂板)
+ sql = @"select * from TK_Wrk_OutRecord where wo_code=@wo_code and step_code=@step_code and wx_code=@wx_code and style='F'";
+ dynamicParams.Add("@wo_code", mesordercode);
+ dynamicParams.Add("@step_code", stepcode);
+ dynamicParams.Add("@wx_code", wxcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ //淇敼鍙戞枡璁板綍
+ sql = @"update TK_Wrk_OutRecord set fqty=fqty+@fqty,lm_user=@username,lm_date=@CreateDate
+ where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code and style='F'";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, wx_code = wxcode, fqty = decimal.Parse(fqty), username = username, CreateDate = date } });
+ //鍐欏叆瀛愯〃
+ sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,out_person,out_time,fqty,style,lm_user,lm_date)
+ values(@m_id,@wx_code,@out_person,@out_time,@fqty,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), wx_code = wxcode, out_person = outuser, out_time = date, fqty = fqty, style = 'F', lm_user = username, lm_date = date } });
+ }
+ else
+ {
+ //鑾峰彇涓昏〃鏈�澶D
+ sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_OutRecord')+1,1) as id";
+ var dt = DapperHelper.selecttable(sql);
+ //鍐欏叆澶栧崗璁板綍涓昏〃
+ sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,fqty,lm_user,lm_date)
+ values(@mesordercode,@stepseq,@stepcode,@wx_code,@partcode,@style,@fqty,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'F', fqty = fqty, lm_user = username, lm_date = date } });
+
+ //鍐欏叆瀛愯〃
+ sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,out_person,out_time,fqty,style,lm_user,lm_date)
+ values(@m_id,@wx_code,@out_person,@out_time,@fqty,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), wx_code = wxcode, out_person = outuser, out_time = date, fqty = fqty, style = 'F', lm_user = username, lm_date = date } });
+ }
+ //鍥炲啓宸ュ崟宸ュ簭琛ㄧ姸鎬佷负START: 寮�宸�
+ sql = @"update TK_Wrk_Step set status='START' where wo_code=@mesordercode and step_code=@stepcode";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode } });
+
+
+ //鍥炲啓宸ュ崟琛ㄧ姸鎬佷负锛� 寮�宸ワ細START
+ sql = @"update TK_Wrk_Man set status='START' where wo_code=@mesordercode";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode } });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍙戞枡鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍙戞枡澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐, 鏀舵枡鎻愪氦]
+ public static ToMessage SavaMesOrderStepIn(string mesordercode, string partcode, string stepseq, string stepcode, string wxcode, string inbarcode, string inuser, string taskqty, string sqty, string ngqty, string badcode, string remarks, string username)
+ {
+ var sql = "";
+ string[] arra1 = new string[] { };
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ string date = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
+ //鎴彇涓嶈壇鍘熷洜
+ if (ngqty != "" || ngqty != "0")
+ {
+ //鎴彇涓嶈壇鍘熷洜
+ arra1 = badcode.Split(';');
+ }
+
+ list.Clear();
+ //鍒ゆ柇鏄惁鏈夋敹鏂欒褰�(鏈夛細锛堝悓宸ュ崟+宸ュ簭+澶栧崗渚涙柟淇敼锛� 鏃狅細鏂板)
+ sql = @"select * from TK_Wrk_OutRecord where wo_code=@wo_code and step_code=@step_code and wx_code=@wx_code and style='S'";
+ dynamicParams.Add("@wo_code", mesordercode);
+ dynamicParams.Add("@step_code", stepcode);
+ dynamicParams.Add("@wx_code", wxcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ //鑾峰彇鍙戞枡璁板綍鐨勯粯璁ら�変腑鐨勫鍗忎緵搴斿晢涓庢敹鏂欐椂鐨勫鍗忎緵搴斿晢鍋氬姣斿垽鏂�
+ sql = @"select A.wx_code,B.name,A.fqty from TK_Wrk_OutRecord A
+ inner join TCustomer B on A.wx_code=B.code
+ where A.wo_code=@wo_code and A.step_code=@step_code and wx_code=@wx_code and A.style='F' ";
+ dynamicParams.Add("@wo_code", mesordercode);
+ dynamicParams.Add("@step_code", stepcode);
+ dynamicParams.Add("@wx_code", wxcode);
+ var da = DapperHelper.selectdata(sql, dynamicParams);
+ if (da.Rows.Count <= 0)
+ {
+ sql = @"select A.wx_code,B.name,A.fqty from TK_Wrk_OutRecord A
+ inner join TCustomer B on A.wx_code=B.code
+ where A.wo_code=@wo_code and A.step_code=@step_code and A.style='F' ";
+ dynamicParams.Add("@wo_code", mesordercode);
+ dynamicParams.Add("@step_code", stepcode);
+ var da1 = DapperHelper.selectdata(sql, dynamicParams);
+ var dr = da1.AsEnumerable().ToList().Select(x => x.Field<string>("NAME")).ToList();
+ string wxstring = (string.Join(",", dr.Select(x => x.ToString()).ToArray()));
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触,褰撳墠鏀舵枡澶栧崗渚涙柟涓庡彂鏂欏鍗忎緵搴斿晢涓嶅尮閰�,搴斾负锛氥��" + wxstring + "銆�!";
+ mes.data = null;
+ return mes;
+ }
+ if ((decimal.Parse(sqty) + decimal.Parse(ngqty)) > decimal.Parse(da.Rows[0]["FQTY"].ToString())) //鏀舵枡鏁伴噺+涓嶈壇鏁伴噺>鍙戞枡鏁伴噺
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触,褰撳墠鏀舵枡鏁伴噺+涓嶈壇鏁伴噺,涓嶈兘澶т簬鍙戞枡鏁伴噺:" + da.Rows[0]["FQTY"].ToString() + "!";
+ mes.data = null;
+ return mes;
+ }
+ //if (da.Rows[0]["WX_CODE"].ToString() != wxcode)
+ //{
+ // mes.code = "300";
+ // mes.count = 0;
+ // mes.Message = "鎿嶄綔澶辫触,褰撳墠鏀舵枡澶栧崗渚涙柟搴斾负锛�" + da.Rows[0]["NAME"].ToString() + "!";
+ // mes.data = null;
+ // return mes;
+ //}
+ if (data.Rows.Count > 0)
+ {
+ decimal sum_sqty = data.AsEnumerable().Select(d => d.Field<decimal>("SQTY")).Sum(); //鑾峰彇鍚屽崟鍙�,鍚屽伐搴�,鍚屽鍗忎緵搴斿晢鏀舵枡鎬绘暟閲�
+ decimal sum_fqty = da.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum(); //鑾峰彇鍚屽崟鍙�,鍚屽伐搴�,鍚屽鍗忎緵搴斿晢鍙戞枡鎬绘暟閲�
+ if ((sum_sqty + decimal.Parse(sqty) + decimal.Parse(ngqty)) > sum_fqty) //宸叉敹鏂欐�绘暟+褰撳墠鏀舵枡鏁伴噺+涓嶈壇鏁伴噺>鎬诲彂鏂欐暟閲�
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触,褰撳墠鏀舵枡鏁伴噺+涓嶈壇鏁伴噺,涓嶈兘澶т簬寰呮敹鏁伴噺:" + (sum_fqty - sum_sqty) + "!";
+ mes.data = null;
+ return mes;
+ }
+
+
+ //鑾峰彇涓昏〃鏈�澶D
+ sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_OutRecord')+1,1) as id";
+ var dt = DapperHelper.selecttable(sql);
+ //鍐欏叆澶栧崗璁板綍涓昏〃
+ sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,sqty,ng_qty,lm_user,lm_date,inbarcode)
+ values(@mesordercode,@stepseq,@stepcode,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date,@inbarcode)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = username, lm_date = date, inbarcode = inbarcode } });
+
+ //鍐欏叆澶栧崗璁板綍瀛愯〃
+ sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date)
+ values(@m_id,@wxcode,@in_person,@in_time,@sqty,@ng_qty,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), wxcode = wxcode, in_person = inuser, in_time = date, sqty = sqty, ng_qty = ngqty, style = "S", lm_user = username, lm_date = date } });
+
+ if (badcode != "" && ngqty != "0")
+ {
+ //鍐欏叆缂洪櫡璁板綍琛�
+ for (int i = 0; i < arra1.Length; i++)
+ {
+ sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,remarks,style,lm_user,lm_date)
+ values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@remarks,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], remarks = remarks, style = "S", lm_user = username, lm_date = date } });
+
+ }
+ }
+
+
+ ////淇敼澶栧崗璁板綍涓昏〃
+ //sql = @"update TK_Wrk_OutRecord set sqty=sqty+@sqty,ng_qty=ng_qty+@ngqty,lm_user=@username,lm_date=@CreateDate
+ // where wo_code=@mesordercode and step_code=@stepcode and wx_code=@wx_code and style='S'";
+ //list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, wx_code = wxcode, sqty = decimal.Parse(sqty), ngqty = decimal.Parse(ngqty), username = username, CreateDate = date } });
+ ////鍐欏叆澶栧崗璁板綍瀛愯〃
+ //sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date)
+ // values(@m_id,@wx_code,@in_person,@in_time,@sqty,@ngqty,@style,@lm_user,@lm_date)";
+ //list.Add(new { str = sql, parm = new { m_id = int.Parse(data.Rows[0]["ID"].ToString()), wx_code = wxcode, in_person = inuser, in_time = date, sqty = sqty, ngqty = ngqty, style = 'S', lm_user = username, lm_date = date } });
+
+ //if (badcode != "" && ngqty != "0")
+ //{
+ // //鍐欏叆缂洪櫡璁板綍琛�
+ // for (int i = 0; i < arra1.Length; i++)
+ // {
+ // sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,style,lm_user,lm_date)
+ // values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@style,@lm_user,@lm_date)";
+ // list.Add(new { str = sql, parm = new { record_id = int.Parse(data.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], style = "S", lm_user = username, lm_date = date } });
+
+ // }
+ //}
+ }
+ else
+ {
+ //鑾峰彇涓昏〃鏈�澶D
+ sql = @"select ISNULL(IDENT_CURRENT('TK_Wrk_OutRecord')+1,1) as id";
+ var dt = DapperHelper.selecttable(sql);
+ //鍐欏叆澶栧崗璁板綍涓昏〃
+ sql = @"insert into TK_Wrk_OutRecord(wo_code,step_seq,step_code,wx_code,materiel_code,style,sqty,ng_qty,lm_user,lm_date,inbarcode)
+ values(@mesordercode,@stepseq,@stepcode,@wx_code,@partcode,@style,@sqty,@ngqty,@lm_user,@lm_date,@inbarcode)";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepseq = stepseq, stepcode = stepcode, wx_code = wxcode, partcode = partcode, style = 'S', sqty = sqty, ngqty = ngqty, lm_user = username, lm_date = date, inbarcode = inbarcode } });
+
+ //鍐欏叆澶栧崗璁板綍瀛愯〃
+ sql = @"insert into TK_Wrk_OutRecordSub(m_id,wx_code,in_person,in_time,sqty,ng_qty,style,lm_user,lm_date)
+ values(@m_id,@wxcode,@in_person,@in_time,@sqty,@ng_qty,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { m_id = int.Parse(dt.Rows[0]["ID"].ToString()), wxcode = wxcode, in_person = inuser, in_time = date, sqty = sqty, ng_qty = ngqty, style = "S", lm_user = username, lm_date = date } });
+
+ if (badcode != "" && ngqty != "0")
+ {
+ //鍐欏叆缂洪櫡璁板綍琛�
+ for (int i = 0; i < arra1.Length; i++)
+ {
+ sql = @"insert into CSR_WorkRecord_Defect(record_id,wo_code,partnumber,step_seq,step_code,defect_qty,defect_code,remarks,style,lm_user,lm_date)
+ values(@record_id,@wo_code,@partcode,@stepseq,@stepcode,@ngqty,@defect_code,@remarks,@style,@lm_user,@lm_date)";
+ list.Add(new { str = sql, parm = new { record_id = int.Parse(dt.Rows[0]["ID"].ToString()), wo_code = mesordercode, partcode = partcode, stepseq = stepseq, stepcode = stepcode, ngqty = ngqty, defect_code = arra1[i], remarks = remarks, style = "S", lm_user = username, lm_date = date } });
+
+ }
+ }
+ }
+ //鍥炲啓宸ュ崟宸ュ簭琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲�
+ sql = @"update TK_Wrk_Step set good_qty=good_qty+@sqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode and step_code=@stepcode";
+ list.Add(new { str = sql, parm = new { mesordercode = mesordercode, stepcode = stepcode, sqty = sqty, ngqty = ngqty } });
+
+ //鍥炲啓宸ュ崟琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲�
+ //sql = @"update TK_Wrk_Man set good_qty=good_qty+@sqty,ng_qty=ng_qty+@ngqty where wo_code=@mesordercode";
+ //list.Add(new { str = sql, parm = new { mesordercode = mesordercode, sqty = sqty, ngqty = ngqty } });
+
+ ////鍐欏叆ERP鍏ュ簱鍗�
+
+ //鍒ゆ柇鏄惁鏈亾宸ュ簭瀹屽伐鎶ュ伐(鑷姩鍏抽棴宸ュ崟鍙婂伐搴忎换鍔�)
+ //list = AutosCloseOrder.AutosColseOrderReport(list, mesordercode, partcode, stepseq, stepcode, sqty, ngqty);
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏀舵垚鍔�!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏀舵枡澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion'
+
+ #region[涓嶈壇澶勭悊,鎻愪氦]
+ public static ToMessage EditOrderNgStepSeave(ReportDefectHandle json, string username)
+ {
+ var sql = "";
+ string[] arra1 = new string[] { };
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ decimal sumrepair_qty = 0, sumbad_qty = 0; //绱缁翠慨鏁伴噺銆佺疮璁℃姤搴熸暟閲�
+ try
+ {
+ string date = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
+ list.Clear();
+
+
+ //寰幆json鏁版嵁
+ for (int i = 0; i < json.Data.Rows.Count; i++)
+ {
+ //鑷埗宸ュ簭
+ if (json.Data.Rows[i]["STYLE"].ToString() == "Z")
+ {
+ //鍥炲啓瀵瑰簲鐨勬姤宸ヨ褰曞瓙琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
+ sql = @"update TK_Wrk_RecordSub set report_qty=report_qty+@repair_qty,ng_qty=ng_qty-@repair_qty-@bad_qty,bad_qty=bad_qty+@bad_qty
+ where m_id=@m_id and style='B'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ m_id = int.Parse(json.Data.Rows[i]["ID"].ToString()),
+ repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()),
+ bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString())
+ }
+ });
+ //鍥炲啓瀵瑰簲鐨勬姤宸ヨ褰曚富琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
+ sql = @"update TK_Wrk_Record set good_qty=good_qty+@repair_qty,ng_qty=ng_qty-@repair_qty-@bad_qty,bad_qty=bad_qty+@bad_qty
+ where wo_code=@wo_code and step_code=@step_code and id=@id and style='B'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()),
+ bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()),
+ wo_code = json.Data.Rows[i]["WO_CODE"].ToString(),
+ step_code = json.Data.Rows[i]["STEP_CODE"].ToString(),
+ id = int.Parse(json.Data.Rows[i]["ID"].ToString())
+ }
+ });
+ //鍐欏叆鎶ュ伐缂洪櫡澶勭悊璁板綍琛�
+ sql = @"insert into CSR_WorkRecord_DefectHandle(record_subid,wo_code,partnumber,step_seq,step_code,repair_qty,bad_qty,defect_code,style,lm_user,lm_date)
+ values(@record_subid,@wo_code,@partcode,@stepseq,@stepcode,@repair_qty,@bad_qty,@defect_code,@style,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ record_subid = int.Parse(json.Data.Rows[i]["M_ID"].ToString()),
+ wo_code = json.Data.Rows[i]["WO_CODE"].ToString(),
+ partcode = json.Data.Rows[i]["MATERIEL_CODE"].ToString(),
+ stepseq = json.Data.Rows[i]["SEQ"].ToString(),
+ stepcode = json.Data.Rows[i]["STEP_CODE"].ToString(),
+ repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()),
+ bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()),
+ defect_code = json.Data.Rows[i]["DEFECT_CODE"].ToString(),
+ style = "B",
+ lm_user = username,
+ lm_date = date
+ }
+ });
+
+ sumrepair_qty = sumrepair_qty + decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString());
+ sumbad_qty = sumbad_qty + decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString());
+ }
+ //澶栧崗宸ュ簭
+ if (json.Data.Rows[i]["STYLE"].ToString() == "S")
+ {
+ //鍥炲啓瀵瑰簲鐨勬敹鏂欒褰曞瓙琛ㄦ敹鏂欐暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
+ sql = @"update TK_Wrk_OutRecordSub set sqty=sqty+@repair_qty,ng_qty=ng_qty-@repair_qty-@bad_qty,bad_qty=bad_qty+@bad_qty
+ where m_id=@m_id and style='S'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ m_id = int.Parse(json.Data.Rows[i]["ID"].ToString()),
+ repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()),
+ bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString())
+ }
+ });
+ //鍥炲啓瀵瑰簲鐨勬敹鏂欒褰曚富琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲忋�佹姤搴熸暟閲�
+ sql = @"update TK_Wrk_OutRecord set sqty=sqty+@repair_qty,ng_qty=ng_qty-@repair_qty-@bad_qty,bad_qty=bad_qty+@bad_qty
+ where wo_code=@wo_code and step_code=@step_code and id=@id and style='S'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()),
+ bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()),
+ wo_code = json.Data.Rows[i]["WO_CODE"].ToString(),
+ step_code = json.Data.Rows[i]["STEP_CODE"].ToString(),
+ id = int.Parse(json.Data.Rows[i]["ID"].ToString())
+ }
+ });
+ //鍐欏叆鎶ュ伐缂洪櫡澶勭悊璁板綍琛�
+ sql = @"insert into CSR_WorkRecord_DefectHandle(record_subid,wo_code,partnumber,step_seq,step_code,repair_qty,bad_qty,defect_code,style,lm_user,lm_date)
+ values(@record_subid,@wo_code,@partcode,@stepseq,@stepcode,@repair_qty,@bad_qty,@defect_code,@style,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ record_subid = int.Parse(json.Data.Rows[i]["M_ID"].ToString()),
+ wo_code = json.Data.Rows[i]["WO_CODE"].ToString(),
+ partcode = json.Data.Rows[i]["MATERIEL_CODE"].ToString(),
+ stepseq = json.Data.Rows[i]["SEQ"].ToString(),
+ stepcode = json.Data.Rows[i]["STEP_CODE"].ToString(),
+ repair_qty = decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString()),
+ bad_qty = decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString()),
+ defect_code = json.Data.Rows[i]["DEFECT_CODE"].ToString(),
+ style = "S",
+ lm_user = username,
+ lm_date = date
+ }
+ });
+ sumrepair_qty = sumrepair_qty + decimal.Parse(json.Data.Rows[i]["REPAIR_QTY"].ToString());
+ sumbad_qty = sumbad_qty + decimal.Parse(json.Data.Rows[i]["BAD_QTY"].ToString());
+ }
+ }
+
+ //鍥炲啓宸ュ崟宸ュ簭琛ㄥ悎鏍兼暟閲忋�佷笉鑹暟閲�
+ sql = @"update TK_Wrk_Step set good_qty=good_qty+@sumrepair_qty,ng_qty=ng_qty-@sumrepair_qty-@sumbad_qty,bad_qty=bad_qty+@sumbad_qty where wo_code=@wo_code and step_code=@stepcode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ wo_code = json.Data.Rows[0]["WO_CODE"].ToString(),
+ stepcode = json.Data.Rows[0]["STEP_CODE"].ToString(),
+ sumrepair_qty = sumrepair_qty,
+ sumbad_qty = sumbad_qty
+ }
+ });
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[宸ュ簭妫�楠屾壂鐮佽幏鍙栦换鍔′俊鎭痌
+ public static ToMessage MesOrderStepCheckSearch(string stu_torgcode, string orderstepqrcode, string checktype)
+ {
+ var sql = "";
+ string ordercode = "";
+ string stepcode = "";
+ var dynamicParams = new DynamicParameters();
+ Dictionary<string, object> list = new Dictionary<string, object>();
+ try
+ {
+ if (orderstepqrcode != "" && orderstepqrcode != null)
+ {
+ string[] arra = orderstepqrcode.Split(';');
+ if (arra.Length == 1) //宸ュ崟鍙蜂簩缁寸爜
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璇锋壂鎻忓伐搴忔潯鐮�!";
+ mes.data = null;
+ return mes;
+ }
+ if (arra.Length == 2) //宸ュ崟鍙�+宸ュ簭鍙蜂簩缁寸爜
+ {
+ ordercode = arra[0]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ stepcode = arra[1]; //鑾峰彇鎸囧畾瀛楃涓插墠闈㈢殑瀛楃
+ }
+ //鍒ゆ柇褰撳墠宸ュ崟鏄惁鍏抽棴
+ sql = @"select * from TK_Wrk_Man where wo_code=@ordercode and wkshp_code=@stu_torgcode and status='CLOSED'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ var da0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (da0.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ崟宸插叧闂�,涓嶅厑璁告楠屾搷浣�!";
+ mes.data = null;
+ return mes;
+ }
+
+ //0.鍒ゆ柇褰撳墠宸ュ崟鎵�灞炶溅闂存槸鍚︿负褰撳墠鐧诲綍浜哄憳杞﹂棿
+ sql = @"select * from TK_Wrk_Man where wo_code=@ordercode and wkshp_code=@stu_torgcode";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ var da1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (da1.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "涓嶆槸鏈溅闂寸敓浜т换鍔�,涓嶅厑璁告楠屾搷浣�!";
+ mes.data = null;
+ return mes;
+ }
+
+ //閫氳繃鎵弿浜岀淮鐮佷俊鎭煡鎵句换鍔′俊鎭�
+ sql = @"select A.wo_code,A.good_qty,M.partcode,M.partname,M.partspec,M.stocktype_code,S.stepcode,S.stepname
+ from TK_Wrk_Step A
+ inner join TK_Wrk_Man P on A.wo_code=P.wo_code
+ left join TMateriel_Info M on P.materiel_code=M.partcode
+ left join TStep S on A.step_code=S.stepcode
+ where A.wo_code=@wo_code and A.step_code=@stepcode";
+ dynamicParams.Add("@wo_code", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ if (decimal.Parse(data.Rows[0]["good_qty"].ToString()) > 0)
+ {
+ //鑾峰彇缁戝畾鐨勮川妫�鏂规銆佹娊鏍锋柟寮忋�佹牱鏈暟
+ sql = @"select code as checkstandcode,name as checkstandname,sampmethod,sampscare
+ from TStepCheckStandard
+ where (PATINDEX('%,' + RTRIM(@partcode) + ',%',',' + suitpart + ',')>0 or PATINDEX('%,' + RTRIM(@stocktype_code) + ',%',',' + suitpart + ',')>0)
+ and checktype=@checktype and stepcode=@stepcode ";
+ dynamicParams.Add("@partcode", data.Rows[0]["partcode"].ToString());//鐗╂枡缂栫爜
+ dynamicParams.Add("@stepcode", stepcode);//宸ュ簭缂栫爜
+ dynamicParams.Add("@stocktype_code", data.Rows[0]["stocktype_code"].ToString());//瀛樿揣绫诲瀷缂栫爜
+ dynamicParams.Add("@checktype", checktype);//妫�楠岀被鍨�
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data1.Rows.Count > 0)
+ {
+ list.Add("labcont", data);
+ list.Add("chekstand", data1);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = list;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠浜у搧銆�" + data.Rows[0]["partname"].ToString() + "銆�,瀵瑰簲宸ュ簭銆�" + data.Rows[0]["stepname"].ToString() + "銆戯紝鏈寚瀹氳川妫�鏂规!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭浠诲姟鏃犳姤宸ヤ骇鍑�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鐢熶骇浠诲姟涓嶅瓨鍦�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "浜岀淮鐮佷俊鎭负绌�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[宸ュ簭妫�楠屾牴鎹�夋嫨鐨勬楠屾柟妗堟煡鎵炬楠岄」鐩甝
+ public static ToMessage MesOrderStepCheckItemList(string checkstandcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //璐ㄦ鏂规缂栫爜鑾峰彇妫�楠岄」
+ sql = @"select A.stepcheckitem_seq, B.code,B.name,A.required,A.numberjudge,A.unit,A.decimalnum,
+ A.standvalue,A.uppervalue,A.lowervalue,A.stepcheckitem_desc
+ from TStepCheckStandardSub A
+ left join TStepCheckItem B on A.stepcheckitem_code=B.code
+ where A.stepstaned_code=@checkstandcode
+ order by A.stepcheckitem_seq";
+ dynamicParams.Add("@checkstandcode", checkstandcode);//璐ㄦ鏂规缂栫爜
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠璐ㄦ鏂规鏃犳楠岄」!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[宸ュ簭妫�楠�,鎻愪氦]
+ public static ToMessage SaveMesOrderStepCheckItem(string stu_torgcode, string wocode, string partcode, string stepcode, string checkstandcode, string check_type, string sampmethod, string qualitystatus, string labqty, string sampleqty, string goodqty, string ngqty, string checkitemcont, string username)
+ {
+ var sql = "";
+ string checktypename = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ string datetime = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
+ //鑾峰彇妫�楠岄」鐩俊鎭�
+ JArray arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(checkitemcont);
+ list.Clear();
+
+ //鍐欏叆妫�楠岃褰曚富琛�
+ sql = @"insert into TStepCheckRecord(wo_code,partcode,step_code,checkstaned_code,check_user,check_type,check_typename,sampmethod,check_result,check_qty,good_qty,ng_qty,lm_user,lm_date,torg_code)
+ values(@wo_code,@partcode,@step_code,@checkstaned_code,@check_user,@check_type,@check_typename,@sampmethod,@check_result,@check_qty,@good_qty,@ng_qty,@lm_user,@lm_date,@torg_code)";
+ switch (check_type)
+ {
+ case "FirstCheck":
+ checktypename = "棣栨";
+ break;
+ case "PatroCheck":
+ checktypename = "宸℃";
+ break;
+ case "EndCheck":
+ checktypename = "瀹屽伐妫�楠�";
+ break;
+ default:
+ break;
+ }
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ wo_code = wocode,
+ partcode = partcode,
+ step_code = stepcode,
+ checkstaned_code = checkstandcode,
+ check_user = username,
+ check_type = check_type,
+ check_typename = checktypename,
+ sampmethod = sampmethod,
+ check_result = qualitystatus,
+ check_qty = decimal.Parse(sampleqty),
+ good_qty = decimal.Parse(goodqty),
+ ng_qty = decimal.Parse(ngqty),
+ lm_user = username,
+ lm_date = datetime,
+ torg_code = stu_torgcode
+ }
+ });
+ //鍐欏叆妫�楠岃褰曞瓙琛�
+ for (int j = 0; j < arra.Count; j++)
+ {
+ sql = @"insert into TStepCheckRecordSub(m_id,checknum,checkitem_seq,checkitem_code,checkitem_name,checkitem_descr,check_value,check_result,lm_user,lm_date,torg_code)
+ values(CONVERT(INT,IDENT_CURRENT('TStepCheckRecord')),@checknum,@checkiem_seq,@checkitem_code,@checkitem_name,@checkitem_descr,@check_value,@check_result,@lm_user,@lm_date,@torg_code)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ checknum = arra[j]["checknum"].ToString(),
+ checkiem_seq = arra[j]["checkiem_seq"].ToString(),
+ checkitem_code = arra[j]["checkitem_code"].ToString(),
+ checkitem_name = arra[j]["checkitem_name"].ToString(),
+ checkitem_descr = arra[j]["checkitem_descr"].ToString(),
+ check_value = arra[j]["check_value"].ToString(),
+ check_result = arra[j]["check_result"].ToString(),
+ lm_user = username,
+ lm_date = datetime,
+ torg_code = stu_torgcode
+ }
+ });
+ }
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+
+ #region[MES宸ュ崟鎵归噺鍏抽棴鏌ヨ]
+ public static ToMessage MesOrderBitchClosedSearch(string stu_torgcode, string stu_torgtypecode, string mesorderstus, string mesordercode, string sourceorder, string ordertype, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ switch (stu_torgtypecode)
+ {
+ case "":
+ break;
+ case "D":
+ search += "and L.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ case "W":
+ search += "and C.org_code=@stu_torgcode ";
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ break;
+ default:
+ break;
+ }
+ if (mesorderstus != "" && mesorderstus != null)
+ {
+ search += "and A.status=@mesorderstus ";
+ dynamicParams.Add("@mesorderstus", mesorderstus);
+ }
+ if (mesordercode != "" && mesordercode != null)
+ {
+ search += "and A.wo_code like '%'+@mesordercode+'%' ";
+ dynamicParams.Add("@mesordercode", mesordercode);
+ }
+ if (sourceorder != "" && sourceorder != null)
+ {
+ search += "and A.m_po like '%'+@sourceorder+'%' ";
+ dynamicParams.Add("@sourceorder", sourceorder);
+ }
+ if (ordertype != "" && ordertype != null)
+ {
+ search += "and A.wotype like '%'+@ordertype+'%' ";
+ dynamicParams.Add("@ordertype", ordertype);
+ }
+ if (partcode != "" && partcode != null)
+ {
+ search += "and A.materiel_code like '%'+@partcode+'%' ";
+ dynamicParams.Add("@partcode", partcode);
+ }
+ if (partname != "" && partname != null)
+ {
+ search += "and B.partname like '%'+@partname+'%' ";
+ dynamicParams.Add("@partname", partname);
+ }
+ if (partspec != "" && partspec != null)
+ {
+ search += "and B.partspec like '%'+@partspec+'%' ";
+ dynamicParams.Add("@partspec", partspec);
+ }
+ if (createdate != "" && createdate != null)
+ {
+ search += "and CONVERT(varchar(100),A.lm_date,23)=@createdate ";
+ dynamicParams.Add("@createdate", createdate);
+ }
+ if (creatuser != "" && creatuser != null)
+ {
+ search += "and U.username like '%'+@creatuser+'%' ";
+ dynamicParams.Add("@creatuser", creatuser);
+ }
+
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.plan_qty,A.wkshp_code,C.org_name as wkshp_name,
+ A.route_code,E.name as route_name,A.stck_code,F.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,U.username as lm_user,A.lm_date
+ ,(select sum(S.good_qty) from TK_Wrk_Step S where S.wo_code=A.wo_code and S.isend='Y') as good_qty
+ ,(select sum(S.ng_qty) from TK_Wrk_Step S where S.wo_code=A.wo_code and S.isend='Y') as ng_qty
+ ,(select sum(S.bad_qty) from TK_Wrk_Step S where S.wo_code=A.wo_code and S.isend='Y') as bad_qty
+ from TK_Wrk_Man A
+ left join TMateriel_Info B on A.materiel_code=B.partcode
+ left join TOrganization C on A.wkshp_code=C.org_code
+ left join T_Sec_Stck D on A.stck_code=D.code
+ left join TFlw_Rout E on A.route_code=E.code
+ left join T_Sec_Stck F on A.stck_code=F.code
+ left join TUser U on A.lm_user=U.usercode
+ left join TOrganization L on C.parent_id=L.id
+ where A.is_delete<>'1' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[MES宸ュ崟鎵归噺鍏抽棴鎻愪氦]
+ public static ToMessage MesOrderBitchClosedSeave(string username, DataTable dt)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ for (int i = 0; i < dt.Rows.Count; i++)
+ {
+ //鍏抽棴宸ュ崟瀵瑰簲宸ュ簭浠诲姟
+ sql = @"update TK_Wrk_Step set status='CLOSED' where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString() } });
+ //鍥炲啓宸ュ崟琛ㄧ姸鎬佷负(鍏抽棴)
+ sql = @"update TK_Wrk_Man set status='CLOSED',closeuser=@username,closedate=@closedate where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString(), username = username, closedate = DateTime.Now.ToString() } });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "宸ュ崟鍏抽棴鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ュ崟鍏抽棴澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[MES宸ュ崟鎵归噺鍙嶅叧闂璢
+ public static ToMessage MesOrderBitchAntiClosedSeave(string username, DataTable dt)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ for (int i = 0; i < dt.Rows.Count; i++)
+ {
+ //鍏抽棴宸ュ崟瀵瑰簲宸ュ簭浠诲姟
+ sql = @"update TK_Wrk_Step set status='START' where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString() } });
+ //鍥炲啓宸ュ崟琛ㄧ姸鎬佷负(鍏抽棴)
+ sql = @"update TK_Wrk_Man set status='START',closeuser=@username,closedate=@closedate where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = dt.Rows[i]["WO_CODE"].ToString(), username = username, closedate = DateTime.Now.ToString() } });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "宸ュ崟鍏抽棴鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ュ崟鍏抽棴澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[浜ц兘瑙勫垝璁剧疆鏌ヨ]
+ public static ToMessage CapacityPlanningSetupSearch()
+ {
+ string sql = "";
+ try
+ {
+ sql = @"select code,name,wktme1_start,wktme2_start,wktme3_start,wktme4_start,wktme5_start,
+ lm_user,lm_date,duration
+ from TBas_wkshift_info";
+ var data = DapperHelper.selecttable(sql);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝璁剧疆鏂板]
+ public static ToMessage CapacityPlanningSetupAddUpdate(string username, List<CapacityPlanningSetup> objs)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鍒ゆ柇缂栫爜鏄惁閲嶅
+ sql = @"select * from TBas_wkshift_info where code=@code";
+ dynamicParams.Add("@code", objs[0].CapSetupCode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "缂栫爜宸插瓨鍦�,涓嶈兘閲嶅!";
+ mes.data = null;
+ return mes;
+ }
+ //鍒ゆ柇鍚嶇О鏄惁閲嶅
+ sql = @"select * from TBas_wkshift_info where name=@name";
+ dynamicParams.Add("@name", objs[0].CapSetupName);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍚嶇О宸插瓨鍦�,涓嶈兘閲嶅!";
+ mes.data = null;
+ return mes;
+ }
+ list.Clear();
+ //寰幆鍐欏叆璁惧绫诲瀷琛�
+ for (int i = 0; i < objs.Count; i++)
+ {
+ sql = @"insert into TBas_wkshift_info(code, name, wktme1_start, wktme2_start, wktme3_start, wktme4_start, wktme5_start, lm_user, lm_date, duration)
+ values(@code,@name,@wktme1_start,@wktme2_start,@wktme3_start,@wktme4_start,@wktme5_start,@lm_user,@lm_date,@duration)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ code = objs[i].CapSetupCode,
+ name = objs[i].CapSetupName,
+ wktme1_start = objs[i].OneStartDate,
+ wktme2_start = objs[i].TwoStartDate,
+ wktme3_start = objs[i].ThreeStartDate,
+ wktme4_start = objs[i].FourStartDate,
+ wktme5_start = objs[i].FiveStartDate,
+ lm_user = username,
+ lm_date = DateTime.Now.ToString(),
+ duration = objs[i].Duration
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝鏂规璁剧疆鍒犻櫎]
+ public static ToMessage CapacityPlanningSetupDelete(string username, string capsetupcode)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鍒ゆ柇鏂规鏄惁琚紩鐢�
+ sql = @"select * from TWkm_capac_plan where wkshift_code=@capsetupcode";
+ dynamicParams.Add("@capsetupcode", capsetupcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎澶辫触锛�,璇ユ柟妗堝凡缁忚浜ц兘瑙勫垝璧勬簮寮曠敤!";
+ mes.data = null;
+ return mes;
+ }
+ list.Clear();
+ //鍒犻櫎鏂规
+
+ sql = @"delete TBas_wkshift_info where code=@code";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ code = capsetupcode
+ }
+ });
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍒犻櫎澶辫触!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝鏌ヨ]
+ public static ToMessage CapacityPlanningSearch(string workshop, string devicetype, string stustype, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (workshop != "" && workshop != null)
+ {
+ search += "and A.wksp_code=@workshop ";
+ dynamicParams.Add("@workshop", workshop);
+ }
+ if (devicetype != "" && devicetype != null)
+ {
+ search += "and A.code=@devicetype ";
+ dynamicParams.Add("@devicetype", devicetype);
+ }
+ if (stustype != "" && stustype != null)
+ {
+ search += "and B.enable=@stustype ";
+ dynamicParams.Add("@stustype", stustype);
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select
+ B.id CaptPlanId,
+ A.wksp_code CaptPlanWorkShopid,
+ C.org_name CaptPlanWorkShop,
+ A.code CaptPlanDeviceTypeid,
+ A.name CaptPlanDeviceType,
+ A.ClassType CaptPlanType,
+ E.aa CaptPlanShopCalendar,
+ E.RR CaptPlanShopMaxDate,
+ E.TT CaptPlanShopCalendarList,
+ B.wkshift_code CaptPlanWorkShiftCode,
+ D.name CaptPlanWorkShift,
+ D.duration CaptPlanDuration,
+ B.lm_date CaptPlanDate,
+ B.ENABLE CaptPlanStus,
+ G.username CaptPlanUser
+ FROM(
+ select distinct B.wksp_code,A.code,A.name,'D' ClassType from TEqpType A
+ left join TEqpInfo B on A.code=B.eqptype_code
+ left join TFlw_Rteqp C on B.code=C.eqp_code
+ left join TFlw_Rtdt D on C.step_code=D.step_code
+ where D.first_choke='Y' --order by A.code
+ )A
+ left join TOrganization C on A.wksp_code=C.org_code
+ left join TWkm_capac_plan B ON A.wksp_code=B.wkshop and A.code=B.eqp_typecode
+ left join TBas_wkshift_info D on B.wkshift_code=D.code
+ left join TUser G on B.lm_user=G.usercode
+ left join (
+ select m_id,
+ min(CONVERT(varchar(100), wkdate, 23))+'~'+max(CONVERT(varchar(100), wkdate, 23)) aa,
+ max(CONVERT(varchar(100), wkdate, 23))RR,
+ STUFF((
+ SELECT ',' + CONVERT(varchar(100),t1.wkdate, 23)
+ FROM TWkm_capac_plan_sub t1
+ WHERE t1.m_id = t0.m_id
+ ORDER BY t1.m_id
+ FOR XML PATH('')), 1, LEN(','), '') AS TT
+ FROM TWkm_capac_plan_sub t0 where CONVERT(varchar(100), wkdate, 23)>=CONVERT(varchar(100),getdate(), 23)
+ GROUP BY t0.m_id
+ ) E on B.id=E.m_id
+ where C.description='W' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝榛樿鏂规淇濆瓨鎻愪氦]
+ public static ToMessage CapacityPlanSubmit(string type, string captplanid, string wkshopcode, string capunitcode, string capsetupcode, string captplantype, string username)
+ {
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (type == "Add")
+ {
+ var sql = @"insert into TWkm_capac_plan(wkshop, eqp_typecode, wkshift_code, enable, lm_user, lm_date,classtype)
+ values(@wkshop,@eqp_typecode,@wkshift_code,@enable,@lm_user,@lm_date,@classtype)";
+ dynamicParams.Add("@wkshop", wkshopcode);
+ dynamicParams.Add("@eqp_typecode", capunitcode);
+ dynamicParams.Add("@wkshift_code", capsetupcode);
+ dynamicParams.Add("@enable", "Y");
+ dynamicParams.Add("@lm_user", username);
+ dynamicParams.Add("@lm_date", DateTime.Now.ToString());
+ dynamicParams.Add("@classtype", captplantype);
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ if (type == "Update")
+ {
+ var sql = @"update TWkm_capac_plan set wkshift_code=@wkshift_code,lm_user=@username,lm_date=@CreateDate where id=@captplanid";
+ dynamicParams.Add("@captplanid", captplanid);
+ dynamicParams.Add("@wkshift_code", capsetupcode);
+ dynamicParams.Add("@username", username);
+ dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "淇敼鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝鐐瑰嚮鏃ュ巻缁勪欢鏌ユ壘宸插叧鑱旂殑鏃ユ湡鏂规]
+ public static ToMessage CapacityPlanningCalendar(string captplanid)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ List<CapaPlan> list = new List<CapaPlan>();
+ try
+ {
+ sql = @"select CONVERT(varchar(100), wkdate, 23) DataTime,wkshift_code from TWkm_capac_plan_sub where m_id=@captplanid";
+ dynamicParams.Add("@captplanid", captplanid);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ for (int i = 0; i < data.Rows.Count; i++)
+ {
+ string DataTime = data.Rows[i]["DataTime"].ToString();//鏃ユ湡
+ string key = data.Rows[i]["wkshift_code"].ToString(); //鏂规缂栫爜
+ CapaPlan cmp = new CapaPlan();
+ cmp.name = DataTime;
+ cmp.key = key;
+ list.Add(cmp);
+ }
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = list;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝鏃ュ巻鍙屽嚮鏃跺甫鍑哄搴旂殑鏂规]
+ public static ToMessage CapacityPlanningOnclickSelect(string captplanid, string datetime)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ List<CapacityPlanSect> list = new List<CapacityPlanSect>();
+ try
+ {
+ sql = @"select distinct AA.code,AA.name,(case when AA.Stus is null then 'N' else 'Y' end) flag
+ from
+ (
+ select A.code,A.name,B.wkshift_code Stus from TBas_wkshift_info A
+ left join TWkm_capac_plan_sub B on A.code= B.wkshift_code and B.m_id=@captplanid and CONVERT(varchar(100), wkdate, 23)=@datetime
+ ) AA order by code";
+ dynamicParams.Add("@captplanid", captplanid);
+ dynamicParams.Add("@datetime", datetime);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ for (int i = 0; i < data.Rows.Count; i++)
+ {
+ string code = data.Rows[i]["code"].ToString();//鏂规缂栫爜
+ string name = data.Rows[i]["name"].ToString();//鏂规鍚嶇О
+ string flag = data.Rows[i]["flag"].ToString(); //閫変腑鏂规鏍囪瘑
+ CapacityPlanSect cmp = new CapacityPlanSect();
+ cmp.CapCode = code;
+ cmp.CapName = name;
+ cmp.CapStus = flag;
+ cmp.list = new List<object>();
+
+ string sql1 = @"select wktme1_start,wktme2_start,wktme3_start,wktme4_start,wktme5_start from TBas_wkshift_info where code=@code";
+ dynamicParams.Add("@code", code);
+ var db = DapperHelper.selectdata(sql1, dynamicParams);
+
+ for (int j = 0; j < db.Columns.Count; j++) //鏃堕棿娈�
+ {
+ if (db.Rows[0][j].ToString().Trim() != null && db.Rows[0][j].ToString().Trim() != "")
+ {
+ cmp.list.Add(db.Rows[0][j].ToString());
+ }
+ }
+ list.Add(cmp);
+ }
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = list;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[浜ц兘瑙勫垝宸ヤ綔鏃ュ巻閫夋嫨鎻愪氦]
+ public static ToMessage CapacityPlanningGivePlanSubmit(string captplanid, string wkshopcode, string capunitcode, string capsetupcode, string captplantype, List<CapaPlan> objs, string type, string username)
+ {
+ string sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ if (capsetupcode == "" || capsetupcode == null)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "榛樿鏂规閫夋嫨涓嶈兘涓虹┖!";
+ mes.data = null;
+ return mes;
+ }
+ if (objs.Count <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ヤ綔鏃ュ巻閫夋嫨涓嶈兘涓虹┖!";
+ mes.data = null;
+ return mes;
+ }
+ if (type == "Add")
+ {
+ for (int i = 0; i < objs.Count; i++)
+ {
+ sql = @"insert into TWkm_capac_plan_sub(m_id, wkdate,wkshift_code)
+ values(@m_id,@wkdate,@wkshift_code)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ m_id = captplanid,
+ wkdate = objs[i].name,
+ wkshift_code = objs[i].key
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+
+ }
+ if (type == "Update")
+ {
+ //瀹氫箟涓や釜鏁扮粍鐢ㄦ潵瀵规瘮淇敼鍓嶅悗鏃ユ湡鍙婃柟妗堢殑鍙樺寲
+ List<CapaPlan> ids = new List<CapaPlan>();
+ List<CapaPlan> ids1 = new List<CapaPlan>();
+ for (int i = 0; i < objs.Count; i++)
+ {
+ ids.Add(objs[i]);
+ }
+
+ //鏍规嵁id鏌ユ壘鏃ュ巻鏃堕棿
+ string sql2 = @"select CONVERT(varchar(100), wkdate, 23) wkdate,wkshift_code from TWkm_capac_plan_sub where m_id=@m_id";
+ dynamicParams.Add("@m_id", captplanid);
+ var dt2 = DapperHelper.selectdata(sql2, dynamicParams);
+ if (dt2.Rows.Count > 0)
+ {
+ for (int k = 0; k < dt2.Rows.Count; k++)
+ {
+ CapaPlan ids2 = new CapaPlan();
+ ids2.name = dt2.Rows[k]["wkdate"].ToString();
+ ids2.key = dt2.Rows[k]["wkshift_code"].ToString();
+ ids1.Add(ids2);
+ }
+ }
+
+ List<CapaPlan> list3 = ids.Except(ids1).ToList(); //琛ㄧずids涓摢浜涘�兼槸ids1涓墍涓嶅瓨鍦ㄧ殑;
+ List<CapaPlan> list4 = ids1.Except(ids).ToList(); //琛ㄧずids1涓摢浜涘�兼槸ids涓墍涓嶅瓨鍦ㄧ殑;
+ list4 = list3.Union(list4).ToList();
+ //鏌ユ壘鍏抽敭宸ュ簭璁惧銆佸伐浣嶇兢缁勭殑鎵�鏈夎澶�
+ string sql3 = @"select distinct A.code,A.name from TEqpInfo A
+ left join TFlw_Rteqp B on A.code=B.eqp_code
+ left join TFlw_Rtdt D on B.step_code=D.step_code
+ where A.wksp_code=@wkshopcode and D.first_choke='Y' order by A.code";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ var dt3 = DapperHelper.selectdata(sql3, dynamicParams);
+ if (list4.Count > 0) //濡傛灉鏃ユ湡鏈夊彉鍔�
+ {
+ if (dt3.Rows.Count > 0)
+ {
+ for (int m = 0; m < list4.Count; m++)
+ {
+ for (int n = 0; n < dt3.Rows.Count; n++)
+ {
+ string sql4 = @"select A.wo_code,A.eqp_code,A.Time_Start,A.time_end,
+ (case B.Status when 'SCHED' then '宸叉帓绋�' when 'ALLOC' then '宸叉淳鍙�' when 'START' then '宸插紑宸�' end ) status
+ from TK_Wrk_EqpAps A
+ left join TK_Wrk_Man B on A.wo_code=B.wo_code
+ left join TEqpInfo C on A.eqp_code=C.code
+ where CONVERT(varchar(100), time_start, 23)=@time_start and A.eqp_code=@eqp_code and B.isaps='Y' and B.status IN('SCHED','ALLOC','START')";
+ dynamicParams.Add("@time_start", list4[m].name);
+ dynamicParams.Add("@eqp_code", dt3.Rows[n]["CODE"]);
+ var dt4 = DapperHelper.selectdata(sql4, dynamicParams);
+ if (dt4.Rows.Count > 0)
+ {
+ for (int g = 0; g < dt4.Rows.Count; g++)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "淇敼澶辫触锛�,鏃ユ湡锛�" + dt4.Rows[g]["TIME_START"] + "鏈夈��" + dt4.Rows[g]["STATUS"] + "銆戝伐鍗曪細" + dt4.Rows[g]["WO_CODE"] + "";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ }
+ }
+ }
+ //鏇存柊鎺掍骇鐢熶骇璧勬簮涓昏〃
+ sql = @"update TWkm_capac_plan set wkshift_code=@wkshift_code,classtype=@classtype,lm_user=@lm_user,lm_date=@lm_time where id=@id";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ id = captplanid,
+ wkshift_code = capsetupcode,
+ classtype = captplantype,
+ lm_user = username,
+ lm_time = DateTime.Now.ToString()
+ }
+ });
+ //鍒犻櫎鎺掍骇鐢熶骇璧勬簮瀛愯〃
+ sql = @"delete TWkm_capac_plan_sub where m_id=@id";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ id = captplanid
+ }
+ });
+ //寰幆鍐欏叆鎺掍骇鐢熶骇璧勬簮瀛愯〃
+ for (int i = 0; i < objs.Count; i++)
+ {
+ sql = @"insert into TWkm_capac_plan_sub(m_id,wkdate,wkshift_code) values(@m_id,@wkdate,@wkshift_code)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ m_id = captplanid,
+ wkdate = objs[i].name,
+ wkshift_code = objs[i].key
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[鑷姩鎺掔▼宸ュ崟鏌ヨ]
+ public static ToMessage AdvancedSchedulingSearch(string workshop, string wocode, string partcode, string partname, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (workshop != "" && workshop != null)
+ {
+ search += "and A.wkshp_code=@workshop ";
+ dynamicParams.Add("@workshop", workshop);
+ }
+ if (wocode != "" && wocode != null)
+ {
+ search += "and A.wo_code like '%'+@wocode+'%' ";
+ dynamicParams.Add("@wocode", wocode);
+ }
+ if (partcode != "" && partcode != null)
+ {
+ search += "and A.materiel_code like '%'+@partcode+'%' ";
+ dynamicParams.Add("@partcode", partcode);
+ }
+ if (partname != "" && partname != null)
+ {
+ search += "and C.partname like '%'+@partname+'%' ";
+ dynamicParams.Add("@partname", partname);
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select
+ A.id AdvaScheId,
+ A.status AdvaScheStus,
+ A.wo_code AdvaScheWorkCode,
+ A.wkshp_code AdvaScheWorkShopid,
+ M.org_name AdvaScheWorkShop,
+ A.materiel_code AdvaSchePartNumber,
+ C.partname AdvaSchePartName,
+ C.partspec AdvaSchePartSpec,
+ D.name AdvaSchePartModel,
+ A.plan_qty AdvaScheQty,
+ U.name AdvaScheUom,
+ isnull(E.sched_qty,0) AdvaScheYPQty,
+ CONVERT(varchar(100), A.saleOrderDeliveryDate, 23) AdvaScheEndDate,
+ convert(varchar(20),isnull(E.sched_qty,0))+'/'+convert(varchar(20),isnull(A.plan_qty,0)) AdvaScheSpeed,
+ A.route_code AdvaScheRoutid,
+ F.name AdvaScheRoutName,
+ E.step_code AdvaScheBotProcid,
+ G.stepname AdvaScheBotProcName,
+ CONVERT(varchar(100), H.maxtime, 23) AdvaSchePCEndDate,
+ CONVERT(varchar(100), H.mintime, 23) AdvaSchePCStartDate,
+ (case when CONVERT(varchar(100), H.maxtime, 23)<=CONVERT(varchar(100), E.plan_enddate, 23) then 'Y' when H.MAXTime is null then 'Y' else 'N' end) Flag,
+ (case when A.PiroQue='1' then '鐗规��' when A.PiroQue='2' then '绱ф��' when A.PiroQue='3' then '姝e父' end) AdvaSchePiroQue
+ from TK_Wrk_Man A
+ left join TMateriel_Info C on C.partcode= A.materiel_code
+ left join T_Dict D on C.stocktype_code= d.code
+ left join TK_Wrk_Step E on E.wo_code=A.wo_code
+ left join TFlw_Rout F on A.route_code=F.code
+ left join TStep G on E.step_code=G.stepcode
+ left join (select wo_code, max(TIME_END) MAXTime,min(time_start) MINTime from TK_Wrk_EqpAps group by wo_code) H on A.wo_code=H.wo_code
+ left join TUom U on C.uom_code=U.code
+ left join TOrganization M on A.wkshp_code=M.org_code
+ where E.isbott = 'Y' and A.status='NOSCHED' and A.isaps='Y' " + search;
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鎺掍骇璁惧淇℃伅]
+ public static List<AdvancedSchedulingDevice> OnclickAdvancedSchedulingDevice(string wocode, string wkshpcode, string partcode, string startdate, string enddate, ref ToMessage mes)
+ {
+ string sql = "", sql0 = "";
+ var dynamicParams = new DynamicParameters();
+ List<AdvancedSchedulingDevice> list = new List<AdvancedSchedulingDevice>();
+ DataTable dt, dt1;
+
+ DateTime beginDate = Convert.ToDateTime(startdate);
+ DateTime endDate = DateTime.Parse(enddate);
+ try
+ {
+ if (beginDate > endDate)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "瑕佹眰浜や粯鏃堕棿涓嶈兘灏忎簬褰撳墠绯荤粺鏃堕棿锛�";
+ mes.data = null;
+ return list;
+ }
+ bool IsCap = false; //鏄惁璁剧疆浜ц兘
+ //閫氳繃宸ュ崟鏌ユ壘瀵瑰簲杞﹂棿宸ヨ壓璺嚎涓嬪叧閿伐搴忔墍鍏宠仈鐨勮澶囨槸鍚﹀彲鐢�
+ sql = @"select distinct C.eqp_code ,D.Enable from TK_Wrk_Man A
+ left join TFlw_Rout K on A.route_code=K.code
+ left join TFlw_Rtdt B on K.code=B.rout_code and B.first_choke='Y'
+ left join TFlw_Rteqp C on B.step_code= C.step_code
+ left join TEqpInfo D on C.eqp_code=D.code
+ where A.wo_code=@wocode and A.materiel_code=@partcode and D.wksp_code=@wkshpcode";
+ dynamicParams.Add("@wocode", wocode);
+ dynamicParams.Add("@partcode", partcode);
+ dynamicParams.Add("@wkshpcode", wkshpcode);
+ var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt_0.Rows.Count > 0)
+ {
+ int cout = dt_0.Rows.Count;
+ int num = 0;
+ for (int m = 0; m < dt_0.Rows.Count; m++)
+ {
+ if (dt_0.Rows[m]["Enable"].ToString() == "N")
+ {
+ num = num + 1;
+ }
+ }
+ if (num == cout)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璁惧涓嶅彲鐢紒";
+ mes.data = null;
+ return list;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ヨ壓璺嚎鏈叧鑱旇澶囷紒";
+ mes.data = null;
+ return list;
+ }
+
+ //閫氳繃宸ュ崟鏌ユ壘宸ヨ壓璺嚎瀵瑰簲鍏抽敭宸ュ簭鎵�鍏宠仈鐨勮澶囨墍灞炶溅闂�
+ sql0 = @"select distinct D.wksp_code from TK_Wrk_Man A
+ left join TFlw_Rout K on A.route_code=K.code
+ left join TFlw_Rtdt B on K.code=B.rout_code and B.first_choke='Y'
+ left join TFlw_Rteqp C on B.step_code= C.step_code
+ left join TEqpInfo D on C.eqp_code=D.code
+ where A.wo_code=@wocode and A.materiel_code=@partcode ";
+ dynamicParams.Add("@wocode", wocode);
+ dynamicParams.Add("@partcode", partcode);
+ var dt0 = DapperHelper.selectdata(sql0, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ string sy = "0";
+ for (int i = 0; i < dt0.Rows.Count; i++)
+ {
+ if (dt0.Rows[i]["WKSP_CODE"].ToString() == wkshpcode) //宸ュ崟鍒涘缓杞﹂棿鏄惁绛変簬鎺掍骇璁惧 杞﹂棿
+ {
+ sy = "1";
+ break;
+ }
+ else
+ {
+ sy = "0";
+ }
+ }
+ if (sy == "0")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎺掍骇璁惧杞﹂棿涓庡伐鍗曞垱寤虹殑杞﹂棿涓嶅悓锛�";
+ mes.data = null;
+ return list;
+ }
+ else
+ {
+ List<APSList> listData = SchedulingMethod.SchedulingMethodTF(wocode, wkshpcode, partcode);
+ for (DateTime date = beginDate; date <= endDate; date = date.AddDays(1))
+ {
+ AdvancedSchedulingDevice tbj = new AdvancedSchedulingDevice();
+ tbj.YearDate = date.ToString("yyyy-MM-dd");
+ tbj.children = new List<AdvancedSchedulingDeviceCont>();
+ for (int j = 0; j < listData.Count; j++)
+ {
+ if (listData[j].AdvaDevicCropMob.ToString() == "0" || listData[j].AdvaDevicRhythm.ToString() == "")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎺掔▼璁惧" + listData[j].eqp_id.ToString() + "绋煎姩鐜囦笉鑳戒负0鎴栦负绌猴紒";
+ mes.data = null;
+ return list;
+ }
+ if (listData[j].AdvaDevicRhythm.ToString() == "0" || listData[j].AdvaDevicRhythm.ToString() == "")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎺掔▼璁惧" + listData[j].eqp_id.ToString() + "鏈缃妭鎷嶏紒";
+ mes.data = null;
+ return list;
+ }
+ string sql1 = @"select wktme1_start,wktme2_start,wktme3_start,wktme4_start,wktme5_start,G.name
+ from TWkm_capac_plan E
+ left join TWkm_capac_plan_sub F on E.id=F.m_id
+ left join TBas_wkshift_info G on F.wkshift_code=G.code
+ where E.wkshop=@wkshop and E.eqp_typecode=@eqp_typecode and E.ClassType=@classtype
+ and CONVERT(varchar(100), F.wkdate, 23)=@wkdate and E.enable='Y'";
+ dynamicParams.Add("@wkshop", wkshpcode);
+ dynamicParams.Add("@eqp_typecode", listData[j].Style.ToString());
+ dynamicParams.Add("@classtype", listData[j].ClassType.ToString());
+ dynamicParams.Add("@wkdate", date.ToString("yyyy-MM-dd"));
+ dt1 = DapperHelper.selectdata(sql1, dynamicParams);
+
+ AdvancedSchedulingDeviceCont tbjson = new AdvancedSchedulingDeviceCont();
+ tbjson.AdvaDevicNumber = listData[j].eqp_id.ToString();
+ tbjson.AdvaDevicName = listData[j].name.ToString();
+ tbjson.AdvaDevicCropMob = listData[j].AdvaDevicCropMob.ToString(); //绋煎姩鐜�
+ tbjson.AdvaDevicRhythm = listData[j].AdvaDevicRhythm.ToString(); //鐢熶骇鑺傛媿
+ if (dt1.Rows.Count > 0)
+ {
+ tbjson.OneStartDate = dt1.Rows[0]["wktme1_start"].ToString();
+ tbjson.TwoStartDate = dt1.Rows[0]["wktme2_start"].ToString();
+ tbjson.ThreeStartDate = dt1.Rows[0]["wktme3_start"].ToString();
+ tbjson.FourStartDate = dt1.Rows[0]["wktme4_start"].ToString();
+ tbjson.FiveStartDate = dt1.Rows[0]["wktme5_start"].ToString();
+ tbj.children.Add(tbjson);
+ IsCap = true;
+ }
+ else
+ {
+
+ tbjson.OneStartDate = "";
+ tbjson.TwoStartDate = "";
+ tbjson.ThreeStartDate = "";
+ tbjson.FourStartDate = "";
+ tbjson.FiveStartDate = "";
+ tbj.children.Add(tbjson);
+ }
+ }
+
+ list.Add(tbj);
+ }
+ if (list.Select(p => p.children).ToList().Count > 0)
+ {
+ int one = list.Where(t => t.children.Select(s => s.OneStartDate).Any(x => x != "")).ToList().Count;
+ int two = list.Where(t => t.children.Select(s => s.TwoStartDate).Any(x => x != "")).ToList().Count;
+ int three = list.Where(t => t.children.Select(s => s.ThreeStartDate).Any(x => x != "")).ToList().Count;
+ int four = list.Where(t => t.children.Select(s => s.FourStartDate).Any(x => x != "")).ToList().Count;
+ int five = list.Where(t => t.children.Select(s => s.FiveStartDate).Any(x => x != "")).ToList().Count;
+ if (one <= 0 && two <= 0 && three <= 0 && four <= 0 && five <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ崟鍔犲伐浜у搧瀵瑰簲宸ヨ壓璺嚎璁惧鏈缃骇鑳芥垨鏈缃敓浜ц妭鎷嶏紒";
+ mes.data = null;
+ }
+ }
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璁惧娌℃湁鍏宠仈杞﹂棿锛�";
+ mes.data = null;
+ }
+ return list;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return list;
+ }
+ #endregion
+
+ #region[璁惧宸叉帓绋嬩俊鎭痌
+ public static DataTable AlreadyScheduling(string wocode, string wkshpcode, string partcode, string botproccode, string startdate, string enddate)
+ {
+ var dynamicParams = new DynamicParameters();
+ DataTable dt;
+ try
+ {
+ List<APSList> listData = SchedulingMethod.SchedulingMethodTF(wocode, wkshpcode, partcode);
+ string[] empIds = listData.Select(a => a.eqp_id).ToArray();
+ string str = string.Join(",", empIds);
+ string[] s1 = Array.ConvertAll<string, string>(str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString()); //string鍒嗗壊杞瑂tring[]
+ //string s1 = string.Format("'{0}'", str.Replace(",", "','"));
+
+ string sql = @"select B.wo_code, B.eqp_code,B.time_start,B.time_end, 'S' status , B.alloc_qty,D.partcode as part_code,D.partname as part_name,T.name as uom_name
+ from TK_Wrk_EqpAps B
+ left join TK_Wrk_Man C on B.wo_code=C.wo_code
+ left join TMateriel_Info D on C.materiel_code=D.partcode
+ left join TUom T on D.uom_code=T.code
+ where B.eqp_code in @eqpcode
+ and convert(varchar(100),B.Time_Start,21)>=@startdate and convert(varchar(100),B.Time_End,21)<=@enddate order by time_end";
+ dt = DapperHelper.selectlist(sql, new { eqpcode = s1.ToArray(), startdate = startdate + " 00:00:00", enddate = enddate + " 23:59:59" });
+ //dynamicParams.Add("@s1", new { shopcode = s1.ToArray() });
+ //dynamicParams.Add("@startdate", startdate + " 00:00:00");
+ //dynamicParams.Add("@enddate", enddate + " 23:59:59");
+ //var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt == null || dt.Rows.Count == 0)
+ {
+ return null;
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+
+ return dt;
+ }
+ #endregion
+
+ #region[NEW鎺掍骇璁惧淇℃伅]
+ public static List<AdvancedSchedulingDevice> NewOnclickAdvancedSchedulingDevice(List<ApsOrderSerch> json, ref ToMessage mes)
+ {
+ string sql = "", sql0 = "";
+ var dynamicParams = new DynamicParameters();
+ List<AdvancedSchedulingDevice> list = new List<AdvancedSchedulingDevice>();
+ DataTable dt, dt1;
+ //List<ApsOrderSerch> json = new List<ApsOrderSerch>();
+ try
+ {
+ for (int w = 0; w < json.Count; w++)
+ {
+
+
+ DateTime beginDate = Convert.ToDateTime(json[w].startdate);
+ DateTime endDate = DateTime.Parse(json[w].enddate);
+ if (beginDate > endDate)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "瑕佹眰浜や粯鏃堕棿涓嶈兘灏忎簬褰撳墠绯荤粺鏃堕棿锛�";
+ mes.data = null;
+ return list;
+ }
+ bool IsCap = false; //鏄惁璁剧疆浜ц兘
+ //閫氳繃宸ュ崟鏌ユ壘瀵瑰簲杞﹂棿宸ヨ壓璺嚎涓嬪叧閿伐搴忔墍鍏宠仈鐨勮澶囨槸鍚﹀彲鐢�
+ sql = @"select distinct C.eqp_code ,D.Enable from TK_Wrk_Man A
+ left join TFlw_Rout K on A.route_code=K.code
+ left join TFlw_Rtdt B on K.code=B.rout_code and B.first_choke='Y'
+ left join TFlw_Rteqp C on B.step_code= C.step_code
+ left join TEqpInfo D on C.eqp_code=D.code
+ where A.wo_code=@wocode and A.materiel_code=@partcode and D.wksp_code=@wkshpcode";
+ dynamicParams.Add("@wocode", json[w].wocode);
+ dynamicParams.Add("@partcode", json[w].partcode);
+ dynamicParams.Add("@wkshpcode", json[w].wkshpcode);
+ var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt_0.Rows.Count > 0)
+ {
+ int cout = dt_0.Rows.Count;
+ int num = 0;
+ for (int m = 0; m < dt_0.Rows.Count; m++)
+ {
+ if (dt_0.Rows[m]["Enable"].ToString() == "N")
+ {
+ num = num + 1;
+ }
+ }
+ if (num == cout)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璁惧涓嶅彲鐢紒";
+ mes.data = null;
+ return list;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "宸ヨ壓璺嚎鏈叧鑱旇澶囷紒";
+ mes.data = null;
+ return list;
+ }
+
+ //閫氳繃宸ュ崟鏌ユ壘宸ヨ壓璺嚎瀵瑰簲鍏抽敭宸ュ簭鎵�鍏宠仈鐨勮澶囨墍灞炶溅闂�
+ sql0 = @"select distinct D.wksp_code from TK_Wrk_Man A
+ left join TFlw_Rout K on A.route_code=K.code
+ left join TFlw_Rtdt B on K.code=B.rout_code and B.first_choke='Y'
+ left join TFlw_Rteqp C on B.step_code= C.step_code
+ left join TEqpInfo D on C.eqp_code=D.code
+ where A.wo_code=@wocode and A.materiel_code=@partcode ";
+ dynamicParams.Add("@wocode", json[w].wocode);
+ dynamicParams.Add("@partcode", json[w].partcode);
+ var dt0 = DapperHelper.selectdata(sql0, dynamicParams);
+ if (dt0.Rows.Count > 0)
+ {
+ string sy = "0";
+ for (int i = 0; i < dt0.Rows.Count; i++)
+ {
+ if (dt0.Rows[i]["WKSP_CODE"].ToString() == json[w].wkshpcode) //宸ュ崟鍒涘缓杞﹂棿鏄惁绛変簬鎺掍骇璁惧 杞﹂棿
+ {
+ sy = "1";
+ break;
+ }
+ else
+ {
+ sy = "0";
+ }
+ }
+ if (sy == "0")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎺掍骇璁惧杞﹂棿涓庡伐鍗曞垱寤虹殑杞﹂棿涓嶅悓锛�";
+ mes.data = null;
+ return list;
+ }
+ else
+ {
+ List<APSList> listData = SchedulingMethod.SchedulingMethodTF(json[w].wocode, json[w].wkshpcode, json[w].partcode);
+ for (DateTime date = beginDate; date <= endDate; date = date.AddDays(1))
+ {
+ AdvancedSchedulingDevice tbj = new AdvancedSchedulingDevice();
+ tbj.wo_code = json[w].wocode;
+ tbj.YearDate = date.ToString("yyyy-MM-dd");
+ tbj.children = new List<AdvancedSchedulingDeviceCont>();
+ for (int j = 0; j < listData.Count; j++)
+ {
+ if (listData[j].AdvaDevicCropMob.ToString() == "0" || listData[j].AdvaDevicRhythm.ToString() == "")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎺掔▼璁惧" + listData[j].eqp_id.ToString() + "绋煎姩鐜囦笉鑳戒负0鎴栦负绌猴紒";
+ mes.data = null;
+ return list;
+ }
+ if (listData[j].AdvaDevicRhythm.ToString() == "0" || listData[j].AdvaDevicRhythm.ToString() == "")
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎺掔▼璁惧" + listData[j].eqp_id.ToString() + "鏈缃妭鎷嶏紒";
+ mes.data = null;
+ return list;
+ }
+ string sql1 = @"select wktme1_start,wktme2_start,wktme3_start,wktme4_start,wktme5_start,G.name
+ from TWkm_capac_plan E
+ left join TWkm_capac_plan_sub F on E.id=F.m_id
+ left join TBas_wkshift_info G on F.wkshift_code=G.code
+ where E.wkshop=@wkshop and E.eqp_typecode=@eqp_typecode and E.ClassType=@classtype
+ and CONVERT(varchar(100), F.wkdate, 23)=@wkdate and E.enable='Y'";
+ dynamicParams.Add("@wkshop", json[w].wkshpcode);
+ dynamicParams.Add("@eqp_typecode", listData[j].Style.ToString());
+ dynamicParams.Add("@classtype", listData[j].ClassType.ToString());
+ dynamicParams.Add("@wkdate", date.ToString("yyyy-MM-dd"));
+ dt1 = DapperHelper.selectdata(sql1, dynamicParams);
+
+ AdvancedSchedulingDeviceCont tbjson = new AdvancedSchedulingDeviceCont();
+ tbjson.AdvaDevicNumber = listData[j].eqp_id.ToString();
+ tbjson.AdvaDevicName = listData[j].name.ToString();
+ tbjson.AdvaDevicCropMob = listData[j].AdvaDevicCropMob.ToString(); //绋煎姩鐜�
+ tbjson.AdvaDevicRhythm = listData[j].AdvaDevicRhythm.ToString(); //鐢熶骇鑺傛媿
+ if (dt1.Rows.Count > 0)
+ {
+ tbjson.OneStartDate = dt1.Rows[0]["wktme1_start"].ToString();
+ tbjson.TwoStartDate = dt1.Rows[0]["wktme2_start"].ToString();
+ tbjson.ThreeStartDate = dt1.Rows[0]["wktme3_start"].ToString();
+ tbjson.FourStartDate = dt1.Rows[0]["wktme4_start"].ToString();
+ tbjson.FiveStartDate = dt1.Rows[0]["wktme5_start"].ToString();
+ tbj.children.Add(tbjson);
+ IsCap = true;
+ }
+ else
+ {
+
+ tbjson.OneStartDate = "";
+ tbjson.TwoStartDate = "";
+ tbjson.ThreeStartDate = "";
+ tbjson.FourStartDate = "";
+ tbjson.FiveStartDate = "";
+ tbj.children.Add(tbjson);
+ }
+ }
+
+ list.Add(tbj);
+ }
+ if (list.Select(p => p.children).ToList().Count > 0)
+ {
+ int one = list.Where(t => t.children.Select(s => s.OneStartDate).Any(x => x != "")).ToList().Count;
+ int two = list.Where(t => t.children.Select(s => s.TwoStartDate).Any(x => x != "")).ToList().Count;
+ int three = list.Where(t => t.children.Select(s => s.ThreeStartDate).Any(x => x != "")).ToList().Count;
+ int four = list.Where(t => t.children.Select(s => s.FourStartDate).Any(x => x != "")).ToList().Count;
+ int five = list.Where(t => t.children.Select(s => s.FiveStartDate).Any(x => x != "")).ToList().Count;
+ if (one <= 0 && two <= 0 && three <= 0 && four <= 0 && five <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ崟鍔犲伐浜у搧瀵瑰簲宸ヨ壓璺嚎璁惧鏈缃骇鑳芥垨鏈缃敓浜ц妭鎷嶏紒";
+ mes.data = null;
+ }
+ }
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "璁惧娌℃湁鍏宠仈杞﹂棿锛�";
+ mes.data = null;
+ }
+ }
+ return list;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return list;
+ }
+ #endregion
+
+ #region[New璁惧宸叉帓绋嬩俊鎭痌
+ public static List<DataTable> NewAlreadyScheduling(List<ApsOrderSerch> json)
+ {
+ var dynamicParams = new DynamicParameters();
+ DataTable dt;
+ List<DataTable> list = new List<DataTable>();
+ try
+ {
+ for (int i = 0; i < json.Count; i++)
+ {
+ List<APSList> listData = SchedulingMethod.SchedulingMethodTF(json[i].wocode, json[i].wkshpcode, json[i].partcode);
+ string[] empIds = listData.Select(a => a.eqp_id).ToArray();
+ string str = string.Join(",", empIds);
+ string[] s1 = Array.ConvertAll<string, string>(str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString()); //string鍒嗗壊杞瑂tring[]
+ //string s1 = string.Format("'{0}'", str.Replace(",", "','"));
+
+ string sql = @"select B.wo_code, B.eqp_code,B.time_start,B.time_end, 'S' status , B.alloc_qty,D.partcode as part_code,D.partname as part_name,T.name as uom_name
+ from TK_Wrk_EqpAps B
+ left join TK_Wrk_Man C on B.wo_code=C.wo_code
+ left join TMateriel_Info D on C.materiel_code=D.partcode
+ left join TUom T on D.uom_code=T.code
+ where B.eqp_code in @eqpcode
+ and convert(varchar(100),B.Time_Start,21)>=@startdate and convert(varchar(100),B.Time_End,21)<=@enddate order by time_end";
+ dt = DapperHelper.selectlist(sql, new { eqpcode = s1.ToArray(), startdate = json[i].startdate + " 00:00:00", enddate = json[i].enddate + " 23:59:59" });
+ //dynamicParams.Add("@s1", new { shopcode = s1.ToArray() });
+ //dynamicParams.Add("@startdate", startdate + " 00:00:00");
+ //dynamicParams.Add("@enddate", enddate + " 23:59:59");
+ //var dt_0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt == null || dt.Rows.Count == 0)
+ {
+ return null;
+ }
+ list.Add(dt);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+
+ return list;
+ }
+ #endregion
+
+ #region[鎺掔▼鏁版嵁鎻愪氦]
+ public static ToMessage SubmitAlreadyScheduling(string username, string wocode, string botprocecode, List<AlreadyScheduling> objs)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ string maxTime = objs.Max(t => Convert.ToDateTime(t.AlreEndDate).ToString("yyyy-MM-dd HH:mm")); //鏈�澶у��
+ string minTime = objs.Min(t => Convert.ToDateTime(t.AlreEndDate).ToString("yyyy-MM-dd HH:mm")); //鏈�灏忓��
+ sql = @"select
+ A.id, A.status,
+ '0' BottFrointv, convert(varchar(100),B.plan_enddate-0,21) Plan_end ,
+ convert(varchar(100),B.plan_startdate+0,21) plan_start
+ from TK_Wrk_Step A
+ left join TK_Wrk_Man B on A.wo_code=B.wo_code
+ where A.wo_code=@wocode and A.step_code=@botprocecode and A.isbott='Y'";
+ dynamicParams.Add("@wocode", wocode);
+ dynamicParams.Add("@botprocecode", botprocecode);
+ var dt = DapperHelper.selectdata(sql, dynamicParams);
+ string ID = dt.Rows[0]["ID"].ToString(); // mes_tk_wrk_step 琛� 鐡跺緞宸ュ簭琛孖D
+ string status = dt.Rows[0]["STATUS"].ToString();
+ Decimal nm = 0; //鐡跺緞宸ュ簭鐨勫墠缃ぉ鏁�
+ Decimal nn = Decimal.Parse(dt.Rows[0]["BottFrointv"].ToString()); //鐡跺緞宸ュ簭鐨勫悗缃ぉ鏁�
+ if (status != "NEW" && status != "SCHED" && status != "NOSCHED") //宸ュ簭浠诲姟鐨勭姸鎬佸凡缁忔淳鍙戯紙瀹℃牳锛�
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鎺掔▼浠诲姟宸茬粡娲惧彂,鎻愪氦鍙栨秷锛�";
+ mes.data = null;
+ return mes;
+ }
+ if (status == "SCHED") //宸ュ簭浠诲姟鐨勭姸鎬佸凡缁忔帓绋�
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鎺掔▼浠诲姟宸茬粡鎺掔▼,鎻愪氦鍙栨秷锛�";
+ mes.data = null;
+ return mes;
+ }
+
+ list.Clear();
+ //鎸夊伐鍗曞垹闄よ澶囦换鍔¤〃(鏃ヤ换鍔¤〃锛�
+ sql = @"delete TK_Wrk_EqpAps where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode } });
+ //鎸夊伐鍗曞垹闄よ澶囦换鍔¤〃(姹囨�昏〃锛�
+ sql = @"delete TK_Wrk_EqpApsSum where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode } });
+ //鎸夊伐鍗曞垹闄よ澶囦换鍔¤〃(姹囨�昏〃锛夌墿鏂欒〃
+ sql = @"delete TK_Wrk_EqpSum_Allo where wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode } });
+
+ float n = 0; //绱鎺掍骇鎬绘暟
+
+ for (int i = 0; i < objs.Count; i++) //寰幆娣诲姞姣忎釜璁惧鐨勬満鍙颁换鍔�
+ {
+ sql = @"insert into TK_Wrk_EqpAps (wo_code,step_taid,eqp_code,time_start,time_end,alloc_qty,status)
+ values(@wo_code,@step_taid,@eqp_code,@time_start,@time_end,@alloc_qty,@status)";
+ list.Add(new { str = sql, parm = new { wo_code = wocode, step_taid = ID, eqp_code = objs[i].AlreDevicNumber, time_start = objs[i].AlreStartDate, time_end = objs[i].AlreEndDate, alloc_qty = objs[i].AlreQty, status = "NEW" } });
+ n = n + float.Parse(objs[i].AlreQty.ToString());
+ }
+
+ bool aa = DapperHelper.DoTransaction(list); //鎻愪氦璁惧浠诲姟
+ if (!aa)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鍏堥鎺�,鍐嶇偣鍑绘彁浜わ紒";
+ mes.data = null;
+ return mes;
+ }
+ list.Clear();
+ //鐢熸垚璁惧浠诲姟姹囨�昏〃 锛堟牴鎹澶囨棩浠诲姟琛級
+ sql = "select distinct eqp_code from TK_Wrk_EqpAps where wo_code=@wocode";
+ dynamicParams.Add("@wocode", wocode);
+ var dt1 = DapperHelper.selectdata(sql, dynamicParams);
+
+ for (int i = 0; i < dt1.Rows.Count; i++)
+ {
+ sql = @"insert into TK_Wrk_EqpApsSum (wo_code,eqp_code,step_taid,p_date, t_date, qty,status)
+ select min(wo_code),min(eqp_code),min(step_taid),min(time_start),max(time_end),sum(Alloc_Qty),'NEW' from TK_Wrk_EqpAps
+ where wo_code=@wocode and eqp_code=@eqp_code";
+ list.Add(new { str = sql, parm = new { wocode = wocode, eqp_code = dt1.Rows[i]["EQP_CODE"].ToString() } });
+ }
+
+ bool aa1 = DapperHelper.DoTransaction(list); //鎻愪氦璁惧浠诲姟
+ if (!aa1)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鐢熸垚璁惧浠诲姟姹囨�昏〃鍑洪敊锛屾帓浜уけ璐ワ紒";
+ mes.data = null;
+ return mes;
+ }
+ list.Clear();
+ //鍐欏叆璁惧浠诲姟(姹囨�昏〃)鐢ㄦ枡 璁″垝鏁伴噺*瀛愪欢鍩烘湰鐢ㄩ噺*锛�1+鎹熻�楃巼锛�/姣嶄欢鍩烘湰鐢ㄩ噺
+ sql = @"insert into TK_Wrk_EqpSum_Allo(m_id, seq, materiel_code, qty,wo_code,materieltype)
+ select A.id M_id, B.seq,B.materiel_code,(round(A.qty,2)*BE.Base_Quantity*(1+BE.LOSS_QUANTITY/100))/BM.quantity qty,A.wo_code,B.materieltype
+ from TK_Wrk_EqpApsSum A
+ left join TK_Wrk_Allo B on A.Wo_Code= B.Wo_Code
+ left join TBom_Deta BE ON B.bom_id=BE.m_id and B.materiel_code=BE.smateriel_code
+ left join TBom_Main BM on BE.m_Id=BM.id where A.wo_code=@wocode";
+ list.Add(new { str = sql, parm = new { wocode = wocode } });
+
+ //鏇存柊 宸ュ簭浠诲姟鍗曠殑銆愮摱寰勫伐搴忋�� 鎺掍骇棰勫紑宸ユ棩鏈熴�佹帓浜ч瀹屽伐鏃ユ湡銆佺姸鎬侊細NEW===>SCHED 銆佸凡鎺掍骇鏁伴噺
+ sql = @"update TK_Wrk_Step set plan_startdate =convert(varchar(100),@plan_startdate,21), plan_enddate =convert(varchar(100),@plan_enddate,21), status = 'SCHED', sched_qty =@sched_qty where id =@id";
+ list.Add(new { str = sql, parm = new { plan_startdate = minTime, plan_enddate = maxTime, sched_qty = n, id = ID } });
+
+ //宸ュ崟宸ュ簭鐨勨�滆鍒掑紑鏈烘棩鏈� = 鐡跺緞宸ュ簭鐨勯寮�宸ユ棩鏈� - 鐡跺緞宸ュ簭鐨勫墠缃棩鏈燂級 涓诲伐鍗曪細璁″垝瀹屽伐鏃ユ湡 = 鐡跺緞宸ュ簭鐨勯瀹屽伐鏃ユ湡 + 鐡跺緞宸ュ簭鐨勫悗缃棩鏈�
+ sql = @"update TK_Wrk_Step set plan_startdate =convert(varchar(100),@plan_startdate,21), plan_enddate =convert(varchar(100),@plan_enddate,21), status = 'SCHED', sched_qty =@sched_qty where wo_code =@wocode and isbott='N'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ plan_startdate = Convert.ToDateTime(minTime).AddDays(Convert.ToDouble(-nm)).ToString("yyyy-MM-dd"),
+ plan_enddate = Convert.ToDateTime(maxTime).AddDays(Convert.ToDouble(nn)).ToString("yyyy-MM-dd"),
+ sched_qty = n,
+ wocode = wocode
+ }
+ });
+ //涓诲伐鍗曠殑鈥滆鍒掑紑鏈烘棩鏈� = 鐡跺緞宸ュ簭鐨勯寮�宸ユ棩鏈� - 鐡跺緞宸ュ簭鐨勫墠缃棩鏈燂級 涓诲伐鍗曪細璁″垝瀹屽伐鏃ユ湡 = 鐡跺緞宸ュ簭鐨勯瀹屽伐鏃ユ湡 + 鐡跺緞宸ュ簭鐨勫悗缃棩鏈�
+ sql = @"update TK_Wrk_Man set status='SCHED',plan_startdate =convert(varchar(100),@plan_startdate,21), plan_enddate =convert(varchar(100),@plan_enddate,21), exchag='Y',allocfag='N' where wo_code =@wocode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ plan_startdate = Convert.ToDateTime(minTime).AddDays(Convert.ToDouble(-nm)).ToString("yyyy-MM-dd"),
+ plan_enddate = Convert.ToDateTime(maxTime).AddDays(Convert.ToDouble(nn)).ToString("yyyy-MM-dd"),
+ sched_qty = n,
+ wocode = wocode
+ }
+ });
+ bool aa2 = DapperHelper.DoTransaction(list); //鎻愪氦璁惧浠诲姟
+ if (aa2)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎻愪氦鎺掔▼鎴愬姛锛�";
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎻愪氦鎺掔▼澶辫触锛�";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+
+ #region[鐢熶骇鍏ュ簱鏉$爜琛ユ墦]
+ public static ToMessage ProductInHouseLabCode(string ordercode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鑾峰彇鏈亾宸ュ簭鎶ュ伐鏉$爜鏁版嵁
+ sql = @"select * from(
+ select A.inbarcode,A.wo_code,P.partcode,P.partname,P.partspec,
+ A.good_qty,U.username,A.lm_date
+ from TK_Wrk_Record A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ inner join TMateriel_Info P on A.materiel_code=P.partcode
+ inner join TUser U on A.lm_user=U.usercode
+ where A.style='B' and S.isend='Y' and A.good_qty>0
+ union all
+ select A.inbarcode,A.wo_code,P.partcode,P.partname,P.partspec,
+ A.sqty as sqty,U.username,A.lm_date
+ from TK_Wrk_OutRecord A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ inner join TMateriel_Info P on A.materiel_code=P.partcode
+ inner join TUser U on A.lm_user=U.usercode
+ where A.style='S' and S.isend='Y' and A.sqty>0
+ ) as AA where AA.wo_code=@ordercode";
+ dynamicParams.Add("@ordercode", ordercode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇鍏ュ簱閫氳繃杞﹂棿鏌ユ壘鐢熶骇璁㈠崟]
+ public static ToMessage ProductInHouseWkshopOrder(string ordertype, string wkshopcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ if (ordertype == "Y") //鏈夋簮鍗�
+ {
+ sql = @"select distinct AA.ordercode from (
+ select A.m_po as ordercode
+ from TK_Wrk_Man A
+ inner join TK_Wrk_Step B on A.wo_code=B.wo_code
+ inner join TK_Wrk_Record S on B.wo_code=S.wo_code and B.step_code=S.step_code
+ where S.style='B' and B.isend='Y' and A.m_po<>'' and S.good_qty>0 and S.good_qty>isnull(S.inhouseqty,0) and A.wkshp_code=@wkshopcode
+ union all
+ select A.m_po as ordercode
+ from TK_Wrk_Man A
+ inner join TK_Wrk_Step B on A.wo_code=B.wo_code
+ inner join TK_Wrk_OutRecord S on B.wo_code=S.wo_code and B.step_code=S.step_code
+ where S.style='S' and B.isend='Y' and A.m_po<>'' and S.sqty>0 and S.sqty>isnull(S.inhouseqty,0) and A.wkshp_code=@wkshopcode
+ ) as AA";
+ }
+ if (ordertype == "N")
+ {
+ sql = @"select distinct AA.ordercode from (
+ select A.wo_code as ordercode
+ from TK_Wrk_Man A
+ inner join TK_Wrk_Step B on A.wo_code=B.wo_code
+ inner join TK_Wrk_Record S on B.wo_code=S.wo_code and B.step_code=S.step_code
+ where S.style='B' and B.isend='Y' and A.m_po='' and S.good_qty>0 and S.good_qty>isnull(S.inhouseqty,0) and A.wkshp_code=@wkshopcode
+ union all
+ select A.wo_code as ordercode
+ from TK_Wrk_Man A
+ inner join TK_Wrk_Step B on A.wo_code=B.wo_code
+ inner join TK_Wrk_OutRecord S on B.wo_code=S.wo_code and B.step_code=S.step_code
+ where S.style='S' and B.isend='Y' and A.m_po='' and S.sqty>0 and S.sqty>isnull(S.inhouseqty,0) and A.wkshp_code=@wkshopcode
+ ) as AA";
+ }
+
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇鍏ュ簱淇℃伅鏌ヨ]
+ public static ToMessage ProductInHouseOrderSearch(string wkshopcode, string erpordercode, string mesordercode, string partcode, string partname, string partspec, string startorderdate, string endorderdate)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (wkshopcode != "" && wkshopcode != null)
+ {
+ search += "and AA.wkshp_code=@wkshopcode ";
+ dynamicParams.Add("@wkshopcode", wkshopcode);
+ }
+ if (erpordercode != "" && erpordercode != null)
+ {
+ search += "and AA.m_po like '%'+@erpordercode+'%' ";
+ dynamicParams.Add("@erpordercode", erpordercode);
+ }
+ if (mesordercode != "" && mesordercode != null)
+ {
+ search += "and AA.wo_code like '%'+@mesordercode+'%' ";
+ dynamicParams.Add("@mesordercode", mesordercode);
+ }
+ if (partcode != "" && partcode != null)
+ {
+ search += "and AA.partcode like '%'+@partcode+'%' ";
+ dynamicParams.Add("@partcode", partcode);
+ }
+ if (partname != "" && partname != null)
+ {
+ search += "and AA.partname like '%'+@partname+'%' ";
+ dynamicParams.Add("@partname", partname);
+ }
+ if (partspec != "" && partspec != null)
+ {
+ search += "and AA.partspec like '%'+@partspec+'%' ";
+ dynamicParams.Add("@partspec", partspec);
+ }
+ if (startorderdate != "" && startorderdate != null)
+ {
+ search += "and AA.lm_date between @startorderdate and @endorderdate ";
+ dynamicParams.Add("@opencheckdate", startorderdate + " 00:00:00");
+ dynamicParams.Add("@endorderdate", endorderdate + " 23:59:59");
+ }
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select * from(
+ select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname,
+ A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname,
+ E.saleOrderqty,E.qty,M.plan_qty,A.good_qty,isnull(A.inhouseqty,0) as inhouseqty,A.good_qty-isnull(A.inhouseqty,0) as stinhouseqty,M.lm_date,A.style
+ from TK_Wrk_Record A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ inner join TK_Wrk_Man M on S.wo_code=M.wo_code
+ inner join TMateriel_Info P on M.materiel_code=P.partcode
+ left join TKimp_Ewo E on M.sourceid=E.id
+ left join T_Sec_Stck K on E.stck_code=K.code
+ where A.style='B' and S.isend='Y' and A.good_qty>0
+ union all
+ select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname,
+ A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname,
+ E.saleOrderqty,E.qty,M.plan_qty,A.sqty as sqty,isnull(A.inhouseqty,0) as inhouseqty,A.sqty-isnull(A.inhouseqty,0) as stinhouseqty,M.lm_date,A.style
+ from TK_Wrk_OutRecord A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ inner join TK_Wrk_Man M on S.wo_code=M.wo_code
+ inner join TMateriel_Info P on M.materiel_code=P.partcode
+ left join TKimp_Ewo E on M.sourceid=E.id
+ left join T_Sec_Stck K on E.stck_code=K.code
+ where A.style='S' and S.isend='Y' and A.sqty>0
+ ) as AA where AA.good_qty>AA.inhouseqty " + search;
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data;
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇鍏ュ簱鎻愪氦]
+ public static ToMessage ProductInHouseOrderSeave(string username, JObject obj)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ var dynamicParams1 = new DynamicParameters();
+ try
+ {
+ string sub = obj["sub"].ToString();//鏄庣粏
+ string subsum = obj["subsum"].ToString();//姹囨��
+ //鑾峰彇鎶ュ伐鏄庣粏
+ JArray sub_arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(sub);
+ //鑾峰彇姹囨��
+ JArray subsum_arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(subsum);
+
+ //鍥炲啓鎶ュ伐璁板綍涓昏〃銆佸伐鍗曞伐搴忚〃宸插叆搴撴暟閲忋�佸啓鍏ES搴撳瓨琛�
+ for (int i = 0; i < sub_arra.Count; i++)
+ {
+ if (sub_arra[i]["style"].ToString() == "B")
+ {
+ //鍥炲啓鎶ュ伐璁板綍涓昏〃鐨勫叆搴撴暟閲�
+ sql = @"update TK_Wrk_Record set inhouseqty=inhouseqty+@stinhouseqty where inbarcode=@inbarcode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ stinhouseqty = decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()),
+ inbarcode = sub_arra[i]["inbarcode"].ToString()
+ }
+ });
+ }
+ if (sub_arra[i]["style"].ToString() == "S")
+ {
+ //鍥炲啓澶栧崗鏀舵枡璁板綍涓昏〃鐨勫叆搴撴暟閲�
+ sql = @"update TK_Wrk_OutRecord set inhouseqty=inhouseqty+@stinhouseqty where inbarcode=@inbarcode";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ stinhouseqty = decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()),
+ inbarcode = sub_arra[i]["inbarcode"].ToString()
+ }
+ });
+ }
+ //鍥炲啓宸ュ崟宸ュ簭琛ㄦ湯閬撳伐搴忓凡鍏ュ簱鏁伴噺
+ sql = @"update TK_Wrk_Step set inhouseqty=inhouseqty+@stinhouseqty where wo_code=@wo_code and step_code=@step_code and isend='Y'";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ stinhouseqty = decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()),
+ wo_code = sub_arra[i]["wo_code"].ToString(),
+ step_code = sub_arra[i]["step_code"].ToString()
+ }
+ });
+ //鍐欏叆MES搴撳瓨琛�
+ sql = @"insert into TK_WMS_Stock(hbillno,labcode,materiel_code,storehouse_code,qty,lm_user,lm_date)
+ values(@hbillno,@labcode,@materiel_code,@storehouse_code,@qty,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ hbillno = obj["head"]["hbillno"].ToString(),
+ labcode = sub_arra[i]["inbarcode"].ToString(),
+ materiel_code = sub_arra[i]["partcode"].ToString(),
+ storehouse_code = sub_arra[i]["stockcode"].ToString(),
+ qty = decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()),
+ lm_user = username,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+ }
+ //鍐橫ES鍏ュ簱璁板綍涓昏〃
+ sql = @"insert into TK_WMS_Inwh_Main(docu_typecode,hbillno,hsoucenillnoid,hsoucenillno,saleorderid,saleordercode,status,wkshpcode,lm_user,lm_date)
+ values(@docu_typecode,@hbillno,@hsoucenillnoid,@hsoucenillno,@saleorderid,@saleordercode,@status,@wkshpcode,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ docu_typecode = "1202",
+ hbillno = obj["head"]["hbillno"].ToString(),
+ hsoucenillnoid = obj["head"]["sourceVoucherId"].ToString(),
+ hsoucenillno = obj["head"]["sourceVoucherCode"].ToString(),
+ saleorderid = obj["head"]["saleOrderId"].ToString(),
+ saleordercode = obj["head"]["saleOrderCode"].ToString(),
+ status = "NEW",
+ wkshpcode = obj["head"]["wkshpcode"].ToString(),
+ lm_user = username,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+
+ //鑾峰彇ERP鍏ュ簱琛╯ql
+ //DataTable dt = DapperHelper.lissql("h_p_MesInErpProductWareHous");
+ //鍐欏叆ERP鍏ュ簱璁板綍涓昏〃
+ //sql = @"" + dt.Rows[0]["cname"].ToString() + "";
+ //list.Add(new
+ //{
+ // str = sql,
+ // parm = new
+ // {
+ // code = obj["head"]["hbillno"].ToString(),
+ // sourceVoucherId = obj["head"]["sourceVoucherId"].ToString(),
+ // sourceVoucherCode = obj["head"]["sourceVoucherCode"].ToString(),
+ // saleOrderId = obj["head"]["saleOrderId"].ToString(),
+ // saleOrderCode = obj["head"]["saleOrderCode"].ToString(),
+ // rdDirectionFlag = obj["head"]["rdDirectionFlag"].ToString(),
+ // makerid = obj["head"]["makerid"].ToString(),
+ // maker = obj["head"]["maker"].ToString(),
+ // accountingyear = obj["head"]["accountingyear"].ToString(),
+ // VoucherYear = obj["head"]["VoucherYear"].ToString(),
+ // VoucherPeriod = obj["head"]["VoucherPeriod"].ToString(),
+ // ManufactureOrderCode = obj["head"]["ManufactureOrderCode"].ToString(),
+ // idbusitype = obj["head"]["idbusitype"].ToString(),
+ // iddepartment = obj["head"]["iddepartment"].ToString(),
+ // idrdstyle = obj["head"]["idrdstyle"].ToString(),
+ // idwarehouse = obj["head"]["idwarehouse"].ToString(),
+ // voucherState = obj["head"]["voucherState"].ToString(),
+ // idvouchertype = obj["head"]["idvouchertype"].ToString(),
+ // voucherdate = obj["head"]["voucherdate"].ToString(),
+ // madedate = obj["head"]["madedate"].ToString(),
+ // createdtime = obj["head"]["createdtime"].ToString(),
+ // DataSource = obj["head"]["DataSource"].ToString(),
+ // idsourcevouchertype= obj["head"]["idsourcevouchertype"].ToString()
+
+ // }
+ //});
+ //鍐欏叆ERP銆丮ES鍏ュ簱璁板綍瀛愯〃
+ for (int j = 0; j < subsum_arra.Count; j++)
+ {
+ //鍐欏叆ERP鍏ュ簱璁板綍瀛愯〃
+ //sql = @"" + dt.Rows[1]["cname"].ToString() + "";
+ //list.Add(new
+ //{
+ // str = sql,
+ // parm = new
+ // {
+ // code = subsum_arra[j]["code"].ToString(),
+ // arrivalQuantity = subsum_arra[j]["arrivalQuantity"].ToString(),
+ // quantity = subsum_arra[j]["quantity"].ToString(),
+ // compositionQuantity = subsum_arra[j]["compositionQuantity"].ToString(),
+ // baseQuantity = subsum_arra[j]["baseQuantity"].ToString(),
+ // sourceVoucherId = subsum_arra[j]["sourceVoucherId"].ToString(),
+ // sourceVoucherCode = subsum_arra[j]["sourceVoucherCode"].ToString(),
+ // sourceVoucherDetailId = subsum_arra[j]["sourceVoucherDetailId"].ToString(),
+ // idsourcevouchertype = subsum_arra[j]["idsourcevouchertype"].ToString(),
+ // saleOrderId = subsum_arra[j]["saleOrderId"].ToString(),
+ // saleOrderCode = subsum_arra[j]["saleOrderCode"].ToString(),
+ // saleOrderDetailId = subsum_arra[j]["saleOrderDetailId"].ToString(),
+ // ManufactureOrderId = subsum_arra[j]["ManufactureOrderId"].ToString(),
+ // ManufactureOrderCode = subsum_arra[j]["ManufactureOrderCode"].ToString(),
+ // ManufactureOrderDetailId = subsum_arra[j]["ManufactureOrderDetailId"].ToString(),
+ // idbusiTypeByMergedFlow = subsum_arra[j]["idbusiTypeByMergedFlow"].ToString(),
+ // idinventory = subsum_arra[j]["idinventory"].ToString(),
+ // idbaseunit = subsum_arra[j]["idbaseunit"].ToString(),
+ // idunit = subsum_arra[j]["idunit"].ToString(),
+ // idwarehouse = subsum_arra[j]["idwarehouse"].ToString(),
+ // SourceVoucherIdByMergedFlow = subsum_arra[j]["SourceVoucherIdByMergedFlow"].ToString(),
+ // SourceVoucherCodeByMergedFlow = subsum_arra[j]["SourceVoucherCodeByMergedFlow"].ToString(),
+ // SourceVoucherDetailIdByMergedFlow = subsum_arra[j]["SourceVoucherDetailIdByMergedFlow"].ToString(),
+ // idsourceVoucherTypeByMergedFlow = subsum_arra[j]["idsourceVoucherTypeByMergedFlow"].ToString(),
+ // createdtime = subsum_arra[j]["createdtime"].ToString(),
+ // DataSource = subsum_arra[j]["DataSource"].ToString()
+ // }
+ //});
+ //鍐欏叆ERP鐜板瓨閲忔煡璇㈣〃
+ //sql = @"" + dt.Rows[2]["cname"].ToString() + "";
+ //list.Add(new
+ //{
+ // str = sql,
+ // parm = new
+ // {
+ // idinventory = subsum_arra[j]["idinventory"].ToString(),
+ // idwarehouse = subsum_arra[j]["idwarehouse"].ToString(),
+ // propertyName = "ProductForReceive",
+ // baseQuantity= subsum_arra[j]["quantity"].ToString(),
+ // IdMarketingOrgan="1",
+ // idbaseunit= subsum_arra[j]["idbaseunit"].ToString(),
+ // updated= DateTime.Now.ToString(),
+ // isCarriedForwardOut ="0",
+ // isCarriedForwardIn = "0"
+ // }
+ //});
+
+
+
+ //鍐欏叆MES鍏ュ簱璁板綍瀛愯〃
+ sql = @"insert into TK_WMS_Inwh_Sub(hbillno,rownumber,materiel_code,storehouse_code,qty)
+ values(@hbillno,@rownumber,@materiel_code,@storehouse_code,@qty)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ hbillno = obj["head"]["hbillno"].ToString(),
+ rownumber = subsum_arra[j]["rownumber"].ToString(),
+ materiel_code = subsum_arra[j]["materiel_code"].ToString(),
+ storehouse_code = subsum_arra[j]["warehouse"].ToString(),
+ qty = decimal.Parse(subsum_arra[j]["quantity"].ToString())
+ }
+ });
+ }
+ //鏇存柊鍗曟嵁娴佹按鍙�
+ List<object> list1 = SeachEncodeJob.StrEncodingUpdate(obj["head"]["rightcode"].ToString(), obj["head"]["incbit"].ToString());
+ list.Add(list1[0]);
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ #region[鐢熶骇鍏ュ簱鎵弿鏉$爜]
+ public static ToMessage MesAppProductInHouseOrderBarCodeSearch(string labcode)
+ {
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鍒ゆ柇鏉$爜鏄惁瀛樺湪
+ sql = @"select distinct AA.inbarcode from (
+ select A.inbarcode
+ from TK_Wrk_Record A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ where A.style='B' and S.isend='Y' and A.good_qty>0 and A.inbarcode=@labcode
+ union all
+ select A.inbarcode
+ from TK_Wrk_OutRecord A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ where A.style='S' and S.isend='Y' and A.sqty>0 and A.inbarcode=@labcode
+ ) as AA";
+ dynamicParams.Add("@labcode", labcode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.Message = "鏃犳晥鏉$爜!";
+ mes.data = null;
+ return mes;
+ }
+ //鍒ゆ柇鏉$爜鏄惁瀛樺彲鐢�
+ sql = @"select distinct AA.inbarcode,AA.good_qty,AA.inhouseqty from (
+ select A.inbarcode,sum(A.good_qty) as good_qty,sum(isnull(A.inhouseqty,0)) as inhouseqty
+ from TK_Wrk_Record A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ where A.style='B' and S.isend='Y' and A.good_qty>0 and A.inbarcode=@labcode
+ group by A.inbarcode
+ union all
+ select A.inbarcode,sum(A.sqty) as good_qty,sum(isnull(A.inhouseqty,0)) as inhouseqty
+ from TK_Wrk_OutRecord A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ where A.style='S' and S.isend='Y' and A.sqty>0 and A.inbarcode=@labcode
+ group by A.inbarcode
+ ) as AA where AA.good_qty>AA.inhouseqty ";
+ dynamicParams.Add("@labcode", labcode);
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data1.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.Message = "褰撳墠鏉$爜宸插叆搴�!";
+ mes.data = null;
+ return mes;
+ }
+
+ //鏍规嵁閲囪喘璁㈠崟鍙锋煡璇㈢墿鏂欎俊鎭紝渚涘簲鍟嗕俊鎭�
+ sql = @"select * from(
+ select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname,
+ A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname,
+ E.saleOrderqty,E.qty,M.plan_qty,A.good_qty,isnull(A.inhouseqty,0) as inhouseqty,A.good_qty-isnull(A.inhouseqty,0) as stinhouseqty,A.lm_date,A.style
+ from TK_Wrk_Record A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ inner join TK_Wrk_Man M on S.wo_code=M.wo_code
+ inner join TMateriel_Info P on M.materiel_code=P.partcode
+ left join TKimp_Ewo E on M.sourceid=E.id
+ left join T_Sec_Stck K on E.stck_code=K.code
+ where A.style='B' and S.isend='Y' and A.good_qty>0 and A.inbarcode=@labcode
+ union all
+ select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname,
+ A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname,
+ E.saleOrderqty,E.qty,M.plan_qty,A.sqty as sqty,isnull(A.inhouseqty,0) as inhouseqty,A.sqty-isnull(A.inhouseqty,0) as stinhouseqty,A.lm_date,A.style
+ from TK_Wrk_OutRecord A
+ inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
+ inner join TK_Wrk_Man M on S.wo_code=M.wo_code
+ inner join TMateriel_Info P on M.materiel_code=P.partcode
+ left join TKimp_Ewo E on M.sourceid=E.id
+ left join T_Sec_Stck K on E.stck_code=K.code
+ where A.style='S' and S.isend='Y' and A.sqty>0 and A.inbarcode=@labcode
+ ) as AA where AA.good_qty>AA.inhouseqty";
+ dynamicParams.Add("@labcode", labcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.Message = "鏆傛棤鐗╂枡鏁版嵁!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/DLL/DAL/SystemSettingDAL.cs b/VueWebCoreApi/DLL/DAL/SystemSettingDAL.cs
new file mode 100644
index 0000000..0bb40c2
--- /dev/null
+++ b/VueWebCoreApi/DLL/DAL/SystemSettingDAL.cs
@@ -0,0 +1,355 @@
+锘縰sing Dapper;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.DLL.DAL
+{
+ public class SystemSettingDAL
+ {
+ public static DataTable dt; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static bool res; //瀹氫箟鍏ㄥ眬鍙橀噺dt
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+ public static string strProcName = ""; //瀹氫箟鍏ㄥ眬sql鍙橀噺
+ public static List<SqlParameter> listStr = new List<SqlParameter>(); //瀹氫箟鍏ㄥ眬鍙傛暟闆嗗悎
+ public static SqlParameter[] parameters; //瀹氫箟鍏ㄥ眬SqlParameter鍙傛暟鏁扮粍
+
+ #region[缂栫爜瑙勫垯鑾峰彇鍙缃殑鍔熻兘鑿滃崟淇℃伅]
+ public static ToMessage CodeMenuSelect()
+ {
+ string sql = "";
+ try
+ {
+ sql = @"with RecursiveCTE as (
+ select menucode, parent_id,menuname,menu_seq,Type
+ from TMenu
+ where is_codeview = 'Y'
+ union ALL
+ select e.menucode, e.parent_id, e.menuname,e.menu_seq,e.Type
+ from TMenu e
+ inner join RecursiveCTE r ON e.menucode = r.parent_id
+ )
+ select menucode, parent_id, menuname,Type
+ from RecursiveCTE order by menu_seq";
+ var data = DapperHelper.selecttable(sql);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = data;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏃犲彲璁剧疆鍔熻兘瑙勫垯!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[缂栫爜瑙勫垯鏌ヨ]
+ public static ToMessage EncodingRules(string rightname, string prefix, int startNum, int endNum, string prop, string order)
+ {
+ var dynamicParams = new DynamicParameters();
+ string search = "";
+ try
+ {
+ if (rightname != "" && rightname != null)
+ {
+ search += "and A.menuname like '%'+@rightname+'%' ";
+ dynamicParams.Add("@rightname", rightname);
+ }
+ if (prefix != "" && prefix != null)
+ {
+ search += "and A.prefix like '%'+@prefix+'%' ";
+ dynamicParams.Add("@prefix", prefix);
+ }
+ if (search == "")
+ {
+ search = "and 1=1 ";
+ }
+ search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
+ // --------------鏌ヨ鎸囧畾鏁版嵁--------------
+ var total = 0; //鎬绘潯鏁�
+ var sql = @"select A.menucode,A.menuname,A.prefix,A.filingdate,A.incbit,A.value,A.Type,U.usercode,U.username,A.lm_date
+ from TCodeRules A
+ left join TUser U on A.lm_user=U.usercode
+ where " + search + "";
+ var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
+ mes.code = "200";
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.count = total;
+ mes.data = data.ToList();
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[缂栫爜瑙勫垯缂栬緫淇濆瓨]
+ public static ToMessage SaveEncodingRules(string rightcode, string rightname, string prefix, string filingdate, string incbit, string type, User us)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select menucode,value from TCodeRules where menucode=@rightcode and Type=@type";
+ dynamicParams.Add("@rightcode", rightcode);
+ dynamicParams.Add("@type", type);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ string value = data.Rows[0]["value"].ToString();
+ if (decimal.Parse(incbit) > value.Length)
+ {
+ decimal cnum = decimal.Parse(incbit) - value.Length;
+ for (int i = 0; i < cnum; i++)
+ {
+ value = "0" + value;
+ }
+ }
+ sql = @"update TCodeRules set prefix=@prefix,filingdate=@filingdate,incbit=@incbit,value=@value,lm_user=@lm_user,lm_date=@CreateDate where menucode=@menucode";
+ dynamicParams.Add("@prefix", prefix);
+ dynamicParams.Add("@filingdate", filingdate);
+ dynamicParams.Add("@incbit", incbit);
+ dynamicParams.Add("@value", value);
+ dynamicParams.Add("@lm_user", us.usercode);
+ dynamicParams.Add("@CreateDate", DateTime.Now.ToString());
+ dynamicParams.Add("@menucode", rightcode);
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "淇敼", "淇敼浜嗙紪鐮佽鍒�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ else
+ {
+ //棣栨鍐欏叆鍓嶆寜浣嶆暟琛ュ厖0
+ string value = "";
+ for (int i = 0; i < int.Parse(incbit); i++)
+ {
+ value = value + "0";
+ }
+ //鍐欏叆瑙勫垯琛�
+ sql = @"insert into TCodeRules(menucode,menuname,prefix,filingdate,incbit,value,lm_user,lm_date,Type)
+ values(@menucode,@menuname,@prefix,@filingdate,@incbit,@value,@lm_user,@lm_date,@type)";
+ dynamicParams.Add("@menucode", rightcode);
+ dynamicParams.Add("@menuname", rightname);
+ dynamicParams.Add("@prefix", prefix);
+ dynamicParams.Add("@filingdate", filingdate);
+ dynamicParams.Add("@incbit", incbit);
+ dynamicParams.Add("@value", value);
+ dynamicParams.Add("@lm_user", us.usercode);
+ dynamicParams.Add("@lm_date", DateTime.Now.ToString());
+ dynamicParams.Add("@type", type);
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鏂板", "鏂板浜嗙紪鐮佽鍒�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[缂栫爜瑙勫垯鍒犻櫎]
+ public static ToMessage DeleteEncodingRules(string menucode, User us)
+ {
+ var sql = "";
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"delete TCodeRules where menucode=@menucode";
+ dynamicParams.Add("@menucode", menucode);
+ int cont = DapperHelper.SQL(sql, dynamicParams);
+ if (cont > 0)
+ {
+ //鍐欏叆鎿嶄綔璁板綍琛�
+ LogHelper.DbOperateLog(us.usercode, "鍒犻櫎", "鍒犻櫎浜嗙紪鐮佽鍒�", us.usertype);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鑾峰彇瑙勫垯鐢熸垚鐨勭紪鐮�(姣忔鑾峰彇鏈�鏂�)]
+ public static ToMessage NewEncodingRules(string rightcode)
+ {
+ mes = SeachEncode.EncodingSeach(rightcode);
+ return mes;
+ }
+ #endregion
+
+ #region[鑾峰彇瑙勫垯鐢熸垚鐨勭紪鐮�(鍙湁浣跨敤鎵嶈幏鍙栨渶鏂�)]
+ public static ToMessage OnlyEncodingRules(string rightcode)
+ {
+ mes = SeachEncodeJob.EncodingSeach(rightcode);
+ return mes;
+ }
+ #endregion
+
+ #region[鍥炲啓瑙勫垯鐢熸垚鐨勭紪鐮�(浣跨敤淇濆瓨)]
+ public static ToMessage SaveOnlyEncodingRules(string rightcode, string incbit)
+ {
+ List<object> list = SeachEncodeJob.StrEncodingUpdate(rightcode, incbit);
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔鎴愬姛!";
+ mes.data = null;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触!";
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熸垚鐗╂枡鏍囩鏉$爜(姣忔鑾峰彇鏈�鏂�,App鍙娇鐢�)]
+ public static ToMessage LabelBarCode(string rightcode, string partcode, string qty, string onelabqty)
+ {
+ mes = AppLableBarCode.EncodingSeach(rightcode, partcode, qty, onelabqty);
+ return mes;
+ }
+ #endregion
+
+ #region[App鐗堟湰鍗囩骇鎺ュ彛]
+ public static ToMessage AppUpgrade(string rid, string vision)
+ {
+ var sql = "";
+ List<object> list = new List<object>();
+ List<AppVersion> obj = new List<AppVersion>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ sql = @"select * from TSystemAppUser where rid=@rid and appvesion=@vision";
+ dynamicParams.Add("@rid", rid);
+ dynamicParams.Add("@vision", vision);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count <= 0) //涓嶅瓨鍦�
+ {
+ //鍐欏叆鏈増鐢ㄦ埛鍏宠仈琛�
+ sql = @"insert into TSystemAppUser(rid,appvesion,lm_date)
+ values(@rid,@appvesion,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ rid = rid,
+ appvesion = vision,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+ bool aa = DapperHelper.DoTransaction(list);
+ list.Clear();
+ }
+ //鏌ヨ鎺у埗鍗囩骇琛ㄧ増鏈暟鎹�
+ sql = @"select * from TSystemApp";
+ var data1 = DapperHelper.selecttable(sql);
+ AppVersion vn = new AppVersion();
+ vn.path = data1.Rows[0]["path"].ToString();
+ vn.version = data1.Rows[0]["version"].ToString();
+ vn.dispyversion = vision;
+ vn.activeversion = data1.Rows[0]["activeversion"].ToString();
+ vn.mustupgrade = data1.Rows[0]["mustupgrade"].ToString();
+ list.Add(vn);
+
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "鏌ヨ鎴愬姛!";
+ mes.data = list;
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/Dockerfile b/VueWebCoreApi/Dockerfile
new file mode 100644
index 0000000..7a6e605
--- /dev/null
+++ b/VueWebCoreApi/Dockerfile
@@ -0,0 +1,25 @@
+#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
+
+#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
+#For more information, please see https://aka.ms/containercompat
+
+FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
+WORKDIR /app
+EXPOSE 80
+EXPOSE 443
+
+FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
+WORKDIR /src
+COPY ["VueWebCoreApi/VueWebCoreApi.csproj", "VueWebCoreApi/"]
+RUN dotnet restore "VueWebCoreApi/VueWebCoreApi.csproj"
+COPY . .
+WORKDIR "/src/VueWebCoreApi"
+RUN dotnet build "VueWebCoreApi.csproj" -c Release -o /app/build
+
+FROM build AS publish
+RUN dotnet publish "VueWebCoreApi.csproj" -c Release -o /app/publish
+
+FROM base AS final
+WORKDIR /app
+COPY --from=publish /app/publish .
+ENTRYPOINT ["dotnet", "VueWebCoreApi.dll"]
\ No newline at end of file
diff --git "a/VueWebCoreApi/Excel/\344\273\223\345\272\223\345\272\223\344\275\215\346\270\205\345\215\225.xls" "b/VueWebCoreApi/Excel/\344\273\223\345\272\223\345\272\223\344\275\215\346\270\205\345\215\225.xls"
new file mode 100644
index 0000000..cbfe09a
--- /dev/null
+++ "b/VueWebCoreApi/Excel/\344\273\223\345\272\223\345\272\223\344\275\215\346\270\205\345\215\225.xls"
Binary files differ
diff --git "a/VueWebCoreApi/Excel/\345\276\200\346\235\245\345\215\225\344\275\215.xls" "b/VueWebCoreApi/Excel/\345\276\200\346\235\245\345\215\225\344\275\215.xls"
new file mode 100644
index 0000000..5703294
--- /dev/null
+++ "b/VueWebCoreApi/Excel/\345\276\200\346\235\245\345\215\225\344\275\215.xls"
Binary files differ
diff --git "a/VueWebCoreApi/Excel/\347\211\251\346\226\231\346\270\205\345\215\225.xls" "b/VueWebCoreApi/Excel/\347\211\251\346\226\231\346\270\205\345\215\225.xls"
new file mode 100644
index 0000000..ec5befe
--- /dev/null
+++ "b/VueWebCoreApi/Excel/\347\211\251\346\226\231\346\270\205\345\215\225.xls"
Binary files differ
diff --git "a/VueWebCoreApi/Excel/\347\224\250\346\210\267\346\270\205\345\215\225.xls" "b/VueWebCoreApi/Excel/\347\224\250\346\210\267\346\270\205\345\215\225.xls"
new file mode 100644
index 0000000..e8d342f
--- /dev/null
+++ "b/VueWebCoreApi/Excel/\347\224\250\346\210\267\346\270\205\345\215\225.xls"
Binary files differ
diff --git "a/VueWebCoreApi/Excel/\347\274\272\351\231\267\345\256\232\344\271\211.xls" "b/VueWebCoreApi/Excel/\347\274\272\351\231\267\345\256\232\344\271\211.xls"
new file mode 100644
index 0000000..bec990a
--- /dev/null
+++ "b/VueWebCoreApi/Excel/\347\274\272\351\231\267\345\256\232\344\271\211.xls"
Binary files differ
diff --git "a/VueWebCoreApi/Excel/\350\212\202\346\213\215\345\267\245\344\273\267.xls" "b/VueWebCoreApi/Excel/\350\212\202\346\213\215\345\267\245\344\273\267.xls"
new file mode 100644
index 0000000..af8e14e
--- /dev/null
+++ "b/VueWebCoreApi/Excel/\350\212\202\346\213\215\345\267\245\344\273\267.xls"
Binary files differ
diff --git "a/VueWebCoreApi/Excel/\350\247\222\350\211\262\346\270\205\345\215\225.xls" "b/VueWebCoreApi/Excel/\350\247\222\350\211\262\346\270\205\345\215\225.xls"
new file mode 100644
index 0000000..7accda8
--- /dev/null
+++ "b/VueWebCoreApi/Excel/\350\247\222\350\211\262\346\270\205\345\215\225.xls"
Binary files differ
diff --git "a/VueWebCoreApi/Excel/\350\256\276\345\244\207\344\277\235\345\205\273\346\240\207\345\207\206.xls" "b/VueWebCoreApi/Excel/\350\256\276\345\244\207\344\277\235\345\205\273\346\240\207\345\207\206.xls"
new file mode 100644
index 0000000..71a4ca6
--- /dev/null
+++ "b/VueWebCoreApi/Excel/\350\256\276\345\244\207\344\277\235\345\205\273\346\240\207\345\207\206.xls"
Binary files differ
diff --git "a/VueWebCoreApi/Excel/\350\256\276\345\244\207\344\277\235\345\205\273\351\241\271\347\233\256.xls" "b/VueWebCoreApi/Excel/\350\256\276\345\244\207\344\277\235\345\205\273\351\241\271\347\233\256.xls"
new file mode 100644
index 0000000..3bf9409
--- /dev/null
+++ "b/VueWebCoreApi/Excel/\350\256\276\345\244\207\344\277\235\345\205\273\351\241\271\347\233\256.xls"
Binary files differ
diff --git "a/VueWebCoreApi/Excel/\350\256\276\345\244\207\346\270\205\345\215\225.xls" "b/VueWebCoreApi/Excel/\350\256\276\345\244\207\346\270\205\345\215\225.xls"
new file mode 100644
index 0000000..b7e051c
--- /dev/null
+++ "b/VueWebCoreApi/Excel/\350\256\276\345\244\207\346\270\205\345\215\225.xls"
Binary files differ
diff --git "a/VueWebCoreApi/Excel/\350\256\276\345\244\207\347\202\271\346\243\200\346\240\207\345\207\206.xls" "b/VueWebCoreApi/Excel/\350\256\276\345\244\207\347\202\271\346\243\200\346\240\207\345\207\206.xls"
new file mode 100644
index 0000000..a9ff9f3
--- /dev/null
+++ "b/VueWebCoreApi/Excel/\350\256\276\345\244\207\347\202\271\346\243\200\346\240\207\345\207\206.xls"
Binary files differ
diff --git "a/VueWebCoreApi/Excel/\350\256\276\345\244\207\347\202\271\346\243\200\351\241\271\347\233\256.xls" "b/VueWebCoreApi/Excel/\350\256\276\345\244\207\347\202\271\346\243\200\351\241\271\347\233\256.xls"
new file mode 100644
index 0000000..6dc00bd
--- /dev/null
+++ "b/VueWebCoreApi/Excel/\350\256\276\345\244\207\347\202\271\346\243\200\351\241\271\347\233\256.xls"
Binary files differ
diff --git a/VueWebCoreApi/Models/APSList.cs b/VueWebCoreApi/Models/APSList.cs
new file mode 100644
index 0000000..fe58772
--- /dev/null
+++ b/VueWebCoreApi/Models/APSList.cs
@@ -0,0 +1,19 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class APSList
+ {
+ public string wo_code { get; set; } //宸ュ崟缂栧彿
+ public string step_id { get; set; } //宸ュ簭缂栫爜
+ public string eqp_id { get; set; } //璁惧缂栫爜
+ public string name { get; set; } //璁惧鍚嶇О
+ public string AdvaDevicCropMob { get; set; } //绋煎姩鐜�
+ public string AdvaDevicRhythm { get; set; } //鑺傛媿
+ public string Style { get; set; } //璁惧绫诲瀷
+ public string ClassType { get; set; } //鎵�灞炵被鍨嬶紙浜х嚎銆佽澶囷級
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/AdvancedSchedAlready.cs b/VueWebCoreApi/Models/AdvancedSchedAlready.cs
new file mode 100644
index 0000000..034db04
--- /dev/null
+++ b/VueWebCoreApi/Models/AdvancedSchedAlready.cs
@@ -0,0 +1,17 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class AdvancedSchedAlready
+ {
+ public string eqp_code { get; set; }
+ public string time_start { get; set; }
+ public string time_end { get; set; }
+ public string status { get; set; }
+ public string alloc_qty { get; set; }
+ public string part_name { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/AdvancedSchedulingDevice.cs b/VueWebCoreApi/Models/AdvancedSchedulingDevice.cs
new file mode 100644
index 0000000..2aecf7d
--- /dev/null
+++ b/VueWebCoreApi/Models/AdvancedSchedulingDevice.cs
@@ -0,0 +1,28 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class AdvancedSchedulingDevice
+ {
+ public string wo_code { get; set; }
+ public string YearDate { get; set; }
+ public List<AdvancedSchedulingDeviceCont> children { get; set; }
+
+ }
+ public class AdvancedSchedulingDeviceCont
+ {
+
+ public string AdvaDevicNumber { get; set; }
+ public string AdvaDevicName { get; set; }
+ public string AdvaDevicCropMob { get; set; }
+ public string AdvaDevicRhythm { get; set; }
+ public string OneStartDate { get; set; }
+ public string TwoStartDate { get; set; }
+ public string ThreeStartDate { get; set; }
+ public string FourStartDate { get; set; }
+ public string FiveStartDate { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/AlreadyScheduling.cs b/VueWebCoreApi/Models/AlreadyScheduling.cs
new file mode 100644
index 0000000..e769edf
--- /dev/null
+++ b/VueWebCoreApi/Models/AlreadyScheduling.cs
@@ -0,0 +1,15 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class AlreadyScheduling
+ {
+ public string AlreDevicNumber { get; set; } //璁惧缂栫爜
+ public string AlreStartDate { get; set; } //寮�濮嬫椂闂�
+ public string AlreEndDate { get; set; } //缁撴潫鏃堕棿
+ public string AlreQty { get; set; } //鏁伴噺
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/AnDnDate.cs b/VueWebCoreApi/Models/AnDnDate.cs
new file mode 100644
index 0000000..426f0bb
--- /dev/null
+++ b/VueWebCoreApi/Models/AnDnDate.cs
@@ -0,0 +1,23 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class AnDnDate
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string flag { get; set; }
+ public List<AnDnDateSub> children { get; set; }//瀛愯妭鐐�
+ }
+ public class AnDnDateSub
+ {
+ public string rid { get; set; } //鏋佸厜鎺ㄩ�佺敤鎴穒d
+ public string alias { get; set; } //鏋佸厜鎺ㄩ�佹寚瀹氱敤鎴峰埆鍚�(璺熷墠绔繚鎸佷竴鑷�),褰撳墠涓�:rid+usercode
+ public string usercode { get; set; }
+ public string username { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/AppDevicecCheck.cs b/VueWebCoreApi/Models/AppDevicecCheck.cs
new file mode 100644
index 0000000..e658152
--- /dev/null
+++ b/VueWebCoreApi/Models/AppDevicecCheck.cs
@@ -0,0 +1,24 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class AppDevicecCheck
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string standcode { get; set; }
+ public string result { get; set; }
+ public List<AppDevicecCheckCn> children { get; set; }//瀛愯妭鐐�
+ }
+ public class AppDevicecCheckCn
+ {
+ public string seq { get; set; }
+ public string itemcode { get; set; }
+ public string cycle { get; set; }
+ public string value { get; set; }
+ public string result { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/AppLabCode.cs b/VueWebCoreApi/Models/AppLabCode.cs
new file mode 100644
index 0000000..b95dfce
--- /dev/null
+++ b/VueWebCoreApi/Models/AppLabCode.cs
@@ -0,0 +1,27 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class AppLabCode
+ {
+ /// <summary>
+ /// 鍔熻兘缂栫爜
+ /// </summary>
+ public string rightcode { get; set; }
+ /// <summary>
+ /// 鏍囩鏉$爜
+ /// </summary>
+ public string labcode { get; set; }
+ /// <summary>
+ /// 鏍囩鏁伴噺
+ /// </summary>
+ public string labqty { get; set; }
+ /// <summary>
+ /// 鐗╂枡缂栫爜
+ /// </summary>
+ public string partnumber { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/AppPurchOrderSave.cs b/VueWebCoreApi/Models/AppPurchOrderSave.cs
new file mode 100644
index 0000000..c83aa6d
--- /dev/null
+++ b/VueWebCoreApi/Models/AppPurchOrderSave.cs
@@ -0,0 +1,56 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class AppPurchOrderSave
+ {
+ /// <summary>
+ /// 棰勮鍒拌揣鏃ユ湡
+ /// </summary>
+ public string hacceptdate { get; set; }
+ /// <summary>
+ /// 閮ㄩ棬缂栫爜
+ /// </summary>
+ public string hdepartmentcode { get; set; }
+ /// <summary>
+ /// 渚涘簲鍟嗙紪鐮�
+ /// </summary>
+ public string hcustomercode { get; set; }
+ /// <summary>
+ /// 鎵规鍙�
+ /// </summary>
+ public string hbatchno { get; set; }
+ /// <summary>
+ /// 婧愬崟鍗曞彿(閲囪喘璁㈠崟鍙�)
+ /// </summary>
+ public string hsourcebillno { get; set; }
+ /// <summary>
+ /// 琛屽彿
+ /// </summary>
+ public string rownumber { get; set; }
+ /// <summary>
+ /// 鐗╂枡缂栫爜
+ /// </summary>
+ public string hpartcode { get; set; }
+ /// <summary>
+ /// 璁㈠崟鏁伴噺
+ /// </summary>
+ public string hplanqty { get; set; }
+ /// <summary>
+ /// 鍒拌揣鏁伴噺
+ /// </summary>
+ public string hqty { get; set; }
+ /// <summary>
+ /// 鐗╂枡鏄惁闇�妫�楠�
+ /// </summary>
+ public string hischeck { get; set; }
+
+ /// <summary>
+ /// 鏉$爜淇℃伅
+ /// </summary>
+ public List<AppLabCode> children { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/AppScheduleKanban.cs b/VueWebCoreApi/Models/AppScheduleKanban.cs
new file mode 100644
index 0000000..0b5e943
--- /dev/null
+++ b/VueWebCoreApi/Models/AppScheduleKanban.cs
@@ -0,0 +1,44 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class AppScheduleKanban
+ {
+ /// <summary>
+ /// 鍗曟嵁缂栧彿
+ /// </summary>
+ public string ordercode { get; set; }
+ /// <summary>
+ /// 鍗曟嵁鏁伴噺
+ /// </summary>
+ public string orderqty { get; set; }
+ /// <summary>
+ /// 鍗曟嵁缂栧彿
+ /// </summary>
+ public string ordergoodqty { get; set; }
+ /// <summary>
+ /// 浜у搧缂栫爜
+ /// </summary>
+ public string partcode { get; set; }
+ /// <summary>
+ /// 浜у搧鍚嶇О
+ /// </summary>
+ public string partname { get; set; }
+ /// <summary>
+ /// 浜у搧瑙勬牸
+ /// </summary>
+ public string partspec { get; set; }
+ public List<AppScheduleKanbanSub> children { get; set; }//瀛愯妭鐐�
+ }
+ public class AppScheduleKanbanSub
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string spec { get; set; }
+ public string planqty { get; set; }
+ public string goodqty { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/AppVersion.cs b/VueWebCoreApi/Models/AppVersion.cs
new file mode 100644
index 0000000..7e16e7c
--- /dev/null
+++ b/VueWebCoreApi/Models/AppVersion.cs
@@ -0,0 +1,16 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class AppVersion
+ {
+ public string path { get; set; }
+ public string version { get; set; }
+ public string dispyversion { get; set; }
+ public string activeversion { get; set; }
+ public string mustupgrade { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/ApsOrderSerch.cs b/VueWebCoreApi/Models/ApsOrderSerch.cs
new file mode 100644
index 0000000..451d4e2
--- /dev/null
+++ b/VueWebCoreApi/Models/ApsOrderSerch.cs
@@ -0,0 +1,35 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class ApsOrderSerch
+ {
+ /// <summary>
+ /// 宸ュ崟鍙�
+ /// </summary>
+ public string wocode { get; set; }
+ /// <summary>
+ /// 杞﹂棿缂栫爜
+ /// </summary>
+ public string wkshpcode { get; set; }
+ /// <summary>
+ /// 浜у搧缂栧彿
+ /// </summary>
+ public string partcode { get; set; }
+ /// <summary>
+ /// 鐡堕宸ュ簭缂栫爜(棣栭亾宸ュ簭)
+ /// </summary>
+ public string botproccode { get; set; }
+ /// <summary>
+ /// 寮�濮嬫棩鏈�
+ /// </summary>
+ public string startdate { get; set; }
+ /// <summary>
+ /// 缁撴潫鏃ユ湡
+ /// </summary>
+ public string enddate { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/BomSub.cs b/VueWebCoreApi/Models/BomSub.cs
new file mode 100644
index 0000000..0be0451
--- /dev/null
+++ b/VueWebCoreApi/Models/BomSub.cs
@@ -0,0 +1,17 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class BomSub
+ {
+ public string seq { get; set; }
+ public string smaterirl_code { get; set; }
+ public string base_quantity { get; set; }
+ public string loss_quantity { get; set; }
+ public string total_quantity { get; set; }
+ public string pn_type { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/CapaPlan.cs b/VueWebCoreApi/Models/CapaPlan.cs
new file mode 100644
index 0000000..0f4e2c6
--- /dev/null
+++ b/VueWebCoreApi/Models/CapaPlan.cs
@@ -0,0 +1,26 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class CapaPlan
+ {
+ public string name { get; set; }
+ public string key { get; set; }
+ public override bool Equals(object obj)
+ {
+ if (obj is CapaPlan)
+ {
+ CapaPlan student = obj as CapaPlan;
+ return name == student.name && key == student.key;
+ }
+ return false;
+ }
+ public override int GetHashCode()
+ {
+ return name.GetHashCode() ^ key.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/CapacityPlanSect.cs b/VueWebCoreApi/Models/CapacityPlanSect.cs
new file mode 100644
index 0000000..3560d15
--- /dev/null
+++ b/VueWebCoreApi/Models/CapacityPlanSect.cs
@@ -0,0 +1,15 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class CapacityPlanSect
+ {
+ public string CapCode { get; set; } //鏂规缂栫爜
+ public string CapName { get; set; } //鏂规鍚嶇О
+ public string CapStus { get; set; } //閫変腑鐘舵��
+ public List<object> list { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/CapacityPlanningSetup.cs b/VueWebCoreApi/Models/CapacityPlanningSetup.cs
new file mode 100644
index 0000000..461f159
--- /dev/null
+++ b/VueWebCoreApi/Models/CapacityPlanningSetup.cs
@@ -0,0 +1,21 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class CapacityPlanningSetup
+ {
+ public string CapSetupCode { get; set; } //鐝浠g爜
+ public string CapSetupName { get; set; } //鐝鍚嶇О
+ public string OneStartDate { get; set; } //鏃堕棿娈�1
+ public string TwoStartDate { get; set; } //鏃堕棿娈�2
+ public string ThreeStartDate { get; set; } //鏃堕棿娈�3
+ public string FourStartDate { get; set; } //鏃堕棿娈�4
+ public string FiveStartDate { get; set; } //鏃堕棿娈�5
+ public string CapSetupUser { get; set; } //鎿嶄綔浜哄憳
+ public string CapSetupDate { get; set; } //鎿嶄綔鏃堕棿
+ public string Duration { get; set; } //鏃堕暱
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/ChanjetEncryptMsg.cs b/VueWebCoreApi/Models/ChanjetEncryptMsg.cs
new file mode 100644
index 0000000..a8e6ba4
--- /dev/null
+++ b/VueWebCoreApi/Models/ChanjetEncryptMsg.cs
@@ -0,0 +1,17 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class ChanjetEncryptMsg
+ {
+ public string encryptMsg { get; set; }
+
+ public string GetEncryptMsg()
+ {
+ return encryptMsg;
+ }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/DeviceRepair.cs b/VueWebCoreApi/Models/DeviceRepair.cs
new file mode 100644
index 0000000..51a2db9
--- /dev/null
+++ b/VueWebCoreApi/Models/DeviceRepair.cs
@@ -0,0 +1,25 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class DeviceReport
+ {
+ public string faultsource { get; set; } //鏁呴殰鏉ユ簮
+ public string faultdescr { get; set; } //鏁呴殰鎻忚堪
+ public DataTable faultimage { get; set; } //鏁呴殰鍥剧墖
+ }
+
+ public class DeviceRepair
+ {
+ public string faultdescr { get; set; } //鏁呴殰鎻忚堪
+ public string isstoprepair { get; set; } //鍋滄満缁翠慨
+ public string repaircontent { get; set; } //缁翠慨鍐呭
+ public string repairpart { get; set; } //鏇存崲澶囦欢
+ public DataTable repairimage { get; set; } //鏁呴殰鍥剧墖/鏇存崲澶囦欢鍥剧墖
+
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/EqpRepair.cs b/VueWebCoreApi/Models/EqpRepair.cs
new file mode 100644
index 0000000..ed48ea6
--- /dev/null
+++ b/VueWebCoreApi/Models/EqpRepair.cs
@@ -0,0 +1,17 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class EqpRepair
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string repaircycle { get; set; }
+ public string description { get; set; }
+ public DataTable Data { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/ExcelErro.cs b/VueWebCoreApi/Models/ExcelErro.cs
new file mode 100644
index 0000000..39ef9d8
--- /dev/null
+++ b/VueWebCoreApi/Models/ExcelErro.cs
@@ -0,0 +1,15 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class ExcelErro
+ {
+ public string Seq { get; set; } //搴忓彿
+ public string RoeNumber { get; set; } //琛屽彿
+ public string ErrorField { get; set; } //閿欒瀛楁
+ public string ErrorCont { get; set; } //閿欒璇︽儏
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/MaterialRout.cs b/VueWebCoreApi/Models/MaterialRout.cs
new file mode 100644
index 0000000..f5cdfbe
--- /dev/null
+++ b/VueWebCoreApi/Models/MaterialRout.cs
@@ -0,0 +1,18 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class MaterialRout
+ {
+ public string wkshopcode { get; set; }
+ public string wkshopname { get; set; }
+ public string code { get; set; }
+ public string name { get; set; }
+ public string flag { get; set; }
+ public DataTable Data { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/ObjectData.cs b/VueWebCoreApi/Models/ObjectData.cs
new file mode 100644
index 0000000..3b332da
--- /dev/null
+++ b/VueWebCoreApi/Models/ObjectData.cs
@@ -0,0 +1,14 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class ObjectData
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string flag { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/ObjectDataCont.cs b/VueWebCoreApi/Models/ObjectDataCont.cs
new file mode 100644
index 0000000..7cfa0c8
--- /dev/null
+++ b/VueWebCoreApi/Models/ObjectDataCont.cs
@@ -0,0 +1,15 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class ObjectDataCont
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string group { get; set; }
+ public string description { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/PartRout.cs b/VueWebCoreApi/Models/PartRout.cs
new file mode 100644
index 0000000..4f65fda
--- /dev/null
+++ b/VueWebCoreApi/Models/PartRout.cs
@@ -0,0 +1,15 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class PartRout
+ {
+ public string wkshopcode { get; set; }
+ public string code { get; set; }
+ public string name { get; set; }
+ public string flag { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/ReportDefectHandle.cs b/VueWebCoreApi/Models/ReportDefectHandle.cs
new file mode 100644
index 0000000..360cb22
--- /dev/null
+++ b/VueWebCoreApi/Models/ReportDefectHandle.cs
@@ -0,0 +1,13 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class ReportDefectHandle
+ {
+ public DataTable Data { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/RolePermission/MenuItem.cs b/VueWebCoreApi/Models/RolePermission/MenuItem.cs
new file mode 100644
index 0000000..da0c857
--- /dev/null
+++ b/VueWebCoreApi/Models/RolePermission/MenuItem.cs
@@ -0,0 +1,34 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Models.RolePermission
+{
+ public class MenuItem
+ {
+ public string MenuCode { get; set; }
+ public string ButtonCode { get; set; }
+ public string DataCode { get; set; }
+ }
+
+ public class TreeOne
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string flag { get; set; }
+ public string imgurl { get; set; }
+ public string is_show { get; set; }
+ public List<TreeTwo> children { get; set; }//瀛愯妭鐐�
+ }
+ public class TreeTwo
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string flag { get; set; }
+ public string imgurl { get; set; }
+ public string is_show { get; set; }
+ public string buttoncode { get; set; }
+ public string datacode { get; set; }
+ }
+}
diff --git a/VueWebCoreApi/Models/RolePermission/RolePermission.cs b/VueWebCoreApi/Models/RolePermission/RolePermission.cs
new file mode 100644
index 0000000..c251803
--- /dev/null
+++ b/VueWebCoreApi/Models/RolePermission/RolePermission.cs
@@ -0,0 +1,50 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Models.RolePermission
+{
+ public class RolePermission
+ {
+ public class Company
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public List<TRole> Roles { get; set; }
+ }
+ public class TRole
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string datarange { get; set; }
+ public string datapermissions { get; set; }
+ public string identifying { get; set; }
+
+ }
+
+ public class TMenu
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string parentid { get; set; }
+ public string flag { get; set; }
+ }
+
+ public class TButton
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string menucode { get; set; }
+ public string flag { get; set; }
+ }
+
+ public class TData
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string menucode { get; set; }
+ public string flag { get; set; }
+ }
+ }
+}
diff --git a/VueWebCoreApi/Models/RolePermission/RolePermissionSava.cs b/VueWebCoreApi/Models/RolePermission/RolePermissionSava.cs
new file mode 100644
index 0000000..e793032
--- /dev/null
+++ b/VueWebCoreApi/Models/RolePermission/RolePermissionSava.cs
@@ -0,0 +1,60 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Models.RolePermission
+{
+ public class RolePermissionSava
+ {
+ public class RolePermissionSavaData
+ {
+ public List<RoleMenu> RoleMenu { get; set; }
+ public List<RoleButton> RoleButton { get; set; }
+ public List<RoleData> RoleData { get; set; }
+ }
+
+ /// <summary>
+ /// 瑙掕壊鑿滃崟
+ /// </summary>
+ public class RoleMenu
+ {
+ /// <summary>
+ /// 瑙掕壊缂栫爜
+ /// </summary>
+ public string rolecode { get; set; }
+ /// <summary>
+ /// 鑿滃崟缂栫爜
+ /// </summary>
+ public string menucode { get; set; }
+ }
+ /// <summary>
+ /// 瑙掕壊鎸夐挳
+ /// </summary>
+ public class RoleButton
+ {
+ /// <summary>
+ /// 瑙掕壊缂栫爜
+ /// </summary>
+ public string rolecode { get; set; }
+ /// <summary>
+ /// 鎸夐挳缂栫爜
+ /// </summary>
+ public string buttoncode { get; set; }
+ }
+ /// <summary>
+ /// 瑙掕壊鏁版嵁
+ /// </summary>
+ public class RoleData
+ {
+ /// <summary>
+ /// 瑙掕壊缂栫爜
+ /// </summary>
+ public string rolecode { get; set; }
+ /// <summary>
+ ///鏁版嵁缂栫爜
+ /// </summary>
+ public string datacode { get; set; }
+ }
+ }
+}
diff --git a/VueWebCoreApi/Models/RoleUserSubmit.cs b/VueWebCoreApi/Models/RoleUserSubmit.cs
new file mode 100644
index 0000000..970fd08
--- /dev/null
+++ b/VueWebCoreApi/Models/RoleUserSubmit.cs
@@ -0,0 +1,14 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class RoleUserSubmit
+ {
+ public string Code { get; set; }
+ public string Name { get; set; }
+ public List<string> Data { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/RoutEdit.cs b/VueWebCoreApi/Models/RoutEdit.cs
new file mode 100644
index 0000000..19c9849
--- /dev/null
+++ b/VueWebCoreApi/Models/RoutEdit.cs
@@ -0,0 +1,18 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class RoutEdit
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string enable { get; set; }
+ public string description { get; set; }
+ public string wkshopcode { get; set; }
+ public DataTable Data { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/ScanStartReportData.cs b/VueWebCoreApi/Models/ScanStartReportData.cs
new file mode 100644
index 0000000..f38fd6c
--- /dev/null
+++ b/VueWebCoreApi/Models/ScanStartReportData.cs
@@ -0,0 +1,31 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class ScanStartReportData
+ {
+ public string wo_code { get; set; } //宸ュ崟缂栧彿
+ public string partnumber { get; set; } //浜у搧缂栫爜
+ public string partname { get; set; } //浜у搧鍚嶇О
+
+ public string partspec { get; set; } //浜у搧瑙勬牸
+ public string seq { get; set; } //褰撳墠宸ュ簭搴忓彿
+ public string stepcode { get; set; } //褰撳墠宸ュ簭缂栫爜
+ public string stepname { get; set; } //褰撳墠宸ュ簭
+ public string nextstepcode { get; set; } //涓嬮亾宸ュ簭缂栫爜
+ public string nextstepname { get; set; } //涓嬮亾宸ュ簭
+ public string stepdesc { get; set; } //宸ュ簭鎻忚堪
+ public decimal planqty { get; set; } //浠诲姟鏁伴噺
+ public decimal startqty { get; set; } //寮�宸ユ暟閲�
+ public decimal noreportqty { get; set; } //鏈姤鏁伴噺
+ public decimal reportqty { get; set; } //宸叉姤鏁伴噺
+ public decimal noputqty { get; set; } //鏈敹鏁伴噺
+ public string wkshopcode { get; set; } //杞﹂棿缂栫爜
+ public string wkshopname { get; set; } //杞﹂棿鍚嶇О
+ public string eqpcode { get; set; } //璁惧缂栫爜
+ public string eqpname { get; set; } //璁惧鍚嶇О
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/ScanStartReportDataOut.cs b/VueWebCoreApi/Models/ScanStartReportDataOut.cs
new file mode 100644
index 0000000..db4df81
--- /dev/null
+++ b/VueWebCoreApi/Models/ScanStartReportDataOut.cs
@@ -0,0 +1,29 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class ScanStartReportDataOut
+ {
+ public string wo_code { get; set; } //宸ュ崟缂栧彿
+ public string partnumber { get; set; } //浜у搧缂栫爜
+ public string partname { get; set; } //浜у搧鍚嶇О
+ public string partspec { get; set; } //浜у搧瑙勬牸
+ public string seq { get; set; } //褰撳墠宸ュ簭搴忓彿
+ public string stepcode { get; set; } //褰撳墠宸ュ簭缂栫爜
+ public string stepname { get; set; } //褰撳墠宸ュ簭
+ public string nextstepcode { get; set; } //涓嬮亾宸ュ簭缂栫爜
+ public string nextstepname { get; set; } //涓嬮亾宸ュ簭
+ public string stepdesc { get; set; } //宸ュ簭鎻忚堪
+ public string wkshopcode { get; set; } //杞﹂棿缂栫爜
+ public string wkshopname { get; set; } //杞﹂棿鍚嶇О
+ public decimal planqty { get; set; } //浠诲姟鏁伴噺
+ public decimal startqty { get; set; } //寮�宸ユ暟閲�
+ public decimal noreportqty { get; set; } //鏈姤鏁伴噺
+ public decimal reportqty { get; set; } //宸叉姤鏁伴噺
+ public decimal noputqty { get; set; } //鏈敹鏁伴噺
+ public object list { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/StandEqp.cs b/VueWebCoreApi/Models/StandEqp.cs
new file mode 100644
index 0000000..84e0f77
--- /dev/null
+++ b/VueWebCoreApi/Models/StandEqp.cs
@@ -0,0 +1,25 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class StandEqp
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string type { get; set; }
+ public string flag { get; set; }
+ public string flag1 { get; set; }
+ public List<StandEqpCn> children { get; set; }//瀛愯妭鐐�
+ }
+ public class StandEqpCn
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string type { get; set; }
+ public string flag { get; set; }
+ public string flag1 { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/StepCheck.cs b/VueWebCoreApi/Models/StepCheck.cs
new file mode 100644
index 0000000..cd022d8
--- /dev/null
+++ b/VueWebCoreApi/Models/StepCheck.cs
@@ -0,0 +1,16 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class StepCheck
+ {
+ public string seq { get; set; }
+ public string code { get; set; }
+ public string name { get; set; }
+ public string descr { get; set; }
+ public string checkresult { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/StepDefect.cs b/VueWebCoreApi/Models/StepDefect.cs
new file mode 100644
index 0000000..fc802d4
--- /dev/null
+++ b/VueWebCoreApi/Models/StepDefect.cs
@@ -0,0 +1,15 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class StepDefect
+ {
+ public string storg_code { get; set; }
+ public string code { get; set; }
+ public string name { get; set; }
+ public string flag { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/StepEqp.cs b/VueWebCoreApi/Models/StepEqp.cs
new file mode 100644
index 0000000..5025f14
--- /dev/null
+++ b/VueWebCoreApi/Models/StepEqp.cs
@@ -0,0 +1,23 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class StepEqp
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string type { get; set; }
+ public string flag { get; set; }
+ public List<StepEqpCn> children { get; set; }//瀛愯妭鐐�
+ }
+ public class StepEqpCn
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string type { get; set; }
+ public string flag { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/TreeDG.cs b/VueWebCoreApi/Models/TreeDG.cs
new file mode 100644
index 0000000..4a2180b
--- /dev/null
+++ b/VueWebCoreApi/Models/TreeDG.cs
@@ -0,0 +1,16 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class TreeDG
+ {
+ public string id { get; set; }
+ public string code { get; set; }
+ public string name { get; set; }
+ public string flag { get; set; }
+ public List<TreeDG> children { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/TreeDM.cs b/VueWebCoreApi/Models/TreeDM.cs
new file mode 100644
index 0000000..6c922c8
--- /dev/null
+++ b/VueWebCoreApi/Models/TreeDM.cs
@@ -0,0 +1,31 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class TreeDM
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string flag { get; set; }
+ public string is_delete { get; set; } //鏄惁闅愯棌
+ public List<TreeDMOne> children { get; set; }
+ }
+ public class TreeDMOne
+ {
+ public string code { set; get; }
+ public string name { set; get; }
+ public string flag { get; set; }
+ public string is_delete { get; set; } //鏄惁闅愯棌
+ public List<TreeDMTwo> children { get; set; }
+ }
+ public class TreeDMTwo
+ {
+ public string code { set; get; }
+ public string name { set; get; }
+ public string flag { get; set; }
+ public string is_delete { get; set; } //鏄惁闅愯棌
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/TreeObejct.cs b/VueWebCoreApi/Models/TreeObejct.cs
new file mode 100644
index 0000000..bbb3a72
--- /dev/null
+++ b/VueWebCoreApi/Models/TreeObejct.cs
@@ -0,0 +1,23 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class TreeObejct
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string flag { get; set; }
+ public string imgurl { get; set; }
+ public List<TreeObejctCn> children { get; set; }//瀛愯妭鐐�
+ }
+ public class TreeObejctCn
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string flag { get; set; }
+ public string imgurl { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/Uom.cs b/VueWebCoreApi/Models/Uom.cs
new file mode 100644
index 0000000..ad60942
--- /dev/null
+++ b/VueWebCoreApi/Models/Uom.cs
@@ -0,0 +1,15 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace VueWebCoreApi.Models
+{
+ public class Uom
+ {
+ public string code { get; set; }
+ public string name { get; set; }
+ public string digdect { get; set; }
+ public string r_ule { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Models/User.cs b/VueWebCoreApi/Models/User.cs
new file mode 100644
index 0000000..ba3911b
--- /dev/null
+++ b/VueWebCoreApi/Models/User.cs
@@ -0,0 +1,45 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Models
+{
+ public class User
+ {
+ /// <summary>
+ /// 鐢ㄦ埛缂栫爜
+ /// </summary>
+ public string usercode { get; set; }
+ /// <summary>
+ /// 鐢ㄦ埛鍚嶇О
+ /// </summary>
+ public string username { get; set; }
+ /// <summary>
+ /// 鎵�灞炵粍缁囩紪鐮�
+ /// </summary>
+ public string storg_code { get; set; }
+ /// <summary>
+ /// 鎵�灞炵粍缁囧悕绉�
+ /// </summary>
+ public string storg_name { get; set; }
+ /// <summary>
+ /// 鏄惁绠$悊鍛�
+ /// </summary>
+ public string is_system_admin { get; set; }
+ /// <summary>
+ /// 瑙掕壊缂栫爜
+ /// </summary>
+ public string role_code { get; set; }
+ /// <summary>
+ /// 瑙掕壊鏁版嵁鏉冮檺缂栫爜
+ /// </summary>
+ public string role_datapermissions { get; set; }
+ /// <summary>
+ /// 鎿嶄綔绔被鍨�
+ /// </summary>
+ public string usertype { get; set; }
+ public string rediskey { get; set; }
+ public string token { get; set; }
+ }
+}
diff --git a/VueWebCoreApi/Program.cs b/VueWebCoreApi/Program.cs
new file mode 100644
index 0000000..947ca45
--- /dev/null
+++ b/VueWebCoreApi/Program.cs
@@ -0,0 +1,26 @@
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ CreateHostBuilder(args).Build().Run();
+ }
+
+ public static IHostBuilder CreateHostBuilder(string[] args) =>
+ Host.CreateDefaultBuilder(args)
+ .ConfigureWebHostDefaults(webBuilder =>
+ {
+ webBuilder.UseStartup<Startup>();
+ });
+ }
+}
diff --git a/VueWebCoreApi/Properties/launchSettings.json b/VueWebCoreApi/Properties/launchSettings.json
new file mode 100644
index 0000000..ccbc616
--- /dev/null
+++ b/VueWebCoreApi/Properties/launchSettings.json
@@ -0,0 +1,38 @@
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:23258",
+ "sslPort": 44334
+ }
+ },
+ "$schema": "http://json.schemastore.org/launchsettings.json",
+ "profiles": {
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "VueWebCoreApi": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "applicationUrl": "https://localhost:5001;http://localhost:5000"
+ }
+ //,
+ //"Docker": {
+ // "commandName": "Docker",
+ // "launchBrowser": true,
+ // "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
+ // "publishAllPorts": true,
+ // "useSSL": true
+ //}
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Quartz/ConvertPath.cs b/VueWebCoreApi/Quartz/ConvertPath.cs
new file mode 100644
index 0000000..2885289
--- /dev/null
+++ b/VueWebCoreApi/Quartz/ConvertPath.cs
@@ -0,0 +1,22 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Quartz
+{
+ public static class ConvertPath
+ {
+ public static bool _windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
+ public static string ReplacePath(this string path)
+ {
+ if (string.IsNullOrEmpty(path))
+ return "";
+ if (_windows)
+ return path.Replace("/", "\\");
+ return path.Replace("\\", "/");
+
+ }
+ }
+}
diff --git a/VueWebCoreApi/Quartz/FileHelper.cs b/VueWebCoreApi/Quartz/FileHelper.cs
new file mode 100644
index 0000000..1f3e7d1
--- /dev/null
+++ b/VueWebCoreApi/Quartz/FileHelper.cs
@@ -0,0 +1,113 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Quartz
+{
+ public class FileHelper
+ {
+ /// <summary>
+ /// 閫氳繃杩唬鍣ㄨ鍙杢xt鏃ュ織鍐呭
+ /// </summary>
+ /// <param name="fullPath"></param>
+ /// <param name="page"></param>
+ /// <param name="pageSize"></param>
+ /// <param name="seekEnd"></param>
+ /// <returns></returns>
+ public static IEnumerable<string> ReadPageLine(string fullPath, int page, int pageSize, bool seekEnd = false)
+ {
+ if (page <= 0)
+ {
+ page = 1;
+ }
+ fullPath = fullPath.ReplacePath();
+ var lines = File.ReadLines(fullPath, Encoding.UTF8);
+ if (seekEnd)
+ {
+ int lineCount = lines.Count();
+ int linPageCount = (int)Math.Ceiling(lineCount / (pageSize * 1.00));
+ //瓒呰繃鎬婚〉鏁帮紝涓嶅鐞�
+ if (page > linPageCount)
+ {
+ page = 0;
+ pageSize = 0;
+ }
+ else if (page == linPageCount)//鏈�鍚庝竴椤碉紝鍙栨渶鍚庝竴椤靛墿涓嬫墍鏈夌殑琛�
+ {
+ pageSize = lineCount - (page - 1) * pageSize;
+ if (page == 1)
+ {
+ page = 0;
+ }
+ else
+ {
+ page = lines.Count() - page * pageSize;
+ }
+ }
+ else
+ {
+ page = lines.Count() - page * pageSize;
+ }
+ }
+ else
+ {
+ page = (page - 1) * pageSize;
+ }
+ lines = lines.Skip(page).Take(pageSize);
+
+ var enumerator = lines.GetEnumerator();
+ int count = 1;
+ while (enumerator.MoveNext() || count <= pageSize)
+ {
+ yield return enumerator.Current;
+ count++;
+ }
+ enumerator.Dispose();
+ }
+
+ public static string ReadFile(string path)
+ {
+ path = path.ReplacePath();
+ if (!File.Exists(path))
+ return "";
+ using (StreamReader stream = new StreamReader(path))
+ {
+ return stream.ReadToEnd(); // 璇诲彇鏂囦欢
+ }
+ }
+
+ /// <summary>
+ /// 鍐欐枃浠�
+ /// </summary>
+ /// <param name="Path">鏂囦欢璺緞</param>
+ /// <param name="Strings">鏂囦欢鍐呭</param>
+ public static void WriteFile(string path, string fileName, string content, bool appendToLast = false)
+ {
+ if (!path.EndsWith("\\"))
+ {
+ path = path + "\\";
+ }
+ path = path.ReplacePath();
+ if (!Directory.Exists(path))//濡傛灉涓嶅瓨鍦ㄥ氨鍒涘缓file鏂囦欢澶�
+ {
+ Directory.CreateDirectory(path);
+ }
+ using (FileStream stream = File.Open(path + fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
+ {
+ byte[] by = Encoding.Default.GetBytes(content);
+ if (appendToLast)
+ {
+ stream.Position = stream.Length;
+ }
+ else
+ {
+ stream.SetLength(0);
+ }
+ stream.Write(by, 0, by.Length);
+ }
+ }
+ }
+}
diff --git a/VueWebCoreApi/Quartz/FileQuartz.cs b/VueWebCoreApi/Quartz/FileQuartz.cs
new file mode 100644
index 0000000..59ebcb2
--- /dev/null
+++ b/VueWebCoreApi/Quartz/FileQuartz.cs
@@ -0,0 +1,130 @@
+锘縰sing Microsoft.AspNetCore.Hosting;
+using Newtonsoft.Json;
+using Quartz;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Quartz
+{
+ public class FileQuartz
+ {
+ private static string _rootPath { get; set; }
+
+ private static string _logPath { get; set; }
+ /// <summary>
+ /// 鍒涘缓浣滀笟鎵�鍦ㄦ牴鐩綍鍙婃棩蹇楁枃浠跺す
+ /// </summary>
+ /// <returns></returns>
+ public static string CreateQuartzRootPath(IWebHostEnvironment env)
+ {
+ if (!string.IsNullOrEmpty(_rootPath))
+ return _rootPath;
+ _rootPath = $"{Directory.GetParent(env.ContentRootPath).FullName}\\{QuartzFileInfo.QuartzSettingsFolder}\\";
+ _rootPath = _rootPath.ReplacePath();
+ if (!Directory.Exists(_rootPath))
+ {
+ Directory.CreateDirectory(_rootPath);
+ }
+ _logPath = _rootPath + QuartzFileInfo.Logs + "\\";
+ _logPath = _logPath.ReplacePath();
+ //鐢熸垚鏃ュ織鏂囦欢澶�
+ if (!Directory.Exists(_logPath))
+ {
+ Directory.CreateDirectory(_logPath);
+ }
+ return _rootPath;
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栦綔涓氭棩蹇楁枃浠�,浠xt浣滀负鏂囦欢
+ /// </summary>
+ /// <param name="groupJobName"></param>
+ public static void InitGroupJobFileLog(string groupJobName)
+ {
+ string jobFile = _logPath + groupJobName;
+ jobFile = jobFile.ReplacePath();
+ if (!File.Exists(jobFile))
+ {
+ File.Create(jobFile);
+ }
+ }
+
+ public static List<TaskLog> GetJobRunLog(string taskName, string groupName, int page, int pageSize = 100)
+ {
+ string path = $"{_logPath}{groupName}\\{taskName}.txt";
+ List<TaskLog> list = new List<TaskLog>();
+
+ path = path.ReplacePath();
+ if (!File.Exists(path))
+ return list;
+ var logs = FileHelper.ReadPageLine(path, page, pageSize, true);
+ foreach (string item in logs)
+ {
+ string[] arr = item?.Split('_');
+ if (item == "" || arr == null || arr.Length == 0)
+ continue;
+ if (arr.Length != 3)
+ {
+ list.Add(new TaskLog() { Msg = item });
+ continue;
+ }
+ list.Add(new TaskLog() { BeginDate = arr[0], EndDate = arr[1], Msg = arr[2] });
+ }
+ return list.OrderByDescending(x => x.BeginDate).ToList();
+ }
+
+ public static void WriteJobConfig(List<TaskOptions> taskList)
+ {
+ //string jobs = JsonConvert.SerializeObject(taskList);
+ string jobs= JsonConvert.SerializeObject(taskList, Formatting.Indented);
+ //鍐欏叆閰嶇疆鏂囦欢
+ FileHelper.WriteFile(_rootPath, QuartzFileInfo.JobConfigFileName, jobs);
+ }
+
+ public static void WriteStartLog(string content)
+ {
+ content = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "," + content;
+ if (!content.EndsWith("\r\n"))
+ {
+ content += "\r\n";
+ }
+ FileHelper.WriteFile(FileQuartz.LogPath, "start.txt", content, true);
+ }
+ public static void WriteJobAction(JobAction jobAction, ITrigger trigger, string taskName, string groupName)
+ {
+ WriteJobAction(jobAction, taskName, groupName, trigger == null ? "鏈壘鍒颁綔涓�" : "OK");
+ }
+ public static void WriteJobAction(JobAction jobAction, string taskName, string groupName, string content = null)
+ {
+ content = $"{jobAction.ToString()} -- {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} --鍒嗙粍锛歿groupName},浣滀笟锛歿taskName},娑堟伅:{content ?? "OK"}\r\n";
+ FileHelper.WriteFile(FileQuartz.LogPath, "action.txt", content, true);
+ }
+
+ public static void WriteAccess(string content = null)
+ {
+ content = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}_{content}\r\n";
+ FileHelper.WriteFile(FileQuartz.LogPath, "access.txt", content, true);
+ }
+
+ public static string GetAccessLog(int pageSize = 1)
+ {
+ string path = FileQuartz.LogPath + "access.txt";
+ path = path.ReplacePath();
+ if (!File.Exists(path))
+ return "娌℃湁鎵惧埌鐩綍";
+ return string.Join("<br/>", FileHelper.ReadPageLine(path, pageSize, 5000, true).ToList());
+ }
+ public static string RootPath
+ {
+ get { return _rootPath; }
+ }
+
+ public static string LogPath
+ {
+ get { return _logPath; }
+ }
+ }
+}
diff --git a/VueWebCoreApi/Quartz/HttpContext.cs b/VueWebCoreApi/Quartz/HttpContext.cs
new file mode 100644
index 0000000..a787cf2
--- /dev/null
+++ b/VueWebCoreApi/Quartz/HttpContext.cs
@@ -0,0 +1,20 @@
+锘縰sing Microsoft.AspNetCore.Http;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Quartz
+{
+ public static class HttpContext
+ {
+ private static IHttpContextAccessor _accessor;
+
+ public static Microsoft.AspNetCore.Http.HttpContext Current => _accessor.HttpContext;
+
+ internal static void Configure(IHttpContextAccessor accessor)
+ {
+ _accessor = accessor;
+ }
+ }
+}
diff --git a/VueWebCoreApi/Quartz/HttpManager.cs b/VueWebCoreApi/Quartz/HttpManager.cs
new file mode 100644
index 0000000..f1f9c4a
--- /dev/null
+++ b/VueWebCoreApi/Quartz/HttpManager.cs
@@ -0,0 +1,73 @@
+锘縰sing Microsoft.AspNetCore.Http;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Quartz
+{
+ public static class HttpManager
+ {
+ public static string GetUserIP(IHttpContextAccessor httpContextAccessor)
+ {
+ var Request = httpContextAccessor.HttpContext.Request;
+ string realIP = null;
+ string forwarded = null;
+ string remoteIpAddress = httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
+ if (Request.Headers.ContainsKey("X-Real-IP"))
+ {
+ realIP = Request.Headers["X-Real-IP"].ToString();
+ if (realIP != remoteIpAddress)
+ {
+ remoteIpAddress = realIP;
+ }
+ }
+ if (Request.Headers.ContainsKey("X-Forwarded-For"))
+ {
+ forwarded = Request.Headers["X-Forwarded-For"].ToString();
+ if (forwarded != remoteIpAddress)
+ {
+ remoteIpAddress = forwarded;
+ }
+ }
+ return remoteIpAddress;
+ }
+
+
+
+ public static async Task<string> HttpSendAsync(this IHttpClientFactory httpClientFactory, HttpMethod method, string url, Dictionary<string, string> headers = null)
+ {
+
+ var client = httpClientFactory.CreateClient();
+ var content = new StringContent("");
+ //content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ //content.Headers.ContentType.CharSet = "utf-8";
+ var request = new HttpRequestMessage(method, url)
+ {
+ Content = content
+ };
+ if (headers != null)
+ {
+ foreach (var header in headers)
+ {
+ request.Headers.Add(header.Key, header.Value);
+ }
+ }
+ try
+ {
+ HttpResponseMessage httpResponseMessage = await client.SendAsync(request);
+
+ var result = await httpResponseMessage.Content
+ .ReadAsStringAsync();
+ return result;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ return ex.Message;
+ }
+ }
+ }
+}
diff --git a/VueWebCoreApi/Quartz/HttpResultfulJob.cs b/VueWebCoreApi/Quartz/HttpResultfulJob.cs
new file mode 100644
index 0000000..c3aa4e5
--- /dev/null
+++ b/VueWebCoreApi/Quartz/HttpResultfulJob.cs
@@ -0,0 +1,94 @@
+锘縰sing log4net;
+using Microsoft.AspNetCore.SignalR;
+using Quartz;
+using Quartz.Impl;
+using Quartz.Impl.Triggers;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Net.Http;
+using System.Threading.Tasks;
+using VueWebCoreApi.Extensions;
+using VueWebCoreApi.SignalR;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.Quartz
+{
+ public class HttpResultfulJob : IJob
+ {
+ private ILog log = LogManager.GetLogger(Startup.repository.Name, typeof(ChatHub));
+ private readonly IHubContext<ChatHub, IChatClient> _hubContext;
+
+ readonly IHttpClientFactory httpClientFactory;
+ /// <summary>
+ /// 2020.05.31澧炲姞鏋勯�犳柟娉�
+ /// </summary>
+ /// <param name="serviceProvider"></param>
+ /// <param name="httpClientFactory"></param>
+ public HttpResultfulJob(IServiceProvider serviceProvider, IHttpClientFactory httpClientFactory, IHubContext<ChatHub, IChatClient> hubContext)
+ {
+ this.httpClientFactory = httpClientFactory;
+ _hubContext = hubContext;
+ //serviceProvider.GetService()
+ }
+ public async Task Execute(IJobExecutionContext context)
+ {
+ DateTime dateTime = DateTime.Now;
+ TaskOptions taskOptions = context.GetTaskOptions();
+ string httpMessage = "";
+ AbstractTrigger trigger = (context as JobExecutionContextImpl).Trigger as AbstractTrigger;
+ if (taskOptions == null)
+ {
+ FileHelper.WriteFile(FileQuartz.LogPath + trigger.Group, $"{trigger.Name}.txt", "鏈埌鎵句綔涓氭垨鍙兘琚Щ闄�", true);
+ return;
+ }
+ Console.WriteLine($"浣滀笟[{taskOptions.TaskName}]寮�濮�:{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss")}");
+ if (string.IsNullOrEmpty(taskOptions.ApiUrl) || taskOptions.ApiUrl == "/")
+ {
+ FileHelper.WriteFile(FileQuartz.LogPath + trigger.Group, $"{trigger.Name}.txt", $"{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss")}鏈厤缃畊rl,", true);
+ return;
+ }
+
+ try
+ {
+ Dictionary<string, string> header = new Dictionary<string, string>();
+ if (!string.IsNullOrEmpty(taskOptions.AuthKey) && !string.IsNullOrEmpty(taskOptions.AuthValue))
+ {
+ header.Add(taskOptions.AuthKey.Trim(), taskOptions.AuthValue.Trim());
+ }
+
+ httpMessage = await httpClientFactory.HttpSendAsync(taskOptions.RequestType?.ToLower() == "get" ? HttpMethod.Get : HttpMethod.Post, taskOptions.ApiUrl, header);
+ }
+ catch (Exception ex)
+ {
+ httpMessage = ex.Message;
+ }
+
+ try
+ {
+ string logContent = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}_{dateTime.ToString("yyyy-MM-dd HH:mm:ss")}_{(string.IsNullOrEmpty(httpMessage) ? "OK" : httpMessage)}\r\n";
+ FileHelper.WriteFile(FileQuartz.LogPath + taskOptions.GroupName + "\\", $"{taskOptions.TaskName}.txt", logContent, true);
+ //await _hubContext.Clients.All.SendAsync("SendMessage绯荤粺閫氱煡:"+$"鏈�鏂版秷鎭瘂DateTime.Now}");
+ //await _hubContext.Clients.All.SendAll(logContent);
+ //鏌ユ壘绯荤粺鐢ㄦ埛
+ var sql = @"select usercode as code,username as name
+ from TUser
+ where is_delete='0' and enable='Y' and password='123'";
+ var data = DapperHelper.selecttable(sql);
+ var departmentIDs = data.AsEnumerable().Select(x => x.Field<string>("code")).ToList();//鑾峰彇鎺ㄩ�佷汉鍛樼紪鐮�
+ var FindPublicBaseDic = UserIdsStore.Ids.Where(d => departmentIDs.Contains(d.Value)).Select(x => x.Key).ToList(); //鍖归厤宸茬粡鐧诲綍鐨勬帹閫佷汉鍛榗onnectionIds
+ if (FindPublicBaseDic.Count > 0)
+ {
+ //鎺ㄩ�佹寚瀹氱敤鎴�
+ await _hubContext.Clients.Clients(FindPublicBaseDic).SendCustomUserMessage(logContent);
+ }
+ }
+ catch (Exception)
+ {
+ }
+ Console.WriteLine(trigger.FullName + " " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss") + " " + httpMessage);
+ return;
+ }
+ }
+}
diff --git a/VueWebCoreApi/Quartz/IOCJobFactory.cs b/VueWebCoreApi/Quartz/IOCJobFactory.cs
new file mode 100644
index 0000000..4240437
--- /dev/null
+++ b/VueWebCoreApi/Quartz/IOCJobFactory.cs
@@ -0,0 +1,28 @@
+锘縰sing Quartz;
+using Quartz.Spi;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Quartz
+{
+ public class IOCJobFactory : IJobFactory
+ {
+ private readonly IServiceProvider _serviceProvider;
+ public IOCJobFactory(IServiceProvider serviceProvider)
+ {
+ _serviceProvider = serviceProvider;
+ }
+ public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
+ {
+ return _serviceProvider.GetService(bundle.JobDetail.JobType) as IJob;
+
+ }
+
+ public void ReturnJob(IJob job)
+ {
+ (job as IDisposable)?.Dispose();
+ }
+ }
+}
diff --git a/VueWebCoreApi/Quartz/IPathProvider.cs b/VueWebCoreApi/Quartz/IPathProvider.cs
new file mode 100644
index 0000000..af76ac2
--- /dev/null
+++ b/VueWebCoreApi/Quartz/IPathProvider.cs
@@ -0,0 +1,48 @@
+锘縰sing Microsoft.AspNetCore.Hosting;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Quartz
+{
+ public interface IPathProvider
+ {
+ string MapPath(string path);
+ string MapPath(string path, bool rootPath);
+ IWebHostEnvironment GetHostingEnvironment();
+ }
+ public class PathProvider : IPathProvider
+ {
+ private IWebHostEnvironment _hostingEnvironment;
+
+ public PathProvider(IWebHostEnvironment environment)
+ {
+ _hostingEnvironment = environment;
+ }
+ public IWebHostEnvironment GetHostingEnvironment()
+ {
+ return _hostingEnvironment;
+ }
+
+ public string MapPath(string path)
+ {
+ return MapPath(path, false);
+ }
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="path"></param>
+ /// <param name="rootPath">鑾峰彇wwwroot璺緞</param>
+ /// <returns></returns>
+ public string MapPath(string path, bool rootPath)
+ {
+ if (rootPath)
+ {
+ return Path.Combine(_hostingEnvironment.WebRootPath, path);
+ }
+ return Path.Combine(_hostingEnvironment.ContentRootPath, path);
+ }
+ }
+}
diff --git a/VueWebCoreApi/Quartz/JobAction.cs b/VueWebCoreApi/Quartz/JobAction.cs
new file mode 100644
index 0000000..be66f29
--- /dev/null
+++ b/VueWebCoreApi/Quartz/JobAction.cs
@@ -0,0 +1,18 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Quartz
+{
+ public enum JobAction
+ {
+ 鏂板 = 1,
+ 鍒犻櫎 = 2,
+ 淇敼 = 3,
+ 鏆傚仠 = 4,
+ 鍋滄,
+ 寮�鍚�,
+ 绔嬪嵆鎵ц
+ }
+}
diff --git a/VueWebCoreApi/Quartz/QuartzFileInfo.cs b/VueWebCoreApi/Quartz/QuartzFileInfo.cs
new file mode 100644
index 0000000..c588a6d
--- /dev/null
+++ b/VueWebCoreApi/Quartz/QuartzFileInfo.cs
@@ -0,0 +1,22 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Quartz
+{
+ public class QuartzFileInfo
+ {
+ /// <summary>
+ /// 鎵�鏈変换鍔$浉鍏冲瓨鏀剧殑鏂囦欢澶归粯璁ょ敓鎴愬湪褰撳墠椤圭洰绫诲簱鍚岀骇(瀛愭枃浠跺す鍖呮嫭锛氭棩蹇�,浣滀笟閰嶇疆)
+ /// </summary>
+ public static string QuartzSettingsFolder = "QuartzSettings";
+ //鎵�鏈変綔涓氶厤缃瓨鍌ㄦ枃浠�
+ public static string JobConfigFileName = "job_options.json";
+
+ /// <summary>
+ /// 鏃ュ織鏂囦欢澶瑰悕绉�
+ /// </summary>
+ public static string Logs = "logs";
+ }
+}
diff --git a/VueWebCoreApi/Quartz/QuartzNETExtension.cs b/VueWebCoreApi/Quartz/QuartzNETExtension.cs
new file mode 100644
index 0000000..977eb5c
--- /dev/null
+++ b/VueWebCoreApi/Quartz/QuartzNETExtension.cs
@@ -0,0 +1,512 @@
+锘縰sing Dapper;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.DependencyInjection;
+using Newtonsoft.Json;
+using Quartz;
+using Quartz.Impl;
+using Quartz.Impl.Matchers;
+using Quartz.Impl.Triggers;
+using Quartz.Spi;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Quartz;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.Extensions
+{
+ public static class QuartzNETExtension
+ {
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+ private static List<TaskOptions> _taskList = new List<TaskOptions>();
+
+ /// <summary>
+ /// 鍒濆鍖栦綔涓�
+ /// </summary>
+ /// <param name="applicationBuilder"></param>
+ /// <param name="env"></param>
+ /// <returns></returns>
+ public static IApplicationBuilder UseQuartz(this IApplicationBuilder applicationBuilder, IWebHostEnvironment env)
+ {
+ IServiceProvider services = applicationBuilder.ApplicationServices;
+
+ ISchedulerFactory _schedulerFactory = services.GetService<ISchedulerFactory>();
+
+ string path = FileQuartz.CreateQuartzRootPath(env);
+ //鏌ユ壘浠诲姟鍒楄〃
+ var data = QuartzSearchData.QuartzSearch();
+ if (data.Rows.Count <= 0)
+ {
+ FileHelper.WriteFile(FileQuartz.LogPath, "start.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},娌℃湁榛樿閰嶇疆浠诲姟\r\n", true);
+ return applicationBuilder;
+ }
+ string jobConfig = JsonConvert.SerializeObject(data);
+
+ //string jobConfig = FileHelper.ReadFile(path + QuartzFileInfo.JobConfigFileName);
+ //if (string.IsNullOrEmpty(jobConfig))
+ //{
+ // FileHelper.WriteFile(FileQuartz.LogPath, "start.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},娌℃湁榛樿閰嶇疆浠诲姟\r\n", true);
+ // return applicationBuilder;
+ //}
+
+ int errorCount = 0;
+ string errorMsg = "";
+ TaskOptions options = null;
+ try
+ {
+ _taskList = JsonConvert.DeserializeObject<List<TaskOptions>>(jobConfig);
+ _taskList.ForEach(x =>
+ {
+ options = x;
+ var result = x.AddJob(_schedulerFactory, true, jobFactory: services.GetService<IJobFactory>()).GetAwaiter().GetResult();
+ });
+ }
+ catch (Exception ex)
+ {
+ errorCount = +1;
+ errorMsg += $"浣滀笟:{options?.TaskName},寮傚父锛歿ex.Message}";
+ }
+ string content = $"鎴愬姛:{ _taskList.Count - errorCount}涓�,澶辫触{errorCount}涓�,寮傚父锛歿errorMsg}\r\n";
+ FileQuartz.WriteStartLog(content);
+
+
+ return applicationBuilder;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎵�鏈夌殑浣滀笟
+ /// </summary>
+ /// <param name="schedulerFactory"></param>
+ /// <returns></returns>
+ public static async Task<List<TaskOptions>> GetJobs(this ISchedulerFactory schedulerFactory)
+ {
+ List<TaskOptions> list = new List<TaskOptions>();
+ try
+ {
+ IScheduler _scheduler = await schedulerFactory.GetScheduler();
+ var groups = await _scheduler.GetJobGroupNames();
+ foreach (var groupName in groups)
+ {
+ foreach (var jobKey in await _scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(groupName)))
+ {
+ TaskOptions taskOptions = _taskList.Where(x => x.GroupName == jobKey.Group && x.TaskName == jobKey.Name)
+ .FirstOrDefault();
+ if (taskOptions == null)
+ continue;
+
+ var triggers = await _scheduler.GetTriggersOfJob(jobKey);
+ foreach (ITrigger trigger in triggers)
+ {
+ DateTimeOffset? dateTimeOffset = trigger.GetPreviousFireTimeUtc();
+ if (dateTimeOffset != null)
+ {
+ taskOptions.LastRunTime = Convert.ToDateTime(dateTimeOffset.ToString());
+ //鏇存敼鏈�鍚庢墽琛屾椂闂�
+ bool aa = QuartzSearchData.QuartzUpdate(taskOptions);
+ }
+ else
+ {
+ var runlog = FileQuartz.GetJobRunLog(taskOptions.TaskName, taskOptions.GroupName, 1, 2);
+ if (runlog.Count > 0)
+ {
+ DateTime.TryParse(runlog[0].BeginDate, out DateTime lastRunTime);
+ taskOptions.LastRunTime = lastRunTime;
+ //鏇存敼鏈�鍚庢墽琛屾椂闂�
+ bool aa = QuartzSearchData.QuartzUpdate(taskOptions);
+ }
+ }
+ }
+ list.Add(taskOptions);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = ex.Message + ex.StackTrace;
+ mes.data = null;
+ FileQuartz.WriteStartLog("鑾峰彇浣滀笟寮傚父锛�" + ex.Message + ex.StackTrace);
+ }
+ return list;
+ }
+
+ /// <summary>
+ /// 娣诲姞浣滀笟
+ /// </summary>
+ /// <param name="taskOptions"></param>
+ /// <param name="schedulerFactory"></param>
+ /// <param name="init">鏄惁鍒濆鍖�,鍚�=闇�瑕侀噸鏂扮敓鎴愰厤缃枃浠讹紝鏄�=涓嶉噸鏂扮敓鎴愰厤缃枃浠�</param>
+ /// <returns></returns>
+ public static async Task<object> AddJob(this TaskOptions taskOptions, ISchedulerFactory schedulerFactory, bool init = false, IJobFactory jobFactory = null)
+ {
+ try
+ {
+ //澶勭悊鍓嶇Corn琛ㄨ揪寮忔渶鍚庝竴涓湀鐨勬槦鏈熷ぉ琛ㄨ揪寮忕己闄烽棶棰�
+ string resultString = "";
+ string[] str = taskOptions.Interval.Split(" ");
+ if ((str[3].Equals("1L") || str[3].Equals("2L") || str[3].Equals("3L") || str[3].Equals("4L") || str[3].Equals("5L") || str[3].Equals("6L") || str[3].Equals("7L")) && str[5].Equals("?"))
+ {
+ str[5] = str[3];
+ str[3] = "?";
+ for (int i = 0; i < str.Length; i++)
+ {
+ resultString += str[i] + " ";
+ }
+ taskOptions.Interval = resultString;
+ }
+ (bool, string) validExpression = taskOptions.Interval.IsValidExpression();
+ if (!validExpression.Item1)
+ return new { code = 300,count=0,Message=validExpression.Item2,data="null" };
+
+ (bool, object) result = taskOptions.Exists(init);
+ if (!result.Item1)
+ return result.Item2;
+ if (!init)
+ {
+ //灏嗗巻鍙蹭换鍔″強鏂板鍔犱换鍔″ぉ鍔犲埌List闆嗗悎
+ _taskList.Add(taskOptions);
+ //灏嗛泦鍚堟暟鎹坊鍔犲埌json鏂囦欢(瑕嗙洊寮�)
+ FileQuartz.WriteJobConfig(_taskList);
+ //灏嗗綋鍓嶆柊浠诲姟娣诲姞鍒版暟鎹〃
+ bool aa = QuartzSearchData.QuartzCreate(taskOptions);
+ }
+
+ IJobDetail job = JobBuilder.Create<HttpResultfulJob>().WithIdentity(taskOptions.TaskName, taskOptions.GroupName).Build();
+ ITrigger trigger = TriggerBuilder.Create()
+ .WithIdentity(taskOptions.TaskName, taskOptions.GroupName)
+ .StartNow()
+ .WithDescription(taskOptions.Describe)
+ .WithCronSchedule(taskOptions.Interval)
+ .Build();
+
+ IScheduler scheduler = await schedulerFactory.GetScheduler();
+
+ if (jobFactory == null)
+ {
+ try
+ {
+ jobFactory = HttpContext.Current.RequestServices.GetService<IJobFactory>();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"鍒涘缓浠诲姟[{taskOptions.TaskName}]寮傚父,{ex.Message}");
+ }
+ }
+
+ if (jobFactory != null)
+ {
+ scheduler.JobFactory = jobFactory;
+ }
+
+ await scheduler.ScheduleJob(job, trigger);
+ if (taskOptions.Status == (int)TriggerState.Normal)
+ {
+ await scheduler.Start();
+ }
+ else
+ {
+ await scheduler.PauseJob(job.Key);
+ // await schedulerFactory.Pause(taskOptions);
+ FileQuartz.WriteStartLog($"浣滀笟:{taskOptions.TaskName},鍒嗙粍:{taskOptions.GroupName},鏂板缓鏃舵湭鍚姩鍘熷洜,鐘舵�佷负:{taskOptions.Status}");
+ }
+ if (!init)
+ FileQuartz.WriteJobAction(JobAction.鏂板, taskOptions.TaskName, taskOptions.GroupName);
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message ="鎵ц鎴愬姛锛�";
+ mes.data = null;
+ }
+ catch (Exception ex)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = ex.Message;
+ mes.data = null;
+ return new { status = false, msg = ex.Message };
+ }
+ return mes;
+ }
+
+ /// <summary>
+ /// 绉婚櫎浣滀笟
+ /// </summary>
+ /// <param name="schedulerFactory"></param>
+ /// <param name="taskName"></param>
+ /// <param name="groupName"></param>
+ /// <returns></returns>
+ public static Task<object> Remove(this ISchedulerFactory schedulerFactory, TaskOptions taskOptions)
+ {
+ return schedulerFactory.TriggerAction(taskOptions.TaskName, taskOptions.GroupName, JobAction.鍒犻櫎, taskOptions);
+ }
+
+ /// <summary>
+ /// 鏇存柊浣滀笟
+ /// </summary>
+ /// <param name="schedulerFactory"></param>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ public static Task<object> Update(this ISchedulerFactory schedulerFactory, TaskOptions taskOptions)
+ {
+ return schedulerFactory.TriggerAction(taskOptions.TaskName, taskOptions.GroupName, JobAction.淇敼, taskOptions);
+ }
+
+ /// <summary>
+ /// 鏆傚仠浣滀笟
+ /// </summary>
+ /// <param name="schedulerFactory"></param>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ public static Task<object> Pause(this ISchedulerFactory schedulerFactory, TaskOptions taskOptions)
+ {
+ return schedulerFactory.TriggerAction(taskOptions.TaskName, taskOptions.GroupName, JobAction.鏆傚仠, taskOptions);
+ }
+
+ /// <summary>
+ /// 鍚姩浣滀笟
+ /// </summary>
+ /// <param name="schedulerFactory"></param>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ public static Task<object> Start(this ISchedulerFactory schedulerFactory, TaskOptions taskOptions)
+ {
+ return schedulerFactory.TriggerAction(taskOptions.TaskName, taskOptions.GroupName, JobAction.寮�鍚�, taskOptions);
+ }
+
+ /// <summary>
+ /// 绔嬪嵆鎵ц涓�娆′綔涓�
+ /// </summary>
+ /// <param name="schedulerFactory"></param>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ public static Task<object> Run(this ISchedulerFactory schedulerFactory, TaskOptions taskOptions)
+ {
+ return schedulerFactory.TriggerAction(taskOptions.TaskName, taskOptions.GroupName, JobAction.绔嬪嵆鎵ц, taskOptions);
+ }
+
+ public static object ModifyTaskEntity(this TaskOptions taskOptions, ISchedulerFactory schedulerFactory, JobAction action)
+ {
+ TaskOptions options = null;
+ object result = null;
+ switch (action)
+ {
+ case JobAction.鍒犻櫎:
+ for (int i = 0; i < _taskList.Count; i++)
+ {
+ options = _taskList[i];
+ if (options.TaskName == taskOptions.TaskName && options.GroupName == taskOptions.GroupName)
+ {
+ _taskList.RemoveAt(i);
+ //鍒犻櫎浠诲姟
+ bool aa = QuartzSearchData.QuartzDelete(options);
+ }
+ }
+ break;
+ case JobAction.淇敼:
+ options = _taskList.Where(x => x.TaskName == taskOptions.TaskName && x.GroupName == taskOptions.GroupName).FirstOrDefault();
+ //绉婚櫎浠ュ墠鐨勯厤缃�
+ if (options != null)
+ {
+ _taskList.Remove(options);
+ //鍒犻櫎浠诲姟
+ bool aa = QuartzSearchData.QuartzDelete(options);
+ }
+
+ //鐢熸垚浠诲姟骞舵坊鍔犳柊閰嶇疆
+ result = taskOptions.AddJob(schedulerFactory, false).GetAwaiter().GetResult();
+ break;
+ case JobAction.鏆傚仠:
+ case JobAction.寮�鍚�:
+ case JobAction.鍋滄:
+ case JobAction.绔嬪嵆鎵ц:
+ options = _taskList.Where(x => x.TaskName == taskOptions.TaskName && x.GroupName == taskOptions.GroupName).FirstOrDefault();
+ if (action == JobAction.鏆傚仠)
+ {
+ options.Status = (int)TriggerState.Paused;
+ //鏇存柊浠诲姟鐘舵��
+ bool aa= QuartzSearchData.QuartzUpdate(options);
+ }
+ else if (action == JobAction.鍋滄)
+ {
+ options.Status = (int)action;
+ //鏇存柊浠诲姟鐘舵��
+ bool aa = QuartzSearchData.QuartzUpdate(options);
+ }
+ else
+ {
+ options.Status = (int)TriggerState.Normal;
+ //鏇存柊浠诲姟鐘舵��
+ bool aa = QuartzSearchData.QuartzUpdate(options);
+ }
+ break;
+ }
+ //鐢熸垚閰嶇疆鏂囦欢
+ FileQuartz.WriteJobConfig(_taskList);
+ FileQuartz.WriteJobAction(action, taskOptions.TaskName, taskOptions.GroupName, "鎿嶄綔瀵硅薄锛�" + JsonConvert.SerializeObject(taskOptions));
+ return result;
+ }
+
+ /// <summary>
+ /// 瑙﹀彂鏂板銆佸垹闄ゃ�佷慨鏀广�佹殏鍋溿�佸惎鐢ㄣ�佺珛鍗虫墽琛屼簨浠�
+ /// </summary>
+ /// <param name="schedulerFactory"></param>
+ /// <param name="taskName"></param>
+ /// <param name="groupName"></param>
+ /// <param name="action"></param>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ public static async Task<object> TriggerAction(this ISchedulerFactory schedulerFactory, string taskName, string groupName, JobAction action, TaskOptions taskOptions = null)
+ {
+ string errorMsg = "";
+ try
+ {
+ //澶勭悊鍓嶇Corn琛ㄨ揪寮忔渶鍚庝竴涓湀鐨勬槦鏈熷ぉ琛ㄨ揪寮忕己闄烽棶棰�
+ string resultString = "";
+ string[] str = taskOptions.Interval.Split(" ");
+ if ((str[3].Equals("1L") || str[3].Equals("2L") || str[3].Equals("3L") || str[3].Equals("4L") || str[3].Equals("5L") || str[3].Equals("6L") || str[3].Equals("7L")) && str[5].Equals("?"))
+ {
+ str[5] = str[3];
+ str[3] = "?";
+ for (int i = 0; i < str.Length; i++)
+ {
+ resultString += str[i] + " ";
+ }
+ taskOptions.Interval = resultString;
+ }
+ IScheduler scheduler = await schedulerFactory.GetScheduler();
+ List<JobKey> jobKeys = scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(groupName)).Result.ToList();
+ if (jobKeys == null || jobKeys.Count() == 0)
+ {
+ errorMsg = $"鏈壘鍒板垎缁刐{groupName}]";
+ return new { code = 300, count = 0, Message = errorMsg, data = "null" };
+ //return new { status = false, msg = errorMsg };
+ }
+ JobKey jobKey = jobKeys.Where(s => scheduler.GetTriggersOfJob(s).Result.Any(x => (x as CronTriggerImpl).Name == taskName)).FirstOrDefault();
+ if (jobKey == null)
+ {
+ errorMsg = $"鏈壘鍒拌Е鍙戝櫒[{taskName}]";
+ return new { code = 300, count = 0, Message = errorMsg, data = "null" };
+ }
+ var triggers = await scheduler.GetTriggersOfJob(jobKey);
+ ITrigger trigger = triggers?.Where(x => (x as CronTriggerImpl).Name == taskName).FirstOrDefault();
+
+ if (trigger == null)
+ {
+ errorMsg = $"鏈壘鍒拌Е鍙戝櫒[{taskName}]";
+ return new { code = 300, count = 0, Message = errorMsg, data = "null" };
+ }
+ object result = null;
+ switch (action)
+ {
+ case JobAction.鍒犻櫎:
+ case JobAction.淇敼:
+ await scheduler.PauseTrigger(trigger.Key);
+ await scheduler.UnscheduleJob(trigger.Key);// 绉婚櫎瑙﹀彂鍣�
+ await scheduler.DeleteJob(trigger.JobKey);
+ result = taskOptions.ModifyTaskEntity(schedulerFactory, action);
+ break;
+ case JobAction.鏆傚仠:
+ case JobAction.鍋滄:
+ case JobAction.寮�鍚�:
+ result = taskOptions.ModifyTaskEntity(schedulerFactory, action);
+ if (action == JobAction.鏆傚仠)
+ {
+ await scheduler.PauseTrigger(trigger.Key);
+ }
+ else if (action == JobAction.寮�鍚�)
+ {
+ await scheduler.ResumeTrigger(trigger.Key);
+ // await scheduler.RescheduleJob(trigger.Key, trigger);
+ }
+ else
+ {
+ await scheduler.Shutdown();
+ }
+ break;
+ case JobAction.绔嬪嵆鎵ц:
+ if (taskOptions != null && taskOptions.Status != (int)TriggerState.Normal)
+ {
+ result = taskOptions.ModifyTaskEntity(schedulerFactory, JobAction.寮�鍚�);
+ await scheduler.ResumeTrigger(trigger.Key);
+
+ }
+ else {
+ await scheduler.TriggerJob(jobKey);
+ }
+
+ break;
+ }
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = $"浣滀笟{action.ToString()}鎴愬姛";
+ mes.data = null;
+ return result ?? mes;
+ //return result ?? new { status = true, msg = $"浣滀笟{action.ToString()}鎴愬姛" };
+ }
+ catch (Exception ex)
+ {
+ errorMsg = ex.Message;
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = errorMsg;
+ mes.data = null;
+ return mes;
+ //return new { status = false, msg = ex.Message };
+ }
+ finally
+ {
+ FileQuartz.WriteJobAction(action, taskName, groupName, errorMsg);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="context"></param>閫氳繃浣滀笟涓婁笅鏂囪幏鍙栦綔涓氬搴旂殑閰嶇疆鍙傛暟
+ /// <returns></returns>
+ public static TaskOptions GetTaskOptions(this IJobExecutionContext context)
+ {
+ AbstractTrigger trigger = (context as JobExecutionContextImpl).Trigger as AbstractTrigger;
+ TaskOptions taskOptions = _taskList.Where(x => x.TaskName == trigger.Name && x.GroupName == trigger.Group).FirstOrDefault();
+ return taskOptions ?? _taskList.Where(x => x.TaskName == trigger.JobName && x.GroupName == trigger.JobGroup).FirstOrDefault();
+ }
+
+ /// <summary>
+ /// 浣滀笟鏄惁瀛樺湪
+ /// </summary>
+ /// <param name="taskOptions"></param>
+ /// <param name="init">鍒濆鍖栫殑涓嶉渶瑕佸垽鏂�</param>
+ /// <returns></returns>
+ public static (bool, object) Exists(this TaskOptions taskOptions, bool init)
+ {
+ if (!init && _taskList.Any(x => x.TaskName == taskOptions.TaskName && x.GroupName == taskOptions.GroupName))
+ {
+ return (false,
+ new
+ {
+ status = false,
+ msg = $"浣滀笟:{taskOptions.TaskName},鍒嗙粍锛歿taskOptions.GroupName}宸茬粡瀛樺湪"
+ });
+ }
+ return (true, null);
+ }
+
+ public static (bool, string) IsValidExpression(this string cronExpression)
+ {
+ try
+ {
+ CronTriggerImpl trigger = new CronTriggerImpl();
+ trigger.CronExpressionString = cronExpression;
+ DateTimeOffset? date = trigger.ComputeFirstFireTimeUtc(null);
+ return (date != null, date == null ? $"璇风‘璁よ〃杈惧紡{cronExpression}鏄惁姝g‘!" : "");
+ }
+ catch (Exception e)
+ {
+ return (false, $"璇风‘璁よ〃杈惧紡{cronExpression}鏄惁姝g‘!{e.Message}");
+ }
+ }
+ }
+
+}
diff --git a/VueWebCoreApi/Quartz/QuartzSearchData.cs b/VueWebCoreApi/Quartz/QuartzSearchData.cs
new file mode 100644
index 0000000..7f34698
--- /dev/null
+++ b/VueWebCoreApi/Quartz/QuartzSearchData.cs
@@ -0,0 +1,116 @@
+锘縰sing Dapper;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.Quartz
+{
+ public class QuartzSearchData
+ {
+ /// <summary>
+ /// 鏌ヨ浠诲姟鍒楄〃
+ /// </summary>
+ /// <returns></returns>
+ public static DataTable QuartzSearch()
+ {
+ //鏌ユ壘浠诲姟鍒楄〃
+ var sql = @"select TaskName,GroupName,Interval,ApiUrl,AuthKey,AuthValue,Describe,RequestType,LastRunTime,Status
+ from ScheduleInfo";
+ var data = DapperHelper.selecttable(sql);
+ return data;
+ }
+
+ /// <summary>
+ /// 鏂板浠诲姟
+ /// </summary>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ public static bool QuartzCreate(TaskOptions taskOptions)
+ {
+ List<object> list = new List<object>();
+ string sql = @"insert into ScheduleInfo(TaskName,GroupName,Interval,ApiUrl,AuthKey,AuthValue,Describe,RequestType,LastRunTime,Status,CreateAuthr,CreateTime)
+ values(@TaskName,@GroupName,@Interval,@ApiUrl,@AuthKey,@AuthValue,@Describe,@RequestType,@LastRunTime,@Status,@CreateAuthr,@CreateTime)";
+ list.Add(new { str = sql, parm = new {
+ TaskName = taskOptions.TaskName,
+ GroupName = taskOptions.GroupName,
+ Interval = taskOptions.Interval,
+ ApiUrl = taskOptions.ApiUrl,
+ AuthKey = taskOptions.AuthKey,
+ AuthValue = taskOptions.AuthValue,
+ Describe = taskOptions.Describe,
+ RequestType = taskOptions.RequestType,
+ LastRunTime = taskOptions.LastRunTime,
+ Status=taskOptions.Status,
+ CreateAuthr="9999",
+ CreateTime= DateTime.Now.ToString()
+ }
+ });
+ bool aa = DapperHelper.DoTransaction(list);
+ return aa;
+ }
+
+ /// <summary>
+ /// 淇敼浠诲姟
+ /// </summary>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ public static bool QuartzUpdate(TaskOptions taskOptions)
+ {
+ List<object> list = new List<object>();
+ string sql = @"update ScheduleInfo set TaskName=@TaskName,GroupName=@GroupName,Interval=@Interval,ApiUrl=@ApiUrl,AuthKey=@AuthKey,AuthValue=@AuthValue,Describe=@Describe,RequestType=@RequestType,LastRunTime=@LastRunTime,Status=@Status
+ where TaskName=@TaskName and GroupName=@GroupName";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ TaskName = taskOptions.TaskName,
+ GroupName = taskOptions.GroupName,
+ Interval = taskOptions.Interval,
+ ApiUrl = taskOptions.ApiUrl,
+ AuthKey = taskOptions.AuthKey,
+ AuthValue = taskOptions.AuthValue,
+ Describe = taskOptions.Describe,
+ RequestType = taskOptions.RequestType,
+ LastRunTime = taskOptions.LastRunTime,
+ Status = taskOptions.Status
+ }
+ });
+ bool aa = DapperHelper.DoTransaction(list);
+ return aa;
+ }
+
+ /// <summary>
+ /// 鍒犻櫎浠诲姟
+ /// </summary>
+ /// <param name="taskOptions"></param>
+ /// <returns></returns>
+ public static bool QuartzDelete(TaskOptions taskOptions)
+ {
+ List<object> list = new List<object>();
+ string sql = @"delete ScheduleInfo where TaskName=@TaskName and GroupName=@GroupName";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ TaskName = taskOptions.TaskName,
+ GroupName = taskOptions.GroupName,
+ Interval = taskOptions.Interval,
+ ApiUrl = taskOptions.ApiUrl,
+ AuthKey = taskOptions.AuthKey,
+ AuthValue = taskOptions.AuthValue,
+ Describe = taskOptions.Describe,
+ RequestType = taskOptions.RequestType,
+ LastRunTime = taskOptions.LastRunTime,
+ Status = taskOptions.Status
+ }
+ });
+ bool aa = DapperHelper.DoTransaction(list);
+ return aa;
+ }
+ }
+}
diff --git a/VueWebCoreApi/Quartz/StaticHttpContextExtensions.cs b/VueWebCoreApi/Quartz/StaticHttpContextExtensions.cs
new file mode 100644
index 0000000..20d0cdd
--- /dev/null
+++ b/VueWebCoreApi/Quartz/StaticHttpContextExtensions.cs
@@ -0,0 +1,20 @@
+锘縰sing Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Extensions
+{
+ public static class StaticHttpContextExtensions
+ {
+ public static IApplicationBuilder UseStaticHttpContext(this IApplicationBuilder app)
+ {
+ var httpContextAccessor = app.ApplicationServices.GetRequiredService<IHttpContextAccessor>();
+ Quartz.HttpContext.Configure(httpContextAccessor);
+ return app;
+ }
+ }
+}
diff --git a/VueWebCoreApi/Quartz/TaskAuthorAttribute.cs b/VueWebCoreApi/Quartz/TaskAuthorAttribute.cs
new file mode 100644
index 0000000..a0a1aa8
--- /dev/null
+++ b/VueWebCoreApi/Quartz/TaskAuthorAttribute.cs
@@ -0,0 +1,13 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Quartz
+{
+ public class TaskAuthorAttribute : Attribute
+ {
+ public string Name { get; set; }
+ public string Role { get; set; }
+ }
+}
diff --git a/VueWebCoreApi/Quartz/TaskLog.cs b/VueWebCoreApi/Quartz/TaskLog.cs
new file mode 100644
index 0000000..d106211
--- /dev/null
+++ b/VueWebCoreApi/Quartz/TaskLog.cs
@@ -0,0 +1,14 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Quartz
+{
+ public class TaskLog
+ {
+ public string BeginDate { get; set; }
+ public string EndDate { get; set; }
+ public string Msg { get; set; }
+ }
+}
diff --git a/VueWebCoreApi/Quartz/TaskOptions.cs b/VueWebCoreApi/Quartz/TaskOptions.cs
new file mode 100644
index 0000000..a921c10
--- /dev/null
+++ b/VueWebCoreApi/Quartz/TaskOptions.cs
@@ -0,0 +1,21 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Quartz
+{
+ public class TaskOptions
+ {
+ public string TaskName { get; set; }
+ public string GroupName { get; set; }
+ public string Interval { get; set; }
+ public string ApiUrl { get; set; }
+ public string AuthKey { get; set; }
+ public string AuthValue { get; set; }
+ public string Describe { get; set; }
+ public string RequestType { get; set; }
+ public DateTime? LastRunTime { get; set; }
+ public int Status { get; set; }
+ }
+}
diff --git a/VueWebCoreApi/SignalR/ChatHub.cs b/VueWebCoreApi/SignalR/ChatHub.cs
new file mode 100644
index 0000000..643cdf2
--- /dev/null
+++ b/VueWebCoreApi/SignalR/ChatHub.cs
@@ -0,0 +1,87 @@
+锘縰sing log4net;
+using Microsoft.AspNet.SignalR.Hubs;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.SignalR;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Reflection;
+using System.Threading.Tasks;
+using VueWebCoreApi.Models;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi.SignalR
+{
+ public class ChatHub : Hub<IChatClient>
+ {
+ private readonly IHttpContextAccessor _httpContextAccessor;
+ private ILog log = LogManager.GetLogger(Startup.repository.Name, typeof(ChatHub));
+ ILogger<ChatHub> _logger;
+ public ChatHub(ILogger<ChatHub> logger, IHttpContextAccessor httpContextAccessor)
+ {
+ _logger = logger;
+ _httpContextAccessor = httpContextAccessor;
+ }
+ /// <summary>
+ /// 瀹㈡埛绔繛鎺ユ湇鍔$
+ /// </summary>
+ /// <returns></returns>
+ public override Task OnConnectedAsync()
+ {
+ log.Info("寮�鍚繛鎺ユ湇鍔�");
+ var id = Context.ConnectionId;
+ _logger.LogInformation($"Client ConnectionId=> [[{id}]] Already Connection Server锛�");
+ return base.OnConnectedAsync();
+ }
+ /// <summary>
+ /// 瀹㈡埛绔柇寮�杩炴帴
+ /// </summary>
+ /// <param name="exception"></param>
+ /// <returns></returns>
+ public override Task OnDisconnectedAsync(Exception exception)
+ {
+ var id = Context.ConnectionId;
+ // 鍒犻櫎鐢ㄦ埛ID
+ UserIdsStore.Ids.Remove(id);
+ _logger.LogInformation($"Client ConnectionId=> [[{id}]] Already Close Connection Server!");
+ return base.OnDisconnectedAsync(exception);
+ }
+ /**
+ * 娴嬭瘯
+ * */
+ /// <summary>
+ /// 缁欐墍鏈夊鎴风鍙戦�佹秷鎭�
+ /// </summary>
+ /// <returns></returns>
+ public async Task SendMessage(string data)
+ {
+ await Clients.All.SendAll(data);
+ }
+
+ /// <summary>
+ /// 娣诲姞鍒板湪绾跨敤鎴峰垪琛�
+ /// </summary>
+ /// <param name="usercode"></param>
+ /// <returns></returns>
+ public async Task AddUser(string usercode)
+ {
+ string cid = Context.ConnectionId;
+ if (!UserIdsStore.Ids.ContainsValue(usercode))
+ {
+ await Task.Run(() => UserIdsStore.Ids.Add(cid, usercode));
+ }
+ else
+ {
+ //lambada琛ㄨ揪寮�:鏍规嵁鍊煎幓閿悕Key
+ string key = UserIdsStore.Ids.FirstOrDefault(d => d.Value == usercode).Key.ToString();
+ // 鍒涘缓涓�涓柊鐨勯敭鍊煎
+ UserIdsStore.Ids.Add(cid, usercode);
+ // 绉婚櫎鏃х殑閿�煎
+ UserIdsStore.Ids.Remove(key);
+ }
+
+ }
+ }
+}
diff --git a/VueWebCoreApi/SignalR/IChatClient.cs b/VueWebCoreApi/SignalR/IChatClient.cs
new file mode 100644
index 0000000..3911bc8
--- /dev/null
+++ b/VueWebCoreApi/SignalR/IChatClient.cs
@@ -0,0 +1,13 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.SignalR
+{
+ public interface IChatClient
+ {
+ Task SendAll(object message);
+ Task SendCustomUserMessage(object message);
+ }
+}
diff --git a/VueWebCoreApi/SignalR/UserIdsStore.cs b/VueWebCoreApi/SignalR/UserIdsStore.cs
new file mode 100644
index 0000000..4090d89
--- /dev/null
+++ b/VueWebCoreApi/SignalR/UserIdsStore.cs
@@ -0,0 +1,15 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.SignalR
+{
+ /// <summary>
+ /// 鐢ㄦ埛id闆嗗悎
+ /// </summary>
+ public static class UserIdsStore
+ {
+ public static Dictionary<string, string> Ids = new Dictionary<string, string>();
+ }
+}
diff --git a/VueWebCoreApi/Startup.cs b/VueWebCoreApi/Startup.cs
new file mode 100644
index 0000000..9113269
--- /dev/null
+++ b/VueWebCoreApi/Startup.cs
@@ -0,0 +1,166 @@
+using log4net;
+using log4net.Config;
+using log4net.Repository;
+using Microsoft.AspNetCore.Authentication.Cookies;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http.Connections;
+using Microsoft.AspNetCore.HttpsPolicy;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Authorization;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
+using Microsoft.OpenApi.Models;
+using Quartz;
+using Quartz.Impl;
+using Quartz.Spi;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.ApiGroup;
+using VueWebCoreApi.Extensions;
+using VueWebCoreApi.Quartz;
+using VueWebCoreApi.SignalR;
+using VueWebCoreApi.Tools;
+
+namespace VueWebCoreApi
+{
+ public class Startup
+ {
+ public Startup(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
+
+ public IConfiguration Configuration { get; }
+
+ //log4net日志
+ public static ILoggerRepository repository { get; set; }
+ //跨域设置
+ readonly string ganweiCosr = "AllowSpecificOrigins";
+
+ // This method gets called by the runtime. Use this method to add services to the container.
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddControllers().AddNewtonsoftJson(op =>
+ {
+ op.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
+ op.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
+ });
+ #region Swagger 第二种方式
+ services.AddSwaggerGen(c =>
+ {
+ typeof(OpenApiGroup).GetEnumNames().ToList().ForEach(version =>
+ {
+
+ c.SwaggerDoc(version, new OpenApiInfo()
+ {
+ Title = $"新凯迪MesApi文档:{version}",
+ Version = version,
+ Description = $"Panda.Sewerage : {version} "
+ });
+ });
+ string basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
+ string xmlPath = Path.Combine(basePath, "VueWebCoreApi.xml");
+ c.IncludeXmlComments(xmlPath, true);
+ });
+ #endregion
+ // 设置配置
+ AppSetting.SetAppSetting(Configuration.GetSection("ConnectionStrings"));
+ //log4net配置
+ repository = LogManager.CreateRepository("AprilLog");
+ XmlConfigurator.Configure(repository, new FileInfo("Config/log4net.config"));
+ BasicConfigurator.Configure(repository);
+ services.AddControllersWithViews();
+ //Quartz
+ services.AddHttpClient();
+ services.AddHttpContextAccessor();
+ services.AddSingleton<IPathProvider, PathProvider>();
+ services.AddTransient<HttpResultfulJob>();
+ services.AddSingleton<ISchedulerFactory, StdSchedulerFactory>();
+ services.AddSingleton<IJobFactory, IOCJobFactory>();
+
+ //跨域设置
+ services.AddCors(options =>
+ {
+ options.AddPolicy(
+ "cors",
+ set =>
+ {
+ set.SetIsOriginAllowed(origin => true).AllowAnyHeader().AllowAnyMethod().AllowCredentials();
+ });
+ });
+ //设置SignalR
+ services.AddSignalR();
+
+
+ //设置session,并设置超时时间
+ services.AddSession(o =>
+ {
+ o.IdleTimeout = TimeSpan.FromSeconds(double.Parse(AppSetting.GetAppSetting("InProc")));
+ });
+ //设置Cookies
+ services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
+
+ }
+
+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime applicationLeftTime, ILoggerFactory loggerFactory)
+ {
+ if (env.IsDevelopment())
+ {
+ app.UseDeveloperExceptionPage();
+ }
+ applicationLeftTime.ApplicationStarted.Register(() =>
+ {
+ DataOperator.SetConnectionString1(Convert.ToString(AppSetting.GetAppSetting("DBServer")));
+ });
+ #region Swagger分组第二种
+ app.UseSwagger();
+ app.UseSwaggerUI(c =>
+ {
+ //删除Swagger上默认Schemas架构
+ c.DefaultModelsExpandDepth(-1);
+ //c.SwaggerEndpoint("/swagger/v1/swagger.json", "Api Document");
+ typeof(OpenApiGroup).GetEnumNames().ToList().ForEach(version =>
+ {
+ c.SwaggerEndpoint($"/swagger/{version}/swagger.json", $"{version}");
+ });
+ });
+ #endregion
+ app.UseHttpsRedirection();
+
+ app.UseRouting();
+
+ app.UseAuthorization();
+ //跨域
+ app.UseCors("cors");
+ //用户session服务
+ app.UseSession();
+ //cookies
+ app.UseCookiePolicy();
+ //HttpContext
+ app.UseStaticHostEnviroment();
+ //Quartz
+ app.UseQuartz(env).UseStaticHttpContext();
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllers();
+ endpoints.MapHub<ChatHub>("/ChatHub", options =>
+ {
+ options.Transports =
+ HttpTransportType.WebSockets |
+ HttpTransportType.LongPolling;
+ });
+ });
+ loggerFactory.AddLog4Net("Config/log4net.config");
+ }
+ }
+}
diff --git a/VueWebCoreApi/Tools/AppLableBarCode.cs b/VueWebCoreApi/Tools/AppLableBarCode.cs
new file mode 100644
index 0000000..c13021a
--- /dev/null
+++ b/VueWebCoreApi/Tools/AppLableBarCode.cs
@@ -0,0 +1,183 @@
+锘縰sing Dapper;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Models;
+
+namespace VueWebCoreApi.Tools
+{
+ public class AppLableBarCode
+ {
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+
+ #region [鑾峰彇瑙勫垯缂栫爜]
+ /// <summary>
+ /// 鏍规嵁鍔熻兘缂栫爜鑾峰彇鏈�鏂拌鍒欑紪鐮�
+ /// </summary>
+ /// <param name="rightcode">鍔熻兘缂栫爜</param>
+ /// <param name="partcode">鐗╂枡缂栫爜</param>
+ /// <param name="qty">鏁伴噺</param>
+ /// <param name="onelabqty">鍗曟爣绛炬暟閲�</param>
+ /// <returns></returns>
+ public static ToMessage EncodingSeach(string rightcode, string partcode, string qty, string onelabqty)
+ {
+ string sql, year = "", month = "", day = "", fdate = "", q = "", cunm2 = "", Encode = "", cunm = "";
+ int digit2 = 0, value2 = 0, digit3 = 0, digitdiff = 0;
+ bool stf;
+ List<object> list = new List<object>();
+ List<string> listdt = new List<string>();
+ List<AppLabCode> lab = new List<AppLabCode>();
+ var dynamicParams = new DynamicParameters();
+ //鑾峰彇鏍囩涓暟:杩涗竴娉�
+ decimal labcum = Math.Ceiling(decimal.Parse(qty) / decimal.Parse(onelabqty));
+ try
+ {
+ sql = @"select prefix,filingdate,incbit,value from TCodeRules where rightcode=@rightcode";
+ dynamicParams.Add("@rightcode", rightcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ string prefix = data.Rows[0]["PREFIX"].ToString(); //鍥哄畾瀛楁
+ string filingdate = data.Rows[0]["FILINGDATE"].ToString(); //鎻愪氦鏃ユ湡
+ int incbit = int.Parse(data.Rows[0]["INCBIT"].ToString()); //鑷浣嶆暟
+ string value = data.Rows[0]["VALUE"].ToString(); //娴佹按鍙�
+ decimal sumqty = 0;//瀹氫箟绱鍗曟爣绛炬暟閲�
+ if (int.Parse(value) >= 0)
+ {
+ switch (filingdate)
+ {
+ case "骞存湀鏃�":
+ lab = Labcode(partcode, year, month, day, prefix, fdate, digit2, value2, digit3, digitdiff, q, cunm2, Encode, value, labcum, sumqty, onelabqty, rightcode, qty, out cunm);
+ break;
+ case "骞存湀":
+ lab = Labcode(partcode, year, month, day, prefix, fdate, digit2, value2, digit3, digitdiff, q, cunm2, Encode, value, labcum, sumqty, onelabqty, rightcode, qty, out cunm);
+ break;
+ case "骞�":
+ lab = Labcode(partcode, year, month, day, prefix, fdate, digit2, value2, digit3, digitdiff, q, cunm2, Encode, value, labcum, sumqty, onelabqty, rightcode, qty, out cunm);
+ break;
+ default:
+ break;
+ }
+ //鏇存柊瑙勫垯琛ㄤ綅鏁板強娴佹按鍙�
+ sql = @"update TCodeRules set incbit=@incbit,value=@cunm2 where rightcode=@rightcode";
+ dynamicParams.Add("@incbit", cunm.Length);
+ dynamicParams.Add("@cunm2", cunm);
+ dynamicParams.Add("@rightcode", rightcode);
+ list.Add(new { str = sql, parm = dynamicParams });
+ stf = DapperHelper.DoTransaction(list);
+ if (stf)
+ {
+ mes.code = "200";
+ mes.Message = "鎴愬姛!";
+ mes.data = lab;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶辫触!";
+ mes.data = null;
+ }
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏈缃紪鐮佽鍒�,鐢熸垚鍗曞彿澶辫触,璇疯缃紪鐮佷负銆�" + rightcode + "銆戠殑缂栫爜瑙勫垯!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熸垚鏉$爜]
+ /// <summary>
+ /// 鐢熸垚鏉$爜
+ /// </summary>
+ /// <param name="partcode">鐗╂枡缂栫爜</param>
+ /// <param name="year">骞�</param>
+ /// <param name="month">鏈�</param>
+ /// <param name="day">鏃�</param>
+ /// <param name="prefix">鍥哄畾瀛楁</param>
+ /// <param name="fdate">骞�(2浣�)+鏈�(2浣�)+鏃�(2浣�)</param>
+ /// <param name="digit2">娴佹按鍙烽暱搴�</param>
+ /// <param name="value2">鑷娴佹按鍙�</param>
+ /// <param name="digit3">鑷娴佹按鍙烽暱搴�</param>
+ /// <param name="digitdiff">浣嶆暟宸�</param>
+ /// <param name="q">琛ヤ綅(0)</param>
+ /// <param name="cunm2">鏈�缁堟祦姘村彿(鍖呭惈琛ヤ綅)</param>
+ /// <param name="Encode">鏈�缁堟爣绛剧爜(鍥哄畾瀛楁+瑙勫垯+鏈�缁堟祦姘村彿)</param>
+ /// <param name="value">鍒濆鏌ヨ鏈�鏂版祦姘村彿</param>
+ /// <param name="labcum">鏍囩涓暟</param>
+ /// <param name="sumqty">绱鍗曟爣绛炬暟閲�</param>
+ /// <param name="onelabqty">鍗曟爣绛炬暟閲�</param>
+ /// <param name="rightcode">鍔熻兘缂栫爜</param>
+ /// <param name="qty">鏁伴噺</param>
+ /// <param name="cunm">杈撳嚭鏈�缁堟祦姘村彿</param>
+ /// <returns></returns>
+ public static List<AppLabCode> Labcode(string partcode, string year, string month, string day, string prefix, string fdate, int digit2, int value2, int digit3, int digitdiff, string q, string cunm2, string Encode, string value, decimal labcum, decimal sumqty, string onelabqty, string rightcode, string qty, out string cunm)
+ {
+ List<AppLabCode> lab = new List<AppLabCode>();
+ year = DateTime.Now.Year.ToString().Substring(2, 2);//鑾峰彇骞�(2浣�)
+ month = DateTime.Now.Month.ToString().PadLeft(2, '0');//鑾峰彇鏈�(2浣�)
+ day = DateTime.Now.Day.ToString().PadLeft(2, '0');//鑾峰彇鏃�(2浣�)
+ fdate = year + month + day;
+
+ //鑾峰彇鏌ヨ娴佹按鍙风殑浣嶆暟
+ digit2 = value.Length;//鑾峰彇string绫诲瀷浣嶆暟
+ for (int i = 1; i <= labcum; i++)
+ {
+ AppLabCode lb = new AppLabCode();
+ lb.rightcode = rightcode;
+ if (i == labcum) //鏈�鍚庝竴寮犳爣绛�
+ {
+ lb.labqty = (decimal.Parse(qty) - sumqty).ToString(); //鍗曟爣绛炬暟閲�
+ }
+ else
+ {
+ lb.labqty = onelabqty; //鍗曟爣绛炬暟閲�
+ sumqty += decimal.Parse(onelabqty);
+ }
+
+ //娴佹按鍙峰惊鐜嚜澧�
+ value2 = int.Parse(value) + i;
+ //鑾峰彇鑷鍚庢祦姘村彿浣嶆暟
+ digit3 = value2.ToString().Length;
+ //鑾峰彇浣嶆暟涔嬪樊
+ digitdiff = digit2 - digit3;
+ //閲嶆柊鑾峰彇娴佹按鍙蜂綅鏁�
+ digit2 = digit3;
+ q = "";
+ if (digitdiff < 0) //浣嶆暟宸负璐熸暟闇�瑕佽繘琛ヤ綅
+ {
+ cunm2 = value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ else
+ {
+ for (int j = 1; j <= digitdiff; j++)
+ {
+ q = q + "0";
+ }
+ cunm2 = q + value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ Encode = prefix + fdate + cunm2; //鏈�缁堢紪鐮�
+ lb.labcode = Encode;
+ lb.partnumber = partcode;
+ lab.Add(lb);
+ }
+ cunm = cunm2;
+ return lab;
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/Tools/AppSetting.cs b/VueWebCoreApi/Tools/AppSetting.cs
new file mode 100644
index 0000000..89f3d86
--- /dev/null
+++ b/VueWebCoreApi/Tools/AppSetting.cs
@@ -0,0 +1,33 @@
+锘縰sing Microsoft.Extensions.Configuration;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ /// <summary>
+ /// 璇诲彇appsetting閰嶇疆
+ /// </summary>
+ public class AppSetting
+ {
+ private static IConfigurationSection _configurationSection = null;
+ /// <summary>
+ /// 璇诲彇閰嶇疆
+ /// </summary>
+ /// <param name="key"></param>
+ /// <returns></returns>
+ public static string GetAppSetting(string key)
+ {
+ return _configurationSection.GetSection(key)?.Value;
+ }
+ /// <summary>
+ /// 璁剧疆閰嶇疆
+ /// </summary>
+ /// <param name="section"></param>
+ public static void SetAppSetting(IConfigurationSection section)
+ {
+ _configurationSection = section;
+ }
+ }
+}
diff --git a/VueWebCoreApi/Tools/ChannelActionFilterAttribute.cs b/VueWebCoreApi/Tools/ChannelActionFilterAttribute.cs
new file mode 100644
index 0000000..38e208c
--- /dev/null
+++ b/VueWebCoreApi/Tools/ChannelActionFilterAttribute.cs
@@ -0,0 +1,70 @@
+锘縰sing Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Filters;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+using VueWebCoreApi.Models;
+
+namespace VueWebCoreApi.Tools
+{
+ public class ChannelActionFilterAttribute: ActionFilterAttribute
+ {
+ ToMessage mes = new ToMessage();
+ RedisHelper redis = new RedisHelper();
+
+ /// <summary>
+ /// 鍦ˋction鎵ц鍓嶆墽琛�
+ /// </summary>
+ /// <param name="context"></param>
+ public override void OnActionExecuting(ActionExecutingContext context)
+ {
+ try
+ {
+ //var aa = DapperHelper.GetTokenFromRequestHeader();
+ var token = context.HttpContext.Request.Headers["Token"].ToString();
+ User us = JwtTools.Denocode(token.ToString());
+ base.OnActionExecuting(context);
+ //濡傛灉瀛樺湪
+ if (redis.Get<User>(us.rediskey, 0) !=null)
+ {
+ //鑾峰彇redis涓綋鍓嶇敤鎴蜂俊鎭�
+ User r_loginUser = redis.Get<User>(us.rediskey, 0);
+ if (token != r_loginUser.token)
+ {
+ mes.code = "303";
+ mes.count = 0;
+ mes.Message = "token宸茶繃鏈�,璇烽噸鏂扮櫥褰�!";
+ context.Result = new JsonResult(mes);
+ }
+ else
+ {
+ //閲嶇疆杩囨湡鏃堕棿
+ redis.KeyExpire(us.rediskey, redis.secondsTimeOut);
+ }
+ }
+ else //濡傛灉redis鐧诲綍鐢ㄦ埛涓笉瀛樺湪褰撳墠鐢ㄦ埛
+ {
+ mes.code = "303";
+ mes.count = 0;
+ mes.Message = "鐧诲綍宸茶秴鏃�,璇烽噸鏂扮櫥褰�!";
+ context.Result = new JsonResult(mes);
+ }
+ // 灏嗚繃婊ゅ櫒涓殑鍊煎瓨鍌ㄥ湪HttpContext.Items涓紝浠ヤ究鍦ㄦ帶鍒跺櫒涓闂�
+ //context.HttpContext.Items.Remove("Token");
+ //context.HttpContext.Items["Token"] = token;
+ }
+ catch (Exception e)
+ {
+ LogHelper.WriteLog(e);
+ mes.code = "303";
+ mes.Message = e.Message;
+ context.Result = new JsonResult(mes);
+ }
+ }
+ }
+}
diff --git a/VueWebCoreApi/Tools/ChannelActionFilterAttributeApp.cs b/VueWebCoreApi/Tools/ChannelActionFilterAttributeApp.cs
new file mode 100644
index 0000000..7a9681a
--- /dev/null
+++ b/VueWebCoreApi/Tools/ChannelActionFilterAttributeApp.cs
@@ -0,0 +1,38 @@
+锘縰sing Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Filters;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Models;
+
+namespace VueWebCoreApi.Tools
+{
+ public class ChannelActionFilterAttributeApp : ActionFilterAttribute
+ {
+ ToMessage mes = new ToMessage();
+ RedisHelper redis = new RedisHelper();
+
+ /// <summary>
+ /// 鍦ˋction鎵ц鍓嶆墽琛�
+ /// </summary>
+ /// <param name="context"></param>
+ public override void OnActionExecuting(ActionExecutingContext context)
+ {
+ try
+ {
+
+ mes.code = "303";
+ mes.Message = "鐧诲綍宸茶秴鏃�,璇烽噸鏂扮櫥褰�!";
+ context.Result = new JsonResult(mes);
+
+ }
+ catch (Exception)
+ {
+ mes.code = "303";
+ mes.Message = "鐧诲綍宸茶秴鏃�,璇烽噸鏂扮櫥褰�!";
+ context.Result = new JsonResult(mes);
+ }
+ }
+ }
+}
diff --git a/VueWebCoreApi/Tools/CoreHttpContext .cs b/VueWebCoreApi/Tools/CoreHttpContext .cs
new file mode 100644
index 0000000..a97ef4f
--- /dev/null
+++ b/VueWebCoreApi/Tools/CoreHttpContext .cs
@@ -0,0 +1,36 @@
+锘縰sing Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class CoreHttpContext
+ {
+ private static IWebHostEnvironment _hostEnviroment;
+ public static string WebPath => _hostEnviroment.WebRootPath;
+
+ public static string MapPath(string path)
+ {
+ return Path.Combine(_hostEnviroment.ContentRootPath, path);
+ }
+
+ internal static void Configure(IWebHostEnvironment hostEnviroment)
+ {
+ _hostEnviroment = hostEnviroment;
+ }
+ }
+ public static class StaticHostEnviromentExtensions
+ {
+ public static IApplicationBuilder UseStaticHostEnviroment(this IApplicationBuilder app)
+ {
+ var webHostEnvironment = app.ApplicationServices.GetRequiredService<IWebHostEnvironment>();
+ CoreHttpContext.Configure(webHostEnvironment);
+ return app;
+ }
+ }
+}
diff --git a/VueWebCoreApi/Tools/DALSkillCondition.cs b/VueWebCoreApi/Tools/DALSkillCondition.cs
new file mode 100644
index 0000000..ce62b6d
--- /dev/null
+++ b/VueWebCoreApi/Tools/DALSkillCondition.cs
@@ -0,0 +1,34 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class DALSkillCondition
+ {
+ /// <summary>
+ /// 涓嬭浇excel
+ /// </summary>
+ /// <param name="path"></param>
+ /// <param name="num"></param>
+ /// <returns></returns>
+ #region
+ public static bool ResultExcel(string path, DataTable dt)
+ {
+ try
+ {
+
+ NPOIHelper.ExportEasy(dt, path);
+ return true;
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/Tools/DBHelper.cs b/VueWebCoreApi/Tools/DBHelper.cs
new file mode 100644
index 0000000..4d1d28c
--- /dev/null
+++ b/VueWebCoreApi/Tools/DBHelper.cs
@@ -0,0 +1,731 @@
+锘縰sing System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class DBHelper
+ {
+ #region DataTable GetTable(string sql) 鑾峰彇DataTable
+ /// <summary>
+ /// 鑾峰彇DataTable
+ /// </summary>
+ /// <param name="sql">浼犲叆SQL璇彞</param>
+ /// <returns>杩斿洖DataTable</returns>
+ public static DataTable GetTable(string sql)
+ {
+ DataOperator dbo = null;
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.getTable(sql);
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ //throw (ex);
+ return null;
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇DataTable
+ /// </summary>
+ /// <param name="sql">浼犲叆SQL璇彞</param>
+ /// <param name="parameters">SqlParameter 鍙傛暟</param>
+ /// <returns>杩斿洖DataTable</returns>
+ public static DataTable GetTable(string sql, params SqlParameter[] parameters)
+ {
+
+
+ DataOperator dbo = null;
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.getTable(sql, parameters);
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw (ex);
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+ #endregion
+
+ /// <summary>
+ /// Dataset鑾峰彇鏁版嵁琛�
+ /// </summary>
+ /// <param name="sql"></param>
+ /// <param name="parameters"></param>
+ /// <returns></returns>
+ #region
+ public static DataSet GetData(string sql, params SqlParameter[] parameters)
+ {
+
+
+ DataOperator dbo = null;
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.getdate(sql, parameters);
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ //throw (ex);
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ return null;
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+ #endregion
+
+ #region GetCount(string sql) 鑾峰彇鏁版嵁琛屾暟,濡傛灉鍑洪敊杩斿洖"-1"
+ /// <summary>
+ /// 鑾峰彇鏁版嵁琛屾暟,濡傛灉鍑洪敊杩斿洖"-1"
+ /// </summary>
+ /// <param name="sql">浼犲叆SQL璇彞</param>
+ /// <returns>濡傛灉鍑洪敊杩斿洖"-1"</returns>
+ public static int GetCount(string sql)
+ {
+ DataOperator dbo = null;
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.getCount(sql);
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ //throw (ex);
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ return 0;
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+
+ /// <summary>
+ /// 鎵ц澶氭潯sql璇彞鐨勪簨鐗�
+ /// </summary>
+ /// <param name="list"></param>
+ /// <returns></returns>
+ public static int Executesqltran(List<string> list, params SqlParameter[] parameters)
+ {
+ DataOperator dbo = null;
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.ExecuteSqlTran(list, parameters);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLog(ex);
+ throw (ex);
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ return 0;
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇鏁版嵁琛屾暟,濡傛灉鍑洪敊杩斿洖"-1"
+ /// </summary>
+ /// <param name="sql">浼犲叆SQL璇彞</param>
+ /// <param name="parameters">SqlParameter 鍙傛暟</param>
+ /// <returns>濡傛灉鍑洪敊杩斿洖"-1"</returns>
+ public static int GetCount(string sql, params SqlParameter[] parameters)
+ {
+ DataOperator dbo = null;
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.getCount(sql, parameters);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLog(ex);
+ throw (ex);
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ return 0;
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+ #endregion
+
+ #region GetObject(string sql) 鑾峰彇琛ㄦ牸绗竴琛岀涓�鍒�
+ /// <summary>
+ /// 鑾峰彇琛ㄦ牸绗竴琛岀涓�鍒�
+ /// </summary>
+ /// <param name="sql">浼犲叆SQL璇彞</param>
+ /// <returns>濡傛灉鍑洪敊杩斿洖"null"</returns>
+ public static object GetObject(string sql)
+ {
+ DataOperator dbo = null;
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.getObject(sql);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLog(ex);
+ throw (ex);
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ return null;
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇琛ㄦ牸绗竴琛岀涓�鍒�
+ /// </summary>
+ /// <param name="sql">浼犲叆SQL璇彞</param>
+ /// <param name="parameters">SqlParameter 鍙傛暟</param>
+ /// <returns>杩斿洖Object</returns>
+ public static object GetObject(string sql, params SqlParameter[] parameters)
+ {
+ DataOperator dbo = null;
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.getObject(sql, parameters);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLog(ex);
+ throw (ex);
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ return null;
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+ #endregion
+
+ #region ExecuteSql(string sql) 鎵цSQL璇彞杩斿洖鏄惁鎴愬姛
+ /// <summary>
+ /// 鎵цSQL璇彞杩斿洖鏄惁鎴愬姛
+ /// </summary>
+ /// <param name="sql">浼犲叆SQL璇彞</param>
+ /// <returns>杩斿洖鏄惁鎴愬姛</returns>
+ public static bool ExecuteSql(string sql)
+ {
+ DataOperator dbo = null;
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.executeSql(sql);
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ //throw (ex);
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ return false;
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+
+ /// <summary>
+ /// 鎵цSQL璇彞杩斿洖鏄惁鎴愬姛
+ /// </summary>
+ /// <param name="sql">浼犲叆SQL璇彞</param>
+ /// <param name="parameters">SqlParameter 鍙傛暟</param>
+ /// <returns>杩斿洖鏄惁鎴愬姛</returns>
+ public static bool ExecuteSql(string sql, params SqlParameter[] parameters)
+ {
+ DataOperator dbo = null;
+ //ParamCollections pc = new ParamCollections();
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.executeSql(sql, parameters);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLog(ex);
+ throw (ex);
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ return false;
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+ #endregion
+
+ #region ExecuteProduct(string productName, params SqlParameter[] parameters) 鎵ц瀛樺偍杩囩▼杩斿洖杩斿洖鍊�
+ /// <summary>
+ /// 鎵ц瀛樺偍杩囩▼杩斿洖杩斿洖鍊�
+ /// </summary>
+ /// <param name="productName">瀛樺偍杩囩▼鍚嶅瓧</param>
+ /// <param name="parameters">SqlParameter 鍙傛暟</param>
+ /// <returns>杩斿洖鍊糎ash琛�</returns>
+ public static Hashtable ExecuteProduct(string productName, params SqlParameter[] parameters)
+ {
+ DataOperator dbo = null;
+ //ParamCollections pc = new ParamCollections();
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.executeProduct(productName, parameters);
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ //throw (ex);
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ return new Hashtable();
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+ #endregion
+
+ #region ExecuteProductData(string productName, params SqlParameter[] parameters) 鎵ц瀛樺偍杩囩▼杩斿洖DataTable
+ /// <summary>
+ /// 鎵ц瀛樺偍杩囩▼杩斿洖杩斿洖鍊�
+ /// </summary>
+ /// <param name="productName">瀛樺偍杩囩▼鍚嶅瓧</param>
+ /// <param name="parameters">SqlParameter 鍙傛暟</param>
+ /// <returns>杩斿洖鍊糎ash琛�</returns>
+ public static DataTable ExecuteProductData(string productName, params SqlParameter[] parameters)
+ {
+ DataOperator dbo = null;
+ //ParamCollections pc = new ParamCollections();
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.ExecuteProductData(productName, parameters);
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw new Exception(ex.Message);
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+ #endregion
+
+ #region ExecuteProductData(string productName, params SqlParameter[] parameters) 鎵ц瀛樺偍杩囩▼杩斿洖List<DataTable>
+ /// <summary>
+ /// 鎵ц瀛樺偍杩囩▼杩斿洖杩斿洖鍊�
+ /// </summary>
+ /// <param name="productName">瀛樺偍杩囩▼鍚嶅瓧</param>
+ /// <param name="parameters">SqlParameter 鍙傛暟</param>
+ /// <returns>杩斿洖鍊糎ash琛�</returns>
+ public static List<DataTable> ExecuteProductDataList(string productName, params SqlParameter[] parameters)
+ {
+ DataOperator dbo = null;
+ //ParamCollections pc = new ParamCollections();
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.ExecuteProductDataList(productName, parameters);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLog(ex);
+ throw new Exception(ex.Message);
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+ #endregion
+
+ #region ExecuteProductData(string productName, params SqlParameter[] parameters) 鎵ц瀛樺偍杩囩▼杩斿洖ArrayList
+ /// <summary>
+ /// 鎵ц瀛樺偍杩囩▼杩斿洖杩斿洖鍊�
+ /// </summary>
+ /// <param name="productName">瀛樺偍杩囩▼鍚嶅瓧</param>
+ /// <param name="parameters">SqlParameter 鍙傛暟</param>
+ /// <returns>杩斿洖鍊糒ist</returns>
+ public static ArrayList executeProductList(string produreName, bool returnDt, params SqlParameter[] parameters)
+ {
+ DataOperator dbo = null;
+ //ParamCollections pc = new ParamCollections();
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.executeProduct(produreName, parameters, returnDt);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLog(ex);
+ throw new Exception(ex.Message);
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+ #endregion
+
+ #region ExecuteProductData(string productName) 鎵ц瀛樺偍杩囩▼杩斿洖bool
+ /// <summary>
+ /// 鎵ц瀛樺偍杩囩▼杩斿洖杩斿洖鍊�
+ /// </summary>
+ /// <param name="productName">瀛樺偍杩囩▼鍚嶅瓧</param>
+ /// <param name="parameters">SqlParameter 鍙傛暟</param>
+ /// <returns>杩斿洖鍊糄ataTable琛�</returns>
+ public static bool ExecuteProductbool(string productName, params SqlParameter[] parameters)
+ {
+ DataOperator dbo = null;
+ //ParamCollections pc = new ParamCollections();
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ return dbo.ExecuteProduct(productName, parameters);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLog(ex);
+ throw (ex);
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+
+ }
+ finally
+ {
+ if (dbo != null)
+ {
+ dbo.Close();
+ }
+ }
+ }
+ #endregion
+
+ #region GetDataByPage() 鍒嗛〉鏌ヨ
+ /// <summary>
+ /// 鍒嗛〉鏌ヨ
+ /// </summary>
+ /// <param name="filename">琛ㄥ悕</param>
+ /// <param name="filename">闇�瑕佽繑鍥炵殑鍒�</param>
+ /// <param name="sortfilename">鎺掑簭瀛楁鍚�</param>
+ /// <param name="PageSize">椤靛昂瀵�</param>
+ /// <param name="PageIndex">椤电爜</param>
+ /// <param name="OrderType">璁剧疆鎺掑簭绫诲瀷, 闈� 0 鍊煎垯闄嶅簭</param>
+ /// <param name="strWhere">鏌ヨ鏉′欢 (娉ㄦ剰: 涓嶈鍔� where)</param>
+ /// <param name="RecordCount">鎬昏褰�</param>
+ /// <returns></returns>
+ public static DataTable GetDataByPage(string tablename, string filename, string sortfilename, int PageSize, int PageIndex, int OrderType, string strWhere, out int RecordCount)
+ {
+ RecordCount = 0;
+ //鍒涘缓鍙傛暟
+ SqlParameter[] param = {
+ new SqlParameter("@tblName", SqlDbType.VarChar, 50),
+ new SqlParameter("@strGetFields", SqlDbType.VarChar, 1000),
+ new SqlParameter("@fldName", SqlDbType.VarChar, 255),
+ new SqlParameter("@PageSize", SqlDbType.Int),
+ new SqlParameter("@PageIndex", SqlDbType.Int),
+ new SqlParameter("@OrderType", SqlDbType.Bit,1),
+ new SqlParameter("@strWhere", SqlDbType.VarChar,500),
+ new SqlParameter("@RecordCount", SqlDbType.Int)
+ };
+ param[0].Value = tablename;
+ param[1].Value = filename;
+ param[2].Value = sortfilename;
+ param[3].Value = PageSize;
+ param[4].Value = PageIndex;
+ param[5].Value = OrderType;
+ param[6].Value = strWhere;
+ param[7].Direction = ParameterDirection.Output;
+ DataOperator dbo = null;
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ DataTable dt = dbo.ExecuteProductData("GetDataByPage", param);
+ RecordCount = (int)param[7].Value;
+ return dt;
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ if (null != dbo)
+ {
+ dbo.Close();
+ dbo = null;
+ }
+ }
+ }
+ /// <summary>
+ /// 鍒嗛〉鏌ヨ(鏀寔JOIN)
+ /// </summary>
+ /// <param name="filename">琛ㄥ悕</param>
+ /// <param name="filename">闇�瑕佽繑鍥炵殑鍒�</param>
+ /// <param name="sortfilename">鎺掑簭瀛楁鍚�(榛樿鍗囧簭锛岄檷搴忛渶鍦ㄦ帓搴忓瓧娈靛悕鍚庨潰DESC鍏抽敭瀛楋細sortField Desc)</param>
+ /// <param name="PageSize">椤靛昂瀵�</param>
+ /// <param name="PageIndex">椤电爜</param>
+ /// <param name="strWhere">鏌ヨ鏉′欢 (娉ㄦ剰: 涓嶈鍔� where)</param>
+ /// <param name="RecordCount">鎬昏褰�</param>
+ /// <returns></returns>
+ public static DataTable GetDataByPage_V2(string tablename, string filename, string sortfilename, int PageSize, int PageIndex, string strWhere, out int RecordCount)
+ {
+ RecordCount = 0;
+ //鍒涘缓鍙傛暟
+ SqlParameter[] param = {
+ new SqlParameter("@tblName", SqlDbType.VarChar, 200),
+ new SqlParameter("@strGetFields", SqlDbType.VarChar, 500),
+ new SqlParameter("@fldName", SqlDbType.VarChar, 255),
+ new SqlParameter("@PageSize", SqlDbType.Int),
+ new SqlParameter("@PageIndex", SqlDbType.Int),
+ new SqlParameter("@strWhere", SqlDbType.VarChar,500),
+ new SqlParameter("@RecordCount", SqlDbType.Int),
+ new SqlParameter("@TotalPage", SqlDbType.Int)
+ };
+ param[0].Value = tablename;//琛ㄥ悕
+ param[1].Value = filename;//闇�瑕佽繑鍥炵殑鍒�
+ param[2].Value = sortfilename;//鎺掑簭瀛楁鍚�
+ param[3].Value = PageSize;//椤靛昂瀵�
+ param[4].Value = PageIndex;//椤电爜
+ param[5].Value = strWhere;//鏌ヨ鏉′欢
+ param[6].Direction = ParameterDirection.ReturnValue;//鎬昏褰�
+ param[7].Direction = ParameterDirection.Output;//鎬婚〉鏁�
+ DataOperator dbo = null;
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ DataTable dt = dbo.ExecuteProductData("GetDataByPage_V2", param);
+ RecordCount = (int)param[6].Value;
+ return dt;
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ if (null != dbo)
+ {
+ dbo.Close();
+ dbo = null;
+ }
+ }
+ }
+ /// <summary>
+ /// 鍒嗛〉鏌ヨ(鏀寔JOIN)
+ /// </summary>
+ /// <param name="filename">琛ㄥ悕</param>
+ /// <param name="filename">闇�瑕佽繑鍥炵殑鍒�</param>
+ /// <param name="sortfilename">鎺掑簭瀛楁鍚�(榛樿鍗囧簭锛岄檷搴忛渶鍦ㄦ帓搴忓瓧娈靛悕鍚庨潰DESC鍏抽敭瀛楋細sortField Desc)</param>
+ /// <param name="PageSize">椤靛昂瀵�</param>
+ /// <param name="PageIndex">椤电爜</param>
+ /// <param name="strWhere">鏌ヨ鏉′欢 (娉ㄦ剰: 涓嶈鍔� where)</param>
+ /// <param name="RecordCount">鎬昏褰�</param>
+ /// <returns></returns>
+ public static DataTable GetDataByPage_V2_Join(string tablename, string filename, string sortfilename, int PageSize, int PageIndex, string strWhere, out int RecordCount)
+ {
+ RecordCount = 0;
+ //鍒涘缓鍙傛暟
+ SqlParameter[] param = {
+ new SqlParameter("@tblName", SqlDbType.VarChar, 200),
+ new SqlParameter("@strGetFields", SqlDbType.VarChar, 500),
+ new SqlParameter("@fldName", SqlDbType.VarChar, 255),
+ new SqlParameter("@PageSize", SqlDbType.Int),
+ new SqlParameter("@PageIndex", SqlDbType.Int),
+ new SqlParameter("@strWhere", SqlDbType.VarChar,500),
+ new SqlParameter("@RecordCount", SqlDbType.Int),
+ new SqlParameter("@TotalPage", SqlDbType.Int)
+ };
+ param[0].Value = tablename;//琛ㄥ悕
+ param[1].Value = filename;//闇�瑕佽繑鍥炵殑鍒�
+ param[2].Value = sortfilename;//鎺掑簭瀛楁鍚�
+ param[3].Value = PageSize;//椤靛昂瀵�
+ param[4].Value = PageIndex;//椤电爜
+ param[5].Value = strWhere;//鏌ヨ鏉′欢
+ param[6].Direction = ParameterDirection.ReturnValue;//鎬昏褰�
+ param[7].Direction = ParameterDirection.Output;//鎬婚〉鏁�
+ DataOperator dbo = null;
+ try
+ {
+ if (dbo == null)
+ {
+ dbo = new DataOperator();
+ }
+ DataTable dt = dbo.ExecuteProductData("GetDataByPage_V2_Join", param);
+ RecordCount = (int)param[6].Value;
+ return dt;
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ if (null != dbo)
+ {
+ dbo.Close();
+ dbo = null;
+ }
+ }
+ }
+ #endregion
+
+ #region ParametersStrGet(SqlParameter[] parameters) [鐢ㄤ簬鏃ュ織鏂囨湰杈撳嚭] 灏哠qlParameter鏁扮粍鍙傛暟杞垚瀛楃涓�.
+ /// <summary>
+ /// [鐢ㄤ簬鏃ュ織鏂囨湰杈撳嚭] 灏哠qlParameter鏁扮粍鍙傛暟杞垚瀛楃涓�.
+ /// </summary>
+ /// <param name="parameters">鍙傛暟鏁扮粍</param>
+ /// <returns></returns>
+ private static string ParametersStrGet(SqlParameter[] parameters)
+ {
+ string parametersHeadStr = @"鍙傛暟:{{{0}}}";
+ string parametersContentStr = "";
+ int count = 0;
+ foreach (SqlParameter sp in parameters)
+ {
+ if (count++ > 0)
+ parametersContentStr += @",";
+ parametersContentStr += string.Format("{0}:{1}", sp.ParameterName, sp.Value);
+ }
+ return string.Format(parametersHeadStr, parametersContentStr);
+ }
+ #endregion
+
+ }
+}
diff --git a/VueWebCoreApi/Tools/DapperHelper.cs b/VueWebCoreApi/Tools/DapperHelper.cs
new file mode 100644
index 0000000..b4f6247
--- /dev/null
+++ b/VueWebCoreApi/Tools/DapperHelper.cs
@@ -0,0 +1,775 @@
+锘縰sing Dapper;
+using Microsoft.AspNetCore.Http;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using VueWebCoreApi.DLL.BLL;
+using VueWebCoreApi.Models;
+
+namespace VueWebCoreApi.Tools
+{
+ public class DapperHelper
+ {
+
+ /// <summary>
+ /// 鍒涘缓鏁版嵁搴撹繛鎺ュ璞qlserver
+ /// </summary>
+ /// <returns></returns>
+ public static IDbConnection sqlConnection()
+ {
+ //string sqlServerConnectString = "server=***;database=***;User=***;password=***;Connect Timeout=10000";
+ string sqlServerConnectString = AppSetting.GetAppSetting("DBServer");
+ //鑾峰彇鏁版嵁搴撹繛鎺�
+ IDbConnection connection = new SqlConnection(sqlServerConnectString);
+ connection.Open();
+ return connection;
+ }
+
+
+ /// <summary>
+ /// Dapper鏌ヨ杩斿洖List
+ /// </summary>
+ /// <typeparam name="T">闇�瑕佽繑鍥炵殑瀵硅薄绫诲瀷</typeparam>
+ /// <param name="sql">Sql璇彞</param>
+ /// <param name="parm"></param>
+ /// <returns></returns>
+ public static List<T> select<T>(string sql, Object parm) where T : new()
+ {
+
+ List<T> list = null;
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ //鐢ㄦ埛鎿嶄綔璁板綍鍐欏叆鏁版嵁琛�
+ //Log4net.LogUtil.SaveMessage("PC", "鎿嶄綔浜唜xxxx", "api/Login/LoginSave", ConfigurationManager.AppSettings["FileIP"], "9999", 1);
+ list = conn.Query<T>(sql, parm).ToList<T>();
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+
+ }
+ return list;
+ }
+
+
+ /// <summary>
+ /// Dapper鏌ヨ杩斿洖List瀛楀吀瀵硅薄 鏃犻渶鎵嬪姩Wapper瀵硅薄浜�
+ /// </summary>
+ /// <param name="sql"></param>
+ /// <param name="parm"></param>
+ /// <returns></returns>
+ public static List<Dictionary<string, Object>> selectToDict(string sql, Object parm)
+ {
+
+ List<Dictionary<string, Object>> result = null;
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ var menus = conn.Query(sql, parm).ToList();
+ result = JsonConvert.DeserializeObject<List<Dictionary<string, Object>>>(JsonConvert.SerializeObject(menus));
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// Dapper鏌ヨ杩斿洖瀵硅薄闈濴ist闆嗗悎
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="sql"></param>
+ /// <param name="parm"></param>
+ /// <returns></returns>
+ public static T selectToObject<T>(string sql, Object parm) where T : new()
+ {
+ T t = new T();
+ //sql璇彞
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ t = conn.Query<T>(sql, parm).Single<T>();
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ }
+ return t;
+ }
+
+ /// <summary>
+ /// dapper閫氱敤鍒嗛〉鍑芥暟
+ /// </summary>
+ /// <typeparam name="T">娉涘瀷闆嗗悎瀹炰綋绫�</typeparam>
+ /// <param name="sql">鏌ヨ璇彞</param>
+ /// <param name="orderBy">鎺掑簭锛堝瓧娈� DESC/ASC锛�</param>
+ /// <param name="pageIndex">褰撳墠椤�</param>
+ /// <param name="pageSize">褰撳墠椤垫樉绀烘潯鏁�</param>
+ /// <param name="total">缁撴灉闆嗘�绘暟</param>
+ /// <returns></returns>
+ public static IEnumerable<T> GetPageList<T>(string sql, Object parm, string orderBy, string sort, int pageIndex, int pageSize, out int total)
+ {
+ //int skip = 1;
+ //if (pageIndex > 0)
+ //{
+ // skip = (pageIndex - 1) * pageSize + 1;
+ //}
+ StringBuilder sb = new StringBuilder();
+ sb.AppendFormat("SELECT COUNT(1) FROM ({0}) AS Result;", sql);
+ sb.AppendFormat(@"SELECT *
+ FROM(SELECT *,ROW_NUMBER() OVER(ORDER BY {1} {2}) AS RowNum
+ FROM ({0}) AS Temp) AS Result
+ WHERE RowNum >= {3} AND RowNum <= {4}
+ ORDER BY {1} {2}", sql, orderBy, sort, pageIndex, pageSize); //skip, pageIndex * pageSize
+
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ using (var reader = conn.QueryMultiple(sb.ToString(), parm))
+ {
+ total = reader.ReadFirst<int>();
+ return reader.Read<T>();
+ }
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+
+ }
+ }
+
+ /// <summary>
+ /// dapper閫氱敤鍒嗛〉鍑芥暟
+ /// </summary>
+ /// <typeparam name="T">娉涘瀷闆嗗悎瀹炰綋绫�</typeparam>
+ ///<param name="withsql">with鍑芥暟璇彞</param>
+ /// <param name="sql">鏌ヨ璇彞</param>
+ /// <param name="orderBy">鎺掑簭锛堝瓧娈� DESC/ASC锛�</param>
+ /// <param name="pageIndex">褰撳墠椤�</param>
+ /// <param name="pageSize">褰撳墠椤垫樉绀烘潯鏁�</param>
+ /// <param name="total">缁撴灉闆嗘�绘暟</param>
+ /// <returns></returns>
+ public static IEnumerable<T> GetPagedDataWith<T>(string withsql, string sql, Object parm, string orderBy, string sort, int pageIndex, int pageSize, out int total)
+ {
+ //int skip = 1;
+ //if (pageIndex > 0)
+ //{
+ // skip = (pageIndex - 1) * pageSize + 1;
+ //}
+ StringBuilder sb = new StringBuilder();
+ sb.AppendFormat("{0} SELECT COUNT(1) FROM ({1}) AS Result;",withsql, sql);
+ sb.AppendFormat(@"{0} SELECT *
+ FROM(SELECT *,ROW_NUMBER() OVER(ORDER BY {2} {3}) AS RowNum
+ FROM ({1}) AS Temp) AS Result
+ WHERE RowNum >= {4} AND RowNum <= {5}
+ ORDER BY {2} {3}",withsql, sql, orderBy, sort, pageIndex, pageSize); //skip, pageIndex * pageSize
+
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ using (var reader = conn.QueryMultiple(sb.ToString(), parm))
+ {
+ total = reader.ReadFirst<int>();
+ return reader.Read<T>();
+ }
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+
+ }
+ }
+
+
+ /// <summary>
+ /// WITH鍒嗛〉
+ /// </summary>
+ /// <typeparam name="T">娉涘瀷闆嗗悎瀹炰綋绫�</typeparam>
+ /// <param name="tableName">琛ㄥ悕</param>
+ /// <param name="torg_code">瀛愮骇瀛楁</param>
+ /// <param name="parent_id">鐖剁骇瀛楁</param>
+ /// <param name="condition">鏌ヨ鏉′欢</param>
+ /// <param name="parm">鏌ヨ鍙傛暟</param>
+ /// <param name="prop">鎺掑簭瀛楁</param>
+ /// <param name="order">鎺掑簭瑙勫垯</param>
+ /// <param name="pageSize">椤电爜</param>
+ /// <param name="pageNumber">姣忛〉鏄剧ず鏉℃暟</param>
+ /// <returns></returns>
+
+ public static IEnumerable<T> GetPagedData<T>(string tableName, string torg_code, string parent_id, string condition, Object parm, string prop, string order, int pageSize, int pageNumber, out int total)
+ {
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ // 鏌ヨ鎬昏褰曟暟
+ string countQuery = $@"WITH CTE AS (
+ SELECT *
+ FROM {tableName}
+ WHERE {condition}
+ UNION ALL
+ select o.*
+ from {tableName} o
+ JOIN CTE c ON o.{torg_code} = c.{parent_id}
+ )
+ SELECT DISTINCT * FROM CTE";
+ int totalRecords = conn.ExecuteScalar<int>(countQuery, parm);
+
+ // 璁$畻鎬婚〉鏁�
+ int totalPages = (int)Math.Ceiling((double)totalRecords / pageSize);
+
+ // 璁$畻鍒嗛〉鐨勮捣濮嬭鍙�
+ int startRow = (pageNumber - 1) * pageSize + 1;
+ // 璁$畻鍒嗛〉鐨勭粨鏉熻鍙�
+ int endRow = pageNumber * pageSize;
+
+ // 鍒嗛〉鏌ヨ
+ string query = $@"WITH CTE AS (
+ SELECT *
+ FROM {tableName}
+ WHERE {condition}
+ UNION ALL
+ select o.*
+ from {tableName} o
+ JOIN CTE c ON o.{torg_code} = c.{parent_id}
+ )
+ SELECT * FROM(
+ SELECT ROW_NUMBER() OVER (ORDER BY {prop} {order}) AS RowNum,*
+ FROM (
+ SELECT DISTINCT *
+ from CTE
+ ) AS subquery) AS AA WHERE RowNum >= {startRow} AND RowNum <={endRow}";
+ total = totalRecords;
+ return conn.Query<T>(query, parm);
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Dapper鏌ヨ杩斿洖datatable鏁版嵁(甯﹀弬鏁�)
+ /// </summary>
+ /// <param name="sql"></param>
+ /// <param name="parm"></param>
+ /// <returns></returns>
+ public static DataTable selectdata(string sql, Object parm)
+ {
+ //sql璇彞
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ DataTable table = new DataTable();
+ var data = conn.ExecuteReader(sql, parm);
+ table.Load(data);
+ return table;
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Dapper鏌ヨ杩斿洖datatable鏁版嵁(甯﹀弬鏁�)
+ /// </summary>
+ /// <param name="sql"></param>
+ /// <param name="parm"></param>
+ /// <returns></returns>
+ public static DataTable selectlist(string sql, Object parm)
+ {
+ //sql璇彞
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ DataTable table = new DataTable();
+ var data = conn.ExecuteReader(sql, parm);
+ table.Load(data);
+ return table;
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Dapper鏌ヨ杩斿洖datatable鏁版嵁(涓嶅甫鍙傛暟)
+ /// </summary>
+ /// <param name="sql"></param>
+ /// <returns></returns>
+ public static DataTable selecttable(string sql)
+ {
+ //sql璇彞
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ DataTable table = new DataTable();
+ var data = conn.ExecuteReader(sql);
+ table.Load(data);
+ return table;
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ //LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Dapper鎵ц瀛樺偍杩囩▼杩斿洖datatable鏁版嵁(甯﹀弬鏁�)
+ /// </summary>
+ /// <param name="sql">瀛樺偍杩囩▼鍚�</param>
+ /// <param name="parm">鍙傛暟</param>
+ /// <returns></returns>
+ public static DataTable selectProcedure(string sql, Object parm)
+ {
+ //sql璇彞
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ DataTable table = new DataTable();
+ //var data = conn.ExecuteReader(sql, parm);
+ var res = conn.ExecuteReader(sql, parm, commandType: CommandType.StoredProcedure);//sql 瀛樺偍杩囩▼
+ table.Load(res);
+ return table;
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// Dapper鎵ц瀛樺偍杩囩▼杩斿洖datatable鏁版嵁(甯﹀弬鏁�)
+ /// </summary>
+ /// <param name="sql">瀛樺偍杩囩▼鍚�</param>
+ /// <param name="parm">鍙傛暟</param>
+ /// <returns></returns>
+ public static bool IsProcedure(string sql, Object parm)
+ {
+ bool result;
+ //sql璇彞
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ DataTable table = new DataTable();
+ //var data = conn.ExecuteReader(sql, parm);
+ var res = conn.ExecuteReader(sql, parm, commandType: CommandType.StoredProcedure);//sql 瀛樺偍杩囩▼
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ result = false;
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Dapper鎵ц瀛樺偍杩囩▼杩斿洖datatable鏁版嵁(涓嶅甫鍙傛暟)
+ /// </summary>
+ /// <param name="sql">瀛樺偍杩囩▼鍚�</param>
+ /// <returns></returns>
+ public static bool IsProcedureNo(string sql)
+ {
+ bool result;
+ //sql璇彞
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ DataTable table = new DataTable();
+ //var data = conn.ExecuteReader(sql, parm);
+ var res = conn.ExecuteReader(sql);//sql 瀛樺偍杩囩▼
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ result = false;
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Dapper鏌ヨ杩斿洖鏁版嵁鏉℃暟
+ /// </summary>
+ /// <param name="sql"></param>
+ /// <param name="parm"></param>
+ /// <returns></returns>
+ public static int selectcount(string sql, Object parm)
+ {
+ //sql璇彞
+ int result = 0;
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ result = conn.Query(sql, parm).Count();
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Dapper澧炲垹鏀�
+ /// </summary>
+ /// <param name="sql"></param>
+ /// <param name="parametere"></param>
+ /// <returns></returns>
+ public static int SQL(string sql, Object parametere)
+ {
+ //sql璇彞
+ int result = 0;
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ result = conn.Execute(sql, parametere);
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// 澧炲姞锛屽垹闄わ紝淇敼浣跨敤鐨� 浜嬪姟鏂规硶 Sqllist涓轰緷娆℃墽琛�
+ /// </summary>
+ /// <param name="sqlList"></param>
+ /// <returns></returns>
+ public static bool DoTransaction(List<object> sqlList)
+ {
+ bool result;
+ IDbTransaction tranction = null;
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ tranction = conn.BeginTransaction();
+ for (int i = 0; i < sqlList.Count; i++)
+ {
+ conn.Execute(sqlList[i].GetType().GetProperty("str").GetValue(sqlList[i], null).ToString(), sqlList[i].GetType().GetProperty("parm").GetValue(sqlList[i], null), tranction);
+ }
+ tranction.Commit();
+
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ result = false;
+ tranction.Rollback();
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// 澧炲姞锛屽垹闄わ紝淇敼浣跨敤鐨� 浜嬪姟鏂规硶 Sqllist涓轰緷娆℃墽琛�
+ /// </summary>
+ /// <param name="sqlList"></param>
+ /// <returns></returns>
+ public static int DoTransactionCont(List<object> sqlList)
+ {
+ int result = 0;
+ IDbTransaction tranction = null;
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ tranction = conn.BeginTransaction();
+ for (int i = 0; i < sqlList.Count; i++)
+ {
+ result += conn.Execute(sqlList[i].GetType().GetProperty("str").GetValue(sqlList[i], null).ToString(), sqlList[i].GetType().GetProperty("parm").GetValue(sqlList[i], null), tranction);
+ }
+ tranction.Commit();
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ tranction.Rollback();
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Dapper鎻掑叆 杩斿洖鑷涓婚敭Id锛堝浠斤級
+ /// </summary>
+ /// <param name="sql"></param>
+ /// <param name="parameter"></param>
+ /// <param name="tableName">寰呮彃鍏ユ暟鎹殑琛ㄥ悕</param>
+ /// <returns></returns>
+ public static int insertReturnId0(string sql, Object parameter, String tableName)
+ {
+
+ int result = 0;
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ result = conn.Execute(sql, parameter);
+ if (result != 0)
+ {
+ result = conn.Query<int>("select ident_current(@table)", new { table = tableName }).Single<int>();
+ }
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ }
+ return result;
+ }
+
+
+ /// <summary>
+ /// Dapper 杩斿洖鑷涓婚敭褰撳墠鏁版嵁琛ㄦ渶澶d
+ /// </summary>
+ /// <param name="tableName">寰呮彃鍏ユ暟鎹殑琛ㄥ悕</param>
+ /// <returns></returns>
+ public static int insertReturnId(String tableName)
+ {
+
+ int result = 0;
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ if (result == 0)
+ {
+ result = conn.Query<int>("select ident_current(@table)", new { table = tableName }).Single<int>();
+ }
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ }
+ return result;
+ }
+ /// <summary>
+ /// 鎵цsql鎵ц璇彞,杩斿洖瀛楃涓�
+ /// </summary>
+ /// <param name="sql"></param>
+ /// <returns></returns>
+ public static string sqlstr(String sql)
+ {
+
+ string result = "";
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ if (result == "")
+ {
+ result = conn.Query<string>(sql).First();
+ }
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ }
+ return result;
+ }
+
+ public static DataTable lissql(string sql)
+ {
+ //sql璇彞
+ using (IDbConnection conn = sqlConnection())
+ {
+ try
+ {
+ DataTable table = new DataTable();
+ //var data = conn.ExecuteReader(sql, parm);
+ var res = conn.ExecuteReader(sql);//sql 瀛樺偍杩囩▼
+ table.Load(res);
+ return table;
+ }
+ catch (Exception ex)
+ {
+ //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+ LogHelper.WriteLog(ex);
+ throw ex;
+ }
+ finally
+ {
+ conn.Dispose();
+ conn.Close();
+ }
+ }
+ }
+ }
+}
diff --git a/VueWebCoreApi/Tools/DataOperator.cs b/VueWebCoreApi/Tools/DataOperator.cs
new file mode 100644
index 0000000..3544805
--- /dev/null
+++ b/VueWebCoreApi/Tools/DataOperator.cs
@@ -0,0 +1,1374 @@
+锘縰sing System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class DataOperator
+ {
+ private static string connectionString = string.Empty;
+
+ private static string connectionName = string.Empty;
+
+ private static string key = "fengyi";
+
+ private static string iv = "fengyibi";
+
+ private SqlConnection _conn = null;
+
+ private static string uid;
+
+ public static string password;
+
+ private SqlCommand _cmd = null;
+
+ private SqlDataAdapter _adp = null;
+
+ public static string ConnectionName
+ {
+ get
+ {
+ return DataOperator.connectionName;
+ }
+ }
+
+ public static string Key
+ {
+ get
+ {
+ return DataOperator.key;
+ }
+ set
+ {
+ DataOperator.key = value;
+ }
+ }
+
+ public static string IV
+ {
+ get
+ {
+ return DataOperator.iv;
+ }
+ set
+ {
+ DataOperator.iv = value;
+ }
+ }
+
+ public SqlConnection Connection
+ {
+ get
+ {
+ return this._conn;
+ }
+ }
+
+ public string UId
+ {
+ get
+ {
+ return DataOperator.uid;
+ }
+ }
+
+ public string Password
+ {
+ get
+ {
+ return DataOperator.password;
+ }
+ }
+
+ public DataOperator()
+ {
+ if (DataOperator.connectionString == "")
+ {
+ throw new ArgumentNullException("ConnectionString");
+ }
+ }
+
+ public DataOperator(string server, string puid, string pwd, string dbname)
+ {
+ try
+ {
+ if (server == null || server.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("Type:string pramName:server", "鏁版嵁搴撴湇鍔″櫒涓虹┖锛�");
+ }
+ if (DataOperator.uid == null || DataOperator.uid.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("Type:string pramName:uid", "鏁版嵁搴撶敤鎴峰悕涓虹┖锛�");
+ }
+ if (dbname == null || dbname.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("Type:string pramName:dbname", "鏁版嵁搴撳悕涓虹┖锛�");
+ }
+ DataOperator.uid = puid;
+ DataOperator.password = pwd;
+ string text = string.Format("server={0};uid={1};pwd={2};database={3};", new object[]
+ {
+ server,
+ DataOperator.uid,
+ pwd,
+ dbname
+ });
+ this._conn = new SqlConnection(text);
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ public bool getTable(string sqlstr, ref DataTable rdt)
+ {
+ bool result;
+ try
+ {
+ if (null == rdt)
+ {
+ rdt = new DataTable();
+ }
+ else
+ {
+ rdt.Clear();
+ }
+ if (null == this._conn)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ this._adp = new SqlDataAdapter(sqlstr, this._conn);
+ this._adp.Fill(rdt);
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._adp)
+ {
+ this._adp.Dispose();
+ this._adp = null;
+ }
+ }
+ return result;
+ }
+
+ public DataTable getTable(string sqlstr)
+ {
+ DataTable result;
+ try
+ {
+ DataTable dataTable = new DataTable();
+ if (null == this._conn)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ this._adp = new SqlDataAdapter(sqlstr, this._conn);
+ this._adp.Fill(dataTable);
+ result = dataTable;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._adp)
+ {
+ this._adp.Dispose();
+ this._adp = null;
+ }
+ }
+ return result;
+ }
+
+ public DataTable GetTable(string sqlstr)
+ {
+ DataTable result;
+ try
+ {
+ DataTable dataTable = new DataTable();
+ if (null == this._conn)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ this._adp = new SqlDataAdapter(sqlstr, this._conn);
+ this._adp.Fill(dataTable);
+ result = dataTable;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._adp)
+ {
+ this._adp.Dispose();
+ this._adp = null;
+ }
+ }
+ return result;
+ }
+
+ public bool getTable(string sqlstr, SqlParameter[] param, ref DataTable rdt)
+ {
+ bool result;
+ try
+ {
+ if (null == rdt)
+ {
+ rdt = new DataTable();
+ }
+ else
+ {
+ rdt.Clear();
+ }
+ if (null == this._conn)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ this._adp = new SqlDataAdapter(sqlstr, this._conn);
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._adp.SelectCommand.Parameters.Add((SqlParameter)((ICloneable)param[i]).Clone());
+ }
+ this._adp.Fill(rdt);
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._adp)
+ {
+ this._adp.Dispose();
+ this._adp = null;
+ }
+ }
+ return result;
+ }
+
+ public DataTable GetTable(string sqlstr, SqlParameter[] param)
+ {
+ DataTable result;
+ try
+ {
+ DataTable dataTable = new DataTable();
+ if (null == this._conn)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ this._adp = new SqlDataAdapter(sqlstr, this._conn);
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._adp.SelectCommand.Parameters.Add((SqlParameter)((ICloneable)param[i]).Clone());
+ }
+ this._adp.Fill(dataTable);
+ result = dataTable;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._adp)
+ {
+ this._adp.Dispose();
+ this._adp = null;
+ }
+ }
+ return result;
+ }
+
+ public DataTable getTable(string sqlstr, SqlParameter[] param)
+ {
+ DataTable result;
+ try
+ {
+ DataTable dataTable = new DataTable();
+ if (null == this._conn)
+ {
+
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ this._adp = new SqlDataAdapter(sqlstr, this._conn);
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._adp.SelectCommand.Parameters.Add((SqlParameter)((ICloneable)param[i]).Clone());
+ }
+ this._adp.Fill(dataTable);
+ result = dataTable;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._adp)
+ {
+ this._adp.Dispose();
+ this._adp = null;
+ }
+ }
+
+ return result;
+ }
+
+ public DataSet getdate(string sqlstr, SqlParameter[] param)
+ {
+ DataSet result;
+ try
+ {
+ DataSet dset = new DataSet();
+ if (null == this._conn)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ this._adp = new SqlDataAdapter(sqlstr, this._conn);
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._adp.SelectCommand.Parameters.Add((SqlParameter)((ICloneable)param[i]).Clone());
+ }
+ this._adp.Fill(dset);
+ result = dset;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._adp)
+ {
+ this._adp.Dispose();
+ this._adp = null;
+ }
+ }
+ return result;
+ }
+
+ public object getObject(string sqlstr)
+ {
+ object result;
+ try
+ {
+ if (sqlstr == null || sqlstr.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("sqlstr", "SQL璇彞涓嶈兘涓虹┖锛�");
+ }
+ if (null == this._conn)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ this._cmd = new SqlCommand(sqlstr, this._conn);
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ result = this._cmd.ExecuteScalar();
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._cmd)
+ {
+ this._cmd.Dispose();
+ this._cmd = null;
+ }
+ }
+ return result;
+ }
+
+ public object getObject(string sqlstr, SqlParameter[] param)
+ {
+ object result;
+ try
+ {
+ if (sqlstr == null || sqlstr.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("sqlstr", "SQL璇彞涓嶈兘涓虹┖锛�");
+ }
+ if (null == this._conn)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ this._cmd = new SqlCommand(sqlstr, this._conn);
+ this._cmd.Parameters.Clear();
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._cmd.Parameters.Add((SqlParameter)((ICloneable)param[i]).Clone());
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ result = this._cmd.ExecuteScalar();
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._cmd)
+ {
+ this._cmd.Dispose();
+ this._cmd = null;
+ }
+ }
+ return result;
+ }
+
+ public int getCount(string sqlstr)
+ {
+ int result;
+ try
+ {
+ if (sqlstr == null || sqlstr.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("sqlstr", "SQL璇彞涓嶈兘涓虹┖锛�");
+ }
+ if (null == this._conn)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ this._cmd = new SqlCommand(sqlstr, this._conn);
+ object obj = this._cmd.ExecuteScalar();
+ if (null == obj)
+ {
+ throw new ArgumentNullException("_cmd.ExecuteScalar()", "缁撴灉杩斿洖绌猴紒");
+ }
+ result = Convert.ToInt32(obj);
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._cmd)
+ {
+ this._cmd.Dispose();
+ this._cmd = null;
+ }
+ }
+ return result;
+ }
+
+ public int getCount(string sqlstr, SqlParameter[] param)
+ {
+ int result;
+ try
+ {
+ if (sqlstr == null || sqlstr.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("sqlstr", "SQL璇彞涓嶈兘涓虹┖锛�");
+ }
+ if (null == this._conn)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ this._cmd = new SqlCommand(sqlstr, this._conn);
+ this._cmd.Parameters.Clear();
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._cmd.Parameters.Add((SqlParameter)((ICloneable)param[i]).Clone());
+ }
+ object obj = this._cmd.ExecuteScalar();
+ if (null == obj)
+ {
+ throw new ArgumentNullException("_cmd.ExecuteScalar()", "缁撴灉杩斿洖绌猴紒");
+ }
+ result = Convert.ToInt32(obj);
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._cmd)
+ {
+ this._cmd.Dispose();
+ this._cmd = null;
+ }
+ }
+ return result;
+ }
+
+ public bool executeSql(string sqlstr)
+ {
+ bool result;
+ try
+ {
+ if (sqlstr == null || sqlstr.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("sqlstr", "SQL璇彞涓虹┖锛�");
+ }
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ this._cmd = new SqlCommand(sqlstr, this._conn);
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ this._cmd.ExecuteNonQuery();
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (this._cmd != null)
+ {
+ this._cmd.Dispose();
+ this._cmd = null;
+ }
+ }
+ return result;
+ }
+
+ public bool executeSql(string sqlstr, SqlParameter[] param)
+ {
+ bool result;
+ try
+ {
+ if (sqlstr == null || sqlstr.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("sqlstr", "SQL璇彞涓虹┖锛�");
+ }
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ this._cmd = new SqlCommand(sqlstr, this._conn);
+ this._cmd.Parameters.Clear();
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._cmd.Parameters.Add((SqlParameter)((ICloneable)param[i]).Clone());
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ this._cmd.ExecuteNonQuery();
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (this._cmd != null)
+ {
+ this._cmd.Dispose();
+ this._cmd = null;
+ }
+ }
+ return result;
+ }
+
+ public bool executeSql(List<string> list)
+ {
+ string[] array = new string[list.Count];
+ for (int i = 0; i < list.Count; i++)
+ {
+ array[i] = list[i];
+ }
+ return this.executeSql(array);
+ }
+
+ public bool executeSql(string[] list)
+ {
+ SqlTransaction sqlTransaction = null;
+ bool result;
+ try
+ {
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ sqlTransaction = this._conn.BeginTransaction();
+ for (int i = 0; i < list.Length; i++)
+ {
+ string text = list[i];
+ if (text == null || text.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("sqlstr", "SQL璇彞涓虹┖锛�");
+ }
+ this._cmd = new SqlCommand(text, this._conn);
+ this._cmd.Transaction = sqlTransaction;
+ this._cmd.ExecuteNonQuery();
+ }
+ sqlTransaction.Commit();
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ if (null != sqlTransaction)
+ {
+ sqlTransaction.Rollback();
+ }
+ throw ex;
+ }
+ finally
+ {
+ if (this._cmd != null)
+ {
+ this._cmd.Dispose();
+ this._cmd = null;
+ }
+ if (null != sqlTransaction)
+ {
+ sqlTransaction.Dispose();
+ sqlTransaction = null;
+ }
+ }
+ return result;
+ }
+
+ //public bool executeSql(SQLExecEntity entity)
+ //{
+ // return this.executeSql(new List<SQLExecEntity>
+ // {
+ // entity
+ // });
+ //}
+
+ //public bool executeSql(List<SQLExecEntity> list)
+ //{
+ // SqlTransaction sqlTransaction = null;
+ // bool result;
+ // try
+ // {
+ // if (this._conn == null)
+ // {
+ // this._conn = new SqlConnection(DataOperator.connectionString);
+ // }
+ // if (ConnectionState.Closed == this._conn.State)
+ // {
+ // this._conn.Open();
+ // }
+ // sqlTransaction = this._conn.BeginTransaction();
+ // foreach (SQLExecEntity current in list)
+ // {
+ // this._cmd = new SqlCommand(current.SqlStr, this._conn);
+ // SqlParameter[] @params = new ParamCollections(current.Param).GetParams();
+ // SqlParameter[] array = @params;
+ // for (int i = 0; i < array.Length; i++)
+ // {
+ // SqlParameter value = array[i];
+ // this._cmd.Parameters.Add(value);
+ // }
+ // this._cmd.Transaction = sqlTransaction;
+ // this._cmd.ExecuteNonQuery();
+ // }
+ // sqlTransaction.Commit();
+ // result = true;
+ // }
+ // catch (Exception ex)
+ // {
+ // if (null != sqlTransaction)
+ // {
+ // sqlTransaction.Rollback();
+ // }
+ // throw ex;
+ // }
+ // finally
+ // {
+ // if (this._cmd != null)
+ // {
+ // this._cmd.Dispose();
+ // this._cmd = null;
+ // }
+ // if (null != sqlTransaction)
+ // {
+ // sqlTransaction = null;
+ // }
+ // }
+ // return result;
+ //}
+
+ public bool executeProduct(string sqlstr, ref ArrayList outAl)
+ {
+ DataTable dataTable = new DataTable();
+ bool result;
+ try
+ {
+ if (sqlstr == null || sqlstr.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("sqlstr", "SQL涓嶈兘涓虹┖锛�");
+ }
+ if (null != outAl)
+ {
+ outAl.Clear();
+ }
+ else
+ {
+ outAl = new ArrayList();
+ }
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ this._adp = new SqlDataAdapter(sqlstr, this._conn);
+ this._adp.Fill(dataTable);
+ if (null != dataTable)
+ {
+ for (int i = 0; i < dataTable.Columns.Count; i++)
+ {
+ if (null != dataTable.Rows[0][i])
+ {
+ outAl.Add(dataTable.Rows[0][i]);
+ }
+ }
+ }
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._adp)
+ {
+ this._adp.Dispose();
+ this._adp = null;
+ }
+ if (null != dataTable)
+ {
+ dataTable.Clear();
+ dataTable.Dispose();
+ dataTable = null;
+ }
+ }
+ return result;
+ }
+
+ public ArrayList executeProduct(string produreName, SqlParameter[] param, bool returnDt)
+ {
+ DataTable dataTable = new DataTable();
+ ArrayList result;
+ try
+ {
+ ArrayList arrayList = new ArrayList();
+ if (produreName == null || produreName.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("produreName", "杩囩▼鍚嶄笉鑳戒负绌猴紒");
+ }
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ this._cmd = new SqlCommand();
+ this._cmd.Connection = this._conn;
+ this._cmd.CommandType = CommandType.StoredProcedure;
+ this._cmd.CommandText = produreName;
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._cmd.Parameters.Add(param[i]);
+ }
+ if (returnDt)
+ {
+ SqlDataReader sqlDataReader = this._cmd.ExecuteReader();
+ for (int i = 0; i < sqlDataReader.FieldCount; i++)
+ {
+ dataTable.Columns.Add(sqlDataReader.GetName(i), sqlDataReader.GetFieldType(i));
+ }
+ while (sqlDataReader.Read())
+ {
+ DataRow dataRow = dataTable.NewRow();
+ dataRow.BeginEdit();
+ for (int i = 0; i < sqlDataReader.FieldCount; i++)
+ {
+ dataRow[i] = sqlDataReader.GetValue(i);
+ }
+ dataRow.EndEdit();
+ dataTable.Rows.Add(dataRow);
+ }
+ sqlDataReader.Close();
+ arrayList.Add(dataTable);
+ }
+ else
+ {
+ object value = this._cmd.ExecuteScalar();
+ arrayList.Add(value);
+ }
+ result = arrayList;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ return result;
+ }
+
+ public DataTable ExecuteProductData(string produreName, SqlParameter[] param)
+ {
+ DataTable result;
+ try
+ {
+ if (produreName == null || produreName.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("produreName", "杩囩▼鍚嶄笉鑳戒负绌猴紒");
+ }
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ this._cmd = new SqlCommand();
+ this._cmd.Connection = this._conn;
+ this._cmd.CommandType = CommandType.StoredProcedure;
+ this._cmd.CommandText = produreName;
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._cmd.Parameters.Add(param[i]);
+ }
+ DataTable dataTable = new DataTable();
+ this._adp = new SqlDataAdapter(this._cmd);
+ this._adp.Fill(dataTable);
+ result = dataTable;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._adp)
+ {
+ this._adp.Dispose();
+ this._adp = null;
+ }
+ }
+ return result;
+ }
+
+ public List<DataTable> ExecuteProductDataList(string produreName, SqlParameter[] param)
+ {
+ List<DataTable> result = new List<DataTable>();
+ try
+ {
+ if (produreName == null || produreName.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("produreName", "杩囩▼鍚嶄笉鑳戒负绌猴紒");
+ }
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ this._cmd = new SqlCommand();
+ this._cmd.Connection = this._conn;
+ this._cmd.CommandType = CommandType.StoredProcedure;
+ this._cmd.CommandText = produreName;
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._cmd.Parameters.Add(param[i]);
+ }
+ DataSet ds = new DataSet();
+ this._adp = new SqlDataAdapter(this._cmd);
+ this._adp.Fill(ds);
+ for (int i = 0; i < ds.Tables.Count; i++)
+ {
+ result.Add(ds.Tables[i]);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._adp)
+ {
+ this._adp.Dispose();
+ this._adp = null;
+ }
+ }
+ return result;
+ }
+
+ public DataSet ExecuteProductDataSet(string produreName, SqlParameter[] param)
+ {
+ DataSet result;
+ try
+ {
+ if (produreName == null || produreName.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("produreName", "杩囩▼鍚嶄笉鑳戒负绌猴紒");
+ }
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ this._cmd = new SqlCommand();
+ this._cmd.Connection = this._conn;
+ this._cmd.CommandType = CommandType.StoredProcedure;
+ this._cmd.CommandText = produreName;
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._cmd.Parameters.Add(param[i]);
+ }
+ DataSet dataSet = new DataSet();
+ this._adp = new SqlDataAdapter(this._cmd);
+ this._adp.Fill(dataSet);
+ result = dataSet;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._adp)
+ {
+ this._adp.Dispose();
+ this._adp = null;
+ }
+ }
+ return result;
+ }
+
+ public bool BatchUpdate(DataTable dt, string sqlStr, SqlParameter[] param)
+ {
+ return this.BatchUpdate(dt, sqlStr, param, 100, false);
+ }
+
+ public bool BatchUpdate(DataTable dt, string sqlStr, SqlParameter[] param, int batchSize, bool updateAllRows)
+ {
+ bool result;
+ try
+ {
+ if (updateAllRows)
+ {
+ dt.AcceptChanges();
+ foreach (DataRow dataRow in dt.Rows)
+ {
+ dataRow.SetModified();
+ }
+ }
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ this._adp = new SqlDataAdapter();
+ this._adp.UpdateCommand = new SqlCommand(sqlStr, this._conn);
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._adp.UpdateCommand.Parameters.Add(param[i]);
+ }
+ this._adp.UpdateCommand.UpdatedRowSource = UpdateRowSource.None;
+ this._adp.UpdateBatchSize = batchSize;
+ this._adp.Update(dt);
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != this._adp)
+ {
+ this._adp.Dispose();
+ this._adp = null;
+ }
+ if (null != this._conn)
+ {
+ this._conn.Close();
+ this._conn = null;
+ }
+ }
+ return result;
+ }
+ public Hashtable executeProduct(string produreName, SqlParameter[] param)
+ {
+ Hashtable result;
+ try
+ {
+ Hashtable hashtable = new Hashtable();
+ if (produreName == null || produreName.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("produreName", "杩囩▼鍚嶄笉鑳戒负绌猴紒");
+ }
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ this._cmd = new SqlCommand();
+ this._cmd.Connection = this._conn;
+ this._cmd.CommandType = CommandType.StoredProcedure;
+ this._cmd.CommandText = produreName;
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._cmd.Parameters.Add((SqlParameter)((ICloneable)param[i]).Clone());
+ }
+ this._cmd.ExecuteNonQuery();
+ for (int i = 0; i < this._cmd.Parameters.Count; i++)
+ {
+ if (this._cmd.Parameters[i].Direction == ParameterDirection.Output || this._cmd.Parameters[i].Direction == ParameterDirection.InputOutput)
+ {
+ hashtable.Add(this._cmd.Parameters[i].SourceColumn, this._cmd.Parameters[i].Value);
+ }
+ }
+ result = hashtable;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ return result;
+ }
+
+ public bool ExecuteProduct(string produreName, SqlParameter[] param)
+ {
+ bool result;
+ try
+ {
+ if (produreName == null || produreName.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("produreName", "杩囩▼鍚嶄笉鑳戒负绌猴紒");
+ }
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ this._cmd = new SqlCommand();
+ this._cmd.Connection = this._conn;
+ this._cmd.CommandType = CommandType.StoredProcedure;
+ this._cmd.CommandText = produreName;
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._cmd.Parameters.Add(param[i]);
+ }
+ this._cmd.ExecuteNonQuery();
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ return result;
+ }
+
+ public string ExecuteDBProduct(string produreName, SqlParameter[] param)
+ {
+ string result;
+ try
+ {
+ if (produreName == null || produreName.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("produreName", "杩囩▼鍚嶄笉鑳戒负绌猴紒");
+ }
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ this._cmd = new SqlCommand();
+ this._cmd.Connection = this._conn;
+ this._cmd.CommandType = CommandType.StoredProcedure;
+ this._cmd.CommandText = produreName;
+ for (int i = 0; i < param.Length; i++)
+ {
+ this._cmd.Parameters.Add(param[i]);
+ }
+ this._cmd.ExecuteNonQuery();
+ result = (string)this._cmd.Parameters["@ResultValues"].Value;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ return result;
+ }
+
+ public static void SetConnectionName(string serverName)
+ {
+ DataOperator.SetConnectionName(serverName, DataOperator.key, DataOperator.iv);
+ }
+
+ public static void SetConnectionString(string conStr, string key, string iv)
+ {
+ if (conStr.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("conStr");
+ }
+ DataOperator.connectionString = Encrypt.DecryptStr(conStr, key, iv);
+ }
+
+ public static void SetConnectionString1(string conStr)
+ {
+ if (conStr.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("conStr");
+ }
+ DataOperator.connectionString = conStr;
+ }
+
+ public static void SetConnectionName(string serverName, string key, string iv)
+ {
+ if (serverName.Trim().Length == 0)
+ {
+ throw new ArgumentNullException("serverName");
+ }
+ DataOperator.connectionName = serverName.Trim();
+ DataOperator.connectionString = DataOperator.GetConnectionObjString(DataOperator.connectionName, "connectionString", key, iv);
+ DataOperator.uid = DataOperator.GetConnectionObjString(DataOperator.connectionName, "Uid", key, iv);
+ DataOperator.password = DataOperator.GetConnectionObjString(DataOperator.connectionName, "Password", key, iv);
+ }
+
+ private static string GetConnectionObjString(string serverName, string itemName)
+ {
+ return DataOperator.GetConnectionObjString(serverName, itemName, DataOperator.key, DataOperator.iv);
+ }
+
+ private static string GetConnectionObjString(string serverName, string itemName, string key, string iv)
+ {
+ return Encrypt.DecryptStr(Regedit.GetValue(serverName, itemName, false), key, iv);
+ }
+
+ public bool TestDboState()
+ {
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ bool result;
+ try
+ {
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ return result;
+ }
+
+ public string checkSql(string sqlstr)
+ {
+ sqlstr = sqlstr.Replace("--", "__").Replace("'", "鈥�").Replace(";", "锛�").Trim();
+ return sqlstr;
+ }
+
+ public void Close()
+ {
+ if (null != this._conn)
+ {
+ try
+ {
+ if (ConnectionState.Open == this._conn.State)
+ {
+ this._conn.Close();
+ }
+ }
+ catch (Exception)
+ {
+ }
+ finally
+ {
+ this._conn = null;
+ }
+ }
+ if (null != this._adp)
+ {
+ this._adp.Dispose();
+ }
+ this._adp = null;
+ if (null != this._cmd)
+ {
+ this._cmd.Dispose();
+ }
+ }
+
+ public void Dispose()
+ {
+ this.Close();
+ }
+
+ /// <summary>
+ /// 鎵ц澶氭潯SQL璇彞锛屽疄鐜版暟鎹簱浜嬪姟銆�
+ /// </summary>
+ /// <param name="sql">澶氭潯SQL璇彞</param>
+ /// <returns>褰卞搷鐨勮褰曟暟</returns>
+ public int ExecuteSqlTran(List<string> list, params SqlParameter[] param)
+ {
+ if (list == null || list.Count == 0)
+ {
+ throw new ArgumentNullException("sqlstr", "SQL璇彞涓虹┖锛�");
+ }
+ if (this._conn == null)
+ {
+ this._conn = new SqlConnection(DataOperator.connectionString);
+ }
+ for (int i = 0; i < list.Count; i++)
+ {
+ this._cmd = new SqlCommand(list[i], this._conn);
+ this._cmd.Parameters.Clear();
+ }
+ for (int j = 0; j < param.Length; j++)
+ {
+ this._cmd.Parameters.Add((SqlParameter)((ICloneable)param[j]).Clone());
+ }
+ if (ConnectionState.Closed == this._conn.State)
+ {
+ this._conn.Open();
+ }
+ //if (conn.State.ToString() == "OPEN")
+ //{
+ // conn.Close();
+ //}
+ //conn.Open();
+ //SqlCommand cmd = new SqlCommand();
+ this._cmd.Connection = this._conn;
+ SqlTransaction tx = this._conn.BeginTransaction();
+ this._cmd.Transaction = tx;
+ try
+ {
+ int count = 0;
+ for (int n = 0; n < list.Count; n++)
+ {
+
+ string strsql = list[n];
+
+ if (strsql.Trim().Length > 1)
+ {
+
+ this._cmd.CommandText = strsql;
+ count += this._cmd.ExecuteNonQuery();
+ }
+
+ }
+
+ tx.Commit();
+ this._conn.Close();
+ return count;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ tx.Rollback();
+ this._conn.Close();
+ return -1;
+ }
+ }
+
+
+
+ #region銆愭壒閲忓啓鍏ql銆�
+ //public int AddDBSqlBulkCopy(DataTable dt, string targetTable)
+ //{
+
+
+ // this._conn.Open();
+ // //澹版槑SqlBulkCopy ,using閲婃斁闈炴墭绠¤祫婧�
+
+ // using (OracleBulkCopy sqlBC = new OracleBulkCopy(this._conn))
+ // {
+
+ // //涓�娆℃壒閲忕殑鎻掑叆鐨勬暟鎹噺
+
+ // sqlBC.BatchSize = 1000;
+
+ // //瓒呮椂涔嬪墠鎿嶄綔瀹屾垚鎵�鍏佽鐨勭鏁帮紝濡傛灉瓒呮椂鍒欎簨鍔′笉浼氭彁浜� 锛屾暟鎹皢鍥炴粴锛屾墍鏈夊凡澶嶅埗鐨勮閮戒細浠庣洰鏍囪〃涓Щ闄�
+
+ // sqlBC.BulkCopyTimeout = 60;
+
+ // //瑷畾NotifyAfter 灞炴�э紝浠ヤ究鍦ㄦ瘡鎻掑叆10000 鏉℃暟鎹椂锛屽懠鍙浉搴斾簨浠躲��
+
+ // sqlBC.NotifyAfter = 10000;
+
+ // sqlBC.OracleRowsCopied += new OracleRowsCopiedEventHandler(sqlBC_OracleRowsCopied);
+
+ // //璁剧疆瑕佹壒閲忓啓鍏ョ殑琛�
+
+ // sqlBC.DestinationTableName = "dbo.Name";
+
+ // //鑷畾涔夌殑datatable鍜屾暟鎹簱鐨勫瓧娈佃繘琛屽搴�
+
+ // sqlBC.ColumnMappings.Add("Name", "userName");
+
+ // // sqlBC.ColumnMappings.Add("Name",1);
+
+ // //鎵归噺鍐欏叆
+
+ // sqlBC.WriteToServer(dt);
+
+ // }
+
+ // this._conn.Dispose();
+
+ //}
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/Tools/DownLoad.cs b/VueWebCoreApi/Tools/DownLoad.cs
new file mode 100644
index 0000000..66d159c
--- /dev/null
+++ b/VueWebCoreApi/Tools/DownLoad.cs
@@ -0,0 +1,572 @@
+锘縰sing NPOI.HSSF.UserModel;
+using NPOI.SS.UserModel;
+using NPOI.SS.Util;
+using NPOI.XSSF.UserModel;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public static class DownLoad
+ {
+ ///<summary>
+ /// 涓嬭浇
+ ///</summary>
+ ///<typeparam name="T"></typeparam>
+ ///<param name="data"></param>
+ ///<param name="map">鎵�闇�瑕佺殑鍒�</param>
+ ///<param name="filenName">鏂囦欢鍚嶅瓧</param>
+ ///<returns></returns>
+ public static string Download<T>(this IList<T> data, Dictionary<string, string> map, string filenName)
+ {
+ var filename = filenName + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
+ string fileip = AppSetting.GetAppSetting("FileIP");
+ var filepath = CoreHttpContext.MapPath("/File/newxls/");
+ var path = filepath + filename;
+
+ if (!Directory.Exists(filepath))
+ {
+ Directory.CreateDirectory(filepath);
+ }
+ var properties = TypeDescriptor.GetProperties(typeof(T));
+ var dt = new DataTable();
+ var list = map.Values;
+ //鏄剧ず琛ㄧ粨鏋�
+ foreach (var row in list)
+ {
+ dt.Columns.Add(row);
+ }
+ //鍙栧��
+ foreach (var item in data)
+ {
+ var i = 0;
+ var values = new object[dt.Columns.Count];
+ foreach (var content in map)
+ {
+ var property = properties[content.Key];
+ if (property != null)
+ {
+ var value = property.GetValue(item);
+ if (property.PropertyType == typeof(decimal))
+ {
+ if ((decimal)value == 0)
+ {
+ value = 0;
+ }
+ else
+ {
+ value = ((decimal)value).ToString("0.00");
+ }
+ }
+ values[i] = value;
+ if (Convert.ToString(content).Contains("鐜�"))
+ {
+ values[i] = value + "%";
+ }
+
+ }
+ else
+ {
+ values[i] = DBNull.Value;
+ }
+ i++;
+ }
+ dt.Rows.Add(values);
+ }
+ var b = DALSkillCondition.ResultExcel(path, dt);
+ if (b)
+ {
+ var url = fileip + "/apis/File/newxls/" + filename;
+ return url;
+ }
+ var messge = filename + "涓嬭浇澶辫触";
+ return messge;
+ }
+
+ /// <summary>
+ /// Datas the set to excel.
+ /// </summary>
+ /// <param name="ds">The ds.</param>
+ /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
+ public static string DataSetToExcel(DataSet ds, string filenName)
+ {
+ try
+ {
+ string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";
+ string fileip = AppSetting.GetAppSetting("FileIP");
+ string filePath = CoreHttpContext.MapPath("/File/newxls/");
+
+ Directory.CreateDirectory(filePath);
+ string Path = filePath + fileName;
+
+ FileStream fs = null;
+ XSSFWorkbook workbook = new XSSFWorkbook();
+ for (int i = 0; i < ds.Tables.Count; i++)
+ {
+ XSSFSheet sheet = (XSSFSheet)workbook.CreateSheet(ds.Tables[i].TableName);
+ XSSFCellStyle dateStyle = (XSSFCellStyle)workbook.CreateCellStyle();
+ XSSFDataFormat format = (XSSFDataFormat)workbook.CreateDataFormat();
+ dateStyle.DataFormat = format.GetFormat("yyyy-mm-dd");
+
+ int rowIndex = 0;
+
+ #region 鏂板缓琛紝濉厖琛ㄥご锛屽~鍏呭垪澶达紝鏍峰紡
+
+ if (rowIndex == 0)
+ {
+ #region 鍒楀ご鍙婃牱寮�
+
+ XSSFRow headerRow = (XSSFRow)sheet.CreateRow(0);
+ XSSFCellStyle headStyle = (XSSFCellStyle)workbook.CreateCellStyle();
+ headStyle.Alignment = HorizontalAlignment.Center;
+
+ XSSFFont font = (XSSFFont)workbook.CreateFont();
+ font.FontName = "寰蒋闆呴粦";
+ font.FontHeightInPoints = 12; //瀛椾綋澶у皬
+ font.Boldweight = 700;//瀛椾綋鍔犵矖
+ headStyle.SetFont(font);
+ //鑷畾涔夎〃澶�
+ for (var j = 0; j < ds.Tables[i].Columns.Count; j++)
+ {
+ sheet.SetColumnWidth(j, 30 * 256);//
+ //sheet.AutoSizeColumn(j); //鑷�傚簲瀹藉害
+ headerRow.CreateCell(j).SetCellValue(ds.Tables[i].Columns[j].ColumnName);
+ headerRow.GetCell(j).CellStyle = headStyle;
+ }
+
+ #endregion
+
+ rowIndex = 1;
+ }
+
+ #endregion
+ ICellStyle cellstyle = workbook.CreateCellStyle();
+ cellstyle.VerticalAlignment = VerticalAlignment.Center;
+ cellstyle.Alignment = HorizontalAlignment.Center;
+ foreach (DataRow row in ds.Tables[i].Rows)
+ {
+ XSSFRow dataRow = (XSSFRow)sheet.CreateRow(rowIndex);
+
+ #region 濉厖鍐呭
+
+ foreach (DataColumn column in ds.Tables[i].Columns)
+ {
+ XSSFCell newCell = (XSSFCell)dataRow.CreateCell(column.Ordinal);
+ string type = row[column].GetType().FullName.ToString();
+ newCell.SetCellValue(GetValue(row[column].ToString(), type));
+ newCell.CellStyle = cellstyle;
+ }
+
+ #endregion
+
+ rowIndex++;
+ }
+ }
+
+ using (fs = File.OpenWrite(Path))
+ {
+ workbook.Write(fs);
+ var url = fileip + "/File/newxls/" + fileName;
+ return url;
+ }
+ }
+ catch (Exception e)
+ {
+ return e.Message;
+ }
+ }
+
+ /// <summary>
+ /// Datas the set to excel.
+ /// </summary>
+ /// <param name="ds">The ds.</param>
+ /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
+ public static string DataTableToExcel(DataTable ds, string filenName)
+ {
+ try
+ {
+ string fileName = filenName + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";
+ string fileip = AppSetting.GetAppSetting("FileIP");
+ string filePath = CoreHttpContext.MapPath("/File/newxls/");
+ Directory.CreateDirectory(filePath);
+ string Path = filePath + fileName;
+
+ FileStream fs = null;
+ XSSFWorkbook workbook = new XSSFWorkbook();
+
+ XSSFSheet sheet = (XSSFSheet)workbook.CreateSheet(ds.TableName);
+ XSSFCellStyle dateStyle = (XSSFCellStyle)workbook.CreateCellStyle();
+ XSSFDataFormat format = (XSSFDataFormat)workbook.CreateDataFormat();
+ dateStyle.DataFormat = format.GetFormat("yyyy-mm-dd");
+
+ int rowIndex = 0;
+
+ #region 鏂板缓琛紝濉厖琛ㄥご锛屽~鍏呭垪澶达紝鏍峰紡
+
+ if (rowIndex == 0)
+ {
+ #region 鍒楀ご鍙婃牱寮�
+
+ XSSFRow headerRow = (XSSFRow)sheet.CreateRow(0);
+ XSSFCellStyle headStyle = (XSSFCellStyle)workbook.CreateCellStyle();
+ headStyle.Alignment = HorizontalAlignment.Center;
+
+ XSSFFont font = (XSSFFont)workbook.CreateFont();
+ font.FontName = "寰蒋闆呴粦";
+ font.FontHeightInPoints = 12; //瀛椾綋澶у皬
+ font.Boldweight = 700;//瀛椾綋鍔犵矖
+ headStyle.SetFont(font);
+ //鑷畾涔夎〃澶�
+ for (var j = 0; j < ds.Columns.Count; j++)
+ {
+ sheet.SetColumnWidth(j, 30 * 256);//
+ //sheet.AutoSizeColumn(j); //鑷�傚簲瀹藉害
+ headerRow.CreateCell(j).SetCellValue(ds.Columns[j].ColumnName);
+ headerRow.GetCell(j).CellStyle = headStyle;
+ }
+
+ #endregion
+
+ rowIndex = 1;
+ }
+
+ #endregion
+ ICellStyle cellstyle = workbook.CreateCellStyle();
+ cellstyle.VerticalAlignment = VerticalAlignment.Center;
+ cellstyle.Alignment = HorizontalAlignment.Center;
+ foreach (DataRow row in ds.Rows)
+ {
+ XSSFRow dataRow = (XSSFRow)sheet.CreateRow(rowIndex);
+
+ #region 濉厖鍐呭
+
+ foreach (DataColumn column in ds.Columns)
+ {
+ XSSFCell newCell = (XSSFCell)dataRow.CreateCell(column.Ordinal);
+ string type = row[column].GetType().FullName.ToString();
+ newCell.SetCellValue(GetValue(row[column].ToString(), type));
+ newCell.CellStyle = cellstyle;
+ }
+
+ #endregion
+
+ rowIndex++;
+ }
+
+
+ using (fs = File.OpenWrite(Path))
+ {
+ workbook.Write(fs);
+ var url = fileip + "/File/newxls/" + fileName;
+ return url;
+ }
+ }
+ catch (Exception e)
+ {
+ return e.Message;
+ }
+ }
+
+ /// <summary>
+ /// Gets the value.
+ /// </summary>
+ /// <param name="cellValue">The cell value.</param>
+ /// <param name="type">The type.</param>
+ /// <returns>System.String.</returns>
+ private static string GetValue(string cellValue, string type)
+ {
+ object value = string.Empty;
+ switch (type)
+ {
+ case "System.String"://瀛楃涓茬被鍨�
+ value = cellValue;
+ break;
+ case "System.DateTime"://鏃ユ湡绫诲瀷
+ System.DateTime dateV;
+ System.DateTime.TryParse(cellValue, out dateV);
+ value = dateV;
+ break;
+ case "System.Boolean"://甯冨皵鍨�
+ bool boolV = false;
+ bool.TryParse(cellValue, out boolV);
+ value = boolV;
+ break;
+ case "System.Int16"://鏁村瀷
+ case "System.Int32":
+ case "System.Int64":
+ case "System.Byte":
+ int intV = 0;
+ int.TryParse(cellValue, out intV);
+ value = intV;
+ break;
+ case "System.Decimal"://娴偣鍨�
+ case "System.Double":
+ double doubV = 0;
+ double.TryParse(cellValue, out doubV);
+ value = doubV;
+ break;
+ case "System.DBNull"://绌哄�煎鐞�
+ value = string.Empty;
+ break;
+ default:
+ value = string.Empty;
+ break;
+ }
+ return value.ToString();
+ }
+
+
+ /// <summary>
+ /// Datatable鐢熸垚Excel琛ㄦ牸骞惰繑鍥炶矾寰�
+ /// </summary>
+ /// <param name="m_DataTable">Datatable</param>
+ /// <param name="s_FileName">鏂囦欢鍚�</param>
+ /// <returns></returns>
+ public static string DataToExcel(System.Data.DataTable m_DataTable, string filenName)
+ {
+ var filename = filenName + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
+ string fileip = AppSetting.GetAppSetting("FileIP");
+ string filepath = CoreHttpContext.MapPath("/File/newxls/");
+ var path = filepath + filename;
+
+ //string FileName = AppDomain.CurrentDomain.BaseDirectory + ("/Upload/Excel/") + filenName + ".xls"; //鏂囦欢瀛樻斁璺緞
+ if (System.IO.File.Exists(path)) //瀛樺湪鍒欏垹闄�
+ {
+ System.IO.File.Delete(path);
+ }
+ System.IO.FileStream objFileStream;
+ System.IO.StreamWriter objStreamWriter;
+ string strLine = "";
+ objFileStream = new System.IO.FileStream(path, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
+ objStreamWriter = new System.IO.StreamWriter(objFileStream, Encoding.Unicode);
+ for (int i = 0; i < m_DataTable.Columns.Count; i++)
+ {
+
+ strLine = strLine + m_DataTable.Columns[i].Caption.ToString() + Convert.ToChar(9); //鍐欏垪鏍囬
+ }
+ objStreamWriter.WriteLine(strLine);
+ strLine = "";
+ for (int i = 0; i < m_DataTable.Rows.Count; i++)
+ {
+ for (int j = 0; j < m_DataTable.Columns.Count; j++)
+ {
+ if (m_DataTable.Rows[i].ItemArray[j] == null)
+ strLine = strLine + " " + Convert.ToChar(9); //鍐欏唴瀹�
+ else
+ {
+ string rowstr = "";
+ rowstr = m_DataTable.Rows[i].ItemArray[j].ToString();
+ if (rowstr.IndexOf("\r\n") > 0)
+ rowstr = rowstr.Replace("\r\n", " ");
+ if (rowstr.IndexOf("\t") > 0)
+ rowstr = rowstr.Replace("\t", " ");
+ strLine = strLine + rowstr + Convert.ToChar(9);
+ }
+ }
+ objStreamWriter.WriteLine(strLine);
+ strLine = "";
+ }
+ objStreamWriter.Close();
+ objFileStream.Close();
+ var url = fileip + "/File/newxls/" + filename;
+ return url;
+ }
+
+
+
+ /// <summary>
+ /// 宸ヨ祫鎶ヨ〃Excel瀵煎嚭鏁版嵁鍚堝苟
+ /// </summary>
+ /// <param name="path"></param>
+ /// <param name="table"></param>
+ /// <param name="treeIndex"></param>
+ public static void DataTree(DataTable table, string filenName, int treeIndex, out string pathstring) // /apis/File/newxls/宸ヨ祫浜ч噺鎶ヨ〃20200507114638.xls
+ {
+ var filename = filenName + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
+ string fileip = AppSetting.GetAppSetting("FileIP");
+ string filepath = CoreHttpContext.MapPath("/File/newxls/");
+ var path = filepath + filename;
+ using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite))
+ {
+ IWorkbook workBook = new HSSFWorkbook();
+ //鐜板湪浣跨敤鐨勪粛鐒舵槸鐢熸垚Excel2003鐨凟xcel鏂囦欢锛岀敱浜�03瀵硅鏁帮紙65535锛夊拰鍒楁暟锛�255锛夋湁闄愬埗锛屾墍浠ュ綋鏁版嵁瓒呭嚭鑼冨洿鍚庨毦鍏嶅嚭閿�
+ //ArgumentException: Invalid column index (256). Allowable column range for BIFF8 is (0..255) or ('A'..'IV') ...
+ if (Path.GetExtension(path).Equals(".xlsx", System.StringComparison.OrdinalIgnoreCase))
+ {
+ workBook = new XSSFWorkbook();
+ }
+
+ string sheetName = string.IsNullOrWhiteSpace(table.TableName) ? "Sheet1" : table.TableName;
+ ISheet sheet = workBook.CreateSheet(sheetName);
+ IRow row = null;
+ int colNum = 8; //鍚堝苟鐨勫垪鏁�
+ //int colNum = table.Columns.Count;
+ //if (treeIndex < table.Columns.Count || treeIndex > 0)
+ //{
+ // colNum = treeIndex;
+ //}
+
+ ICellStyle cellCenterStyle = GetCenter(workBook);
+ //IFont font = workBook.CreateFont(); //鍒涘缓涓�涓瓧浣撴牱寮忓璞�
+ //font.FontName = "鏂规鑸掍綋"; //鍜宔xcel閲岄潰鐨勫瓧浣撳搴�
+ //font.IsItalic = true; //鏂滀綋
+ //font.FontHeightInPoints = 16;//瀛椾綋澶у皬
+ //font.Boldweight = short.MaxValue;//瀛椾綋鍔犵矖
+ //cellCenterStyle.SetFont(font); //灏嗗瓧浣撴牱寮忚祴缁欐牱寮忓璞�
+
+ int beginNum = 1;//鎺掗櫎鍒楀ご锛屼粠1寮�濮�
+
+ //澶勭悊琛ㄦ牸鍒楀ご
+ row = sheet.CreateRow(beginNum - 1);
+ for (int i = 0; i < table.Columns.Count; i++)
+ {
+
+ string strVal = table.Columns[i].ColumnName;
+ ICell cell = row.CreateCell(i);
+ cell.SetCellValue(strVal);
+ cell.CellStyle = cellCenterStyle;
+ row.Height = 450;
+
+ sheet.AutoSizeColumn(i);
+
+ List<int> lstColWidth = new List<int>();
+ //璁板綍鍒楅暱搴�
+ lstColWidth.Add(DataLength(strVal));
+ //璁剧疆鍒楀
+ int maxWidth = lstColWidth.Max() * 600;
+ sheet.SetColumnWidth(i, maxWidth);
+ }
+
+ //澶勭悊鏁版嵁鍐呭
+ for (int i = 0; i < table.Rows.Count; i++)
+ {
+ row = sheet.CreateRow(beginNum + i);
+ row.Height = 350;
+ for (int j = 0; j < table.Columns.Count; j++)
+ {
+ string strVal = table.Rows[i][j].ToString();
+ ICell currCell = row.CreateCell(j);
+ currCell.SetCellValue(strVal);
+ currCell.CellStyle = cellCenterStyle;
+ sheet.SetColumnWidth(j, 256 * 15);
+ }
+ }
+
+ for (int i = 0; i < colNum; i++) //鏁版嵁鏉℃暟
+ {
+ List<int> lstColWidth = new List<int>();
+ string currVal = string.Empty;
+ string nextVal = string.Empty;
+ for (int j = beginNum; j <= sheet.LastRowNum; j++)
+ {
+ currVal = sheet.GetRow(j).Cells[i].StringCellValue;
+
+ int mk = j;
+ if (!string.IsNullOrWhiteSpace(currVal))//鎺掗櫎 绌哄�硷紝绌哄�间笉鍋氬悎骞跺鐞�
+ {
+ for (int k = j + 1; k <= sheet.LastRowNum; k++)
+ {
+ nextVal = sheet.GetRow(k).Cells[i].StringCellValue;
+
+ if (currVal != nextVal)
+ {
+ //鍥犱负k 绱姞鎵�浠ュ鑷村綋鍓嶅�间笌涓嬩釜鍊� 涓嶇浉鍚岋紝鎵�浠ヨ褰� 褰撳墠琛屾暟瑕� 鍑忓幓1
+ mk = k - 1;
+ break;
+ }
+ else if (k == sheet.LastRowNum) //杈圭晫鍊硷紝澶勭悊鏈�鍚庝竴琛岋紝鍒欐彁鍓岯reak 骞惰褰曞綋鍓� k
+ {
+ mk = k;
+ break;
+ }
+ }
+ }
+
+ if (mk != j)//鎺掗櫎 绌哄�煎锛屼笅涓�肩殑琛屾暟涓嶇瓑浜庡綋鍓嶈鏁帮紝鍒欓渶瑕佸悎骞�
+ {
+ sheet.AddMergedRegion(new CellRangeAddress(j, mk, i, i));
+
+ //sheet.GetRow(j).GetCell(i).SetCellValue("");
+ }
+ //else
+ //{
+ // if (mk < sheet.LastRowNum)
+ // {
+ // if (sheet.GetRow(j).Cells[0].StringCellValue == sheet.GetRow(mk + 1).Cells[0].StringCellValue
+ // && sheet.GetRow(j).Cells[1].StringCellValue == sheet.GetRow(mk + 1).Cells[1].StringCellValue
+ // && sheet.GetRow(j).Cells[2].StringCellValue == sheet.GetRow(mk + 1).Cells[2].StringCellValue
+ // && sheet.GetRow(j).Cells[3].StringCellValue == sheet.GetRow(mk + 1).Cells[3].StringCellValue
+ // )
+ // {
+ // int mmk = mk + 1;
+ // sheet.AddMergedRegion(new CellRangeAddress(j, mmk, i, i));
+ // }
+ // }
+ //}
+
+ //if (i == 0) //濡傛灉鏄涓�鍒楋紝鍒� 鍨傜洿姘村钩灞呬腑
+ {
+ sheet.GetRow(j).Cells[i].CellStyle = cellCenterStyle;
+ }
+ //璺冲埌鎵ц涓嬩竴涓笉鍚屾暟鎹殑琛�
+ j = mk;
+
+ //璁板綍鍒楅暱搴�
+ lstColWidth.Add(DataLength(currVal));
+ }
+
+ //璁剧疆鍒楀
+ //int maxWidth = lstColWidth.Max() * 600;
+ //sheet.SetColumnWidth(i, maxWidth);
+ }
+ //鍥哄畾鍒椼�佽 婊氬姩鏃朵笉鍙�
+ //sheet.CreateFreezePane(3, 1, 3, 1);
+
+ //鍐欏叆鏁版嵁娴�
+ workBook.Write(fs);
+ var url = fileip + "/apis/File/newxls/" + filename;
+ pathstring = url;
+ }
+ }
+
+
+ private static ICellStyle GetCenter(IWorkbook workBook, short fontSize = 10)
+ {
+ ICellStyle cellStyle = workBook.CreateCellStyle();
+ IFont font = workBook.CreateFont();
+ font.FontName = "寰蒋闆呴粦";
+ font.FontHeightInPoints = fontSize;
+ cellStyle.SetFont(font);
+ cellStyle.VerticalAlignment = VerticalAlignment.Center;
+ cellStyle.Alignment = HorizontalAlignment.Center;
+ return cellStyle;
+ }
+
+
+ /// <summary>
+ /// 鑾峰彇瀛楃涓查暱搴︼紙涓枃鎸�2涓瓧鑺傞暱搴︼級
+ /// </summary>
+ /// <param name="stringWithEnglishAndChinese"></param>
+ /// <returns></returns>
+ private static int DataLength(string stringWithEnglishAndChinese)
+ {
+ int lng = 0;
+ for (int i = 0; i < stringWithEnglishAndChinese.Length; i++)
+ {
+ byte[] b = System.Text.Encoding.Default.GetBytes(stringWithEnglishAndChinese.Substring(i, 1));
+ if (b.Length > 1)
+ lng += 2;
+ else
+ lng += 1;
+ }
+ return lng;
+ }
+
+ }
+}
diff --git a/VueWebCoreApi/Tools/Encrypt.cs b/VueWebCoreApi/Tools/Encrypt.cs
new file mode 100644
index 0000000..ef019a7
--- /dev/null
+++ b/VueWebCoreApi/Tools/Encrypt.cs
@@ -0,0 +1,143 @@
+锘縰sing System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+
+namespace VueWebCoreApi.Tools
+{
+ public class Encrypt
+ {
+ private static RijndaelManaged RMCrypto = null;
+
+ private Hashtable keyList = new Hashtable();
+
+ public static string EncryptStr(string str, string strKey, string strIV)
+ {
+ CryptoStream cryptoStream = null;
+ MD5CryptoServiceProvider mD5CryptoServiceProvider = new MD5CryptoServiceProvider();
+ string result;
+ try
+ {
+ Encrypt.RMCrypto = new RijndaelManaged();
+ if (str == null || str.Trim().Length == 0)
+ {
+ result = "";
+ }
+ else
+ {
+ byte[] rgbKey = mD5CryptoServiceProvider.ComputeHash(Encoding.ASCII.GetBytes(strKey));
+ byte[] rgbIV = mD5CryptoServiceProvider.ComputeHash(Encoding.ASCII.GetBytes(strIV));
+ MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(str));
+ cryptoStream = new CryptoStream(memoryStream, Encrypt.RMCrypto.CreateEncryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
+ result = Convert.ToBase64String(memoryStream.ToArray());
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != cryptoStream)
+ {
+ cryptoStream = null;
+ }
+ if (null != Encrypt.RMCrypto)
+ {
+ Encrypt.RMCrypto.Clear();
+ Encrypt.RMCrypto = null;
+ }
+ }
+ return result;
+ }
+
+ public static string DecryptStr(string str, string strKey, string strIV)
+ {
+ string result;
+ if (str == null || str.Trim().Length == 0)
+ {
+ result = "";
+ }
+ else
+ {
+ CryptoStream cryptoStream = null;
+ MD5CryptoServiceProvider mD5CryptoServiceProvider = new MD5CryptoServiceProvider();
+ try
+ {
+ Encrypt.RMCrypto = new RijndaelManaged();
+ byte[] buffer = Convert.FromBase64String(str);
+ byte[] rgbKey = mD5CryptoServiceProvider.ComputeHash(Encoding.ASCII.GetBytes(strKey));
+ byte[] rgbIV = mD5CryptoServiceProvider.ComputeHash(Encoding.ASCII.GetBytes(strIV));
+ MemoryStream memoryStream = new MemoryStream(buffer);
+ cryptoStream = new CryptoStream(memoryStream, Encrypt.RMCrypto.CreateDecryptor(rgbKey, rgbIV), CryptoStreamMode.Read);
+ result = Encoding.UTF8.GetString(memoryStream.ToArray());
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != cryptoStream)
+ {
+ cryptoStream = null;
+ }
+ if (null != Encrypt.RMCrypto)
+ {
+ Encrypt.RMCrypto.Clear();
+ Encrypt.RMCrypto = null;
+ }
+ }
+ }
+ return result;
+ }
+
+ public void Add(string key, string value)
+ {
+ if (this.keyList.ContainsKey(key))
+ {
+ this.keyList[key] = value;
+ }
+ else
+ {
+ this.keyList.Add(key, value);
+ }
+ }
+
+ public string GetEncryptXml(string name, string key, string iv)
+ {
+ XmlDocument xmlDocument = new XmlDocument();
+ XmlElement xmlElement = xmlDocument.CreateElement(name);
+ foreach (object current in this.keyList.Keys)
+ {
+ XmlElement xmlElement2 = xmlDocument.CreateElement(Convert.ToString(current));
+ xmlElement2.InnerText = Convert.ToString(this.keyList[current]);
+ xmlElement.AppendChild(xmlElement2);
+ }
+ xmlDocument.AppendChild(xmlElement);
+ return Encrypt.EncryptStr(xmlDocument.OuterXml, key, iv);
+ }
+
+ public Hashtable GetKeyList(string name, string encryptStr, string key, string iv)
+ {
+ string xml = Encrypt.DecryptStr(encryptStr, key, iv);
+ XmlDocument xmlDocument = new XmlDocument();
+ xmlDocument.LoadXml(xml);
+ this.keyList.Clear();
+ XmlNode xmlNode = xmlDocument.SelectSingleNode(name);
+ if (null != xmlNode)
+ {
+ foreach (XmlNode xmlNode2 in xmlNode.ChildNodes)
+ {
+ this.keyList.Add(xmlNode2.Name, xmlNode2.InnerText);
+ }
+ }
+ return this.keyList;
+ }
+ }
+}
diff --git a/VueWebCoreApi/Tools/ExcelList.cs b/VueWebCoreApi/Tools/ExcelList.cs
new file mode 100644
index 0000000..fc2de5b
--- /dev/null
+++ b/VueWebCoreApi/Tools/ExcelList.cs
@@ -0,0 +1,52 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class ExcelList
+ {
+ public static List<ScoreReport> ExcelData()
+ {
+
+ List<ScoreReport> list = new List<ScoreReport>
+ {
+ new ScoreReport("1","瑙掕壊娓呭崟"),
+ new ScoreReport("2","鐢ㄦ埛娓呭崟"),
+ new ScoreReport("3","宸ヤ綅娓呭崟"),
+ new ScoreReport("4","寰�鏉ュ崟浣�"),
+ new ScoreReport("6","浠撳簱搴撲綅娓呭崟"),
+ new ScoreReport("7","瀹瑰櫒瀹氫箟"),
+ new ScoreReport("8","瀛樿揣妗f"),
+ new ScoreReport("9","璁惧娓呭崟"),
+ new ScoreReport("10","璁惧鐐规椤圭洰"),
+ new ScoreReport("22","璁惧鐐规鏍囧噯"),
+ new ScoreReport("11","璁惧淇濆吇椤圭洰"),
+ new ScoreReport("23","璁惧淇濆吇鏍囧噯"),
+ new ScoreReport("12","宸ヨ娓呭崟"),
+ new ScoreReport("13","宸ヨ鐐规"),
+ new ScoreReport("14","宸ヨ淇濆吇"),
+ new ScoreReport("15","宸ュ簭瀹氫箟"),
+ new ScoreReport("16","宸ヨ壓璺嚎"),
+ new ScoreReport("24","鑺傛媿宸ヤ环"),
+ new ScoreReport("17","璐ㄦ鏍囧噯"),
+ new ScoreReport("18","缂洪櫡瀹氫箟"),
+ new ScoreReport("19","鐢熶骇璁㈠崟"),
+ new ScoreReport("20","搴撳瓨鏌ヨ"),
+ new ScoreReport("21","鐗╂枡娓呭崟"),
+ };
+ return list;
+ }
+ }
+ public class ScoreReport
+ {
+ public ScoreReport(string a, string n)
+ {
+ FileCode = a;
+ FileName = n;
+ }
+ public string FileCode { get; set; }
+ public string FileName { get; set; }
+ }
+}
diff --git a/VueWebCoreApi/Tools/ExcelModelCheck.cs b/VueWebCoreApi/Tools/ExcelModelCheck.cs
new file mode 100644
index 0000000..2c25921
--- /dev/null
+++ b/VueWebCoreApi/Tools/ExcelModelCheck.cs
@@ -0,0 +1,14 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class ExcelModelCheck
+ {
+ public ToMessage json1 { get; set; }
+ public ToMessage json2 { get; set; }
+ public ToMessage json3 { get; set; }
+ }
+}
diff --git a/VueWebCoreApi/Tools/ImportExcel.cs b/VueWebCoreApi/Tools/ImportExcel.cs
new file mode 100644
index 0000000..a3c206b
--- /dev/null
+++ b/VueWebCoreApi/Tools/ImportExcel.cs
@@ -0,0 +1,1277 @@
+锘縰sing NPOI.HSSF.UserModel;
+using NPOI.SS.UserModel;
+using NPOI.XSSF.UserModel;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Models;
+
+namespace VueWebCoreApi.Tools
+{
+ public class ImportExcel
+ {
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+
+ /// <summary>
+ /// Excel瀵煎叆鎴怐atable
+ /// </summary>
+ /// <param name="file">瀵煎叆璺緞(鍖呭惈鏂囦欢鍚嶄笌鎵╁睍鍚�)</param>
+ /// <returns></returns>
+ public static DataTable ExcelToTable(string file)
+ {
+ IWorkbook Workbook;
+ DataTable table = new DataTable();
+ try
+ {
+ using (FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read))
+ {
+ //XSSFWorkbook 閫傜敤XLSX鏍煎紡锛孒SSFWorkbook 閫傜敤XLS鏍煎紡
+ string fileExt = Path.GetExtension(file).ToLower();
+ if (fileExt == ".xls")
+ {
+ Workbook = new HSSFWorkbook(fileStream);
+ }
+ else if (fileExt == ".xlsx")
+ {
+ Workbook = new XSSFWorkbook(fileStream);
+ }
+ else
+ {
+ Workbook = null;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+
+ //瀹氫綅鍦ㄧ涓�涓猻heet
+ ISheet sheet = Workbook.GetSheetAt(0);
+ //绗竴琛屼负鏍囬琛�
+ IRow headerRow = sheet.GetRow(0);
+ if (headerRow == null)
+ {
+ return table;
+ }
+ int cellCount = headerRow.LastCellNum;
+ int rowCount = sheet.LastRowNum;
+
+ //寰幆娣诲姞鏍囬鍒�
+ for (int i = headerRow.FirstCellNum; i < cellCount; i++)
+ {
+ DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
+ table.Columns.Add(column);
+ }
+
+ //鏁版嵁
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ IRow row = sheet.GetRow(i);
+ DataRow dataRow = table.NewRow();
+ if (row != null && row.Cells.Count > 0)
+ {
+ for (int j = row.FirstCellNum; j < cellCount; j++)
+ {
+ if (row.GetCell(j) != null)
+ {
+ dataRow[j] = GetCellValue(row.GetCell(j)).Trim();
+ }
+ }
+ }
+ table.Rows.Add(dataRow);
+ }
+ //娓呴櫎鏈�鍚庣殑绌鸿
+ //娓呴櫎鏈�鍚庣殑绌鸿
+ for (int i = 0; i < table.Rows.Count; i++)
+ {
+ bool isnull = true;
+ for (int j = 0; j < table.Columns.Count; j++)
+ {
+ if (table.Rows[i][j].ToString() != null && table.Rows[i][j].ToString() != "")
+ {
+ if (table.Rows[i][j].ToString().Trim() != "" && table.Rows[i][j].ToString().Trim() != null)
+ {
+ isnull = false;
+ break;
+ }
+ }
+ }
+ if (isnull)
+ {
+ table.Rows[i].Delete();
+ i = 0;
+ }
+ }
+ return table;
+ }
+
+ /// <summary>
+ /// Excel 2涓猄heet瀵煎叆鎴怐atable
+ /// </summary>
+ /// <param name="file">瀵煎叆璺緞(鍖呭惈鏂囦欢鍚嶄笌鎵╁睍鍚�)</param>
+ /// <returns></returns>
+ public static List<DataTable> ExcelToTableList(string file)
+ {
+ List<DataTable> list = new List<DataTable>();
+ IWorkbook Workbook;
+ try
+ {
+ using (FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read))
+ {
+ //XSSFWorkbook 閫傜敤XLSX鏍煎紡锛孒SSFWorkbook 閫傜敤XLS鏍煎紡
+ string fileExt = Path.GetExtension(file).ToLower();
+ if (fileExt == ".xls")
+ {
+ Workbook = new HSSFWorkbook(fileStream);
+ }
+ else if (fileExt == ".xlsx")
+ {
+ Workbook = new XSSFWorkbook(fileStream);
+ }
+ else
+ {
+ Workbook = null;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ int count = Workbook.NumberOfSheets; //鑾峰彇鎵�鏈塖heetName
+ if (count < 2)
+ {
+ DataTable table = new DataTable();
+ //瀹氫綅鍦ㄧ涓�涓猻heet
+ ISheet sheet = Workbook.GetSheetAt(0);
+ //绗竴琛屼负鏍囬琛�
+ IRow headerRow = sheet.GetRow(0);
+ if (headerRow == null)
+ {
+ return list;
+ }
+ int cellCount = headerRow.LastCellNum;
+ int rowCount = sheet.LastRowNum;
+
+ //寰幆娣诲姞鏍囬鍒�
+ for (int i = headerRow.FirstCellNum; i < cellCount; i++)
+ {
+ DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
+ table.Columns.Add(column);
+ }
+
+ //鏁版嵁
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ IRow row = sheet.GetRow(i);
+ DataRow dataRow = table.NewRow();
+ if (row != null && row.Cells.Count > 0)
+ {
+ for (int j = row.FirstCellNum; j < cellCount; j++)
+ {
+ if (row.GetCell(j) != null)
+ {
+ dataRow[j] = GetCellValue(row.GetCell(j)).Trim();
+ }
+ }
+ }
+ table.Rows.Add(dataRow);
+ }
+ //娓呴櫎鏈�鍚庣殑绌鸿
+ for (int i = 0; i < table.Rows.Count; i++)
+ {
+ bool isnull = true;
+ for (int j = 0; j < table.Columns.Count; j++)
+ {
+ if (table.Rows[i][j].ToString() != null && table.Rows[i][j].ToString() != "")
+ {
+ if (table.Rows[i][j].ToString().Trim() != "" && table.Rows[i][j].ToString().Trim() != null)
+ {
+ isnull = false;
+ break;
+ }
+ }
+ }
+ if (isnull)
+ {
+ table.Rows[i].Delete();
+ i = 0;
+ }
+ }
+ list.Add(table);
+ }
+ else
+ {
+ for (int m = 0; m < count; m++)
+ {
+ DataTable table = new DataTable();
+ //瀹氫綅鍦ㄧ涓�涓猻heet
+ ISheet sheet = Workbook.GetSheetAt(m);
+ //绗竴琛屼负鏍囬琛�
+ IRow headerRow = sheet.GetRow(0);
+ if (headerRow == null)
+ {
+ return list;
+ }
+ int cellCount = headerRow.LastCellNum;
+ int rowCount = sheet.LastRowNum;
+
+ //寰幆娣诲姞鏍囬鍒�
+ for (int i = headerRow.FirstCellNum; i < cellCount; i++)
+ {
+ DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
+ table.Columns.Add(column);
+ }
+
+ //鏁版嵁
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ IRow row = sheet.GetRow(i);
+ DataRow dataRow = table.NewRow();
+ if (row != null && row.Cells.Count > 0)
+ {
+ for (int j = row.FirstCellNum; j < cellCount; j++)
+ {
+ if (row.GetCell(j) != null)
+ {
+ dataRow[j] = GetCellValue(row.GetCell(j)).Trim();
+ }
+ }
+ }
+ table.Rows.Add(dataRow);
+ }
+ //娓呴櫎鏈�鍚庣殑绌鸿
+ for (int i = 0; i < table.Rows.Count; i++)
+ {
+ bool isnull = true;
+ for (int j = 0; j < table.Columns.Count; j++)
+ {
+ if (table.Rows[i][j].ToString() != null && table.Rows[i][j].ToString() != "")
+ {
+ if (table.Rows[i][j].ToString().Trim() != "" && table.Rows[i][j].ToString().Trim() != null)
+ {
+ isnull = false;
+ break;
+ }
+ }
+ }
+ if (isnull)
+ {
+ table.Rows[i].Delete();
+ i = 0;
+ }
+ }
+ list.Add(table);
+ }
+ }
+ return list;
+ }
+
+ /// <summary>
+ /// Excel 3涓猄heet瀵煎叆鎴怐atable
+ /// </summary>
+ /// <param name="file">瀵煎叆璺緞(鍖呭惈鏂囦欢鍚嶄笌鎵╁睍鍚�)</param>
+ /// <returns></returns>
+ public static List<DataTable> ExcelToThreeTableList(string file)
+ {
+ List<DataTable> list = new List<DataTable>();
+ IWorkbook Workbook;
+ try
+ {
+ using (FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read))
+ {
+ //XSSFWorkbook 閫傜敤XLSX鏍煎紡锛孒SSFWorkbook 閫傜敤XLS鏍煎紡
+ string fileExt = Path.GetExtension(file).ToLower();
+ if (fileExt == ".xls")
+ {
+ Workbook = new HSSFWorkbook(fileStream);
+ }
+ else if (fileExt == ".xlsx")
+ {
+ Workbook = new XSSFWorkbook(fileStream);
+ }
+ else
+ {
+ Workbook = null;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ int count = Workbook.NumberOfSheets; //鑾峰彇鎵�鏈塖heetName
+ if (count < 3)
+ {
+ DataTable table = new DataTable();
+ //瀹氫綅鍦ㄧ涓�涓猻heet
+ ISheet sheet = Workbook.GetSheetAt(0);
+ //绗竴琛屼负鏍囬琛�
+ IRow headerRow = sheet.GetRow(0);
+ if (headerRow == null)
+ {
+ return list;
+ }
+ int cellCount = headerRow.LastCellNum;
+ int rowCount = sheet.LastRowNum;
+
+ //寰幆娣诲姞鏍囬鍒�
+ for (int i = headerRow.FirstCellNum; i < cellCount; i++)
+ {
+ DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
+ table.Columns.Add(column);
+ }
+
+ //鏁版嵁
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ IRow row = sheet.GetRow(i);
+ DataRow dataRow = table.NewRow();
+ if (row != null && row.Cells.Count > 0)
+ {
+ for (int j = row.FirstCellNum; j < cellCount; j++)
+ {
+ if (row.GetCell(j) != null)
+ {
+ dataRow[j] = GetCellValue(row.GetCell(j)).Trim();
+ }
+ }
+ }
+ table.Rows.Add(dataRow);
+ }
+ //娓呴櫎鏈�鍚庣殑绌鸿
+ for (int i = 0; i < table.Rows.Count; i++)
+ {
+ bool isnull = true;
+ for (int j = 0; j < table.Columns.Count; j++)
+ {
+ if (table.Rows[i][j].ToString() != null && table.Rows[i][j].ToString() != "")
+ {
+ if (table.Rows[i][j].ToString().Trim() != "" && table.Rows[i][j].ToString().Trim() != null)
+ {
+ isnull = false;
+ break;
+ }
+ }
+ }
+ if (isnull)
+ {
+ table.Rows[i].Delete();
+ i = 0;
+ }
+ }
+ list.Add(table);
+ }
+ else
+ {
+ for (int m = 0; m < count; m++)
+ {
+ DataTable table = new DataTable();
+ //瀹氫綅鍦ㄧ涓�涓猻heet
+ ISheet sheet = Workbook.GetSheetAt(m);
+ //绗竴琛屼负鏍囬琛�
+ IRow headerRow = sheet.GetRow(0);
+ if (headerRow == null)
+ {
+ return list;
+ }
+ int cellCount = headerRow.LastCellNum;
+ int rowCount = sheet.LastRowNum;
+
+ //寰幆娣诲姞鏍囬鍒�
+ for (int i = headerRow.FirstCellNum; i < cellCount; i++)
+ {
+ DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
+ table.Columns.Add(column);
+ }
+
+ //鏁版嵁
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ IRow row = sheet.GetRow(i);
+ DataRow dataRow = table.NewRow();
+ if (row != null && row.Cells.Count > 0)
+ {
+ for (int j = row.FirstCellNum; j < cellCount; j++)
+ {
+ if (row.GetCell(j) != null)
+ {
+ dataRow[j] = GetCellValue(row.GetCell(j)).Trim();
+ }
+ }
+ }
+ table.Rows.Add(dataRow);
+ }
+ //娓呴櫎鏈�鍚庣殑绌鸿
+ for (int i = 0; i < table.Rows.Count; i++)
+ {
+ bool isnull = true;
+ for (int j = 0; j < table.Columns.Count; j++)
+ {
+ if (table.Rows[i][j].ToString() != null && table.Rows[i][j].ToString() != "")
+ {
+ if (table.Rows[i][j].ToString().Trim() != "" && table.Rows[i][j].ToString().Trim() != null)
+ {
+ isnull = false;
+ break;
+ }
+ }
+ }
+ if (isnull)
+ {
+ table.Rows[i].Delete();
+ i = 0;
+ }
+ }
+ list.Add(table);
+ }
+ }
+ return list;
+ }
+
+
+
+
+ /// <summary>
+ /// 鑾峰彇鍗曞厓鏍肩被鍨�
+ /// </summary>
+ /// <param name="cell"></param>
+ /// <returns></returns>
+ private static string GetCellValue(ICell cell)
+ {
+ if (cell == null)
+ {
+ return string.Empty;
+ }
+
+ switch (cell.CellType)
+ {
+ case CellType.Blank:
+ return string.Empty;
+ case CellType.Boolean:
+ return cell.BooleanCellValue.ToString();
+ case CellType.Error:
+ return cell.ErrorCellValue.ToString();
+ case CellType.Numeric:
+ //Cell涓洪潪NUMERIC鏃讹紝璋冪敤IsCellDateFormatted鏂规硶浼氭姤閿欙紝鎵�浠ュ厛瑕佽繘琛岀被鍨嬪垽鏂�
+ if (cell.CellType == CellType.Numeric && DateUtil.IsCellDateFormatted(cell))
+ return Convert.ToDateTime(cell.DateCellValue).ToString("yyyy-MM-dd");
+ else
+ {
+ return cell.NumericCellValue.ToString();
+ }
+ //if (format != 0) { return Convert.ToDateTime(cell.DateCellValue).ToString("yyyy-MM-dd"); } else { return cell.NumericCellValue.ToString(); }
+ case CellType.Unknown:
+ default:
+ return cell.ToString();
+ case CellType.String:
+ return cell.StringCellValue;
+ case CellType.Formula:
+ try
+ {
+ HSSFFormulaEvaluator e = new HSSFFormulaEvaluator(cell.Sheet.Workbook);
+ e.EvaluateInCell(cell);
+ return cell.ToString();
+ }
+ catch
+ {
+ return cell.NumericCellValue.ToString();
+ }
+ }
+ }
+
+
+ /// <summary>
+ /// 鍗曚釜Excel 涓嶄负绌洪獙璇併�侀噸澶嶆暟鎹獙璇�
+ /// </summary>
+ /// <param name="file">瀵煎叆璺緞(鍖呭惈鏂囦欢鍚嶄笌鎵╁睍鍚�)</param>
+ /// <returns></returns>
+ public static List<ExcelErro> ExcelToTableErro(string file)
+ {
+ List<ExcelErro> list = new List<ExcelErro>();
+ IWorkbook Workbook;
+ DataTable table = new DataTable();
+ bool iscell = false;
+ int iscellCount = 0;
+ try
+ {
+ using (FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read))
+ {
+ //XSSFWorkbook 閫傜敤XLSX鏍煎紡锛孒SSFWorkbook 閫傜敤XLS鏍煎紡
+ string fileExt = Path.GetExtension(file).ToLower();
+ if (fileExt == ".xls")
+ {
+ Workbook = new HSSFWorkbook(fileStream);
+ }
+ else if (fileExt == ".xlsx")
+ {
+ Workbook = new XSSFWorkbook(fileStream);
+ }
+ else
+ {
+ Workbook = null;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+
+ //瀹氫綅鍦ㄧ涓�涓猻heet
+ ISheet sheet = Workbook.GetSheetAt(0);
+ //sheet.ShiftRows(sheet.FirstRowNum-1, sheet.LastRowNum,1);
+ //绗竴琛屼负鏍囬琛�
+ IRow headerRow = sheet.GetRow(0);
+ int cellCount = headerRow.LastCellNum;
+ int rowCount0 = sheet.FirstRowNum;
+ //int rowCount = sheet.LastRowNum;
+ //int rowCount = sheet.PhysicalNumberOfRows;
+ int rowCount = Rownum(headerRow, cellCount, sheet, sheet.LastRowNum); //鑾峰彇鍒犻櫎绌鸿涔嬪悗鐨勬暟鎹 (鍙拡瀵逛簬鏈�鍚庢暟鎹」鏈夌┖琛岀殑)
+
+ if (rowCount - rowCount0 >= 1)
+ {
+
+ //-------------鍒ゆ柇蹇呭~椤规槸鍚︿负绌�----------------//
+ //寰幆鏁版嵁琛�
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ iscell = false;
+ iscellCount = 0;
+ IRow row = sheet.GetRow(i);
+ //鍒ゆ柇鏄惁鏈夌┖琛�
+ if (row == null)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = (i + 1).ToString();
+ erro.ErrorField = "绌鸿";
+ erro.ErrorCont = "绌鸿";
+ list.Add(erro);
+ continue;
+ }
+ //鍒ゆ柇鏄惁瀛樺湪绌烘暟鎹
+ for (int c = 0; c < cellCount; c++)
+ {
+ if (GetCellValue(row.GetCell(c)).Trim() != null && GetCellValue(row.GetCell(c)).Trim() != "")
+ {
+ iscell = false;
+ }
+ else
+ {
+ iscell = true;
+ iscellCount++;
+ }
+ }
+ if (iscell == true && iscellCount == cellCount) //绌鸿
+ {
+ continue;
+ }
+ else
+ {
+ //寰幆鏍囬鍒�
+ for (int j = headerRow.FirstCellNum; j < cellCount; j++)
+ {
+ //鑾峰彇鍗曞厓鏍肩殑濉厖鑹�
+ string rgb = headerRow.Cells[j].CellStyle.FillForegroundColor.ToString();
+ if (rgb == "51") //蹇呭~椤瑰瓧娈靛垪澶村~鍏呰壊
+ {
+ if (sheet.GetRow(i) == null || sheet.GetRow(i).ToString() == "") //瀛樺湪绌鸿
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = i.ToString();
+ erro.ErrorField = "{绗�" + i.ToString() + "琛寎";
+ erro.ErrorCont = "{绗�" + i.ToString() + "}琛屼负绌�";
+ list.Add(erro);
+ break;
+ }
+ else
+ {
+ string cellValue = GetCellValue(sheet.GetRow(i).GetCell(j)).Trim(); //GetCell:杩斿洖鍖呮嫭绌哄垪鍊� Cells:鍙繑鍥炴湁鍊肩殑鍒�
+ if (cellValue == "" || cellValue == null)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = (sheet.GetRow(i).RowNum + 1).ToString();
+ erro.ErrorField = "{" + headerRow.Cells[j].StringCellValue + "}";
+ erro.ErrorCont = "{" + headerRow.Cells[j].StringCellValue + "}瀛楁涓嶈兘涓虹┖";
+ list.Add(erro);
+ }
+ }
+ }
+
+ }
+ }
+ }
+ //-------------鍒ゆ柇鍞竴椤规槸鍚﹂噸澶�----------------//
+ //寰幆娣诲姞鏍囬鍒�
+ for (int i = headerRow.FirstCellNum; i < cellCount; i++)
+ {
+ DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
+ table.Columns.Add(column);
+ }
+
+ //鏁版嵁
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ IRow row = sheet.GetRow(i);
+ DataRow dataRow = table.NewRow();
+ if (row != null)
+ {
+ for (int j = row.FirstCellNum; j < cellCount; j++)
+ {
+ if (row.GetCell(j) != null)
+ {
+ dataRow[j] = GetCellValue(row.GetCell(j)).Trim();
+ }
+ }
+ }
+ table.Rows.Add(dataRow);
+ }
+ //娓呴櫎鏈�鍚庣殑绌鸿
+ for (int i = 0; i < table.Rows.Count; i++)
+ {
+ bool isnull = true;
+ for (int j = 0; j < table.Columns.Count; j++)
+ {
+ if (table.Rows[i][j].ToString() != null && table.Rows[i][j].ToString() != "")
+ {
+ if (table.Rows[i][j].ToString().Trim() != "" && table.Rows[i][j].ToString().Trim() != null)
+ {
+ isnull = false;
+ break;
+ }
+ }
+ }
+ if (isnull)
+ {
+ table.Rows[i].Delete();
+ i = 0;
+ }
+ }
+ DataView view = new DataView(table);
+ //鑾峰彇鎵�鏈夊敮涓�鍒�
+ List<string> list0 = new List<string>();
+ //寰幆鏍囬鍒�
+ for (int j = headerRow.FirstCellNum; j < cellCount; j++)
+ {
+ bool isContain = headerRow.Cells[j].StringCellValue.Contains("鍞竴"); //鏍囬鍒椾腑鐨勫繀濉垪
+ if (isContain == true)
+ {
+ //
+ if (view.ToTable(true, new string[] { "" + headerRow.Cells[j].StringCellValue.Trim() + "" }).Rows.Count < table.Rows.Count)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{" + headerRow.Cells[j].StringCellValue + "}";
+ erro.ErrorCont = "{" + headerRow.Cells[j].StringCellValue + "}瀛楁鏈夐噸澶嶆暟鎹�";
+ list.Add(erro);
+ }
+ }
+ }
+ }
+ List<ExcelErro> stuList = list.OrderBy(s => s.RoeNumber).ToList<ExcelErro>();
+ return list;
+ }
+ /// <summary>
+ /// Excel 2涓猄heet 鏁版嵁楠岃瘉
+ /// </summary>
+ /// <param name="file">瀵煎叆璺緞(鍖呭惈鏂囦欢鍚嶄笌鎵╁睍鍚�)</param>
+ /// <returns></returns>
+ public static List<ExcelErro> ExcelToTableListErro(string file)
+ {
+ List<ExcelErro> list = new List<ExcelErro>();
+ IWorkbook Workbook;
+ bool iscell = false;
+ int iscellCount = 0;
+ try
+ {
+ using (FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read))
+ {
+ //XSSFWorkbook 閫傜敤XLSX鏍煎紡锛孒SSFWorkbook 閫傜敤XLS鏍煎紡
+ string fileExt = Path.GetExtension(file).ToLower();
+ if (fileExt == ".xls")
+ {
+ Workbook = new HSSFWorkbook(fileStream);
+ }
+ else if (fileExt == ".xlsx")
+ {
+ Workbook = new XSSFWorkbook(fileStream);
+ }
+ else
+ {
+ Workbook = null;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ for (int mm = 0; mm < 2; mm++)
+ {
+ DataTable table = new DataTable();
+ //瀹氫綅鍦ㄧ涓�涓猻heet
+ ISheet sheet = Workbook.GetSheetAt(mm);
+ //sheet.ShiftRows(sheet.FirstRowNum-1, sheet.LastRowNum,1);
+ //绗竴琛屼负鏍囬琛�
+ IRow headerRow = sheet.GetRow(0);
+ int cellCount = headerRow.LastCellNum;
+ int rowCount0 = sheet.FirstRowNum;
+ //int rowCount = sheet.LastRowNum;
+ int rowCount = Rownum(headerRow, cellCount, sheet, sheet.LastRowNum); //鑾峰彇鍒犻櫎绌鸿涔嬪悗鐨勬暟鎹 (鍙拡瀵逛簬鏈�鍚庢暟鎹」鏈夌┖琛岀殑)
+ if (rowCount - rowCount0 >= 1)
+ {
+ //-------------鍒ゆ柇蹇呭~椤规槸鍚︿负绌�----------------//
+ //寰幆鏁版嵁琛�
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ iscell = false;
+ iscellCount = 0;
+ IRow row = sheet.GetRow(i);
+ //鍒ゆ柇鏄惁鏈夌┖琛�
+ if (row == null)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = (i + 1).ToString();
+ erro.ErrorField = "绌鸿";
+ erro.ErrorCont = "绌鸿";
+ list.Add(erro);
+ continue;
+ }
+ //鍒ゆ柇鏄惁瀛樺湪绌烘暟鎹
+ for (int c = 0; c < cellCount; c++)
+ {
+ if (GetCellValue(row.GetCell(c)).Trim() != null && GetCellValue(row.GetCell(c)).Trim() != "")
+ {
+ iscell = false;
+ }
+ else
+ {
+ iscell = true;
+ iscellCount++;
+ }
+ }
+ if (iscell == true && iscellCount == cellCount) //绌鸿
+ {
+ continue;
+ }
+ else
+ {
+ //寰幆鏍囬鍒�
+ for (int j = headerRow.FirstCellNum; j < cellCount; j++)
+ {
+ //鑾峰彇鍗曞厓鏍肩殑濉厖鑹�
+ string rgb = headerRow.Cells[j].CellStyle.FillForegroundColor.ToString();
+ if (rgb == "51") //蹇呭~椤瑰瓧娈靛垪澶村~鍏呰壊
+ {
+ if (sheet.GetRow(i) == null || sheet.GetRow(i).ToString() == "") //瀛樺湪绌鸿
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = i.ToString();
+ erro.ErrorField = "{绗�" + i.ToString() + "琛寎";
+ erro.ErrorCont = "{绗�" + i.ToString() + "}琛屼负绌�";
+ list.Add(erro);
+ break;
+ }
+ else
+ {
+ string cellValue = GetCellValue(sheet.GetRow(i).GetCell(j)).Trim(); //GetCell:杩斿洖鍖呮嫭绌哄垪鍊� Cells:鍙繑鍥炴湁鍊肩殑鍒�
+ if (cellValue == "" || cellValue == null)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = (sheet.GetRow(i).RowNum + 1).ToString();
+ erro.ErrorField = "{" + headerRow.Cells[j].StringCellValue + "}";
+ erro.ErrorCont = mm == 0 ? "涓昏〃涓細" + "{" + headerRow.Cells[j].StringCellValue + "}瀛楁涓嶈兘涓虹┖" : "瀛愯〃涓細" + "{" + headerRow.Cells[j].StringCellValue + "}瀛楁涓嶈兘涓虹┖";
+ list.Add(erro);
+ }
+ }
+ }
+
+ }
+ }
+ }
+ //-------------鍒ゆ柇鍞竴椤规槸鍚﹂噸澶�----------------//
+ //寰幆娣诲姞鏍囬鍒�
+ for (int i = headerRow.FirstCellNum; i < cellCount; i++)
+ {
+ DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
+ table.Columns.Add(column);
+ }
+
+ //鏁版嵁
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ IRow row = sheet.GetRow(i);
+ DataRow dataRow = table.NewRow();
+ if (row != null)
+ {
+ for (int j = row.FirstCellNum; j < cellCount; j++)
+ {
+ if (row.GetCell(j) != null)
+ {
+ dataRow[j] = GetCellValue(row.GetCell(j)).Trim();
+ }
+ }
+ }
+ table.Rows.Add(dataRow);
+ }
+ //娓呴櫎鏈�鍚庣殑绌鸿
+ for (int i = 0; i < table.Rows.Count; i++)
+ {
+ bool isnull = true;
+ for (int j = 0; j < table.Columns.Count; j++)
+ {
+ if (table.Rows[i][j].ToString() != null && table.Rows[i][j].ToString() != "")
+ {
+ if (table.Rows[i][j].ToString().Trim() != "" && table.Rows[i][j].ToString().Trim() != null)
+ {
+ isnull = false;
+ break;
+ }
+ }
+ }
+ if (isnull)
+ {
+ table.Rows[i].Delete();
+ i = 0;
+ }
+ }
+ DataView view = new DataView(table);
+ //鑾峰彇鎵�鏈夊敮涓�鍒�
+ List<string> list0 = new List<string>();
+ //寰幆鏍囬鍒�
+ for (int j = headerRow.FirstCellNum; j < cellCount; j++)
+ {
+ bool isContain = headerRow.Cells[j].StringCellValue.Contains("鍞竴"); //鏍囬鍒椾腑鐨勫繀濉垪
+ if (isContain == true)
+ {
+ //
+ if (view.ToTable(true, new string[] { "" + headerRow.Cells[j].StringCellValue + "" }).Rows.Count < table.Rows.Count)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{" + headerRow.Cells[j].StringCellValue + "}";
+ erro.ErrorCont = mm == 0 ? "涓昏〃涓細" + "{" + headerRow.Cells[j].StringCellValue + "}瀛楁鏈夐噸澶嶆暟鎹�" : "瀛愯〃涓細" + "{" + headerRow.Cells[j].StringCellValue + "}瀛楁鏈夐噸澶嶆暟鎹�";
+ list.Add(erro);
+ }
+ }
+ }
+ }
+ }
+ List<ExcelErro> stuList = list.OrderBy(s => s.RoeNumber).ToList<ExcelErro>();
+ return list;
+ }
+
+ /// <summary>
+ /// Excel 3涓猄heet 鏁版嵁楠岃瘉
+ /// </summary>
+ /// <param name="file">瀵煎叆璺緞(鍖呭惈鏂囦欢鍚嶄笌鎵╁睍鍚�)</param>
+ /// <returns></returns>
+ public static List<ExcelErro> ExcelToThreeTableListErro(string file)
+ {
+ List<ExcelErro> list = new List<ExcelErro>();
+ IWorkbook Workbook;
+ bool iscell = false;
+ int iscellCount = 0;
+ try
+ {
+ using (FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read))
+ {
+ //XSSFWorkbook 閫傜敤XLSX鏍煎紡锛孒SSFWorkbook 閫傜敤XLS鏍煎紡
+ string fileExt = Path.GetExtension(file).ToLower();
+ if (fileExt == ".xls")
+ {
+ Workbook = new HSSFWorkbook(fileStream);
+ }
+ else if (fileExt == ".xlsx")
+ {
+ Workbook = new XSSFWorkbook(fileStream);
+ }
+ else
+ {
+ Workbook = null;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ for (int mm = 0; mm < 3; mm++)
+ {
+ DataTable table = new DataTable();
+ //瀹氫綅鍦ㄧ涓�涓猻heet
+ ISheet sheet = Workbook.GetSheetAt(mm);
+ //sheet.ShiftRows(sheet.FirstRowNum-1, sheet.LastRowNum,1);
+ //绗竴琛屼负鏍囬琛�
+ IRow headerRow = sheet.GetRow(0);
+ int cellCount = headerRow.LastCellNum;
+ int rowCount0 = sheet.FirstRowNum;
+ //int rowCount = sheet.LastRowNum;
+ int rowCount = Rownum(headerRow, cellCount, sheet, sheet.LastRowNum); //鑾峰彇鍒犻櫎绌鸿涔嬪悗鐨勬暟鎹 (鍙拡瀵逛簬鏈�鍚庢暟鎹」鏈夌┖琛岀殑)
+ if (rowCount - rowCount0 >= 1)
+ {
+ //-------------鍒ゆ柇蹇呭~椤规槸鍚︿负绌�----------------//
+ //寰幆鏁版嵁琛�
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ iscell = false;
+ iscellCount = 0;
+ IRow row = sheet.GetRow(i);
+ //鍒ゆ柇鏄惁鏈夌┖琛�
+ if (row == null)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = (i + 1).ToString();
+ erro.ErrorField = "绌鸿";
+ erro.ErrorCont = "绌鸿";
+ list.Add(erro);
+ continue;
+ }
+ //鍒ゆ柇鏄惁瀛樺湪绌烘暟鎹
+ for (int c = 0; c < cellCount; c++)
+ {
+ if (GetCellValue(row.GetCell(c)).Trim() != null && GetCellValue(row.GetCell(c)).Trim() != "")
+ {
+ iscell = false;
+ }
+ else
+ {
+ iscell = true;
+ iscellCount++;
+ }
+ }
+ if (iscell == true && iscellCount == cellCount) //绌鸿
+ {
+ continue;
+ }
+ else
+ {
+ //寰幆鏍囬鍒�
+ for (int j = headerRow.FirstCellNum; j < cellCount; j++)
+ {
+ //鑾峰彇鍗曞厓鏍肩殑濉厖鑹�
+ string rgb = headerRow.Cells[j].CellStyle.FillForegroundColor.ToString();
+ if (rgb == "51") //蹇呭~椤瑰瓧娈靛垪澶村~鍏呰壊
+ {
+ if (sheet.GetRow(i) == null || sheet.GetRow(i).ToString() == "") //瀛樺湪绌鸿
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = i.ToString();
+ erro.ErrorField = "{绗�" + i.ToString() + "琛寎";
+ erro.ErrorCont = "{绗�" + i.ToString() + "}琛屼负绌�";
+ list.Add(erro);
+ break;
+ }
+ else
+ {
+ string cellValue = GetCellValue(sheet.GetRow(i).GetCell(j)).Trim(); //GetCell:杩斿洖鍖呮嫭绌哄垪鍊� Cells:鍙繑鍥炴湁鍊肩殑鍒�
+ if (cellValue == "" || cellValue == null)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = (sheet.GetRow(i).RowNum + 1).ToString();
+ erro.ErrorField = "{" + headerRow.Cells[j].StringCellValue + "}";
+ erro.ErrorCont = mm == 0 ? "涓昏〃涓細" + "{" + headerRow.Cells[j].StringCellValue + "}瀛楁涓嶈兘涓虹┖" : "瀛愯〃涓細" + "{" + headerRow.Cells[j].StringCellValue + "}瀛楁涓嶈兘涓虹┖";
+ list.Add(erro);
+ }
+ }
+ }
+
+ }
+ }
+ }
+ //-------------鍒ゆ柇鍞竴椤规槸鍚﹂噸澶�----------------//
+ //寰幆娣诲姞鏍囬鍒�
+ for (int i = headerRow.FirstCellNum; i < cellCount; i++)
+ {
+ DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
+ table.Columns.Add(column);
+ }
+
+ //鏁版嵁
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ IRow row = sheet.GetRow(i);
+ DataRow dataRow = table.NewRow();
+ if (row != null)
+ {
+ for (int j = row.FirstCellNum; j < cellCount; j++)
+ {
+ if (row.GetCell(j) != null)
+ {
+ dataRow[j] = GetCellValue(row.GetCell(j)).Trim();
+ }
+ }
+ }
+ table.Rows.Add(dataRow);
+ }
+ //娓呴櫎鏈�鍚庣殑绌鸿
+ for (int i = 0; i < table.Rows.Count; i++)
+ {
+ bool isnull = true;
+ for (int j = 0; j < table.Columns.Count; j++)
+ {
+ if (table.Rows[i][j].ToString() != null && table.Rows[i][j].ToString() != "")
+ {
+ if (table.Rows[i][j].ToString().Trim() != "" && table.Rows[i][j].ToString().Trim() != null)
+ {
+ isnull = false;
+ break;
+ }
+ }
+ }
+ if (isnull)
+ {
+ table.Rows[i].Delete();
+ i = 0;
+ }
+ }
+ DataView view = new DataView(table);
+ //鑾峰彇鎵�鏈夊敮涓�鍒�
+ List<string> list0 = new List<string>();
+ //寰幆鏍囬鍒�
+ for (int j = headerRow.FirstCellNum; j < cellCount; j++)
+ {
+ bool isContain = headerRow.Cells[j].StringCellValue.Contains("鍞竴"); //鏍囬鍒椾腑鐨勫繀濉垪
+ if (isContain == true)
+ {
+ //
+ if (view.ToTable(true, new string[] { "" + headerRow.Cells[j].StringCellValue + "" }).Rows.Count < table.Rows.Count)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{" + headerRow.Cells[j].StringCellValue + "}";
+ erro.ErrorCont = mm == 0 ? "涓昏〃涓細" + "{" + headerRow.Cells[j].StringCellValue + "}瀛楁鏈夐噸澶嶆暟鎹�" : "瀛愯〃涓細" + "{" + headerRow.Cells[j].StringCellValue + "}瀛楁鏈夐噸澶嶆暟鎹�";
+ list.Add(erro);
+ }
+ }
+ }
+ }
+ }
+ List<ExcelErro> stuList = list.OrderBy(s => s.RoeNumber).ToList<ExcelErro>();
+ return list;
+ }
+
+
+
+
+
+
+
+ #region銆愭暟鎹噺楠岃瘉銆�
+ public static ToMessage ExcelCheckCountSum(string file)
+ {
+ IWorkbook Workbook;
+ try
+ {
+ using (FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read))
+ {
+ //XSSFWorkbook 閫傜敤XLSX鏍煎紡锛孒SSFWorkbook 閫傜敤XLS鏍煎紡
+ string fileExt = Path.GetExtension(file).ToLower();
+ if (fileExt == ".xls")
+ {
+ Workbook = new HSSFWorkbook(fileStream);
+ }
+ else if (fileExt == ".xlsx")
+ {
+ Workbook = new XSSFWorkbook(fileStream);
+ }
+ else
+ {
+ Workbook = null;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ int count = Workbook.NumberOfSheets; //鑾峰彇鎵�鏈塖heetName
+ if (count < 2)
+ {
+ DataTable table = new DataTable();
+ //瀹氫綅鍦ㄧ涓�涓猻heet
+ ISheet sheet = Workbook.GetSheetAt(0);
+ //绗竴琛屼负鏍囬琛�
+ IRow headerRow = sheet.GetRow(0);
+ int cellCount = headerRow.LastCellNum;
+ int rowCount = sheet.LastRowNum;
+
+ //寰幆娣诲姞鏍囬鍒�
+ for (int i = headerRow.FirstCellNum; i < cellCount; i++)
+ {
+ DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
+ table.Columns.Add(column);
+ }
+
+ //鏁版嵁
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ IRow row = sheet.GetRow(i);
+ DataRow dataRow = table.NewRow();
+ if (row != null)
+ {
+ for (int j = row.FirstCellNum; j < cellCount; j++)
+ {
+ if (row.GetCell(j) != null)
+ {
+ dataRow[j] = GetCellValue(row.GetCell(j)).Trim();
+ }
+ }
+ }
+ table.Rows.Add(dataRow);
+ }
+ //娓呴櫎鏈�鍚庣殑绌鸿
+ for (int i = 0; i < table.Rows.Count; i++)
+ {
+ bool isnull = true;
+ for (int j = 0; j < table.Columns.Count; j++)
+ {
+ if (table.Rows[i][j] != null)
+ {
+ if (table.Rows[i][j].ToString().Trim() != "" && table.Rows[i][j].ToString().Trim() != null)
+ {
+ isnull = false;
+ break;
+ }
+ }
+ }
+ if (isnull)
+ {
+ table.Rows[i].Delete();
+ }
+ }
+ if (table.Rows.Count <= 0)
+ {
+
+ mes.code = "300";
+ mes.Message = "鏂囦欢鏁版嵁涓嶈兘涓虹┖锛�";
+
+ }
+ }
+ else
+ {
+ for (int m = 0; m < 2; m++)
+ {
+ DataTable table = new DataTable();
+ //瀹氫綅鍦ㄧ涓�涓猻heet
+ ISheet sheet = Workbook.GetSheetAt(m);
+ //绗竴琛屼负鏍囬琛�
+ IRow headerRow = sheet.GetRow(0);
+ int cellCount = headerRow.LastCellNum;
+ int rowCount = sheet.LastRowNum;
+
+ //寰幆娣诲姞鏍囬鍒�
+ for (int i = headerRow.FirstCellNum; i < cellCount; i++)
+ {
+ DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
+ table.Columns.Add(column);
+ }
+
+ //鏁版嵁
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ IRow row = sheet.GetRow(i);
+ DataRow dataRow = table.NewRow();
+ if (row != null)
+ {
+ for (int j = row.FirstCellNum; j < cellCount; j++)
+ {
+ if (row.GetCell(j) != null)
+ {
+ dataRow[j] = GetCellValue(row.GetCell(j)).Trim();
+ }
+ }
+ }
+ table.Rows.Add(dataRow);
+ }
+ //娓呴櫎鏈�鍚庣殑绌鸿
+ for (int i = 0; i < table.Rows.Count; i++)
+ {
+ bool isnull = true;
+ for (int j = 0; j < table.Columns.Count; j++)
+ {
+ if (table.Rows[i][j] != null)
+ {
+ if (table.Rows[i][j].ToString().Trim() != "" && table.Rows[i][j].ToString().Trim() != null)
+ {
+ isnull = false;
+ break;
+ }
+ }
+ }
+ if (isnull)
+ {
+ table.Rows[i].Delete();
+ }
+ }
+ if (table.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.Message = "涓诲瓙琛ㄦ枃浠朵腑鏁版嵁涓嶈兘涓虹┖锛�";
+ }
+ }
+ }
+ return mes;
+ }
+
+ #endregion
+
+
+ #region銆愬幓闄ょ┖琛屽悗鑾峰彇琛屾暟銆�
+ public static int Rownum(IRow headerRow, int cellCount, ISheet sheet, int rowCount)
+ {
+ DataTable table = new DataTable();
+ //寰幆娣诲姞鏍囬鍒�
+ for (int i = headerRow.FirstCellNum; i < cellCount; i++)
+ {
+ DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
+ table.Columns.Add(column);
+ }
+
+ //鏁版嵁
+ for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
+ {
+ IRow row = sheet.GetRow(i);
+ DataRow dataRow = table.NewRow();
+ if (row != null)
+ {
+ for (int j = row.FirstCellNum; j < cellCount; j++)
+ {
+ if (row.GetCell(j) != null)
+ {
+ dataRow[j] = GetCellValue(row.GetCell(j)).Trim();
+ }
+ }
+ }
+ table.Rows.Add(dataRow);
+ }
+ //娓呴櫎鏈�鍚庣殑绌鸿
+ for (int i = 0; i < table.Rows.Count; i++)
+ {
+ bool isnull = true;
+ for (int j = 0; j < table.Columns.Count; j++)
+ {
+ if (table.Rows[i][j].ToString() != null && table.Rows[i][j].ToString() != "")
+ {
+ if (table.Rows[i][j].ToString().Trim() != "" && table.Rows[i][j].ToString().Trim() != null)
+ {
+ isnull = false;
+ break;
+ }
+ }
+ }
+ if (isnull)
+ {
+ table.Rows[i].Delete();
+ i = 0;
+ }
+ }
+ return table.Rows.Count;
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/Tools/ImportExcelData.cs b/VueWebCoreApi/Tools/ImportExcelData.cs
new file mode 100644
index 0000000..45efc88
--- /dev/null
+++ b/VueWebCoreApi/Tools/ImportExcelData.cs
@@ -0,0 +1,4472 @@
+锘縰sing Dapper;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Models;
+
+namespace VueWebCoreApi.Tools
+{
+ public class ImportExcelData
+ {
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉銆�
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,鐢ㄦ埛娓呭崟妯℃澘銆�
+ public static string Two(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 4)
+ {
+ code = "300";
+ Message = "瀵煎叆妯℃澘涓嶇鍚堣鑼�,璇锋鏌heet鏁�";
+ return Message;
+
+ }
+ else if (excelTable[0].Columns.Count != 5)
+ {
+ code = "300";
+ Message = "鐢ㄦ埛鐝粍妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[1].Columns.Count != 10)
+ {
+ code = "300";
+ Message = "鐢ㄦ埛娓呭崟妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛鐝粍妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "缁勭粐缂栫爜")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛鐝粍妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕缁勭粐缂栫爜}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "鐝粍缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛鐝粍妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕鐝粍缂栧彿(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "鐝粍鍚嶇О")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛鐝粍妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�3鍒楀簲涓簕鐝粍鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[4].ColumnName != "鐝粍鎻忚堪")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛鐝粍妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�4鍒楀簲涓簕鐝粍鎻忚堪}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[1].ColumnName != "鐢ㄦ埛缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕鐢ㄦ埛缂栧彿(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[2].ColumnName != "鐢ㄦ埛濮撳悕")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�3鍒楀簲涓簕鐢ㄦ埛濮撳悕}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[3].ColumnName != "鍦ㄨ亴鐘舵��")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�4鍒楀簲涓簕鍦ㄨ亴鐘舵�亇";
+ return Message;
+ }
+ else if (excelTable[1].Columns[4].ColumnName != "瀵嗙爜")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�5鍒楀簲涓簕瀵嗙爜}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[5].ColumnName != "鎵嬫満鍙�")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�6鍒楀簲涓簕鎵嬫満鍙穧";
+ return Message;
+ }
+ else if (excelTable[1].Columns[6].ColumnName != "閭")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�7鍒楀簲涓簕閭}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[7].ColumnName != "缁勭粐缂栫爜")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�8鍒楀簲涓簕缁勭粐缂栫爜}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[8].ColumnName != "宸ヨ祫绫诲瀷")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�9鍒楀簲涓簕宸ヨ祫绫诲瀷}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[9].ColumnName != "鐢ㄦ埛缁勭紪鐮�")
+ {
+ code = "300";
+ Message = "鐢ㄦ埛娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�10鍒楀簲涓簕鐢ㄦ埛缁勭紪鐮亇";
+ return Message;
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,瑙掕壊鏉冮檺妯℃澘銆�
+ public static string One(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 4)
+ {
+ code = "300";
+ Message = "瀵煎叆妯℃澘涓嶇鍚堣鑼�,璇锋鏌heet鏁�";
+ return Message;
+
+ }
+ else if (excelTable[0].Columns.Count != 4)
+ {
+ code = "300";
+ Message = "瑙掕壊绫诲瀷妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[1].Columns.Count != 6)
+ {
+ code = "300";
+ Message = "妯℃澘瑙掕壊娓呭崟涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "瑙掕壊绫诲瀷妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "缁勭粐缂栫爜")
+ {
+ code = "300";
+ Message = "瑙掕壊绫诲瀷妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕缁勭粐缂栫爜}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "瑙掕壊绫诲瀷缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "瑙掕壊绫诲瀷妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕瑙掕壊绫诲瀷缂栧彿(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "瑙掕壊绫诲瀷鍚嶇О")
+ {
+ code = "300";
+ Message = "瑙掕壊绫诲瀷妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�3鍒楀簲涓簕瑙掕壊绫诲瀷鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "瑙掕壊娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[1].ColumnName != "缁勭粐缂栫爜")
+ {
+ code = "300";
+ Message = "瑙掕壊娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕缁勭粐缂栫爜}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[2].ColumnName != "瑙掕壊缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "瑙掕壊娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕瑙掕壊缂栧彿(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[3].ColumnName != "瑙掕壊濮撳悕")
+ {
+ code = "300";
+ Message = "瑙掕壊娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�3鍒楀簲涓簕瑙掕壊濮撳悕}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[4].ColumnName != "瑙掕壊绫诲瀷缂栫爜")
+ {
+ code = "300";
+ Message = "瑙掕壊娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�4鍒楀簲涓簕瑙掕壊绫诲瀷缂栫爜}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[5].ColumnName != "瑙掕壊鎻忚堪")
+ {
+ code = "300";
+ Message = "瑙掕壊娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�5鍒楀簲涓簕瑙掕壊鎻忚堪}";
+ return Message;
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,宸ヤ綅娓呭崟妯℃澘銆�
+ public static string Three(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ DataTable excelTable = new DataTable();
+ excelTable = ImportExcel.ExcelToTable(FileCode);
+ if (excelTable.Columns.Count != 9)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[1].ColumnName != "宸ヤ綅缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[2].ColumnName != "宸ヤ綅鍚嶇О锛堝敮涓�锛�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[3].ColumnName != "宸ヤ綅绫诲瀷")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[4].ColumnName != "鎵�灞炶溅闂�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[5].ColumnName != "鎵�灞炰骇绾�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[6].ColumnName != "浣跨敤鐘舵��")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[7].ColumnName != "鏁伴噰鏍囪瘑1")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[8].ColumnName != "鏁伴噰鏍囪瘑2")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,寰�鏉ュ崟浣嶆竻鍗曟ā鏉裤��
+ public static string Four(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 2)
+ {
+ code = "300";
+ Message = "瀵煎叆妯℃澘涓嶇鍚堣鑼�,璇锋鏌heet鏁�";
+ return Message;
+
+ }
+ else if (excelTable[0].Columns.Count != 7)
+ {
+ code = "300";
+ Message = "寰�鏉ュ崟浣嶆ā鏉夸笉绗﹀悎瑙勮寖,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "寰�鏉ュ崟浣嶆ā鏉夸笉绗﹀悎瑙勮寖锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "寰�鏉ュ崟浣嶇紪鍙�(鍞竴)")
+ {
+ code = "300";
+ Message = "寰�鏉ュ崟浣嶆ā鏉夸笉绗﹀悎瑙勮寖锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕寰�鏉ュ崟浣嶇紪鍙�(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "寰�鏉ュ崟浣嶅悕绉�")
+ {
+ code = "300";
+ Message = "寰�鏉ュ崟浣嶆ā鏉夸笉绗﹀悎瑙勮寖锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�3鍒楀簲涓簕寰�鏉ュ崟浣嶅悕绉皚";
+ return Message;
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "寰�鏉ュ崟浣嶅睘鎬�")
+ {
+ code = "300";
+ Message = "寰�鏉ュ崟浣嶆ā鏉夸笉绗﹀悎瑙勮寖锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�4鍒楀簲涓簕寰�鏉ュ崟浣嶅睘鎬";
+ return Message;
+ }
+ else if (excelTable[0].Columns[4].ColumnName != "鑱旂郴浜�")
+ {
+ code = "300";
+ Message = "寰�鏉ュ崟浣嶆ā鏉夸笉绗﹀悎瑙勮寖锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�5鍒楀簲涓簕鑱旂郴浜簘";
+ return Message;
+ }
+ else if (excelTable[0].Columns[5].ColumnName != "鑱旂郴鏂瑰紡")
+ {
+ code = "300";
+ Message = "寰�鏉ュ崟浣嶆ā鏉夸笉绗﹀悎瑙勮寖锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�6鍒楀簲涓簕鑱旂郴鏂瑰紡}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[6].ColumnName != "鍦板潃")
+ {
+ code = "300";
+ Message = "寰�鏉ュ崟浣嶆ā鏉夸笉绗﹀悎瑙勮寖锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�7鍒楀簲涓簕鍦板潃}";
+ return Message;
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,浠撳簱銆佸簱浣嶅畾涔夋ā鏉裤��
+ public static string SixOne(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 4)
+ {
+ code = "300";
+ Message = "瀵煎叆妯℃澘涓嶇鍚堣鑼�,璇锋鏌heet鏁�";
+ return Message;
+
+ }
+ else if (excelTable[0].Columns.Count != 4)
+ {
+ code = "300";
+ Message = "浠撳簱娓呭崟妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[1].Columns.Count != 5)
+ {
+ code = "300";
+ Message = "搴撲綅娓呭崟妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "浠撳簱娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "浠撳簱缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "浠撳簱娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕浠撳簱缂栧彿(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "浠撳簱鍚嶇О")
+ {
+ code = "300";
+ Message = "浠撳簱娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�3鍒楀簲涓簕浠撳簱鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "浠撳簱鎻忚堪")
+ {
+ code = "300";
+ Message = "浠撳簱娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�4鍒楀簲涓簕浠撳簱鎻忚堪}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "搴撲綅娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[1].ColumnName != "搴撲綅缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "搴撲綅娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕搴撲綅缂栧彿(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[2].ColumnName != "搴撲綅濮撳悕")
+ {
+ code = "300";
+ Message = "搴撲綅娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�3鍒楀簲涓簕搴撲綅濮撳悕}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[3].ColumnName != "鎵�灞炰粨搴撶紪鐮�")
+ {
+ code = "300";
+ Message = "搴撲綅娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�4鍒楀簲涓簕鎵�灞炰粨搴撶紪鐮亇";
+ return Message;
+ }
+ else if (excelTable[1].Columns[4].ColumnName != "搴撲綅鎻忚堪")
+ {
+ code = "300";
+ Message = "搴撲綅娓呭崟妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�5鍒楀簲涓簕搴撲綅鎻忚堪}";
+ return Message;
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,瀹瑰櫒瀹氫箟妯℃澘銆�
+ public static string Seven(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ DataTable excelTable = new DataTable();
+ excelTable = ImportExcel.ExcelToTable(FileCode);
+ if (excelTable.Columns.Count != 5)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[1].ColumnName != "瀹瑰櫒缂栫爜(鍞竴)")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[2].ColumnName != "瀹瑰櫒鍚嶇О锛堝敮涓�锛�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[3].ColumnName != "瀹瑰櫒鑷噸锛圞G锛�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[4].ColumnName != "瀹瑰櫒绫诲瀷")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,瀛樿揣妗f妯℃澘銆�
+ public static string Eight(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ DataTable excelTable = new DataTable();
+ excelTable = ImportExcel.ExcelToTable(FileCode);
+ if (excelTable.Columns.Count != 11)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[1].ColumnName != "鐗╂枡缂栫爜(鍞竴)")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[2].ColumnName != "鐗╂枡鍚嶇О")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[3].ColumnName != "鐗╂枡瑙勬牸")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[4].ColumnName != "涓诲崟浣�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[5].ColumnName != "杈呭崟浣�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[6].ColumnName != "杈�/涓�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[7].ColumnName != "鐗╂枡绫诲埆")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[8].ColumnName != "浠撳簱鍚嶇О")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[9].ColumnName != "搴撳瓨涓嬮檺")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[10].ColumnName != "搴撳瓨涓婇檺")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,璁惧娓呭崟妯℃澘銆�
+ public static string Nine(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 2)
+ {
+ code = "300";
+ Message = "瀵煎叆妯℃澘涓嶇鍚堣鑼�,璇锋鏌heet鏁�";
+ }
+ else if (excelTable[0].Columns.Count != 7)
+ {
+ code = "300";
+ Message = "璁惧娓呭崟妯℃澘(璁惧娓呭崟)涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "璁惧娓呭崟妯℃澘(璁惧娓呭崟)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "璁惧缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "璁惧娓呭崟妯℃澘(璁惧娓呭崟)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕璁惧缂栧彿(鍞竴)}";
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "璁惧鍚嶇О")
+ {
+ code = "300";
+ Message = "璁惧娓呭崟妯℃澘(璁惧娓呭崟)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕璁惧鍚嶇О}";
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "鎶曞叆鏃ユ湡")
+ {
+ code = "300";
+ Message = "璁惧娓呭崟妯℃澘(璁惧娓呭崟)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕鎶曞叆鏃ユ湡}";
+ }
+ else if (excelTable[0].Columns[4].ColumnName != "杞﹂棿缂栫爜")
+ {
+ code = "300";
+ Message = "璁惧娓呭崟妯℃澘(璁惧娓呭崟)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕杞﹂棿缂栫爜}";
+ }
+ else if (excelTable[0].Columns[5].ColumnName != "浣跨敤鐘舵��")
+ {
+ code = "300";
+ Message = "璁惧娓呭崟妯℃澘(璁惧娓呭崟)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕浣跨敤鐘舵�亇";
+ }
+ else if (excelTable[0].Columns[6].ColumnName != "绋煎姩鐜囷紙%锛�")
+ {
+ code = "300";
+ Message = "璁惧娓呭崟妯℃澘(璁惧娓呭崟)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕绋煎姩鐜囷紙%锛墋";
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,璁惧鐐规椤圭洰妯℃澘銆�
+ public static string Ten(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 2)
+ {
+ code = "300";
+ Message = "瀵煎叆妯℃澘涓嶇鍚堣鑼�,璇锋鏌heet鏁�";
+ return Message;
+
+ }
+ else if (excelTable[0].Columns.Count != 6)
+ {
+ code = "300";
+ Message = "璁惧鐐规椤圭洰妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "璁惧鐐规椤圭洰妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "鐐规椤圭洰缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "璁惧鐐规椤圭洰妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�2鍒楀簲涓簕鐐规椤圭洰缂栧彿(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "鐐规椤圭洰鍚嶇О")
+ {
+ code = "300";
+ Message = "璁惧鐐规椤圭洰妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�3鍒楀簲涓簕鐐规椤圭洰鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "鐐规鍛ㄦ湡")
+ {
+ code = "300";
+ Message = "璁惧鐐规椤圭洰妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�4鍒楀簲涓簕鐐规鍛ㄦ湡}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[4].ColumnName != "鏄惁鎵爜")
+ {
+ code = "300";
+ Message = "璁惧鐐规椤圭洰妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�4鍒楀簲涓簕鏄惁鎵爜}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[5].ColumnName != "鐐规椤圭洰瑕佹眰")
+ {
+ code = "300";
+ Message = "璁惧鐐规椤圭洰妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�4鍒楀簲涓簕鐐规椤圭洰瑕佹眰}";
+ return Message;
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,璁惧鐐规鏍囧噯妯℃澘銆�
+ public static string TwentyTwo(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 4)
+ {
+ code = "300";
+ Message = "瀵煎叆妯℃澘涓嶇鍚堣鑼�,璇锋鏌heet鏁�";
+ return Message;
+
+ }
+ else if (excelTable[0].Columns.Count != 5)
+ {
+ code = "300";
+ Message = "璁惧鐐规鏍囧噯椤电妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[1].Columns.Count != 8)
+ {
+ code = "300";
+ Message = "璁惧鐐规閮ㄤ綅椤电妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "璁惧鐐规鏍囧噯椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "璁惧鐐规鏍囧噯缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "璁惧鐐规鏍囧噯椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕璁惧鐐规鏍囧噯缂栧彿(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "璁惧鐐规鏍囧噯鍚嶇О")
+ {
+ code = "300";
+ Message = "璁惧鐐规鏍囧噯椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�3鍒楀簲涓簕璁惧鐐规鏍囧噯鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "鐐规绠℃帶")
+ {
+ code = "300";
+ Message = "璁惧鐐规鏍囧噯椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�4鍒楀簲涓簕鐐规绠℃帶}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[4].ColumnName != "鏍囧噯鎻忚堪")
+ {
+ code = "300";
+ Message = "璁惧鐐规鏍囧噯椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�5鍒楀簲涓簕鏍囧噯鎻忚堪}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "璁惧鐐规閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[1].ColumnName != "鐐规椤瑰簭鍙�")
+ {
+ code = "300";
+ Message = "璁惧鐐规閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕鐐规椤瑰簭鍙穧";
+ return Message;
+ }
+ else if (excelTable[1].Columns[2].ColumnName != "璁惧鐐规鏍囧噯缂栧彿")
+ {
+ code = "300";
+ Message = "璁惧鐐规閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�3鍒楀簲涓簕璁惧鐐规鏍囧噯缂栧彿}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[3].ColumnName != "璁惧鐐规閮ㄤ綅缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "璁惧鐐规閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�4鍒楀簲涓簕璁惧鐐规閮ㄤ綅缂栧彿(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[4].ColumnName != "璁惧鐐规閮ㄤ綅鍚嶇О")
+ {
+ code = "300";
+ Message = "璁惧鐐规閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�5鍒楀簲涓簕璁惧鐐规閮ㄤ綅鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[5].ColumnName != "鐐规閮ㄤ綅瑕佹眰")
+ {
+ code = "300";
+ Message = "璁惧鐐规閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�6鍒楀簲涓簕鐐规閮ㄤ綅瑕佹眰}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[6].ColumnName != "閫夋嫨鎵爜")
+ {
+ code = "300";
+ Message = "璁惧鐐规閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�7鍒楀簲涓簕閫夋嫨鎵爜}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[7].ColumnName != "鐐规鍛ㄦ湡")
+ {
+ code = "300";
+ Message = "璁惧鐐规閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�8鍒楀簲涓簕鐐规鍛ㄦ湡}";
+ return Message;
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,璁惧淇濆吇椤圭洰妯℃澘銆�
+ public static string Eleven(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 2)
+ {
+ code = "300";
+ Message = "瀵煎叆妯℃澘涓嶇鍚堣鑼�,璇锋鏌heet鏁�";
+ return Message;
+
+ }
+ else if (excelTable[0].Columns.Count != 5)
+ {
+ code = "300";
+ Message = "璁惧淇濆吇椤圭洰妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇椤圭洰妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "淇濆吇椤圭洰缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇椤圭洰妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�2鍒楀簲涓簕淇濆吇椤圭洰缂栧彿(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "淇濆吇椤圭洰鍚嶇О")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇椤圭洰妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�3鍒楀簲涓簕淇濆吇椤圭洰鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "鏄惁鎵爜")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇椤圭洰妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�4鍒楀簲涓簕鏄惁鎵爜}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[4].ColumnName != "淇濆吇椤圭洰瑕佹眰")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇椤圭洰妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�4鍒楀簲涓簕淇濆吇椤圭洰瑕佹眰}";
+ return Message;
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,璁惧淇濆吇鏍囧噯妯℃澘銆�
+ public static string TwentyThree(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 4)
+ {
+ code = "300";
+ Message = "瀵煎叆妯℃澘涓嶇鍚堣鑼�,璇锋鏌heet鏁�";
+ return Message;
+
+ }
+ else if (excelTable[0].Columns.Count != 5)
+ {
+ code = "300";
+ Message = "璁惧淇濆吇鏍囧噯椤电妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[1].Columns.Count != 7)
+ {
+ code = "300";
+ Message = "璁惧淇濆吇閮ㄤ綅椤电妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "璁惧鐐规鏍囧噯椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "璁惧淇濆吇鏍囧噯缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇鏍囧噯椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕璁惧淇濆吇鏍囧噯缂栧彿(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "璁惧淇濆吇鏍囧噯鍚嶇О")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇鏍囧噯椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�3鍒楀簲涓簕璁惧淇濆吇鏍囧噯鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "淇濆吇鍛ㄦ湡")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇鏍囧噯椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�4鍒楀簲涓簕淇濆吇鍛ㄦ湡}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[4].ColumnName != "鏍囧噯鎻忚堪")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇鏍囧噯椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�5鍒楀簲涓簕鏍囧噯鎻忚堪}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "璁惧鐐规閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[1].ColumnName != "淇濆吇椤瑰簭鍙�")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕淇濆吇椤瑰簭鍙穧";
+ return Message;
+ }
+ else if (excelTable[1].Columns[2].ColumnName != "璁惧淇濆吇鏍囧噯缂栧彿")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�3鍒楀簲涓簕璁惧淇濆吇鏍囧噯缂栧彿}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[3].ColumnName != "璁惧淇濆吇閮ㄤ綅缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�4鍒楀簲涓簕璁惧淇濆吇閮ㄤ綅缂栧彿(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[4].ColumnName != "璁惧淇濆吇閮ㄤ綅鍚嶇О")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�5鍒楀簲涓簕璁惧淇濆吇閮ㄤ綅鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[5].ColumnName != "淇濆吇閮ㄤ綅瑕佹眰")
+ {
+ code = "300";
+ Message = "璁惧淇濆吇閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�6鍒楀簲涓簕淇濆吇閮ㄤ綅瑕佹眰}";
+ return Message;
+ }
+ else if (excelTable[1].Columns[6].ColumnName != "閫夋嫨鎵爜")
+ {
+ code = "300";
+ Message = "璁惧鐐规閮ㄤ綅椤电妯℃澘锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�7鍒楀簲涓簕閫夋嫨鎵爜}";
+ return Message;
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,宸ヨ娓呭崟妯℃澘銆�
+ public static string Twelve(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ DataTable excelTable = new DataTable();
+ excelTable = ImportExcel.ExcelToTable(FileCode);
+ if (excelTable.Columns.Count != 7)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[1].ColumnName != "宸ヨ缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[2].ColumnName != "宸ヨ鍚嶇О锛堝敮涓�锛�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[3].ColumnName != "宸ヨ绫诲瀷")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[4].ColumnName != "鍨嬭厰鏁伴噺")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[5].ColumnName != "鐞嗚瀵垮懡锛堟锛�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[6].ColumnName != "浣跨敤鐘舵��")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,宸ヨ鐐规妯℃澘銆�
+ public static string Thirteen(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 2)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,缂哄け鐨凷heet";
+ }
+ else if (excelTable[0].Columns.Count != 3)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ }
+ else if (excelTable[1].Columns.Count != 8)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "鐐规鏍囧噯(鍞竴)")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "鏍囧噯鍚嶇О锛堝敮涓�锛�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[1].ColumnName != "鐐规鏍囧噯")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[2].ColumnName != "鏍囧噯鍚嶇О")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[3].ColumnName != "SEQ(閮ㄤ綅椤哄簭)")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[4].ColumnName != "閮ㄤ綅鏉$爜锛堝敮涓�锛�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[5].ColumnName != "閮ㄤ綅鍚嶇О")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[6].ColumnName != "鐐规瑕佹眰")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[7].ColumnName != "鐐规鍛ㄦ湡")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,宸ヨ淇濆吇妯℃澘銆�
+ public static string Fourteen(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 2)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,缂哄け鐨凷heet";
+ }
+ else if (excelTable[0].Columns.Count != 3)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ }
+ else if (excelTable[1].Columns.Count != 8)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "淇濆吇鏍囧噯(鍞竴)")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "鏍囧噯鍚嶇О锛堝敮涓�锛�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[1].ColumnName != "淇濆吇鏍囧噯")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[2].ColumnName != "鏍囧噯鍚嶇О")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[3].ColumnName != "SEQ(閮ㄤ綅椤哄簭)")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[4].ColumnName != "閮ㄤ綅鏉$爜锛堝敮涓�锛�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[5].ColumnName != "閮ㄤ綅鍚嶇О")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[6].ColumnName != "淇濆吇瑕佹眰")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[7].ColumnName != "淇濆吇绛夌骇")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,宸ュ簭瀹氫箟妯℃澘銆�
+ public static string Fifteen(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ DataTable excelTable = new DataTable();
+ excelTable = ImportExcel.ExcelToTable(FileCode);
+ if (excelTable.Columns.Count != 4)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[1].ColumnName != "宸ュ簭缂栫爜(鍞竴)")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[2].ColumnName != "宸ュ簭鍚嶇О锛堝敮涓�锛�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[3].ColumnName != "鍚敤鐘舵��")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,宸ヨ壓璺嚎妯℃澘銆�
+ public static string Sixteen(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 2)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,缂哄け鐨凷heet";
+ }
+ else if (excelTable[0].Columns.Count != 6)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ }
+ else if (excelTable[1].Columns.Count != 9)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "宸ヨ壓璺嚎(鍞竴)")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "鐗╂枡缂栫爜")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "鐗╂枡鍚嶇О")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[4].ColumnName != "鐢熶骇鍛ㄦ湡锛堝ぉ锛�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[5].ColumnName != "缁撴潫瑁呯")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[1].ColumnName != "宸ヨ壓璺嚎")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[2].ColumnName != "SEQ(鎺掑垪椤哄簭)")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[3].ColumnName != "宸ュ簭缂栫爜")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[4].ColumnName != "宸ュ簭鍚嶇О")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[5].ColumnName != "宸ュ簭妫�楠�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[6].ColumnName != "鍒濆鑺傛媿锛堢锛�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[7].ColumnName != "鍒濆鍨嬭厰鏁�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[8].ColumnName != "鍒濆宸ヤ环锛堝厓锛�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,鑺傛媿宸ヤ环妯℃澘銆�
+ public static string TwentyFour(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 2)
+ {
+ code = "300";
+ Message = "瀵煎叆妯℃澘涓嶇鍚堣鑼�,璇锋鏌heet鏁�";
+ return Message;
+
+ }
+ else if (excelTable[0].Columns.Count != 9)
+ {
+ code = "300";
+ Message = "鑺傛媿宸ヤ环妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "鑺傛媿宸ヤ环妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "浜у搧鍚嶇О")
+ {
+ code = "300";
+ Message = "浜у搧鍚嶇О妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�2鍒楀簲涓簕浜у搧鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "宸ヨ壓璺嚎鍚嶇О")
+ {
+ code = "300";
+ Message = "鑺傛媿宸ヤ环妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�3鍒楀簲涓簕宸ヨ壓璺嚎鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "宸ュ簭鍚嶇О")
+ {
+ code = "300";
+ Message = "鑺傛媿宸ヤ环妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�4鍒楀簲涓簕宸ュ簭鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[4].ColumnName != "璁惧鍚嶇О")
+ {
+ code = "300";
+ Message = "鑺傛媿宸ヤ环妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�4鍒楀簲涓簕璁惧鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[5].ColumnName != "璁′欢鍗曚环")
+ {
+ code = "300";
+ Message = "鑺傛媿宸ヤ环妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�4鍒楀簲涓簕璁′欢鍗曚环}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[6].ColumnName != "璁惧鑺傛媿")
+ {
+ code = "300";
+ Message = "鑺傛媿宸ヤ环妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�4鍒楀簲涓簕璁惧鑺傛媿}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[7].ColumnName != "鐢熶骇鑺傛媿")
+ {
+ code = "300";
+ Message = "鑺傛媿宸ヤ环妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�4鍒楀簲涓簕鐢熶骇鑺傛媿}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[8].ColumnName != "鍨嬭厰鏁�")
+ {
+ code = "300";
+ Message = "鑺傛媿宸ヤ环妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�4鍒楀簲涓簕鍨嬭厰鏁皚";
+ return Message;
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,璐ㄦ鏍囧噯妯℃澘銆�
+ public static string Seventeen(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 2)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,缂哄け鐨凷heet";
+ }
+ else if (excelTable[0].Columns.Count != 8)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ }
+ else if (excelTable[1].Columns.Count != 9)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "鐗╂枡缂栫爜")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "鐗╂枡鍚嶇О")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "妫�楠岀被鍨�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[4].ColumnName != "宸ヨ壓璺嚎")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[5].ColumnName != "宸ュ簭缂栫爜")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[6].ColumnName != "宸ュ簭鍚嶇О")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[0].Columns[7].ColumnName != "娴佺▼绠℃帶")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[1].ColumnName != "涓昏〃搴忓垪鍙�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[2].ColumnName != "鎺掑垪椤哄簭")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[3].ColumnName != "妫�楠岄」鐩�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[4].ColumnName != "閲嶈搴�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[5].ColumnName != "妫�楠屽伐鍏�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[6].ColumnName != "鏍囧噯瑕佹眰")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[7].ColumnName != "涓嬮檺鍊�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable[1].Columns[8].ColumnName != "涓婇檺鍊�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,缂洪櫡瀹氫箟妯℃澘銆�
+ public static string Eighteen(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 2)
+ {
+ code = "300";
+ Message = "瀵煎叆妯℃澘涓嶇鍚堣鑼�,璇锋鏌heet鏁�";
+ return Message;
+
+ }
+ else if (excelTable[0].Columns.Count != 4)
+ {
+ code = "300";
+ Message = "缂洪櫡瀹氫箟妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ return Message;
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "缂洪櫡瀹氫箟妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�1鍒楀簲涓簕搴忓彿}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "缂洪櫡缂栧彿(鍞竴)")
+ {
+ code = "300";
+ Message = "缂洪櫡瀹氫箟妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�2鍒楀簲涓簕缂洪櫡缂栧彿(鍞竴)}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "缂洪櫡鍚嶇О")
+ {
+ code = "300";
+ Message = "缂洪櫡瀹氫箟妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�3鍒楀簲涓簕缂洪櫡鍚嶇О}";
+ return Message;
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "缂洪櫡鎻忚堪")
+ {
+ code = "300";
+ Message = "缂洪櫡鎻忚堪妯℃澘涓嶇鍚堣鑼冿細琛ㄥご淇℃伅涓嶇鍚堣鑼�,绗�4鍒楀簲涓簕缂洪櫡鎻忚堪}";
+ return Message;
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,鐢熶骇璁㈠崟妯℃澘銆�
+ public static string Nineteen(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ DataTable excelTable = new DataTable();
+ excelTable = ImportExcel.ExcelToTable(FileCode);
+ if (excelTable.Columns.Count != 7)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[1].ColumnName != "浜у搧缂栫爜")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[2].ColumnName != "浜у搧鍚嶇О")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[3].ColumnName != "浜у搧瑙勬牸")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[4].ColumnName != "璁㈠崟鏁伴噺")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[5].ColumnName != "瑕佹眰浜や粯鏃堕棿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[6].ColumnName != "ERP璁㈠崟鍙�")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,鐢熶骇璁㈠崟妯℃澘銆�
+ public static string Twenty(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ DataTable excelTable = new DataTable();
+ excelTable = ImportExcel.ExcelToTable(FileCode);
+ if (excelTable.Columns.Count != 10)
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[1].ColumnName != "搴撲綅缂栫爜")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[2].ColumnName != "鐗╂枡缂栫爜")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[3].ColumnName != "鐗╂枡鍚嶇О")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[4].ColumnName != "娴佺▼鍗″彿")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[5].ColumnName != "瀹瑰櫒缂栫爜")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[6].ColumnName != "鍏ュ巶鏉$爜")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[7].ColumnName != "鐐夊彿鎵规")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[8].ColumnName != "渚涙柟鍚嶇О")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else if (excelTable.Columns[9].ColumnName != "褰撳墠搴撳瓨")
+ {
+ code = "300";
+ Message = "妯℃澘涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚�";
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #region銆怑xcel妯℃澘涓婁紶楠岃瘉,鐗╂枡娓呭崟妯℃澘銆�
+ public static string TwentyOne(string FileCode, out string code)
+ {
+ string Message = "";
+ code = "";
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ if (excelTable.Count != 4)
+ {
+ code = "300";
+ Message = "瀵煎叆妯℃澘涓嶇鍚堣鑼�,璇锋鏌heet鏁�";
+ }
+ else if (excelTable[0].Columns.Count != 6)
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(姣嶄欢淇℃伅)涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ }
+ else if (excelTable[1].Columns.Count != 10)
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(瀛愪欢淇℃伅)涓嶇鍚堣鑼�,璇锋鏌ュ垪鍚嶅瓧娈垫暟";
+ }
+ else if (excelTable[0].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(姣嶄欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ }
+ else if (excelTable[0].Columns[1].ColumnName != "姣嶄欢缂栫爜")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(姣嶄欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕姣嶄欢缂栫爜}";
+ }
+ else if (excelTable[0].Columns[2].ColumnName != "姣嶄欢鍚嶇О")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(姣嶄欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�3鍒楀簲涓簕姣嶄欢鍚嶇О}";
+ }
+ else if (excelTable[0].Columns[3].ColumnName != "鍩虹鏁伴噺")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(姣嶄欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�4鍒楀簲涓簕鍩虹鏁伴噺}";
+ }
+ else if (excelTable[0].Columns[4].ColumnName != "鍚敤鐘舵��")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(姣嶄欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�5鍒楀簲涓簕鍚敤鐘舵�亇";
+ }
+ else if (excelTable[0].Columns[5].ColumnName != "鐗堟湰鍙�")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(姣嶄欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�6鍒楀簲涓簕鐗堟湰鍙穧";
+ }
+ else if (excelTable[1].Columns[0].ColumnName != "搴忓彿")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(瀛愪欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�1鍒楀簲涓簕搴忓彿}";
+ }
+ else if (excelTable[1].Columns[1].ColumnName != "涓昏〃搴忓垪鍙�")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(瀛愪欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�2鍒楀簲涓簕涓昏〃搴忓垪鍙穧";
+ }
+ else if (excelTable[1].Columns[2].ColumnName != "瀛愪欢椤哄簭鍙�")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(瀛愪欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�3鍒楀簲涓簕瀛愪欢椤哄簭鍙穧";
+ }
+ else if (excelTable[1].Columns[3].ColumnName != "瀛愪欢缂栫爜")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(瀛愪欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�4鍒楀簲涓簕瀛愪欢缂栫爜}";
+ }
+ else if (excelTable[1].Columns[4].ColumnName != "瀛愪欢鍚嶇О")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(瀛愪欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�5鍒楀簲涓簕瀛愪欢鍚嶇О}";
+ }
+ else if (excelTable[1].Columns[5].ColumnName != "鍙戞枡浠撳簱")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(瀛愪欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�6鍒楀簲涓簕鍙戞枡浠撳簱}";
+ }
+ else if (excelTable[1].Columns[6].ColumnName != "鍩烘湰鐢ㄩ噺")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(瀛愪欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�7鍒楀簲涓簕鍩烘湰鐢ㄩ噺}";
+ }
+ else if (excelTable[1].Columns[7].ColumnName != "鎹熻�楃巼(%)")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(瀛愪欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�8鍒楀簲涓簕鎹熻�楃巼(%)}";
+ }
+ else if (excelTable[1].Columns[8].ColumnName != "瀹為檯鐢ㄩ噺")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(瀛愪欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�9鍒楀簲涓簕瀹為檯鐢ㄩ噺}";
+ }
+ else if (excelTable[1].Columns[9].ColumnName != "灞炴��")
+ {
+ code = "300";
+ Message = "鐗╂枡娓呭崟妯℃澘(瀛愪欢)锛氳〃澶翠俊鎭笉绗﹀悎瑙勮寖,绗�10鍒楀簲涓簕灞炴�";
+ }
+ else
+ {
+ code = "200";
+ Message = "妯℃澘妫�楠岄�氳繃";
+ }
+ return Message;
+ }
+ #endregion
+
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉銆�
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,鐢ㄦ埛瑙掕壊銆�
+ public static List<ExcelErro> TwoData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+ List<DataTable> excelTable = new List<DataTable>();
+ list = ImportExcel.ExcelToTableListErro(FileCode); //楠岃瘉Excel鏁版嵁蹇呭~瀛楁鏄惁涓虹┖銆佸敮涓�瀛楁鏄惁閲嶅
+ excelTable = ImportExcel.ExcelToTableList(FileCode); //鑾峰彇Excel鏁版嵁
+ //涓昏〃
+ for (int j = 0; j < excelTable[0].Rows.Count; j++)
+ {
+ if (excelTable[0].Rows[j][2].ToString().Trim() != null && excelTable[0].Rows[j][2].ToString().Trim() != "")
+ {
+ sql = @"select * from TGroup where group_code=@group_code";
+ dynamicParams.Add("@group_code", excelTable[0].Rows[j][2].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{鐝粍缂栫爜(鍞竴)}";
+ erro.ErrorCont = "鐝粍琛�:{鐝粍缂栫爜(鍞竴)}瀛楁" + excelTable[0].Rows[j][2].ToString().Trim() + "宸插瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ }
+ //瀛愯〃
+ for (int k = 0; k < excelTable[1].Rows.Count; k++)
+ {
+ if (excelTable[1].Rows[k][1].ToString().Trim() != null && excelTable[1].Rows[k][1].ToString().Trim() != "")
+ {
+ sql = @"select * from TUser where usercode=@usercode";
+ dynamicParams.Add("@usercode", excelTable[1].Rows[k][1].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{鐢ㄦ埛缂栫爜(鍞竴)}";
+ erro.ErrorCont = "鐢ㄦ埛琛�:{鐢ㄦ埛缂栫爜(鍞竴)}瀛楁" + excelTable[1].Rows[k][1].ToString().Trim() + "宸插瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ if (excelTable[1].Rows[k][7].ToString().Trim() != null && excelTable[1].Rows[k][7].ToString().Trim() != "")
+ {
+ sql = @"select * from TOrganization where org_code=@org_code";
+ dynamicParams.Add("@org_code", excelTable[1].Rows[k][7].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt == null || dt.Rows.Count <= 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{缁勭粐缂栫爜}";
+ erro.ErrorCont = "鐢ㄦ埛琛�:{缁勭粐缂栫爜}瀛楁" + excelTable[1].Rows[k][7].ToString().Trim() + "涓嶅瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ if (excelTable[1].Rows[k][9].ToString().Trim() != null && excelTable[1].Rows[k][9].ToString().Trim() != "")
+ {
+ sql = @"select torg_code from TGroup where group_code=@group_code";
+ dynamicParams.Add("@group_code", excelTable[1].Rows[k][9].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt != null && dt.Rows.Count > 0)
+ {
+ if (dt.Rows[0]["torg_code"].ToString() != excelTable[1].Rows[k][7].ToString().Trim())
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{鐢ㄦ埛缁勭紪鐮亇";
+ erro.ErrorCont = "鐢ㄦ埛琛�:{鐢ㄦ埛缁勭紪鐮亇瀛楁" + excelTable[1].Rows[k][9].ToString().Trim() + " 涓嶆槸缁勭粐缂栫爜:" + excelTable[1].Rows[k][7].ToString().Trim() + "涓嬬殑鐢ㄦ埛缁�";
+ list.Add(erro);
+ }
+ }
+ }
+ }
+ //鍒ゆ柇瀛愯〃缁勭粐缂栫爜涓嶅瓨鍦ㄤ簬涓昏〃缁勭粐缂栫爜涓殑鏁版嵁
+ var dt2 = from r in excelTable[1].AsEnumerable()
+ where !(
+ from rr in excelTable[0].AsEnumerable()
+ select rr.Field<string>("缁勭粐缂栫爜")
+ ).Contains(r.Field<string>("缁勭粐缂栫爜"))
+ select r;
+ List<DataRow> listRow2 = dt2.ToList();
+ if (listRow2.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{缁勭粐缂栫爜}";
+ erro.ErrorCont = "鐢ㄦ埛琛�:{缁勭粐缂栫爜}瀛楁涓湁鍊煎湪鐝粍琛�:{缁勭粐缂栫爜}涓笉瀛樺湪";
+ list.Add(erro);
+ }
+ //鍒ゆ柇瀛愯〃澶栭敭涓嶅瓨鍦ㄤ簬涓昏〃涓婚敭涓殑鏁版嵁
+ var dt3 = from r in excelTable[1].AsEnumerable()
+ where !(
+ from rr in excelTable[0].AsEnumerable()
+ select rr.Field<string>("鐝粍缂栧彿(鍞竴)")
+ ).Contains(r.Field<string>("鐢ㄦ埛缁勭紪鐮�"))
+ select r;
+ List<DataRow> listRow = dt3.ToList();
+ if (listRow.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{鐢ㄦ埛缁勭紪鐮亇";
+ erro.ErrorCont = "鐢ㄦ埛琛�:{鐢ㄦ埛缁勭紪鐮亇瀛楁涓湁鍊煎湪鐝粍琛�:{鐝粍缂栧彿(鍞竴)}涓笉瀛樺湪";
+ list.Add(erro);
+ }
+ if (list.Count > 0)
+ {
+ int index = 0;
+ foreach (ExcelErro item in list)
+ {
+ index++;
+ item.Seq = index.ToString();
+ }
+ StuCode = "301";
+ message = "鏁版嵁楠岃瘉澶辫触";
+ }
+ else
+ {
+ StuCode = "200";
+ message = "鏁版嵁楠岃瘉鎴愬姛";
+ count = excelTable[0].Rows.Count + excelTable[1].Rows.Count;
+ }
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,瑙掕壊鏉冮檺銆�
+ public static List<ExcelErro> OneData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+ List<DataTable> excelTable = new List<DataTable>();
+ list = ImportExcel.ExcelToTableListErro(FileCode); //楠岃瘉Excel鏁版嵁蹇呭~瀛楁鏄惁涓虹┖銆佸敮涓�瀛楁鏄惁閲嶅
+ excelTable = ImportExcel.ExcelToTableList(FileCode); //鑾峰彇Excel鏁版嵁
+ //涓昏〃
+ for (int j = 0; j < excelTable[0].Rows.Count; j++)
+ {
+ if (excelTable[1].Rows[j][1].ToString().Trim() != null && excelTable[1].Rows[j][1].ToString().Trim() != "")
+ {
+ sql = @"select * from TOrganization where org_code=@org_code";
+ dynamicParams.Add("@org_code", excelTable[1].Rows[j][1].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt == null || dt.Rows.Count <= 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{缁勭粐缂栫爜}";
+ erro.ErrorCont = "瑙掕壊绫诲瀷琛�:{缁勭粐缂栫爜}瀛楁" + excelTable[1].Rows[j][1].ToString().Trim() + "涓嶅瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ if (excelTable[0].Rows[j][2].ToString().Trim() != null && excelTable[0].Rows[j][2].ToString().Trim() != "")
+ {
+ sql = @"select * from TRoleType where roletype_code=@roletype_code";
+ dynamicParams.Add("@roletype_code", excelTable[0].Rows[j][2].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{瑙掕壊绫诲瀷缂栫爜(鍞竴)}";
+ erro.ErrorCont = "鐝粍琛�:{瑙掕壊绫诲瀷缂栫爜(鍞竴)}瀛楁" + excelTable[0].Rows[j][2].ToString().Trim() + "宸插瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ }
+ //瀛愯〃
+ for (int k = 0; k < excelTable[1].Rows.Count; k++)
+ {
+ if (excelTable[1].Rows[k][2].ToString().Trim() != null && excelTable[1].Rows[k][2].ToString().Trim() != "")
+ {
+ sql = @"select * from TRole where role_code=@role_code";
+ dynamicParams.Add("@role_code", excelTable[1].Rows[k][2].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{瑙掕壊缂栧彿(鍞竴)}";
+ erro.ErrorCont = "瑙掕壊琛�:{瑙掕壊缂栧彿(鍞竴)}瀛楁" + excelTable[1].Rows[k][2].ToString().Trim() + "宸插瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ if (excelTable[1].Rows[k][1].ToString().Trim() != null && excelTable[1].Rows[k][1].ToString().Trim() != "")
+ {
+ sql = @"select * from TOrganization where org_code=@org_code";
+ dynamicParams.Add("@org_code", excelTable[1].Rows[k][1].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt == null || dt.Rows.Count <= 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{缁勭粐缂栫爜}";
+ erro.ErrorCont = "瑙掕壊琛�:{缁勭粐缂栫爜}瀛楁" + excelTable[1].Rows[k][1].ToString().Trim() + "涓嶅瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ if (excelTable[1].Rows[k][4].ToString().Trim() != null && excelTable[1].Rows[k][4].ToString().Trim() != "")
+ {
+ sql = @"select torg_code from TRoleType where roletype_code=@roletype_code";
+ dynamicParams.Add("@roletype_code", excelTable[1].Rows[k][4].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt != null && dt.Rows.Count > 0)
+ {
+ if (dt.Rows[0]["torg_code"].ToString() != excelTable[1].Rows[k][1].ToString().Trim())
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{瑙掕壊绫诲瀷缂栫爜}";
+ erro.ErrorCont = "瑙掕壊琛�:{瑙掕壊绫诲瀷缂栫爜}瀛楁" + excelTable[1].Rows[k][4].ToString().Trim() + " 涓嶆槸缁勭粐缂栫爜:" + excelTable[1].Rows[k][1].ToString().Trim() + "涓嬬殑瑙掕壊缁�";
+ list.Add(erro);
+ }
+ }
+ }
+ }
+ //鍒ゆ柇瀛愯〃缁勭粐缂栫爜涓嶅瓨鍦ㄤ簬涓昏〃缁勭粐缂栫爜涓殑鏁版嵁
+ var dt2 = from r in excelTable[1].AsEnumerable()
+ where !(
+ from rr in excelTable[0].AsEnumerable()
+ select rr.Field<string>("缁勭粐缂栫爜")
+ ).Contains(r.Field<string>("缁勭粐缂栫爜"))
+ select r;
+ List<DataRow> listRow2 = dt2.ToList();
+ if (listRow2.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{缁勭粐缂栫爜}";
+ erro.ErrorCont = "瑙掕壊琛�:{缁勭粐缂栫爜}瀛楁涓湁鍊煎湪瑙掕壊绫诲瀷琛�:{缁勭粐缂栫爜}涓笉瀛樺湪";
+ list.Add(erro);
+ }
+ //鍒ゆ柇瀛愯〃澶栭敭涓嶅瓨鍦ㄤ簬涓昏〃涓婚敭涓殑鏁版嵁
+ var dt3 = from r in excelTable[1].AsEnumerable()
+ where !(
+ from rr in excelTable[0].AsEnumerable()
+ select rr.Field<string>("瑙掕壊绫诲瀷缂栧彿(鍞竴)")
+ ).Contains(r.Field<string>("瑙掕壊绫诲瀷缂栫爜"))
+ select r;
+ List<DataRow> listRow = dt3.ToList();
+ if (listRow.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{瑙掕壊绫诲瀷缂栫爜}";
+ erro.ErrorCont = "瑙掕壊琛�:{瑙掕壊绫诲瀷缂栫爜}瀛楁涓湁鍊煎湪瑙掕壊绫诲瀷琛�:{瑙掕壊绫诲瀷缂栧彿(鍞竴)}涓笉瀛樺湪";
+ list.Add(erro);
+ }
+ if (list.Count > 0)
+ {
+ int index = 0;
+ foreach (ExcelErro item in list)
+ {
+ index++;
+ item.Seq = index.ToString();
+ }
+ StuCode = "301";
+ message = "鏁版嵁楠岃瘉澶辫触";
+ }
+ else
+ {
+ StuCode = "200";
+ message = "鏁版嵁楠岃瘉鎴愬姛";
+ count = excelTable[0].Rows.Count + excelTable[1].Rows.Count;
+ }
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,宸ヤ綅娓呭崟銆�
+ public static List<ExcelErro> ThreeData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,寰�鏉ュ崟浣嶆竻鍗曘��
+ public static List<ExcelErro> FourData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ var dynamicParams = new DynamicParameters();
+ List<ExcelErro> list = new List<ExcelErro>();
+ DataTable excelTable = new DataTable();
+ list = ImportExcel.ExcelToTableErro(FileCode); //楠岃瘉Excel鏁版嵁蹇呭~瀛楁鏄惁涓虹┖銆佸敮涓�瀛楁鏄惁閲嶅
+ excelTable = ImportExcel.ExcelToTable(FileCode); //鑾峰彇Excel鏁版嵁
+ for (int i = 0; i < excelTable.Rows.Count; i++)
+ {
+ if (excelTable.Rows[i][1].ToString().Trim() != null && excelTable.Rows[i][1].ToString().Trim() != "")
+ {
+ sql = @"select code from TCustomer where code=@code";
+
+ dynamicParams.Add("@code", excelTable.Rows[i][1].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{寰�鏉ュ崟浣嶇紪鐮�(鍞竴)}";
+ erro.ErrorCont = "寰�鏉ュ崟浣嶈〃:{寰�鏉ュ崟浣嶇紪鐮�(鍞竴)}瀛楁" + excelTable.Rows[i][1].ToString().Trim() + "宸插瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ }
+ if (list.Count > 0)
+ {
+ int index = 0;
+ foreach (ExcelErro item in list)
+ {
+ index++;
+ item.Seq = index.ToString();
+ }
+ StuCode = "301";
+ message = "鏁版嵁楠岃瘉澶辫触";
+ }
+ else
+ {
+ StuCode = "200";
+ message = "鏁版嵁楠岃瘉鎴愬姛";
+ count = excelTable.Rows.Count;
+ }
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,浠撳簱銆佸簱浣嶅畾涔夈��
+ public static List<ExcelErro> SixOneData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+ List<DataTable> excelTable = new List<DataTable>();
+ list = ImportExcel.ExcelToTableListErro(FileCode); //楠岃瘉Excel鏁版嵁蹇呭~瀛楁鏄惁涓虹┖銆佸敮涓�瀛楁鏄惁閲嶅
+ excelTable = ImportExcel.ExcelToTableList(FileCode); //鑾峰彇Excel鏁版嵁
+ //浠撳簱琛�
+ for (int j = 0; j < excelTable[0].Rows.Count; j++)
+ {
+ if (excelTable[0].Rows[j][1].ToString().Trim() != null && excelTable[0].Rows[j][1].ToString().Trim() != "")
+ {
+ sql = @"select * from T_Sec_Stck where code=@code";
+ dynamicParams.Add("@code", excelTable[0].Rows[j][1].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{浠撳簱缂栧彿(鍞竴)}";
+ erro.ErrorCont = "浠撳簱琛�:{浠撳簱缂栧彿(鍞竴)}瀛楁" + excelTable[0].Rows[j][1].ToString().Trim() + "宸插瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ }
+ //搴撲綅琛�
+ for (int k = 0; k < excelTable[1].Rows.Count; k++)
+ {
+ if (excelTable[1].Rows[k][1].ToString().Trim() != null && excelTable[1].Rows[k][1].ToString().Trim() != "")
+ {
+ sql = @"select * from T_Sec_Loca where code=@code";
+ dynamicParams.Add("@code", excelTable[1].Rows[k][1].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{搴撲綅缂栧彿(鍞竴)}";
+ erro.ErrorCont = "搴撲綅琛�:{搴撲綅缂栧彿(鍞竴)}瀛楁" + excelTable[1].Rows[k][2].ToString().Trim() + "宸插瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ }
+ //鍒ゆ柇瀛愯〃澶栭敭涓嶅瓨鍦ㄤ簬涓昏〃涓婚敭涓殑鏁版嵁
+ var dt3 = from r in excelTable[1].AsEnumerable()
+ where !(
+ from rr in excelTable[0].AsEnumerable()
+ select rr.Field<string>("浠撳簱缂栧彿(鍞竴)")
+ ).Contains(r.Field<string>("鎵�灞炰粨搴撶紪鐮�"))
+ select r;
+ List<DataRow> listRow = dt3.ToList();
+ if (listRow.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{鎵�灞炰粨搴撶紪鐮亇";
+ erro.ErrorCont = "搴撲綅琛�:{鎵�灞炰粨搴撶紪鐮亇瀛楁涓湁鍊煎湪浠撳簱琛�:{浠撳簱缂栧彿(鍞竴)}涓笉瀛樺湪";
+ list.Add(erro);
+ }
+ if (list.Count > 0)
+ {
+ int index = 0;
+ foreach (ExcelErro item in list)
+ {
+ index++;
+ item.Seq = index.ToString();
+ }
+ StuCode = "301";
+ message = "鏁版嵁楠岃瘉澶辫触";
+ }
+ else
+ {
+ StuCode = "200";
+ message = "鏁版嵁楠岃瘉鎴愬姛";
+ count = excelTable[0].Rows.Count + excelTable[1].Rows.Count;
+ }
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,瀹瑰櫒瀹氫箟銆�
+ public static List<ExcelErro> SevenData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,瀛樿揣妗f銆�
+ public static List<ExcelErro> EightData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,璁惧娓呭崟銆�
+ public static List<ExcelErro> NineData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+ DataTable excelTable = new DataTable();
+ list = ImportExcel.ExcelToTableErro(FileCode); //楠岃瘉Excel鏁版嵁蹇呭~瀛楁鏄惁涓虹┖銆佸敮涓�瀛楁鏄惁閲嶅
+ excelTable = ImportExcel.ExcelToTable(FileCode); //鑾峰彇Excel鏁版嵁
+ //璁惧娓呭崟琛�
+ for (int k = 0; k < excelTable.Rows.Count; k++)
+ {
+ if (excelTable.Rows[k][1].ToString().Trim() != null && excelTable.Rows[k][1].ToString().Trim() != "")
+ {
+ sql = @"select * from TEqpInfo where code=@code";
+ dynamicParams.Add("@code", excelTable.Rows[k][1].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧琛�:{璁惧缂栧彿(鍞竴)}瀛楁" + excelTable.Rows[k][1].ToString().Trim() + "宸插瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ }
+ //杞﹂棿鍒ゆ柇
+ for (int m = 0; m < excelTable.Rows.Count; m++)
+ {
+ if (excelTable.Rows[m][4].ToString().Trim() != null && excelTable.Rows[m][4].ToString().Trim() != "")
+ {
+ sql = @"select * from TOrganization where org_code=@code and description='W'";
+ dynamicParams.Add("@code", excelTable.Rows[m][4].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count <= 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{杞﹂棿缂栫爜}";
+ erro.ErrorCont = "璁惧琛�:{杞﹂棿缂栫爜}瀛楁" + excelTable.Rows[m][4].ToString().Trim() + "涓嶅瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ }
+ if (list.Count > 0)
+ {
+ int index = 0;
+ foreach (ExcelErro item in list)
+ {
+ index++;
+ item.Seq = index.ToString();
+ }
+ StuCode = "301";
+ message = "鏁版嵁楠岃瘉澶辫触";
+ }
+ else
+ {
+ StuCode = "200";
+ message = "鏁版嵁楠岃瘉鎴愬姛";
+ count = excelTable.Rows.Count;
+ }
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,璁惧鐐规椤圭洰銆�
+ public static List<ExcelErro> TenData(string FileCode, out string StuCode, out string message, out int count)
+ {
+
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ var dynamicParams = new DynamicParameters();
+ List<ExcelErro> list = new List<ExcelErro>();
+ DataTable excelTable = new DataTable();
+ list = ImportExcel.ExcelToTableErro(FileCode); //楠岃瘉Excel鏁版嵁蹇呭~瀛楁鏄惁涓虹┖銆佸敮涓�瀛楁鏄惁閲嶅
+ excelTable = ImportExcel.ExcelToTable(FileCode); //鑾峰彇Excel鏁版嵁
+ //褰撳墠Excel鏁版嵁涓偣妫�鏍囧噯椤电涓�,璁惧鐐规鏍囧噯缂栧彿(鍞竴鏄惁鏈夐噸澶�)
+ DataTable distinct = excelTable.DefaultView.ToTable(true, "鐐规椤圭洰缂栧彿(鍞竴)");
+ if (distinct.Rows.Count != excelTable.Rows.Count)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{鐐规椤圭洰缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧鐐规椤圭洰椤电妯℃澘:{鐐规椤圭洰缂栧彿(鍞竴)}鏈夐噸澶�";
+ list.Add(erro);
+ }
+ for (int i = 0; i < excelTable.Rows.Count; i++)
+ {
+ if (excelTable.Rows[i][1].ToString().Trim() != null && excelTable.Rows[i][1].ToString().Trim() != "")
+ {
+ sql = @"select code from TEqpchk_Item where code=@code";
+
+ dynamicParams.Add("@code", excelTable.Rows[i][1].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{鐐规椤圭洰缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧鐐规椤圭洰琛�:{鐐规椤圭洰缂栧彿(鍞竴)}瀛楁" + excelTable.Rows[i][1].ToString().Trim() + "宸插瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ }
+ if (list.Count > 0)
+ {
+ int index = 0;
+ foreach (ExcelErro item in list)
+ {
+ index++;
+ item.Seq = index.ToString();
+ }
+ StuCode = "301";
+ message = "鏁版嵁楠岃瘉澶辫触";
+ }
+ else
+ {
+ StuCode = "200";
+ message = "鏁版嵁楠岃瘉鎴愬姛";
+ count = excelTable.Rows.Count;
+ }
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,璁惧鐐规鏍囧噯銆�
+ public static List<ExcelErro> TwentyTwoData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+ List<DataTable> excelTable = new List<DataTable>();
+ list = ImportExcel.ExcelToTableListErro(FileCode); //楠岃瘉Excel鏁版嵁蹇呭~瀛楁鏄惁涓虹┖銆佸敮涓�瀛楁鏄惁閲嶅
+ excelTable = ImportExcel.ExcelToTableList(FileCode); //鑾峰彇Excel鏁版嵁
+ //褰撳墠Excel鏁版嵁涓偣妫�鏍囧噯椤电涓�,璁惧鐐规鏍囧噯缂栧彿(鍞竴鏄惁鏈夐噸澶�)
+ DataTable distinct = excelTable[0].DefaultView.ToTable(true, "璁惧鐐规鏍囧噯缂栧彿(鍞竴)");
+ if (distinct.Rows.Count != excelTable[0].Rows.Count)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧鐐规鏍囧噯缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧鐐规鏍囧噯椤电妯℃澘:{璁惧鐐规鏍囧噯缂栧彿(鍞竴)}鏈夐噸澶�";
+ list.Add(erro);
+ }
+ //璁惧鐐规鏍囧噯琛ㄦ槸鍚﹀凡瀛樺湪鐐规鏍囧噯
+ for (int j = 0; j < excelTable[0].Rows.Count; j++)
+ {
+ if (excelTable[0].Rows[j][1].ToString().Trim() != null && excelTable[0].Rows[j][1].ToString().Trim() != "")
+ {
+ sql = @"select * from TEqpchk_Main where code=@code";
+ dynamicParams.Add("@code", excelTable[0].Rows[j][1].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧鐐规鏍囧噯缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧鐐规鏍囧噯琛�:{璁惧鐐规鏍囧噯缂栧彿(鍞竴)}瀛楁" + excelTable[0].Rows[j][1].ToString().Trim() + "鍦ㄦ暟鎹〃涓凡瀛樺湪";
+ list.Add(erro);
+ }
+ //閫氳繃璁惧鐐规鏍囧噯椤电妯℃澘涓殑鏍囧噯缂栫爜鏌ヨ璁惧鐐规閮ㄤ綅椤电妯℃澘涓搴旂殑鏁版嵁淇℃伅
+ var var_dtTable = excelTable[1].AsEnumerable().Where<DataRow>(W => W["璁惧鐐规鏍囧噯缂栧彿"].ToString() == excelTable[0].Rows[j][1].ToString().Trim());
+ DataTable ds = var_dtTable.Any() ? var_dtTable.CopyToDataTable() : excelTable[1].Clone();
+ if (ds.Rows.Count > 0)
+ {
+ //鍒ゆ柇淇濆吇鏍囧噯鏌ヨ淇濆吇閮ㄤ綅鏁版嵁鏄惁鏈夐噸澶�
+ DataTable distinct1 = ds.DefaultView.ToTable(true, "璁惧鐐规閮ㄤ綅缂栧彿(鍞竴)");
+ if (distinct1.Rows.Count != ds.Rows.Count)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧鐐规閮ㄤ綅缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧鐐规閮ㄤ綅椤电妯℃澘:{璁惧鐐规鏍囧噯缂栧彿}:" + excelTable[1].Rows[j][2].ToString().Trim() + " 瀵瑰簲{璁惧鐐规閮ㄤ綅缂栧彿(鍞竴)}鏈夐噸澶�";
+ list.Add(erro);
+ }
+ }
+ else
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧鐐规閮ㄤ綅缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧鐐规閮ㄤ綅椤电妯℃澘:{璁惧鐐规鏍囧噯缂栧彿}:" + excelTable[1].Rows[j][2].ToString().Trim() + " 鍦ㄨ澶囩偣妫�鏍囧噯椤电妯℃澘涓笉瀛樺湪";
+ list.Add(erro);
+ }
+ }
+ }
+ //褰撳墠Excel鏁版嵁涓偣妫�閮ㄤ綅椤电涓�,璁惧鐐规閮ㄤ綅缂栧彿(鍞竴)鍦ㄨ澶囩偣妫�閮ㄤ綅琛ㄤ腑鏄惁瀛樺湪
+ for (int k = 0; k < excelTable[1].Rows.Count; k++)
+ {
+ if (excelTable[1].Rows[k][3].ToString().Trim() != null && excelTable[1].Rows[k][3].ToString().Trim() != "")
+ {
+ sql = @"select * from TEqpchk_Item where code=@code";
+ dynamicParams.Add("@code", excelTable[1].Rows[k][3].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count < 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧鐐规閮ㄤ綅缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧鐐规閮ㄤ綅琛�:{璁惧鐐规閮ㄤ綅缂栧彿(鍞竴)}瀛楁" + excelTable[1].Rows[k][2].ToString().Trim() + "鍦ㄦ暟鎹〃涓笉瀛樺湪";
+ list.Add(erro);
+ }
+ }
+ }
+ //鍒ゆ柇瀛愯〃澶栭敭涓嶅瓨鍦ㄤ簬涓昏〃涓婚敭涓殑鏁版嵁
+ var dt3 = from r in excelTable[1].AsEnumerable()
+ where !(
+ from rr in excelTable[0].AsEnumerable()
+ select rr.Field<string>("璁惧鐐规鏍囧噯缂栧彿(鍞竴)")
+ ).Contains(r.Field<string>("璁惧鐐规鏍囧噯缂栧彿"))
+ select r;
+ List<DataRow> listRow = dt3.ToList();
+ if (listRow.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧鐐规鏍囧噯缂栧彿}";
+ erro.ErrorCont = "璁惧鐐规閮ㄤ綅椤电妯℃澘:{璁惧鐐规鏍囧噯缂栧彿}瀛楁涓湁鍊煎湪璁惧鐐规鏍囧噯椤电妯℃澘:{璁惧鐐规鏍囧噯缂栧彿(鍞竴)}涓笉瀛樺湪";
+ list.Add(erro);
+ }
+ if (list.Count > 0)
+ {
+ int index = 0;
+ foreach (ExcelErro item in list)
+ {
+ index++;
+ item.Seq = index.ToString();
+ }
+ StuCode = "301";
+ message = "鏁版嵁楠岃瘉澶辫触";
+ }
+ else
+ {
+ StuCode = "200";
+ message = "鏁版嵁楠岃瘉鎴愬姛";
+ count = excelTable[0].Rows.Count + excelTable[1].Rows.Count;
+ }
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,璁惧淇濆吇椤圭洰銆�
+ public static List<ExcelErro> ElevenData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ var dynamicParams = new DynamicParameters();
+ List<ExcelErro> list = new List<ExcelErro>();
+ DataTable excelTable = new DataTable();
+ list = ImportExcel.ExcelToTableErro(FileCode); //楠岃瘉Excel鏁版嵁蹇呭~瀛楁鏄惁涓虹┖銆佸敮涓�瀛楁鏄惁閲嶅
+ excelTable = ImportExcel.ExcelToTable(FileCode); //鑾峰彇Excel鏁版嵁
+ //褰撳墠Excel鏁版嵁涓偣妫�鏍囧噯椤电涓�,璁惧鐐规鏍囧噯缂栧彿(鍞竴鏄惁鏈夐噸澶�)
+ DataTable distinct = excelTable.DefaultView.ToTable(true, "淇濆吇椤圭洰缂栧彿(鍞竴)");
+ if (distinct.Rows.Count != excelTable.Rows.Count)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{淇濆吇椤圭洰缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧淇濆吇椤圭洰椤电妯℃澘:{淇濆吇椤圭洰缂栧彿(鍞竴)}鏈夐噸澶�";
+ list.Add(erro);
+ }
+ for (int i = 0; i < excelTable.Rows.Count; i++)
+ {
+ if (excelTable.Rows[i][1].ToString().Trim() != null && excelTable.Rows[i][1].ToString().Trim() != "")
+ {
+ sql = @"select code from TEqpmai_Item where code=@code";
+
+ dynamicParams.Add("@code", excelTable.Rows[i][1].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{淇濆吇椤圭洰缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧淇濆吇椤圭洰琛�:{鐐规淇濆吇缂栧彿(鍞竴)}瀛楁" + excelTable.Rows[i][1].ToString().Trim() + "宸插瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ }
+ if (list.Count > 0)
+ {
+ int index = 0;
+ foreach (ExcelErro item in list)
+ {
+ index++;
+ item.Seq = index.ToString();
+ }
+ StuCode = "301";
+ message = "鏁版嵁楠岃瘉澶辫触";
+ }
+ else
+ {
+ StuCode = "200";
+ message = "鏁版嵁楠岃瘉鎴愬姛";
+ count = excelTable.Rows.Count;
+ }
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,璁惧淇濆吇鏍囧噯銆�
+ public static List<ExcelErro> TwentyThreeData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+ List<DataTable> excelTable = new List<DataTable>();
+ list = ImportExcel.ExcelToTableListErro(FileCode); //楠岃瘉Excel鏁版嵁蹇呭~瀛楁鏄惁涓虹┖銆佸敮涓�瀛楁鏄惁閲嶅
+ excelTable = ImportExcel.ExcelToTableList(FileCode); //鑾峰彇Excel鏁版嵁
+ //褰撳墠Excel鏁版嵁涓繚鍏绘爣鍑嗛〉绛句腑,璁惧淇濆吇鏍囧噯缂栧彿(鍞竴鏄惁鏈夐噸澶�)
+ DataTable distinct = excelTable[0].DefaultView.ToTable(true, "璁惧淇濆吇鏍囧噯缂栧彿(鍞竴)");
+ if (distinct.Rows.Count != excelTable[0].Rows.Count)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧淇濆吇鏍囧噯缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧淇濆吇鏍囧噯椤电妯℃澘:{璁惧淇濆吇鏍囧噯缂栧彿(鍞竴)}鏈夐噸澶�";
+ list.Add(erro);
+ }
+ //璁惧淇濆吇鏍囧噯琛ㄦ槸鍚﹀凡瀛樺湪淇濆吇鏍囧噯
+ for (int j = 0; j < excelTable[0].Rows.Count; j++)
+ {
+ if (excelTable[0].Rows[j][1].ToString().Trim() != null && excelTable[0].Rows[j][1].ToString().Trim() != "")
+ {
+ sql = @"select * from TEqpmai_Main where code=@code";
+ dynamicParams.Add("@code", excelTable[0].Rows[j][1].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧淇濆吇鏍囧噯缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧淇濆吇鏍囧噯琛�:{璁惧淇濆吇鏍囧噯缂栧彿(鍞竴)}瀛楁" + excelTable[0].Rows[j][1].ToString().Trim() + "鍦ㄦ暟鎹〃涓凡瀛樺湪";
+ list.Add(erro);
+ }
+ //閫氳繃璁惧淇濆吇鏍囧噯椤电妯℃澘涓殑鏍囧噯缂栫爜鏌ヨ璁惧淇濆吇閮ㄤ綅椤电妯℃澘涓搴旂殑鏁版嵁淇℃伅
+ var var_dtTable = excelTable[1].AsEnumerable().Where<DataRow>(W => W["璁惧淇濆吇鏍囧噯缂栧彿"].ToString() == excelTable[0].Rows[j][1].ToString().Trim());
+ DataTable ds = var_dtTable.Any() ? var_dtTable.CopyToDataTable() : excelTable[1].Clone();
+ if (ds.Rows.Count > 0)
+ {
+ //鍒ゆ柇淇濆吇鏍囧噯鏌ヨ淇濆吇閮ㄤ綅鏁版嵁鏄惁鏈夐噸澶�
+ DataTable distinct1 = ds.DefaultView.ToTable(true, "璁惧淇濆吇閮ㄤ綅缂栧彿(鍞竴)");
+ if (distinct1.Rows.Count != ds.Rows.Count)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧淇濆吇閮ㄤ綅缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧淇濆吇閮ㄤ綅椤电妯℃澘:{璁惧淇濆吇鏍囧噯缂栧彿}:" + excelTable[1].Rows[j][2].ToString().Trim() + " 瀵瑰簲{璁惧淇濆吇閮ㄤ綅缂栧彿(鍞竴)}鏈夐噸澶�";
+ list.Add(erro);
+ }
+ }
+ else
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧淇濆吇閮ㄤ綅缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧淇濆吇閮ㄤ綅椤电妯℃澘:{璁惧淇濆吇鏍囧噯缂栧彿}:" + excelTable[1].Rows[j][2].ToString().Trim() + " 鍦ㄨ澶囦繚鍏绘爣鍑嗛〉绛炬ā鏉夸腑涓嶅瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ }
+ //褰撳墠Excel鏁版嵁涓偣妫�閮ㄤ綅椤电涓�,璁惧淇濆吇閮ㄤ綅缂栧彿(鍞竴)鍦ㄨ澶囦繚鍏婚儴浣嶈〃涓槸鍚﹀瓨鍦�
+ for (int k = 0; k < excelTable[1].Rows.Count; k++)
+ {
+ if (excelTable[1].Rows[k][3].ToString().Trim() != null && excelTable[1].Rows[k][3].ToString().Trim() != "")
+ {
+ sql = @"select * from TEqpmai_Item where code=@code";
+ dynamicParams.Add("@code", excelTable[1].Rows[k][3].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count < 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧淇濆吇閮ㄤ綅缂栧彿(鍞竴)}";
+ erro.ErrorCont = "璁惧淇濆吇閮ㄤ綅琛�:{璁惧淇濆吇閮ㄤ綅缂栧彿(鍞竴)}瀛楁" + excelTable[1].Rows[k][2].ToString().Trim() + "鍦ㄦ暟鎹〃涓笉瀛樺湪";
+ list.Add(erro);
+ }
+ }
+ }
+ //鍒ゆ柇瀛愯〃澶栭敭涓嶅瓨鍦ㄤ簬涓昏〃涓婚敭涓殑鏁版嵁
+ var dt3 = from r in excelTable[1].AsEnumerable()
+ where !(
+ from rr in excelTable[0].AsEnumerable()
+ select rr.Field<string>("璁惧淇濆吇鏍囧噯缂栧彿(鍞竴)")
+ ).Contains(r.Field<string>("璁惧淇濆吇鏍囧噯缂栧彿"))
+ select r;
+ List<DataRow> listRow = dt3.ToList();
+ if (listRow.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧淇濆吇鏍囧噯缂栧彿}";
+ erro.ErrorCont = "璁惧淇濆吇閮ㄤ綅椤电妯℃澘:{璁惧淇濆吇鏍囧噯缂栧彿}瀛楁涓湁鍊煎湪璁惧淇濆吇鏍囧噯椤电妯℃澘:{璁惧淇濆吇鏍囧噯缂栧彿(鍞竴)}涓笉瀛樺湪";
+ list.Add(erro);
+ }
+ if (list.Count > 0)
+ {
+ int index = 0;
+ foreach (ExcelErro item in list)
+ {
+ index++;
+ item.Seq = index.ToString();
+ }
+ StuCode = "301";
+ message = "鏁版嵁楠岃瘉澶辫触";
+ }
+ else
+ {
+ StuCode = "200";
+ message = "鏁版嵁楠岃瘉鎴愬姛";
+ count = excelTable[0].Rows.Count + excelTable[1].Rows.Count;
+ }
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,宸ヨ娓呭崟銆�
+ public static List<ExcelErro> TwelveData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,宸ヨ鐐规銆�
+ public static List<ExcelErro> ThirteenData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,宸ヨ淇濆吇銆�
+ public static List<ExcelErro> FourteenData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,宸ュ簭瀹氫箟銆�
+ public static List<ExcelErro> FifteenData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,宸ヨ壓璺嚎銆�
+ public static List<ExcelErro> SixteenData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,鑺傛媿宸ヤ环銆�
+ public static List<ExcelErro> TwentyFourData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ var dynamicParams = new DynamicParameters();
+ List<ExcelErro> list = new List<ExcelErro>();
+ DataTable excelTable = new DataTable();
+ list = ImportExcel.ExcelToTableErro(FileCode); //楠岃瘉Excel鏁版嵁蹇呭~瀛楁鏄惁涓虹┖銆佸敮涓�瀛楁鏄惁閲嶅
+ excelTable = ImportExcel.ExcelToTable(FileCode); //鑾峰彇Excel鏁版嵁
+ for (int i = 0; i < excelTable.Rows.Count; i++)
+ {
+ //浜у搧鏄惁瀛樺湪
+ sql = @"select partname from TMateriel_Info
+ where partname=@partname";
+ dynamicParams.Add("@partname", excelTable.Rows[i][1].ToString().Trim());
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count <= 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{浜у搧鍚嶇О}";
+ erro.ErrorCont = "瀛樿揣妗f:{浜у搧鍚嶇О}瀛楁" + excelTable.Rows[i][1].ToString().Trim() + "涓嶅瓨鍦�";
+ list.Add(erro);
+ }
+ //宸ヨ壓璺嚎鏄惁瀛樺湪
+ sql = @"select name from TFlw_Rout
+ where name=@routename";
+ dynamicParams.Add("@routename", excelTable.Rows[i][2].ToString().Trim());
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count <= 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{宸ヨ壓璺嚎鍚嶇О}";
+ erro.ErrorCont = "宸ヨ壓璺嚎:{宸ヨ壓璺嚎鍚嶇О}瀛楁" + excelTable.Rows[i][2].ToString().Trim() + "涓嶅瓨鍦�";
+ list.Add(erro);
+ }
+ //宸ュ簭鏄惁瀛樺湪
+ sql = @"select stepname from TStep
+ where stepname=@stepname";
+ dynamicParams.Add("@stepname", excelTable.Rows[i][3].ToString().Trim());
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data1.Rows.Count <= 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{宸ュ簭鍚嶇О}";
+ erro.ErrorCont = "宸ュ簭瀹氫箟:{宸ュ簭鍚嶇О}瀛楁" + excelTable.Rows[i][3].ToString().Trim() + "涓嶅瓨鍦�";
+ list.Add(erro);
+ }
+ //璁惧鏄惁瀛樺湪
+ sql = @"select name from TEqpInfo
+ where name=@eqpname";
+ dynamicParams.Add("@eqpname", excelTable.Rows[i][4].ToString().Trim());
+ var data2 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data2.Rows.Count <= 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{璁惧鍚嶇О}";
+ erro.ErrorCont = "璁惧娓呭崟:{璁惧鍚嶇О}瀛楁" + excelTable.Rows[i][4].ToString().Trim() + "涓嶅瓨鍦�";
+ list.Add(erro);
+ }
+ //鍒ゆ柇浜у搧鏄惁鍏宠仈宸ヨ壓璺嚎
+ sql = @"select M.partname,R.name from TMateriel_Route A
+ inner join TMateriel_Info M on A.materiel_code=M.partcode
+ inner join TFlw_Rout R on A.route_code=R.code
+ where M.partname=@partname and R.name=@routename";
+ dynamicParams.Add("@partname", excelTable.Rows[i][1].ToString().Trim());
+ dynamicParams.Add("@routename", excelTable.Rows[i][2].ToString().Trim());
+ var data3 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data3.Rows.Count <= 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{浜у搧鍚嶇О/宸ヨ壓璺嚎鍚嶇О}";
+ erro.ErrorCont = "浜у搧鍏宠仈宸ヨ壓璺嚎:{浜у搧鍚嶇О}瀛楁:銆�" + excelTable.Rows[i][1].ToString().Trim() + "銆戝搴斿伐鑹鸿矾绾垮悕绉帮細銆�" + excelTable.Rows[i][2].ToString().Trim() + "銆戞湭鍏宠仈";
+ list.Add(erro);
+ }
+ //鍒ゆ柇宸ヨ壓璺嚎鏄惁鍏宠仈宸ュ簭
+ sql = @"select R.name,S.stepname from TFlw_Rtdt A
+ inner join TFlw_Rout R on A.rout_code=R.code
+ inner join TStep S on A.step_code=S.stepcode
+ where R.name=@routename and S.stepname=@stepname";
+ dynamicParams.Add("@routename", excelTable.Rows[i][2].ToString().Trim());
+ dynamicParams.Add("@stepname", excelTable.Rows[i][3].ToString().Trim());
+ var data4 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data4.Rows.Count <= 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{宸ヨ壓璺嚎鍚嶇О/宸ュ簭鍚嶇О}";
+ erro.ErrorCont = "宸ヨ壓璺嚎鍏宠仈宸ュ簭:{宸ヨ壓璺嚎鍚嶇О}瀛楁:銆�" + excelTable.Rows[i][2].ToString().Trim() + "銆戝搴斿伐搴忓悕绉帮細銆�" + excelTable.Rows[i][3].ToString().Trim() + "銆戞湭鍏宠仈";
+ list.Add(erro);
+ }
+ //鍒ゆ柇宸ュ簭鏄惁鍏宠仈璁惧
+ sql = @"select E.name,S.stepname from TFlw_Rteqp A
+ inner join TStep S on A.step_code=S.stepcode
+ inner join TEqpInfo E on A.eqp_code=E.code
+ where S.stepname=@stepname and E.name=@eqpname";
+ dynamicParams.Add("@stepname", excelTable.Rows[i][3].ToString().Trim());
+ dynamicParams.Add("@eqpname", excelTable.Rows[i][4].ToString().Trim());
+ var data5 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data5.Rows.Count <= 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{宸ュ簭鍚嶇О/璁惧鍚嶇О}";
+ erro.ErrorCont = "宸ュ簭鍏宠仈璁惧:{宸ュ簭鍚嶇О}瀛楁:銆�" + excelTable.Rows[i][3].ToString().Trim() + "銆戝搴旇澶囧悕绉帮細銆�" + excelTable.Rows[i][4].ToString().Trim() + "銆戞湭鍏宠仈";
+ list.Add(erro);
+ }
+ }
+ if (list.Count > 0)
+ {
+ int index = 0;
+ foreach (ExcelErro item in list)
+ {
+ index++;
+ item.Seq = index.ToString();
+ }
+ StuCode = "301";
+ message = "鏁版嵁楠岃瘉澶辫触";
+ }
+ else
+ {
+ StuCode = "200";
+ message = "鏁版嵁楠岃瘉鎴愬姛";
+ count = excelTable.Rows.Count;
+ }
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,璐ㄦ鏍囧噯銆�
+ public static List<ExcelErro> SeventeenData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,缂洪櫡瀹氫箟銆�
+ public static List<ExcelErro> EighteenData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ var dynamicParams = new DynamicParameters();
+ List<ExcelErro> list = new List<ExcelErro>();
+ DataTable excelTable = new DataTable();
+ list = ImportExcel.ExcelToTableErro(FileCode); //楠岃瘉Excel鏁版嵁蹇呭~瀛楁鏄惁涓虹┖銆佸敮涓�瀛楁鏄惁閲嶅
+ excelTable = ImportExcel.ExcelToTable(FileCode); //鑾峰彇Excel鏁版嵁
+ for (int i = 0; i < excelTable.Rows.Count; i++)
+ {
+ if (excelTable.Rows[i][1].ToString().Trim() != null && excelTable.Rows[i][1].ToString().Trim() != "")
+ {
+ sql = @"select code from TDefect where code=@code";
+
+ dynamicParams.Add("@code", excelTable.Rows[i][1].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{缂洪櫡瀹氫箟缂栧彿(鍞竴)}";
+ erro.ErrorCont = "缂洪櫡瀹氫箟琛�:{缂洪櫡瀹氫箟缂栧彿(鍞竴)}瀛楁" + excelTable.Rows[i][1].ToString().Trim() + "宸插瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ }
+ if (list.Count > 0)
+ {
+ int index = 0;
+ foreach (ExcelErro item in list)
+ {
+ index++;
+ item.Seq = index.ToString();
+ }
+ StuCode = "301";
+ message = "鏁版嵁楠岃瘉澶辫触";
+ }
+ else
+ {
+ StuCode = "200";
+ message = "鏁版嵁楠岃瘉鎴愬姛";
+ count = excelTable.Rows.Count;
+ }
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,鐢熶骇璁㈠崟銆�
+ public static List<ExcelErro> NineteenData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+
+ return list;
+ }
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,搴撳瓨鏌ヨ銆�
+ public static List<ExcelErro> TwentyData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ DataTable dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+
+ return list;
+ }
+
+ #region銆愯幏鍙栧簱瀛樼殑瀹瑰櫒涓槸鍚﹀悓涓�涓骇鍝併��
+
+ public static Boolean getSamePNofTote(String PN, String Tote_ID)
+ {
+ Boolean bRes = false;
+ String sql = "";
+ String stockPN = "";
+ DataTable dt = null;
+
+ if (String.IsNullOrEmpty(PN))
+ {
+ bRes = true;
+ }
+ else
+ {
+ sql = @"select part_number from mes_tk_wms_stock where tote_id='" + Tote_ID + "' and qty>0 ";
+ dt = DBHelper.GetTable(sql);
+ if (dt.Rows.Count > 0)
+ {
+ stockPN = dt.Rows[0]["part_number"].ToString();
+ if (PN == stockPN)
+ {
+ bRes = true;
+ }
+ }
+ else
+ {
+ //浠撳簱涓笉瀛樺湪姝ゅ鍣�
+ bRes = true;
+ }
+ }
+ return bRes;
+ }
+ #endregion
+ #endregion
+
+ #region銆怑xcel涓婁紶鏁版嵁楠岃瘉,鐗╂枡娓呭崟銆�
+ public static List<ExcelErro> TwentyOneData(string FileCode, out string StuCode, out string message, out int count)
+ {
+ message = "";
+ StuCode = "";
+ count = 0;
+ string sql = "";
+ var dynamicParams = new DynamicParameters();
+ DataTable dt0, dt;
+ List<ExcelErro> list = new List<ExcelErro>();
+ List<DataTable> excelTable = new List<DataTable>();
+ list = ImportExcel.ExcelToTableListErro(FileCode); //楠岃瘉Excel鏁版嵁蹇呭~瀛楁鏄惁涓虹┖銆佸敮涓�瀛楁鏄惁閲嶅
+ excelTable = ImportExcel.ExcelToTableList(FileCode); //鑾峰彇Excel鏁版嵁
+ //Excel鏌ヨ姣嶄欢+鐗堟湰鍙锋槸鍚﹂噸澶�
+ DataTable distinct = excelTable[0].DefaultView.ToTable(true, new string[] { "姣嶄欢缂栫爜", "鐗堟湰鍙�" });
+ if (distinct.Rows.Count != excelTable[0].Rows.Count)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{鐗堟湰鍙穧";
+ erro.ErrorCont = "Bom姣嶄欢琛�:{姣嶄欢缂栫爜}瀵瑰簲鐨剓鐗堟湰鍙穧鏈夐噸澶�";
+ list.Add(erro);
+ }
+ //鍒ゆ柇瀛愯〃澶栭敭涓嶅瓨鍦ㄤ簬涓昏〃涓婚敭涓殑鏁版嵁
+ var dt3 = from r in excelTable[1].AsEnumerable()
+ where !(
+ from rr in excelTable[0].AsEnumerable()
+ select rr.Field<string>("搴忓彿")
+ ).Contains(r.Field<string>("涓昏〃搴忓垪鍙�"))
+ select r;
+ List<DataRow> listRow = dt3.ToList();
+ if (listRow.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{涓昏〃搴忓垪鍙穧";
+ erro.ErrorCont = "瀛愪欢淇℃伅:{涓昏〃搴忓垪鍙穧瀛楁涓湁鍊煎湪姣嶄欢淇℃伅:{搴忓彿}涓笉瀛樺湪";
+ list.Add(erro);
+ }
+ //鏁版嵁搴撴煡璇㈡瘝浠�+鐗堟湰鍙锋槸鍚﹀瓨鍦�
+ for (int j = 0; j < excelTable[0].Rows.Count; j++)
+ {
+ if (excelTable[0].Rows[j][1].ToString().Trim() != null && excelTable[0].Rows[j][1].ToString().Trim() != "")
+ {
+ //鍒ゆ柇姣嶄欢鍦ㄥ瓨璐т腑鏄惁瀛樺湪
+ sql = @"select * from TMateriel_Info where partcode=@partcode";
+ dynamicParams.Add("@partcode", excelTable[0].Rows[j][1].ToString().Trim());
+ dt0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt0.Rows.Count <= 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{姣嶄欢缂栫爜}";
+ erro.ErrorCont = "Bom姣嶄欢琛�:{姣嶄欢缂栫爜}瀛楁" + excelTable[0].Rows[j][1].ToString().Trim() + "鍦ㄥ瓨璐ф。妗堜腑涓嶅瓨鍦�";
+ list.Add(erro);
+ }
+
+ sql = @"select * from TBom_Main where materiel_code=@code and version=@version";
+ dynamicParams.Add("@code", excelTable[0].Rows[j][1].ToString().Trim());
+ dynamicParams.Add("@version", excelTable[0].Rows[j][5].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{姣嶄欢缂栫爜}";
+ erro.ErrorCont = "Bom姣嶄欢琛�:{姣嶄欢缂栫爜}瀛楁" + excelTable[0].Rows[j][1].ToString().Trim() + "瀵瑰簲鐨勭増鏈彿:" + excelTable[0].Rows[j][5].ToString() + "宸插瓨鍦�";
+ list.Add(erro);
+ }
+ //鏌ヨ姣嶄欢淇℃伅瀵瑰簲鐨勫瓙浠朵俊鎭�
+ var var_dtTable = excelTable[1].AsEnumerable().Where<DataRow>(W => W["涓昏〃搴忓垪鍙�"].ToString() == excelTable[0].Rows[j][0].ToString().Trim());
+ DataTable ds = var_dtTable.Any() ? var_dtTable.CopyToDataTable() : excelTable[1].Clone();
+ if (ds.Rows.Count > 0)
+ {
+ //鍒ゆ柇鍚屾瘝浠跺搴旂殑瀛愪欢鏄惁閲嶅
+ DataTable distinct1 = ds.DefaultView.ToTable(true, "瀛愪欢缂栫爜");
+ if (distinct1.Rows.Count != ds.Rows.Count)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{瀛愪欢缂栫爜}";
+ erro.ErrorCont = "鐗╂枡娓呭崟瀵瑰簲瀛愪欢淇℃伅椤电妯℃澘:涓昏〃搴忓垪鍙凤細銆�" + excelTable[1].Rows[j]["涓昏〃搴忓垪鍙�"].ToString() + "銆戝搴攞瀛愪欢缂栫爜}鏈夐噸澶�";
+ list.Add(erro);
+ }
+ }
+ else
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{涓昏〃搴忓垪鍙穧";
+ erro.ErrorCont = "鐗╂枡娓呭崟瀵瑰簲瀛愪欢淇℃伅椤电妯℃澘:{涓昏〃搴忓垪鍙穧:" + excelTable[1].Rows[j][1].ToString().Trim() + " 鍦ㄦ瘝浠朵俊鎭〉绛炬ā鏉夸腑涓嶅瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ }
+ //瀛愪欢鍒ゆ柇
+ for (int k = 0; k < excelTable[1].Rows.Count; k++)
+ {
+ if (excelTable[1].Rows[k][3].ToString().Trim() != null && excelTable[1].Rows[k][3].ToString().Trim() != "")
+ {
+ sql = @"select * from TMateriel_Info where partcode=@partcode";
+ dynamicParams.Add("@partcode", excelTable[1].Rows[k][3].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count <= 0)
+ {
+ ExcelErro erro = new ExcelErro();
+ erro.RoeNumber = "/";
+ erro.ErrorField = "{瀛愪欢缂栫爜}";
+ erro.ErrorCont = "鐗╂枡娓呭崟瀛愪欢淇℃伅:{瀛愪欢缂栫爜}瀛楁" + excelTable[1].Rows[k][3].ToString().Trim() + "鍦ㄥ瓨璐ф。妗堜腑涓嶅瓨鍦�";
+ list.Add(erro);
+ }
+ }
+ }
+ if (list.Count > 0)
+ {
+ int index = 0;
+ foreach (ExcelErro item in list)
+ {
+ index++;
+ item.Seq = index.ToString();
+ }
+ StuCode = "301";
+ message = "鏁版嵁楠岃瘉澶辫触";
+ }
+ else
+ {
+ StuCode = "200";
+ message = "鏁版嵁楠岃瘉鎴愬姛";
+ count = excelTable[0].Rows.Count + excelTable[1].Rows.Count;
+ }
+ return list;
+ }
+ #endregion
+ #endregion
+
+ #region[Excel涓婁紶鏁版嵁鎻愪氦]
+ #region銆怑xcel鏁版嵁涓婁紶,鐢ㄦ埛瑙掕壊銆�
+ public static string TwoSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ string sql = "";
+ string ZZName = "", Enable = "", WageType = "";
+ DataTable dt;
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ //瀵煎叆鐝粍
+ for (int k = 0; k < excelTable[0].Rows.Count; k++)
+ {
+ sql = @"select * from TGroup where group_code=@group_code";
+ dynamicParams.Add("@group_code", excelTable[0].Rows[k][2].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ continue;
+ }
+ else
+ {
+ sql = @"insert into TGroup(group_code,group_name,description,lm_user,lm_date,torg_code)
+ values(@group_code,@group_name,@description,@Operator,@CreateDate,@torg_code)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ group_code = excelTable[0].Rows[k][2].ToString().Trim(),
+ group_name = excelTable[0].Rows[k][3].ToString().Trim(),
+ description = excelTable[0].Rows[k][4].ToString().Trim(),
+ CreateDate = DateTime.Now.ToString(),
+ Operator = User,
+ torg_code = excelTable[0].Rows[k][1].ToString().Trim()
+ }
+ });
+ }
+ }
+ //瀵煎叆鐢ㄦ埛
+ for (int i = 0; i < excelTable[1].Rows.Count; i++)
+ {
+ if (excelTable[1].Rows[i][3].ToString().Trim() == "鍦ㄨ亴")
+ {
+ Enable = "Y";
+ }
+ else
+ {
+ Enable = "N";
+ }
+ //宸ヨ祫绫诲瀷
+ switch (excelTable[1].Rows[i][8].ToString().Trim())
+ {
+ case "璁′欢鍒�":
+ WageType = "2";
+ break;
+ case "璁℃椂鍒�":
+ WageType = "1";
+ break;
+ default:
+ break;
+ }
+ sql = @"select * from TUser where usercode=@usercode";
+ dynamicParams.Add("@usercode", excelTable[1].Rows[i][1].ToString().Trim());
+ dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ continue;
+ }
+ sql = @"insert into TUser(usercode,username,password,enable,mobile,lm_date,email,lm_user,stu_torgcode,wagetype,usergroup_code)
+ values(@UserCode,@UserName,@password,@Enable,@Mobile,@CreateDate,@Email,@Operator,@StuOrg,@wagetype,@usergroup_code)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ UserCode = excelTable[1].Rows[i][1].ToString().Trim(),
+ UserName = excelTable[1].Rows[i][2].ToString().Trim(),
+ password = excelTable[1].Rows[i][4].ToString().Trim(),
+ Enable = Enable,
+ Mobile = excelTable[1].Rows[i][5].ToString().Trim(),
+ CreateDate = DateTime.Now.ToString(),
+ Email = excelTable[1].Rows[i][6].ToString().Trim(),
+ Operator = User,
+ StuOrg = excelTable[1].Rows[i][7].ToString().Trim(),
+ wagetype = WageType,
+ usergroup_code = excelTable[1].Rows[i][9].ToString().Trim()
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ StuCode = "200";
+ message = "瀵煎叆鎴愬姛锛�";
+ }
+ else
+ {
+ StuCode = "300";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,瑙掕壊鏉冮檺銆�
+ public static string OneSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ string sql = "";
+ string ZZName = "", Enable = "", WageType = "";
+ DataTable dt;
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ //瀵煎叆瑙掕壊绫诲瀷
+ for (int k = 0; k < excelTable[0].Rows.Count; k++)
+ {
+ sql = @"insert into TRoleType(roletype_code,roletype_name,torg_code)
+ values(@roletype_code,@roletype_name,@torg_code)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ roletype_code = excelTable[0].Rows[k][2].ToString().Trim(),
+ roletype_name = excelTable[0].Rows[k][3].ToString().Trim(),
+ torg_code = excelTable[0].Rows[k][1].ToString().Trim()
+ }
+ });
+ }
+ //瀵煎叆瑙掕壊
+ for (int i = 0; i < excelTable[1].Rows.Count; i++)
+ {
+ sql = @"insert into TRole(role_code,role_name,roletype_code,description,lm_user,lm_date,torg_code)
+ values(@role_code,@role_name,@roletype_code,@description,@Operator,@CreateDate,@torg_code)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ role_code = excelTable[1].Rows[i][2].ToString().Trim(),
+ role_name = excelTable[1].Rows[i][3].ToString().Trim(),
+ roletype_code = excelTable[1].Rows[i][4].ToString().Trim(),
+ description = excelTable[1].Rows[i][5].ToString().Trim(),
+ Operator = User,
+ CreateDate = DateTime.Now.ToString(),
+ torg_code = excelTable[1].Rows[i][1].ToString().Trim()
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ StuCode = "200";
+ message = "瀵煎叆鎴愬姛锛�";
+ }
+ else
+ {
+ StuCode = "300";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,宸ヤ綅娓呭崟銆�
+ public static string ThreeSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ try
+ {
+
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,寰�鏉ュ崟浣嶆竻鍗曘��
+ public static string FourSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ string sql = "";
+ DataTable dt;
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ DataTable excelTable = new DataTable();
+ excelTable = ImportExcel.ExcelToTable(FileCode);
+ //瀵煎叆寰�鏉ュ崟浣嶈〃
+ for (int i = 0; i < excelTable.Rows.Count; i++)
+ {
+ string Type = "";
+ switch (excelTable.Rows[i][3].ToString().Trim())
+ {
+ case "渚涘簲鍟�":
+ Type = "226";
+ break;
+ case "瀹㈡埛":
+ Type = "211";
+ break;
+ case "瀹㈡埛/渚涘簲鍟�":
+ Type = "228";
+ break;
+ default:
+ break;
+ }
+
+ sql = @"insert into TCustomer(code,name,type,conttacts,conttphone,addr,lm_user,lm_date)
+ values(@code,@name,@type,@conttacts,@conttphone,@addr,@Operator,@CreateDate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ code = excelTable.Rows[i][1].ToString().Trim(),
+ name = excelTable.Rows[i][2].ToString().Trim(),
+ type = Type,
+ conttacts = excelTable.Rows[i][4].ToString().Trim(),
+ conttphone = excelTable.Rows[i][5].ToString().Trim(),
+ addr = excelTable.Rows[i][6].ToString().Trim(),
+ Operator = User,
+ CreateDate = DateTime.Now.ToString()
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ StuCode = "200";
+ message = "瀵煎叆鎴愬姛锛�";
+ }
+ else
+ {
+ StuCode = "300";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,浠撳簱銆佸簱浣嶅畾涔夈��
+ public static string SixOneSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ string sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ //瀵煎叆浠撳簱
+ for (int k = 0; k < excelTable[0].Rows.Count; k++)
+ {
+ sql = @"insert into T_Sec_Stck(code,name,description,lm_user,lm_date)
+ values(@code,@name,@description,@Operator,@CreateDate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ code = excelTable[0].Rows[k][1].ToString().Trim(),
+ name = excelTable[0].Rows[k][2].ToString().Trim(),
+ description = excelTable[0].Rows[k][3].ToString().Trim(),
+ CreateDate = DateTime.Now.ToString(),
+ Operator = User
+ }
+ });
+ }
+ //瀵煎叆搴撲綅
+ for (int i = 0; i < excelTable[1].Rows.Count; i++)
+ {
+ sql = @"insert into T_Sec_Loca(code,name,description,stock_code,lm_user,lm_date)
+ values(@code,@name,@description,@stock_code,@Operator,@CreateDate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ code = excelTable[1].Rows[i][1].ToString().Trim(),
+ name = excelTable[1].Rows[i][2].ToString().Trim(),
+ stock_code = excelTable[1].Rows[i][3].ToString().Trim(),
+ description = excelTable[1].Rows[i][4].ToString().Trim(),
+ Operator = User,
+ CreateDate = DateTime.Now.ToString()
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ StuCode = "200";
+ message = "瀵煎叆鎴愬姛锛�";
+ }
+ else
+ {
+ StuCode = "300";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,瀹瑰櫒瀹氫箟銆�
+ public static string SevenSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ try
+ {
+
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,瀛樿揣妗f銆�
+ public static string EightSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ try
+ {
+
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,璁惧娓呭崟銆�
+ public static string NineSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = ""; StuCode = "";
+ string sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ DataTable excelTable = new DataTable();
+ excelTable = ImportExcel.ExcelToTable(FileCode);
+ //瀵煎叆璁惧娓呭崟
+ for (int k = 0; k < excelTable.Rows.Count; k++)
+ {
+ sql = @"select * from TEqpInfo where code=@eqp_code";
+ dynamicParams.Add("@eqp_code", excelTable.Rows[k][1].ToString().Trim());
+ DataTable dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0)
+ {
+ continue;
+ }
+ sql = @"insert into TEqpInfo(code,name,wksp_code,input_date,operation_ration,enable,opc_uom,lm_user,lm_date)
+ values(@devicecode,@devicename,@workshop,@importdate,@ratio,@status,@uom,@lm_user,@lm_date)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ devicecode = excelTable.Rows[k][1].ToString().Trim(),
+ devicename = excelTable.Rows[k][2].ToString().Trim(),
+ workshop = excelTable.Rows[k][4].ToString().Trim(),
+ importdate = excelTable.Rows[k][3].ToString().Trim(),
+ ratio = excelTable.Rows[k][6].ToString().Trim(),
+ status = excelTable.Rows[k][5].ToString().Trim(),
+ uom = "鍙�",
+ lm_user = User,
+ lm_date = DateTime.Now.ToString()
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ StuCode = "200";
+ message = "瀵煎叆鎴愬姛锛�";
+ }
+ else
+ {
+ StuCode = "300";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,璁惧鐐规椤圭洰銆�
+ public static string TenSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ string sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ DataTable excelTable = new DataTable();
+ excelTable = ImportExcel.ExcelToTable(FileCode);
+ //瀵煎叆璁惧鐐规椤圭洰琛�
+ for (int i = 0; i < excelTable.Rows.Count; i++)
+ {
+ string Type = "", IsScan = "";
+ switch (excelTable.Rows[i][3].ToString().Trim())
+ {
+ case "骞�":
+ Type = "Y";
+ break;
+ case "瀛�":
+ Type = "S";
+ break;
+ case "鏈�":
+ Type = "M";
+ break;
+ case "鍛�":
+ Type = "W";
+ break;
+ case "鏃�":
+ Type = "D";
+ break;
+ default:
+ break;
+ }
+ switch (excelTable.Rows[i][4].ToString().Trim())
+ {
+ case "鏄�":
+ IsScan = "Y";
+ break;
+ case "鍚�":
+ IsScan = "N";
+ break;
+ default:
+ break;
+ }
+ sql = @"insert into TEqpchk_Item(code,name,description,isscan,cycle,lm_user,lm_date)
+ values(@code,@name,@descr,@isscan,@cycle,@Operator,@CreateDate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ code = excelTable.Rows[i][1].ToString().Trim(),
+ name = excelTable.Rows[i][2].ToString().Trim(),
+ descr = excelTable.Rows[i][5].ToString().Trim(),
+ isscan = IsScan,
+ cycle = Type,
+ Operator = User,
+ CreateDate = DateTime.Now.ToString()
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ StuCode = "200";
+ message = "瀵煎叆鎴愬姛锛�";
+ }
+ else
+ {
+ StuCode = "300";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,璁惧鐐规鏍囧噯銆�
+ public static string TwentyTwoSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ string sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ //瀵煎叆璁惧鐐规鏍囧噯涓昏〃
+ for (int k = 0; k < excelTable[0].Rows.Count; k++)
+ {
+ sql = @"insert into TEqpchk_Main(code,name,description,iscontr,lm_user,lm_date)
+ values(@code,@name,@description,@iscontr,@Operator,@CreateDate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ code = excelTable[0].Rows[k][1].ToString().Trim(),
+ name = excelTable[0].Rows[k][2].ToString().Trim(),
+ iscontr = excelTable[0].Rows[k][3].ToString().Trim(),
+ description = excelTable[0].Rows[k][4].ToString().Trim(),
+ CreateDate = DateTime.Now.ToString(),
+ Operator = User
+ }
+ });
+ }
+ //瀵煎叆璁惧鐐规鏍囧噯閮ㄤ綅瀛愯〃
+ for (int i = 0; i < excelTable[1].Rows.Count; i++)
+ {
+ string Type = "";
+ switch (excelTable[1].Rows[i][7].ToString().Trim())
+ {
+ case "鏃�":
+ Type = "D";
+ break;
+ default:
+ break;
+ }
+ sql = @"insert into TEqpchk_Deta(seq,code,name,eqpchk_main_code,chkdesc,isscan,cycle,lm_user,lm_date)
+ values(@seq,@code,@name,@eqpchk_main_code,@description,@isscan,@cycle,@Operator,@CreateDate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ seq = excelTable[1].Rows[i][1].ToString().Trim(),
+ code = excelTable[1].Rows[i][3].ToString().Trim(),
+ name = excelTable[1].Rows[i][4].ToString().Trim(),
+ eqpchk_main_code = excelTable[1].Rows[i][2].ToString().Trim(),
+ description = excelTable[1].Rows[i][5].ToString().Trim(),
+ isscan = excelTable[1].Rows[i][6].ToString().Trim(),
+ cycle = Type,
+ Operator = User,
+ CreateDate = DateTime.Now.ToString()
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ StuCode = "200";
+ message = "瀵煎叆鎴愬姛锛�";
+ }
+ else
+ {
+ StuCode = "300";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,璁惧淇濆吇椤圭洰銆�
+ public static string ElevenSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ string sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ DataTable excelTable = new DataTable();
+ excelTable = ImportExcel.ExcelToTable(FileCode);
+ //瀵煎叆璁惧鐐规椤圭洰琛�
+ for (int i = 0; i < excelTable.Rows.Count; i++)
+ {
+ string Type = "", IsScan = "";
+ //switch (excelTable.Rows[i][3].ToString().Trim())
+ //{
+ // case "骞�":
+ // Type = "Y";
+ // break;
+ // case "瀛�":
+ // Type = "S";
+ // break;
+ // case "鏈�":
+ // Type = "M";
+ // break;
+ // case "鍛�":
+ // Type = "W";
+ // break;
+ // case "鏃�":
+ // Type = "D";
+ // break;
+ // default:
+ // break;
+ //}
+ switch (excelTable.Rows[i][3].ToString().Trim())
+ {
+ case "鏄�":
+ IsScan = "Y";
+ break;
+ case "鍚�":
+ IsScan = "N";
+ break;
+ default:
+ break;
+ }
+ sql = @"insert into TEqpmai_Item(code,name,description,isscan,cycle,lm_user,lm_date)
+ values(@code,@name,@descr,@isscan,@cycle,@Operator,@CreateDate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ code = excelTable.Rows[i][1].ToString().Trim(),
+ name = excelTable.Rows[i][2].ToString().Trim(),
+ descr = excelTable.Rows[i][4].ToString().Trim(),
+ isscan = IsScan,
+ cycle = "",
+ Operator = User,
+ CreateDate = DateTime.Now.ToString()
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ StuCode = "200";
+ message = "瀵煎叆鎴愬姛锛�";
+ }
+ else
+ {
+ StuCode = "300";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,璁惧淇濆吇鏍囧噯銆�
+ public static string TwentyThreeSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ string sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ //瀵煎叆璁惧淇濆吇鏍囧噯涓昏〃
+ for (int k = 0; k < excelTable[0].Rows.Count; k++)
+ {
+ string Type = "";
+ switch (excelTable[0].Rows[k][3].ToString().Trim())
+ {
+ case "骞�":
+ Type = "Y";
+ break;
+ case "瀛�":
+ Type = "S";
+ break;
+ case "鏈�":
+ Type = "M";
+ break;
+ case "鍛�":
+ Type = "W";
+ break;
+ default:
+ break;
+ }
+ sql = @"insert into TEqpmai_Main(code,name,description,main_cycle,lm_user,lm_date)
+ values(@code,@name,@description,@main_cycle,@Operator,@CreateDate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ code = excelTable[0].Rows[k][1].ToString().Trim(),
+ name = excelTable[0].Rows[k][2].ToString().Trim(),
+ main_cycle = Type,
+ description = excelTable[0].Rows[k][4].ToString().Trim(),
+ CreateDate = DateTime.Now.ToString(),
+ Operator = User
+ }
+ });
+ }
+ //瀵煎叆璁惧淇濆吇鏍囧噯閮ㄤ綅瀛愯〃
+ for (int i = 0; i < excelTable[1].Rows.Count; i++)
+ {
+ sql = @"insert into TEqpmai_Deta(seq,code,name,eapmai_code,chk_desc,isscan,lm_user,lm_date)
+ values(@seq,@code,@name,@eapmai_code,@description,@isscan,@Operator,@CreateDate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ seq = excelTable[1].Rows[i][1].ToString().Trim(),
+ code = excelTable[1].Rows[i][3].ToString().Trim(),
+ name = excelTable[1].Rows[i][4].ToString().Trim(),
+ eapmai_code = excelTable[1].Rows[i][2].ToString().Trim(),
+ description = excelTable[1].Rows[i][5].ToString().Trim(),
+ isscan = excelTable[1].Rows[i][6].ToString().Trim(),
+ Operator = User,
+ CreateDate = DateTime.Now.ToString()
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ StuCode = "200";
+ message = "瀵煎叆鎴愬姛锛�";
+ }
+ else
+ {
+ StuCode = "300";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,宸ヨ娓呭崟銆�
+ public static string TwelveSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ try
+ {
+
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,宸ヨ鐐规銆�
+ public static string ThirteenSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ try
+ {
+
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,宸ヨ淇濆吇銆�
+ public static string FourteenSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ try
+ {
+
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,宸ュ簭瀹氫箟銆�
+ public static string FifteenSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ try
+ {
+
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,宸ヨ壓璺嚎銆�
+ public static string SixteenSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ try
+ {
+
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,鑺傛媿宸ヤ环銆�
+ public static string TwentyFourSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ string sql = "";
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ DataTable excelTable = new DataTable();
+ excelTable = ImportExcel.ExcelToTable(FileCode);
+ //瀵煎叆璁惧鐐规椤圭洰琛�
+ for (int i = 0; i < excelTable.Rows.Count; i++)
+ {
+ string partcode = "", routecode = "", stepcode = "", eqpcode = "", wkspcode = "";
+ //鏌ヨ浜у搧缂栫爜
+ sql = @"select partcode from TMateriel_Info
+ where partname=@partname";
+ dynamicParams.Add("@partname", excelTable.Rows[i][1].ToString().Trim());
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ partcode = data.Rows[0]["partcode"].ToString();
+ }
+ else
+ {
+ StuCode = "浜у搧鍚嶇О锛氥��" + excelTable.Rows[i][1].ToString().Trim() + "銆戝搴旂紪鐮佷笉瀛樺湪锛�";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ //鏌ヨ宸ヨ壓璺嚎缂栫爜
+ sql = @"select code from TFlw_Rout
+ where name=@routename";
+ dynamicParams.Add("@routename", excelTable.Rows[i][2].ToString().Trim());
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ routecode = data0.Rows[0]["code"].ToString();
+ }
+ else
+ {
+ StuCode = "宸ヨ壓璺嚎鍚嶇О锛氥��" + excelTable.Rows[i][2].ToString().Trim() + "銆戝搴旂紪鐮佷笉瀛樺湪锛�";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ //鏌ヨ宸ュ簭缂栫爜
+ sql = @"select stepcode from TStep
+ where stepname=@stepname";
+ dynamicParams.Add("@stepname", excelTable.Rows[i][3].ToString().Trim());
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data1.Rows.Count > 0)
+ {
+ stepcode = data1.Rows[0]["stepcode"].ToString();
+ }
+ else
+ {
+ StuCode = "宸ュ簭鍚嶇О锛氥��" + excelTable.Rows[i][3].ToString().Trim() + "銆戝搴旂紪鐮佷笉瀛樺湪锛�";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ //鏌ヨ璁惧缂栫爜
+ sql = @"select code from TEqpInfo
+ where name=@eqpname";
+ dynamicParams.Add("@eqpname", excelTable.Rows[i][4].ToString().Trim());
+ var data4 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data4.Rows.Count > 0)
+ {
+ eqpcode = data4.Rows[0]["code"].ToString();
+ }
+ else
+ {
+ StuCode = "璁惧鍚嶇О锛氥��" + excelTable.Rows[i][4].ToString().Trim() + "銆戝搴旂紪鐮佷笉瀛樺湪锛�";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ //鏌ヨ杞﹂棿缂栫爜
+ sql = @"select wksp_code from TEqpInfo
+ where name=@eqpname";
+ dynamicParams.Add("@eqpname", excelTable.Rows[i][4].ToString().Trim());
+ var data5 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data5.Rows.Count > 0)
+ {
+ wkspcode = data5.Rows[0]["wksp_code"].ToString();
+ }
+ else
+ {
+ StuCode = "璁惧鍚嶇О锛氥��" + excelTable.Rows[i][4].ToString().Trim() + "銆戝搴旇溅闂寸紪鐮佷笉瀛樺湪锛�";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ //鏌ヨ宸ュ簭鑺傛媿琛ㄤ腑锛氫骇鍝�+宸ヨ壓璺嚎+宸ュ簭+璁惧鏄惁瀛樺湪
+ sql = @"select * from TPrteEqp_Stad
+ where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode";
+ dynamicParams.Add("@partcode", partcode);
+ dynamicParams.Add("@routecode", routecode);
+ dynamicParams.Add("@stepcode", stepcode);
+ dynamicParams.Add("@eqpcode", eqpcode);
+ var data6 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data6.Rows.Count > 0)
+ {
+ sql = @"update TPrteEqp_Stad set stand_value=@stand_value,eqp_value=@eqp_value,cavity_qty=@cavity_qty,unprice=@unprice,lm_user=@username,lm_date=@userdate
+ where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode ";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ partcode = partcode,
+ routecode = routecode,
+ stepcode = stepcode,
+ eqpcode = eqpcode,
+ stand_value = excelTable.Rows[i][7].ToString().Trim(),
+ eqp_value = excelTable.Rows[i][6].ToString().Trim(),
+ cavity_qty = excelTable.Rows[i][8].ToString().Trim(),
+ unprice = excelTable.Rows[i][5].ToString().Trim(),
+ username = User,
+ userdate = DateTime.Now.ToString()
+ }
+ });
+ }
+ else
+ {
+ sql = @"insert into TPrteEqp_Stad(materiel_code,eqp_code,stand_value,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,step_code)
+ values(@partcode,@eqpcode,@stand_value,@routecode,@unprice,@eqp_value,@cavity_qty,@wkspcode,@username,@userdate,@stepcode)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ partcode = partcode,
+ eqpcode = eqpcode,
+ stand_value = excelTable.Rows[i][7].ToString().Trim(),
+ routecode = routecode,
+ unprice = excelTable.Rows[i][5].ToString().Trim(),
+ eqp_value = excelTable.Rows[i][6].ToString().Trim(),
+ cavity_qty = excelTable.Rows[i][8].ToString().Trim(),
+ wkspcode = wkspcode,
+ username = User,
+ userdate = DateTime.Now.ToString(),
+ stepcode = stepcode
+ }
+ });
+ }
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ StuCode = "200";
+ message = "瀵煎叆鎴愬姛锛�";
+ }
+ else
+ {
+ StuCode = "300";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,璐ㄦ鏍囧噯銆�
+ public static string SeventeenSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ try
+ {
+
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,缂洪櫡瀹氫箟銆�
+ public static string EighteenSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ string sql = "";
+ DataTable dt;
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ DataTable excelTable = new DataTable();
+ excelTable = ImportExcel.ExcelToTable(FileCode);
+ //瀵煎叆寰�鏉ュ崟浣嶈〃
+ for (int i = 0; i < excelTable.Rows.Count; i++)
+ {
+ sql = @"insert into TDefect(code,name,descr,lm_user,lm_date)
+ values(@code,@name,@descr,@Operator,@CreateDate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ code = excelTable.Rows[i][1].ToString().Trim(),
+ name = excelTable.Rows[i][2].ToString().Trim(),
+ descr = excelTable.Rows[i][3].ToString().Trim(),
+ Operator = User,
+ CreateDate = DateTime.Now.ToString()
+ }
+ });
+ }
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ StuCode = "200";
+ message = "瀵煎叆鎴愬姛锛�";
+ }
+ else
+ {
+ StuCode = "300";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,鐢熶骇璁㈠崟銆�
+ public static string NineteenSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ try
+ {
+
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,搴撳瓨鏌ヨ銆�
+ public static string TwentySubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = "";
+ StuCode = "";
+ try
+ {
+
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #region銆怑xcel鏁版嵁涓婁紶,鐗╂枡娓呭崟銆�
+ public static string TwentyOneSubmit(string FileCode, string User, out string StuCode)
+ {
+ string message = ""; StuCode = "";
+ string sql = "";
+ int BomID = 0; //鏈�澶d
+ List<object> list = new List<object>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ list.Clear();
+ List<DataTable> excelTable = new List<DataTable>();
+ excelTable = ImportExcel.ExcelToTableList(FileCode);
+ //鑾峰彇涓昏〃褰撳墠鏈�澶D
+ BomID = DapperHelper.insertReturnId("TBom_Main");
+ //瀵煎叆Bom涓昏〃
+ for (int k = 0; k < excelTable[0].Rows.Count; k++)
+ {
+ BomID = BomID + 1;
+ sql = @"insert into TBom_Main(materiel_code,quantity,status,version,lm_user,lm_date,startdate)
+ values(@materiel_code,@quantity,@status,@version,@lm_user,@lm_date,@startdate)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ materiel_code = excelTable[0].Rows[k][1].ToString().Trim(),
+ quantity = excelTable[0].Rows[k][3].ToString().Trim(),
+ status = excelTable[0].Rows[k][4].ToString().Trim(),
+ version = excelTable[0].Rows[k][5].ToString().Trim(),
+ lm_user = User,
+ lm_date = DateTime.Now.ToString(),
+ startdate = DateTime.Now.ToString()
+ }
+ });
+ //鏌ヨ姣嶄欢淇℃伅瀵瑰簲鐨勫瓙浠朵俊鎭�
+ DataTable ds = excelTable[1].AsEnumerable().Where(item => item["涓昏〃搴忓垪鍙�"].ToString().Equals(excelTable[0].Rows[k][0].ToString())).CopyToDataTable();
+ //瀵煎叆Bom瀛愯〃
+ for (int i = 0; i < ds.Rows.Count; i++)
+ {
+ string Type = "";
+ switch (ds.Rows[i][9].ToString().Trim())
+ {
+ case "涓绘枡":
+ Type = "Z";
+ break;
+ case "杈呮枡":
+ Type = "F";
+ break;
+ default:
+ break;
+ }
+ sql = @"insert into TBom_Deta(m_id,seq,smateriel_code,base_quantity,loss_quantity,total_quantity,pn_type)
+ values(@m_id,@seq,@smateriel_code,@base_quantity,@loss_quantity,@total_quantity,@pn_type)";
+ list.Add(new
+ {
+ str = sql,
+ parm = new
+ {
+ m_id = BomID,
+ seq = ds.Rows[i][2].ToString().Trim(),
+ smateriel_code = ds.Rows[i][3].ToString().Trim(),
+ base_quantity = ds.Rows[i][6].ToString().Trim(),
+ loss_quantity = ds.Rows[i][7].ToString().Trim(),
+ total_quantity = ds.Rows[i][8].ToString().Trim(),
+ pn_type = Type
+ }
+ });
+ }
+ }
+
+ bool aa = DapperHelper.DoTransaction(list);
+ if (aa)
+ {
+ StuCode = "200";
+ message = "瀵煎叆鎴愬姛锛�";
+ }
+ else
+ {
+ StuCode = "300";
+ message = "瀵煎叆澶辫触锛�";
+ }
+ }
+ catch (Exception e)
+ {
+ StuCode = "300";
+ message = e.Message;
+ }
+ return message;
+ }
+ #endregion
+
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/Tools/JwtTools.cs b/VueWebCoreApi/Tools/JwtTools.cs
new file mode 100644
index 0000000..37950a4
--- /dev/null
+++ b/VueWebCoreApi/Tools/JwtTools.cs
@@ -0,0 +1,133 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using JWT;
+using JWT.Algorithms;
+using JWT.Exceptions;
+using JWT.Serializers;
+using Newtonsoft.Json;
+using VueWebCoreApi.Models;
+
+namespace VueWebCoreApi.Tools
+{
+ public static class JwtTools
+ {
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+ public static string Key = AppSetting.GetAppSetting("SigningKey");
+ public static double time =double.Parse(AppSetting.GetAppSetting("RedisKeyTimeCont"));
+ //public static string Key { get; set; } = "Hello World"; //涓嶈娉勫瘑
+ //鍔犲瘑
+ public static ToMessage Encode(Dictionary<string, object> payLoad, string key = null)
+ {
+ if (string.IsNullOrEmpty(key))
+ {
+ key = Key;
+ }
+
+ IJwtAlgorithm algorithm = new HMACSHA256Algorithm();
+ IJsonSerializer serializer = new JsonNetSerializer();
+ IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
+ IJwtEncoder encoder = new JwtEncoder(algorithm, serializer, urlEncoder);
+ //娣诲姞涓�涓狫wt鏃舵晥涓�
+ payLoad.Add("timeout", DateTime.Now.AddSeconds(time));
+ mes.code = "200";
+ mes.Message = "鑾峰彇token鎴愬姛!";
+ mes.data= encoder.Encode(payLoad, key);
+ return mes;
+ }
+
+ //瑙e瘑(鏁版嵁绫诲瀷1)
+ public static Dictionary<string, object> Decode(string jwtstr, string key = null)
+ {
+ if (string.IsNullOrEmpty(key))
+ {
+ key = Key;
+ }
+ try
+ {
+ IJsonSerializer serializer = new JsonNetSerializer();
+ IDateTimeProvider provider = new UtcDateTimeProvider();
+ IJwtValidator validator = new JwtValidator(serializer, provider);
+ IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
+ IJwtAlgorithm algorithm = new HMACSHA256Algorithm();
+ IJwtDecoder decoder = new JwtDecoder(serializer, validator, urlEncoder, algorithm);
+
+ var json = decoder.Decode(jwtstr, key, verify: true);//token涓轰箣鍓嶇敓鎴愮殑瀛楃涓�
+
+ //string---->Dictionary
+ //鎶婁竴涓瓧绗︿覆鍙嶅悜鐢熸垚瀵瑰簲鐨勫璞″唴瀹�
+ var result = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
+ if ((DateTime)result["timeout"] < DateTime.Now)
+ {
+ throw new Exception(message: "token宸茶繃鏈�,璇烽噸鏂扮櫥褰�");
+ }
+ result.Remove(key: "timeout");
+ return result;
+ }
+ catch (TokenExpiredException)
+ {
+
+ throw; //璇锋眰瓒呮椂
+ }
+ catch (SignatureVerificationException)
+ {
+ throw; //绛惧悕楠岃瘉澶辫触锛屾暟鎹彲鑳借绡℃敼
+ }
+ }
+ //瑙e瘑(鏁版嵁绫诲瀷2)
+ public static User Denocode(string jwtstr, string key = null)
+ {
+ if (string.IsNullOrEmpty(key))
+ {
+ key = Key;
+ }
+ try
+ {
+ IJsonSerializer serializer = new JsonNetSerializer();
+ IDateTimeProvider provider = new UtcDateTimeProvider();
+ IJwtValidator validator = new JwtValidator(serializer, provider);
+ IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
+ IJwtAlgorithm algorithm = new HMACSHA256Algorithm();
+ IJwtDecoder decoder = new JwtDecoder(serializer, validator, urlEncoder, algorithm);
+
+ var json = decoder.Decode(jwtstr, key, verify: true);//token涓轰箣鍓嶇敓鎴愮殑瀛楃涓�
+
+ //string---->Dictionary
+ //鎶婁竴涓瓧绗︿覆鍙嶅悜鐢熸垚瀵瑰簲鐨勫璞″唴瀹�
+ User loginUser = JsonConvert.DeserializeObject<User>(json);
+ return loginUser;
+ }
+ catch (TokenExpiredException)
+ {
+
+ throw; //璇锋眰瓒呮椂
+ }
+ catch (SignatureVerificationException)
+ {
+ throw; //绛惧悕楠岃瘉澶辫触锛屾暟鎹彲鑳借绡℃敼
+ }
+ }
+
+ //鏍规嵁缁欏畾鍊艰幏鍙栭敭鍚�
+ public static K FindFirstValueByKey<K, V>(this Dictionary<K, V> dict, V val)
+ {
+ return dict.FirstOrDefault(entry =>
+ EqualityComparer<V>.Default.Equals(entry.Value, val)).Key;
+ }
+
+ //鏍规嵁缁欏畾閿悕鑾峰彇鍊�
+ public static V FindFirstKeyByValue<K,V>(this Dictionary<K, V> dict, K val)
+ {
+ return dict.FirstOrDefault(entry =>EqualityComparer<K>.Default.Equals(entry.Key, val)).Value;
+ }
+ //鏍¢獙鐧诲綍
+ //public static string key = "123456";
+ //public static string ValideLogined(HttpRequest req)
+ //{
+ // if (req.Headers["token"] == null)
+ // throw new Exception(message: "璇风櫥褰�!");
+ // return Decode(token: req.Headers["token"], key);
+ //}
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Tools/LogHelper.cs b/VueWebCoreApi/Tools/LogHelper.cs
new file mode 100644
index 0000000..16fffbe
--- /dev/null
+++ b/VueWebCoreApi/Tools/LogHelper.cs
@@ -0,0 +1,86 @@
+锘縰sing Dapper;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class LogHelper
+ {
+ /// <summary>
+ /// 杈撳嚭鏃ュ織鍒癓og4Net
+ /// </summary>
+ /// <param name="ex"></param>
+ #region
+ public static void WriteLog(Exception ex)
+ {
+ string message = string.Format("\r\n娑堟伅绫诲瀷锛歿0}\r\n娑堟伅鍐呭锛歿1}\r\n寮曞彂寮傚父璺緞锛歿2}\r\n寮曞彂寮傚父鐨勬柟娉曪細{3}\r\n寮曞彂寮傚父婧愶細{4}"
+ , ex.GetType().Name
+ , ex.Message
+ , ex.TargetSite.Name
+ , ex.Source + ex.StackTrace
+ );
+ log4net.ILog log = log4net.LogManager.GetLogger("鏃ュ織璁板綍");
+ log.Error(message);
+ }
+ #endregion
+
+ #region
+ public static void WriteLogData(string aa)
+ {
+ string message = string.Format("" + aa + "\r\n鏃堕棿锛歿0}"
+ , DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
+ log4net.ILog log = log4net.LogManager.GetLogger("鏃ュ織璁板綍");
+ log.Error(message);
+ }
+ #endregion
+
+ #region
+ public static void WriteLogData1(string aa)
+ {
+ string message = aa;
+ log4net.ILog log = log4net.LogManager.GetLogger("鏃ュ織璁板綍");
+ log.Error(message);
+ }
+ #endregion
+
+ #region
+ public static void WriteLogData2(string aa)
+ {
+ log4net.ILog log = log4net.LogManager.GetLogger("鏃ュ織璁板綍");
+ log.Error(JsonConvert.SerializeObject(aa));
+ }
+ #endregion
+
+ #region[灏嗘搷浣滃啓鍏ユ暟鎹〃璁板綍]
+ public static void DbOperateLog(string usercode, string oper_type, string description, string type)
+ {
+ var sql = "";
+ var cont = 0;
+ var dynamicParams = new DynamicParameters();
+ string message = string.Format("\r\n鐢ㄦ埛璐﹀彿锛歿0}\r\n鎿嶄綔鏃堕棿锛歿1}\r\n鎿嶄綔绫诲瀷锛歿2}\r\n鎿嶄綔鎻忚堪锛歿3}\r\n鎿嶄綔绔細{4}"
+ , usercode
+ , DateTime.Now.ToString()
+ , oper_type
+ , description
+ , type
+ );
+ log4net.ILog log = log4net.LogManager.GetLogger("鏃ュ織璁板綍");
+ log.Error(message);
+
+ sql = @"insert into TOperlog(usercode,oper_date,oper_type,description,operator_type)
+ values(@usercode,@oper_date,@oper_type,@description,@operator_type)";
+ dynamicParams.Add("@usercode", usercode);
+ dynamicParams.Add("@oper_date", DateTime.Now.ToString());
+ dynamicParams.Add("@oper_type", oper_type);
+ dynamicParams.Add("@description", description);
+ dynamicParams.Add("@operator_type", type);
+ cont = DapperHelper.SQL(sql, dynamicParams);
+
+
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/Tools/NPOIHelper.cs b/VueWebCoreApi/Tools/NPOIHelper.cs
new file mode 100644
index 0000000..1ae2e24
--- /dev/null
+++ b/VueWebCoreApi/Tools/NPOIHelper.cs
@@ -0,0 +1,190 @@
+锘縰sing NPOI.HSSF.UserModel;
+using NPOI.SS.UserModel;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.OleDb;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class NPOIHelper
+ {
+ /// <summary>
+ /// NPOI绠�鍗旸emo锛屽揩閫熷叆闂ㄤ唬鐮�
+ /// </summary>
+ /// <param name="dtSource"></param>
+ /// <param name="strFileName"></param>
+ /// <remarks>NPOI璁や负Excel鐨勭涓�涓崟鍏冩牸鏄細(0锛�0)</remarks>
+ /// <Author>鏌虫案娉� http://www.yongfa365.com/ 2010-5-8 22:21:41</Author>
+ public static void ExportEasy(DataTable dtSource, string strFileName)
+ {
+ HSSFWorkbook workbook = new HSSFWorkbook();
+ ISheet sheet = workbook.CreateSheet();
+ //濉厖琛ㄥご
+ IRow dataRow = sheet.CreateRow(0);
+ foreach (DataColumn column in dtSource.Columns)
+ {
+ dataRow.CreateCell(column.Ordinal).SetCellValue(column.ColumnName);
+ }
+
+
+ //濉厖鍐呭
+ for (int i = 0; i < dtSource.Rows.Count; i++)
+ {
+ dataRow = sheet.CreateRow(i + 1);
+ for (int j = 0; j < dtSource.Columns.Count; j++)
+ {
+ dataRow.CreateCell(j).SetCellValue(dtSource.Rows[i][j].ToString());
+ }
+ }
+
+
+ //淇濆瓨
+ using (MemoryStream ms = new MemoryStream())
+ {
+ using (FileStream fs = new FileStream(strFileName, FileMode.Create, FileAccess.Write))
+ {
+ workbook.Write(ms);
+ ms.Flush();
+ ms.Position = 0;
+ byte[] data = ms.ToArray();
+ fs.Write(data, 0, data.Length);
+ fs.Flush();
+ }
+ }
+ //workbook.Dispose();
+ }
+
+
+
+
+ public static System.Data.DataTable GetExcelDatatable(string fileUrl)
+ {
+
+ string strConn = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + fileUrl + ";Extended Properties='Excel 12.0; HDR=Yes; IMEX=1'";
+
+
+ DataSet myDataSet = new DataSet();
+
+ //杩炴帴涓�
+ OleDbConnection conn = new OleDbConnection(strConn);
+ conn.Open();
+ //杩斿洖Excel鐨勬灦鏋勶紝鍖呮嫭鍚勪釜sheet琛ㄧ殑鍚嶇О,绫诲瀷锛屽垱寤烘椂闂村拰淇敼鏃堕棿绛夈��
+ DataTable dtSheetName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" });
+ //鍖呭惈excel涓〃鍚嶇殑瀛楃涓叉暟缁�
+ string[] strTableNames = new string[dtSheetName.Rows.Count];
+ for (int k = 0; k < dtSheetName.Rows.Count; k++)
+ {
+ strTableNames[k] = dtSheetName.Rows[k]["TABLE_NAME"].ToString();
+ }
+ OleDbDataAdapter myCommand = null;
+ DataTable dt = new DataTable();
+ //浠庢寚瀹氱殑琛ㄦ槑鏌ヨ鏁版嵁,鍙厛鎶婃墍鏈夎〃鏄庡垪鍑烘潵渚涚敤鎴烽�夋嫨
+ string strExcel = "select*from[" + strTableNames[0] + "]";
+ myCommand = new OleDbDataAdapter(strExcel, strConn);
+ //myCommand.Fill(dt);
+ myCommand.Fill(myDataSet, "ExcelInfo");
+ conn.Close();
+ DataTable ExcelTable = myDataSet.Tables["ExcelInfo"].DefaultView.ToTable();
+ return ExcelTable;
+ }
+
+
+ /// <summary>
+ /// 澶氫釜sheet瀵煎叆
+ /// </summary>
+ /// <param name="fileUrl"></param>
+ /// <returns></returns>
+ public static List<DataTable> GetExcelDatatableList(string fileUrl)
+ {
+ List<DataTable> list = new List<DataTable>();
+ string strConn = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + fileUrl + ";Extended Properties='Excel 12.0; HDR=Yes; IMEX=1'";
+
+
+ DataSet myDataSet = new DataSet();
+
+ //杩炴帴涓�
+ OleDbConnection conn = new OleDbConnection(strConn);
+ conn.Open();
+ //杩斿洖Excel鐨勬灦鏋勶紝鍖呮嫭鍚勪釜sheet琛ㄧ殑鍚嶇О,绫诲瀷锛屽垱寤烘椂闂村拰淇敼鏃堕棿绛夈��
+ DataTable dtSheetName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" });
+ //鍖呭惈excel涓〃鍚嶇殑瀛楃涓叉暟缁�
+ string[] strTableNames = new string[dtSheetName.Rows.Count];
+ for (int k = 0; k < dtSheetName.Rows.Count; k++)
+ {
+ strTableNames[k] = dtSheetName.Rows[k]["TABLE_NAME"].ToString();
+ }
+ for (int i = 0; i < strTableNames.Length; i++)
+ {
+ OleDbDataAdapter myCommand = null;
+ DataTable dt = new DataTable();
+ //浠庢寚瀹氱殑琛ㄦ槑鏌ヨ鏁版嵁,鍙厛鎶婃墍鏈夎〃鏄庡垪鍑烘潵渚涚敤鎴烽�夋嫨
+ string strExcel = "select*from[" + strTableNames[i].Trim() + "]";
+ myCommand = new OleDbDataAdapter(strExcel, strConn);
+ //myCommand.Fill(dt);
+ myCommand.Fill(myDataSet, "" + i + "");
+ conn.Close();
+ DataTable ExcelTable = myDataSet.Tables[i].DefaultView.ToTable();
+ list.Add(ExcelTable);
+ }
+
+ return list;
+ }
+
+ /// <summary>
+ /// 澶氫釜sheet瀵煎叆
+ /// </summary>
+ /// <param name="fileUrl"></param>
+ /// <returns></returns>
+ public static List<DataTable> GetExcelDatatableListName(string fileUrl)
+ {
+ List<DataTable> list = new List<DataTable>();
+ string strConn = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + fileUrl + ";Extended Properties='Excel 12.0; HDR=Yes; IMEX=1'";
+
+
+ DataSet myDataSet = new DataSet();
+
+ //杩炴帴涓�
+ OleDbConnection conn = new OleDbConnection(strConn);
+ conn.Open();
+ //杩斿洖Excel鐨勬灦鏋勶紝鍖呮嫭鍚勪釜sheet琛ㄧ殑鍚嶇О,绫诲瀷锛屽垱寤烘椂闂村拰淇敼鏃堕棿绛夈��
+ DataTable dtSheetName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" });
+ for (int m = 0; m < dtSheetName.Rows.Count; m++)
+ {
+ string TABLE_NAME = dtSheetName.Rows[m]["TABLE_NAME"].ToString();
+ string FilterDatabase = "$FilterDatabase";
+ if (TABLE_NAME.Contains(FilterDatabase))
+ {
+ dtSheetName.Rows.Remove(dtSheetName.Rows[m]);
+ }
+ }
+
+ //鍖呭惈excel涓〃鍚嶇殑瀛楃涓叉暟缁�
+ string[] strTableNames = new string[dtSheetName.Rows.Count];
+ for (int k = 0; k < dtSheetName.Rows.Count; k++)
+ {
+ strTableNames[k] = dtSheetName.Rows[k]["TABLE_NAME"].ToString();
+ }
+ for (int i = 0; i < strTableNames.Length; i++)
+ {
+ OleDbDataAdapter myCommand = null;
+ DataTable dt = new DataTable();
+
+ //浠庢寚瀹氱殑琛ㄦ槑鏌ヨ鏁版嵁,鍙厛鎶婃墍鏈夎〃鏄庡垪鍑烘潵渚涚敤鎴烽�夋嫨
+ string strExcel = "select*from[" + strTableNames[i].Trim() + "]";
+ myCommand = new OleDbDataAdapter(strExcel, strConn);
+ //myCommand.Fill(dt);
+ myCommand.Fill(myDataSet, "" + i + "");
+ conn.Close();
+ DataTable ExcelTable = myDataSet.Tables[i].DefaultView.ToTable();
+ ExcelTable.TableName = strTableNames[i].Trim();
+ list.Add(ExcelTable);
+ }
+
+ return list;
+ }
+ }
+}
diff --git a/VueWebCoreApi/Tools/RedisHelper.cs b/VueWebCoreApi/Tools/RedisHelper.cs
new file mode 100644
index 0000000..c5c1368
--- /dev/null
+++ b/VueWebCoreApi/Tools/RedisHelper.cs
@@ -0,0 +1,267 @@
+锘縰sing ServiceStack.Redis;
+using ServiceStack.Redis.Generic;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class RedisHelper
+ {
+ /// <summary>
+ /// redis鑾峰彇杩炴帴閰嶇疆瀛楃涓�
+ /// </summary>
+ private static readonly string RedisIpConnString = AppSetting.GetAppSetting("RedisConnIp");
+ private static readonly string RedisPortConnString = AppSetting.GetAppSetting("RedisConnPort");
+ private static readonly string RedisKeyTimeCont = AppSetting.GetAppSetting("RedisKeyTimeCont");
+
+
+ private static RedisClient Redis = new RedisClient(RedisIpConnString, Convert.ToInt32(RedisPortConnString));
+ //缂撳瓨姹�
+ static PooledRedisClientManager prcm = new PooledRedisClientManager();
+
+
+ //榛樿缂撳瓨杩囨湡鏃堕棿鍗曚綅绉�
+ public int secondsTimeOut = Convert.ToInt32(RedisKeyTimeCont);
+ private static readonly Dictionary<int, PooledRedisClientManager> pools = new Dictionary<int, PooledRedisClientManager>();
+ /// <summary>
+ /// 缂撳啿姹�
+ /// </summary>
+ /// <param name="readWriteHosts"></param>
+ /// <param name="readOnlyHosts"></param>
+ /// <returns></returns>
+ private static void CreateManager(string[] readWriteHosts, string[] readOnlyHosts)
+ {
+ for (int i = 0; i <= 15; i++)
+ {
+ PooledRedisClientManager prc = new PooledRedisClientManager(readWriteHosts, readOnlyHosts,
+ new RedisClientManagerConfig
+ {
+ MaxWritePoolSize = readWriteHosts.Length * 512, //鏈�澶у啓閾炬帴鏁�
+ MaxReadPoolSize = readOnlyHosts.Length * 512, //鏈�澶ц閾炬帴鏁�
+ AutoStart = true, //鑷姩閲嶅惎
+ }, i, 200, 10);// { RedisClientFactory = (IRedisClientFactory)RedisCacheClientFactory.Instance.CreateRedisClient("127.0.0.1", 6379) };
+ pools.Add(i, prc);
+ }
+ }
+ public static PooledRedisClientManager ChooseRedisInstance(int database)
+ {
+ if (database > 16) return pools[0];
+ return pools[database];
+ }
+ /// <summary>
+ /// 鏋勯�犲嚱鏁�
+ /// </summary>
+ /// <param name="openPooledRedis">鏄惁寮�鍚紦鍐叉睜</param>
+ static RedisHelper()
+ {
+ //CreateManager(new string[] { "127.0.0.1:6379" }, new string[] { "127.0.0.1:6379" });
+ CreateManager(new string[] { RedisIpConnString + ":" + RedisPortConnString }, new string[] { RedisIpConnString + ":" + RedisPortConnString });
+ //Redis = prcm.GetClient() as RedisClient;
+ }
+
+ #region Key/Value瀛樺偍
+ /// <summary>
+ /// 璁剧疆缂撳瓨
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="key">缂撳瓨寤�</param>
+ /// <param name="t">缂撳瓨鍊�</param>
+ /// <param name="timeout">杩囨湡鏃堕棿锛屽崟浣嶇,-1锛氫笉杩囨湡锛�0锛氶粯璁よ繃鏈熸椂闂�</param>
+ /// <returns></returns>
+ public bool Set<T>(string key, T t, int timeout = 0, int db = 0)
+ {
+ Redis = (RedisClient)ChooseRedisInstance(db).GetClient();
+ var values = Redis.Add<T>(key, t);
+ if (timeout >= 0)
+ {
+ if (timeout > 0)
+ {
+ secondsTimeOut = timeout;
+ }
+ Redis.Expire(key, secondsTimeOut);
+ }
+ Redis.Dispose();
+ return values;
+ }
+
+ /// <summary>
+ /// 璁剧疆澶辨晥鏃堕棿
+ /// </summary>
+ /// <param name="key"></param>
+ /// <param name="expiry"></param>
+ /// <returns></returns>
+ public bool KeyExpire(string key, int expiry)
+ {
+ return Redis.Expire(key, expiry);
+ }
+ /// <summary>
+ /// 鑾峰彇
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="key"></param>
+ /// <returns></returns>
+ public T Get<T>(string key, int db = 0)
+ {
+ Redis = (RedisClient)ChooseRedisInstance(db).GetClient();
+ var values = Redis.Get<T>(key);
+ Redis.Dispose();
+ return values;
+ }
+ /// <summary>
+ /// 鍒犻櫎
+ /// </summary>
+ /// <param name="key"></param>
+ /// <returns></returns>
+ public bool Remove(string key, int db = 0)
+ {
+ Redis = (RedisClient)ChooseRedisInstance(db).GetClient();
+ Redis.Dispose();
+ return Redis.Remove(key);
+ }
+
+
+ //public static bool Add<T>(string key, T t, int timeout)
+ //{
+ // var values = Redis.Add<T>(key, t);
+ // if (timeout >= 0)
+ // {
+ // if (timeout > 0)
+ // {
+ // secondsTimeOut = timeout;
+ // }
+ // Redis.Expire(key, secondsTimeOut);
+ // }
+ // return values;
+ //}
+ #endregion
+
+
+ #region 閾捐〃鎿嶄綔
+ /// <summary>
+ /// 鏍规嵁IEnumerable鏁版嵁娣诲姞閾捐〃
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="listId"></param>
+ /// <param name="values"></param>
+ /// <param name="timeout"></param>
+ public void AddList<T>(string listId, IEnumerable<T> values, int timeout = 0)
+ {
+ Redis.Expire(listId, 60);
+ IRedisTypedClient<T> iredisClient = Redis.As<T>();
+ if (timeout >= 0)
+ {
+ if (timeout > 0)
+ {
+ secondsTimeOut = timeout;
+ }
+ Redis.Expire(listId, secondsTimeOut);
+ }
+ var redisList = iredisClient.Lists[listId];
+ redisList.AddRange(values);
+ iredisClient.Save();
+ Redis.Dispose();
+ }
+ /// <summary>
+ /// 娣诲姞鍗曚釜瀹炰綋鍒伴摼琛ㄤ腑
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="listId"></param>
+ /// <param name="Item"></param>
+ /// <param name="timeout"></param>
+ public void AddEntityToList<T>(string listId, T Item, int timeout = 0, int db = 0)
+ {
+ Redis = (RedisClient)ChooseRedisInstance(db).GetClient();
+ IRedisTypedClient<T> iredisClient = Redis.As<T>();
+ if (timeout >= 0)
+ {
+ if (timeout > 0)
+ {
+ secondsTimeOut = timeout;
+ }
+ Redis.Expire(listId, secondsTimeOut);
+ }
+ var redisList = iredisClient.Lists[listId];
+ redisList.Add(Item);
+ iredisClient.Save();
+ Redis.Dispose();
+ }
+ /// <summary>
+ /// 鑾峰彇閾捐〃
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="listId"></param>
+ /// <returns></returns>
+ public IEnumerable<T> GetList<T>(string listId, int db = 0)
+ {
+ Redis = (RedisClient)ChooseRedisInstance(db).GetClient();
+ IRedisTypedClient<T> iredisClient = Redis.As<T>();
+ Redis.Dispose();
+ return iredisClient.Lists[listId];
+ }
+ /// <summary>
+ /// 鍦ㄩ摼琛ㄤ腑鍒犻櫎鍗曚釜瀹炰綋
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="listId"></param>
+ /// <param name="t"></param>
+ public void RemoveEntityFromList<T>(string listId, T t, int db = 0)
+ {
+ Redis = (RedisClient)ChooseRedisInstance(db).GetClient();
+ IRedisTypedClient<T> iredisClient = Redis.As<T>();
+ var redisList = iredisClient.Lists[listId];
+ redisList.RemoveValue(t);
+ iredisClient.Save();
+ Redis.Dispose();
+ }
+ /// <summary>
+ /// 鏍规嵁lambada琛ㄨ揪寮忓垹闄ょ鍚堟潯浠剁殑瀹炰綋
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="listId"></param>
+ /// <param name="func"></param>
+ public void RemoveEntityFromList<T>(string listId, Func<T, bool> func)
+ {
+ //using (IRedisTypedClient<T> iredisClient = Redis.As<T>())
+ //{
+ // var redisList = iredisClient.Lists[listId];
+ // T value = redisList.Where(func).FirstOrDefault();
+ // redisList.RemoveValue(value);
+ // iredisClient.Save();
+ //}
+
+
+ // 浣跨敤using 鎶ラ敊锛�
+ // using 璇彞涓娇鐢ㄧ殑绫诲瀷蹇呴』鍙殣寮忚浆鎹负鈥淪ystem.IDisposable鈥�
+ // using浼氳嚜鍔ㄨ皟鐢⊿ystem.IDisposable涓嬬殑Dispose鏂规硶鏉ラ噴鏀鹃潪鎵樼璧勬簮锛�
+ // IRedisTypedClient娌℃湁缁ф壙System.IDisposable鐨勬帴鍙o紝鎵�浠ヤ笉鑳界敤
+ IRedisTypedClient<T> iredisClient = Redis.As<T>();
+ var redisList = iredisClient.Lists[listId];
+ T value = redisList.Where(func).FirstOrDefault();
+ redisList.RemoveValue(value);
+ iredisClient.Save();
+ Redis.Dispose();
+
+ }
+ public void test()
+ {
+ string s1 = Redis.GetClient();
+ List<Dictionary<string, string>> s2 = Redis.GetClientsInfo();
+ List<string> s3 = Redis.GetAllKeys();
+ string s4 = Redis.GetHostString();
+ long s5 = Redis.Db;
+ }
+ #endregion
+ //閲婃斁璧勬簮
+ public void Dispose()
+ {
+ if (Redis != null)
+ {
+ Redis.Dispose();
+ Redis = null;
+ }
+ GC.Collect();
+ }
+ }
+}
diff --git a/VueWebCoreApi/Tools/Regedit.cs b/VueWebCoreApi/Tools/Regedit.cs
new file mode 100644
index 0000000..721f371
--- /dev/null
+++ b/VueWebCoreApi/Tools/Regedit.cs
@@ -0,0 +1,573 @@
+锘縰sing Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class Regedit
+ {
+ private static RegistryKey LoadRoot(string path, bool writable)
+ {
+ RegistryKey result;
+ try
+ {
+ RegistryKey registryKey = Regedit.LoadRoot(writable);
+ registryKey = registryKey.OpenSubKey(path, writable);
+ if (null == registryKey)
+ {
+ registryKey = Registry.LocalMachine.CreateSubKey(path);
+ }
+ result = registryKey;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ return result;
+ }
+
+ private static RegistryKey LoadRoot(bool writable)
+ {
+ RegistryKey registryKey = null;
+ RegistryKey result;
+ try
+ {
+ registryKey = Registry.LocalMachine.OpenSubKey("Software", writable);
+ RegistryKey registryKey2 = registryKey.OpenSubKey("YYBB", writable);
+ if (null == registryKey2)
+ {
+ registryKey2 = registryKey.CreateSubKey("YYBB");
+ }
+ result = registryKey2;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ private static RegistryKey LoadRegistryKey(bool writable)
+ {
+ RegistryKey registryKey = null;
+ RegistryKey result;
+ try
+ {
+ registryKey = Registry.LocalMachine.OpenSubKey("Software", writable);
+ RegistryKey registryKey2 = registryKey.OpenSubKey("YYBB", writable);
+ if (null == registryKey2)
+ {
+ registryKey2 = registryKey.CreateSubKey("YYBB");
+ }
+ RegistryKey registryKey3 = registryKey2.OpenSubKey("connectionString", writable);
+ if (null == registryKey3)
+ {
+ registryKey3 = registryKey2.CreateSubKey("connectionString");
+ }
+ result = registryKey3;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static RegistryKey AddFolder(string itemName)
+ {
+ RegistryKey registryKey = null;
+ RegistryKey result;
+ try
+ {
+ registryKey = Regedit.LoadRoot(true);
+ result = registryKey.CreateSubKey(itemName);
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static bool SetFolderValueX(string path, string name, string val)
+ {
+ RegistryKey registryKey = null;
+ bool result;
+ try
+ {
+ registryKey = Regedit.LoadRoot(path, true);
+ registryKey.SetValue(name, val);
+ registryKey.Flush();
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static bool SetFolderValue(string itemName, string name, string itemValue)
+ {
+ RegistryKey registryKey = null;
+ bool result;
+ try
+ {
+ registryKey = Regedit.AddFolder(itemName);
+ registryKey.SetValue(name, itemValue);
+ registryKey.Flush();
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static bool DeleteFolder(string itemName)
+ {
+ RegistryKey registryKey = null;
+ bool result;
+ try
+ {
+ registryKey = Regedit.LoadRoot(true);
+ registryKey.DeleteSubKey(itemName);
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static bool DeleteFolder(string path, string itemName)
+ {
+ RegistryKey registryKey = null;
+ bool result;
+ try
+ {
+ registryKey = Regedit.LoadRoot(path, true);
+ registryKey.DeleteSubKey(itemName);
+ registryKey.Flush();
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static bool DeleteFolderValue(string itemName, string name)
+ {
+ RegistryKey registryKey = null;
+ bool result;
+ try
+ {
+ registryKey = Regedit.LoadRoot(true);
+ registryKey = Regedit.LoadRoot(true);
+ RegistryKey registryKey2 = registryKey.OpenSubKey(itemName, true);
+ registryKey2.DeleteValue(name);
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static RegistryKey GetFolder(string itemName)
+ {
+ RegistryKey registryKey = null;
+ RegistryKey result;
+ try
+ {
+ registryKey = Regedit.LoadRoot(false);
+ RegistryKey registryKey2 = registryKey.OpenSubKey(itemName, false);
+ if (null == registryKey2)
+ {
+ throw new Exception("涓嶅瓨鍦╗" + itemName + "]鐨勯」...");
+ }
+ result = registryKey2;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static string[] GetFolderNames(string itemName)
+ {
+ RegistryKey registryKey = null;
+ string[] result;
+ try
+ {
+ registryKey = Regedit.LoadRoot(false);
+ RegistryKey registryKey2 = registryKey.OpenSubKey(itemName, false);
+ if (null == registryKey2)
+ {
+ result = null;
+ }
+ else
+ {
+ result = registryKey2.GetValueNames();
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static string GetFolderValueX(string path, string name)
+ {
+ RegistryKey registryKey = null;
+ string result;
+ try
+ {
+ registryKey = Regedit.LoadRoot(path, false);
+ string text = string.Empty;
+ object value = registryKey.GetValue(name);
+ if (null != value)
+ {
+ text = value.ToString();
+ result = text;
+ }
+ else
+ {
+ result = null;
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static string GetFolderValue(string itemName, string name)
+ {
+ RegistryKey registryKey = null;
+ string result;
+ try
+ {
+ registryKey = Regedit.GetFolder(itemName);
+ string text = string.Empty;
+ object value = registryKey.GetValue(name);
+ if (null != value)
+ {
+ text = value.ToString();
+ result = text;
+ }
+ else
+ {
+ result = null;
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static RegistryKey CreateItem(string itemName)
+ {
+ RegistryKey registryKey = null;
+ RegistryKey result;
+ try
+ {
+ registryKey = Regedit.LoadRegistryKey(true);
+ result = registryKey.CreateSubKey(itemName);
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static RegistryKey CreateItem(string path, string itemName)
+ {
+ RegistryKey registryKey = null;
+ RegistryKey result;
+ try
+ {
+ registryKey = Regedit.AddFolder(path);
+ result = registryKey.CreateSubKey(itemName);
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static bool DeleteItem(string itemName)
+ {
+ RegistryKey registryKey = null;
+ bool result;
+ try
+ {
+ registryKey = Regedit.LoadRegistryKey(true);
+ registryKey.DeleteSubKey(itemName);
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static RegistryKey GetItem(string itemName)
+ {
+ RegistryKey registryKey = null;
+ RegistryKey result;
+ try
+ {
+ registryKey = Regedit.LoadRegistryKey(false);
+ RegistryKey registryKey2 = registryKey.OpenSubKey(itemName, false);
+ if (null == registryKey2)
+ {
+ throw new Exception("涓嶅瓨鍦╗" + itemName + "]鐨勯」...");
+ }
+ result = registryKey2;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static bool SetConnectionString(string name, string connectionString)
+ {
+ return Regedit.SetValue(name, "connectionString", connectionString);
+ }
+
+ public static bool SetValue(string itemName, string name, string itemValue)
+ {
+ RegistryKey registryKey = null;
+ bool result;
+ try
+ {
+ registryKey = Regedit.CreateItem(itemName);
+ registryKey.SetValue(name, Encrypt.EncryptStr(itemValue, "fengyi", "fengyibi"));
+ registryKey.Flush();
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static string GetConnectionString(string serverName)
+ {
+ string[] connectionLists = Regedit.GetConnectionLists();
+ string[] array = connectionLists;
+ for (int i = 0; i < array.Length; i++)
+ {
+ string a = array[i];
+ if (a == serverName)
+ {
+ return Regedit.GetValue(serverName, "connectionString", false);
+ }
+ }
+ throw new Exception("涓嶅瓨鍦ㄩ厤缃悕涓篬" + serverName + "]鐨勮缃�,璇锋鏌�!");
+ }
+
+ public static string GetValue(string itemName, string name)
+ {
+ return Regedit.GetValue(itemName, name, true);
+ }
+
+ public static string GetValue(string itemName, string name, bool isDecrpt)
+ {
+ RegistryKey registryKey = null;
+ string result;
+ try
+ {
+ registryKey = Regedit.GetItem(itemName);
+ string text = string.Empty;
+ object value = registryKey.GetValue(name);
+ if (null == value)
+ {
+ throw new Exception(itemName + "涓笉瀛樺湪[" + name + "]椤癸紒");
+ }
+ text = value.ToString();
+ if (isDecrpt)
+ {
+ result = Encrypt.DecryptStr(text, "fengyi", "fengyibi");
+ }
+ else
+ {
+ result = text;
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return result;
+ }
+
+ public static string[] GetConnectionLists()
+ {
+ RegistryKey registryKey = null;
+ string[] subKeyNames;
+ try
+ {
+ registryKey = Regedit.LoadRegistryKey(false);
+ subKeyNames = registryKey.GetSubKeyNames();
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (null != registryKey)
+ {
+ registryKey.Close();
+ }
+ }
+ return subKeyNames;
+ }
+ }
+}
diff --git a/VueWebCoreApi/Tools/ScanStartReport.cs b/VueWebCoreApi/Tools/ScanStartReport.cs
new file mode 100644
index 0000000..79e42c5
--- /dev/null
+++ b/VueWebCoreApi/Tools/ScanStartReport.cs
@@ -0,0 +1,1185 @@
+锘縰sing Dapper;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Web;
+using VueWebCoreApi.Models;
+
+namespace VueWebCoreApi.Tools
+{
+ public class ScanStartReport
+ {
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+
+
+ #region[鐢熶骇寮�鎶ュ伐:鑷埗宸ュ簭浠诲姟寮�鎶ュ伐鍒ゆ柇锛氬伐鍗�+宸ュ簭鏉$爜]
+ /// <summary>
+ /// 鎵爜淇℃伅涓哄伐鍗�+宸ュ簭鏉$爜
+ /// </summary>
+ /// <param name="stu_torgcode">鎵�灞炵粍缁囩紪鐮�</param>
+ /// <param name="ordercode">宸ュ崟缂栧彿</param>
+ /// <param name="stepcode">宸ュ簭缂栫爜</param>
+ /// <returns></returns>
+ public static ToMessage ZZEncodingSeach(string stu_torgcode, string ordercode, string stepcode)
+ {
+ var sql = "";
+ string flwtype = ""; //宸ュ簭灞炴��
+ string isbott = ""; //棣栭亾宸ュ簭
+ string isend = ""; //鏈亾宸ュ簭
+ string seq = ""; //宸ュ簭搴忓彿
+ List<object> list = new List<object>();
+ ScanStartReportData rt = new ScanStartReportData();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鍒ゆ柇褰撳墠宸ュ崟鏄惁鍏抽棴
+ sql = @"select * from TK_Wrk_Man where wo_code=@ordercode and wkshp_code=@stu_torgcode and status='CLOSED'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ var da0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (da0.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ崟宸插叧闂�,涓嶅厑璁稿紑鎶ュ伐鎿嶄綔!";
+ mes.data = null;
+ return mes;
+ }
+
+ //0.鍒ゆ柇褰撳墠宸ュ崟鎵�灞炶溅闂存槸鍚︿负褰撳墠鐧诲綍浜哄憳杞﹂棿
+ sql = @"select * from TK_Wrk_Man where wo_code=@ordercode and wkshp_code=@stu_torgcode";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ var da1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (da1.Rows.Count<=0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "涓嶆槸鏈溅闂寸敓浜т换鍔�,涓嶅厑璁告搷浣�!";
+ mes.data = null;
+ return mes;
+ }
+
+ //1.鏍规嵁宸ュ崟+宸ュ簭鏌ユ壘褰撳墠宸ュ簭鏄惁棣栭亾宸ュ簭
+ sql = @"select A.wo_code,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.seq,T.flwtype,T.descr,A.status,A.plan_qty,A.isbott,A.isend,L.org_code,L.org_name
+ from TK_Wrk_Step A
+ left join TStep T on A.step_code=T.stepcode
+ left join TK_Wrk_Man M on A.wo_code=M.wo_code
+ left join TMateriel_Info P on M.materiel_code=P.partcode
+ left join TOrganization L on M.wkshp_code=L.org_code
+ where A.wo_code=@ordercode and A.step_code=@stepcode";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ rt.wkshopcode= data.Rows[0]["org_code"].ToString(); //杞﹂棿缂栫爜
+ rt.wkshopname = data.Rows[0]["org_name"].ToString(); //杞﹂棿鍚嶇О
+ rt.wo_code = data.Rows[0]["WO_CODE"].ToString(); //宸ュ崟鍙�
+ rt.partnumber = data.Rows[0]["PARTCODE"].ToString(); //浜у搧缂栫爜
+ rt.partname = data.Rows[0]["PARTNAME"].ToString(); //浜у搧鍚嶇О
+ rt.partspec = data.Rows[0]["PARTSPEC"].ToString(); //浜у搧瑙勬牸
+ rt.stepcode = data.Rows[0]["STEPCODE"].ToString(); //宸ュ簭缂栫爜
+ rt.stepname = data.Rows[0]["STEPNAME"].ToString(); //宸ュ簭鍚嶇О
+ rt.stepdesc = data.Rows[0]["DESCR"].ToString(); //宸ュ簭鎻忚堪
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+
+ flwtype = data.Rows[0]["FLWTYPE"].ToString();//鑾峰彇宸ュ簭灞炴��
+ isbott = data.Rows[0]["ISBOTT"].ToString();//棣栭亾宸ュ簭
+ isend = data.Rows[0]["ISEND"].ToString();//鏈亾宸ュ簭
+ rt.seq = data.Rows[0]["SEQ"].ToString();//宸ュ簭搴忓彿
+
+ //鑾峰彇褰撳墠宸ュ簭涓嬮亾宸ュ簭
+ sql = @"select A.isbott,A.isend,T.stepcode,T.stepname from TK_Wrk_Step A
+ left join TStep T on A.step_code=T.stepcode
+ where A.wo_code=@ordercode and A.seq=@seq+1 ";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@seq", decimal.Parse(data.Rows[0]["SEQ"].ToString()));
+ var dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0) //鏈変笅閬撳伐搴�
+ {
+ rt.nextstepcode = dt.Rows[0]["STEPCODE"].ToString();//涓嬮亾宸ュ簭缂栫爜
+ rt.nextstepname = dt.Rows[0]["STEPNAME"].ToString();//涓嬮亾宸ュ簭鍚嶇О
+ }
+ if (isend == "Y") //褰撳墠宸ュ簭鏄湯閬撳伐搴�
+ {
+ rt.nextstepcode = "";//data.Rows[0]["STEPCODE"].ToString();//褰撳墠宸ュ簭缂栫爜
+ rt.nextstepname = "";// data.Rows[0]["STEPNAME"].ToString();//褰撳墠宸ュ簭鍚嶇О
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鎵爜宸ュ簭浠诲姟涓嶅瓨鍦�!";
+ mes.data = null;
+ return mes;
+ }
+ switch (flwtype)
+ {
+ case "Z": //鑷埗宸ュ簭
+ if (isbott == "Y") //棣栭亾宸ュ簭
+ {
+ //1.棣栭亾宸ュ簭鏃讹紝鍒ゆ柇鏄惁鏈夊紑宸ヨ褰�
+ sql = @"select * from TK_Wrk_Record R
+ left join TEqpInfo E on R.eqp_code=E.code
+ where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='S'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0) //鏈夊紑宸ヨ褰�
+ {
+ //棣栭亾宸ュ簭鏃讹紝鍒ゆ柇鏄惁鏈夋姤宸ヨ褰�
+ sql = @"select * from TK_Wrk_Record where wo_code=@ordercode and step_code=@stepcode and style='B'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data1.Rows.Count > 0)
+ {
+ decimal good_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("GOOD_QTY")).Sum(); //鎶ュ伐鎬绘暟閲�
+ decimal ng_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("NG_QTY")).Sum(); //涓嶈壇鏁伴噺
+ decimal bad_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("BAD_QTY")).Sum(); //鎶ュ簾鏁伴噺
+
+ decimal kbqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()) - (good_qty + ng_qty+bad_qty); //鍓╀綑鍙姤宸ユ暟閲�=浠诲姟鏁伴噺-(鎶ュ伐鏁伴噺+涓嶈壇鏁伴噺+鎶ュ簾鏁伴噺)
+ if (kbqty <= 0)//鏃犲彲鎶ュ伐鏁伴噺
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭鏃犲彲鎶ュ伐鏁伴噺!";
+ mes.data = null;
+ return mes;
+ }
+ else
+ {
+ rt.eqpcode = data0.Rows[0]["code"].ToString(); //寮�宸ヨ澶囩紪鐮�
+ rt.eqpname = data0.Rows[0]["name"].ToString(); //寮�宸ヨ澶囧悕绉�
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.startqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //寮�宸ユ暟閲�=浠诲姟鏁伴噺
+ rt.noreportqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()) - good_qty- ng_qty-bad_qty; //鏈姤鏁伴噺=浠诲姟鏁伴噺-宸叉姤鏁伴噺-涓嶈壇鏁伴噺-鎶ュ簾鏁伴噺
+ rt.reportqty = good_qty + ng_qty+bad_qty; //宸叉姤鏁伴噺=鎶ュ伐鏁伴噺+涓嶈壇鏁伴噺+鎶ュ簾鏁伴噺
+ mes.code = "200";
+ mes.count = 1;
+ mes.Message = "寮圭獥鎶ュ伐鐣岄潰!";
+ mes.data = rt;
+ }
+ }
+ else
+ {
+ rt.eqpcode = data0.Rows[0]["code"].ToString(); //寮�宸ヨ澶囩紪鐮�
+ rt.eqpname = data0.Rows[0]["name"].ToString(); //寮�宸ヨ澶囧悕绉�
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.startqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //寮�宸ユ暟閲�
+ rt.noreportqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //鏈姤鏁伴噺
+ rt.reportqty = 0; //宸叉姤鏁伴噺
+ mes.code = "200";
+ mes.count = 1;
+ mes.Message = "寮圭獥鎶ュ伐鐣岄潰!";
+ mes.data = rt;
+ }
+ }
+ else
+ {
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.startqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //寮�宸ユ暟閲�
+ rt.noreportqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //鏈姤鏁伴噺
+ rt.reportqty = 0; //宸叉姤鏁伴噺
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "寮圭獥寮�宸ョ晫闈�!";
+ mes.data = rt;
+ }
+ }
+ else //闈為閬撳伐搴�
+ {
+ //鏌ユ壘褰撳墠宸ュ簭涓婂埌宸ュ簭(鑷埗鎴栬�呭鍗�)
+ sql = @"select A.step_code,S.stepname,S.flwtype from TFlw_Rtdt A
+ left join TK_Wrk_Man M on A.rout_code=M.route_code
+ left join TStep S on A.step_code=S.stepcode
+ where M.wo_code=@wocode and A.seq=@seq-1";
+ dynamicParams.Add("@wocode", data.Rows[0]["WO_CODE"].ToString());
+ dynamicParams.Add("@seq", decimal.Parse(data.Rows[0]["SEQ"].ToString()));
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ //1.闈為閬撳伐搴忔椂锛屽垽鏂湰閬撴槸鍚︽湁寮�宸ヨ褰�
+ sql = @"select * from TK_Wrk_Record R
+ left join TEqpInfo E on R.eqp_code=E.code
+ where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='S'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data1.Rows.Count > 0)//鏈亾鏈夊紑宸ヨ褰�
+ {
+ //闈為閬撳伐搴忔椂锛屽垽鏂湰閬撴槸鍚︽湁鎶ュ伐璁板綍
+ sql = @"select * from TK_Wrk_Record where wo_code=@ordercode and step_code=@stepcode and style='B'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data2 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data2.Rows.Count > 0) //鏈夋姤宸ヨ褰�
+ {
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "Z") //鍒ゆ柇涓婇亾宸ュ簭灞炴�э細鑷埗宸ュ簭
+ {
+ //鏌ユ壘涓婂埌宸ュ簭鎶ュ伐璁板綍
+ sql = @"select * from TK_Wrk_Record where wo_code=@ordercode and step_code=@stepcode and style='B'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", data0.Rows[0]["STEP_CODE"].ToString());
+ var data3 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data3.Rows.Count > 0) //涓婇亾鏈夋姤宸�
+ {
+ decimal sgood_qty = data3.AsEnumerable().Select(d => d.Field<decimal>("GOOD_QTY")).Sum(); //涓婇亾鎶ュ伐鎬绘暟閲�
+ decimal good_qty = data2.AsEnumerable().Select(d => d.Field<decimal>("GOOD_QTY")).Sum(); //鏈亾鎶ュ伐鎬绘暟閲�
+ decimal ng_qty = data2.AsEnumerable().Select(d => d.Field<decimal>("NG_QTY")).Sum(); //鏈亾涓嶈壇鎬绘暟閲�
+ decimal bad_qty = data2.AsEnumerable().Select(d => d.Field<decimal>("BAD_QTY")).Sum(); //鏈亾鎬绘姤搴熸暟閲�
+
+ decimal sybqty = sgood_qty - good_qty - ng_qty-bad_qty;//鏈亾鍓╀綑鍙姤鏁伴噺=涓婇亾鎶ュ伐鎬绘暟閲�-鏈亾鎶ュ伐鎬绘暟閲�-鏈亾涓嶈壇鎬绘暟閲�-鏈亾鎶ュ簾鎬绘暟
+ if (sybqty <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + "鏃犲彲鎶ユ暟閲�!";
+ mes.data = null;
+ return mes;
+ }
+ else
+ {
+ if (sgood_qty == null || sgood_qty == 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鍚堟牸浜у嚭涓�0,鏈亾涓嶅厑璁稿紑鎶ュ伐!";
+ mes.data = null;
+ return mes;
+ }
+ rt.eqpcode = data1.Rows[0]["code"].ToString(); //寮�宸ヨ澶囩紪鐮�
+ rt.eqpname = data1.Rows[0]["name"].ToString(); //寮�宸ヨ澶囧悕绉�
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.startqty = sybqty; //寮�宸ユ暟閲�=鏈亾鍓╀綑鍙姤鏁伴噺
+ rt.noreportqty = sybqty; //鏈姤鏁伴噺=鏈亾鍓╀綑鍙姤鏁伴噺
+ rt.reportqty = good_qty + ng_qty+bad_qty; //宸叉姤鏁伴噺=鏈亾鎶ュ伐鎬绘暟閲�+鏈亾鎶ュ伐鎬讳笉鑹�+鏈亾鎶ュ簾鎬绘暟
+ mes.code = "200";
+ mes.count = 1;
+ mes.Message = "寮圭獥鎶ュ伐鐣岄潰!";
+ mes.data = rt;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鏈姤宸�,鏈亾涓嶅厑璁稿紑鎶ュ伐!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "W") //鍒ゆ柇涓婇亾宸ュ簭灞炴�э細濮斿宸ュ簭
+ {
+ //鏌ユ壘涓婂埌宸ュ簭鏀舵枡璁板綍
+ sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='S'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", data0.Rows[0]["STEP_CODE"].ToString());
+ var data3 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data3.Rows.Count > 0) //涓婇亾鏈夋敹鏂�
+ {
+ decimal sqty = data3.AsEnumerable().Select(d => d.Field<decimal>("SQTY")).Sum(); //涓婇亾鏀舵枡鏁伴噺
+ decimal good_qty = data2.AsEnumerable().Select(d => d.Field<decimal>("GOOD_QTY")).Sum(); //鏈亾鎶ュ伐鎬绘暟閲�
+ decimal ng_qty = data2.AsEnumerable().Select(d => d.Field<decimal>("NG_QTY")).Sum(); //鏈亾涓嶈壇鎬绘暟閲�
+ decimal bad_qty = data2.AsEnumerable().Select(d => d.Field<decimal>("BAD_QTY")).Sum(); //鏈亾鎬绘姤搴熸暟閲�
+
+ decimal sybqty = sqty - good_qty - ng_qty-bad_qty;//鏈亾鍓╀綑鍙姤鏁伴噺=涓婇亾鏀舵枡鎬绘暟閲�-鏈亾鎶ュ伐鎬绘暟閲�-鏈亾涓嶈壇鎬绘暟閲�-鏈亾鎬绘姤搴熸暟
+ if (sybqty <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + "鏃犲彲鎶ユ暟閲�!";
+ mes.data = null;
+ return mes;
+ }
+ else
+ {
+ if (sqty == null || sqty == 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鍚堟牸鏀舵枡涓�0,鏈亾涓嶅厑璁稿紑鎶ュ伐!";
+ mes.data = null;
+ return mes;
+ }
+ rt.eqpcode = data1.Rows[0]["code"].ToString(); //寮�宸ヨ澶囩紪鐮�
+ rt.eqpname = data1.Rows[0]["name"].ToString(); //寮�宸ヨ澶囧悕绉�
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.startqty = sybqty; //寮�宸ユ暟閲�=鏈亾鍓╀綑鍙姤鏁伴噺
+ rt.noreportqty = sybqty; //鏈姤鏁伴噺=鏈亾鍓╀綑鍙姤鏁伴噺
+ rt.reportqty = good_qty + ng_qty+bad_qty; //宸叉姤鏁伴噺=鏈亾鎶ュ伐鎬绘暟閲�+鏈亾鎶ュ伐鎬讳笉鑹�+鏈亾鎬绘姤搴熸暟
+ mes.code = "200";
+ mes.count = 1;
+ mes.Message = "寮圭獥鎶ュ伐鐣岄潰!";
+ mes.data = rt;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鏈敹鏂�,鏈亾涓嶅厑璁稿紑鎶ュ伐,璇峰墠寰�澶栧崗鎿嶄綔椤垫墽琛�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ else //鏈亾鏃犳姤宸ヨ褰�
+ {
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "Z") //鑷埗宸ュ簭
+ {
+ //鏌ユ壘涓婂埌宸ュ簭鎶ュ伐璁板綍
+ sql = @"select * from TK_Wrk_Record where wo_code=@ordercode and step_code=@stepcode and style='B'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", data0.Rows[0]["STEP_CODE"].ToString());
+ var data3 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data3.Rows.Count > 0) //涓婇亾鏈夋姤宸�
+ {
+ decimal sgood_qty = data3.AsEnumerable().Select(d => d.Field<decimal>("GOOD_QTY")).Sum(); //涓婇亾鎶ュ伐鎬绘暟閲�
+ decimal sybqty = sgood_qty; //鏈亾鍓╀綑鍙姤鏁伴噺=涓婇亾鎶ュ伐鏁伴噺
+ if (sgood_qty == null || sgood_qty == 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鍚堟牸浜у嚭涓�0,鏈亾涓嶅厑璁稿紑鎶ュ伐!";
+ mes.data = null;
+ return mes;
+ }
+ rt.eqpcode = data1.Rows[0]["code"].ToString(); //寮�宸ヨ澶囩紪鐮�
+ rt.eqpname = data1.Rows[0]["name"].ToString(); //寮�宸ヨ澶囧悕绉�
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.startqty = sybqty; //寮�宸ユ暟閲�=鏈亾鍓╀綑鍙姤鏁伴噺
+ rt.noreportqty = sybqty; //鏈姤鏁伴噺=鏈亾鍓╀綑鍙姤鏁伴噺
+ rt.reportqty = 0; //宸叉姤鏁伴噺
+ mes.code = "200";
+ mes.count = 1;
+ mes.Message = "寮圭獥鎶ュ伐鐣岄潰!";
+ mes.data = rt;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鏈姤宸�,鏈亾涓嶅厑璁稿紑鎶ュ伐!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "W") //濮斿宸ュ簭
+ {
+ //鏌ユ壘涓婂埌宸ュ簭鏀舵枡璁板綍
+ sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='S'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", data0.Rows[0]["STEP_CODE"].ToString());
+ var data3 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data3.Rows.Count > 0) //涓婇亾鏈夋敹鏂�
+ {
+ decimal sqty = data3.AsEnumerable().Select(d =>d.Field<decimal>("SQTY")).Sum();//涓婇亾鏀舵枡鏁伴噺
+ decimal sybqty = sqty; //鏈亾鍓╀綑鍙敹鏁伴噺=涓婇亾鏀舵枡鏁伴噺
+ if (sqty == null || sqty == 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鍚堟牸鏀舵枡涓�0,鏈亾涓嶅厑璁稿紑鎶ュ伐!";
+ mes.data = null;
+ return mes;
+ }
+ rt.eqpcode = data1.Rows[0]["code"].ToString(); //寮�宸ヨ澶囩紪鐮�
+ rt.eqpname = data1.Rows[0]["name"].ToString(); //寮�宸ヨ澶囧悕绉�
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.startqty = sybqty; //寮�宸ユ暟閲�=鏈亾鍓╀綑鍙敹鏁伴噺
+ rt.noreportqty = sybqty; //鏈姤鏁伴噺=鏈亾鍓╀綑鍙敹鏁伴噺
+ rt.reportqty = 0; //宸叉姤鏁伴噺
+ mes.code = "200";
+ mes.count = 1;
+ mes.Message = "寮圭獥鎶ュ伐鐣岄潰!";
+ mes.data = rt;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鏈敹鏂�,鏈亾涓嶅厑璁稿紑鎶ュ伐,璇峰墠寰�澶栧崗鎿嶄綔椤垫墽琛�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ }
+ else //鏃犲紑宸ヨ褰�
+ {
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "Z") //鑷埗宸ュ簭
+ {
+ //鏌ユ壘涓婂埌宸ュ簭鎶ュ伐璁板綍
+ sql = @"select * from TK_Wrk_Record where wo_code=@ordercode and step_code=@stepcode and style='B'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", data0.Rows[0]["STEP_CODE"].ToString());
+ var data2 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data2.Rows.Count > 0) //涓婂埌宸ュ簭鏈夋姤宸�
+ {
+ decimal good_qty = data2.AsEnumerable().Select(d => d.Field<decimal>("GOOD_QTY")).Sum();//鎶ュ伐鏁伴噺
+ decimal ng_qty = data2.AsEnumerable().Select(d => d.Field<decimal>("NG_QTY")).Sum();// 涓嶈壇鏁伴噺
+ decimal bad_qty = data2.AsEnumerable().Select(d => d.Field<decimal>("BAD_QTY")).Sum();// 鎶ュ簾鏁伴噺
+ if (good_qty == null || good_qty == 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鍚堟牸浜у嚭涓�0,鏈亾涓嶅厑璁稿紑鎶ュ伐!";
+ mes.data = null;
+ return mes;
+ }
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.startqty = good_qty; //寮�宸ユ暟閲�=(涓婁竴閬撶殑鎶ュ伐鎬绘暟閲�)
+ rt.noreportqty = good_qty; //鏈姤鏁伴噺=(涓婁竴閬撶殑鎶ュ伐鎬绘暟閲�)
+ rt.reportqty = 0; //宸叉姤鏁伴噺
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "寮圭獥寮�宸ョ晫闈�!";
+ mes.data = rt;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鏈姤宸�,鏈亾涓嶅厑璁稿紑鎶ュ伐!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "W") //濮斿宸ュ簭
+ {
+ //鏌ユ壘涓婇亾宸ュ簭澶栧崗鏀舵枡璁板綍
+ sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='S'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", data0.Rows[0]["STEP_CODE"].ToString());
+ var data2 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data2.Rows.Count > 0) //涓婇亾宸ュ簭鏈夋敹鏂�
+ {
+ decimal sqty = data2.AsEnumerable().Select(d => d.Field<decimal>("SQTY")).Sum();//鏀舵枡鏁伴噺
+ decimal ng_qty = data2.AsEnumerable().Select(d => d.Field<decimal>("NG_QTY")).Sum();// 涓嶈壇鏁伴噺
+ decimal bad_qty = data2.AsEnumerable().Select(d => d.Field<decimal>("BAD_QTY")).Sum();// 鎶ュ簾鏁伴噺
+ if (sqty == null || sqty == 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鍚堟牸鏀舵枡涓�0,鏈亾涓嶅厑璁稿紑鎶ュ伐!";
+ mes.data = null;
+ return mes;
+ }
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.startqty = sqty; //寮�宸ユ暟閲�=(涓婁竴閬撶殑鏀舵枡鏁伴噺)
+ rt.noreportqty = sqty; //鏈姤鏁伴噺=(涓婁竴閬撶殑鏀舵枡鏁伴噺)
+ rt.reportqty = 0; //宸叉姤鏁伴噺
+ mes.code = "200";
+ mes.count = 0;
+ mes.Message = "寮圭獥寮�宸ョ晫闈�!";
+ mes.data = rt;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鏈敹鏂�,鏈亾涓嶅厑璁稿紑鎶ュ伐,璇峰墠寰�澶栧崗鎿嶄綔椤垫墽琛�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏈壘鍒板綋鍓嶅伐搴忕殑涓婇亾宸ュ簭淇℃伅,璇疯仈绯荤鐞嗗憳鏍稿疄!";
+ mes.data = null;
+ return mes;
+ }
+
+ }
+ break;
+ case "W": //澶栧崗宸ュ簭
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鏍囩涓哄鍗忔爣绛�,璇峰墠寰�澶栧崗鎿嶄綔鏍囩椤垫壂鐮�!";
+ mes.data = null;
+ break;
+ default: //鑷埗+澶栧崗宸ュ簭
+ break;
+ }
+
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ return mes;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鐢熶骇寮�鎶ュ伐:澶栧崗宸ュ簭浠诲姟寮�鎶ュ伐鍒ゆ柇:宸ュ崟鍙�+宸ュ簭]
+ /// <summary>
+ /// 鐢熶骇寮�鎶ュ伐:澶栧崗宸ュ簭浠诲姟寮�鎶ュ伐鍒ゆ柇:宸ュ崟鍙�+宸ュ簭
+ /// </summary>
+ /// <param name="stu_torgcode">鎵�灞炵粍缁囩紪鐮�</param>
+ /// <param name="SelectType">鎿嶄綔绫诲瀷</param>
+ /// <param name="ordercode">宸ュ崟缂栧彿</param>
+ /// <param name="stepcode">宸ュ簭缂栫爜</param>
+ /// <returns></returns>
+ public static ToMessage WXEncodingSeach(string stu_torgcode, string SelectType, string ordercode, string stepcode)
+ {
+ var sql = "";
+ string flwtype = ""; //宸ュ簭灞炴��
+ string isbott = ""; //棣栭亾宸ュ簭
+ string isend = ""; //鏈亾宸ュ簭
+ string seq = ""; //宸ュ簭搴忓彿
+ List<object> list = new List<object>();
+ ScanStartReportDataOut rt = new ScanStartReportDataOut();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ //鍒ゆ柇褰撳墠宸ュ崟鏄惁鍏抽棴
+ sql = @"select * from TK_Wrk_Man where wo_code=@ordercode and wkshp_code=@stu_torgcode and status='CLOSED'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ var da0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (da0.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ崟宸插叧闂�,涓嶅厑璁稿紑鎶ュ伐鎿嶄綔!";
+ mes.data = null;
+ return mes;
+ }
+
+ //0.鍒ゆ柇褰撳墠宸ュ崟鎵�灞炶溅闂存槸鍚︿负褰撳墠鐧诲綍浜哄憳杞﹂棿
+ sql = @"select * from TK_Wrk_Man where wo_code=@ordercode and wkshp_code=@stu_torgcode";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stu_torgcode", stu_torgcode);
+ var da1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (da1.Rows.Count <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "涓嶆槸鏈溅闂寸敓浜т换鍔�,涓嶅厑璁告搷浣�!";
+ mes.data = null;
+ return mes;
+ }
+
+ //1.鏍规嵁宸ュ崟+宸ュ簭鏌ユ壘褰撳墠宸ュ簭鏄惁棣栭亾宸ュ簭
+ sql = @"select A.wo_code,P.partcode,P.partname,P.partspec, T.stepcode,T.stepname,A.seq,T.flwtype,T.descr,A.status,A.plan_qty,A.isbott,A.isend,L.org_code,L.org_name
+ from TK_Wrk_Step A
+ left join TStep T on A.step_code=T.stepcode
+ left join TK_Wrk_Man M on A.wo_code=M.wo_code
+ left join TMateriel_Info P on M.materiel_code=P.partcode
+ left join TOrganization L on M.wkshp_code=L.org_code
+ where A.wo_code=@ordercode and A.step_code=@stepcode";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ rt.wkshopcode = data.Rows[0]["org_code"].ToString(); //杞﹂棿缂栫爜
+ rt.wkshopname = data.Rows[0]["org_name"].ToString(); //杞﹂棿鍚嶇О
+ rt.wo_code = data.Rows[0]["WO_CODE"].ToString(); //宸ュ崟鍙�
+ rt.partnumber = data.Rows[0]["PARTCODE"].ToString(); //浜у搧缂栫爜
+ rt.partname = data.Rows[0]["PARTNAME"].ToString(); //浜у搧鍚嶇О
+ rt.partspec = data.Rows[0]["PARTSPEC"].ToString(); //浜у搧瑙勬牸
+ rt.stepcode = data.Rows[0]["STEPCODE"].ToString(); //宸ュ簭缂栫爜
+ rt.stepname = data.Rows[0]["STEPNAME"].ToString(); //宸ュ簭鍚嶇О
+ rt.stepdesc = data.Rows[0]["DESCR"].ToString(); //宸ュ簭鎻忚堪
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+
+ flwtype = data.Rows[0]["FLWTYPE"].ToString();//鑾峰彇宸ュ簭灞炴��
+ isbott = data.Rows[0]["ISBOTT"].ToString();//棣栭亾宸ュ簭
+ isend = data.Rows[0]["ISEND"].ToString();//鏈亾宸ュ簭
+ rt.seq = data.Rows[0]["SEQ"].ToString();//宸ュ簭搴忓彿
+
+ //鑾峰彇褰撳墠宸ュ簭涓嬮亾宸ュ簭
+ sql = @"select A.isbott,A.isend,T.stepcode,T.stepname from TK_Wrk_Step A
+ left join TStep T on A.step_code=T.stepcode
+ where A.wo_code=@ordercode and A.seq=@seq+1 ";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@seq", decimal.Parse(data.Rows[0]["SEQ"].ToString()));
+ var dt = DapperHelper.selectdata(sql, dynamicParams);
+ if (dt.Rows.Count > 0) //鏈変笅閬撳伐搴�
+ {
+ rt.nextstepcode = dt.Rows[0]["STEPCODE"].ToString();//涓嬮亾宸ュ簭缂栫爜
+ rt.nextstepname = dt.Rows[0]["STEPNAME"].ToString();//涓嬮亾宸ュ簭鍚嶇О
+ }
+ if (isend == "Y") //褰撳墠宸ュ簭鏄湯閬撳伐搴�
+ {
+ rt.nextstepcode = "";// data.Rows[0]["STEPCODE"].ToString();//褰撳墠宸ュ簭缂栫爜
+ rt.nextstepname = "";// data.Rows[0]["STEPNAME"].ToString();//褰撳墠宸ュ簭鍚嶇О
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鎵爜宸ュ簭浠诲姟涓嶅瓨鍦�!";
+ mes.data = null;
+ return mes;
+ }
+ switch (SelectType)
+ {
+ case "OUT": //鍙戞枡
+ switch (flwtype)
+ {
+ case "Z":
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鏍囩涓鸿嚜鍒舵爣绛�,璇峰墠寰�鑷埗鎿嶄綔鏍囩椤垫壂鐮�!";
+ mes.data = null;
+ break;
+ case "W":
+ if (isbott == "Y") //棣栭亾宸ュ簭
+ {
+ //1.棣栭亾宸ュ簭鏃讹紝鍒ゆ柇鏄惁鏈夊彂鏂欒褰�
+ sql = @"select * from TK_Wrk_OutRecord R
+ left join TCustomer C on R.wx_code=C.code
+ where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='F'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0) //鏈夊彂鏂欒褰�
+ {
+ decimal fqty = data0.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum(); //鍙戞枡鏁伴噺
+ decimal ng_qty =data0.AsEnumerable().Select(d => d.Field<decimal>("NG_QTY")).Sum();// 涓嶈壇鏁伴噺
+ decimal bad_qty = data0.AsEnumerable().Select(d => d.Field<decimal>("BAD_QTY")).Sum(); //鎶ュ簾鏁伴噺
+ decimal kfqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()) - fqty - ng_qty- bad_qty; //鍓╀綑鍙彂鏁伴噺
+ if (kfqty <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭鏃犲彲鍙戞枡鏁伴噺!";
+ mes.data = null;
+ return mes;
+ }
+ else
+ {
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.noreportqty = kfqty; //鏈彂鏁伴噺=鍓╀綑鍙彂鏁伴噺
+ rt.reportqty = fqty; //宸插彂鏁伴噺= 鍙戞枡鏁伴噺
+ rt.startqty = kfqty; //鍙戞枡鏁伴噺=鍓╀綑鍙彂鏁伴噺
+ mes.code = "200";
+ mes.count = 2;
+ mes.Message = "寮圭獥鍙戞枡鐣岄潰!";
+ mes.data = rt;
+ }
+ }
+ else
+ {
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.noreportqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //鏈彂鏁伴噺=浠诲姟鏁伴噺
+ rt.reportqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //宸插彂鏁伴噺=浠诲姟鏁伴噺
+ rt.startqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //鍙戞枡鏁伴噺=浠诲姟鏁伴噺
+ mes.code = "200";
+ mes.count = 2;
+ mes.Message = "寮圭獥鍙戞枡鐣岄潰!";
+ mes.data = rt;
+ }
+ }
+ else //闈為閬�
+ {
+ //鏌ユ壘褰撳墠宸ュ簭涓婂埌宸ュ簭(鑷埗鎴栬�呭鍗�)
+ sql = @"select A.step_code,S.stepname,S.flwtype from TFlw_Rtdt A
+ left join TK_Wrk_Man M on A.rout_code=M.route_code
+ left join TStep S on A.step_code=S.stepcode
+ where M.wo_code=@wocode and A.seq=@seq-1";
+ dynamicParams.Add("@wocode", data.Rows[0]["WO_CODE"].ToString());
+ dynamicParams.Add("@seq", decimal.Parse(data.Rows[0]["SEQ"].ToString()));
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ //1.闈為閬撳伐搴忔椂锛屽垽鏂湰閬撴槸鍚︽湁鍙戞枡璁板綍
+ sql = @"select * from TK_Wrk_OutRecord R
+ left join TCustomer C on R.wx_code=C.code
+ where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='F'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data1.Rows.Count > 0)//鏈亾鏈夊彂鏂欒褰�
+ {
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "Z") //鍒ゆ柇涓婇亾宸ュ簭灞炴�э細鑷埗宸ュ簭
+ {
+ //鏌ユ壘涓婂埌宸ュ簭鎶ュ伐璁板綍
+ sql = @"select * from TK_Wrk_Record where wo_code=@ordercode and step_code=@stepcode and style='B'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", data0.Rows[0]["STEP_CODE"].ToString());
+ var data3 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data3.Rows.Count > 0) //涓婇亾鏈夋姤宸�
+ {
+ decimal sgood_qty = data3.AsEnumerable().Select(d => d.Field<decimal>("GOOD_QTY")).Sum(); //鏈亾鎶ュ伐鎬绘暟閲�
+ decimal sqty = data1.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum();//鏈亾鍙戞枡鏁伴噺
+ decimal ng_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("NG_QTY")).Sum();// 鏈亾涓嶈壇鏁伴噺
+ decimal bad_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("BAD_QTY")).Sum(); //鏈亾鎶ュ簾鏁伴噺
+
+ decimal sybqty =sgood_qty - sqty - ng_qty- bad_qty;//鏈亾鍓╀綑鍙彂鏁伴噺=涓婇亾鎶ュ伐鏁伴噺-鏈亾鍙戞枡鏁伴噺-鏈亾涓嶈壇鏁伴噺-鏈亾鎶ュ簾鏁伴噺
+ if (sybqty <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + "鏃犲彲鍙戞暟閲�!";
+ mes.data = null;
+ return mes;
+ }
+ else
+ {
+ if (sgood_qty == null || sgood_qty == 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鍚堟牸浜у嚭涓�0,鏈亾涓嶅厑璁稿彂鏂�!";
+ mes.data = null;
+ return mes;
+ }
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.noreportqty = sybqty; //鏈彂鏁伴噺=鍓╀綑鍙彂鏁伴噺
+ rt.reportqty = sqty + ng_qty+bad_qty; //宸插彂鏁伴噺= 鏈亾鍙戞枡鏁伴噺+鏈亾涓嶈壇鏁伴噺+鏈亾鎶ュ簾鏁伴噺
+ rt.startqty = sybqty; //鏀舵枡鏁伴噺=鍓╀綑鍙彂鏁伴噺
+
+ mes.code = "200";
+ mes.count = 2;
+ mes.Message = "寮圭獥鍙戞枡鐣岄潰!";
+ mes.data = rt;
+ }
+ }
+ else //鏃犳姤宸ヨ褰�
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鏈姤宸�,鏈亾涓嶅厑璁稿彂鏂�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "W") //鍒ゆ柇涓婇亾宸ュ簭灞炴�э細澶栧崗宸ュ簭
+ {
+ //鏌ユ壘涓婂埌宸ュ簭鏀舵枡璁板綍
+ sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='S'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", data0.Rows[0]["STEP_CODE"].ToString());
+ var data3 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data3.Rows.Count > 0) //涓婇亾鏈夋敹鏂�
+ {
+ decimal ssqty = data3.AsEnumerable().Select(d => d.Field<decimal>("SQTY")).Sum();//涓婇亾鏀舵枡鏁伴噺
+ decimal sqty = data1.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum();//鏈亾鍙戞枡鏁伴噺
+ decimal ng_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("NG_QTY")).Sum();// 鏈亾涓嶈壇鏁伴噺
+ decimal bad_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("BAD_QTY")).Sum(); //鏈亾鎶ュ簾鏁伴噺
+
+ decimal sybqty = ssqty - sqty - ng_qty-bad_qty;//鏈亾鍓╀綑鍙彂鏁伴噺=涓婇亾鏀舵枡鏁伴噺-鏈亾鍙戞枡鏁伴噺-鏈亾涓嶈壇鏁伴噺-鏈亾鎶ュ簾鏁伴噺
+ if (sybqty <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + "鏃犲彲鍙戞暟閲�!";
+ mes.data = null;
+ return mes;
+ }
+ else
+ {
+ if (ssqty == null || ssqty == 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鍚堟牸鏀舵枡涓�0,鏈亾涓嶅厑璁稿彂鏂�!";
+ mes.data = null;
+ return mes;
+ }
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.noreportqty = sybqty; //鏈彂鏁伴噺=鍓╀綑鍙彂鏁伴噺
+ rt.reportqty = sqty + ng_qty+bad_qty; //宸插彂鏁伴噺= 鏈亾鍙戞枡鏁伴噺+鏈亾涓嶈壇鏁伴噺+鏈亾鎶ュ簾鏁伴噺
+ rt.startqty = sybqty; //鏀舵枡鏁伴噺=鍓╀綑鍙彂鏁伴噺
+
+ mes.code = "200";
+ mes.count = 2;
+ mes.Message = "寮圭獥鍙戞枡鐣岄潰!";
+ mes.data = rt;
+ }
+ }
+ else //鏃犳姤宸ヨ褰�
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鏈彂鏂�,鏈亾涓嶅厑璁稿彂鏂�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ else //鏃犲彂鏂欒褰�
+ {
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "Z") //鑷埗宸ュ簭
+ {
+ //鏌ユ壘涓婂埌宸ュ簭鎶ュ伐璁板綍
+ sql = @"select * from TK_Wrk_Record where wo_code=@ordercode and step_code=@stepcode and style='B'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", data0.Rows[0]["STEP_CODE"].ToString());
+ var data3 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data3.Rows.Count > 0) //涓婇亾鏈夋姤宸�
+ {
+ decimal sgood_qty = data3.AsEnumerable().Select(d => d.Field<decimal>("GOOD_QTY")).Sum(); //鏈亾鎶ュ伐鎬绘暟閲�
+
+ decimal sybqty = sgood_qty;//鏈亾鍓╀綑鍙彂鏁伴噺=涓婇亾鎶ュ伐鎬绘暟閲�
+ if (sgood_qty == null || sgood_qty == 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鍚堟牸浜у嚭涓�0,鏈亾涓嶅厑璁稿彂鏂�!";
+ mes.data = null;
+ return mes;
+ }
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.noreportqty = sybqty; //鏈彂鏁伴噺=鍓╀綑鍙彂鏁伴噺
+ rt.reportqty = 0; //宸插彂鏁伴噺
+ rt.startqty = sybqty; //鏀舵枡鏁伴噺=鍓╀綑鍙彂鏁伴噺
+
+ mes.code = "200";
+ mes.count = 2;
+ mes.Message = "寮圭獥鍙戞枡鐣岄潰!";
+ mes.data = rt;
+
+ }
+ else //鏃犳姤宸ヨ褰�
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鏈姤宸�,鏈亾涓嶅厑璁稿彂鏂�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ if (data0.Rows[0]["FLWTYPE"].ToString() == "W") //澶栧崗宸ュ簭
+ {
+ //鏌ユ壘涓婂埌宸ュ簭鏀舵枡璁板綍
+ sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='S'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", data0.Rows[0]["STEP_CODE"].ToString());
+ var data3 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data3.Rows.Count > 0) //涓婇亾鏈夋敹鏂�
+ {
+ decimal ssqty = data3.AsEnumerable().Select(d => d.Field<decimal>("SQTY")).Sum();//涓婇亾鏀舵枡鏁伴噺
+
+ decimal sybqty = ssqty;//鏈亾鍓╀綑鍙彂鏁伴噺=涓婇亾鏀舵枡鏁伴噺
+ if (sybqty <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + "鏃犲彲鍙戞暟閲�!";
+ mes.data = null;
+ return mes;
+ }
+ else
+ {
+ if (ssqty == null || ssqty == 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鍚堟牸鏀舵枡涓�0,鏈亾涓嶅厑璁稿彂鏂�!";
+ mes.data = null;
+ return mes;
+ }
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.noreportqty = sybqty; //鏈彂鏁伴噺=鍓╀綑鍙彂鏁伴噺
+ rt.reportqty = 0; //宸插彂鏁伴噺
+ rt.startqty = sybqty; //鏀舵枡鏁伴噺=鍓╀綑鍙彂鏁伴噺
+
+ mes.code = "200";
+ mes.count = 2;
+ mes.Message = "寮圭獥鍙戞枡鐣岄潰!";
+ mes.data = rt;
+ }
+ }
+ else //鏃犳姤宸ヨ褰�
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鐨勪笂閬撳伐搴忥細" + data0.Rows[0]["STEPNAME"].ToString() + " 鏈敹鏂�,鏈亾涓嶅厑璁稿彂鏂�!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏈壘鍒板綋鍓嶅伐搴忕殑涓婇亾宸ュ簭淇℃伅,璇疯仈绯荤鐞嗗憳鏍稿疄!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ case "IN": //鏀舵枡
+ switch (flwtype)
+ {
+ case "Z"://鑷埗
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠鏍囩涓鸿嚜鍒舵爣绛�,璇峰墠寰�鑷埗鎿嶄綔鏍囩椤垫壂鐮�!";
+ mes.data = null;
+ break;
+ case "W":
+ if (isbott == "Y") //棣栭亾宸ュ簭
+ {
+ //1.棣栭亾宸ュ簭鏃讹紝鍒ゆ柇鏄惁鏈夊彂鏂欒褰�
+ sql = @"select R.wo_code,R.step_code,R.wx_code as code,C.name,R.materiel_code,
+ isnull(sum(R.fqty),0) as fqty,isnull(sum(R.sqty),0) as sqty,isnull(sum(R.ng_qty),0) as ng_qty,isnull(sum(R.bad_qty),0) as bad_qty
+ from TK_Wrk_OutRecord R
+ left join TCustomer C on R.wx_code=C.code
+ where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='F'
+ group by R.wo_code,R.step_code,R.wx_code,C.name,R.materiel_code";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0) //鏈夊彂鏂欒褰�
+ {
+ //1.棣栭亾宸ュ簭鏃讹紝鍒ゆ柇鏄惁鏈夋敹鏂欒褰�
+ sql = @"select R.wo_code,R.step_code,R.wx_code as code,C.name,R.materiel_code,
+ isnull(sum(R.fqty),0) as fqty,isnull(sum(R.sqty),0) as sqty,isnull(sum(R.ng_qty),0) as ng_qty,isnull(sum(R.bad_qty),0) as bad_qty
+ from TK_Wrk_OutRecord R
+ left join TCustomer C on R.wx_code=C.code
+ where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='S'
+ group by R.wo_code,R.step_code,R.wx_code,C.name,R.materiel_code";
+ //sql = @"select * from TK_Wrk_OutRecord where wo_code=@ordercode and step_code=@stepcode and style='S'";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data1.Rows.Count > 0) //鏈夋敹鏂欒褰�
+ {
+ decimal fqty = data0.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum();//鏈亾鍙戞枡鏁伴噺
+ decimal sqty = data1.AsEnumerable().Select(d => d.Field<decimal>("SQTY")).Sum();//鏈亾鏀舵枡鏁伴噺
+ decimal ng_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("NG_QTY")).Sum();//鏈亾涓嶈壇鏁伴噺
+ decimal bad_qty = data1.AsEnumerable().Select(d => d.Field<decimal>("BAD_QTY")).Sum(); //鏈亾鎶ュ簾鏁伴噺
+ decimal ksqty = fqty - sqty - ng_qty-bad_qty; //鍓╀綑鍙彂鏁伴噺=鏈亾鍙戞枡鏁伴噺-鏈亾鏀舵枡鏁伴噺-鏈亾涓嶈壇鏁伴噺-鏈亾鎶ュ簾鏁伴噺
+ if (ksqty <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鏃犲彲鏀舵枡鏁伴噺!";
+ mes.data = null;
+ return mes;
+ }
+ else
+ {
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.noreportqty = ksqty; //鏈敹鏁伴噺=鏈亾鍙戞枡鏁伴噺
+ rt.reportqty = sqty + ng_qty+bad_qty; //宸叉敹鏁伴噺
+ rt.startqty = ksqty; //鏀舵枡鏁伴噺=鏈亾鍙戞枡鏁伴噺
+
+ data0.Merge(data1);//灏嗘寚瀹氱殑dt鍚堝苟
+ rt.list = data0.AsEnumerable().GroupBy(r => new {
+ wo_code = r["wo_code"],
+ step_code = r["step_code"],
+ code = r["code"],
+ name = r["name"]
+ }).Select(g => new {
+ Name = g.Key.code,
+ tp = g.Key.name,
+ fqty = g.Sum(i => (decimal)i["fqty"]),
+ sqty = g.Sum(i => (decimal)i["sqty"]),
+ ng_qty = g.Sum(i => (decimal)i["ng_qty"]),
+ bad_qty = g.Sum(i => (decimal)i["bad_qty"])
+ }).ToList();
+
+ mes.code = "200";
+ mes.count = 3;
+ mes.Message = "寮圭獥鏀舵枡鐣岄潰!";
+ mes.data = rt;
+ }
+
+ }
+ else
+ {
+ decimal fqty = data0.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum();//鏈亾鍙戞枡鏁伴噺
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.noreportqty = fqty; //鏈敹鏁伴噺=鏈亾鍙戞枡鏁伴噺
+ rt.reportqty = 0; //宸叉敹鏁伴噺
+ rt.startqty = fqty; //鏀舵枡鏁伴噺=鏈亾鍙戞枡鏁伴噺
+ //
+ data0.Merge(data1);//灏嗘寚瀹氱殑dt鍚堝苟
+ rt.list = data0.AsEnumerable().GroupBy(r => new {
+ wo_code = r["wo_code"],
+ step_code = r["step_code"],
+ code = r["code"],
+ name = r["name"]
+ }).Select(g => new {
+ Name = g.Key.code,
+ tp = g.Key.name,
+ fqty = g.Sum(i => (decimal)i["fqty"]),
+ sqty = g.Sum(i => (decimal)i["sqty"]),
+ ng_qty = g.Sum(i => (decimal)i["ng_qty"]),
+ bad_qty = g.Sum(i => (decimal)i["bad_qty"])
+ }).ToList();
+
+ mes.code = "200";
+ mes.count = 3;
+ mes.Message = "寮圭獥鏀舵枡鐣岄潰!";
+ mes.data = rt;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鏈彂鏂�,璇峰厛鍙戞枡!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ else //闈為閬�
+ {
+ //鏌ユ壘褰撳墠宸ュ簭涓婂埌宸ュ簭(鑷埗鎴栬�呭鍗�)
+ sql = @"select A.step_code,S.stepname,S.flwtype from TFlw_Rtdt A
+ left join TK_Wrk_Man M on A.rout_code=M.route_code
+ left join TStep S on A.step_code=S.stepcode
+ where M.wo_code=@wocode and A.seq=@seq-1";
+ dynamicParams.Add("@wocode", data.Rows[0]["WO_CODE"].ToString());
+ dynamicParams.Add("@seq", decimal.Parse(data.Rows[0]["SEQ"].ToString()));
+ var data0 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data0.Rows.Count > 0)
+ {
+ //1.闈為閬撳伐搴忔椂锛屽垽鏂湰閬撴槸鍚︽湁鍙戞枡璁板綍
+ sql = @"select R.wo_code,R.step_code,R.wx_code as code,C.name,R.materiel_code,
+ isnull(sum(R.fqty),0) as fqty,isnull(sum(R.sqty),0) as sqty,isnull(sum(R.ng_qty),0) as ng_qty,isnull(sum(R.bad_qty),0) as bad_qty
+ from TK_Wrk_OutRecord R
+ left join TCustomer C on R.wx_code=C.code
+ where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='F'
+ group by R.wo_code,R.step_code,R.wx_code,C.name,R.materiel_code";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data1 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data1.Rows.Count > 0)//鏈亾鏈夊彂鏂欒褰�
+ {
+ //2.闈為閬撳伐搴忔椂锛屽垽鏂湰閬撴槸鍚︽湁鏀舵枡璁板綍
+ sql = @"select R.wo_code,R.step_code,R.wx_code as code,C.name,R.materiel_code,
+ isnull(sum(R.fqty),0) as fqty,isnull(sum(R.sqty),0) as sqty,isnull(sum(R.ng_qty),0) as ng_qty,isnull(sum(R.bad_qty),0) as bad_qty
+ from TK_Wrk_OutRecord R
+ left join TCustomer C on R.wx_code=C.code
+ where R.wo_code=@ordercode and R.step_code=@stepcode and R.style='S'
+ group by R.wo_code,R.step_code,R.wx_code,C.name,R.materiel_code";
+ dynamicParams.Add("@ordercode", ordercode);
+ dynamicParams.Add("@stepcode", stepcode);
+ var data2 = DapperHelper.selectdata(sql, dynamicParams);
+ if (data2.Rows.Count > 0) //鏈夋敹鏂欒褰�
+ {
+ decimal fqty = data1.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum();//鏈亾鍙戞枡鏁伴噺
+ decimal sqty = data2.AsEnumerable().Select(d => d.Field<decimal>("SQTY")).Sum();//鏈亾鏀舵枡鏁伴噺
+ decimal ng_qty = data2.AsEnumerable().Select(d => d.Field<decimal>("NG_QTY")).Sum();//鏈亾涓嶈壇鏁伴噺
+ decimal bad_qty = data2.AsEnumerable().Select(d => d.Field<decimal>("BAD_QTY")).Sum(); //鏈亾鎶ュ簾鏁伴噺
+ decimal ksqty = fqty - sqty - ng_qty-bad_qty;//鍓╀綑鍙彂鏁伴噺=鏈亾鍙戞枡鏁伴噺-鏈亾鏀舵枡鏁伴噺-鏈亾涓嶈壇鏁伴噺-鏈亾鎶ュ簾鏁伴噺
+ if (ksqty <= 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鏃犲彲鏀舵枡鏁伴噺!";
+ mes.data = null;
+ return mes;
+ }
+ else
+ {
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.noreportqty = ksqty; //鏈敹鏁伴噺=鏈亾鍙戞枡鏁伴噺
+ rt.reportqty = sqty + ng_qty+bad_qty; //宸叉敹鏁伴噺
+ rt.startqty = ksqty; //鏀舵枡鏁伴噺=鏈亾鍙戞枡鏁伴噺
+
+ data1.Merge(data2);//灏嗘寚瀹氱殑dt鍚堝苟
+ rt.list = data1.AsEnumerable().GroupBy(r => new {
+ wo_code = r["wo_code"],
+ step_code = r["step_code"],
+ code= r["code"],
+ name = r["name"]
+ }).Select(g => new {
+ Name = g.Key.code,
+ tp = g.Key.name,
+ fqty = g.Sum(i => (decimal)i["fqty"]),
+ sqty = g.Sum(i => (decimal)i["sqty"]),
+ ng_qty = g.Sum(i => (decimal)i["ng_qty"]),
+ bad_qty = g.Sum(i => (decimal)i["bad_qty"])
+ }).ToList();
+
+ mes.code = "200";
+ mes.count = 3;
+ mes.Message = "寮圭獥鏀舵枡鐣岄潰!";
+ mes.data = rt;
+ }
+ }
+ else
+ {
+ decimal fqty = data1.AsEnumerable().Select(d => d.Field<decimal>("FQTY")).Sum(); //鏈亾鍙戞枡鏁伴噺
+ rt.planqty = decimal.Parse(data.Rows[0]["PLAN_QTY"].ToString()); //浠诲姟鏁伴噺
+ rt.noreportqty = fqty; //鏈敹鏁伴噺=鏈亾鍙戞枡鏁伴噺
+ rt.reportqty = 0; //宸叉敹鏁伴噺
+ rt.startqty = fqty; //鏀舵枡鏁伴噺=鏈亾鍙戞枡鏁伴噺
+ data1.Merge(data2);//灏嗘寚瀹氱殑dt鍚堝苟
+ rt.list = data1.AsEnumerable().GroupBy(r => new {
+ wo_code = r["wo_code"],
+ step_code = r["step_code"],
+ code = r["code"],
+ name = r["name"]
+ }).Select(g => new {
+ Name = g.Key.code,
+ tp = g.Key.name,
+ fqty = g.Sum(i => (decimal)i["fqty"]),
+ sqty = g.Sum(i => (decimal)i["sqty"]),
+ ng_qty = g.Sum(i => (decimal)i["ng_qty"]),
+ bad_qty = g.Sum(i => (decimal)i["bad_qty"])
+ }).ToList();
+ mes.code = "200";
+ mes.count = 3;
+ mes.Message = "寮圭獥鏀舵枡鐣岄潰!";
+ mes.data = rt;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "褰撳墠宸ュ簭锛�" + data.Rows[0]["STEPNAME"].ToString() + " 鏈彂鏂�,璇峰厛鍙戞枡!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏈壘鍒板綋鍓嶅伐搴忕殑涓婇亾宸ュ簭淇℃伅,璇疯仈绯荤鐞嗗憳鏍稿疄!";
+ mes.data = null;
+ return mes;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ return mes;
+ }
+ return mes;
+ }
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Tools/SchedulingMethod.cs b/VueWebCoreApi/Tools/SchedulingMethod.cs
new file mode 100644
index 0000000..a255abd
--- /dev/null
+++ b/VueWebCoreApi/Tools/SchedulingMethod.cs
@@ -0,0 +1,75 @@
+锘縰sing Dapper;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using VueWebCoreApi.Models;
+
+namespace VueWebCoreApi.Tools
+{
+ public class SchedulingMethod
+ {
+ public static List<APSList> SchedulingMethodTF(string wocode, string wkshpcode, string partcode)
+ {
+ bool TF = true;
+ var dynamicParams = new DynamicParameters();
+ List<APSList> list = new List<APSList>(); //涓嶅睘浜庝骇绾跨殑鍗曟満
+ List<APSList> list0 = new List<APSList>(); //浜х嚎涓殑鍗曟満
+ List<APSList> list1 = new List<APSList>(); //浜х嚎
+ List<APSList> listSum = new List<APSList>(); //姹囨��
+ //鏌ヨ宸ヨ壓璺嚎鎵�鏈夌殑浜х嚎璁惧鎴栬�呭伐浣�
+ string sql = @"select distinct D.code,D.name from TK_Wrk_Man A
+ left join TFlw_Rout K on A.route_code=K.code
+ left join TFlw_Rtdt B on K.code=B.rout_code
+ left join TFlw_Rteqp C on B.step_code= C.step_code
+ left join TEqpInfo D on C.eqp_code=D.code
+ where A.wo_code=@wocode and A.materiel_code=@partcode
+ and D.enable='Y' and D.wksp_code=@wkshpcode
+ order by D.code";
+ dynamicParams.Add("@wocode", wocode);
+ dynamicParams.Add("@wkshpcode", wkshpcode);
+ dynamicParams.Add("@partcode", partcode);
+ var dt = DapperHelper.selectdata(sql, dynamicParams);
+
+ //(0)鏌ヨ鍏抽敭宸ュ簭鍏宠仈涓嶅睘浜庝骇绾跨殑璁惧鎴栬�呭伐浣�
+ string sql0 = @"select distinct A.wo_code, B.step_code,C.eqp_code,D.name,
+ isnull(D.operation_ration,0) AdvaDevicCropMob,
+ isnull(H.stand_value,0) AdvaDevicRhythm,
+ D.eqptype_code as style,
+ 'D' ClassType
+ from TK_Wrk_Man A
+ left join TFlw_Rout K on A.route_code=K.code
+ left join TFlw_Rtdt B on K.code=B.rout_code and B.first_choke='Y'
+ left join TFlw_Rteqp C on B.step_code= C.step_code
+ left join TEqpInfo D on C.eqp_code=D.code
+ left join TPrteEqp_Stad H on C.eqp_code= H.eqp_code and K.code=H.route_code and B.step_code=H.step_code
+ where A.wo_code=@wocode and H.materiel_code=@partcode and D.wksp_code=@wkshpcode and D.enable='Y'
+ order by C.eqp_code";
+ dynamicParams.Add("@wocode", wocode);
+ dynamicParams.Add("@wkshpcode", wkshpcode);
+ dynamicParams.Add("@partcode", partcode);
+ var dt0 = DapperHelper.selectdata(sql0, dynamicParams);
+
+ if (dt0.Rows.Count > 0)
+ {
+ for (int j = 0; j < dt0.Rows.Count; j++)
+ {
+ APSList asp = new APSList();
+ asp.wo_code = dt0.Rows[j]["wo_code"].ToString();
+ asp.step_id = dt0.Rows[j]["step_code"].ToString();
+ asp.eqp_id = dt0.Rows[j]["eqp_code"].ToString();
+ asp.name = dt0.Rows[j]["name"].ToString();
+ asp.AdvaDevicCropMob = dt0.Rows[j]["AdvaDevicCropMob"].ToString(); //绋煎姩鐜�
+ asp.AdvaDevicRhythm = dt0.Rows[j]["AdvaDevicRhythm"].ToString(); //鐢熶骇鑺傛媿
+ asp.Style = dt0.Rows[j]["Style"].ToString();
+ asp.ClassType = dt0.Rows[j]["ClassType"].ToString();
+ list.Add(asp);
+ }
+ }
+ //鍏抽敭宸ュ簭鍏宠仈鐨勮澶囧叏閮ㄦ槸鍗曟満
+ //缁勫悎鍑犵粍鏁版嵁婧�
+ listSum = list.ToList();
+ return listSum;
+ }
+ }
+}
\ No newline at end of file
diff --git a/VueWebCoreApi/Tools/SeachEncode.cs b/VueWebCoreApi/Tools/SeachEncode.cs
new file mode 100644
index 0000000..b6da739
--- /dev/null
+++ b/VueWebCoreApi/Tools/SeachEncode.cs
@@ -0,0 +1,368 @@
+锘縰sing Dapper;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using VueWebCoreApi.Models;
+
+namespace VueWebCoreApi.Tools
+{
+ public class SeachEncode
+ {
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+
+ #region [鑾峰彇瑙勫垯缂栫爜]
+ /// <summary>
+ /// 鏍规嵁鍔熻兘缂栫爜鑾峰彇鏈�鏂拌鍒欑紪鐮�
+ /// </summary>
+ /// <param name="rightcode">鍔熻兘缂栫爜</param>
+ /// <returns></returns>
+ public static ToMessage EncodingSeach(string rightcode)
+ {
+ string sql, year, month, day, fdate, q, cunm2, Encode;
+ int digit2, value2, digit3, digitdiff;
+ bool stf;
+ List<object> list = new List<object>();
+ List<string> listdt = new List<string>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select prefix,filingdate,incbit,value from TCodeRules where menucode=@rightcode";
+ dynamicParams.Add("@rightcode", rightcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ string prefix = data.Rows[0]["PREFIX"].ToString(); //鍥哄畾瀛楁
+ string filingdate = data.Rows[0]["FILINGDATE"].ToString(); //鎻愪氦鏃ユ湡
+ int incbit = int.Parse(data.Rows[0]["INCBIT"].ToString()); //鑷浣嶆暟
+ string value = data.Rows[0]["VALUE"].ToString(); //娴佹按鍙�
+ if (int.Parse(value) > 0) //鍒ゆ柇鏄惁涓洪娆¤幏鍙�
+ {
+ switch (filingdate)
+ {
+ case "骞存湀鏃�":
+ year = DateTime.Now.Year.ToString().Substring(2, 2);//鑾峰彇骞�(2浣�)
+ month = DateTime.Now.Month.ToString().PadLeft(2, '0');//鑾峰彇鏈�(2浣�)
+ day = DateTime.Now.Day.ToString().PadLeft(2, '0');//鑾峰彇鏃�(2浣�)
+ fdate = year + month + day;
+ digit2 = value.Length;//鑾峰彇string绫诲瀷浣嶆暟
+ value2 = int.Parse(value) + 1;// 灏唖tring绫诲瀷杞寲涓篿nt鑷1
+ digit3 = value2.ToString().Length; //鑾峰彇杞寲鍚巌nt鍨嬬殑浣嶆暟
+ digitdiff = digit2 - digit3; //浣嶆暟涔嬪樊
+ q = "";
+ if (digitdiff < 0) //浣嶆暟宸负璐熸暟闇�瑕佽繘琛ヤ綅
+ {
+ cunm2 = value2.ToString();//鏈�缁堟祦姘村彿
+ sql = @"update TCodeRules set incbit=@incbit where menucode=@rightcode";
+ dynamicParams.Add("@incbit", digit3);
+ dynamicParams.Add("@rightcode", rightcode);
+ list.Add(new { str = sql, parm = dynamicParams });
+ }
+ else
+ {
+ for (int i = 1; i <= digitdiff; i++)
+ {
+ q = q + "0";
+ }
+ cunm2 = q + value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ Encode = prefix + fdate + cunm2; //鏈�缁堢紪鐮�
+
+ sql = @"update TCodeRules set value=@cunm2 where menucode=@rightcode";
+ dynamicParams.Add("@cunm2", cunm2);
+ dynamicParams.Add("@rightcode", rightcode);
+ list.Add(new { str = sql, parm = dynamicParams });
+ stf = DapperHelper.DoTransaction(list);
+ if (stf)
+ {
+ listdt.Add(Encode);
+ listdt.Add(cunm2);
+ mes.code = "200";
+ mes.Message = "鎴愬姛!";
+ mes.data = listdt;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶辫触!";
+ mes.data = null;
+ }
+ break;
+ case "骞存湀":
+ year = DateTime.Now.Year.ToString().Substring(2, 2);//鑾峰彇骞�(2浣�)
+ month = DateTime.Now.Month.ToString().PadLeft(2, '0');//鑾峰彇鏈�(2浣�)
+ fdate = year + month;
+ digit2 = value.Length;//鑾峰彇string绫诲瀷浣嶆暟
+ value2 = int.Parse(value) + 1;// 灏唖tring绫诲瀷杞寲涓篿nt鑷1
+ digit3 = value2.ToString().Length; //鑾峰彇杞寲鍚巌nt鍨嬬殑浣嶆暟
+ digitdiff = digit2 - digit3; //浣嶆暟涔嬪樊
+ q = "";
+ if (digitdiff < 0) //浣嶆暟宸负璐熸暟闇�瑕佽繘琛ヤ綅
+ {
+ cunm2 = value2.ToString();//鏈�缁堟祦姘村彿
+ sql = @"update TCodeRules set incbit=@incbit where menucode=@rightcode";
+ dynamicParams.Add("@incbit", digit3);
+ dynamicParams.Add("@rightcode", rightcode);
+ list.Add(new { str = sql, parm = dynamicParams });
+ }
+ else
+ {
+ for (int i = 1; i <= digitdiff; i++)
+ {
+ q = q + "0";
+ }
+ cunm2 = q + value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ Encode = prefix + fdate + cunm2; //鏈�缁堢紪鐮�
+
+
+ sql = @"update TCodeRules set value=@cunm2 where menucode=@rightcode";
+ dynamicParams.Add("@cunm2", cunm2);
+ dynamicParams.Add("@rightcode", rightcode);
+ list.Add(new { str = sql, parm = dynamicParams });
+ stf = DapperHelper.DoTransaction(list);
+ if (stf)
+ {
+ listdt.Add(Encode);
+ listdt.Add(cunm2);
+ mes.code = "200";
+ mes.Message = "鎴愬姛!";
+ mes.data = listdt;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶辫触!";
+ mes.data = null;
+ }
+ break;
+ case "骞�":
+ year = DateTime.Now.Year.ToString().Substring(2, 2);//鑾峰彇骞�(2浣�)
+ fdate = year;
+ digit2 = value.Length;//鑾峰彇string绫诲瀷浣嶆暟
+ value2 = int.Parse(value) + 1;// 灏唖tring绫诲瀷杞寲涓篿nt鑷1
+ digit3 = value2.ToString().Length; //鑾峰彇杞寲鍚巌nt鍨嬬殑浣嶆暟
+ digitdiff = digit2 - digit3; //浣嶆暟涔嬪樊
+ q = "";
+ if (digitdiff < 0) //浣嶆暟宸负璐熸暟闇�瑕佽繘琛ヤ綅
+ {
+ cunm2 = value2.ToString();//鏈�缁堟祦姘村彿
+ sql = @"update TCodeRules set incbit=@incbit where menucode=@rightcode";
+ dynamicParams.Add("@incbit", digit3);
+ dynamicParams.Add("@rightcode", rightcode);
+ list.Add(new { str = sql, parm = dynamicParams });
+ }
+ else
+ {
+ for (int i = 1; i <= digitdiff; i++)
+ {
+ q = q + "0";
+ }
+ cunm2 = q + value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ Encode = prefix + fdate + cunm2; //鏈�缁堢紪鐮�
+
+ sql = @"update TCodeRules set value=@cunm2 where menucode=@rightcode";
+ dynamicParams.Add("@cunm2", cunm2);
+ dynamicParams.Add("@rightcode", rightcode);
+ list.Add(new { str = sql, parm = dynamicParams });
+ stf = DapperHelper.DoTransaction(list);
+ if (stf)
+ {
+ listdt.Add(Encode);
+ listdt.Add(cunm2);
+ mes.code = "200";
+ mes.Message = "鎴愬姛!";
+ mes.data = listdt;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶辫触!";
+ mes.data = null;
+ }
+
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch (filingdate)
+ {
+ case "骞存湀鏃�":
+ year = DateTime.Now.Year.ToString().Substring(2, 2);//鑾峰彇骞�(2浣�)
+ month = DateTime.Now.Month.ToString().PadLeft(2, '0');//鑾峰彇鏈�(2浣�)
+ day = DateTime.Now.Day.ToString().PadLeft(2, '0');//鑾峰彇鏃�(2浣�)
+ fdate = year + month + day;
+ digit2 = value.Length;//鑾峰彇string绫诲瀷浣嶆暟
+ value2 = int.Parse(value) + 1;// 灏唖tring绫诲瀷杞寲涓篿nt鑷1
+ digit3 = value2.ToString().Length; //鑾峰彇杞寲鍚巌nt鍨嬬殑浣嶆暟
+ digitdiff = digit2 - digit3; //浣嶆暟涔嬪樊
+ q = "";
+ if (digitdiff < 0) //浣嶆暟宸负璐熸暟闇�瑕佽繘琛ヤ綅
+ {
+ cunm2 = value2.ToString();//鏈�缁堟祦姘村彿
+ sql = @"update TCodeRules set incbit=@incbit where menucode=@rightcode";
+ dynamicParams.Add("@incbit", digit3);
+ dynamicParams.Add("@rightcode", rightcode);
+ list.Add(new { str = sql, parm = dynamicParams });
+ }
+ else
+ {
+ for (int i = 1; i <= digitdiff; i++)
+ {
+ q = q + "0";
+ }
+ cunm2 = q + value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ Encode = prefix + fdate + cunm2; //鏈�缁堢紪鐮�
+
+ sql = @"update TCodeRules set value=@cunm2 where menucode=@rightcode";
+ dynamicParams.Add("@cunm2", cunm2);
+ dynamicParams.Add("@rightcode", rightcode);
+ list.Add(new { str = sql, parm = dynamicParams });
+ stf = DapperHelper.DoTransaction(list);
+ if (stf)
+ {
+ listdt.Add(Encode);
+ listdt.Add(cunm2);
+ mes.code = "200";
+ mes.Message = "鎴愬姛!";
+ mes.data = listdt;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶辫触!";
+ mes.data = null;
+ }
+ break;
+ case "骞存湀":
+ year = DateTime.Now.Year.ToString().Substring(2, 2);//鑾峰彇骞�(2浣�)
+ month = DateTime.Now.Month.ToString().PadLeft(2, '0');//鑾峰彇鏈�(2浣�)
+ fdate = year + month;
+ digit2 = value.Length;//鑾峰彇string绫诲瀷浣嶆暟
+ value2 = int.Parse(value) + 1;// 灏唖tring绫诲瀷杞寲涓篿nt鑷1
+ digit3 = value2.ToString().Length; //鑾峰彇杞寲鍚巌nt鍨嬬殑浣嶆暟
+ digitdiff = digit2 - digit3; //浣嶆暟涔嬪樊
+ q = "";
+ if (digitdiff < 0) //浣嶆暟宸负璐熸暟闇�瑕佽繘琛ヤ綅
+ {
+ cunm2 = value2.ToString();//鏈�缁堟祦姘村彿
+ sql = @"update TCodeRules set incbit=@incbit where menucode=@rightcode";
+ dynamicParams.Add("@incbit", digit3);
+ dynamicParams.Add("@rightcode", rightcode);
+ list.Add(new { str = sql, parm = dynamicParams });
+ }
+ else
+ {
+ for (int i = 1; i <= digitdiff; i++)
+ {
+ q = q + "0";
+ }
+ cunm2 = q + value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ Encode = prefix + fdate + cunm2; //鏈�缁堢紪鐮�
+
+
+ sql = @"update TCodeRules set value=@cunm2 where menucode=@rightcode";
+ dynamicParams.Add("@cunm2", cunm2);
+ dynamicParams.Add("@rightcode", rightcode);
+ list.Add(new { str = sql, parm = dynamicParams });
+ stf = DapperHelper.DoTransaction(list);
+ if (stf)
+ {
+ listdt.Add(Encode);
+ listdt.Add(cunm2);
+ mes.code = "200";
+ mes.Message = "鎴愬姛!";
+ mes.data = listdt;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶辫触!";
+ mes.data = null;
+ }
+ break;
+ case "骞�":
+ year = DateTime.Now.Year.ToString().Substring(2, 2);//鑾峰彇骞�(2浣�)
+ fdate = year;
+ digit2 = value.Length;//鑾峰彇string绫诲瀷浣嶆暟
+ value2 = int.Parse(value) + 1;// 灏唖tring绫诲瀷杞寲涓篿nt鑷1
+ digit3 = value2.ToString().Length; //鑾峰彇杞寲鍚巌nt鍨嬬殑浣嶆暟
+ digitdiff = digit2 - digit3; //浣嶆暟涔嬪樊
+ q = "";
+ if (digitdiff < 0) //浣嶆暟宸负璐熸暟闇�瑕佽繘琛ヤ綅
+ {
+ cunm2 = value2.ToString();//鏈�缁堟祦姘村彿
+ sql = @"update TCodeRules set incbit=@incbit where menucode=@rightcode";
+ dynamicParams.Add("@incbit", digit3);
+ dynamicParams.Add("@rightcode", rightcode);
+ list.Add(new { str = sql, parm = dynamicParams });
+ }
+ else
+ {
+ for (int i = 1; i <= digitdiff; i++)
+ {
+ q = q + "0";
+ }
+ cunm2 = q + value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ Encode = prefix + fdate + cunm2; //鏈�缁堢紪鐮�
+
+ sql = @"update TCodeRules set value=@cunm2 where menucode=@rightcode";
+ dynamicParams.Add("@cunm2", cunm2);
+ dynamicParams.Add("@rightcode", rightcode);
+ list.Add(new { str = sql, parm = dynamicParams });
+ stf = DapperHelper.DoTransaction(list);
+ if (stf)
+ {
+ listdt.Add(Encode);
+ listdt.Add(cunm2);
+ mes.code = "200";
+ mes.Message = "鎴愬姛!";
+ mes.data = listdt;
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "澶辫触!";
+ mes.data = null;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏈缃紪鐮佽鍒�,鐢熸垚鍗曞彿澶辫触,璇疯缃紪鐮佷负銆�" + rightcode + "銆戠殑缂栫爜瑙勫垯!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+
+ }
+}
diff --git a/VueWebCoreApi/Tools/SeachEncodeJob.cs b/VueWebCoreApi/Tools/SeachEncodeJob.cs
new file mode 100644
index 0000000..392c2b7
--- /dev/null
+++ b/VueWebCoreApi/Tools/SeachEncodeJob.cs
@@ -0,0 +1,265 @@
+锘縰sing Dapper;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class SeachEncodeJob
+ {
+ public static ToMessage mes = new ToMessage(); //瀹氫箟鍏ㄥ眬杩斿洖淇℃伅瀵硅薄
+
+ #region [鑾峰彇瑙勫垯缂栫爜鐢熸垚鐨勬潯鐮乚
+ /// <summary>
+ /// 鏍规嵁鍔熻兘缂栫爜鑾峰彇鏈�鏂拌鍒欑紪鐮�
+ /// </summary>
+ /// <param name="rightcode">鍔熻兘缂栫爜</param>
+ /// <returns></returns>
+ public static ToMessage EncodingSeach(string rightcode)
+ {
+ string sql, year, month, day, fdate, q, cunm2, Encode;
+ int digit2, value2, digit3, digitdiff;
+ bool stf;
+ List<object> list = new List<object>();
+ List<string> listdt = new List<string>();
+ var dynamicParams = new DynamicParameters();
+ try
+ {
+ sql = @"select prefix,filingdate,incbit,value from TCodeRules where menucode=@rightcode";
+ dynamicParams.Add("@rightcode", rightcode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ string prefix = data.Rows[0]["PREFIX"].ToString(); //鍥哄畾瀛楁
+ string filingdate = data.Rows[0]["FILINGDATE"].ToString(); //鎻愪氦鏃ユ湡
+ int incbit = int.Parse(data.Rows[0]["INCBIT"].ToString()); //鑷浣嶆暟
+ string value = data.Rows[0]["VALUE"].ToString(); //娴佹按鍙�
+ if (int.Parse(value) > 0) //鍒ゆ柇鏄惁涓洪娆¤幏鍙�
+ {
+ switch (filingdate)
+ {
+ case "骞存湀鏃�":
+ year = DateTime.Now.Year.ToString().Substring(2, 2);//鑾峰彇骞�(2浣�)
+ month = DateTime.Now.Month.ToString().PadLeft(2, '0');//鑾峰彇鏈�(2浣�)
+ day = DateTime.Now.Day.ToString().PadLeft(2, '0');//鑾峰彇鏃�(2浣�)
+ fdate = year + month + day;
+ digit2 = value.Length;//鑾峰彇string绫诲瀷浣嶆暟
+ value2 = int.Parse(value) + 1;// 灏唖tring绫诲瀷杞寲涓篿nt鑷1
+ digit3 = value2.ToString().Length; //鑾峰彇杞寲鍚巌nt鍨嬬殑浣嶆暟
+ digitdiff = digit2 - digit3; //浣嶆暟涔嬪樊
+ q = "";
+ if (digitdiff < 0) //浣嶆暟宸负璐熸暟闇�瑕佽繘琛ヤ綅
+ {
+ cunm2 = value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ else
+ {
+ for (int i = 1; i <= digitdiff; i++)
+ {
+ q = q + "0";
+ }
+ cunm2 = q + value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ Encode = prefix + fdate + cunm2; //鏈�缁堢紪鐮�
+ listdt.Add(Encode);
+ listdt.Add(cunm2);
+ mes.code = "200";
+ mes.Message = "鎴愬姛!";
+ mes.data = listdt;
+ break;
+ case "骞存湀":
+ year = DateTime.Now.Year.ToString().Substring(2, 2);//鑾峰彇骞�(2浣�)
+ month = DateTime.Now.Month.ToString().PadLeft(2, '0');//鑾峰彇鏈�(2浣�)
+ fdate = year + month;
+ digit2 = value.Length;//鑾峰彇string绫诲瀷浣嶆暟
+ value2 = int.Parse(value) + 1;// 灏唖tring绫诲瀷杞寲涓篿nt鑷1
+ digit3 = value2.ToString().Length; //鑾峰彇杞寲鍚巌nt鍨嬬殑浣嶆暟
+ digitdiff = digit2 - digit3; //浣嶆暟涔嬪樊
+ q = "";
+ if (digitdiff < 0) //浣嶆暟宸负璐熸暟闇�瑕佽繘琛ヤ綅
+ {
+ cunm2 = value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ else
+ {
+ for (int i = 1; i <= digitdiff; i++)
+ {
+ q = q + "0";
+ }
+ cunm2 = q + value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ Encode = prefix + fdate + cunm2; //鏈�缁堢紪鐮�
+ listdt.Add(Encode);
+ listdt.Add(cunm2);
+ mes.code = "200";
+ mes.Message = "鎴愬姛!";
+ mes.data = listdt;
+ break;
+ case "骞�":
+ year = DateTime.Now.Year.ToString().Substring(2, 2);//鑾峰彇骞�(2浣�)
+ fdate = year;
+ digit2 = value.Length;//鑾峰彇string绫诲瀷浣嶆暟
+ value2 = int.Parse(value) + 1;// 灏唖tring绫诲瀷杞寲涓篿nt鑷1
+ digit3 = value2.ToString().Length; //鑾峰彇杞寲鍚巌nt鍨嬬殑浣嶆暟
+ digitdiff = digit2 - digit3; //浣嶆暟涔嬪樊
+ q = "";
+ if (digitdiff < 0) //浣嶆暟宸负璐熸暟闇�瑕佽繘琛ヤ綅
+ {
+ cunm2 = value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ else
+ {
+ for (int i = 1; i <= digitdiff; i++)
+ {
+ q = q + "0";
+ }
+ cunm2 = q + value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ Encode = prefix + fdate + cunm2; //鏈�缁堢紪鐮�
+
+ listdt.Add(Encode);
+ listdt.Add(cunm2);
+ mes.code = "200";
+ mes.Message = "鎴愬姛!";
+ mes.data = listdt;
+
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch (filingdate)
+ {
+ case "骞存湀鏃�":
+ year = DateTime.Now.Year.ToString().Substring(2, 2);//鑾峰彇骞�(2浣�)
+ month = DateTime.Now.Month.ToString().PadLeft(2, '0');//鑾峰彇鏈�(2浣�)
+ day = DateTime.Now.Day.ToString().PadLeft(2, '0');//鑾峰彇鏃�(2浣�)
+ fdate = year + month + day;
+ digit2 = value.Length;//鑾峰彇string绫诲瀷浣嶆暟
+ value2 = int.Parse(value) + 1;// 灏唖tring绫诲瀷杞寲涓篿nt鑷1
+ digit3 = value2.ToString().Length; //鑾峰彇杞寲鍚巌nt鍨嬬殑浣嶆暟
+ digitdiff = digit2 - digit3; //浣嶆暟涔嬪樊
+ q = "";
+ if (digitdiff < 0) //浣嶆暟宸负璐熸暟闇�瑕佽繘琛ヤ綅
+ {
+ cunm2 = value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ else
+ {
+ for (int i = 1; i <= digitdiff; i++)
+ {
+ q = q + "0";
+ }
+ cunm2 = q + value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ Encode = prefix + fdate + cunm2; //鏈�缁堢紪鐮�
+
+ listdt.Add(Encode);
+ listdt.Add(cunm2);
+ mes.code = "200";
+ mes.Message = "鎴愬姛!";
+ mes.data = listdt;
+ break;
+ case "骞存湀":
+ year = DateTime.Now.Year.ToString().Substring(2, 2);//鑾峰彇骞�(2浣�)
+ month = DateTime.Now.Month.ToString().PadLeft(2, '0');//鑾峰彇鏈�(2浣�)
+ fdate = year + month;
+ digit2 = value.Length;//鑾峰彇string绫诲瀷浣嶆暟
+ value2 = int.Parse(value) + 1;// 灏唖tring绫诲瀷杞寲涓篿nt鑷1
+ digit3 = value2.ToString().Length; //鑾峰彇杞寲鍚巌nt鍨嬬殑浣嶆暟
+ digitdiff = digit2 - digit3; //浣嶆暟涔嬪樊
+ q = "";
+ if (digitdiff < 0) //浣嶆暟宸负璐熸暟闇�瑕佽繘琛ヤ綅
+ {
+ cunm2 = value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ else
+ {
+ for (int i = 1; i <= digitdiff; i++)
+ {
+ q = q + "0";
+ }
+ cunm2 = q + value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ Encode = prefix + fdate + cunm2; //鏈�缁堢紪鐮�
+
+
+ listdt.Add(Encode);
+ listdt.Add(cunm2);
+ mes.code = "200";
+ mes.Message = "鎴愬姛!";
+ mes.data = listdt;
+ break;
+ case "骞�":
+ year = DateTime.Now.Year.ToString().Substring(2, 2);//鑾峰彇骞�(2浣�)
+ fdate = year;
+ digit2 = value.Length;//鑾峰彇string绫诲瀷浣嶆暟
+ value2 = int.Parse(value) + 1;// 灏唖tring绫诲瀷杞寲涓篿nt鑷1
+ digit3 = value2.ToString().Length; //鑾峰彇杞寲鍚巌nt鍨嬬殑浣嶆暟
+ digitdiff = digit2 - digit3; //浣嶆暟涔嬪樊
+ q = "";
+ if (digitdiff < 0) //浣嶆暟宸负璐熸暟闇�瑕佽繘琛ヤ綅
+ {
+ cunm2 = value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ else
+ {
+ for (int i = 1; i <= digitdiff; i++)
+ {
+ q = q + "0";
+ }
+ cunm2 = q + value2.ToString();//鏈�缁堟祦姘村彿
+ }
+ Encode = prefix + fdate + cunm2; //鏈�缁堢紪鐮�
+
+ listdt.Add(Encode);
+ listdt.Add(cunm2);
+ mes.code = "200";
+ mes.Message = "鎴愬姛!";
+ mes.data = listdt;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ else
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏈缃紪鐮佽鍒�,鐢熸垚鍗曞彿澶辫触,璇疯缃紪鐮佷负銆�" + rightcode + "銆戠殑缂栫爜瑙勫垯!";
+ mes.data = null;
+ }
+ }
+ catch (Exception e)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = e.Message;
+ mes.data = null;
+ }
+ return mes;
+ }
+ #endregion
+
+ #region[鏇存柊鏉$爜瑙勫垯琛╙
+ /// <summary>
+ /// 鏇存柊鏉$爜瑙勫垯琛�
+ /// </summary>
+ /// <param name="rightcode">鍔熻兘缂栫爜</param>
+ /// <param name="incbit">娴佹按鍙�</param>
+ /// <returns></returns>
+ public static List<object> StrEncodingUpdate(string rightcode, string incbit)
+ {
+ List<object> list = new List<object>();
+ list.Clear();
+ string sql = @"update TCodeRules set value=@cunm2,incbit=@incbit where menucode=@rightcode";
+ list.Add(new { str = sql, parm = new { rightcode = rightcode, cunm2 = Convert.ToInt32(incbit), incbit = incbit.Length } });
+ return list;
+ }
+ #endregion
+ }
+}
diff --git a/VueWebCoreApi/Tools/TJson.cs b/VueWebCoreApi/Tools/TJson.cs
new file mode 100644
index 0000000..1a8a49e
--- /dev/null
+++ b/VueWebCoreApi/Tools/TJson.cs
@@ -0,0 +1,30 @@
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class TJson
+ {
+ public static HttpResponseMessage toJson(Object obj)
+ {
+ String str;
+ if (obj is String || obj is Char)
+ {
+ str = obj.ToString();
+ }
+ else
+ {
+ var timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
+ str = JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
+ }
+ HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json") };
+ return result;
+ }
+ }
+}
diff --git a/VueWebCoreApi/Tools/ToMessage.cs b/VueWebCoreApi/Tools/ToMessage.cs
new file mode 100644
index 0000000..43b0af7
--- /dev/null
+++ b/VueWebCoreApi/Tools/ToMessage.cs
@@ -0,0 +1,24 @@
+锘縰sing Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Tools
+{
+ public class ToMessage
+ {
+ public string code { get; set; }
+ public int count { get; set; }
+ public string Message { get; set; }
+ public object data { get; set; }
+
+ public HttpResponseMessage ResponseMess(ToMessage mes)
+ {
+ HttpResponseMessage result = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(mes), System.Text.Encoding.UTF8) };
+ return result;
+ }
+ }
+}
diff --git a/VueWebCoreApi/VueWebCoreApi.csproj b/VueWebCoreApi/VueWebCoreApi.csproj
new file mode 100644
index 0000000..3527691
--- /dev/null
+++ b/VueWebCoreApi/VueWebCoreApi.csproj
@@ -0,0 +1,60 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+ <PropertyGroup>
+ <TargetFramework>netcoreapp3.1</TargetFramework>
+ <SatelliteResourceLanguages>zh-Hans</SatelliteResourceLanguages>
+ <UserSecretsId>779cd365-c17d-4e17-92df-cf5d66806042</UserSecretsId>
+ <DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+ <OutputPath>bin\</OutputPath>
+ <DocumentationFile>bin\VueWebCoreApi.xml</DocumentationFile>
+ <NoWarn>1701;1702;1591</NoWarn>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+ <OutputPath>bin\</OutputPath>
+ <DocumentationFile>bin\VueWebCoreApi.xml</DocumentationFile>
+ <NoWarn>1701;1702;1591</NoWarn>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Dapper" Version="2.0.143" />
+ <PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
+ <PackageReference Include="JWT" Version="8.0.0" />
+ <PackageReference Include="log4net" Version="2.0.14" />
+ <PackageReference Include="Microsoft.AspNet.SignalR.Core" Version="2.0.1" />
+ <PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.0.0" />
+ <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.0" />
+ <PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.1.21" />
+ <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
+ <PackageReference Include="Microsoft.AspNetCore.Mvc.WebApiCompatShim" Version="2.1.2" />
+ <PackageReference Include="Microsoft.AspNetCore.Session" Version="2.1.1" />
+ <PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.0.0" />
+ <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.0" />
+ <PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="3.0.0" />
+ <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.11.1" />
+ <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.5" />
+ <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
+ <PackageReference Include="NPOI" Version="2.5.6" />
+ <PackageReference Include="Quartz" Version="3.3.3" />
+ <PackageReference Include="ServiceStack.Redis" Version="5.0.0" />
+ <PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
+ <PackageReference Include="System.Data.OleDb" Version="4.6.0" />
+ <PackageReference Include="System.Data.SqlClient" Version="4.5.0" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Folder Include="InExcel\" />
+ <Folder Include="Models\SystemSetting\" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Content Update="Config\log4net.config">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+
+
+</Project>
diff --git a/VueWebCoreApi/appsettings.Development.json b/VueWebCoreApi/appsettings.Development.json
new file mode 100644
index 0000000..8983e0f
--- /dev/null
+++ b/VueWebCoreApi/appsettings.Development.json
@@ -0,0 +1,9 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft": "Warning",
+ "Microsoft.Hosting.Lifetime": "Information"
+ }
+ }
+}
diff --git a/VueWebCoreApi/appsettings.json b/VueWebCoreApi/appsettings.json
new file mode 100644
index 0000000..648b6ca
--- /dev/null
+++ b/VueWebCoreApi/appsettings.json
@@ -0,0 +1,32 @@
+锘縶
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft": "Warning",
+ "Microsoft.Hosting.Lifetime": "Information"
+ }
+ },
+ "AllowedHosts": "*",
+ //鏈嶅姟鍣ㄧ幆澧�
+ "ConnectionStrings": {
+ "DBServer": "Data Source=121.196.36.24,1533;Initial Catalog=newvmes;User ID=sa;Password=xkd@20230101;pooling=false",
+ //浼佷笟缂栫爜
+ "CompanyCode": "000",
+ //浼佷笟鍚嶇О
+ "CompanyName": "鏂板嚡杩鎶�鑲′唤鏈夐檺鍏徃",
+ //redis浼佷笟閰嶇疆
+ "Enterprise": "NewMES",
+ //redis鏁版嵁搴撻摼鎺ラ厤缃甶p
+ "RedisConnIp": "127.0.0.1",
+ //redis鏁版嵁搴撻摼鎺ラ厤缃鍙e彿
+ "RedisConnPort": "6379",
+ //key澶辨晥鏃堕棿30绉�(reids銆乯wt鍏辩敤)
+ "RedisKeyTimeCont": "7200",
+ //session澶辨晥鏃堕棿
+ "InProc": "240",
+ //Excel瀵煎嚭妯℃澘閰嶇疆IP
+ "FileIP": "http://121.196.36.24:8001/",
+ //jwtkey
+ "SigningKey": "Hello World"
+ }
+}
diff --git a/VueWebCoreApi/libman.json b/VueWebCoreApi/libman.json
new file mode 100644
index 0000000..5cb59aa
--- /dev/null
+++ b/VueWebCoreApi/libman.json
@@ -0,0 +1,14 @@
+{
+ "version": "1.0",
+ "defaultProvider": "unpkg",
+ "libraries": [
+ {
+ "library": "@aspnet/signalr@1.0.2",
+ "destination": "lib/aspnet/signalr/",
+ "files": [
+ "dist/browser/signalr.js",
+ "dist/browser/signalr.min.js"
+ ]
+ }
+ ]
+}
\ No newline at end of file
--
Gitblit v1.9.3