wtt
2025-04-02 9cfdb479a1083fc9615779edcff50472319dd387
WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
@@ -2,6 +2,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Pub_Class;
using SyntacticSugar.constant;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -51,7 +52,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单无编辑权限!";
                        objJsonResult.Message = "[0000-1-065]完工单无编辑权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -62,7 +63,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单无编辑权限!";
                        objJsonResult.Message = "[0000-1-065]出站单无编辑权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -76,6 +77,7 @@
                long HMainInterID = 0;
                HMainInterID = list[0].HMainInterID;
                string eventType = list[0].eventType;
                string HDate = list[0].HDate;
                string BillType = "3791";
                string HBillSubType = "3791";
                long HInterID = list[0].HInterID;//递入type得到的单据ID
@@ -150,7 +152,7 @@
                double HLossQty = list[0].HLossQty;//遗失数量
                double HBackWorkByMaterQty = list[0].HBackWorkByMaterQty;//遗失数量
                int HMouldID = list[0].HMouldID;//模具id
                double HMachineWorkTimes = list[0].HMachineWorkTimes;//设备工时
                LogService.Write($"1.字段赋值,用时" + sw.Elapsed );
                //单据完整性判断
@@ -158,7 +160,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "流转卡没有选择!请扫描条形码或输入条形码后回车";
                    objJsonResult.Message = "[3791-2-005]流转卡没有选择!请扫描条形码或输入条形码后回车";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -166,7 +168,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "流水号没有选择!请输入流水号后回车";
                    objJsonResult.Message = "[0000-2-032]流水号没有选择!请输入流水号后回车";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -174,7 +176,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "流水号没有选择!";
                    objJsonResult.Message = "[0000-2-032]流水号没有选择!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -182,7 +184,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "流转卡号没有选择!";
                    objJsonResult.Message = "[0000-2-032]流转卡号没有选择!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -190,7 +192,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "产品没有选择!";
                    objJsonResult.Message = "[0000-2-007]产品没有选择!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -207,7 +209,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "当前工序没有选择!";
                    objJsonResult.Message = "[0000-2-011]当前工序没有选择!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -224,14 +226,20 @@
                string Ret = "";
                if (oSystemParameter.ShowBill(ref Ret))
                {
                    //判断客户为乔一
                    if(oSystemParameter.omodel.WMS_CampanyName == "乔一")
                    {
                        HDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    }
                    //判断客户不为龙山汽配
                    if (oSystemParameter.omodel.WMS_CampanyName != "龙山汽配" && oSystemParameter.omodel.WMS_CampanyName != "瑞与祺") //系统参数
                    if (oSystemParameter.omodel.WMS_CampanyName != "龙山汽配" && oSystemParameter.omodel.WMS_CampanyName != "瑞与祺" && oSystemParameter.omodel.WMS_CampanyName != "添康科技") //系统参数
                    {
                        if (HSourceID == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "生产资源没有选择!";
                            objJsonResult.Message = "[0000-2-006]生产资源没有选择!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -247,7 +255,7 @@
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "操作员没有选择!";
                                objJsonResult.Message = "[0000-2-030]操作员没有选择!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
@@ -260,7 +268,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "操作员没有选择!";
                            objJsonResult.Message = "[0000-2-030]操作员没有选择!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -272,7 +280,20 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "合格数量加报废数量加不良数量不能为0!";
                            objJsonResult.Message = "[3791-2-006]合格数量加报废数量加不良数量不能为0!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //判断当前工单是否开工
                    else if (oSystemParameter.omodel.MES_StationOutBill_MustBeginWorkCtl == "Y")
                    {
                        ds = oCN.RunProcReturn("select * from Sc_ICMOBillStatus_Tmp where HSourceID = '" + HSourceID + "' and HICMOBillNo = '" + HICMOBillNo + "' and HInterID = '" + HICMOInterID + "' and hicmostatus =1", "Sc_ICMOBillStatus_Tmp");
                        if (ds.Tables[0].Rows[0]["HICMOStatus"].ToString() != "1")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "[3791-2-007]当前工单不是开工状态不能汇报!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -282,7 +303,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "合格数量加报废数量不能为0!";
                            objJsonResult.Message = "[3791-2-008]合格数量加报废数量不能为0!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -352,7 +373,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存前判断失败!";
                    objJsonResult.Message = "[0000-2-012]保存前判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -360,7 +381,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.Message = "[0000-1-051]保存失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -377,7 +398,7 @@
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据号重复!";
                        objJsonResult.Message = "[0000-2-013]单据号重复!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -392,9 +413,9 @@
                    ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HLastSubProc" +
                    ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID,HPRDOrgID" +
                    ",HmaterOutqty,HProcPriceRate,HTemporaryAreaID,HWasterQty_Work,HWasterQty_Mater,HBackWorkQty,HShiftsID" +
                    ",HToCheckQty,HLossQty,HBackWorkByMaterQty,HMouldID" +
                    ",HToCheckQty,HLossQty,HBackWorkByMaterQty,HMouldID,HMachineWorkTimes " +
                    ") " +
                    " values('" + BillType + "','" + (OperationType == "5" ? "SUB" : HBillSubType)  + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" +
                    " values('" + BillType + "','" + (OperationType == "5" ? "SUB" : HBillSubType)  + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",'"+ HDate + "','" + HMaker + "',getdate(),'" + HMouldNum + "'" +
                    "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL +
                    "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID +
                    ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + "," + HPayProcID +
@@ -403,7 +424,7 @@
                    "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + Convert.ToString(HLastSubProc ? 1 : 0) +
                    "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + "," + HPRDOrgID +
                    "," + HmaterOutqty + "," + HProcPriceRate + "," + HTemporaryAreaID + "," + HWasterQty_Work + "," + HWasterQty_Mater + "," + HBackWorkQty +
                    "," + HShiftsID + "," + HToCheckQty + "," + HLossQty + ","+ HBackWorkByMaterQty + "," + HMouldID + ") ");
                    "," + HShiftsID + "," + HToCheckQty + "," + HLossQty + ","+ HBackWorkByMaterQty + "," + HMouldID + ",'" + HMachineWorkTimes + "') ");
                    LogService.Write($"4.新增结束,用时" + sw.Elapsed);
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增工序出站单据:" + HBillNo);
@@ -429,6 +450,8 @@
                    ",HSourceID4=" + HSourceID4 +
                    ",HSourceID5=" + HSourceID5 +
                    ",HPayProcID=" + HPayProcID +
                    ",HGroupID=" + HGroupID +
                    ",HShiftsID=" + HShiftsID +
                    ",HWorkTimes=" + HWorkTimes +
                    ",HSaveBillFlag=0 " +
                    ",HBadCount=" + HBadCount +
@@ -446,9 +469,9 @@
                    ",HWasterQty_Work=" + HWasterQty_Work +
                    ",HWasterQty_Mater=" + HWasterQty_Mater +
                    ",HBackWorkQty=" + HBackWorkQty +
                    ",HShiftsID=" + HShiftsID +
                    ",HBackWorkByMaterQty=" + HBackWorkByMaterQty +
                    ",HMouldID=" + HMouldID +
                    ",HMachineWorkTimes=" + HMachineWorkTimes +
                    " where HInterID=" + HInterID);
                    LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",修改工序出站单据:" + HBillNo);
@@ -459,7 +482,7 @@
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "操作类型无效!";
                    objJsonResult.Message = "[0000-2-014]操作类型无效!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -472,7 +495,7 @@
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "判断数量失败!";
                    objJsonResult.Message = "[0000-2-015]判断数量失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -482,7 +505,7 @@
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "判断数量失败!";
                    objJsonResult.Message = "[0000-2-015]判断数量失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -492,7 +515,7 @@
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "数量控制," + ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.Message = "[0000-2-015]数量控制," + ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -567,7 +590,7 @@
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存后控制判断失败!";
                    objJsonResult.Message = "[0000-2-016]保存后控制判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
@@ -577,7 +600,7 @@
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败2!" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.Message = "[0000-1-051]保存失败2!" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -589,6 +612,10 @@
                string sReturn = "";
                if (oSystemParameter.ShowBill(ref sReturn) == true)
                {
                    if (oSystemParameter.omodel.MES_StationOutBill_AutoCheck == "Y") //系统参数  自动审核
                    {
                        object objResult = set_CheckBill(HInterID.ToString(), user, HBillSubType);
                    }
                    if (oSystemParameter.omodel.MES_StationOutBill_SaveAutoAddnew == "Y") //系统参数  页面保存自动变成新增状态
                    {
                        objJsonResult.Verify = "Y";
@@ -601,9 +628,30 @@
                sw.Stop();//结束计时
                LogService.Write($"11.参数查询结束,新增结束,用时" + sw.Elapsed);
                LogService.Write("END--出站单据保存结束,出站单号:" + HBillNo);
                //测试语句===========================================================================================================
                string msg_str = "";
                string sql_str = "select a.HQty HQty_Main,b.HQty HQty_Sub " +
                            "from Sc_ProcessExchangeBillMain as a " +
                            "inner join Sc_ProcessExchangeBillSub as b on a.HInterID = b.HInterID " +
                            "where a.HInterID = " + HProcExchInterID;
                DataSet ds_str = oCN.RunProcReturn(sql_str, "Sc_ProcessExchangeBillMain");
                if (ds_str.Tables[0].Rows.Count > 0)
                {
                    msg_str = "HQty_Main:" + ds_str.Tables[0].Rows[0]["HQty_Main"].ToString() + ";HQty_Sub:";
                    for (int j = 0; j < ds_str.Tables[0].Rows.Count; j++)
                    {
                        msg_str += ds_str.Tables[0].Rows[j]["HQty_Sub"].ToString() + ",";
                    }
                }
                oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "修改工序出站单据:" + HBillNo + "[工序流转卡号:" + HProcExchBillNo + "]" + msg_str + "','LMES-工序出站模块','" + DBUtility.ClsPub.IPAddress + "','新增或修改单据'", ref DBUtility.ClsPub.sExeReturnInfo);
                //==============================================================================================================
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "新增单据成功!";
                objJsonResult.Message = "[0000-1-050]新增单据成功!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
@@ -613,7 +661,7 @@
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.Message = "[0000-1-051]Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -1611,7 +1659,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单无查询权限!";
                        objJsonResult.Message = "[0000-1-068]完工单无查询权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -1622,7 +1670,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单无查询权限!";
                        objJsonResult.Message = "[0000-1-068]出站单无查询权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -1643,7 +1691,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "没有查询到相关用户信息!";
                            objJsonResult.Message = "[0000-1-069]没有查询到相关用户信息!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -1677,7 +1725,7 @@
                //{
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.Message = "[0000-1-037]Sucess!";
                objJsonResult.list = columnNameList;
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
@@ -1695,7 +1743,103 @@
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.Message = "[0000-1-038]Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 返回工序出站汇报单列表-分页
        [Route("Cj_StationOutBill/get_Display_byPage")]
        [HttpGet]
        public object get_Display_byPage(string sWhere, string user, string Organization, int page, int size, string HBillSubType)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (HBillSubType == "SUB")
                {
                    //判断是否有查询权限
                    if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Sub_Query", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "[0000-1-068]完工单无查询权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断是否有查询权限
                    if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "[0000-1-068]出站单无查询权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                //获取系统参数
                string Ret = "";
                if (oSystemParameter.ShowBill(ref Ret))
                {
                    //判断客户为龙山汽配
                    if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配")
                    {
                        //获取需要拼接的字符串
                        string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "工序汇报单列表");
                        if (sql_splice == "没有查询到相关用户信息")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "[0000-1-069]没有查询到相关用户信息!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            sWhere += sql_splice;
                        }
                    }
                }
                //sWhere = sWhere.Replace("'", "''");
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_MES_StationOutBillList " + page + "," + size + ",'" + Organization + "'," + "''", "h_p_MES_StationOutBillList");
                }
                else
                {
                    ds = oCN.RunProcReturn("exec h_p_MES_StationOutBillList " + page + "," + size + ",'" + Organization + "','" + sWhere + "'", "h_p_MES_StationOutBillList");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                objJsonResult.Message = "[0000-1-037]Sucess!";
                objJsonResult.list = columnNameList;
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[0000-1-038]Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -1727,7 +1871,10 @@
                    case "Emp":
                        sql = "select * from h_v_Sc_StationOutBillSubQuery_Emp where 1 = 1 and HInterID=" + sWhere;
                        break;
                    case "Sup":
                        sql = "select * from h_v_Sc_StationOutBillSubQuery_Sup where 1 = 1 and HInterID=" + sWhere;
                        break;
                }
                ds = oCN.RunProcReturn(sql, TableName);
@@ -1743,7 +1890,7 @@
              
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.Message = "[0000-1-037]Sucess!";
                objJsonResult.list = columnNameList;
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
@@ -1752,7 +1899,7 @@
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.Message = "[0000-1-038]Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -1806,7 +1953,7 @@
            string HRemark = HttpContext.Current.Request.Params["HRemark"];  //备注
            string HUserName = HttpContext.Current.Request.Params["HUserName"];  //创建人
            HttpPostedFile files = HttpContext.Current.Request.Files["file"];
            string path = HttpContext.Current.Server.MapPath("~/../Files/" + HBillNo);
            string path = HttpContext.Current.Server.MapPath("~/../Files/Cj_StationOutBill/" + HBillNo);
            //string path = @"D:\\Files\\"+ HBillNo;
            dynamic dyResult = UpLoadFile(files, path, HBillNo, HRemark, HUserName);
            if (dyResult != null && dyResult.result == 1)
@@ -1862,7 +2009,7 @@
                {
                    File.Delete(fileurl);      //删除指定文件
                    files.SaveAs(fileurl);
                    string StrPath = "/files/"+ HBillNo+"/"+ filename;
                    string StrPath = "/files/Cj_StationOutBill/" + HBillNo+"/"+ filename;
                    if (File.Exists(fileurl)) 
                    {
                        //这里可以执行一些其它的操作,比如更新数据库
@@ -1885,7 +2032,7 @@
                {
                    Directory.CreateDirectory(fileSavePath); //添加文件夹
                    files.SaveAs(fileurl);
                    string StrPath = "/files/" + HBillNo + "/" + filename;
                    string StrPath = "/files/Cj_StationOutBill/" + HBillNo + "/" + filename;
                    if (File.Exists(fileurl))
                    {
                        //这里可以执行一些其它的操作,比如更新数据库
@@ -1926,7 +2073,7 @@
            string HRemark = HttpContext.Current.Request.Params["HRemark"];  //备注
            string HUserName = HttpContext.Current.Request.Params["HUserName"];  //创建人
            HttpPostedFile files = HttpContext.Current.Request.Files["file"];
            string path = HttpContext.Current.Server.MapPath("~/../Files/" + HBillNo);
            string path = HttpContext.Current.Server.MapPath("~/../Files/Cj_StationOutBill/" + HBillNo);
            //string path = @"D:\\Files\\"+ HBillNo;
            dynamic dyResult = UpLoadFile1(files, path, HBillNo, HRemark, HUserName);
            if (dyResult != null && dyResult.result == 1)
@@ -1982,7 +2129,7 @@
                {
                    File.Delete(fileurl);      //删除指定文件
                    files.SaveAs(fileurl);
                    string StrPath = "/files/" + HBillNo + "/" + filename;
                    string StrPath = "/files/Cj_StationOutBill/" + HBillNo + "/" + filename;
                    if (File.Exists(fileurl))
                    {
                        //这里可以执行一些其它的操作,比如更新数据库
@@ -2005,7 +2152,7 @@
                {
                    Directory.CreateDirectory(fileSavePath); //添加文件夹
                    files.SaveAs(fileurl);
                    string StrPath = "/files/" + HBillNo + "/" + filename;
                    string StrPath = "/files/Cj_StationOutBill/" + HBillNo + "/" + filename;
                    if (File.Exists(fileurl))
                    {
                        //这里可以执行一些其它的操作,比如更新数据库
@@ -2055,7 +2202,7 @@
        [HttpGet]
        public object Filelist(string HBillNo)
        {
            var url = fileip + "/files/" + HBillNo+"/";
            var url = fileip + "/files/Cj_StationOutBill/" + HBillNo+"/";
            //@"C:\\files\\"
            try
            {
@@ -2090,7 +2237,7 @@
            {
                oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID);
                string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/" + HSourceBillNo), HFileName);
                string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/Cj_StationOutBill/" + HSourceBillNo), HFileName);
                File.Delete(fileurl);      //删除指定文件
                objJsonResult.code = "1";
                objJsonResult.count = 1;
@@ -2125,7 +2272,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单无权限!";
                        objJsonResult.Message = "[0000-1-058]完工单无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2136,7 +2283,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单无权限!";
                        objJsonResult.Message = "[0000-1-058]出站单无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2154,7 +2301,7 @@
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "只能删除本人的单据!";
                                objJsonResult.Message = "[0000-1-011]只能删除本人的单据!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
@@ -2170,7 +2317,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "判断关联失败!";
                        objJsonResult.Message = "[0000-2-018]判断关联失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2178,7 +2325,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0][1]);
                        objJsonResult.Message = "[0000-1-007]" + Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0][1]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2186,7 +2333,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已经审核,不能删除!";
                        objJsonResult.Message = "[0000-1-013]单据已经审核,不能删除!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2197,7 +2344,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "系统参数控制,已有下道工序,不能删除!";
                        objJsonResult.Message = "[3791-1-002]系统参数控制,已有下道工序,不能删除!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2207,7 +2354,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除出站汇报单发生异常,没有任何返回记录!";
                        objJsonResult.Message = "[3791-1-005]删除出站汇报单发生异常,没有任何返回记录!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2217,7 +2364,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = ds.Tables[0].Rows[0]["HRemarkBack"].ToString();
                            objJsonResult.Message = "[0000-1-007]" + ds.Tables[0].Rows[0]["HRemarkBack"].ToString();
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -2231,7 +2378,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系";
                        objJsonResult.Message = "[0000-1-006]删除失败!原因:删除前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2240,7 +2387,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.Message = "[0000-1-007]删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2250,7 +2397,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.Message = "[0000-1-007]" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2262,7 +2409,7 @@
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "删除成功!";
                        objJsonResult.Message = "[0000-1-008]删除成功!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2271,7 +2418,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据未找到!";
                    objJsonResult.Message = "[0000-1-005]单据未找到!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -2281,7 +2428,7 @@
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "异常!" + e.ToString();
                objJsonResult.Message = "[0000-1-007]异常!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -2303,7 +2450,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单无权限!";
                        objJsonResult.Message = "[3791-1-001]完工单无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2315,7 +2462,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单无权限!";
                        objJsonResult.Message = "[3791-1-001]出站单无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2333,7 +2480,7 @@
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "只能删除本人的单据!";
                                objJsonResult.Message = "[0000-1-011]只能删除本人的单据!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
@@ -2349,7 +2496,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "判断关联失败!";
                        objJsonResult.Message = "[0000-2-018]判断关联失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2357,7 +2504,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0][1]);
                        objJsonResult.Message = "[0000-1-007]" + Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0][1]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2365,7 +2512,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已经审核,不能删除!";
                        objJsonResult.Message = "[0000-1-013]单据已经审核,不能删除!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2376,7 +2523,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "系统参数控制,已有下道工序,不能删除!";
                        objJsonResult.Message = "[3791-1-002]系统参数控制,已有下道工序,不能删除!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2399,7 +2546,7 @@
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除成功!";
                    objJsonResult.Message = "[0000-1-008]删除成功!";
                    objJsonResult.data = null;
                    return objJsonResult;
@@ -2408,7 +2555,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据未找到!";
                    objJsonResult.Message = "[0000-1-005]单据未找到!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -2418,7 +2565,7 @@
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "异常!" + e.ToString();
                objJsonResult.Message = "[0000-1-007]异常!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -2503,7 +2650,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "判断关联失败!";
                    objJsonResult.Message = "[0000-2-018]判断关联失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -2511,7 +2658,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0][1]);
                    objJsonResult.Message = "[0000-1-038]" + Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0][1]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -2519,7 +2666,7 @@
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "Sucess!";
                    objJsonResult.Message = "[0000-1-037]Sucess!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
@@ -2528,7 +2675,7 @@
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.Message = "[0000-1-038]Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -2549,7 +2696,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单审核失败!无权限!";
                        objJsonResult.Message = "[0000-1-060]完工单审核失败!无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2560,7 +2707,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单审核失败!无权限!";
                        objJsonResult.Message = "[0000-1-060]出站单审核失败!无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2577,7 +2724,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "第"+(i+1)+"行:单据ID为0,不能审核!";
                        objJsonResult.Message = "[0000-1-009]第" + (i+1)+"行:单据ID为0,不能审核!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2588,7 +2735,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + (i + 1) + "行:单据已审核!不能再次审核";
                            objJsonResult.Message = "[0000-1-023]第" + (i + 1) + "行:单据已审核!不能再次审核";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -2598,7 +2745,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "第" + (i + 1) + "行:单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.Message = "[0000-1-005]第" + (i + 1) + "行:单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2607,14 +2754,14 @@
                int j = 0;
                for (int i = 0; i < HInterIDs.Length; i++)
                {
                    //审核前控制
                    //审核前控制================================================================================
                    string sql = "exec h_p_Sc_StationOutBill_BeforeCheckCtrl " + HInterIDs[i] + ",'" + HBillNo[i] + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_StationOutBill_BeforeCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系";
                        objJsonResult.Message = "[0000-1-024]审核失败!原因:审核前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2623,11 +2770,11 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.Message = "[0000-1-025]审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //================================================================================
                    //审核
                    if (Cj_StationOutBillCheckBill(long.Parse(HInterIDs[i]), HBillNo[i], CurUserName, oBill.omodel.HLastSubProc, ref DBUtility.ClsPub.sExeReturnInfo))
@@ -2638,7 +2785,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "成功:" + j + "行,第" + (i + 1) + "行:审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.Message = "[0000-1-025]成功:" + j + "行,第" + (i + 1) + "行:审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2646,7 +2793,7 @@
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "全部执行成功!";
                objJsonResult.Message = "[0000-1-029]全部执行成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -2654,7 +2801,7 @@
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "审核失败!" + e.ToString();
                objJsonResult.Message = "[0000-1-025]审核失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -2703,7 +2850,7 @@
                    LogService.Write("出站单据审核更改流转卡数量,流转卡:" + HProcExchBillNo + ",出站单号:" + HBillNo + ",原流转卡数量:" + HProcExchQty + ",新流转卡数量:" + HQty);
                }
                //审核后控制
                //审核后控制================================================================================
                string sql = "exec h_p_Sc_StationOutBill_AfterCheckCtrl " + lngBillKey + ",'" + HBillNo + "','" + CurUserName + "'";
                ds = oCN.RunProcReturn(sql, "h_p_Sc_StationOutBill_AfterCheckCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
@@ -2718,7 +2865,7 @@
                    oCN.RollBack();
                    return false;
                }
                //================================================================================
                sReturn = sReturn + " 审核功能!";
                oCN.Commit();
@@ -2747,7 +2894,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单反审核失败!无权限!";
                        objJsonResult.Message = "[0000-1-061]完工单反审核失败!无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2759,7 +2906,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单反审核失败!无权限!";
                        objJsonResult.Message = "[0000-1-061]出站单反审核失败!无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2780,7 +2927,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "第" + (i + 1) + "行:单据ID为0,不能反审核!";
                        objJsonResult.Message = "[0000-1-009]第" + (i + 1) + "行:单据ID为0,不能反审核!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2792,7 +2939,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + (i + 1) + "行:单据未审核!不需要反审核!";
                            objJsonResult.Message = "[0000-1-018]第" + (i + 1) + "行:单据未审核!不需要反审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -2804,7 +2951,7 @@
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + (i + 1) + "行:审核人和反审核人不一致!";
                                objJsonResult.Message = "[0000-1-062]第" + (i + 1) + "行:审核人和反审核人不一致!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
@@ -2816,7 +2963,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "第" + (i + 1) + "行:单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.Message = "[0000-1-005]第" + (i + 1) + "行:单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2825,14 +2972,14 @@
                int j = 0;
                for (int i = 0; i < HInterIDs.Length; i++)
                {
                    //反审核前控制
                    //反审核前控制=============================================================
                    string sql = "exec h_p_Sc_StationOutBill_BeforeUnCheckCtrl " + HInterIDs[i] + ",'" + HBillNo[i] + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_StationOutBill_BeforeUnCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系";
                        objJsonResult.Message = "[0000-1-027]反审核失败!原因:反审核前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
@@ -2841,11 +2988,11 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.Message = "[0000-1-028]反审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //================================================================================
                    //反审核
                    if (Cj_StationOutBillAbandonCheckBill(long.Parse(HInterIDs[i]),HBillNo[i], CurUserName, oBill.omodel.HLastSubProc, ref DBUtility.ClsPub.sExeReturnInfo))
                    {
@@ -2855,7 +3002,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "成功:" + j + "行,第" + (i + 1) + "行:反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.Message = "[0000-1-028]成功:" + j + "行,第" + (i + 1) + "行:反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2863,7 +3010,7 @@
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "全部执行成功!";
                objJsonResult.Message = "[0000-1-019]全部执行成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -2871,7 +3018,7 @@
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "反审核失败!" + e.ToString();
                objJsonResult.Message = "[0000-1-028]反审核失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -2939,7 +3086,7 @@
                return false; ;
            }
        }
        #endregion
        #region 工序出站关闭/反关闭功能
        [Route("Cj_StationOutBill/CloseCj_StationOutBill")]
@@ -2955,7 +3102,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单无权限关闭!";
                        objJsonResult.Message = "[0000-1-063]完工单无权限关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2966,7 +3113,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单无权限关闭!";
                        objJsonResult.Message = "[0000-1-063]出站单无权限关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2977,7 +3124,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.Message = "[0000-1-009]HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -2999,17 +3146,41 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不需要再关闭!";
                            objJsonResult.Message = "[0000-1-033]单据已关闭!不需要再关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //关闭单据
                    if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    var HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                    //关闭前控制=========================================
                    string sql1 = "exec h_p_Sc_StationOutBill_BeforeCloseCtrl " + HInterID + ",'" + HBillNo + "','" + user + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Sc_StationOutBill_BeforeCloseCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.Message = "关闭失败!原因:关闭前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //==================================================================================
                    //关闭单据
                    if (!BillOld.CloseBill(Int64.Parse(HInterID), HBillNo, "h_p_Sc_StationOutBill_AfterCloseCtrl", user, ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "[0000-1-034]关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -3026,17 +3197,41 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反关闭!不需要再反关闭!";
                            objJsonResult.Message = "[0000-1-035]单据已反关闭!不需要再反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反关闭单据
                    if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    var HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                    //反关闭前控制=========================================
                    string sql1 = "exec h_p_Sc_StationOutBill_BeforeUnCloseCtrl " + HInterID + ",'" + HBillNo + "','" + user + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Sc_StationOutBill_BeforeUnCloseCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.Message = "反关闭失败!原因:反关闭前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //==================================================================================
                    //反关闭单据
                    if (!BillOld.CancelClose(Int64.Parse(HInterID), HBillNo, "h_p_Sc_StationOutBill_AfterUnCloseCtrl", user, ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "[0000-1-036]反关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -3046,7 +3241,7 @@
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "执行成功!";
                objJsonResult.Message = "[0000-1-064]执行成功!";
                objJsonResult.data = null;
                return objJsonResult; ;
@@ -3055,7 +3250,7 @@
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "执行失败!" + e.ToString();
                objJsonResult.Message = "[0000-1-034]执行失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -3064,7 +3259,7 @@
        //是否被关联
        #region //是否被关联
        public bool Cj_StationInBillisUse(Int64 lngBillKey, ref string sReturn)
        {
            try
@@ -3689,7 +3884,7 @@
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "";
                    objJsonResult.Message = "[0000-1-037]";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
@@ -3697,7 +3892,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "";
                    objJsonResult.Message = "[0000-1-010]";
                    return objJsonResult;
                }
@@ -3708,7 +3903,333 @@
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + e.ToString();
                objJsonResult.Message = "[0000-1-010]没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 保存生成白标
        public class WhiteLabelGeneration {
         public  string ProjectNo { get; set; }
         public  string OrderingCode { get; set; }
         public  string DrawVersionNumber { get; set; }
         public  string CustomerOrderNumber { get; set; }
         public  string WaybillNumber { get; set; }
         public  string HRemark { get; set; }
         public  string HBarCode_Pack { get; set; }
         public  string HBillType { get; set; }
        }
        [Route("Cj_StationOutBill_Detail/MES_WhiteLabelGeneration")]
        [HttpPost]
        public object MES_WhiteLabelGeneration([FromBody] JObject oMain)
        {
            try
            {
                oCN.BeginTran();
                var _value = oMain["oMain"].ToString();
                string msg1 = _value.ToString();
                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                string msg2 = sArray[0].ToString(); //主表数据
                WhiteLabelGeneration Main = Newtonsoft.Json.JsonConvert.DeserializeObject<WhiteLabelGeneration>(msg2);
                string HBillType = Main.HBillType;
                string ProjectNo = Main.ProjectNo;
                string OrderingCode = Main.OrderingCode;
                string DrawVersionNumber = Main.DrawVersionNumber;
                string CustomerOrderNumber = Main.CustomerOrderNumber;
                string WaybillNumber = Main.WaybillNumber;
                string HRemark = Main.HRemark;
                string HBarCode_Pack = Main.HBarCode_Pack;
                ds = oCN.RunProcReturn($"exec h_p_MES_HBarCode_White_SMR_15 '{HBillType}','{ProjectNo}','{OrderingCode}','{DrawVersionNumber}','{CustomerOrderNumber}','{WaybillNumber}','{HRemark}','{HBarCode_Pack}'", "h_p_MES_HBarCode_White_SMR_15");
                string HBarCode_White = ds.Tables[0].Rows[0]["HBarCode_White"].ToString();
                if (HBarCode_White == "")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "生成白标失败,单据标识:" + HBarCode_Pack + "!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.RunProc("update Sc_PackUnionBillMain set HBarCode_White='" + HBarCode_White + "' where HBarCode_Pack='" + HBarCode_Pack + "'");
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 下推质量汇报单时返回工序出站汇报单信息
        [Route("Cj_StationOutBill/PushDownBackInfo")]
        [HttpGet]
        public object PushDownBackInfo(string linterid, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                ds = oCN.RunProcReturn("select * from h_v_Sc_StationOutBill_PushDownBackInfo where hmainid in (" + linterid + ")", "h_v_Sc_StationOutBill_PushDownBackInfo");
                if (ds.Tables[0].Rows.Count > 0 && ds != null)
                {
                    //添加列名
                    foreach (DataColumn col in ds.Tables[0].Columns)
                    {
                        Type dataType = col.DataType;
                        string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                        columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                    }
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "Sucess!";
                    objJsonResult.list = columnNameList;
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无数据";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 编辑页面根据id获取工序出站汇报单信息
        [Route("Cj_StationOutBill/SetBillTime")]
        [HttpGet]
        public object SetBillTime(int HInterID,DateTime dateTime,string user)
        {
            try
            {
                //判断是否有编辑权限
                if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-065]出站单无编辑权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                string sql = "select * from Sc_StationOutBillMain  with(nolock) where HInterID=" + HInterID;
                ds = oCN.RunProcReturn(sql, "Sc_StationOutBillMain");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[3791-1-003]修改失败没找到相关出站汇报单";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //修改前时间修改后时间判断有无工资计算
                string HGroupID = ds.Tables[0].Rows[0]["HGroupID"].ToString();
                string HOldDate = ds.Tables[0].Rows[0]["HDate"].ToString();
                string sql1 = "select * from Pay_SingleBalBillMain where HGroupID =" +HGroupID + " and HDate ='" + HOldDate + "'";
                string sql2 = "select * from Pay_GroupBalBillMain where HGroupID =" + HGroupID + " and HDate ='" + HOldDate + "'";
                string sql3 = "select * from Pay_SingleBalBillMain where HGroupID =" + HGroupID + " and HDate ='" + dateTime + "'";
                string sql4 = "select * from Pay_GroupBalBillMain where HGroupID =" + HGroupID + " and HDate ='" + dateTime + "'";
                ds = oCN.RunProcReturn(sql1, "Sc_StationOutBillMain");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[3791-1-004]修改失败该时间班组已计算工资:" + HOldDate;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn(sql2, "Sc_StationOutBillMain");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[3791-1-004]修改失败该时间班组已计算工资:" + HOldDate;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn(sql3, "Sc_StationOutBillMain");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[3791-1-004]修改失败该时间班组已计算工资:" + dateTime;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn(sql4, "Sc_StationOutBillMain");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[3791-1-004]修改失败该时间班组已计算工资:" + dateTime;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //修改时间
                sql = "update Sc_StationOutBillMain set HDate = '" + dateTime + "' where HInterID = " + HInterID;
                oCN.RunProcReturn(sql, "Sc_StationOutBillMain");
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "[0000-1-067]Sucess!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[0000-1-066]Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 出站单列表-下推PPM数据录入保存,删除
        [Route("Cj_StationOutBill/PPMSupAddBill")]
        [HttpPost]
        public object PPMSupAddBill([FromBody] JObject sSubStr)
        {
            var _value = sSubStr["sSubStr"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            try
            {
                //反序列化
                string msg2 = sArray[0].ToString(); //表体
                string refSav = sArray[1].ToString();//操作类型
                string user = sArray[2].ToString(); //用户
                msg2 = msg2.Substring(1, msg2.Length - 2);
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");
                msg2 = "[" + msg2 + "]";
                //判断是否有编辑权限
                if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无编辑权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                List<Sc_StationOutBillSub_Sup> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Sc_StationOutBillSub_Sup>>(msg2);
                oCN.BeginTran();
                for (int i = 0; i < list.Count; i++)
                {
                    int HInterID = list[i].HInterID;
                    int HEntryID = i+1;
                    int HSupID = list[i].HSupID;
                    double HWasterQty_Mater = list[i].HWasterQty_Mater;
                    double HBackWorkQty = list[i].HBackWorkQty;
                    oCN.RunProc("Insert Into Sc_StationOutBillSub_Sup " +
                     "(HInterID, HEntryID, HSupID, HWasterQty_Mater, HBackWorkQty) " +
                     "values ('" + HInterID + "', '" + HEntryID + "', '" + HSupID + "', '" + HWasterQty_Mater + "', '" + HBackWorkQty + "')");
                }
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "新增单据成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        [Route("Cj_StationOutBill/PPMSupDelete")]
        [HttpGet]
        public object PPMSupDelete(int HInterID,string user)
        {
            try
            {
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-058]无删除权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("select * from Sc_StationOutBillSub_Sup WITH(NOLOCK) where HInterID = " + HInterID, "Sc_StationOutBillSub_Sup");
                if (ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-1-045]查无数据!";
                    objJsonResult.data = null;
                }
                oCN.BeginTran();
                string sql = "";
                sql = "delete from Sc_StationOutBillSub_Sup where HInterID = " + HInterID;
                oCN.RunProc(sql);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "[0000-1-037]Sucess!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[0000-1-038]Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }