chenhaozhe
2026-03-09 f9bfd801a3d62f02e0b714c19323fc4f3723ab79
WebAPI/Controllers/»ù´¡×ÊÁÏ/»ù´¡×ÊÁÏ/Gy_WorkStationBillController.cs
@@ -79,11 +79,14 @@
                string msg1 = _value.ToString();
                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                string msg2 = sArray[0].ToString();
                string msg3 = sArray[1].ToString();
                string msg3 = sArray[2].ToString();
                string msg4 = sArray[1].ToString();//子表
                //反序列化
                msg2 = "[" + msg2.ToString() + "]";
                List<WorkStation> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<WorkStation>>(msg2);
                List<WorkStationSub> subList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<WorkStationSub>>(msg4);
                long HItemID = list[0].HItemID;
                string HNumber = list[0].HNumber;
@@ -98,40 +101,42 @@
                long HUSEORGID = list[0].HUSEORGID;
                long HCREATEORGID = list[0].HCREATEORGID;
                #region [注释代码]
                ////判断权限
                //if (!ClsPub.Security_Log("Gy_Warehouse_Edit", 1, false, msg3))
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "没有找到该功能模块!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                //if (!DBUtility.ClsPub.AllowNumber(HNumber))
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "代码中不能出现连续‘.’并且首位末位不能为‘.’!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                    #region [注释代码]
                    ////判断权限
                    //if (!ClsPub.Security_Log("Gy_Warehouse_Edit", 1, false, msg3))
                    //{
                    //    objJsonResult.code = "0";
                    //    objJsonResult.count = 0;
                    //    objJsonResult.Message = "没有找到该功能模块!";
                    //    objJsonResult.data = null;
                    //    return objJsonResult;
                    //}
                //if (oDept.HavSameNumber(HItemID, HNumber))
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "代码重复!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                #endregion
                    //if (!DBUtility.ClsPub.AllowNumber(HNumber))
                    //{
                    //    objJsonResult.code = "0";
                    //    objJsonResult.count = 0;
                    //    objJsonResult.Message = "代码中不能出现连续‘.’并且首位末位不能为‘.’!";
                    //    objJsonResult.data = null;
                    //    return objJsonResult;
                    //}
                //保存
                //保存完毕后处理
                if (HItemID == 0)
                    //if (oDept.HavSameNumber(HItemID, HNumber))
                    //{
                    //    objJsonResult.code = "0";
                    //    objJsonResult.count = 0;
                    //    objJsonResult.Message = "代码重复!";
                    //    objJsonResult.data = null;
                    //    return objJsonResult;
                    //}
                    #endregion
                    //保存
                    //保存完毕后处理
                    if (HItemID == 0)
                {
                    oCN.BeginTran();
                    //判断代码是否重复
@@ -146,14 +151,46 @@
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    oCN.RunProc("Insert into Gy_WorkStation  " +
                    DataSet ds = oCN.RunProcReturn("Insert into Gy_WorkStation  " +
                        " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
                        ",HLevel,HEndFlag,HStopflag,HRemark," +
                        "HUSEORGID,HCREATEORGID,HMakeEmp,HMakeTime) " +
                        "HUSEORGID,HCREATEORGID,HMakeEmp,HMakeTime) output inserted.HItemID" +//获取刚才插入的自增ID
                        " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID.ToString() +
                        "," + HLevel.ToString() + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "',"  + HUSEORGID + ",'" + HCREATEORGID + "','" + msg3 + "',getdate())", ref DBUtility.ClsPub.sExeReturnInfo);
                        "," + HLevel.ToString() + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "',"  + HUSEORGID + ",'" + HCREATEORGID + "','" + msg3 + "',getdate())", "Gy_WorkStation");
                    int HInterID = Convert.ToInt32(ds.Tables[0].Rows[0]["HItemID"]);//自增ID
                    //修改上级为非末级代码
                    oCN.RunProc("Update Gy_WorkStation set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                    //删除子表
                    oCN.RunProc("Delete From " + "Gy_WorkStationSub" + "  where HInterID=" + HInterID);
                    //插入子表
                    if (subList != null && subList.Count > 0)
                    {
                        int i = 0;
                        foreach (Models.WorkStationSub oSub in subList)
                        {
                            if (oSub == null)
                                continue;
                            i++;
                            string subSql = "insert into Gy_WorkStationSub" +
                                   "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
                                   ",HMaterID" + ")" +
                                   " values(" +
                                   HInterID + "," +
                                   (i) + "," +
                                   (oSub.HSourceInterID != 0 ? oSub.HSourceInterID.ToString() : "0") + "," +
                                   ( oSub.HSourceEntryID != 0 ? oSub.HSourceEntryID.ToString() : "0") + ",'" +
                                   (oSub.HSourceBillNo ?? "") + "','" + (oSub.HSourceBillType ?? "") + "'," +
                                   (oSub.HMaterID != 0 ? oSub.HMaterID.ToString() : "0") +
                                   ")";
                            oCN.RunProc(subSql);
                        }
                    }
                    oCN.Commit();
                }
                else
@@ -188,6 +225,37 @@
                    //将上级 ä¸ºéžæœ«çº§
                    oCN.RunProc("Update Gy_WorkStation set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                    //
                    //删除子表
                    oCN.RunProc("Delete From " + "Gy_WorkStationSub" + "  where HInterID=" + HItemID);
                    //插入子表
                    if (subList != null && subList.Count > 0)
                    {
                        int i = 0;
                        foreach (Models.WorkStationSub oSub in subList)
                        {
                            if (oSub == null)
                                continue;
                            i++;
                            string subSql = "insert into Gy_WorkStationSub" +
                                   "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
                                   ",HMaterID" + ")" +
                                   " values(" +
                                   HItemID + "," +
                                   (i) + "," +
                                   (oSub.HSourceInterID != 0 ? oSub.HSourceInterID.ToString() : "0") + "," +
                                   (oSub.HSourceEntryID != 0 ? oSub.HSourceEntryID.ToString() : "0") + ",'" +
                                   (oSub.HSourceBillNo ?? "") + "','" + (oSub.HSourceBillType ?? "") + "'," +
                                   (oSub.HMaterID != 0 ? oSub.HMaterID.ToString() : "0") +
                                   ")";
                            oCN.RunProc(subSql);
                        }
                    }
                    oCN.Commit();
                }
                objJsonResult.code = "0";
@@ -403,6 +471,57 @@
        #endregion
        #region æ ¹æ®åŸºç¡€èµ„æ–™ ID æˆ– æ¡ç  æŸ¥æ‰¾è®°å½•
        [Route("Gy_WorkStationBill/cx1")]
        [HttpGet]
        public object cx(long HInterID = -1, string HBarCode = "-1")
        {
            try
            {
                if(HInterID != -1)
                {
                    return cx(HInterID);
                }
                if(HBarCode != "-1")
                {
                    ds = oCN.RunProcReturn($"select * from h_v_Gy_WorkStationEdit where å·¥ä½ä»£ç ='{HBarCode}'", "h_v_Gy_WorkStationList");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "false!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "Sucess!";
                        objJsonResult.data = ds.Tables[0];
                        return objJsonResult;
                    }
                }else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "false!";
                    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("Gy_WorkStationBill/cx")]
        [HttpGet]
@@ -411,7 +530,7 @@
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_Gy_WorkStationList where HitemID=" + HInterID, "h_v_Gy_WorkStationList");
                ds = oCN.RunProcReturn("select * from h_v_Gy_WorkStationEdit where HitemID=" + HInterID, "h_v_Gy_WorkStationList");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";