From 2cc036e7b5ca7ba242b1296d946f8d563f3cf4c2 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期日, 16 十月 2022 01:34:22 +0800
Subject: [PATCH] 产能规划提交报错

---
 VueWebApi/DLL/DAL/AppDeviceManageDAL.cs |  456 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 445 insertions(+), 11 deletions(-)

diff --git a/VueWebApi/DLL/DAL/AppDeviceManageDAL.cs b/VueWebApi/DLL/DAL/AppDeviceManageDAL.cs
index 9af4163..12d211a 100644
--- a/VueWebApi/DLL/DAL/AppDeviceManageDAL.cs
+++ b/VueWebApi/DLL/DAL/AppDeviceManageDAL.cs
@@ -466,13 +466,13 @@
                     for (int i = 0; i < files.Count; i++)
                     {
                         HttpPostedFile file = files[i];
-                        string imgName = DateTime.Now.ToString("yyyyMMddhhmmss");
-                        string imgPath = "/DeviceImage/image1/" + file.FileName;     //閫氳繃姝ゅ璞¤幏鍙栨枃浠跺悕
+                        string imgName = DateTime.Now.ToString("yyyyMMddhhmmss") + i.ToString();
+                        string imgPath = "/DeviceImage/image1/" + imgName + file.FileName;     //閫氳繃姝ゅ璞¤幏鍙栨枃浠跺悕
                         string AbsolutePath = System.Web.HttpContext.Current.Server.MapPath(imgPath);
                         file.SaveAs(AbsolutePath); //灏嗕笂浼犵殑涓滆タ淇濆瓨
                         //寰幆鍐欑淮淇褰曞搴斿浘鐗囪〃
-                        sql = @"insert into  TEqp_RepairImage(source_wo,wo_type,img1_url) 
-                                values(@source_wo,@wo_type,@img1_url)";
+                        sql = @"insert into  TEqp_RepairImage(source_wo,wo_type,img1url) 
+                                values(@source_wo,@wo_type,@img1url)";
                         list.Add(new
                         {
                             str = sql,
@@ -480,13 +480,13 @@
                             {
                                 source_wo = wxwo,
                                 wo_type = "REPA",
-                                img1_url = imgPath
+                                img1url = imgPath
                             }
                         });
                     }
                 }
 
-                //鍐欏叆缁翠慨璁板綍琛�
+                //鍐欏叆缁翠慨鐢宠璁板綍琛�
                 sql = @"insert into  TEqp_RepairRequest(docu_code,docu_date,status,wksp_code,eqp_code,request_person,request_date,failure_descript,source) 
                                 values(@docu_code,@docu_date,@status,@wksp_code,@eqp_code,@request_person,@request_date,@failure_descript,@source)";
                 list.Add(new
@@ -501,10 +501,14 @@
                         eqp_code = eqpcode,
                         request_person = username,
                         request_date = DateTime.Now.ToString(),
-                        failure_descript= faultdescr,
-                        source=faultsourcecode
+                        failure_descript = faultdescr,
+                        source = faultsourcecode
                     }
                 });
+                //鍥炲啓瀛楀吀琛�,鏇存柊褰撳墠娴佹按鍙�
+                sql = @"update T_CodeRules set value=@cunm2  where rightcode=@RightCode";
+                list.Add(new { str = sql, parm = new { cunm2 = numvalue, RightCode = "2042" } });
+
                 bool aa = DapperHelper.DoTransaction(list);
                 if (aa)
                 {
@@ -532,6 +536,329 @@
         }
         #endregion
 
+
+        #region[璁惧缁翠慨鍒楄〃]
+        public static ToMessage RepairScanDeviceQrCodeDataList()
+        {
+            string sql = "";
+            try
+            {
+                //鑾峰彇璁惧缁翠慨鍒楄〃宸茬敵璇锋湭缁翠慨鐨勬暟鎹�
+                sql = @"select A.docu_code,B.code as eqpcode,B.name as eqpname,
+                        T.org_code as wksp_code,T.org_name as wksp_name,
+                        A.request_person,A.request_date,
+                        (case when A.source='A' then '鐐规' when A.source='B' then '淇濆吇' when A.source='C' then '瀹夌伅' when A.source='D' then '鎵嬪伐' end) as source,
+                        A.failure_descript   
+                        from TEqp_RepairRequest A
+                        inner  join TEqpInfo B on A.eqp_code=B.code
+                        inner  join TOrganization T on A.wksp_code=T.org_code
+                        where T.description='W'and A.status='REPA'";
+                var data = DapperHelper.selecttable(sql);
+                if (data.Rows.Count > 0)
+                {
+                    mes.code = "200";
+                    mes.Message = "鏌ヨ鎴愬姛!";
+                    mes.data = data;
+                }
+                else
+                {
+                    mes.code = "300";
+                    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 RepairScanDeviceSave(string docu_code, string username, string eqpcode, string wkshpcode, string faultdescr, string is_stoprepair, string repaircontent, string replaceparts, HttpFileCollection files)
+        {
+            var sql = "";
+            string wxwo = "", numvalue = "";
+            List<object> list = new List<object>();
+            try
+            {
+                list.Clear();
+                mes = SeachEncode.EncodingSeach("2043");  //鐢熸垚鍗曞彿
+                if (mes.code == "300")
+                {
+                    mes.Message = "鐢熸垚鍗曞彿澶辫触,璇疯缃紪鐮佷负銆�2043銆戠殑缂栫爜瑙勫垯";
+                    return mes;
+                }
+                else
+                {
+                    List<string> wo = (List<string>)mes.data;
+                    wxwo = wo[0].ToString(); //鑾峰彇鍗曞彿
+                    numvalue = wo[1].ToString(); //鑾峰彇娴佹按鍙�
+                }
+                //楠岃瘉涓婁紶鍥剧墖
+                if (files != null && files.Count > 0)
+                {
+                    for (int i = 0; i < files.Count; i++)
+                    {
+                        string imgPath1 = "", imgPath2 = "", AbsolutePath = "";
+                        HttpPostedFile file = files[i];
+                        string imgName = DateTime.Now.ToString("yyyyMMddhhmmss") + i.ToString();
+                        string keyname = files.AllKeys[i].ToString();
+                        if (keyname == "files1")
+                        {
+                            imgPath1 = "/DeviceImage/image1/" + imgName + file.FileName;     //閫氳繃姝ゅ璞¤幏鍙栨枃浠跺悕
+                            AbsolutePath = System.Web.HttpContext.Current.Server.MapPath(imgPath1);
+                        }
+                        if (keyname == "files2")
+                        {
+                            imgPath2 = "/DeviceImage/image2/" + imgName + file.FileName;     //閫氳繃姝ゅ璞¤幏鍙栨枃浠跺悕
+                            AbsolutePath = System.Web.HttpContext.Current.Server.MapPath(imgPath2);
+                        }
+
+                        file.SaveAs(AbsolutePath); //灏嗕笂浼犵殑涓滆タ淇濆瓨
+                                                   //寰幆鍐欑淮淇褰曞搴斿浘鐗囪〃
+                        sql = @"insert into  TEqp_RepairImage(source_wo,wo_type,img1url,img2url) 
+                                values(@source_wo,@wo_type,@img1url,@img2url)";
+                        list.Add(new
+                        {
+                            str = sql,
+                            parm = new
+                            {
+                                source_wo = wxwo,
+                                wo_type = "COMP",
+                                img1url = imgPath1,
+                                img2url = imgPath2
+                            }
+                        });
+                    }
+                }
+                //鍐欏叆缁翠慨璁板綍琛�
+                sql = @"insert into  TEqp_Repair(repair_code,docu_date,status,wksp_code,eqp_code,repair_person,repair_date,repair_content,repair_part,failure_descript,is_shutdown,source_wo) 
+                                values(@repair_code,@docu_date,@status,@wksp_code,@eqp_code,@repair_person,@repair_date,@repair_content,@repair_part,@failure_descript,@is_shutdown,@source_wo)";
+                list.Add(new
+                {
+                    str = sql,
+                    parm = new
+                    {
+                        repair_code = wxwo,
+                        docu_date = DateTime.Now.ToString(),
+                        status = "COMP",
+                        wksp_code = wkshpcode,
+                        eqp_code = eqpcode,
+                        repair_person = username,
+                        repair_date = DateTime.Now.ToString(),
+                        repair_content = repaircontent,
+                        repair_part = replaceparts,
+                        failure_descript = faultdescr,
+                        is_shutdown = is_stoprepair,
+                        source_wo= docu_code
+                    }
+                });
+                //鏇存柊缁翠慨鐢宠鍗曠姸鎬�
+                sql = @"update TEqp_RepairRequest set status=@status  where docu_code=@docu_code and wksp_code=@wkshpcode  and eqp_code=@eqpcode";
+                list.Add(new { str = sql, parm = new { docu_code = docu_code, wkshpcode = wkshpcode, eqpcode= eqpcode, status= "COMP" } });
+
+                //鍥炲啓瀛楀吀琛�,鏇存柊褰撳墠娴佹按鍙�
+                sql = @"update T_CodeRules set value=@cunm2  where rightcode=@RightCode";
+                list.Add(new { str = sql, parm = new { cunm2 = numvalue, RightCode = "2043" } });
+
+                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 RepairVerificationScanDeviceData()
+        {
+            string sql = "";
+            try
+            {
+                //鑾峰彇璁惧缁翠慨鍒楄〃宸茬淮淇殑鏁版嵁
+                sql = @"select A.repair_code,B.code as eqpcode,B.name as eqpname,
+                        T.org_code as wksp_code,T.org_name as wksp_name,
+                        A.repair_person,A.repair_date,A.is_shutdown,
+                        A.failure_descript   
+                        from TEqp_Repair A
+                        inner  join TEqpInfo B on A.eqp_code=B.code
+                        inner  join TOrganization T on A.wksp_code=T.org_code
+                        where T.description='W'and A.status='COMP'";
+                var data = DapperHelper.selecttable(sql);
+                if (data.Rows.Count > 0)
+                {
+                    mes.code = "200";
+                    mes.Message = "鏌ヨ鎴愬姛!";
+                    mes.data = data;
+                }
+                else
+                {
+                    mes.code = "300";
+                    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 RepairVerificationScanDeviceDataSub(string repair_code,string eqpcode, string wkshpcode)
+        {
+            string sql = "";
+            var dynamicParams = new DynamicParameters();
+            Dictionary<string, object> dict = new Dictionary<string, object>();
+            try
+            {
+                //鏍规嵁璁惧缂栫爜\杞﹂棿缂栫爜鑾峰彇缁翠慨璇︽儏
+                sql = @"select repair_code,failure_descript,is_shutdown,repair_content,repair_part   
+                        from TEqp_Repair 
+                        where repair_code=@repair_code and wksp_code=@wkshpcode and eqp_code=@eqpcode";
+                dynamicParams.Add("@repair_code", repair_code);
+                dynamicParams.Add("@wkshpcode", wkshpcode);
+                dynamicParams.Add("@eqpcode", eqpcode);
+                var data = DapperHelper.selectdata(sql, dynamicParams);
+                if (data.Rows.Count > 0)
+                {
+                    dict.Add("failure_descript", data.Rows[0]["failure_descript"].ToString()); //鏁呴殰鎻忚堪
+
+                    //鑾峰彇鏁呴殰涓婁紶鍥剧墖
+                    sql = @"select img1url  from TEqp_RepairImage where source_wo=@source_wo and wo_type='COMP'";
+                    dynamicParams.Add("@source_wo", data.Rows[0]["repair_code"].ToString());
+                    var data0 = DapperHelper.selectdata(sql, dynamicParams);
+                    if (data0.Rows.Count > 0)
+                    {
+                        dict.Add("failure_descriptimg", data0); //鏁呴殰涓婁紶鍥剧墖
+                    }
+                    if (data.Rows[0]["is_shutdown"].ToString() == "N")   //鏄惁鍋滄満缁翠慨
+                    {
+                        dict.Add("repair_content", data.Rows[0]["repair_content"].ToString()); //缁翠慨鍐呭
+                        dict.Add("repair_part", data.Rows[0]["repair_part"].ToString()); //鏇存崲澶囦欢
+
+                        //鑾峰彇鏇存崲澶囦欢涓婁紶鍥剧墖
+                        sql = @"select img2url  from TEqp_RepairImage where source_wo=@source_wo and wo_type='COMP'";
+                        dynamicParams.Add("@source_wo", data.Rows[0]["repair_code"].ToString());
+                        var data1 = DapperHelper.selectdata(sql, dynamicParams);
+                        if (data1.Rows.Count > 0)
+                        {
+                            dict.Add("repair_partimage", data1); //鏁呴殰涓婁紶鍥剧墖
+                        }
+                    }
+                    mes.code = "200";
+                    mes.Message = "鏌ヨ鎴愬姛!";
+                    mes.data = dict;
+                }
+                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
+
+        #region[缁翠慨楠岃瘉鎻愪氦]
+        public static ToMessage RepairVerificationScanDeviceSave(string username, string repairwo, string eqpcode, string wkshpcode, string result)
+        {
+            var sql = "";
+            List<object> list = new List<object>();
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                list.Clear();
+                //鏍规嵁璁惧缁翠慨鍗曟煡鎵炬簮鍗�(缁翠慨鐢宠鍗�)
+                sql = @"select source_wo   from TEqp_Repair where repair_code=@repairwo";
+                dynamicParams.Add("@repairwo", repairwo);
+                var data = DapperHelper.selectdata(sql, dynamicParams);
+                //鏇存柊璁惧缁翠慨璁板綍楠岃瘉浜哄憳銆侀獙璇佹椂闂淬�侀獙璇佺粨鏋溿�侀獙璇佺姸鎬�
+                sql = @"update TEqp_Repair set status=@status,is_verifi=@is_verifi,verify_result=@verify_result,verify_person=@verify_person,verify_date=@verify_date  
+                        where repair_code=@repair_code and wksp_code=@wksp_code and eqp_code=@eqp_code";
+                list.Add(new
+                {
+                    str = sql,
+                    parm = new
+                    {
+                        status = "CONFIR",
+                        is_verifi = "Y",
+                        verify_result = result,
+                        verify_person = username,
+                        verify_date = DateTime.Now.ToString(),
+                        repair_code = repairwo,
+                        wksp_code = wkshpcode,
+                        eqp_code = eqpcode
+                    }
+                });
+                //鏇存柊缁翠慨鐢宠鍗曠姸鎬�
+                sql = @"update TEqp_RepairRequest set status=@status  where docu_code=@docu_code and wksp_code=@wkshpcode  and eqp_code=@eqpcode";
+                list.Add(new { str = sql, parm = new { docu_code = data.Rows[0]["source_wo"].ToString(), wkshpcode = wkshpcode, eqpcode = eqpcode, status = "CONFIR" } });
+
+                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
 
 
 
@@ -583,10 +910,14 @@
             try
             {
                 //鏍规嵁杞﹂棿浠g爜鏌ユ壘鍛煎彨绫诲瀷鏁版嵁
-                sql = @"select A.id,B.code,B.name  from TAnDon_Roul_ConFig A
+                sql = @"select A.id,B.code,B.name,(case when F.type is null then 'N' else 'Y' end) flag  
+                        from TAnDon_Roul_ConFig A
                         inner join TAnDonType B on A.andotype_code=B.code
-                        where A.wkshp_code=@wkshpcode and A.enable='N'";
+                        inner  join TEqpInfo E on A.wkshp_code=e.wksp_code
+                        left join(select type,wkshp_code,eqp_code  from TAnDon_Task_Info where eqp_code=@eqpcode and wkshp_code=@wkshpcode and status='START') F on A.wkshp_code=F.wkshp_code and E.code=F.eqp_code
+                        where A.wkshp_code=@wkshpcode and E.code=@eqpcode and A.enable='N'";
                 dynamicParams.Add("@wkshpcode", wkshpcode);
+                dynamicParams.Add("@eqpcode", eqpcode);
                 var data = DapperHelper.selectdata(sql, dynamicParams);
                 if (data.Rows.Count > 0)
                 {
@@ -595,6 +926,7 @@
                         AnDnDate mn = new AnDnDate();
                         mn.code = data.Rows[i]["CODE"].ToString();
                         mn.name = data.Rows[i]["NAME"].ToString();
+                        mn.flag = data.Rows[i]["FLAG"].ToString();
                         mn.children = new List<AnDnDateSub>();
                         //鏍规嵁鍛煎彨绫诲瀷id鏌ユ壘缁戝畾浜哄憳
                         sql = @"select U.usercode,U.username   
@@ -691,7 +1023,7 @@
                         {
                             //鍐欏叆瀹夌伅璁板綍鎺ㄩ�佷汉鍛樿〃
                             sql = @"insert into TAnDnMessagePush(m_id,wkshp_code,eqp_code,type,resp_user,status) 
-                                    values(@m_id,@wkshp_code,@eqp_code,@type,@start_date,@start_user,@status)";
+                                    values(@m_id,@wkshp_code,@eqp_code,@type,@resp_user,@status)";
                             list.Add(new
                             {
                                 str = sql,
@@ -737,5 +1069,107 @@
         #endregion
 
 
+
+        #region[瀹夌伅鍝嶅簲鎵弿宸ヤ綅/璁惧]
+        public static ToMessage AppDeviceAnDengLampResponseScanSearch(string eqpcode)
+        {
+            string sql = "";
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                //鑾峰彇瀵瑰簲璁惧鍙婃墍灞炶溅闂寸殑瀹夌伅鍛煎彨璁板綍
+                sql = @"select A.eqp_code,B.name as eqp_name,T.org_name,A.type as typecode,D.name as typename   
+                        from TAnDon_Task_Info A
+                        left join  TEqpInfo B on A.eqp_code=B.code
+                        left join  TOrganization T on B.wksp_code=T.org_code
+                        left join  TAnDonType D on A.type=D.code
+                        where A.eqp_code=@eqpcode and A.status='START' and B.enable='Y' and T.description='W' ";
+                dynamicParams.Add("@eqpcode", eqpcode);
+                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 = data;
+                }
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.Message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
+        #region[瀹夌伅鍝嶅簲鎻愪氦]
+        public static ToMessage AppDeviceAnDengLampResponseSave(string username, string eqpcode, string wkshpcode, List<ObjectData> json)
+        {
+            string sql = "";
+            var dynamicParams = new DynamicParameters();
+            List<object> list = new List<object>();
+            ChatHub chthub = new ChatHub();
+            try
+            {
+                list.Clear();
+                for (int i = 1; i <= json.Count; i++)
+                {
+                    string code = json[i].code.ToString();
+                    string name = json[i].name.ToString();
+                    //鏇存柊瀹夌伅鍛煎彨琛�
+                    sql = @"update TAnDon_Task_Info set resp_user=@resp_user,resp_date=@resp_date,status='CLOSED',taking=cast ( cast ( datediff ( ss, start_date, @resp_date) / ( 60 * 60 * 24 ) as int ) as varchar ) + '澶�' + 
+                            cast ( cast ( datediff ( ss, start_date, @resp_date ) % 86400 / 3600 as int ) as varchar ) + '灏忔椂' + 
+	                        cast ( cast ( datediff ( ss, start_date, @resp_date ) % 3600 / 60 as int ) as varchar ) + '鍒�' + 
+	                        cast ( cast ( datediff ( ss, start_date, @resp_date ) % 60 as int ) as varchar ) + '绉�'
+                            where wkshp_code=@wkshp_code and eqp_code=@eqp_code and type=@type and status='START'";
+                    list.Add(new
+                    {
+                        str = sql,
+                        parm = new
+                        {
+                            wkshp_code = wkshpcode,
+                            eqp_code = eqpcode,
+                            type = code,
+                            resp_date = DateTime.Now.ToString(),
+                            resp_user = username,
+                            status = "START"
+                        }
+                    });
+                }
+                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
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3