From 14a48ba934fabee90b5d52471ca47883f6007732 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期三, 20 七月 2022 11:40:39 +0800
Subject: [PATCH] Excel  角色清单导入,工序检验扫码

---
 VueWebApi/DLL/DAL/ProductModelDAL.cs |  101 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 79 insertions(+), 22 deletions(-)

diff --git a/VueWebApi/DLL/DAL/ProductModelDAL.cs b/VueWebApi/DLL/DAL/ProductModelDAL.cs
index 3ab2f66..0d6b0f3 100644
--- a/VueWebApi/DLL/DAL/ProductModelDAL.cs
+++ b/VueWebApi/DLL/DAL/ProductModelDAL.cs
@@ -72,9 +72,10 @@
                 }
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
-                var sql = @"select A.id,A.code,A.name,A.dict_code as stockcode,B.name as stockname,A.lm_user,A.lm_date  
+                var sql = @"select A.id,A.code,A.name,A.dict_code as stockcode,B.name as stockname,U.username as lm_user,A.lm_date  
                             from TMateriel_Type A
                             left join T_Dict B on A.dict_code=B.code and B.dict_type='CHLX'
+                            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";
@@ -101,6 +102,17 @@
             {
                 if (operType == "Add")
                 {
+                    var sql0 = @"select *  from TMateriel_Type where code=@materialtypecode";
+                    dynamicParams.Add("@materialtypecode", materialtypecode);
+                    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 TMateriel_Type(dict_code,code,name,lm_user,lm_date) 
                             values(@stocktypecode,@materialtypecode,@materialtypename,@username,@CreateDate)";
                     dynamicParams.Add("@stocktypecode", stocktypecode);
@@ -257,6 +269,17 @@
                 //寰幆鍐欏叆鍗曚綅琛�
                 for (int i = 0; i < json.Count; i++)
                 {
+                    var sql0 = @"select *  from TUom where code=@code";
+                    dynamicParams.Add("@code", json[i].code);
+                    var data = DapperHelper.selectdata(sql0, dynamicParams);
+                    if (data.Rows.Count > 0)
+                    {
+                        mes.code = "300";
+                        mes.count = 0;
+                        mes.Message = "鎿嶄綔澶辫触,缂栫爜閲嶅!";
+                        mes.data = null;
+                        return mes;
+                    }
                     sql = @"insert into TUom(code,name,digdect,r_ule,lm_user,lm_date) values(@code,@name,@digdect,@r_ule,@username,@CreateDate)";
                     list.Add(new
                     {
@@ -441,13 +464,14 @@
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
                 var sql = @"select A.id,A.partcode,A.partname,A.partspec,A.uom_code,B.name as uom_name,D.code as stocktypecode,D.name as stocktypename,
-                            C.code as materialtypecode,C.name as materialtypename,A.stck_code,T.name as stck_name,A.maxqty,A.minqty,A.lm_user,
+                            C.code as materialtypecode,C.name as materialtypename,A.stck_code,T.name as stck_name,A.maxqty,A.minqty,U.username as lm_user,A.default_route,
                             A.lm_date,A.proute_id
                             from TMateriel_Info A
                             left join TUom B on A.uom_code=B.code
                             left join TMateriel_Type C on A.materieltype_code=C.code
                             left join T_Dict D on A.stocktype_code=D.code and D.dict_type='CHLX'
                             left join T_Sec_Stck T on A.stck_code=T.code 
+                            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";
@@ -474,6 +498,17 @@
             {
                 if (operType == "Add")
                 {
+                    var sql0 = @"select *  from TMateriel_Info where partcode=@materialcode";
+                    dynamicParams.Add("@materialcode", materialcode);
+                    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 TMateriel_Info(partcode,partname,partspec,uom_code,stocktype_code,materieltype_code,stck_code,maxqty,minqty,lm_user,lm_date) 
                             values(@materialcode,@materialname,@materialspec,@uomcode,@stocktypecode,@materialtypecode,@warehousecode,@maxstockqty,@minstockqty,@username,@CreateDate)";
                     dynamicParams.Add("@materialcode", materialcode);
@@ -612,7 +647,7 @@
                 //鏈夋病鏈夎宸ュ崟寮曠敤
 
                 //鍒犻櫎鐗╂枡
-                sql = @"update TMateriel_Info set is_delete='1' where partcode=@materialcode";
+                sql = @"delete TMateriel_Info  where partcode=@materialcode";
                 list.Add(new { str = sql, parm = new { materialcode = materialcode } });
                 bool aa = DapperHelper.DoTransaction(list);
                 if (aa)
@@ -691,7 +726,7 @@
         #endregion
 
         #region[瀛樿揣妗f鍏宠仈宸ヨ壓璺嚎鎻愪氦]
-        public static ToMessage SaveInventoryFile(string partcode, string username, List<ObjectData> json)
+        public static ToMessage SaveInventoryFile(string partcode,string defaultroute_code, string username, List<ObjectData> json)
         {
             var sql = "";
             List<object> list = new List<object>();
@@ -704,7 +739,7 @@
                     sql = @"delete TMateriel_Route where materiel_code=@partcode";
                     list.Add(new { str = sql, parm = new { partcode = partcode } });
                     //鏍囪鐗╂枡琛ㄥ叧鑱斿伐鑹鸿矾绾挎爣璇�
-                    sql = @"update TMateriel_Info set proute_id='N' where partcode=@partcode";
+                    sql = @"update TMateriel_Info set proute_id='N',default_route='' where partcode=@partcode";
                     list.Add(new { str = sql, parm = new { partcode = partcode } });
                 }
                 else
@@ -729,8 +764,8 @@
                         });
                     }
                     //鏍囪鐗╂枡琛ㄥ叧鑱斿伐鑹鸿矾绾挎爣璇�
-                    sql = @"update TMateriel_Info set proute_id='Y' where partcode=@partcode";
-                    list.Add(new { str = sql, parm = new { partcode = partcode } });
+                    sql = @"update TMateriel_Info set proute_id='Y',default_route=@defaultroute_code where partcode=@partcode";
+                    list.Add(new { str = sql, parm = new { partcode = partcode, defaultroute_code= defaultroute_code } });
                 }
                 bool aa = DapperHelper.DoTransaction(list);
                 if (aa)
@@ -770,22 +805,22 @@
             {
                 if (routecode != "" && routecode != null)
                 {
-                    search += "and code like '%'+@partcode+'%' ";
+                    search += "and A.code like '%'+@partcode+'%' ";
                     dynamicParams.Add("@routecode", routecode);
                 }
                 if (routename != "" && routename != null)
                 {
-                    search += "and name like '%'+@routename+'%' ";
+                    search += "and A.name like '%'+@routename+'%' ";
                     dynamicParams.Add("@routename", routename);
                 }
                 if (description != "" && description != null)
                 {
-                    search += "and description=@description ";
+                    search += "and A.description=@description ";
                     dynamicParams.Add("@description", description);
                 }
                 if (createuser != "" && createuser != null)
                 {
-                    search += "and lm_user=@createuser ";
+                    search += "and U.username=@createuser ";
                     dynamicParams.Add("@createuser", createuser);
                 }
                 if (search == "")
@@ -794,9 +829,9 @@
                 }
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
-                var sql = @"select id,code,name,description,enable,lm_user,lm_date  
-                            from TFlw_Rout
-                            where is_delete<>'1' " + search;
+                var sql = @"select A.id,A.code,A.name,A.description,A.enable,U.username as lm_user,A.lm_date  from TFlw_Rout 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 = "鏌ヨ鎴愬姛!";
@@ -871,6 +906,17 @@
             {
                 if (opertype == "Add")
                 {
+                    var sql0 = @"select *  from TFlw_Rout where code=@code";
+                    dynamicParams.Add("@code", json.code);
+                    var data = DapperHelper.selectdata(sql0, dynamicParams);
+                    if (data.Rows.Count > 0)
+                    {
+                        mes.code = "300";
+                        mes.count = 0;
+                        mes.Message = "鎿嶄綔澶辫触,缂栫爜閲嶅!";
+                        mes.data = null;
+                        return mes;
+                    }
                     //鏂板宸ヨ壓璺嚎琛�
                     sql = @"insert into TFlw_Rout(code,name,description,enable,lm_user,lm_date) values(@code,@name,@description,@enable,@lm_user,@lm_date)";
                     list.Add(new { str = sql, parm = new { code = json.code, name = json.name, description = json.description, enable = json.enable, lm_user = username, lm_date = DateTime.Now.ToString() } });
@@ -1026,27 +1072,27 @@
             {
                 if (stepcode != "" && stepcode != null)
                 {
-                    search += "and stepcode like '%'+@stepcode+'%' ";
+                    search += "and A.stepcode like '%'+@stepcode+'%' ";
                     dynamicParams.Add("@stepcode", stepcode);
                 }
                 if (stepname != "" && stepname != null)
                 {
-                    search += "and stepname like '%'+@stepname+'%' ";
+                    search += "and A.stepname like '%'+@stepname+'%' ";
                     dynamicParams.Add("@stepname", stepname);
                 }
                 if (enable != "" && enable != null)
                 {
-                    search += "and enable=@enable ";
+                    search += "and A.enable=@enable ";
                     dynamicParams.Add("@enable", enable);
                 }
                 if (steptypecode != "" && steptypecode != null)
                 {
-                    search += "and flwtype=@steptypecode ";
+                    search += "and A.flwtype=@steptypecode ";
                     dynamicParams.Add("@steptypecode", steptypecode);
                 }
                 if (createuser != "" && createuser != null)
                 {
-                    search += "and lm_user=@createuser ";
+                    search += "and U.username=@createuser ";
                     dynamicParams.Add("@createuser", createuser);
                 }
                 if (search == "")
@@ -1055,9 +1101,9 @@
                 }
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
-                var sql = @"select id,stepcode,stepname,flwtype,enable,descr,lm_user,lm_date,is_eqp,is_defect  
-                            from TStep
-                            where is_delete<>'1' " + search;
+                var sql = @"select A.id,A.stepcode,A.stepname,A.flwtype,A.enable,A.descr,U.username as lm_user,A.lm_date,A.is_eqp,A.is_defect  from TStep 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 = "鏌ヨ鎴愬姛!";
@@ -1083,6 +1129,17 @@
             {
                 if (operType == "Add")
                 {
+                    var sql0 = @"select *  from TStep where stepcode=@stepcode";
+                    dynamicParams.Add("@stepcode", stepcode);
+                    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 TStep(stepcode,stepname,flwtype,enable,descr,lm_user,lm_date) 
                             values(@stepcode,@stepname,@steptypecode,@enable,@description,@username,@CreateDate)";
                     dynamicParams.Add("@stepcode", stepcode);

--
Gitblit v1.9.3