Beispiel #1
0
        public ActionResult Index()
        {
            var code             = new sys_codeService();
            var WorkshopCodeList = new SYS_WorkGroupService()
                                   .GetModelList(ParamQuery.Instance()
                                                 .Select("DISTINCT b.DepartID")
                                                 .From("SYS_WorkGroupDetail a LEFT JOIN SYS_WorkGroup b ON a.MainID=b.ID")
                                                 .AndWhere("a.UserCode", MmsHelper.GetUserCode()));
            var WorkshopCode = "";

            var deptInfo = new SYS_BN_DepartmentService().GetDeptInfoByUCode(MmsHelper.GetUserCode());

            if (WorkshopCodeList.Count > 0)
            {
                WorkshopCode = WorkshopCodeList.FirstOrDefault().DepartID;
            }
            //ViewBag.WorkshopCode = WorkshopCode;
            ViewBag.WorkshopCode = deptInfo.DepartmentCode;
            var model = new
            {
                dataSource = new
                {
                },
                urls = new
                {
                    query  = "/api/Mms/MES_WorkingTicket",
                    newkey = "/api/Mms/MES_WorkingTicket/getnewkey",
                    edit   = "/api/Mms/MES_WorkingTicket/edit"
                },
                resx = new
                {
                    noneSelect   = "请先选择一条数据!",
                    editSuccess  = "保存成功!",
                    auditSuccess = "单据已审核!"
                },
                form = new
                {
                    WorkTicketCode = "",
                    ApsCode        = "",
                    TeamName       = "",
                    WorkshopName   = deptInfo == null?"": deptInfo.DepartmentName,
                    ProcessName    = "",
                    WorkStepsName  = "",
                    EquipmentName  = "",
                    ApproveState   = ""
                },
                defaultRow = new
                {
                    IsEnable = 1
                },
                setting = new
                {
                    idField        = "ID",
                    postListFields = new string[] { "ID", "WorkTicketCode", "TicketLevel", "ApsCode", "WorkStepsID", "IsEnable", "WorkshopCode", "WorkshopName", "TeamCode", "TeamName", "CreateTime", "CreatePerson", "ModifyTime", "ModifyPerson", "ActualStartTime", "ActualFinishTime", "ApproveState", "ApprovePerson", "ApproveTime", "ProcessCode", "ProcessName", "WorkStepsName", "WorkStepsLineCode", "WorkStepsContent", "EquipmentCode", "EquipmentName", "TurnTargetName", "TurnTargetCode", "PartCode", "WorkQuantity", "ApproveRemark" }
                }
            };

            return(View(model));
        }
Beispiel #2
0
        public void Audit(string id, JObject data)
        {
            var pUpdate = ParamUpdate.Instance()
                          .Update("SYS_WorkGroup")
                          .Column("ApproveState", data["status"])
                          .Column("ApproveRemark", data["comment"])
                          .Column("ApprovePerson", FormsAuth.GetUserData().UserName)
                          .Column("ApproveDate", DateTime.Now)
                          .AndWhere("ID", id);

            var service      = new SYS_WorkGroupService();
            var rowsAffected = service.Update(pUpdate);

            MmsHelper.ThrowHttpExceptionWhen(rowsAffected < 0, "单据审核失败[BillNo={0}],请重试或联系管理员!", id);
        }
Beispiel #3
0
        public dynamic GetPageData(string id)
        {
            var masterService = new SYS_WorkGroupService();
            var pQuery        = ParamQuery.Instance().AndWhere("ID", id);
            var pQuery2       = ParamQuery.Instance().AndWhere("MainID", id);

            var result = new
            {
                //主表数据
                form       = masterService.GetModel(pQuery),
                scrollKeys = masterService.ScrollKeys("ID", id),

                //明细数据
                tab0 = new SYS_WorkGroupDetailService().GetDynamicList(pQuery2)
            };

            return(result);
        }
Beispiel #4
0
        public dynamic Get(RequestWrapper query)
        {
            query.LoadSettingXmlString(@"
<settings defaultOrderBy='ID'>
    <select>*</select>
    <from>SYS_WorkGroup</from>
    <where defaultForAll='true' defaultCp='equal' defaultIgnoreEmpty='true' >
        <field name='TeamCode'		cp='equal'></field>   
        <field name='TeamName'		cp='equal'></field>   
        <field name='DepartName'		cp='equal'></field>   
    </where>
</settings>");
            var service = new SYS_WorkGroupService();
            //dynamic depart = new SYS_BN_UserService().GetDepartment(MmsHelper.GetUserCode());
            //if (depart == null)
            //{
            //    return null;
            //}
            //var pQuery = query.ToParamQuery().AndWhere("DepartName", depart.DepartmentName);
            var pQuery = query.ToParamQuery();
            var result = service.GetDynamicListWithPaging(pQuery.AndWhere("IsEnable", 1));

            return(result);
        }
Beispiel #5
0
        public void Edit(dynamic data)
        {
            dynamic depart = new SYS_BN_UserService().GetDepartment(MmsHelper.GetUserCode());
            string  code   = string.Empty;
            string  name   = string.Empty;

            if (depart != null)
            {
                code = depart.DepartmentCode;
                name = depart.DepartmentName;
            }

            if (data.form["TeamCode"] == "系统生成")
            {
                if (data.form["TeamName"] == "")
                {
                    MmsHelper.ThrowHttpExceptionWhen(true, "班组名称不能为空!", 0);
                    return;
                }
                string documentNo = MmsHelper.GetOrderNumber("SYS_WorkGroup", "BillCode", code, "", "");
                data.form["BillCode"] = documentNo;
                documentNo            = documentNo.Replace(DateTime.Now.ToString("yyMMdd") + "0", "");
                data.form["TeamCode"] = documentNo;
            }
            foreach (JToken tab in data["tabs"].Children())
            {
                foreach (JProperty item in tab.Children())
                {
                    if (item.Name == "deleted")
                    {
                        continue;
                    }
                    foreach (var row in item.Value.Children())
                    {
                        var pQuery = ParamQuery.Instance().Select("ID").AndWhere("UserCode", row["UserCode"]).AndWhere("IsEnable", 1);
                        var re     = new SYS_WorkGroupDetailService().GetModel(pQuery);
                        if (re != null)
                        {
                            if (re.ID > 0)
                            {
                                MmsHelper.ThrowHttpExceptionWhen(true, "员工" + row["UserName"] + "已在别的班组!", 0);
                                return;
                            }
                        }
                    }
                }
            }
            var formWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>
        SYS_WorkGroup
    </table>
    <where>
        <field name='ID' cp='equal'></field>
    </where>
</settings>
");

            var tabsWrapper = new List <RequestWrapper>();

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

            var service = new SYS_WorkGroupService();
            var result  = service.EditPage(data, formWrapper, tabsWrapper);
        }