Przeglądaj źródła

组件条码 like 查询

chenxy 2 lat temu
rodzic
commit
04af9dee6c

+ 53 - 34
wwwroot/mes/pc/materielquery/rpt.ashx

@@ -25,7 +25,7 @@ public class rpt : IHttpHandler, IReadOnlySessionState
             if (m == "master" || m == "property")
             {
                 string barcode = context.Request["barcode"];
-                if(!string.IsNullOrEmpty(context.Request["barcodeDB"] +""))
+                if (!string.IsNullOrEmpty(context.Request["barcodeDB"] + ""))
                 {
                     barcode = context.Request["barcodeDB"];
                 }
@@ -130,7 +130,8 @@ public class rpt : IHttpHandler, IReadOnlySessionState
             if (m == "goods")
             {
                 string workshop = context.Request["workshop[]"] is object ? context.Request["workshop[]"].ToString() : "";//车间
-                if (workshop == "" && (context.Request["workshop"] is object)) workshop = context.Request["workshop"].ToString();
+                if (workshop == "" && (context.Request["workshop"] is object))
+                    workshop = context.Request["workshop"].ToString();
 
                 string datebeginMasterS = context.Request["datebeginMasterS"];
                 string datebeginMasterD = context.Request["datebeginMasterD"];
@@ -177,30 +178,34 @@ public class rpt : IHttpHandler, IReadOnlySessionState
                                           where gdd.valueflag = '1'
                                AND gdd.groutingflag = '1'
                                AND gdd.barcode IS NOT NULL 
-                                        AND (INSTR(GT.GOODSTYPECODE,'{GOODSTYPECODE}') = 1 OR '{GOODSTYPECODE}' IS NULL) ".Replace("{GOODSTYPECODE}", goodstypecode);
-                if (!string.IsNullOrEmpty(datebeginMasterS))
-                {
-                    sqlStr += " and t.fhtime >=@datebeginMasterS@ ";
-                    sqlPara.Add(new CDAParameter("datebeginMasterS", datebeginMasterS, DataType.Date));
-                }
-                if (!string.IsNullOrEmpty(datebeginMasterD))
-                {
-                    sqlStr += " and t.fhtime <@datebeginMasterD@ ";
-                    sqlPara.Add(new CDAParameter("datebeginMasterD", Convert.ToDateTime(datebeginMasterD).AddSeconds(1), DataType.Date));
-                }
-                if (!string.IsNullOrEmpty(datebeginMasterG))
-                {
-                    sqlStr += " and gdd.groutingdate >=@datebeginMasterG@ ";
-                    sqlPara.Add(new CDAParameter("datebeginMasterG", datebeginMasterG, DataType.Date));
-                }
-                if (!string.IsNullOrEmpty(dateendMasterG))
-                {
-                    sqlStr += " and gdd.groutingdate <@dateendMasterG@ ";
-                    sqlPara.Add(new CDAParameter("dateendMasterG", Convert.ToDateTime(dateendMasterG).AddDays(1), DataType.Date));
-                }
-                if (!string.IsNullOrEmpty(workshop))
+                                        AND ('{GOODSTYPECODE}' IS NULL or INSTR(GT.GOODSTYPECODE,'{GOODSTYPECODE}') = 1) ".Replace("{GOODSTYPECODE}", goodstypecode);
+
+                if (string.IsNullOrEmpty(barcode) && string.IsNullOrEmpty(IDNRKONLYCODE))
                 {
-                    sqlStr += " AND gl.workshop in (" + workshop + ")";
+                    if (!string.IsNullOrEmpty(datebeginMasterS))
+                    {
+                        sqlStr += " and t.fhtime >=@datebeginMasterS@ ";
+                        sqlPara.Add(new CDAParameter("datebeginMasterS", datebeginMasterS, DataType.Date));
+                    }
+                    if (!string.IsNullOrEmpty(datebeginMasterD))
+                    {
+                        sqlStr += " and t.fhtime <@datebeginMasterD@ ";
+                        sqlPara.Add(new CDAParameter("datebeginMasterD", Convert.ToDateTime(datebeginMasterD).AddSeconds(1), DataType.Date));
+                    }
+                    if (!string.IsNullOrEmpty(datebeginMasterG))
+                    {
+                        sqlStr += " and gdd.groutingdate >=@datebeginMasterG@ ";
+                        sqlPara.Add(new CDAParameter("datebeginMasterG", datebeginMasterG, DataType.Date));
+                    }
+                    if (!string.IsNullOrEmpty(dateendMasterG))
+                    {
+                        sqlStr += " and gdd.groutingdate <@dateendMasterG@ ";
+                        sqlPara.Add(new CDAParameter("dateendMasterG", Convert.ToDateTime(dateendMasterG).AddDays(1), DataType.Date));
+                    }
+                    if (!string.IsNullOrEmpty(workshop))
+                    {
+                        sqlStr += " AND gl.workshop in (" + workshop + ")";
+                    }
                 }
                 if (!string.IsNullOrEmpty(barcode))
                 {
@@ -209,11 +214,13 @@ public class rpt : IHttpHandler, IReadOnlySessionState
 
                 if (!string.IsNullOrEmpty(IDNRKONLYCODE))
                 {
-                    sqlStr += " AND exists (select 1 from TP_PM_BARCODEIDNRKREL bb where bb.IDNRKONLYCODE = @IDNRKONLYCODE@ and bb.barcode = gdd.barcode )";
+                    //sqlStr += " AND exists (select 1 from TP_PM_BARCODEIDNRKREL bb where bb.IDNRKONLYCODE = @IDNRKONLYCODE@ and bb.barcode = gdd.barcode )";
+                    sqlStr += " AND exists (select 1 from TP_PM_BARCODEIDNRKREL bb where bb.IDNRKONLYCODE like @IDNRKONLYCODE@ || '%' and bb.barcode = gdd.barcode )";
+
                     sqlPara.Add(new CDAParameter("IDNRKONLYCODE", IDNRKONLYCODE));
                 }
 
-                    sqlStr += " order by gdd.groutingdate desc, t.fhtime desc, gdd.barcode ";
+                sqlStr += " order by gdd.groutingdate desc, t.fhtime desc, gdd.barcode ";
                 try
                 {
                     JsonResult data = Easyui.ExecuteJsonResult(conn, sqlStr, sqlPara);
@@ -232,11 +239,13 @@ public class rpt : IHttpHandler, IReadOnlySessionState
             if (m == "materiel")
             {
                 string barcode = context.Request["barcode"];
-                if(!string.IsNullOrEmpty(context.Request["barcodeDB"] +""))
+                if (!string.IsNullOrEmpty(context.Request["barcodeDB"] + ""))
                 {
                     barcode = context.Request["barcodeDB"];
                 }
-                DataTable dt = conn.ExecuteDatatable(@"
+                string IDNRKONLYCODE = context.Request["IDNRKONLYCODE"];
+
+                string sql = @"
                    SELECT
 	                    b.MATNR AS 物料,
 	                    m.POSNR AS 项目,
@@ -255,11 +264,21 @@ public class rpt : IHttpHandler, IReadOnlySessionState
                          LEFT JOIN TP_PM_BARCODEIDNRKREL bb on bb.barcode = gdd.barcode and m.IDNRK = bb.IDNRK
                     WHERE
 	                    m.VALUEFLAG = '1' 
-                        AND b.VALUEFLAG = '1' 
-	                    AND (gdd.BARCODE = @BARCODE@ or gdd.OUTLABELCODE = @BARCODE@ )
-                    ",
-                    new CDAParameter("BARCODE",barcode)
-                );
+                        AND b.VALUEFLAG = '1'";
+
+                List<CDAParameter> sps = new List<CDAParameter>();
+                if (!string.IsNullOrWhiteSpace(barcode))
+                {
+                    sql += " and gdd.BARCODE = @BARCODE@";
+                    sps.Add(new CDAParameter("BARCODE", barcode));
+                }
+                if (!string.IsNullOrWhiteSpace(IDNRKONLYCODE))
+                {
+                    sql += " and  bb.IDNRKONLYCODE like @IDNRKONLYCODE@ || '%'";
+                    sps.Add(new CDAParameter("IDNRKONLYCODE", IDNRKONLYCODE));
+                }
+
+                DataTable dt = conn.ExecuteDatatable(sql, sps.ToArray());
                 jsonStr = new JsonResult(dt).ToJson();
             }
             //===============================================

+ 23 - 7
wwwroot/mes/pc/materielquery/rpt_index.html

@@ -40,13 +40,13 @@
                                data:[{'text': '1车间', 'value': '1'},{'text': '2车间', 'value': '2'},{'text': '3车间', 'value': '3'}]"
                                style=" width: 160px; height: 32px;">产品类型:
                         <input class="easyui-combotree" id="goodstypecode" name="goodstypecode" data-options="required:false,prompt:'',tipPosition:'top',url:'../../list.ashx?m=getGoodsType',method:'get',panelHeight:'200px',editable:true" style="width: 160px; height: 32px;"></span>
-                        产品条码/外箱码<input class="easyui-textbox" id="barcode" name="barcode" data-options="required:false,prompt:'',tipPosition:'top',required:false" style="width: 120px; height: 32px;"></span>
-                        组件条码<input class="easyui-textbox" id="IDNRKONLYCODE" name="IDNRKONLYCODE" data-options="required:false,prompt:'',tipPosition:'top',required:false" style="width: 120px; height: 32px;"></span>
 
-                        <a href="javascript:void(0)" id="btnSearchSubmit" title="清空" class="easyui-linkbutton" plain="false" onclick="$('#ffMaster').form('clear')">清空</a>
-                        <a href="javascript:void(0)" id="btnSearchSubmit" title="搜索" class="easyui-linkbutton" plain="false" onclick="tbSearchSubmit()">搜索</a>
-                    </div>
-                </form>
+                            产品条码/外箱码:<input class="easyui-textbox" id="barcode" name="barcode" data-options="required:false,prompt:'',tipPosition:'top',required:false" style="width: 120px; height: 32px;"></span>
+                            组件条码:<input class="easyui-textbox" id="IDNRKONLYCODE" name="IDNRKONLYCODE" data-options="required:false,prompt:'',tipPosition:'top',required:false" style="width: 120px; height: 32px;"></span>
+                            <a href="javascript:void(0)" id="btnSearchSubmit" title="清空" class="easyui-linkbutton" plain="false" onclick="$('#ffMaster').form('clear')">清空</a>
+                            <a href="javascript:void(0)" id="btnSearchSubmit" title="搜索" class="easyui-linkbutton" plain="false" onclick="tbSearchSubmit()">搜索</a>
+                        </div>
+</form>
             </div>
         </div>
     </div>
@@ -265,7 +265,9 @@
         function tbSearchSubmit() {
             var index = $('#tableTabs').tabs('getTabIndex', $('#tableTabs').tabs('getSelected'));
             var barcode = $('#barcode').textbox('getValue');
-            if (($("#datebeginMasterS").datetimebox("getValue") != "" && $("#datebeginMasterD").datetimebox("getValue") != "")
+            var IDNRKONLYCODE = $('#IDNRKONLYCODE').textbox('getValue');
+            if (barcode.length > 0 || IDNRKONLYCODE.length > 0
+                || ($("#datebeginMasterS").datetimebox("getValue") != "" && $("#datebeginMasterD").datetimebox("getValue") != "")
                 || ($("#datebeginMasterG").datebox("getValue") != "" && $("#dateendMasterG").datebox("getValue") != "")) {
                 if ($('#ffMaster').form("validate")) {
 
@@ -282,6 +284,20 @@
                             columnMoving: true
                         });
                     }
+                    if (index == 2 && (IDNRKONLYCODE.length > 0)) {
+                        //物料信息表
+                        $('#DataGridMateriel').datagridLoad({
+                            title: '',
+                            idField: 'SID',
+                            queryParams: $('#ffMaster').serializeJson(),
+                            url: 'rpt.ashx?m=materiel&id=' + request('id'),
+                            fixWidth: 160,
+                            mergeWidth: 100,
+                            splitChar: '_',
+                            columnMenu: '#btnColumnMenu',
+                            columnMoving: true
+                        });
+                    }
                     if ((index == 1 || index == 2 || index == 3) && barcode.length > 0) {
                         //产品追踪表
                         $('#DataGridMaster').datagridLoad({