yangle
2022-03-31 009dfb43a1be6bd461fc5f8fe035c8113669664d
WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs
@@ -60,9 +60,9 @@
                //反序列化传递的值
                ComplementGoods com = JsonConvert.DeserializeObject<ComplementGoods>(sWhere.ToString());
                ds = oCN.RunProcReturn($"exec h_p_JIT_ComplementGoodsBillList_Query '{com.MaterialNumber}','{com.MaterialName}','{com.MaterialModel}','{com.HGD}'," +
                    $"'{com.HWHName}','{com.HDeptName}','{com.Organization}','{com.user}','{com.HJLStatus}','{com.HBeginDate}','{com.HEndDate}'" ,"h_p_JIT_ComplementGoodsBillList_Query");
                    $"'{com.HWHName}','{com.HDeptName}','{com.Organization}','{com.user}','{com.HJLStatus}','{com.HBeginDate}','{com.HEndDate}'", "h_p_JIT_ComplementGoodsBillList_Query");
                objJsonResult.code = "1";
                objJsonResult.count = 1;
@@ -84,7 +84,7 @@
        #region 拣料配送单 删除
        [Route("Sc_ComplementGoods/DelComplementGoodsList")]
        [HttpGet]
        public object DelComplementGoodsList(string HInterID, string HEntryID,string HOrgID, string user)
        public object DelComplementGoodsList(string HInterID, string HEntryID, string HOrgID, string user)
        {
            try
            {
@@ -100,7 +100,7 @@
                ds = oCN.RunProcReturn($"select HISCheck from JIT_SendGoodsBillMain where HMainSourceInterID={HInterID} ", "JIT_SendGoodsBillMain");
                if (ds.Tables[0].Rows.Count>0)
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
@@ -202,7 +202,8 @@
        #region 仓库发料
        //参数
        public class SendGoodsBill {
        public class SendGoodsBill
        {
            public int? 未拣料数量 = 0;
            public int? 最大拣料数量 = 0;
            public int? 本次拣料数量 = 0;
@@ -288,32 +289,53 @@
            {
                oCN.BeginTran();
                oCN.RunProc($"delete from JIT_SendGoodsBillMain where HMainSourceInterID={SourceInterID} and HMainSourceBillNo='{SourceBillNo}'");
                //oCN.RunProc($"delete from JIT_SendGoodsBillMain where HMainSourceInterID={SourceInterID} and HMainSourceBillNo='{SourceBillNo}' and HBillStatus=1");
                oCN.RunProc($"delete from JIT_SendGoodsBillSub where HInterID in (select HInterID from JIT_SendGoodsBillMain where HMainSourceInterID={SourceInterID} and HMainSourceBillNo='{SourceBillNo}')");
                //oCN.RunProc($"delete from JIT_SendGoodsBillSub where HInterID in (select HInterID from JIT_SendGoodsBillMain where HMainSourceInterID={SourceInterID} and HMainSourceBillNo='{SourceBillNo}' and HBillStatus=1)");
                ds = oCN.RunProcReturn($"select a.HMainSourceEntryID,b.HMaterID  from JIT_SendGoodsBillMain a  with(nolock) inner join JIT_SendGoodsBillSub b with(nolock) on a.HInterID = b.HInterID where a.HMainSourceInterID={SourceInterID} and a.HBillStatus=1", "JIT_SendGoodsBillMain");
                for (int i = 0; i < listCa.Count; i++)
                {
                    long InterID = DBUtility.ClsPub.CreateBillID_Prod("460201", ref DBUtility.ClsPub.sExeReturnInfo);
                    string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("460201", ref DBUtility.ClsPub.sExeReturnInfo, true);
                    int a = -1;
                    for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                    {
                        if (ds.Tables[0].Rows[j]["HMaterID"].ToString() == listCa[i].HMaterID.ToString()&& ds.Tables[0].Rows[j]["HMainSourceEntryID"].ToString() == listCa[i].HEntryID.ToString())
                        {
                            a = j;
                            break;
                        }
                    }
                    //添加主表数据
                    oCN.RunProc("insert into JIT_SendGoodsBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate" +
                        ",HBillNo,HBillStatus,HMaker,HMakeDate,HISCheck, HMainSourceInterID, HMainSourceEntryID" +
                        ", HMainSourceBillNo, HMainSourceBillType)" +
                       $"values({DateTime.Now.Year},{DateTime.Now.Month},'460201','460201',{InterID}, GETDATE(), '{HBillNo}'," +
                       $" 0,'{user}', GETDATE(), 0, {SourceInterID}, {listCa[i].HEntryID}, '{SourceBillNo}', '4602')");
                    //a=0  则代表配送单没有数据  需要添加数据
                    if (a == -1 )
                    {
                        long InterID = DBUtility.ClsPub.CreateBillID_Prod("460201", ref DBUtility.ClsPub.sExeReturnInfo);
                        string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("460201", ref DBUtility.ClsPub.sExeReturnInfo, true);
                    //添加子表数据
                    oCN.RunProc("insert into JIT_SendGoodsBillSub(HInterID,HBillNo_bak,HEntryID" +
                        ",HMaterID,HQty,HWHID,HSPID,HISCheck,HCheckSubMan,HCheckSubDate)" +
                        $"values({InterID},'{HBillNo}',{i}, {listCa[i].HMaterID},{listCa[i].本次拣料数量}," +
                        $" {listCa[i].HWHID},{listCa[i].HSPID},0,'{user}', GETDATE())");
                        //添加主表数据
                        oCN.RunProc("insert into JIT_SendGoodsBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate" +
                            ",HBillNo,HBillStatus,HMaker,HMakeDate,HISCheck, HMainSourceInterID, HMainSourceEntryID" +
                            ", HMainSourceBillNo, HMainSourceBillType)" +
                           $"values({DateTime.Now.Year},{DateTime.Now.Month},'460201','460201',{InterID}, GETDATE(), '{HBillNo}'," +
                           $" 1,'{user}', GETDATE(), 0, {SourceInterID}, {listCa[i].HEntryID}, '{SourceBillNo}', '4602')");
                        //添加子表数据
                        oCN.RunProc("insert into JIT_SendGoodsBillSub(HInterID,HBillNo_bak,HEntryID" +
                            ",HMaterID,HQty,HWHID,HSPID,HISCheck,HCheckSubMan,HCheckSubDate)" +
                            $"values({InterID},'{HBillNo}',{i + 1}, {listCa[i].HMaterID},{listCa[i].本次拣料数量}," +
                            $" {listCa[i].HWHID},{listCa[i].HSPID},0,'{user}', GETDATE())");
                    }
                    else
                    {
                        //修改配送单的配送数量
                        oCN.RunProc($"update b  set b.HQty=b.HQty+{listCa[i].本次拣料数量} from JIT_SendGoodsBillMain a  with(nolock) inner join JIT_SendGoodsBillSub b with(nolock) on a.HInterID = b.HInterID  " +
                            $"where  HMainSourceInterID ={SourceInterID} and b.HMaterID ={listCa[i].HMaterID} and a.HBillStatus =1 ");
                    }
                    //修改调拨数量
                    oCN.RunProc($"update JIT_ComplementGoodsBillSub_LK set HSendQTY={listCa[i].本次拣料数量} where HMaterID={listCa[i].HMaterID} " +
                    oCN.RunProc($"update JIT_ComplementGoodsBillSub_LK set HSendQTY=HSendQTY+{listCa[i].本次拣料数量} where HMaterID={listCa[i].HMaterID} " +
                        $" and HSourceInterID=(select top 1 HSourceInterID from JIT_ComplementGoodsBillSub_LK " +
                        $"where HMaterID={listCa[i].HMaterID} order by HSourceInterID ) and HInterID={SourceInterID}");
                        $"where HMaterID={listCa[i].HMaterID}  and HInterID={SourceInterID} order by HSourceInterID )  and HInterID={SourceInterID} ");
                }
                sReturn = "新增单据成功!";
@@ -322,6 +344,7 @@
            }
            catch (Exception e)
            {
                oCN.RollBack();
                sReturn = e.Message;
                throw (e);
            }
@@ -331,12 +354,39 @@
        #region 上查
        [Route("Sc_ComplementGoods/ComplementGoodsList_Sc")]
        [HttpGet]
        public object ComplementGoodsList_Sc(string HInterID,string HEntryID)
        public object ComplementGoodsList_Sc(string HInterID, string HMaterID)
        {
            try
            {
                ds = oCN.RunProcReturn($"exec h_p_JIT_ComplementGoodsBillList_UpQuery '{HInterID}',{HEntryID}", "h_p_JIT_ComplementGoodsBillList_UpQuery");
                ds = oCN.RunProcReturn($"exec h_p_JIT_ComplementGoodsBillList_UpQuery '{HInterID}',{HMaterID}", "h_p_JIT_ComplementGoodsBillList_UpQuery");
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 下查
        [Route("Sc_ComplementGoods/JIT_SendGoodsBillList_Xc")]
        [HttpGet]
        public object JIT_SendGoodsBillList_Xc(string HInterID, string HMaterID)
        {
            try
            {
                ds = oCN.RunProcReturn($"exec h_p_JIT_ComplementGoodsBillList_DownQuery '{HInterID}',{HMaterID}", "h_p_JIT_ComplementGoodsBillList_DownQuery");
                objJsonResult.code = "1";
                objJsonResult.count = 1;