qinqi пре 2 година
родитељ
комит
1e705722f6

+ 62 - 7
wwwroot/main/FqcProductCheck/api/AddFQCInspect_WCF.ashx

@@ -29,6 +29,11 @@ public class AddFQCInspect_WCF : IHttpHandler, IReadOnlySessionState
                 //提交到接口
 
                 DataTable saveTable = JsonConvert.DeserializeObject<DataTable>(context.Request["saveTable"]);
+                DataTable saveBOMTable = new DataTable();
+                if (context.Request["saveBOMTable"] != null)
+                {
+                   saveBOMTable = JsonConvert.DeserializeObject<DataTable>(context.Request["saveBOMTable"]); 
+                }
                 string goodsCode = context.Request["goodsCode"];
                 int planID = 0;
                 int inspectionquality = 0;
@@ -44,13 +49,13 @@ public class AddFQCInspect_WCF : IHttpHandler, IReadOnlySessionState
                     string barcode = saveTable.Rows[0]["BARCODE"].ToString();
                     if (barcode.Length > 11)
                     {
-                            DataTable procedurename = conn.ExecuteDatatable(@"
+                        DataTable procedurename = conn.ExecuteDatatable(@"
                             SELECT BARCODE
                               FROM TP_PM_GROUTINGDAILYDETAIL
                              WHERE OUTLABELCODE = @OUTLABELCODE@",
-                            new CDAParameter("OUTLABELCODE", barcode)
-                            );
-                            barcode = procedurename.Rows[0]["BARCODE"].ToString();
+                        new CDAParameter("OUTLABELCODE", barcode)
+                        );
+                        barcode = procedurename.Rows[0]["BARCODE"].ToString();
                     }
 
                     //查询当前产品的当日计划ID-PLANID
@@ -100,7 +105,8 @@ public class AddFQCInspect_WCF : IHttpHandler, IReadOnlySessionState
                                 ISQUALIFIED,
                                 ACCOUNTID,
                                 CREATEUSERID,
-                                UPDATEUSERID
+                                UPDATEUSERID,
+                                REMARKS
                             ) VALUES (
                                 @PLANID@,
                                 @BARCODE@, 
@@ -113,7 +119,8 @@ public class AddFQCInspect_WCF : IHttpHandler, IReadOnlySessionState
                                 @ISQUALIFIED@,
                                 @ACCOUNTID@,
                                 @CREATEUSERID@,
-                                @UPDATEUSERID@
+                                @UPDATEUSERID@,
+                                @REMARKS@
                             )
                             ",
                                new CDAParameter("PLANID", planID),
@@ -127,7 +134,8 @@ public class AddFQCInspect_WCF : IHttpHandler, IReadOnlySessionState
                                new CDAParameter("ISQUALIFIED", saveTable.Rows[i]["ISQUALIFIED"].ToString() == "0"? 0:1),
                                new CDAParameter("ACCOUNTID", Convert.ToInt32(HttpContext.Current.Session["accountId"])),
                                new CDAParameter("CREATEUSERID", Convert.ToInt32(HttpContext.Current.Session["userId"])),
-                               new CDAParameter("UPDATEUSERID", Convert.ToInt32(HttpContext.Current.Session["userId"]))
+                               new CDAParameter("UPDATEUSERID", Convert.ToInt32(HttpContext.Current.Session["userId"])),
+                               new CDAParameter("REMARKS", saveTable.Rows[i]["REMARKS"].ToString())
                            );
 
                         }
@@ -141,6 +149,53 @@ public class AddFQCInspect_WCF : IHttpHandler, IReadOnlySessionState
                     }
 
                 }
+                if (saveBOMTable != null && saveBOMTable.Rows.Count > 0)
+                {
+                    string barcode = saveBOMTable.Rows[0]["BARCODE"].ToString();
+                    if (barcode.Length > 11)
+                    {
+                        DataTable procedurename = conn.ExecuteDatatable(@"
+                            SELECT BARCODE
+                              FROM TP_PM_GROUTINGDAILYDETAIL
+                             WHERE OUTLABELCODE = @OUTLABELCODE@",
+                        new CDAParameter("OUTLABELCODE", barcode)
+                        );
+                        barcode = procedurename.Rows[0]["BARCODE"].ToString();
+                    }
+
+                    for (int i = 0; i < saveBOMTable.Rows.Count; i++)
+                    {
+                        //插入检验数据
+                        int resultaddItems = conn.ExecuteNonQuery(@"
+                            INSERT INTO TP_PM_FQCBOM ( 
+                                BARCODE,
+                                PACKINGBOMDETAILID,
+                                BOMNAME,
+                                CHECKVALUE, 
+                                REMARKS,
+                                CREATEUSERID,
+                                UPDATEUSERID
+                            ) VALUES ( 
+                                @BARCODE@, 
+                                @PACKINGBOMDETAILID@,
+                                @BOMNAME@,
+                                @CHECKVALUE@,
+                                @REMARKS@, 
+                                @CREATEUSERID@,
+                                @UPDATEUSERID@
+                            )
+                            ",
+                           new CDAParameter("BARCODE", barcode),
+                           new CDAParameter("PACKINGBOMDETAILID", Convert.ToInt32(saveBOMTable.Rows[i]["packingBomDetailID"])),
+                           new CDAParameter("BOMNAME", saveBOMTable.Rows[i]["bomName"]),
+                           new CDAParameter("CHECKVALUE", saveBOMTable.Rows[i]["checkVlaue"]),
+                           new CDAParameter("REMARKS", saveBOMTable.Rows[i]["remarks"]),
+                           new CDAParameter("CREATEUSERID", Convert.ToInt32(HttpContext.Current.Session["userId"])),
+                           new CDAParameter("UPDATEUSERID", Convert.ToInt32(HttpContext.Current.Session["userId"]))
+                       );
+
+                    }
+                }
                 conn.Commit();
                 string jsonStr = ("{'success':true,'message':'操作成功!','rows':''}").Replace("'", "\"");
                 context.Response.Write(jsonStr);

+ 66 - 0
wwwroot/main/FqcProductCheck/api/GetBOMDetail_WCF.ashx

@@ -0,0 +1,66 @@
+<%@ WebHandler Language="C#" Class="GetBOMDetail_WCF" %>
+
+
+using System;
+using System.Data;
+using System.Linq;
+using System.Web;
+using System.Web.SessionState;
+using System.Web.Configuration;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Configuration;
+
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Curtain.DataAccess;
+using Curtain.Log;
+using DK.XuWei.WebMes;
+
+
+/// <summary>
+/// 获取 bom数据
+/// xuwei 2020-06-11
+/// </summary>
+public class GetBOMDetail_WCF : IHttpHandler, IReadOnlySessionState
+{
+
+    public void ProcessRequest(HttpContext context)
+    { 
+        string datuv = System.DateTime.Now.Date.ToString("yyyyMMdd");
+        using (IDataAccess conn = DataAccess.Create())
+        {
+            DataTable dtMatnr = conn.ExecuteDatatable(@"
+                SELECT
+                      m.NAME ,
+                      b.MATNR ,
+                      m.IDNRK ,
+                      m.MENGE,
+                      m.PACKINGBOMDETAILID
+                    FROM
+                      TP_MST_PACKINGBOMDETAIL m
+                      INNER JOIN TP_MST_PACKINGBOM b ON m.PACKINGBOMID = b.PACKINGBOMID
+                      INNER JOIN TP_PM_GROUTINGDAILYDETAIL gdd ON gdd.MATERIALCODE = b.MATNR
+                    WHERE
+                      m.VALUEFLAG = '1' 
+                        AND b.VALUEFLAG = '1' 
+                      AND gdd.BARCODE = @BARCODE@ ",
+                new CDAParameter("BARCODE", context.Request["barcode"])
+            );
+
+            context.Response.Write(new JsonResult(dtMatnr).ToJson()); 
+
+        }
+    }
+
+
+    public bool IsReusable
+    {
+        get
+        {
+            return false;
+        }
+    }
+
+}

+ 54 - 0
wwwroot/main/FqcProductCheck/api/GetItemsDataDetail_WCF.ashx

@@ -0,0 +1,54 @@
+<%@ WebHandler Language="C#" Class="GetItemsDataDetail_WCF" %>
+
+using System;
+using System.Collections.Generic;
+using System.Web;
+using System.Web.SessionState;
+using System.Configuration;
+using System.Data;
+using Newtonsoft.Json;
+using Curtain.DataAccess;
+using Curtain.Log;
+using DK.XuWei.WebMes;
+
+public class GetItemsDataDetail_WCF : IHttpHandler
+{
+    public void ProcessRequest(HttpContext context)
+    {
+        context.Response.ContentType = "text/plain";
+        using (IDataAccess conn = DataAccess.Create())
+        {
+            string barcode = context.Request["barcode"].ToString();
+            string type = context.Request["type"].ToString();
+            
+                DataTable procedurename = conn.ExecuteDatatable(@"
+                    SELECT  
+                        FD.ITEMSID,
+                        FD.ITEMSDETAILID,
+                        FD.INSPECTITEM,
+                        FD.INSPECTVALUE,
+                        FD.ISQUALIFIED 
+                    FROM TP_PM_FQCITEMSDATA FD
+                    LEFT JOIN TP_MST_DATADICTIONARY D ON FD.INSPECTTYPE = D.DICTIONARYID
+                    WHERE FD.VALUEFLAG = '1'
+                    AND FD.BARCODE = @BARCODE@
+                    AND D.DICTIONARYVALUE = @TYPE@ 
+                    ORDER BY FD.CREATETIME,FD.ITEMSDETAILID",
+                new CDAParameter("BARCODE", barcode),
+                new CDAParameter("TYPE", type)
+                ); 
+            context.Response.Write(new JsonResult(procedurename).ToJson());
+
+        }
+
+    }
+
+    public bool IsReusable
+    {
+        get
+        {
+            return false;
+        }
+    }
+
+}

+ 380 - 122
wwwroot/main/FqcProductCheck/index.html

@@ -132,7 +132,7 @@
                                 <div class="form-group col-3 mb-1">
                                     检验项目
                                 </div>
-                                <div class="form-group col-3 mb-1">
+                                <div class="form-group col-2 mb-1">
                                     检验标准
                                 </div>
                                 <div class="form-group col-5 mb-1">
@@ -141,13 +141,78 @@
                                 <div class="form-group col-1 mb-1">
                                     是否合格
                                 </div>
+                                <div class="form-group col-1 mb-1">
+                                    备注
+                                </div>
                             </div>
                         </div>
-                        <div style="overflow-y: scroll; height:540px ">
+                        <div style="overflow-y: scroll; height:340px " id="topdetail">
                             <div id="检验项目">
                             </div>
                         </div>
 
+                        <div class="row pt-2" id="bomhidden">
+                            <div style="overflow-y: scroll;height: 200px; width: 70% ">
+                                <div class="form-row pt-4">
+                                    <table class="table" id="bomTable">
+                                        <thead>
+                                            <tr class="table-secondary">
+                                                <th scope="col"> 序号</th>
+                                                <th scope="col">
+                                                    正确
+                                                    <!--<div style="display:flex">
+
+                                                        <label for="正确" style="padding-top: 10px; padding-bottom: -10px;">正确</label>
+                                                    </div>-->
+
+                                                </th>
+                                                <th scope="col">
+                                                    错误
+                                                    <!--<div style="display:flex">
+                                                        <label for="错误" style="padding-top: 10px; padding-bottom: -10px;">错误</label>
+                                                    </div>-->
+                                                </th>
+                                                <th scope="col">
+                                                    漏装
+                                                    <!--<div style="display:flex">
+                                                        <label for="漏装" style="padding-top: 10px; padding-bottom: -10px;">漏装</label>
+                                                    </div>-->
+                                                </th>
+                                                <th scope="col">
+                                                    多装
+                                                    <!--<div style="display:flex">
+                                                        <label for="多装" style="padding-top: 10px; padding-bottom: -10px;">多装</label>
+                                                    </div>-->
+                                                </th>
+                                                <th scope="col">物料名称</th>
+                                            </tr>
+                                        </thead>
+
+                                        <tbody id="BOM检验项目列表">
+                                        </tbody>
+
+                                    </table>
+                                </div>
+                            </div>
+
+                            
+                            <div style="margin-left:10px; height: 200px; width: 28% ">
+                                <div class="form-row pt-4">
+                                    <textarea value="" id="remarks" style="width:100%;height:190px"></textarea>
+                                   
+                                    <!--<table class="table" id="bomTable">
+                                        <thead>
+                                            <tr class="table-secondary">
+                                                <th scope="col" style="margin-left:10px"> 备注</th>
+                                            </tr>
+                                        </thead>
+                                        <tbody id="BOM备注列表">
+                                        </tbody>
+                                    </table>-->
+                                </div>
+                            </div>
+                        </div> 
+
                         <div class="form-row pt-4">
                             <div class="form-group col-2 align-self-end">
                                 <button onclick="Collapse()" id="收起" type="button" class="btn btn-info btn-block">收起左侧页面</button>
@@ -180,6 +245,40 @@
         </table>
     </div>
 
+    <!--检验模板-->
+    <div class="d-none">
+        <table>
+            <tbody id="BOM检验项目模板">
+                <tr id="{物料检验}">
+                    <td>{序号} </td>
+                    <td>
+                        <input type="checkbox" onclick="chooseCheckBox('正确'+'{序号}','{序号}')" class="form-control border-secondary" id="正确{序号}">
+                    </td>
+                    <td>
+                        <input type="checkbox" onclick="chooseCheckBox('错误'+'{序号}','{序号}')" class="form-control border-secondary" id="错误{序号}">
+                    </td>
+                    <td>
+                        <input type="checkbox" onclick="chooseCheckBox('漏'+'{序号}','{序号}')" class="form-control border-secondary" id="漏{序号}">
+                    </td>
+                    <td>
+                        <input type="checkbox" onclick="chooseCheckBox('多'+'{序号}','{序号}')" class="form-control border-secondary" id="多{序号}">
+                    </td>
+                    <td>{物料名称}</td>
+                </tr>
+            </tbody>
+        </table>
+    </div>
+
+    <div class="d-none">
+        <table>
+            <tbody id="备注模板">
+                <tr id="{备注}"> 
+                    <td>{备注}</td>
+                </tr>
+            </tbody>
+        </table>
+    </div>
+
     <!--对话框-->
     <script src="../common/dialog.js"></script>
     <!--版权信息-->
@@ -195,24 +294,35 @@
         var jsonUser;                           // 生产工号数据源
         var workstation = request('NAME');      // 当前页工位
         var itemsJson;
+        var itemsdataJson;
         var barcode;                            //产品条码
         var goodsid;
         var itemsLength;                        //检验项目长度    
         var divwidht;                           //检验项目 页面宽度
+        var remarks;                            //备注
+
         $(document).ready(function () {
             divwidht = document.getElementById('检验').style.width;
             if (request('NAME').search("型式检验") >= 0) {
 
                 $('#检验标准').val("型式检验");
+                
+                $('#bomhidden').hide(true);
+                document.getElementById('topdetail').style.height = '520px'//赋值高度
+                
             }
             else if (request('NAME').search("外观检验") >= 0) {
                 $('#检验标准').val("外观检验(品管检验)");
+                $('#bomhidden').hide(true);
+                document.getElementById('topdetail').style.height = '520px'//赋值高度
             }
             else if (request('NAME').search("包装检验") >= 0) {
                 $('#检验标准').val("包装检验(品管检验)");
             }
             else if (request('NAME').search("功能检验") >= 0) {
                 $('#检验标准').val("功能检验(品管检验)");
+                $('#bomhidden').hide(true);
+                document.getElementById('topdetail').style.height = '520px'//赋值高度
             }
             //加载数据
             loadData();
@@ -342,7 +452,7 @@
                             else if (json['rows'][0]['INFO'] != '' && json['rows'][0]['INFO'] != null) {
                                 swal({
                                     title: "产品查询",
-                                    text: '当前条码已完成检验,是否重新检验?',
+                                    text: '当前条码已完成检验,是否继续检验?',
                                     icon: "warning",
                                     dangerMode: true,
                                     buttons: ["是", "否"]
@@ -360,139 +470,192 @@
                                             console.log('itemsJson', itemsJson)
 
                                             if (itemsJson["success"] == true) {
-                                                itemsLength = itemsJson["rows"].length;
-                                                for (var i = 0; i < itemsJson["rows"].length; i++) {
-                                                    $("#检验项目").append('<div class="form-row" id = "检验项目' + i + '"></div>');
-
-                                                    var inspectresult = itemsJson["rows"][i]["INSPECTITEM"];
-                                                    if (itemsJson["rows"][i]["INSPECTITEM"].search("%") >= 0) {
-                                                        inspectresult = itemsJson["rows"][i]["INSPECTITEM"].replace("%", "");
-                                                        inspectresult = inspectresult.replace("/", "");
-                                                    }
-                                                    var inspectre = itemsJson["rows"][i]["TECHNICALREQUIREMENT"];
-                                                    var lowerLimit = itemsJson["rows"][i]["LOWERLIMIT"];
-                                                    var upperLimit = itemsJson["rows"][i]["UPPERLIMIT"];
 
-                                                    if (inspectre == '' || inspectre == null) {
-                                                        inspectre = '>=' + lowerLimit + ';<=' + upperLimit;
-                                                    }
+                                                //查询已经检验的项目
+                                                $.get('api/GetItemsDataDetail_WCF.ashx', { 'barcode': barcode, 'type': $('#检验标准').val() }, function (data1) {
 
-                                                    if (itemsJson["rows"][i]["INSPECTMARKVALUE"] == "定性") {
-                                                        if (itemsJson["rows"][i]["ISINSPECT"] == "1") {
-                                                            $("#检验项目" + i).append(
-																'<div class="form-group col-3 mb-1"><input type="text" class="form-control border-secondary" id="' + inspectresult + '" value="' + itemsJson["rows"][i]["INSPECTITEM"] + '*" readonly></div>' +
-																'<div class="form-group col-3 mb-1 rabbit"><input type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
-                                                            );
+                                                    itemsdataJson = JSON.parse(data1);
+                                                    console.log('itemsdataJson', itemsdataJson)
+
+                                                    itemsLength = itemsJson["rows"].length;
+                                                    for (var i = 0; i < itemsJson["rows"].length; i++) {
+                                                        $("#检验项目").append('<div class="form-row" id = "检验项目' + i + '"></div>');
+
+                                                        var inspectresult = itemsJson["rows"][i]["INSPECTITEM"];
+                                                        if (itemsJson["rows"][i]["INSPECTITEM"].search("%") >= 0) {
+                                                            inspectresult = itemsJson["rows"][i]["INSPECTITEM"].replace("%", "");
+                                                            inspectresult = inspectresult.replace("/", "");
                                                         }
-                                                        else {
-                                                            $("#检验项目" + i).append(
-																'<div class="form-group col-3 mb-1"><input type="text" class="form-control border-secondary" id="' + inspectresult + '" value="' + itemsJson["rows"][i]["INSPECTITEM"] + '" readonly></div>' +
-																'<div class="form-group col-3 mb-1 rabbit"><input type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
-                                                            );
+                                                        var inspectre = itemsJson["rows"][i]["TECHNICALREQUIREMENT"];
+                                                        var lowerLimit = itemsJson["rows"][i]["LOWERLIMIT"];
+                                                        var upperLimit = itemsJson["rows"][i]["UPPERLIMIT"];
+
+                                                        if (inspectre == '' || inspectre == null) {
+                                                            inspectre = '>=' + lowerLimit + ';<=' + upperLimit;
                                                         }
+
+                                                        if (itemsJson["rows"][i]["INSPECTMARKVALUE"] == "定性") {
+                                                            if (itemsJson["rows"][i]["ISINSPECT"] == "1") {
+                                                                $("#检验项目" + i).append(
+																    '<div class="form-group col-3 mb-1"><input type="text" class="form-control border-secondary" id="' + inspectresult + '" value="' + itemsJson["rows"][i]["INSPECTITEM"] + '*" readonly></div>' +
+																    '<div class="form-group col-2 mb-1 rabbit"><input type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
+                                                                );
+                                                            }
+                                                            else {
+                                                                $("#检验项目" + i).append(
+																    '<div class="form-group col-3 mb-1"><input type="text" class="form-control border-secondary" id="' + inspectresult + '" value="' + itemsJson["rows"][i]["INSPECTITEM"] + '" readonly></div>' +
+																    '<div class="form-group col-2 mb-1 rabbit"><input type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
+                                                                );
+                                                            }
                                                          
-                                                        if (itemsJson["rows"][i]["INSPECTCOUNT"] == "1" || itemsJson["rows"][i]["INSPECTCOUNT"] == null) {
-                                                            $("#检验项目" + i).append(
-                                                                '<div class="form-group col-5 mb-1"><select id ="' + i + '结果1"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>'
-                                                            );
-                                                        }
-                                                        else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "2") {
-                                                            $("#检验项目" + i).append(
-                                                                '<div class="form-group col-3 mb-1"><select id ="' + i + '结果1"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
-                                                                '<div class="form-group col-2 mb-1"><select id ="' + i + '结果2"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>'
-                                                            );
-                                                        }
-                                                        else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "3") {
-                                                            $("#检验项目" + i).append(
-                                                                '<div class="form-group col-2 mb-1"><select id ="' + i + '结果1"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
-                                                                '<div class="form-group col-2 mb-1"><select id ="' + i + '结果2"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
-                                                                '<div class="form-group col-1 mb-1"><select id ="' + i + '结果3"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>'
-                                                            );
-                                                        }
-                                                        else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "4") {
+                                                            if (itemsJson["rows"][i]["INSPECTCOUNT"] == "1" || itemsJson["rows"][i]["INSPECTCOUNT"] == null) {
+                                                                $("#检验项目" + i).append(
+                                                                    '<div class="form-group col-5 mb-1"><select id ="' + i + '结果1"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>'
+                                                                );
+                                                            }
+                                                            else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "2") {
+                                                                $("#检验项目" + i).append(
+                                                                    '<div class="form-group col-3 mb-1"><select id ="' + i + '结果1"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                                    '<div class="form-group col-2 mb-1"><select id ="' + i + '结果2"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>'
+                                                                );
+                                                            }
+                                                            else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "3") {
+                                                                $("#检验项目" + i).append(
+                                                                    '<div class="form-group col-2 mb-1"><select id ="' + i + '结果1"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                                    '<div class="form-group col-2 mb-1"><select id ="' + i + '结果2"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><select id ="' + i + '结果3"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>'
+                                                                );
+                                                            }
+                                                            else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "4") {
+                                                                $("#检验项目" + i).append(
+                                                                    '<div class="form-group col-2 mb-1"><select id ="' + i + '结果1"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><select id ="' + i + '结果2"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><select id ="' + i + '结果3"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><select id ="' + i + '结果4"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>'
+                                                                );
+                                                            }
+                                                            else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "5") {
+                                                                $("#检验项目" + i).append(
+                                                                    '<div class="form-group col-1 mb-1"><select id ="' + i + '结果1"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><select id ="' + i + '结果2"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><select id ="' + i + '结果3"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><select id ="' + i + '结果4"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><select id ="' + i + '结果5"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>'
+                                                                );
+                                                            }
+
                                                             $("#检验项目" + i).append(
-                                                                '<div class="form-group col-2 mb-1"><select id ="' + i + '结果1"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
-                                                                '<div class="form-group col-1 mb-1"><select id ="' + i + '结果2"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
-                                                                '<div class="form-group col-1 mb-1"><select id ="' + i + '结果3"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
-                                                                '<div class="form-group col-1 mb-1"><select id ="' + i + '结果4"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>'
+                                                            
+                                                                '<div class="form-group col-1 mb-1"><select id="' + i + '合格" class="custom-select" required><option value=""></option><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                                '<div class="form-group col-1 mb-1"><input type="text" class="form-control border-secondary" id="' + i + '备注" value="" ></div>'
                                                             );
                                                         }
-                                                        else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "5") {
+                                                        else if (itemsJson["rows"][i]["INSPECTMARKVALUE"] == "定量") {
+
+                                                            if (itemsJson["rows"][i]["ISINSPECT"] == "1") {
+                                                                $("#检验项目" + i).append(
+																    '<div class="form-group col-3 mb-1"><input  type="text" class="form-control border-secondary" id="' + inspectresult + '" value="' + itemsJson["rows"][i]["INSPECTITEM"] + '*" readonly></div>' +
+																    '<div class="form-group col-2 mb-1"><input  type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
+                                                                );
+                                                            }
+                                                            else {
+                                                                $("#检验项目" + i).append(
+																    '<div class="form-group col-3 mb-1"><input  type="text" class="form-control border-secondary" id="' + inspectresult + '" value="' + itemsJson["rows"][i]["INSPECTITEM"] + '" readonly></div>' +
+																    '<div class="form-group col-2 mb-1"><input  type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
+                                                                );
+                                                            }
+
+
+                                                            if (itemsJson["rows"][i]["INSPECTCOUNT"] == "1" || itemsJson["rows"][i]["INSPECTCOUNT"] == null) {
+                                                                $("#检验项目" + i).append(
+                                                                    '<div class="form-group col-5 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果1" required></div>'
+                                                                );
+                                                            }
+                                                            else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "2") {
+                                                                $("#检验项目" + i).append(
+                                                                    '<div class="form-group col-3 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果1" required></div>' +
+                                                                    '<div class="form-group col-2 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果2" required></div>'
+                                                                );
+                                                            }
+                                                            else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "3") {
+                                                                $("#检验项目" + i).append(
+                                                                    '<div class="form-group col-2 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果1" required></div>' +
+                                                                    '<div class="form-group col-2 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果2" required></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果3" required></div>'
+
+                                                                );
+                                                            }
+                                                            else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "4") {
+                                                                $("#检验项目" + i).append(
+                                                                    '<div class="form-group col-2 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果1" required></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果2" required></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果3" required></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果4" required></div>'
+                                                                );
+                                                            }
+                                                            else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "5") {
+                                                                $("#检验项目" + i).append(
+                                                                    '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果1" required></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果2" required></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果3" required></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果4" required></div>' +
+                                                                    '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果5" required></div>'
+                                                                );
+                                                            }
+
                                                             $("#检验项目" + i).append(
-                                                                '<div class="form-group col-1 mb-1"><select id ="' + i + '结果1"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
-                                                                '<div class="form-group col-1 mb-1"><select id ="' + i + '结果2"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
-                                                                '<div class="form-group col-1 mb-1"><select id ="' + i + '结果3"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
-                                                                '<div class="form-group col-1 mb-1"><select id ="' + i + '结果4"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>' +
-                                                                '<div class="form-group col-1 mb-1"><select id ="' + i + '结果5"  class="custom-select" required><option value="1">合格</option><option value="0">不合格</option></select></div>'
+                                                                '<div class="form-group col-1 mb-1"><select id="' + i + '合格" class="custom-select" required><option value=""></option><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                                '<div class="form-group col-1 mb-1"><input type="text" class="form-control border-secondary" id="' + i + '备注" value="" ></div>'
                                                             );
+
                                                         }
 
-                                                        $("#检验项目" + i).append(
-                                                            
-                                                            '<div class="form-group col-1 mb-1"><select id="' + i + '合格" class="custom-select" required><option value=""></option><option value="1">合格</option><option value="0">不合格</option></select></div>'
-                                                        );
-                                                    }
-                                                    else if (itemsJson["rows"][i]["INSPECTMARKVALUE"] == "定量") {
+                                                        //查找已经检验完成的项目,并进行赋值
+                                                        for (var z = 0; z < itemsdataJson["rows"].length; z++) {
+                                                            if (itemsJson["rows"][i]["ITEMSDETAILID"] == itemsdataJson["rows"][z]["ITEMSDETAILID"] ) {
+                                                                if (itemsJson["rows"][i]["INSPECTMARKVALUE"] == "定性") {
+                                                                    if (itemsJson["rows"][i]["INSPECTCOUNT"] == "1" || itemsJson["rows"][i]["INSPECTCOUNT"] == null) {
+
+                                                                            $("#" + i + "结果1").val(itemsdataJson["rows"][z]["INSPECTVALUE"]);
+                                                                        $("#" + i + "合格").val(itemsdataJson["rows"][z]["ISQUALIFIED"]);
+                                                                       
+                                                                    } else {
+                                                                        for (var m = 1; m <= parseInt(itemsJson["rows"][i]["INSPECTCOUNT"]); m++) {
+                                                                            $("#" + i + "结果" + m).val(itemsdataJson["rows"][z]["INSPECTVALUE"]);
+                                                                            z = z + 1;
+                                                                        }
+                                                                        $("#" + i + "合格").val(itemsdataJson["rows"][z]["ISQUALIFIED"]);
+                                                                    }
+                                                                }
+                                                                else if (itemsJson["rows"][i]["INSPECTMARKVALUE"] == "定量") {
+                                                                    if (itemsJson["rows"][i]["INSPECTCOUNT"] == "1" || itemsJson["rows"][i]["INSPECTCOUNT"] == null) {
+
+                                                                        $("#" + i + "结果1").val(itemsdataJson["rows"][z]["INSPECTVALUE"]);
+                                                                        $("#" + i + "合格").val(itemsdataJson["rows"][z]["ISQUALIFIED"]);
+
+                                                                    } else {
+                                                                        for (var m = 1; m <= parseInt(itemsJson["rows"][i]["INSPECTCOUNT"]); m++) {
+                                                                            if ($("#" + i + "结果" + m).val() == '') {
+                                                                                $("#" + i + "结果" + m).val(itemsdataJson["rows"][z]["INSPECTVALUE"]);
+                                                                                z = z + 1;
+                                                                            }
+                                                                        }
+                                                                        $("#" + i + "合格").val(itemsdataJson["rows"][z]["ISQUALIFIED"]);
+                                                                    }
+                                                                }
+
+                                                            }
 
-                                                        if (itemsJson["rows"][i]["ISINSPECT"] == "1") {
-                                                            $("#检验项目" + i).append(
-																'<div class="form-group col-3 mb-1"><input  type="text" class="form-control border-secondary" id="' + inspectresult + '" value="' + itemsJson["rows"][i]["INSPECTITEM"] + '*" readonly></div>' +
-																'<div class="form-group col-3 mb-1"><input  type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
-                                                            );
-                                                        }
-                                                        else {
-                                                            $("#检验项目" + i).append(
-																'<div class="form-group col-3 mb-1"><input  type="text" class="form-control border-secondary" id="' + inspectresult + '" value="' + itemsJson["rows"][i]["INSPECTITEM"] + '" readonly></div>' +
-																'<div class="form-group col-3 mb-1"><input  type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
-                                                            );
-                                                        }
 
 
-                                                        if (itemsJson["rows"][i]["INSPECTCOUNT"] == "1" || itemsJson["rows"][i]["INSPECTCOUNT"] == null) {
-                                                            $("#检验项目" + i).append(
-                                                                '<div class="form-group col-5 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果1" required></div>'
-                                                            );
-                                                        }
-                                                        else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "2") {
-                                                            $("#检验项目" + i).append(
-                                                                '<div class="form-group col-3 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果1" required></div>' +
-                                                                '<div class="form-group col-2 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果2" required></div>'
-                                                            );
                                                         }
-                                                        else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "3") {
-                                                            $("#检验项目" + i).append(
-                                                                '<div class="form-group col-2 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果1" required></div>' +
-                                                                '<div class="form-group col-2 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果2" required></div>' +
-                                                                '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果3" required></div>'
 
-                                                            );
-                                                        }
-                                                        else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "4") {
-                                                            $("#检验项目" + i).append(
-                                                                '<div class="form-group col-2 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果1" required></div>' +
-                                                                '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果2" required></div>' +
-                                                                '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果3" required></div>' +
-                                                                '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果4" required></div>'
-                                                            );
-                                                        }
-                                                        else if (itemsJson["rows"][i]["INSPECTCOUNT"] == "5") {
-                                                            $("#检验项目" + i).append(
-                                                                '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果1" required></div>' +
-                                                                '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果2" required></div>' +
-                                                                '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果3" required></div>' +
-                                                                '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果4" required></div>' +
-                                                                '<div class="form-group col-1 mb-1"><input value="" type="text" class="form-control" id ="' + i + '结果5" required></div>'
-                                                            );
-                                                        }
 
-                                                        $("#检验项目" + i).append(
-                                                            '<div class="form-group col-1 mb-1"><select id="' + i + '合格" class="custom-select" required><option value=""></option><option value="1">合格</option><option value="0">不合格</option></select></div>'
-                                                        );
 
                                                     }
 
-                                                }
 
+                                                });
                                             }
 
                                         });
@@ -533,13 +696,13 @@
                                                 if (itemsJson["rows"][i]["ISINSPECT"] == "1") {
                                                     $("#检验项目" + i).append(
 														'<div title="' + itemsJson["rows"][i]["INSPECTITEM"] + '*" class="form-group col-3 mb-1"><input type="text" class="form-control border-secondary redstar" id="' + inspectresult + '" value="' + itemsJson["rows"][i]["INSPECTITEM"] + '*" readonly></div>' +
-														'<div title="' + inspectre + '" class="form-group col-3 mb-1 rabbit"><input type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
+														'<div title="' + inspectre + '" class="form-group col-2 mb-1 rabbit"><input type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
                                                     );
                                                 }
                                                 else {
                                                     $("#检验项目" + i).append(
 														'<div title="' + itemsJson["rows"][i]["INSPECTITEM"] + '*" class="form-group col-3 mb-1"><input type="text" class="form-control border-secondary" id="' + inspectresult + '" value="' + itemsJson["rows"][i]["INSPECTITEM"] + '" readonly></div>' +
-														'<div title="' + inspectre + '" class="form-group col-3 mb-1 rabbit"><input type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
+														'<div title="' + inspectre + '" class="form-group col-2 mb-1 rabbit"><input type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
                                                     );
                                                 }
 
@@ -581,7 +744,8 @@
                                                 }
 
                                                 $("#检验项目" + i).append(
-                                                    '<div class="form-group col-1 mb-1"><select id="' + i + '合格" class="custom-select" required><option value=""></option><option value="1">合格</option><option value="0">不合格</option></select></div>'
+                                                    '<div class="form-group col-1 mb-1"><select id="' + i + '合格" class="custom-select" required><option value=""></option><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                    '<div class="form-group col-1 mb-1"><input type="text" class="form-control border-secondary" id="' + i + '备注" value="" ></div>'
                                                 );
                                             }
                                             else if (itemsJson["rows"][i]["INSPECTMARKVALUE"] == "定量") {
@@ -589,13 +753,13 @@
                                                 if (itemsJson["rows"][i]["ISINSPECT"] == "1") {
                                                     $("#检验项目" + i).append(
 														'<div title="' + itemsJson["rows"][i]["INSPECTITEM"] + '*" class="form-group col-3 mb-1"><input  type="text" class="form-control border-secondary redstar" id="' + inspectresult + '" value="' + itemsJson["rows"][i]["INSPECTITEM"] + '*" readonly></div>' +
-														'<div title="' + inspectre + '" class="form-group col-3 mb-1"><input  type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
+														'<div title="' + inspectre + '" class="form-group col-2 mb-1"><input  type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
                                                     );
                                                 }
                                                 else {
                                                     $("#检验项目" + i).append(
 														'<div title="' + itemsJson["rows"][i]["INSPECTITEM"] + '*" class="form-group col-3 mb-1"><input  type="text" class="form-control border-secondary" id="' + inspectresult + '" value="' + itemsJson["rows"][i]["INSPECTITEM"] + '" readonly></div>' +
-														'<div title="' + inspectre + '" class="form-group col-3 mb-1"><input  type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
+														'<div title="' + inspectre + '" class="form-group col-2 mb-1"><input  type="text" class="form-control border-secondary" id="' + i + '" value="' + inspectre + '" readonly></div>'
                                                     );
                                                 }
 
@@ -638,7 +802,8 @@
                                                 }
 
                                                 $("#检验项目" + i).append(
-                                                    '<div class="form-group col-1 mb-1"><select id="' + i + '合格" class="custom-select" required><option value=""></option><option value="1">合格</option><option value="0">不合格</option></select></div>'
+                                                    '<div class="form-group col-1 mb-1"><select id="' + i + '合格" class="custom-select" required><option value=""></option><option value="1">合格</option><option value="0">不合格</option></select></div>' +
+                                                    '<div class="form-group col-1 mb-1"><input type="text" class="form-control border-secondary" id="' + i + '备注" value="" ></div>'
                                                 );
 
                                             }
@@ -648,6 +813,27 @@
                                     }
 
                                 });
+
+                                //查询该产品的所有Bom信息
+                                $.get('api/GetBOMDetail_WCF.ashx', { 'barcode': barcode }, function (data) {
+
+                                    itemsJson1 = JSON.parse(data);
+                                    console.log('itemsJson1', itemsJson1)
+
+                                    if (itemsJson1["success"] == true) {
+                                        //更新数据并添加记录
+                                        for (var i = 0; i < itemsJson1["rows"].length; i++) {
+                                            var temp = $('#BOM检验项目模板').html();
+                                            if (i == 0) $('#BOM检验项目列表').empty();
+                                            temp = temp.replaceAll('{物料检验}', itemsJson1["rows"][i]["PACKINGBOMDETAILID"]);
+                                            temp = temp.replaceAll('{序号}', i + 1);
+                                            temp = temp.replaceAll('{物料名称}', itemsJson1["rows"][i]["NAME"]);
+                                            $('#BOM检验项目列表').append(temp);
+                                        }
+
+                                    }
+
+                                });
                                 swal.close();
                             }
 
@@ -840,6 +1026,7 @@
                             "InspectItem": itemsJson["rows"][i]["INSPECTITEM"],
                             "InspectValue": $(id).val(),
                             "IsQualified": $('#' + i + '合格').val(),
+                            "REMARKS": $('#' + i + '备注').val(),
                         }
                         saveTable.push(saveOne);
                     }
@@ -850,8 +1037,52 @@
 
             console.log('saveTable', saveTable)
 
+            //整合bom 检验数据
+
+            var saveBOMTable = [];
+            if ($('#检验标准').val() == '包装检验(品管检验)') {
+                 
+                for (var i = 0; i < itemsJson1["rows"].length; i++) {
+                    var j = i + 1;
+                    var checkVlaue = '0';
+                    if ($('#正确' + j).is(':checked')) {
+                        checkVlaue = '1';
+                    }
+                    else if ($('#错误' + j).is(':checked')){
+                        checkVlaue = '2';
+                    }
+                    else if ($('#漏' + j).is(':checked')) {
+                        checkVlaue = '3';
+                    }
+                    else if ($('#多' + j).is(':checked')) {
+                        checkVlaue = '4';
+                    }
+                  
+                    if (checkVlaue != '') {
+                        var saveOnes = {
+                            "BarCode": barcode,
+                            "packingBomDetailID": itemsJson1["rows"][i]["PACKINGBOMDETAILID"],
+                            "bomName": itemsJson1["rows"][i]["NAME"],
+                            "checkVlaue": checkVlaue,
+                            "remarks": $('#remarks').val()
+                        }
+                        saveBOMTable.push(saveOnes);
+                    }
+                    else {
+                        swal({
+                            title: itemsJson1["rows"][i]["NAME"],
+                            text: '该物料没有检验!',
+                            icon: "error",
+                            button: "确定"
+                        });
+                        return;
+                    } 
+                }
+            }
+            console.log('saveBOMTable', saveBOMTable)
+
             //提交到接口
-            $.post('api/AddFQCInspect_WCF.ashx', { 'goodsCode': $('#产品编码').val(), 'saveTable': JSON.stringify(saveTable) }, function (data) {
+            $.post('api/AddFQCInspect_WCF.ashx', { 'goodsCode': $('#产品编码').val(), 'saveTable': JSON.stringify(saveTable), 'saveBOMTable': JSON.stringify(saveBOMTable)}, function (data) {
                 var json = JSON.parse(data);
                 if (json['success'] == true) {
 
@@ -894,7 +1125,34 @@
                 $('#检验项目' + i).remove();
             }
         }
-          
+
+        function chooseCheckBox(id,xuhao) { 
+            
+            if (id.search("错误") >= 0 || id.search("多") >= 0 || id.search("漏") >= 0) {
+                //var temp = $('#备注模板').html();
+                //$('#BOM备注列表').empty();
+                remarks = '';
+
+                for (var i = 0; i < itemsJson1["rows"].length; i++) {
+                    var j = i + 1;
+                    if ($('#错误' + j).is(':checked')) {
+                        remarks += itemsJson1["rows"][i]["NAME"] +'[装配错误];\n'
+                    }
+                    if ($('#漏' + j).is(':checked')) {
+                        remarks += itemsJson1["rows"][i]["NAME"] + '[漏装];\n'
+                    }
+                    if ($('#多' + j).is(':checked')) {
+                        remarks += itemsJson1["rows"][i]["NAME"] + '[多装];\n'
+                    }
+                }
+
+                $('#remarks').val(remarks);
+                //temp = temp.replaceAll('{备注}', remarks);
+                //$('#BOM备注列表').append(temp);
+                
+            } 
+        }
+
     </script>
 
 

+ 79 - 13
wwwroot/main/excel/excelRW.ashx

@@ -2,25 +2,91 @@
 
 using System;
 using System.Web;
-using NPOI.SS.UserModel;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
+using System.Data;
+using Curtain.DataAccess;
 
 public class excelRW : IHttpHandler
 {
 
     public void ProcessRequest(HttpContext context)
     {
-        context.Response.ContentType = "text/html";
-
-        ExcelFile excel = new ExcelFile("template.xls");
-        excel.GetWorkbook.GetSheet("封面").GetRow(14).GetCell(6).SetCellValue("东科商标");
-        excel.GetWorkbook.GetSheet("内容").GetRow(1).GetCell(15).SetCellValue("东科检验项目");
-        excel.GetWorkbook.GetSheet("内容").GetRow(1).GetCell(23).SetCellValue("东科检验结果");
-        excel.SaveAs("export.xls");
-        context.Response.Write("文件写入成功!<a href='export.xls'>点击下载</a>");
+        using (IDataAccess conn = DataAccess.Create())
+        {
+            context.Response.ContentType = "text/html";
+
+            ExcelFile excel = new ExcelFile("template.xls");
+
+            string barcode = context.Request["barcode"].ToString();
+            string inspectname = context.Request["inspectname"].ToString();
+
+            DataTable saveTable = conn.ExecuteDatatable(@"
+                 SELECT fd.barcode
+                                          ,g.goodscode
+                                          ,gt.goodstypename
+                                           ,g.groutingdate
+                                          ,fd.inspectitem
+                                          ,case when fdd.unitname is null then '-'
+                                          else to_char(fdd.unitname) end unitname
+                                          ,fdd.technicalrequirement
+                                          ,fd.inspectvalue
+                                          ,case when  fd.isqualified = 1 then '合格'
+                                          else '不合格' end as isqualified
+                                      FROM tp_pm_fqcitemsdata fd
+                                      LEFT JOIN tp_pm_fqcitemsdetail fdd
+                                        ON fd.itemsdetailid = fdd.itemsdetailid
+                                      LEFT JOIN tp_pm_fqcitems f
+                                        ON f.itemsid = fd.itemsid
+                                        left join tp_pm_groutingdailydetail g on 
+                                        g.barcode = fd.barcode
+                                         left join tp_mst_goods gg on 
+                                        gg.goodsid = g.goodsid
+                                         left join tp_mst_goodstype gt on 
+                                        gg.goodstypeid = gt.goodstypeid
+                                     WHERE fd.barcode = @BARCODE@
+                                       AND f.inspectname = @INSPECTNAME@
+                                       AND fd.valueflag = 1  ",
+               new CDAParameter("BARCODE", barcode),
+               new CDAParameter("INSPECTNAME", inspectname)
+               );
+
+
+            if (saveTable != null && saveTable.Rows.Count > 0)
+            {
+                excel.GetWorkbook.GetSheet("封面").GetRow(12).GetCell(6).SetCellValue(saveTable.Rows[0]["goodstypename"].ToString());
+                excel.GetWorkbook.GetSheet("封面").GetRow(12).GetCell(8).SetCellValue(saveTable.Rows[0]["groutingdate"].ToString());
+                excel.GetWorkbook.GetSheet("封面").GetRow(13).GetCell(6).SetCellValue(saveTable.Rows[0]["goodscode"].ToString());
+                excel.GetWorkbook.GetSheet("封面").GetRow(13).GetCell(8).SetCellValue(saveTable.Rows[0]["barcode"].ToString());
+
+                for (int i = 0; i < saveTable.Rows.Count; i++)
+                {
+                    if (i < 30)
+                    {
+                        excel.GetWorkbook.GetSheet("内容").GetRow(i+1).GetCell(0).SetCellValue(i+1);
+                        excel.GetWorkbook.GetSheet("内容").GetRow(i+1).GetCell(1).SetCellValue(saveTable.Rows[i]["inspectitem"].ToString());
+                        excel.GetWorkbook.GetSheet("内容").GetRow(i+1).GetCell(5).SetCellValue(saveTable.Rows[i]["unitname"].ToString());
+                        excel.GetWorkbook.GetSheet("内容").GetRow(i+1).GetCell(6).SetCellValue(saveTable.Rows[i]["technicalrequirement"].ToString());
+                        excel.GetWorkbook.GetSheet("内容").GetRow(i+1).GetCell(9).SetCellValue(saveTable.Rows[i]["inspectvalue"].ToString());
+                        excel.GetWorkbook.GetSheet("内容").GetRow(i+1).GetCell(12).SetCellValue(saveTable.Rows[i]["isqualified"].ToString());
+                    }
+                    else
+                    {
+                        excel.GetWorkbook.GetSheet("内容").GetRow(i-30+1).GetCell(14).SetCellValue(i+1);
+                        excel.GetWorkbook.GetSheet("内容").GetRow(i-30+1).GetCell(15).SetCellValue(saveTable.Rows[i]["inspectitem"].ToString());
+                        excel.GetWorkbook.GetSheet("内容").GetRow(i-30+1).GetCell(19).SetCellValue(saveTable.Rows[i]["unitname"].ToString());
+                        excel.GetWorkbook.GetSheet("内容").GetRow(i-30+1).GetCell(20).SetCellValue(saveTable.Rows[i]["technicalrequirement"].ToString());
+                        excel.GetWorkbook.GetSheet("内容").GetRow(i-30+1).GetCell(23).SetCellValue(saveTable.Rows[i]["inspectvalue"].ToString());
+                        excel.GetWorkbook.GetSheet("内容").GetRow(i-30+1).GetCell(26).SetCellValue(saveTable.Rows[i]["isqualified"].ToString());
+                    }
+
+                    
+                }
+
+            }
+
+
+            excel.SaveAs("export.xls");
+            context.Response.Write("文件写入成功!<a href='export.xls'>点击下载</a>");
+        }
     }
 
     public bool IsReusable

BIN
wwwroot/main/excel/export.xls


BIN
wwwroot/main/excel/template.xls