chenhaozhe
2025-10-26 1948124877478db58b27841f9398aed97ef13053
WebAPI/Controllers/»ù´¡×ÊÁÏ/»ù´¡×ÊÁÏ/Gy_MatePriceSupController.cs
@@ -338,6 +338,7 @@
            try
            {
                var _value = msg["model"].ToString();
                LogService.Write("采购价格" + _value);
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ListModels oListModels = new ListModels();
                List<Model.ClsGy_MatePriceSup_Model> lsmain = new List<Model.ClsGy_MatePriceSup_Model>();
@@ -345,17 +346,28 @@
                string sql = string.Empty;
                //保存
                oCN.BeginTran();
                sql = $"delete Gy_MatePriceSup where HItemID = {lsmain[0].HItemID}";
                foreach (var item in lsmain)
                {
                    sql = $"delete Gy_MatePriceSup where HItemID = {item.HItemID}";
                oCN.RunProc(sql);
                sql = "set identity_insert Gy_MatePriceSup on";
                oCN.RunProc(sql);
                oCN.RunProc($@"insert into Gy_MatePriceSup(HItemID,HInterID,HEntryID,HMaterID,HRelationID,HUnitID,HBeginQty,HEndQty,HCurID,HType
                    LogService.Write("采购价格" + $@"  insert into Gy_MatePriceSup(HItemID,HNumber,HInterID,HEntryID,HMaterID,HRelationID,HUnitID,HBeginQty,HEndQty,HCurID,HType
                        ,HPrice,HBeginDate,HEndDate,HUsed,HRemark,HMaker,HMakeDate)
                  values({lsmain[0].HItemID},{lsmain[0].HInterID},{lsmain[0].HEntryID},{lsmain[0].HMaterID},{lsmain[0].HRelationID},{lsmain[0].HUnitID},{lsmain[0].HBeginQty},{lsmain[0].HEndQty},{lsmain[0].HCurID},'{lsmain[0].HType}',{lsmain[0].HPrice},'{lsmain[0].HBeginDate}','{lsmain[0].HEndDate}','{lsmain[0].HUsed}','{lsmain[0].HRemark}','{lsmain[0].HMaker}','{lsmain[0].HMakeDate}')", ref DBUtility.ClsPub.sExeReturnInfo);
                  values({item.HItemID},'{item.HNumber}',{item.HInterID},{item.HEntryID},{item.HMaterID},{item.HRelationID},{item.HUnitID},{item.HBeginQty},{item.HEndQty},{item.HCurID},'{item.HType}',{item.HPrice},'{item.HBeginDate}','{item.HEndDate}','{item.HUsed}','{item.HRemark}','{item.HMaker}','{item.HMakeDate}')");
                    oCN.RunProc($@"insert into Gy_MatePriceSup(HItemID,HNumber,HInterID,HEntryID,HMaterID,HRelationID,HUnitID,HBeginQty,HEndQty,HCurID,HType
                        ,HPrice,HBeginDate,HEndDate,HUsed,HRemark,HMaker,HMakeDate)
                  values({item.HItemID},'{item.HNumber}',{item.HInterID},{item.HEntryID},{item.HMaterID},{item.HRelationID},{item.HUnitID},{item.HBeginQty},{item.HEndQty},{item.HCurID},'{item.HType}',{item.HPrice},'{item.HBeginDate}','{item.HEndDate}','{item.HUsed}','{item.HRemark}','{item.HMaker}','{item.HMakeDate}')", ref DBUtility.ClsPub.sExeReturnInfo);
                //修改上级为非末级代码
                sql = "set identity_insert Gy_MatePriceSup off";
                oCN.RunProc(sql);
                }
                oCN.Commit();
                objJsonResult.code = "1";
@@ -526,5 +538,75 @@
            }
        }
        #endregion
        #region é‡‡è´­ä»·ç›® é‡‘蝶同步
        [Route("Gy_MatePriceSup/SaveGy_PurPriceApi")]
        [HttpPost]
        public object SaveGy_PurPriceApi([FromBody] JObject msg)
        {
            try
            {
                var _value = msg["model"].ToString();
                LogService.Write("采购价目" + _value);
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ListModels oListModels = new ListModels();
                List<Model.ClsGy_PurPrice_Model> lsmain = new List<Model.ClsGy_PurPrice_Model>();
                lsmain = oListModels.getObjectByJson_Gy_PurPrice(_value);
                string sql = string.Empty;
                //保存
                oCN.BeginTran();
                foreach (var item in lsmain)
                {
                    sql = $"delete Gy_PurPriceList where HItemID = {item.HItemID}";
                    oCN.RunProc(sql);
                    sql = "set identity_insert Gy_PurPriceList on";
                    oCN.RunProc(sql);
                    LogService.Write("采购价目"   + $@"  insert into Gy_PurPriceList(HItemID, HNumber, HName, HShortNumber, HParentID, HLevel,
                    HEndFlag, HStopflag, HRemark, HUseFlag, HCREATEORGID, HUSEORGID,
                    HMakeEmp, HMakeTime, HCheckEmp, HCheckTime,HModifyEmp, HModifyTime, HStopEmp, HStopTime,
                    HPURCHASEORGID, HSupID, HCurID, HPRICER, HPRICETYPE, HPRICEOBJECT,HISINCLUDEDTAX, HDEFPRICELISTID, HSUPPLIERMASTERID)
                    values({item.HItemID},'{item.HNumber}','{item.HName}','{item.HShortNumber}',{item.HParentID},{item.HLevel},
                    '{item.HEndFlag}','{item.HStopflag}','{item.HRemark}','{item.HUseFlag}',{item.HCREATEORGID},{item.HUSEORGID},
                    {item.HMakeEmp},'{item.HMakeTime}',{item.HCheckEmp},'{item.HCheckTime}',{item.HModifyEmp},'{item.HModifyTime}',{item.HStopEmp},'{item.HStopTime}',
                    {item.HPURCHASEORGID},{item.HSupID},{item.HCurID},{item.HPRICER},{item.HPRICETYPE},'{item.HPRICEOBJECT}','{item.HISINCLUDEDTAX}','{item.HDEFPRICELISTID}','{item.HSUPPLIERMASTERID}')");
                    oCN.RunProc($@"insert into Gy_PurPriceList(HItemID, HNumber, HName, HShortNumber, HParentID, HLevel,
                    HEndFlag, HStopflag, HRemark, HUseFlag, HCREATEORGID, HUSEORGID,
                    HMakeEmp, HMakeTime, HCheckEmp, HCheckTime,HModifyEmp, HModifyTime, HStopEmp, HStopTime,
                    HPURCHASEORGID, HSupID, HCurID, HPRICER, HPRICETYPE, HPRICEOBJECT,HISINCLUDEDTAX, HDEFPRICELISTID, HSUPPLIERMASTERID)
                    values({item.HItemID},'{item.HNumber}','{item.HName}','{item.HShortNumber}',{item.HParentID},{item.HLevel},
                    '{item.HEndFlag}','{item.HStopflag}','{item.HRemark}','{item.HUseFlag}',{item.HCREATEORGID},{item.HUSEORGID},
                    {item.HMakeEmp},'{item.HMakeTime}',{item.HCheckEmp},'{item.HCheckTime}',{item.HModifyEmp},'{item.HModifyTime}',{item.HStopEmp},'{item.HStopTime}',
                    {item.HPURCHASEORGID},{item.HSupID},{item.HCurID},{item.HPRICER},{item.HPRICETYPE},'{item.HPRICEOBJECT}','{item.HISINCLUDEDTAX}','{item.HDEFPRICELISTID}','{item.HSUPPLIERMASTERID}')", ref DBUtility.ClsPub.sExeReturnInfo);
                    //修改上级为非末级代码
                    sql = "set identity_insert Gy_PurPriceList 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
    }
}