zzr99
2021-12-07 bec1d01000a794e0166c0c3b12bad5b678e93d91
WebAPI/Controllers/MJGL/Sc_MouldMaintainRuleBillController.cs
@@ -150,10 +150,10 @@
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                //获取保养项目编辑数据
                string sql = "select * from h_v_Sc_MouldMaintainRuleBillSub_Item where 1 = 1 " + Swhere + "";
                ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldMaintainRuleBillSub_Item");
                string sql = "select 保养项目ID,保养项目,保养部位,具体要求,负责人ID,负责人代码,负责人名称,子备注2 from h_v_Sc_MouldMaintainRuleBillList where 1 = 1 " + Swhere + "";
                ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldMaintainRuleBillList");
                //获取配件项目编辑数据
                string sql1 = "select 配件ID,配件代码,配件名称,单位ID,计量单位代码,计量单位名称,用量,标准用量,子备注 from h_v_Sc_MouldMaintainRuleBillList where 1 = 1 " + Swhere + "";
                string sql1 = "select 配件ID,配件代码,配件名称,单位ID,计量单位代码,计量单位名称,用量,标准用量,子备注1 from h_v_Sc_MouldMaintainRuleBillList where 1 = 1 " + Swhere + "";
                ds1 = oCN.RunProcReturn(sql1, "h_v_Sc_MouldMaintainRuleBillList");
                list.Add(ds.Tables[0]);
@@ -182,14 +182,64 @@
            if (string.IsNullOrEmpty(HID))
                return new ApiResult<DataSet> { code = -1, msg = "ID不能为空" };
            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
            var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MouldMaintainRuleBillList  where hmainid= " + HID + " ", "h_v_Sc_MouldMaintainRuleBillList");
            var dataSet = oCN.RunProcReturn("select top 1 * from Sc_MouldMaintainRuleBillMain  where HInterID= " + HID + " ", "Sc_MouldMaintainRuleBillMain");
            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
                return new ApiResult<DataSet> { code = -1, msg = "不存在器具保养规程记录" };
            return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet };
        }
        #endregion
        #region 器具保养规程编辑时获取表体数据新(保养项列表、配件项列表)
        [Route("Sc_MouldMaintainRuleBill/Sc_MouldMaintainRuleBillSubAndSubItem")]
        [HttpGet]
        public object Sc_MouldMaintainRuleBillSubAndSubItem(string HInterID)
        {
            DataSet ds, ds1;
            List<object> list = new List<object>();
            string Swhere = "";
            try
            {
                if (HInterID != "" || HInterID != null)
                {
                    Swhere = " and hmainid='" + HInterID + "'";
                }
                else
                {
                    Swhere = HInterID;
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                //获取保养项目编辑数据
                string sql = "select 保养项目ID HMaintainItemID,保养项目代码 HMaintainItemNumber,保养项目 HMaintainItem,保养部位 HMaintainPart,具体要求 HClaim,负责人ID HManagerID,负责人代码 HManagerNumber,负责人名称 HManagerName,子备注2 HRemark from h_v_Sc_MouldMaintainRuleBillList where 1 = 1 " + Swhere + "";
                ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldMaintainRuleBillList");
                //获取配件项目编辑数据
                string sql1 = "select 配件ID HMaterID,配件代码 HMaterNumber,配件名称 HMaterName,单位ID HUnitID,计量单位代码 HUnitNumber,计量单位名称 HUnitName,用量 HQty,子备注1 HRemark from h_v_Sc_MouldMaintainRuleBillList where 1 = 1 " + Swhere + "";
                ds1 = oCN.RunProcReturn(sql1, "h_v_Sc_MouldMaintainRuleBillList");
                list.Add(ds.Tables[0]);
                list.Add(ds1.Tables[0]);
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "获取信息成功!";
                objJsonResult.list = list;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
            }
            return objJsonResult;
        }
        #endregion
        #region 器具保养规程表 保存/编辑
        /// <summary>
        /// 保存模具维修单
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        [Route("Sc_MouldMaintainRuleBill/SaveMouldMaintainRuleBillList")]
        [HttpPost]
        public object SaveMouldMaintainRuleBillList([FromBody] JObject msg)
@@ -209,20 +259,18 @@
                List<Model.ClsSc_MouldMaintainRuleBillMain> lsmain = new List<Model.ClsSc_MouldMaintainRuleBillMain>();
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");  //\n
                //主表
                lsmain = oListModels.getObjectByJson_Sc_MouldMaintainRuleBillMain(msg2);
                foreach (Model.ClsSc_MouldMaintainRuleBillMain oItem in lsmain)
                {
                    //oItem.HMaker = "";
                    UserName = oItem.HMaker;  //制单人
                    oItem.HBillType = "3833";
                    oItem.HBillSubType = "3833";
                    //oItem.HInterID =0;
                    //oItem.HBillNo = "";
                    oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));//  --日期
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo);
                    oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
                    {
                        objJsonResult.code = "0";
@@ -248,20 +296,17 @@
                    i++;
                    item.HEntryID = i;
                    //oItemSub.HCloseMan = "";       //行关闭
                    item.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    item.HCloseType = false;   //关闭类型
                    //oItemSub.HRemark = "";         //备注
                    item.HSourceInterID = 0;     // 源单主内码
                    item.HSourceEntryID = 0;   //源单子内码
                    //oItemSub.HSourceBillNo = "";  //源单单号
                    //oItemSub.HSourceBillType = ""; //源单类型
                    item.HRelationQty = 0;     //关联数量
                    oBill.DetailColl_Pay.Add(item);
                }
                //配件表体数据
                //配件项表体数据
                //按 },{来拆分数组 //去掉【和】
                msg4 = msg4.Substring(1, msg4.Length - 2);
                msg4 = msg4.Replace("\\", "");
@@ -274,26 +319,19 @@
                {
                    j++;
                    oItemSub.HEntryID = i;
                    oItemSub.HEntryID = j;
                    //oItemSub.HCloseMan = "";       //行关闭
                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    oItemSub.HCloseType = false;   //关闭类型
                                                   //oItemSub.HRemark = "";         //备注
                    oItemSub.HSourceInterID = 0;     // 源单主内码
                    oItemSub.HSourceEntryID = 0;   //源单子内码
                                                   //oItemSub.HSourceBillNo = "";  //源单单号
                                                   //oItemSub.HSourceBillType = ""; //源单类型
                    oItemSub.HRelationQty = 0;     //关联数量
                                                   //oItemSub.HRelationMoney = 0;   //关联金额
                                                   //HMaterID = "";//配件代码
                                                   //HUnitID = "";//单位代码
                                                   //HQty = "";//实际用量
                                                   //HQtyMust = "";//单位用量
                                                   //HRemark = "";//备注
                    oBill.DetailColl_Mater.Add(oItemSub);
                }
                //保存
                //保存完毕后处理
                bool bResult;