Beispiel #1
0
        /// <summary>
        /// 确认签收
        /// </summary>
        public AjaxResult SemiFinishedSignNew(string OrderCode)
        {
            if (string.IsNullOrWhiteSpace(OrderCode))
            {
                return(AjaxResult.Warning("参数错误"));
            }
            string    sql = @"select a.ID,a.OrderCodeH,b.OrderCode,b.DisEntOrderId from TbSemiFinishedSign a
left join TbSiteDischargeCargo b on a.DischargeCargoCode=b.DischargeCargoCode
where (a.DischargeCargoCode is not null and a.OperateState is null and b.OrderCode='" + OrderCode + "') or (OrderCodeH='" + OrderCode + "')";
            DataTable dt  = Db.Context.FromSql(sql).ToDataTable();
            List <TbSemiFinishedSign>     listsf  = new List <TbSemiFinishedSign>();
            List <TbDistributionEntOrder> listEnt = new List <TbDistributionEntOrder>();

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //半成品签收
                    TbSemiFinishedSign model = Repository <TbSemiFinishedSign> .First(p => p.ID == Convert.ToInt32(dt.Rows[i]["ID"]));

                    model.OperateState   = "已签收";
                    model.SigninTime     = DateTime.Now;
                    model.InsertUserCode = OperatorProvider.Provider.CurrentUser.UserCode;//签收人编号
                    listsf.Add(model);


                    if (!string.IsNullOrWhiteSpace(dt.Rows[i]["DisEntOrderId"].ToString()))
                    {
                        TbDistributionEntOrder modelEnt = Repository <TbDistributionEntOrder> .First(p => p.ID == Convert.ToInt32(dt.Rows[i]["DisEntOrderId"]));

                        modelEnt.SignState     = "已签收";        //签收状态
                        modelEnt.SignStateTime = DateTime.Now; //签收完成时间
                        listEnt.Add(modelEnt);
                    }
                }
            }

            try
            {
                using (DbTrans trans = Db.Context.BeginTransaction())//使用事务
                {
                    if (listsf.Count > 0)
                    {
                        Repository <TbSemiFinishedSign> .Update(trans, listsf, true);//半成品签收
                    }
                    if (listEnt.Count > 0)
                    {
                        Repository <TbDistributionEntOrder> .Update(trans, listEnt, true); //配送装车订单
                    }
                    trans.Commit();                                                        //提交事务
                    return(AjaxResult.Success());
                }
            }
            catch (Exception ex)
            {
                return(AjaxResult.Error(ex.ToString()));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 确认签收
        /// </summary>
        public AjaxResult Update(int Id, string userCode = "", bool isApi = false)
        {
            if (Id <= 0)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            var anyRet = AnyInfo(Id);

            if (anyRet.state.ToString() != ResultType.success.ToString())
            {
                return(anyRet);
            }
            var model = (TbSemiFinishedSign)anyRet.data;
            TbDistributionEntOrder modelEnt = null;
            var zdxhModel = Repository <TbSiteDischargeCargo> .First(p => p.DischargeCargoCode == model.DischargeCargoCode);

            if (zdxhModel != null)
            {
                //查询配送装车数据
                modelEnt = Repository <TbDistributionEntOrder> .First(p => p.ID == zdxhModel.DisEntOrderId);
            }
            else
            {
                if (string.IsNullOrEmpty(model.OrderCodeH))
                {
                    return(AjaxResult.Warning("获取站点卸货信息失败"));
                }
            }
            if (!string.IsNullOrEmpty(userCode))
            {
                model.InsertUserCode = userCode;//签收人编号
            }
            else
            {
                model.InsertUserCode = OperatorProvider.Provider.CurrentUser.UserCode;//签收人编号
            }
            try
            {
                using (DbTrans trans = Db.Context.BeginTransaction())//使用事务
                {
                    model.OperateState = "已签收";
                    model.SigninTime   = DateTime.Now;
                    //修改信息
                    Repository <TbSemiFinishedSign> .Update(trans, model, p => p.ID == model.ID, isApi);

                    //当点击签收是,判断是否存在预警信息,如果存在就把预警信息状态改为撤销
                    Db.Context.FromSql("update TbFormEarlyWarningNodeInfo set EWStart=2 where MenuCode='SemiFinishedSign' and EWFormDataCode=" + Id + " and EWStart=0 and MsgType=2").SetDbTransaction(trans).ExecuteNonQuery();
                    //回写配送装车里面的签收状态
                    if (modelEnt != null)
                    {
                        modelEnt.SignState     = "已签收";        //签收状态
                        modelEnt.SignStateTime = DateTime.Now; //签收完成时间
                        Repository <TbDistributionEntOrder> .Update(trans, modelEnt, p => p.ID == modelEnt.ID, isApi);
                    }
                    trans.Commit();//提交事务

                    return(AjaxResult.Success());
                }
            }
            catch (Exception ex)
            {
                return(AjaxResult.Error(ex.ToString()));
            }
            //if (Id <= 0)
            //    return AjaxResult.Warning("参数错误");
            //var anyRet = AnyInfo(Id);
            //if (anyRet.state.ToString() != ResultType.success.ToString())
            //    return anyRet;
            //var model = (TbSemiFinishedSign)anyRet.data;
            ////查询配送装车数据
            //TbDistributionEnt modelEnt = Repository<TbDistributionEnt>.First(p => p.DistributionCode == model.DistributionCode);
            //if (!string.IsNullOrEmpty(userCode))
            //{
            //    model.InsertUserCode = userCode;//签收人编号
            //}
            //else
            //{
            //    model.InsertUserCode = OperatorProvider.Provider.CurrentUser.UserCode;//签收人编号
            //}
            //try
            //{
            //    using (DbTrans trans = Db.Context.BeginTransaction())//使用事务
            //    {
            //        model.OperateState = "已签收";
            //        model.SigninTime = DateTime.Now;
            //        //修改信息
            //        Repository<TbSemiFinishedSign>.Update(trans, model, p => p.ID == model.ID, isApi);
            //        //回写配送装车里面的签收状态
            //        if (modelEnt != null)
            //        {
            //            modelEnt.SignState = "已签收";//签收状态
            //            Repository<TbDistributionEnt>.Update(trans, modelEnt, p => p.ID == modelEnt.ID, isApi);
            //        }
            //        trans.Commit();//提交事务

            //        return AjaxResult.Success();
            //    }
            //}
            //catch (Exception ex)
            //{
            //    return AjaxResult.Error(ex.ToString());
            //}
        }