Esempio n. 1
0
        public dynamic PostCreateDispatchPlanList(dynamic data)
        {
            int    DispatchModelCode = data.DispatchModelCode;
            string ContractCode      = data.ContractCode;
            int    ProductID         = data.ProductID;
            int    PlanQuantity      = data.PlanQuantity;
            string PlanCode          = MmsHelper.GetLSNumber("APS_DispatchPlanMain", "PlanCode", "DDJH", "", "");
            var    plan_list         = new List <APS_DispatchPlanDetail>();
            var    model_list        = new APS_BN_DispatchModelDetailService().GetModelList(ParamQuery.Instance().AndWhere("MainID", DispatchModelCode).OrderBy("ID"));
            int    Seq = 1;

            for (int i = 0; i < PlanQuantity; i++)
            {
                model_list.ForEach(model =>
                {
                    APS_DispatchPlanDetail plan = new APS_DispatchPlanDetail();
                    plan.PlanCode = PlanCode;
                    plan.TaskName = model.Name;
                    plan.WorkHour = model.TaskCycle;
                    plan.Seq      = Seq;
                    plan_list.Add(plan);
                    Seq++;
                });
            }
            return(new
            {
                plan_list = plan_list
            });
        }
Esempio n. 2
0
        public void Edit(dynamic data)
        {
            var formWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>
        APS_BN_DispatchModelMain
    </table>
    <where>
        <field name='ID' cp='equal'></field>
    </where>
</settings>
");

            var tabsWrapper = new List <RequestWrapper>();

            tabsWrapper.Add(RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>APS_BN_DispatchModelDetail</table>
    <where>
        <field name='ID' cp='equal'></field>      
    </where>
</settings>"));

            var service = new APS_BN_DispatchModelDetailService();

            if (data.form["Code"] == "系统生成")
            {
                string documentNo = MmsHelper.GetLSNumber("APS_BN_DispatchModelMain", "Code", "DDMX", "", "");
                data.form["Code"] = documentNo;
            }
            var result = service.EditPage(data, formWrapper, tabsWrapper);
        }
        public void Edit(dynamic data)
        {
            var id     = data.form["ID"].ToString();
            var pQuery = ParamQuery.Instance().Select("*").AndWhere("ID", id);
            var re     = new PRS_ProcessRouteModelMainService().GetModelList(pQuery);

            if (re.Count > 0 && re[0].BillState == 1)
            {
                MmsHelper.ThrowHttpExceptionWhen(true, "已审核数据不能修改!");
                return;
            }
            var formWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>
        PRS_ProcessRouteModelMain
    </table>
    <where>
        <field name='ID' cp='equal'></field>
    </where>
</settings>
");

            var tabsWrapper = new List <RequestWrapper>();

            tabsWrapper.Add(RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>PRS_ProcessRouteModelDetail</table>
    <where>
        <field name='ID' cp='equal'></field>      
    </where>
</settings>"));

            var service = new PRS_ProcessRouteModelMainService();

            if (data.form["ProcessRouteCode"] == "系统生成")
            {
                string documentNo = MmsHelper.GetLSNumber("PRS_ProcessRouteModelMain", "ProcessRouteCode", "GYMX", "", "");
                data.form["ProcessRouteCode"] = documentNo;
            }


            var result = service.EditPage(data, formWrapper, tabsWrapper);
        }
Esempio n. 4
0
        public int SaveProcessRouteModel(dynamic data)
        {
            var pQuery = ParamQuery.Instance()
                         .Select("*")
                         .AndWhere("ContractCode", data["ContractCode"].ToString())
                         .AndWhere("PartCode", data["PartCode"].ToString())
                         .AndWhere("ProcessModelType", data["ProcessModelType"].ToString());

            var    mainID  = "";
            string cPerson = MmsHelper.GetUserName();
            var    list    = new PRS_ProcessRouteModelMainService().GetModelList(pQuery);

            if (list.Count > 0)
            {
                mainID = list[0].ID.ToString();
            }
            PRS_ProcessRouteModelMain master = new PRS_ProcessRouteModelMain();
            int rowsAffected = 0;

            if (string.IsNullOrEmpty(mainID))
            {
                master.ProcessRouteCode = MmsHelper.GetLSNumber("PRS_ProcessRouteModelMain", "ProcessRouteCode", "GYMX", "", "");
                master.ProcessRouteName = data["PartName"].ToString();
                master.BillState        = 0;
                master.IsEnable         = 1;
                master.ContractCode     = data["ContractCode"].ToString();
                master.PartCode         = data["PartCode"].ToString();
                master.PartFigure       = data["PartFigureCode"].ToString();
                master.CraetePerson     = MmsHelper.GetUserName();
                master.CreateTime       = DateTime.Now;
                master.ModifyPerson     = master.CraetePerson;
                master.ModifyTime       = master.CreateTime;
                master.ProcessModelType = data["ProcessModelType"].ToString();
                db.UseTransaction(true);
                rowsAffected = db.Sql(@"insert into PRS_ProcessRouteModelMain (ID,ProcessRouteCode,ProcessRouteName,BillState,IsEnable,ContractCode,PartCode,PartFigure,
CraetePerson,CreateTime,ModifyPerson,ModifyTime,ProcessModelType) values(((select isnull( MAX(id),0)+1 from PRS_ProcessRouteModelMain)),@0,@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11)",
                                      master.ProcessRouteCode, master.ProcessRouteName, master.BillState, master.IsEnable, master.ContractCode, master.PartCode, master.PartFigure, master.CraetePerson,
                                      master.CreateTime, master.ModifyPerson, master.ModifyTime, master.ProcessModelType).Execute();
                if (rowsAffected < 0)
                {
                    db.Rollback();
                    return(rowsAffected);
                }
            }
            else
            {
                master = list[0];
            }
            var sql = String.Format(@"update PRS_ProcessRouteModelMain set BillState=0,ModifyPerson='{1}',ModifyTime='{2}' where ID = '{0}'", master.ID, MmsHelper.GetUserName(), DateTime.Now);

            db.Sql(sql).Execute();
            sql = String.Format(@"select * from PRS_ProcessRouteModelMain where ProcessRouteCode = '{0}'", master.ProcessRouteCode);
            dynamic next   = db.Sql(sql).QuerySingle <dynamic>();//
            string  delSql = "";

            sql = String.Format(@"select * from PRS_ProcessRouteModelDetail where MainID = '{0}'", next.ID);
            var detalList = db.Sql(sql).QueryMany <PRS_ProcessRouteModelDetail>();

            foreach (var item in detalList)
            {
                delSql = String.Format(@"delete PRS_ProcessRouteModelEquipment where MainID = '{0}'", item.ID);
                db.Sql(delSql).Execute();
                delSql = String.Format(@"delete PRS_ProcessModelWorkSteps where MainID = '{0}'", item.ID);
                db.Sql(delSql).Execute();
            }

            delSql = String.Format(@"delete PRS_ProcessRouteModelDetail where MainID = '{0}'", next.ID);
            db.Sql(delSql).Execute();

            foreach (var item in data.model)
            {
                PRS_ProcessRouteModelDetail detail = new PRS_ProcessRouteModelDetail();
                detail.MainID          = next.ID;
                detail.ProcessCode     = item.ProcessCode;
                detail.ProcessName     = item.ProcessName;
                detail.ProcessLineCode = item.ProcessLineCode;
                detail.DepartmentCode  = item.WorkshopID;
                detail.IsEnable        = 1;
                detail.CraetePerson    = MmsHelper.GetUserName();
                detail.CreateTime      = DateTime.Now;
                detail.ModifyPerson    = detail.CraetePerson;
                detail.ModifyTime      = detail.CreateTime;
                var detailID = db.Insert <PRS_ProcessRouteModelDetail>("PRS_ProcessRouteModelDetail", detail)
                               .AutoMap(x => x.ID).ExecuteReturnLastId <int>();
                if (detailID < 0)
                {
                    db.Rollback();
                    return(detailID);
                }

                sql = String.Format(@"select * from MES_BN_ProductProcessRouteEquipment where ProcessRouteID = '{0}'", item.ID);
                var eqpList = db.Sql(sql).QueryMany <MES_BN_ProductProcessRouteEquipment>();//
                foreach (var eqp in eqpList)
                {
                    PRS_ProcessRouteModelEquipment detail1 = new PRS_ProcessRouteModelEquipment();
                    detail1.MainID        = detailID;
                    detail1.EquipmentCode = eqp.EquipmentCode;
                    detail1.EquipmentName = eqp.EquipmentName;
                    detail1.epqID         = eqp.epqID;
                    detail1.IsEnable      = 1;
                    detail1.CreatePerson  = MmsHelper.GetUserName();
                    detail1.CreateTime    = DateTime.Now;
                    detail1.ModifyPerson  = detail1.CreatePerson;
                    detail1.ModifyTime    = detail1.CreateTime;
                    rowsAffected          = db.Insert <PRS_ProcessRouteModelEquipment>("PRS_ProcessRouteModelEquipment", detail1)
                                            .AutoMap(x => x.ID)
                                            .Execute();
                    if (rowsAffected < 0)
                    {
                        db.Rollback();
                        return(rowsAffected);
                    }
                }
                sql = String.Format(@"select * from PRS_ProcessWorkSteps where ProcessRouteID = '{0}'", item.ID);
                var stepList = db.Sql(sql).QueryMany <PRS_ProcessWorkSteps>();//
                foreach (var step in stepList)
                {
                    PRS_ProcessModelWorkSteps detail2 = new PRS_ProcessModelWorkSteps();
                    detail2.MainID            = detailID;
                    detail2.WorkStepsLineCode = step.WorkStepsLineCode;
                    detail2.WorkStepsName     = step.WorkStepsName;
                    detail2.WorkStepsContent  = step.WorkStepsContent;
                    //detail2.ManHours = step.ManHours;
                    detail2.Unit         = step.Unit;
                    detail2.IsEnable     = 1;
                    detail2.CreatePerson = MmsHelper.GetUserName();
                    detail2.CreateTime   = DateTime.Now;
                    detail2.ModifyPerson = detail2.CreatePerson;
                    detail2.ModifyTime   = detail2.CreateTime;
                    rowsAffected         = db.Insert <PRS_ProcessModelWorkSteps>("PRS_ProcessModelWorkSteps", detail2)
                                           .AutoMap(x => x.ID)
                                           .Execute();
                    if (rowsAffected < 0)
                    {
                        db.Rollback();
                        return(rowsAffected);
                    }
                }
            }

            db.Commit();
            return(1);
        }