From 9c634fd767aec36ef97c3a814bf7a29c67d20ee1 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期五, 29 三月 2024 10:57:35 +0800
Subject: [PATCH] 修改单据重复显示问题,增加工单源单id关联

---
 VueWebApi/DLL/DAL/AppQualityManagementDAL.cs |  179 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 174 insertions(+), 5 deletions(-)

diff --git a/VueWebApi/DLL/DAL/AppQualityManagementDAL.cs b/VueWebApi/DLL/DAL/AppQualityManagementDAL.cs
index dbb3def..c6821f0 100644
--- a/VueWebApi/DLL/DAL/AppQualityManagementDAL.cs
+++ b/VueWebApi/DLL/DAL/AppQualityManagementDAL.cs
@@ -1,10 +1,12 @@
 锘縰sing Dapper;
+using Newtonsoft.Json.Linq;
 using System;
 using System.Collections.Generic;
 using System.Data;
 using System.Data.SqlClient;
 using System.Linq;
 using System.Web;
+using VueWebApi.Models;
 using VueWebApi.Tools;
 
 namespace VueWebApi.DLL.DAL
@@ -39,11 +41,23 @@
                     mes.data = null;
                     return mes;
                 }
+                //鍒ゆ柇鏉$爜鏄惁闇�瑕佹楠�
+                sql = @"select *  from TMateriel_Info where partcode=@partcode and is_incheck='N'";
+                dynamicParams.Add("@partcode", data0.Rows[0]["hmaterialcode"].ToString());
+                var data_0 = DapperHelper.selectdata(sql, dynamicParams);
+                if (data_0.Rows.Count > 0)
+                {
+                    mes.code = "300";
+                    mes.count = 0;
+                    mes.Message = "姝ゆ爣绛炬潯鐮佸厤妫�!";
+                    mes.data = null;
+                    return mes;
+                }
                 //鍒ゆ柇鏉$爜鏄惁妫�楠�
                 sql = @"select *  from TStepCheckRecord where hbarcode=@labcode and check_type='InCheck'";
                 dynamicParams.Add("@labcode", labcode);
                 var data = DapperHelper.selectdata(sql, dynamicParams);
-                if (data0.Rows.Count > 0)
+                if (data.Rows.Count > 0)
                 {
                     mes.code = "300";
                     mes.count = 0;
@@ -57,7 +71,7 @@
                         from T_BarCodeBill A
                         left join TMateriel_Info M on A.hmaterialcode=M.partcode
                         left join TCustomer C on A.hcustomercode=C.code
-                        where A.hbarcode=@labcode";
+                        where A.hbarcode=@labcode and A.hbarcodestatus='Y'";
                 dynamicParams.Add("@labcode", labcode);
                 var data1 = DapperHelper.selectdata(sql, dynamicParams);
                 if (data1.Rows.Count > 0)
@@ -65,7 +79,7 @@
                     //鑾峰彇缁戝畾鐨勫叆鍘傝川妫�鏂规銆佹娊鏍锋柟寮忋�佹牱鏈暟
                     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
+                            where (PATINDEX('%,' + RTRIM(@partcode) + ',%',',' + suitpart + ',')>0 or PATINDEX('%,' + RTRIM(@stocktype_code) + ',%',',' + suitpart + ',')>0)
                             and checktype='InCheck'";
                     dynamicParams.Add("@partcode", data1.Rows[0]["partcode"].ToString());//鐗╂枡缂栫爜
                     dynamicParams.Add("@stocktype_code", data1.Rows[0]["stocktype_code"].ToString());//瀛樿揣绫诲瀷缂栫爜
@@ -80,7 +94,7 @@
                 else
                 {
                     mes.code = "300";
-                    mes.Message = "姝ゆ爣绛炬潯鐮佷笉瀛樺湪!";
+                    mes.Message = "姝ゆ爣绛炬潯鐮佷笉瀛樺湪鎴栧け鏁�!";
                     mes.data = null;
                 }
             }
@@ -118,7 +132,7 @@
                     mes.Message = "鏌ヨ鎴愬姛!";
                     mes.data = data;
                 }
-                else 
+                else
                 {
                     mes.code = "300";
                     mes.count = 0;
@@ -137,5 +151,160 @@
         }
 
         #endregion
+
+        #region[鍏ュ巶妫�楠�,鎻愪氦]
+        public static ToMessage InFactoryCheckSave(string hbillno, string labcode, string checkstandcode, string check_type, string sampmethod, string partcode, string customercode, string batchno, string qualitystatus, string labqty, string sampleqty, string goodqty, string ngqty, string issyncbatch, string checkitemcont, string username)
+        {
+            var sql = "";
+            List<object> list = new List<object>();
+            List<ObjectData> obj = new List<ObjectData>();
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                string datetime = DateTime.Now.ToString(); //鑾峰彇绯荤粺鏃堕棿
+                //鑾峰彇妫�楠岄」鐩俊鎭�
+                JArray arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(checkitemcont);
+                list.Clear();
+                if (issyncbatch == "Y")  //鍚屾鐩稿悓鎵规
+                {
+                    //鏌ユ壘鐩稿悓鎵规鏉$爜(鍔熻兘缂栫爜銆佸崟鎹彿銆佸崟鎹被鍨嬨�佹潯鐮佺被鍨嬨�佺墿鏂欑紪鐮併�佹壒娆″彿銆佹潯鐮佺姸鎬�)
+                    sql = @"select hbarcode,hqty  from T_BarCodeBill
+                            where rightcode=@rightcode and hbillno=@hbillno and hbilltype=@hbilltype and hbarcodetype=@hbarcodetype 
+                            and hmaterialcode=@hmaterialcode and hbatchno=@hbatchno and hbarcodestatus=@hbarcodestatus";
+                    dynamicParams.Add("@rightcode", "2060");
+                    dynamicParams.Add("@hbillno", hbillno);
+                    dynamicParams.Add("@hbilltype", "1103");
+                    dynamicParams.Add("@hbarcodetype", "P");
+                    dynamicParams.Add("@hmaterialcode", partcode);
+                    dynamicParams.Add("@hbatchno", batchno);
+                    dynamicParams.Add("@hbarcodestatus", "Y");
+                    var data = DapperHelper.selectdata(sql, dynamicParams);
+                    if (data.Rows.Count > 0)
+                    {
+                        for (int i = 0; i < data.Rows.Count; i++)
+                        {
+                            ObjectData tbj = new ObjectData();
+                            tbj.code = data.Rows[i]["hbarcode"].ToString();
+                            tbj.name = data.Rows[i]["hqty"].ToString();
+                            obj.Add(tbj);
+                        }
+                    }
+                    else
+                    {
+                        ObjectData tbj = new ObjectData();
+                        tbj.code = labcode;
+                        tbj.name = labqty;
+                        obj.Add(tbj);
+                    }
+                }
+                else
+                {
+                    ObjectData tbj = new ObjectData();
+                    tbj.code = labcode;
+                    tbj.name = labqty;
+                    obj.Add(tbj);
+                }
+
+                //寰幆鏍囩涓暟
+                for (int i = 0; i <obj.Count; i++)
+                {
+                    //鍐欏叆妫�楠岃褰曚富琛�
+                    sql = @"insert into  TStepCheckRecord(hbarcode,wo_code,partcode,checkstaned_code,customer_code,check_user,check_type,check_typename,sampmethod,check_result,check_qty,good_qty,ng_qty,lm_user,lm_date) 
+                                values(@hbarcode,@wo_code,@partcode,@checkstaned_code,@customer_code,@check_user,@check_type,@check_typename,@sampmethod,@check_result,@check_qty,@good_qty,@ng_qty,@lm_user,@lm_date)";
+                    list.Add(new
+                    {
+                        str = sql,
+                        parm = new
+                        {
+                            hbarcode = obj[i].code,
+                            wo_code = hbillno,
+                            partcode = partcode,
+                            checkstaned_code = checkstandcode,
+                            customer_code=customercode,
+                            check_user = username,
+                            check_type = check_type,
+                            check_typename = "鍏ュ巶妫�楠�",
+                            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
+                        }
+                    });
+                    //鑾峰彇涓昏〃鏈�澶D
+                    sql = @"select ISNULL(IDENT_CURRENT('TStepCheckRecord')+@num,1) as id";
+                    dynamicParams.Add("@num", i+1);
+                    var dt = DapperHelper.selectdata(sql, dynamicParams);
+                    //鍐欏叆妫�楠岃褰曞瓙琛�
+                    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) 
+                                values(@m_id,@checknum,@checkiem_seq,@checkitem_code,@checkitem_name,@checkitem_descr,@check_value,@check_result,@lm_user,@lm_date)";
+                        list.Add(new
+                        {
+                            str = sql,
+                            parm = new
+                            {
+                                m_id = int.Parse(dt.Rows[0]["ID"].ToString()),
+                                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
+                            }
+                        });
+                    }
+                }
+                //鍥炲啓鏉$爜妗f琛ㄦ爣绛捐川妫�鐘舵��
+                sql = @"update T_BarCodeBill set qualitystatus=@qualitystatus  where rightcode=@rightcode and hbillno=@hbillno and hbilltype=@hbilltype 
+                        and hbarcodetype=@hbarcodetype  and hmaterialcode=@hmaterialcode and hbatchno=@hbatchno and hbarcodestatus=@hbarcodestatus";
+                list.Add(new
+                {
+                    str = sql,
+                    parm = new
+                    {
+                        qualitystatus= qualitystatus,
+                        rightcode = "2060",
+                        hbillno = hbillno,
+                        hbilltype = "1103",
+                        hbarcodetype = "P",
+                        hmaterialcode = partcode,
+                        hbatchno = batchno,
+                        hbarcodestatus = "Y"
+                    }
+                });
+
+                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