wtt
2025-04-02 9cfdb479a1083fc9615779edcff50472319dd387
WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
@@ -52,7 +52,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单无编辑权限!";
                        objJsonResult.Message = "[0000-1-065]完工单无编辑权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -63,7 +63,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单无编辑权限!";
                        objJsonResult.Message = "[0000-1-065]出站单无编辑权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -152,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 );
                //单据完整性判断
@@ -160,7 +160,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "流转卡没有选择!请扫描条形码或输入条形码后回车";
                    objJsonResult.Message = "[3791-2-005]流转卡没有选择!请扫描条形码或输入条形码后回车";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -168,7 +168,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "流水号没有选择!请输入流水号后回车";
                    objJsonResult.Message = "[0000-2-032]流水号没有选择!请输入流水号后回车";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -176,7 +176,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "流水号没有选择!";
                    objJsonResult.Message = "[0000-2-032]流水号没有选择!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -184,7 +184,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "流转卡号没有选择!";
                    objJsonResult.Message = "[0000-2-032]流转卡号没有选择!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -192,7 +192,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "产品没有选择!";
                    objJsonResult.Message = "[0000-2-007]产品没有选择!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -209,7 +209,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "当前工序没有选择!";
                    objJsonResult.Message = "[0000-2-011]当前工序没有选择!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -226,6 +226,12 @@
                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 != "瑞与祺" && oSystemParameter.omodel.WMS_CampanyName != "添康科技") //系统参数                      
                    {
@@ -233,7 +239,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "生产资源没有选择!";
                            objJsonResult.Message = "[0000-2-006]生产资源没有选择!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -249,7 +255,7 @@
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "操作员没有选择!";
                                objJsonResult.Message = "[0000-2-030]操作员没有选择!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
@@ -262,7 +268,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "操作员没有选择!";
                            objJsonResult.Message = "[0000-2-030]操作员没有选择!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -274,7 +280,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "合格数量加报废数量加不良数量不能为0!";
                            objJsonResult.Message = "[3791-2-006]合格数量加报废数量加不良数量不能为0!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -287,7 +293,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "当前工单不是开工状态不能汇报!";
                            objJsonResult.Message = "[3791-2-007]当前工单不是开工状态不能汇报!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -297,7 +303,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "合格数量加报废数量不能为0!";
                            objJsonResult.Message = "[3791-2-008]合格数量加报废数量不能为0!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -367,7 +373,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存前判断失败!";
                    objJsonResult.Message = "[0000-2-012]保存前判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -375,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;
                }
@@ -392,7 +398,7 @@
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据号重复!";
                        objJsonResult.Message = "[0000-2-013]单据号重复!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -407,7 +413,7 @@
                    ",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 + ",'"+ HDate + "','" + HMaker + "',getdate(),'" + HMouldNum + "'" +
                    "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL +
@@ -418,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);
@@ -445,6 +451,7 @@
                    ",HSourceID5=" + HSourceID5 +
                    ",HPayProcID=" + HPayProcID +
                    ",HGroupID=" + HGroupID +
                    ",HShiftsID=" + HShiftsID +
                    ",HWorkTimes=" + HWorkTimes +
                    ",HSaveBillFlag=0 " +
                    ",HBadCount=" + HBadCount +
@@ -462,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);
@@ -475,7 +482,7 @@
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "操作类型无效!";
                    objJsonResult.Message = "[0000-2-014]操作类型无效!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -488,7 +495,7 @@
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "判断数量失败!";
                    objJsonResult.Message = "[0000-2-015]判断数量失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -498,7 +505,7 @@
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "判断数量失败!";
                    objJsonResult.Message = "[0000-2-015]判断数量失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -508,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;
                }
@@ -583,7 +590,7 @@
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存后控制判断失败!";
                    objJsonResult.Message = "[0000-2-016]保存后控制判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
@@ -593,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;
                }
@@ -605,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";
@@ -617,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;
            }
@@ -629,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;
            }
@@ -1627,7 +1659,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单无查询权限!";
                        objJsonResult.Message = "[0000-1-068]完工单无查询权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -1638,7 +1670,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单无查询权限!";
                        objJsonResult.Message = "[0000-1-068]出站单无查询权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -1659,7 +1691,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "没有查询到相关用户信息!";
                            objJsonResult.Message = "[0000-1-069]没有查询到相关用户信息!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -1693,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;
@@ -1711,38 +1743,81 @@
            {
                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/page")]
        #region 返回工序出站汇报单列表-分页
        [Route("Cj_StationOutBill/get_Display_byPage")]
        [HttpGet]
        public json page(string sWhere, string user, int page, int size)
        public object get_Display_byPage(string sWhere, string user, string Organization, int page, int size, string HBillSubType)
        {
            json res = new json();
            try
            {
                List<object> columnNameList = new List<object>();
                    //判断是否有查询权限
             if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user))
                    {
                        res.code = "0";
                        res.count = 0;
                        res.Message = "出站单无查询权限!";
                        res.data = null;
                        return res;
                    }
                if (sWhere == null || sWhere.Equals(""))
                if (HBillSubType == "SUB")
                {
                    ds = oCN.RunProcReturn("exec h_p_MES_StationOutBillList " + page + "," + size + ",''", "h_p_MES_StationOutBillList");
                    //判断是否有查询权限
                    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
                {
                    ds = oCN.RunProcReturn("exec h_p_MES_StationOutBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_MES_StationOutBillList");
                    //判断是否有查询权限
                    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");
                }
                //添加列名
@@ -1753,23 +1828,24 @@
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                res.code = CodeConstant.SUCCEED;
                res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                res.Message = "Sucess!";
                res.list = columnNameList;
                res.data = ds.Tables[0];
                return res;
                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)
            {
                res.code = CodeConstant.FAIL;
                res.count = CountConstant.FAIL;
                res.Message = "Exception!" + e.ToString();
                res.data = null;
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[0000-1-038]Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 工序出站汇报单 子表查询
        [Route("Cj_StationOutBill/get_SubDisplay")]
        [HttpGet]
@@ -1795,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);
@@ -1811,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;
@@ -1820,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;
            }
@@ -1874,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)
@@ -1930,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)) 
                    {
                        //这里可以执行一些其它的操作,比如更新数据库
@@ -1953,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))
                    {
                        //这里可以执行一些其它的操作,比如更新数据库
@@ -1994,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)
@@ -2050,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))
                    {
                        //这里可以执行一些其它的操作,比如更新数据库
@@ -2073,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))
                    {
                        //这里可以执行一些其它的操作,比如更新数据库
@@ -2123,7 +2202,7 @@
        [HttpGet]
        public object Filelist(string HBillNo)
        {
            var url = fileip + "/files/" + HBillNo+"/";
            var url = fileip + "/files/Cj_StationOutBill/" + HBillNo+"/";
            //@"C:\\files\\"
            try
            {
@@ -2158,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;
@@ -2193,7 +2272,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单无权限!";
                        objJsonResult.Message = "[0000-1-058]完工单无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2204,7 +2283,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单无权限!";
                        objJsonResult.Message = "[0000-1-058]出站单无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2222,7 +2301,7 @@
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "只能删除本人的单据!";
                                objJsonResult.Message = "[0000-1-011]只能删除本人的单据!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
@@ -2238,7 +2317,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "判断关联失败!";
                        objJsonResult.Message = "[0000-2-018]判断关联失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2246,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;
                    }
@@ -2254,7 +2333,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已经审核,不能删除!";
                        objJsonResult.Message = "[0000-1-013]单据已经审核,不能删除!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2265,7 +2344,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "系统参数控制,已有下道工序,不能删除!";
                        objJsonResult.Message = "[3791-1-002]系统参数控制,已有下道工序,不能删除!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2275,7 +2354,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除出站汇报单发生异常,没有任何返回记录!";
                        objJsonResult.Message = "[3791-1-005]删除出站汇报单发生异常,没有任何返回记录!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2285,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;
                        }
@@ -2299,7 +2378,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系";
                        objJsonResult.Message = "[0000-1-006]删除失败!原因:删除前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2308,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;
                    }
@@ -2318,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;
                    }
@@ -2330,7 +2409,7 @@
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "删除成功!";
                        objJsonResult.Message = "[0000-1-008]删除成功!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2339,7 +2418,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据未找到!";
                    objJsonResult.Message = "[0000-1-005]单据未找到!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -2349,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;
            }
@@ -2371,7 +2450,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单无权限!";
                        objJsonResult.Message = "[3791-1-001]完工单无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2383,7 +2462,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单无权限!";
                        objJsonResult.Message = "[3791-1-001]出站单无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2401,7 +2480,7 @@
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "只能删除本人的单据!";
                                objJsonResult.Message = "[0000-1-011]只能删除本人的单据!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
@@ -2417,7 +2496,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "判断关联失败!";
                        objJsonResult.Message = "[0000-2-018]判断关联失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2425,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;
                    }
@@ -2433,7 +2512,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已经审核,不能删除!";
                        objJsonResult.Message = "[0000-1-013]单据已经审核,不能删除!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2444,7 +2523,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "系统参数控制,已有下道工序,不能删除!";
                        objJsonResult.Message = "[3791-1-002]系统参数控制,已有下道工序,不能删除!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2467,7 +2546,7 @@
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除成功!";
                    objJsonResult.Message = "[0000-1-008]删除成功!";
                    objJsonResult.data = null;
                    return objJsonResult;
@@ -2476,7 +2555,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据未找到!";
                    objJsonResult.Message = "[0000-1-005]单据未找到!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -2486,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;
            }
@@ -2571,7 +2650,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "判断关联失败!";
                    objJsonResult.Message = "[0000-2-018]判断关联失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -2579,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;
                }
@@ -2587,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;
                }
@@ -2596,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;
            }
@@ -2617,7 +2696,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单审核失败!无权限!";
                        objJsonResult.Message = "[0000-1-060]完工单审核失败!无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2628,7 +2707,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单审核失败!无权限!";
                        objJsonResult.Message = "[0000-1-060]出站单审核失败!无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2645,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;
                    }
@@ -2656,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;
                        }
@@ -2666,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;
                    }
@@ -2675,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;
                    }
@@ -2691,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))
@@ -2706,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;
                    }
@@ -2714,7 +2793,7 @@
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "全部执行成功!";
                objJsonResult.Message = "[0000-1-029]全部执行成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -2722,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;
            }
@@ -2771,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)
@@ -2786,7 +2865,7 @@
                    oCN.RollBack();
                    return false;
                }
                //================================================================================
                sReturn = sReturn + " 审核功能!";
                oCN.Commit();
@@ -2815,7 +2894,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单反审核失败!无权限!";
                        objJsonResult.Message = "[0000-1-061]完工单反审核失败!无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2827,7 +2906,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单反审核失败!无权限!";
                        objJsonResult.Message = "[0000-1-061]出站单反审核失败!无权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -2848,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;
                    }
@@ -2860,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;
                        }
@@ -2872,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;
                            }
@@ -2884,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;
                    }
@@ -2893,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;
@@ -2909,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))
                    {
@@ -2923,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;
                    }
@@ -2931,7 +3010,7 @@
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "全部执行成功!";
                objJsonResult.Message = "[0000-1-019]全部执行成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -2939,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;
            }
@@ -3007,7 +3086,7 @@
                return false; ;
            }
        }
        #endregion
        #region 工序出站关闭/反关闭功能
        [Route("Cj_StationOutBill/CloseCj_StationOutBill")]
@@ -3023,7 +3102,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "完工单无权限关闭!";
                        objJsonResult.Message = "[0000-1-063]完工单无权限关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -3034,7 +3113,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "出站单无权限关闭!";
                        objJsonResult.Message = "[0000-1-063]出站单无权限关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
@@ -3045,7 +3124,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.Message = "[0000-1-009]HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
@@ -3067,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;
                    }
@@ -3094,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;
                    }
@@ -3114,7 +3241,7 @@
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "执行成功!";
                objJsonResult.Message = "[0000-1-064]执行成功!";
                objJsonResult.data = null;
                return objJsonResult; ;
@@ -3123,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;
            }
@@ -3132,7 +3259,7 @@
        //是否被关联
        #region //是否被关联
        public bool Cj_StationInBillisUse(Int64 lngBillKey, ref string sReturn)
        {
            try
@@ -3757,7 +3884,7 @@
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "";
                    objJsonResult.Message = "[0000-1-037]";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
@@ -3765,7 +3892,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "";
                    objJsonResult.Message = "[0000-1-010]";
                    return objJsonResult;
                }
@@ -3776,7 +3903,7 @@
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + e.ToString();
                objJsonResult.Message = "[0000-1-010]没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -3852,5 +3979,261 @@
        }
        #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;
            }
        }
        #endregion
    }
}