Exemplo n.º 1
0
        /// <summary>
        /// 获取底层平台的流水号
        /// </summary>
        /// <param name="TmplCode">表单配置的code</param>
        /// <param name="applySerialNumber"></param>
        /// <returns></returns>
        public static string GetFormSerialNumberString(string TmplCode, bool applySerialNumber = true, DataRow row = null, Dictionary <string, string> dic = null)
        {
            string    sql    = "select * from S_UI_Form where Code='" + TmplCode + "'";
            SQLHelper BaseDb = SQLHelper.CreateSqlHelper(ConnEnum.Base);
            DataTable dt     = BaseDb.ExecuteDataTable(sql);
            string    SerialNumberSettings = dt.Rows[0]["SerialNumberSettings"].ToString();
            var       serialNumberDic      = JsonHelper.ToObject(SerialNumberSettings);
            string    tmpl            = serialNumberDic["Tmpl"].ToString();
            string    resetRule       = serialNumberDic["ResetRule"].ToString();
            string    CategoryCode    = "";
            string    SubCategoryCode = "";
            string    OrderNumCode    = "";
            string    PrjCode         = "";
            string    OrgCode         = "";
            string    UserCode        = "";

            if (serialNumberDic.ContainsKey("CategoryCode"))
            {
                CategoryCode = ReplaceString(serialNumberDic["CategoryCode"].ToString(), row, dic);
            }
            if (serialNumberDic.ContainsKey("SubCategoryCode"))
            {
                SubCategoryCode = ReplaceString(serialNumberDic["SubCategoryCode"].ToString(), row, dic);
            }
            if (serialNumberDic.ContainsKey("OrderNumCode"))
            {
                OrderNumCode = ReplaceString(serialNumberDic["OrderNumCode"].ToString(), row, dic);
            }
            if (serialNumberDic.ContainsKey("PrjCode"))
            {
                PrjCode = ReplaceString(serialNumberDic["PrjCode"].ToString(), row, dic);
            }
            if (serialNumberDic.ContainsKey("OrgCode"))
            {
                OrgCode = ReplaceString(serialNumberDic["OrgCode"].ToString(), row, dic);
            }
            if (serialNumberDic.ContainsKey("UserCode"))
            {
                UserCode = ReplaceString(serialNumberDic["UserCode"].ToString(), row, dic);
            }

            SerialNumberParam param = new SerialNumberParam()
            {
                Code            = TmplCode,
                PrjCode         = PrjCode,
                OrgCode         = OrgCode,
                UserCode        = UserCode,
                CategoryCode    = CategoryCode,
                SubCategoryCode = SubCategoryCode,
                OrderNumCode    = OrderNumCode
            };
            string number = SerialNumberHelper.GetSerialNumberString(tmpl, param, resetRule, applySerialNumber);

            return(number);
        }
Exemplo n.º 2
0
        private string GetSerialNumber(string formCode, string SerialNumberSettings, bool applySerialNumber, DataRow row = null, Dictionary <string, string> dic = null)
        {
            UIFO uiFO = FormulaHelper.CreateFO <UIFO>();

            var    serialNumberDic = JsonHelper.ToObject(SerialNumberSettings);
            string tmpl            = serialNumberDic["Tmpl"].ToString();
            string resetRule       = serialNumberDic["ResetRule"].ToString();
            string CategoryCode    = "";
            string SubCategoryCode = "";
            string OrderNumCode    = "";
            string PrjCode         = "";
            string OrgCode         = "";
            string UserCode        = "";

            if (serialNumberDic.ContainsKey("CategoryCode"))
            {
                CategoryCode = uiFO.ReplaceString(serialNumberDic["CategoryCode"].ToString(), row, dic);
            }
            if (serialNumberDic.ContainsKey("SubCategoryCode"))
            {
                SubCategoryCode = uiFO.ReplaceString(serialNumberDic["SubCategoryCode"].ToString(), row, dic);
            }
            if (serialNumberDic.ContainsKey("OrderNumCode"))
            {
                OrderNumCode = uiFO.ReplaceString(serialNumberDic["OrderNumCode"].ToString(), row, dic);
            }
            if (serialNumberDic.ContainsKey("PrjCode"))
            {
                PrjCode = uiFO.ReplaceString(serialNumberDic["PrjCode"].ToString(), row, dic);
            }
            if (serialNumberDic.ContainsKey("OrgCode"))
            {
                OrgCode = uiFO.ReplaceString(serialNumberDic["OrgCode"].ToString(), row, dic);
            }
            if (serialNumberDic.ContainsKey("UserCode"))
            {
                UserCode = uiFO.ReplaceString(serialNumberDic["UserCode"].ToString(), row, dic);
            }

            SerialNumberParam param = new SerialNumberParam()
            {
                Code            = formCode,
                PrjCode         = PrjCode,
                OrgCode         = OrgCode,
                UserCode        = UserCode,
                CategoryCode    = CategoryCode,
                SubCategoryCode = SubCategoryCode,
                OrderNumCode    = OrderNumCode
            };

            string SerialNumber = SerialNumberHelper.GetSerialNumberString(tmpl, param, resetRule, applySerialNumber);

            return(SerialNumber);
        }
        protected override void AfterGetData(Dictionary <string, object> dic, bool isNew, string upperVersionID)
        {
            if (isNew)
            {
                string engineeringInfo = GetQueryString("EngineeringInfo");
                if (string.IsNullOrEmpty(engineeringInfo))
                {
                    throw new Formula.Exceptions.BusinessValidationException("请选择项目!");
                }

                string sql = string.Format("select * from S_I_Engineering where ID='{0}' ", engineeringInfo);
                var    dt  = EPCSQLDB.ExecuteDataTable(sql);
                if (dt.Rows.Count == 0)
                {
                    throw new Formula.Exceptions.BusinessValidationException("所选项目不存在!");
                }
                var engineering = FormulaHelper.DataRowToDic(dt.Rows[0]);

                dic.SetValue("EngineeringInfo", engineering.GetValue("ID"));
                dic.SetValue("EngineeringInfoName", engineering.GetValue("Name"));
                dic.SetValue("Code", engineering.GetValue("SerialNumber"));

                SerialNumberParam param = new SerialNumberParam()
                {
                    Code            = "TCMWorkingContact",
                    PrjCode         = "",
                    OrgCode         = "",
                    UserCode        = "",
                    CategoryCode    = "",
                    SubCategoryCode = "",
                    OrderNumCode    = ""
                };
                var serialNumber = SerialNumberHelper.GetSerialNumberString("{YY}{MM}{DD}-{NNNN}", param, "YearCode,MonthCode", true);

                dic.SetValue("SerialNumber", serialNumber);
                dic.SetValue("MainCompany", engineering.GetValue("CustomerInfo"));
                dic.SetValue("MainCompanyName", engineering.GetValue("CustomerInfoName"));
                dic.SetValue("SendCompany", CurrentUserInfo.UserOrgID);
                dic.SetValue("SendCompanyName", CurrentUserInfo.UserOrgName);
                dic.SetValue("ID", FormulaHelper.CreateGuid());
            }
        }
        //单个物资到货,自动补到货单,一货一单
        protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew)
        {
            base.BeforeSave(dic, formInfo, isNew);

            if (!isNew)
            {
                return;
            }

            S_P_Arrival arrival = new S_P_Arrival();

            arrival.ID = FormulaHelper.CreateGuid();

            S_P_ContractInfo_Content content = EPCEntites.Set <S_P_ContractInfo_Content>().Find(dic.GetValue("BomInfo"));

            if (content == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("未找到物资信息");
            }

            decimal quantity = 0;

            decimal.TryParse(dic.GetValue("Quantity"), out quantity);
            if (quantity < 0)
            {
                throw new Formula.Exceptions.BusinessValidationException("到货数量不能为" + quantity);
            }

            //可能多发不判断
            //decimal quantity = 0;
            //decimal.TryParse(dic.GetValue("Quantity"), out quantity);
            //decimal hasArrivalQuantity = EPCEntites.Set<S_P_Arrival_DetailInfo>().Where(a => a.BomInfo == content.ID).ToList().Sum(a => a.Quantity ?? 0);
            //decimal sumRest = content.ContractQuantity ?? 0 - hasArrivalQuantity;
            //if (quantity > sumRest)
            //{
            //    throw new Formula.Exceptions.BusinessValidationException("到货数量超出了剩余数量" + sumRest);
            //}

            arrival.CreateDate          = DateTime.Now;
            arrival.ModifyDate          = DateTime.Now;
            arrival.CreateUserID        = CurrentUserInfo.UserID;
            arrival.CreateUser          = CurrentUserInfo.UserName;
            arrival.ModifyUserID        = CurrentUserInfo.UserID;
            arrival.ModifyUser          = CurrentUserInfo.UserName;
            arrival.OrgID               = CurrentUserInfo.UserOrgID;
            arrival.CompanyID           = CurrentUserInfo.UserCompanyID;
            arrival.FlowPhase           = "Start";
            arrival.StepName            = "";
            arrival.EngineeringInfoName = content.S_P_ContractInfo.EngineeringInfoName; //dic.GetValue("EngineeringInfoName");
            arrival.EngineeringInfoCode = content.S_P_ContractInfo.EngineeringInfoCode; // dic.GetValue("EngineeringInfoCode");
            arrival.ContractInfo        = content.S_P_ContractInfo.ID;                  // dic.GetValue("ContractInfo");
            arrival.ContractInfoName    = content.S_P_ContractInfo.Name;                // dic.GetValue("ContractInfoName");
            arrival.ContractCode        = content.S_P_ContractInfo.SerialNumber;        // dic.GetValue("ContractInfoNum");
            arrival.ArrivalDate         = Convert.ToDateTime(dic.GetValue("ArrivalDate"));
            arrival.CheckUser           = CurrentUserInfo.UserID;
            arrival.CheckUserName       = CurrentUserInfo.UserName;

            var form = baseEntities.Set <S_UI_Form>().Where(c => c.Code == "Arrival").OrderByDescending(c => c.ID).FirstOrDefault(); //获取最新一个版本即可

            if (form == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("表单编号为Arrival不存在!");
            }
            string            SerialNumberSettings = form.SerialNumberSettings;
            var               serialNumberDic      = JsonHelper.ToObject(SerialNumberSettings);
            SerialNumberParam param     = new SerialNumberParam();
            string            tmpl      = serialNumberDic["Tmpl"].ToString();
            string            resetRule = serialNumberDic["ResetRule"].ToString();

            arrival.SerialNumber = SerialNumberHelper.GetSerialNumberString(tmpl, param, resetRule, true);

            arrival.SendFormID        = ""; //没有发货单可关联
            arrival.SendFormIDName    = ""; //同上
            arrival.CheckDate         = DateTime.Now;
            arrival.CheckResult       = ""; //无
            arrival.Register          = CurrentUserInfo.UserID;
            arrival.RegisterName      = CurrentUserInfo.UserName;
            arrival.RegisterDate      = DateTime.Now;
            arrival.Remark            = "来自手机端扫描入库";
            arrival.EngineeringInfoID = content.S_P_ContractInfo.EngineeringInfoID;// dic.GetValue("EngineeringInfoID");
            EPCEntites.Set <S_P_Arrival>().Add(arrival);
            EPCEntites.SaveChanges();

            dic.SetValue("PBomID", content.PBomID);
            dic.SetValue("Code", content.Code);
            dic.SetValue("Sepcification", content.Model);
            dic.SetValue("Unit", content.Unit);
            //dic.SetValue("BomInfo", content.ID);
            dic.SetValue("BomInfoName", content.Name);
            dic.SetValue("Name", content.Name);
            dic.SetValue("S_P_ArrivalID", arrival.ID);
        }