chenhaozhe
5 天以前 47b45a4ac3284936515a2edd3e50265de30993a0
WebAPI/Controllers/BaseSet/Gy_ProcessController.cs
@@ -20,6 +20,7 @@
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        #region 工序 文件上传
        [Route("Gy_Process/Gy_Process_Excel")]
@@ -28,6 +29,9 @@
        {
            try
            {
                string Ret = "";
                oSystemParameter.ShowBill(ref Ret);
                //获取文件名称
                var file = HttpContext.Current.Request.Files[0];
                //获取文件物理路径
@@ -114,6 +118,8 @@
                if (!tb2.Columns.Contains("巡检质检方案名称"))
                    error += "没有找到【巡检质检方案名称】的标题,";
                if (!tb2.Columns.Contains("工序分类"))
                    error += "没有找到【工序分类】的标题,";
                if (error.Length > 0)
@@ -129,6 +135,7 @@
                {
                    string HProcessName = "";
                    string HProcessNum = "";
                    string HProcType = "";
                    string HORGNumber = "";
                    string HORGName = "";
                    string HDeptNum = "";
@@ -144,6 +151,7 @@
                    HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["工序名称"].ToString());
                    HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["工序代码"].ToString());
                    HProcType = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["工序分类"].ToString());
                    HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString());
                    HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString());
                    HDeptNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["部门代码"].ToString());
@@ -182,83 +190,166 @@
                        }
                        string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        //查询部门
                        ds = oCN.RunProcReturn("select * from Gy_Department where  HNumber='" + HDeptNum + "'  and HUSEORGID=" + HORGid + "", "Gy_Department");
                        if (ds.Tables[0].Rows.Count == 0)
                        if (oSystemParameter.omodel.WMS_CampanyName == "宝工")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,部门:" + HDeptName + ",不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                            if (HProcType == "")
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,工序分类不能为空!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            //查询部门
                            ds = oCN.RunProcReturn("select * from Gy_Department where  HNumber='" + HDeptNum + "'  and HUSEORGID=" + HORGid + "", "Gy_Department");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                tb2.Rows[i]["HDeptID"] = 0;
                            }
                            else
                            {
                                tb2.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                            }
                            //查询首件质检方案
                            ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Fst + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                tb2.Rows[i]["HQCSchemeID_Fst"] = 0;
                            }
                            else
                            {
                                tb2.Rows[i]["HQCSchemeID_Fst"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                            }
                            //查询工序质检方案
                            ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Proc + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                tb2.Rows[i]["HQCSchemeID_Proc"] = 0;
                            }
                            else
                            {
                                tb2.Rows[i]["HQCSchemeID_Proc"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                            }
                            //查询巡检质检方案
                            ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Patrol + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                tb2.Rows[i]["HQCSchemeID_Patrol"] = 0;
                            }
                            else
                            {
                                tb2.Rows[i]["HQCSchemeID_Patrol"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                            }
                            //查询工作中心
                            ds = oCN.RunProcReturn("select * from Gy_WorkCenter where  HNumber='" + HCentNum + "' and HUSEORGID=" + HORGid + "", "Gy_WorkCenter"); //
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                tb2.Rows[i]["HWorkCenterID"] = 0;
                            }
                            else
                            {
                                tb2.Rows[i]["HWorkCenterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                            }
                        }
                        else
                        {
                            tb2.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        }
                            //查询部门
                            ds = oCN.RunProcReturn("select * from Gy_Department where  HNumber='" + HDeptNum + "'  and HUSEORGID=" + HORGid + "", "Gy_Department");
                        //查询首件质检方案
                        ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Fst + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,部门:" + HDeptName + ",不存在!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                tb2.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                            }
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,首件质检方案:" + HQCSchemeName_Fst + ",不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HQCSchemeID_Fst"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                        }
                        //查询工序质检方案
                        ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Proc + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            //查询首件质检方案
                            ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Fst + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,工序质检方案:" + HQCSchemeName_Proc + ",不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HQCSchemeID_Proc"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                        }
                        //查询巡检质检方案
                        ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Patrol + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,首件质检方案:" + HQCSchemeName_Fst + ",不存在!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                tb2.Rows[i]["HQCSchemeID_Fst"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                            }
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,巡检质检方案:" + HQCSchemeName_Patrol + ",不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HQCSchemeID_Patrol"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                        }
                            //查询工序质检方案
                            ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Proc + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                        //查询工作中心
                        ds = oCN.RunProcReturn("select * from Gy_WorkCenter where  HNumber='" + HCentNum + "' and HUSEORGID=" + HORGid + "", "Gy_WorkCenter"); //
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,工序质检方案:" + HQCSchemeName_Proc + ",不存在!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                tb2.Rows[i]["HQCSchemeID_Proc"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                            }
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,工作中心:" + HCentName + ",不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HWorkCenterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                            //查询巡检质检方案
                            ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Patrol + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,巡检质检方案:" + HQCSchemeName_Patrol + ",不存在!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                tb2.Rows[i]["HQCSchemeID_Patrol"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                            }
                            //查询工作中心
                            ds = oCN.RunProcReturn("select * from Gy_WorkCenter where  HNumber='" + HCentNum + "' and HUSEORGID=" + HORGid + "", "Gy_WorkCenter"); //
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,工作中心:" + HCentName + ",不存在!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                tb2.Rows[i]["HWorkCenterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                            }
                            //工序代码
                            if (HProcessNum == "")
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,工序资源代码不能为空!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                        }
                        //工序名称
@@ -271,15 +362,7 @@
                            return objJsonResult;
                        }
                        //工序代码
                        if (HProcessNum == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,工序资源代码不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    else
                    {
@@ -320,6 +403,9 @@
            string user = sArray[1].ToString();
            try
            {
                string Ret = "";
                oSystemParameter.ShowBill(ref Ret);
                if (!DBUtility.ClsPub.Security_Log("Gy_Porcess_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
@@ -354,6 +440,7 @@
                    string HQCSchemeID_Patrol = item["HQCSchemeID_Patrol"].ToString();//巡检质检方案ID
                    string HProcessName = item["工序名称"].ToString();
                    string HProcessNum = item["工序代码"].ToString();
                    string HProcType = item["工序分类"].ToString();
                    string sShortNumber;
                    sShortNumber = DBUtility.ClsPub.GetShortNumber(HProcessNum);//短代码
                    if (sShortNumber.Trim() == "")
@@ -377,18 +464,25 @@
                        return objJsonResult;
                    }
                    ds = oCN.RunProcReturn("select * from Gy_Process where HNumber='" + HProcessNum + "'", "Gy_Source");
                    if (oSystemParameter.omodel.WMS_CampanyName == "宝工")
                    {
                        ds = oCN.RunProcReturn("select * from Gy_Process where HName='" + HProcessName + "'", "Gy_Process");
                    }
                    else
                    {
                        ds = oCN.RunProcReturn("select * from Gy_Process where HNumber='" + HProcessNum + "'", "Gy_Source");
                    }
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        string sql = "insert into Gy_Process(HName,HNumber,HDeptID,HUSEORGID,HCREATEORGID,HWorkCenterID,HShortNumber,HQCSchemeID_Fst,HQCSchemeID_Proc,HQCSchemeID_Patrol,HEndFlag,HLevel,HHelpCode,HParentID,HStopflag,HRemark,HTypeFlow,HTypeCount)" +
                            $"values('{HProcessName}', '{HProcessNum}',{HDeptID}, {HOrgID}, {HOrgID}, {HWorkCenterID}, '{sShortNumber}',{HQCSchemeID_Fst},{HQCSchemeID_Proc},{HQCSchemeID_Patrol},{HEndFlag},{HLevel},'',0,0,'',0,0)";
                        string sql = "insert into Gy_Process(HName,HNumber,HDeptID,HUSEORGID,HCREATEORGID,HWorkCenterID,HShortNumber,HQCSchemeID_Fst,HQCSchemeID_Proc,HQCSchemeID_Patrol,HEndFlag,HLevel,HHelpCode,HParentID,HStopflag,HRemark,HTypeFlow,HTypeCount,HProcType)" +
                            $"values('{HProcessName}', '{HProcessNum}',{HDeptID}, {HOrgID}, {HOrgID}, {HWorkCenterID}, '{sShortNumber}',{HQCSchemeID_Fst},{HQCSchemeID_Proc},{HQCSchemeID_Patrol},{HEndFlag},{HLevel},'',0,0,'',0,0,'{HProcType}')";
                        oCN.RunProc(sql);
                    }
                    else
                    {
                        oCN.RunProc("   update  Gy_Process set HWorkCenterID=" + HWorkCenterID + ",HDeptID=" + HDeptID + ",HQCSchemeID_Fst=" + HQCSchemeID_Fst + ",HQCSchemeID_Proc=" + HQCSchemeID_Proc + ",HQCSchemeID_Patrol=" + HQCSchemeID_Patrol + "  where HNumber='" + HProcessNum + "'");
                        oCN.RunProc("   update  Gy_Process set HWorkCenterID=" + HWorkCenterID + ",HDeptID=" + HDeptID + ",HQCSchemeID_Fst=" + HQCSchemeID_Fst + ",HQCSchemeID_Proc=" + HQCSchemeID_Proc + ",HQCSchemeID_Patrol=" + HQCSchemeID_Patrol + ",HProcType = '" + HProcType + "'  where HNumber='" + HProcessNum + "'");
                    }
                    i++;
@@ -695,6 +789,7 @@
                long HItemID = list[0].HItemID;
                string HNumber = list[0].HNumber;
                string HName = list[0].HName;
                string HProcType = list[0].HProcType;
                string HShortNumber = list[0].HNumber;
                long HParentID = list[0].HParentID;
                string HHelpCode = list[0].HHelpCode;
@@ -814,14 +909,14 @@
                         ",HLevel,HEndFlag,HStopflag,HRemark,HDeptID,HBarCodeForBase,HProcessID_K3,HBillSubType,HAutoTrunFlag" +
                         ",HFixPrice,HOverFixPrice,HProcMulID,HProcCheckNote" +
                         ",HUSEORGID,HCREATEORGID,HWorkCenterID,HBadWHID,HWasterWHID,HBadCountDevelopWHID,HWWBadWHID,HWWWasterWHID,HWHID,HTProcessFlag" +
                         ",HQCSchemeID_Fst,HQCSchemeID_Proc,HQCSchemeID_Patrol,HPayMentType,HMakeTime,HMakeEmp,HStandardWages) " +
                         ",HQCSchemeID_Fst,HQCSchemeID_Proc,HQCSchemeID_Patrol,HPayMentType,HMakeTime,HMakeEmp,HStandardWages,HProcType) " +
                         " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID.ToString() +
                         "," + Convert.ToString(HTypeFlow ? 1 : 0) + "," + Convert.ToString(HTypeCount ? 1 : 0) + ",'" + HDeptNumber + "','" + HSNo.ToString() + "','" + HUseFlag.ToString() +
                         "'," + HLevel.ToString() + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "'," + HDeptID +
                         ",'" + HBarCodeForBase + "'," + HProcessID_K3 + ",'" + HBillSubType + "'," + Convert.ToString(HAutoTrunFlag ? 1 : 0) +
                         ",'" + HFixPrice.ToString() + "'," + HOverFixPrice.ToString() + "," + HProcMulID.ToString() + ",'" + HProcCheckNote.ToString() + "'" +
                         "," + HUSEORGID + "," + HCREATEORGID + "," + HWorkCenterID + "," + HBadWHID + "," + HWasterWHID + "," + HBadCountDevelopWHID + "," + HWWBadWHID + "," + HWWWasterWHID + "," + HWHID + "," + Convert.ToString(HTProcessFlag ? 1 : 0) + "," + HQCSchemeID_Fst + "," + HQCSchemeID_Proc + "," + HQCSchemeID_Patrol
                         + ",'" + HPayMentType + "',getdate(),'" + HMakeEmp + "'," + HStandardWages + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                         + ",'" + HPayMentType + "',getdate(),'" + HMakeEmp + "'," + HStandardWages + ",'" + HProcType + "' )", ref DBUtility.ClsPub.sExeReturnInfo);
                       
                    //修改上级为非末级代码
                    oCN.RunProc("Update Gy_Process set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
@@ -933,7 +1028,9 @@
                        ",HStandardWages= " + HStandardWages +                        
                        ",HModifyTime= getdate()" +
                        ",HModifyEmp='" + HMakeEmp + "'" +
                        ",HProcCheckNote='" + HProcCheckNote + "' Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                        ",HProcCheckNote='" + HProcCheckNote + "' " +
                        ",HProcType = '" + HProcType + "' " +
                        " Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                    //修改上级为非末级代码
                    oCN.RunProc("Update Gy_Process set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);