llj
2025-10-16 682f65042a17e9f2b173937498622397e3d94247
辅助属性同步
1个文件已修改
96 ■■■■■ 已修改文件
WebAPI/Controllers/BaseSet/Gy_PropertyController.cs 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/BaseSet/Gy_PropertyController.cs
@@ -365,50 +365,60 @@
        }
        #endregion
        //#region 辅助属性 金蝶同步
        //[Route("Gy_Property/SaveGy_PropertyListApi")]
        //[HttpPost]
        //public object SaveGy_PropertyListApi([FromBody] JObject msg)
        //{
        //    try
        //    {
        //        var _value = msg["model"].ToString();
        //        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        //        ListModels oListModels = new ListModels();
        //        List<Model.ClsGy_Property_Model> lsmain = new List<Model.ClsGy_Property_Model>();
        //        lsmain = oListModels.getObjectByJson_Gy_Property(_value);
        //        string sql = string.Empty;
        //        //保存
        //        oCN.BeginTran();
        //        sql = $"delete Gy_Property where HItemID = {lsmain[0].HItemID}";
        //        oCN.RunProc(sql);
        //        sql = "set identity_insert Gy_Property on";
        //        oCN.RunProc(sql);
        #region 辅助属性 金蝶同步
        [Route("Gy_Property/SaveGy_PropertyListApi")]
        [HttpPost]
        public object SaveGy_PropertyListApi([FromBody] JObject msg)
        {
            try
            {
                var _value = msg["model"].ToString();
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ListModels oListModels = new ListModels();
                List<Model.ClsGy_Property_Model> lsmain = new List<Model.ClsGy_Property_Model>();
                lsmain = oListModels.getObjectByJson_Gy_Property(_value);
                string sql = string.Empty;
                //保存
                oCN.BeginTran();
                sql = $"delete Gy_Property where HItemID = {lsmain[0].HItemID}";
                oCN.RunProc(sql);
                sql = "set identity_insert Gy_Property on";
                oCN.RunProc(sql);
        //        oCN.RunProc($@"insert into Gy_Property(HItemID,HNumber,HName,HHelpCode,HShortNumber,HParentID
        //            ,HLevel,HEndFlag,HStopflag,HRemark,HPropertyTypeID,HUseFlag,HERPItemID,HMakeTime)
        //          values({lsmain[0].HItemID},'{lsmain[0].HNumber}','{lsmain[0].HName}','{lsmain[0].HHelpCode}','{lsmain[0].HShortNumber}',{lsmain[0].HParentID},{lsmain[0].HLevel}
        //   ,{Convert.ToString(lsmain[0].HEndFlag ? 1 : 0)},{Convert.ToString(lsmain[0].HStopflag ? 1 : 0) },'{lsmain[0].HRemark}',{lsmain[0].HPropertyTypeID},'{lsmain[0].HUseFlag}',{lsmain[0].HERPItemID},'{lsmain[0].HMakeTime}')", ref DBUtility.ClsPub.sExeReturnInfo);
        //        //修改上级为非末级代码
        //        sql = "set identity_insert Gy_Property off";
        //        oCN.RunProc(sql);
        //        oCN.Commit();
                oCN.RunProc($@"insert into Gy_Property(HItemID,HNumber,HName,HHelpCode,HShortNumber,HParentID
                    ,HLevel,HEndFlag,HStopflag,HRemark,HPropertyTypeID,HUseFlag,HERPItemID,HMakeTime)
                  values({lsmain[0].HItemID},'{lsmain[0].HNumber}','{lsmain[0].HName}','{lsmain[0].HHelpCode}','{lsmain[0].HShortNumber}',{lsmain[0].HParentID},{lsmain[0].HLevel}
           ,{Convert.ToString(lsmain[0].HEndFlag ? 1 : 0)},{Convert.ToString(lsmain[0].HStopflag ? 1 : 0) },'{lsmain[0].HRemark}',{lsmain[0].HPropertyTypeID},'{lsmain[0].HUseFlag}',{lsmain[0].HERPItemID},'{lsmain[0].HMakeTime}')", ref DBUtility.ClsPub.sExeReturnInfo);
        //        objJsonResult.code = "1";
        //        objJsonResult.count = 1;
        //        objJsonResult.Message = "保存成功!";
        //        objJsonResult.data = 1;
        //        return objJsonResult;
        //    }
        //    catch (Exception e)
        //    {
        //        objJsonResult.code = "0";
        //        objJsonResult.count = 0;
        //        objJsonResult.Message = "保存失败!" + e.ToString();
        //        objJsonResult.data = 1;
        //        return objJsonResult;
        //    }
        //}
        //#endregion
                //新增辅助子表:
                oCN.RunProc($@"insert into Gy_PropertyEntry
                            (HItemID,HERPItemID,HAuxpuID,HMaterID,HISDefault,HStopflag,HSno)
                  values({lsmain[1].HItemID},'{lsmain[1].HERPItemID}','{lsmain[1].HAuxpuID}','{lsmain[1].HMaterID}','{lsmain[1].HISDefault}',{Convert.ToString(lsmain[0].HStopflag ? 1 : 0) },'{lsmain[1].HSno}')", ref DBUtility.ClsPub.sExeReturnInfo);
                //修改上级为非末级代码
                sql = "set identity_insert Gy_Property off";
                oCN.RunProc(sql);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "保存成功!";
                objJsonResult.data = 1;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = 1;
                return objJsonResult;
            }
        }
        #endregion
    }
}