Пример #1
0
        /// <summary>
        /// 获取固定数据
        /// </summary>
        /// <param name="LineId">线体ID</param>
        /// <param name="TenantID">企业ID</param>
        /// <returns></returns>
        public ActionResult GetLineData(string LineId, string TenantID)
        {
            ResponseObject result = new ResponseObject();
            minimes_order_recordService reportService = new minimes_order_recordService();
            List <minimes_order_record> reportList    = reportService.GetModelList(
                ParamQuery.Instance()
                .AndWhere("LineId", LineId)
                //.AndWhere("PlanDate", DateTime.Now.Date)
                .AndWhere("State", 1)
                .AndWhere("TenantID", TenantID)
                );

            if (reportList.Count > 0)
            {
                minimes_order_record row      = reportList[0];
                List <dynamic>       linelist = ApiDataSource.GetLineList(TenantID, null, null, LineId, null).ToObject <List <dynamic> >();
                foreach (var item in linelist)
                {
                    row.DifferPerson = item.StandUsers - row.Person;
                    row.PlanPerson   = item.StandUsers;
                }

                row.DifferQty     = row.PlanQty - row.Qty;
                row.CreateDateStr = row.CreateDate.ToString("yyyy-MM-dd HH:mm:ss");
                if (row.UPH > 0)                                                   //标准UPH
                {
                    row.PlanCT = Math.Round((double)3600 / row.UPH, 2).ToString(); //标准CT
                }
                else
                {
                    row.PlanCT = "0";
                }

                dynamic rows = new
                {
                    Person      = row.Person,      //实际人数
                    ProductName = row.ProductName, //产品名称
                    OrderNo     = row.OrderNo,     //工单编号
                    ProductCode = row.ProductCode, //产品编号
                    PlanQty     = row.PlanQty,     //计划产量
                    Ratio       = row.Ratio,       //单次计数
                    PlanUPH     = row.UPH,         // 标准UPH
                    PlanCT      = row.PlanCT       //标准C/T
                };
                result.status  = true;
                result.message = "";
                result.rows    = rows;
            }
            else
            {
                result.message = "获取不到数据。";
            }
            string js = JsonConvert.SerializeObject(result);

            return(Json(js, "application/json", JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        /// <summary>
        /// 获取工单进度
        /// </summary>
        /// <param name="WorkShopId"></param>
        /// <param name="TenantID"></param>
        /// <returns></returns>
        public dynamic GetOrderNoProgress(string WorkShopId, string TenantID)
        {
            LineBoardController lineboardController = new LineBoardController();

            List <dynamic> result = new List <dynamic>();

            try
            {
                minimes_order_recordService reportService = new minimes_order_recordService();
                List <minimes_order_record> reportList    = reportService.GetModelList(ParamQuery.Instance().AndWhere("WorkShopId", WorkShopId).AndWhere("State", 1).AndWhere("TenantID", TenantID).OrderBy("LineId ASC"));
                foreach (var item in reportList)
                {
                    minimes_order_record row = new minimes_order_record();

                    row.LineId      = item.LineId;      //产线ID
                    row.LineName    = item.LineName;    //产线名称
                    row.OrderNo     = item.OrderNo;     //工单编号
                    row.ProductCode = item.ProductCode; //产品编号
                    row.ProductName = item.ProductName; //产品名称
                    row.Qty         = item.Qty;         //实际产量
                    row.PlanQty     = item.PlanQty;     //计划产量
                    row.StopCount   = item.StopTime;    //停机时间

                    if (row.PlanQty == 0)
                    {
                        row.PlanRatio = "0%";
                    }
                    else
                    {
                        row.PlanRatio = Math.Round((double)row.Qty * 100 / row.PlanQty, 2) + "%";//计划达成率
                    }

                    //生产时间
                    int ProductTime = lineboardController.GetProductTime(row.OrderNo, TenantID) - lineboardController.GetLostTime(row.OrderNo, TenantID);//分钟

                    //稼动率
                    double Utilization = 0;
                    if (ProductTime != 0)
                    {
                        Utilization = Math.Round((double)(ProductTime - row.StopTime) * 100 / (ProductTime), 2);
                    }
                    row.Utilization = Utilization + "%";
                    result.Add(row);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Пример #3
0
 public void Edit(dynamic data)
 {
     var listWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
     <settings>
         <table>
             minimes_order_record
         </table>
         <where>
             <field name='ID' cp='equal'></field>
         </where>
     </settings>");
     var service     = new minimes_order_recordService();
     var result      = service.Edit(null, listWrapper, data);
 }
Пример #4
0
        public dynamic Get(RequestWrapper query)
        {
            query.LoadSettingXmlString(@"
            <settings defaultOrderBy='ID'>
                <select>*</select>
                <from>minimes_order_record</from>
                <where defaultForAll='true' defaultCp='equal' defaultIgnoreEmpty='true' >
                    <field name='PlanDate'		cp='daterange'></field>
                     <field name='OrderNo'		cp='equal'></field>   
                     <field name='TenantId'		cp='equal'></field>   
                </where>
            </settings>");
            var service = new minimes_order_recordService();
            var pQuery  = query.ToParamQuery();
            var result  = service.GetDynamicListWithPaging(pQuery);

            return(result);
        }
Пример #5
0
        /// <summary>
        /// 获取模数信息
        /// </summary>
        /// <param name="OrderNo"></param>
        /// <returns></returns>
        public ActionResult GetMouldData(string OrderNo)
        {
            int ActualMould   = 0;
            int StandardMould = 0;
            minimes_order_recordService orderrecordService = new minimes_order_recordService();
            List <minimes_order_record> orderrecordList    = orderrecordService.GetModelList(ParamQuery.Instance().AndWhere("OrderNo", OrderNo));

            if (orderrecordList.Count != 0)
            {
                ActualMould   = orderrecordList[0].ActualMould;
                StandardMould = orderrecordList[0].StandardMould;
            }
            var result = new
            {
                ActualMould   = ActualMould,
                StandardMould = StandardMould,
            };
            string js = JsonConvert.SerializeObject(result);

            return(Json(js, "application/json", JsonRequestBehavior.AllowGet));
        }
Пример #6
0
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <param name="OrderNo"></param>
        /// <returns></returns>
        public ActionResult GetData(string OrderNo)
        {
            int UPH    = 0;
            int Person = 0;
            int Ratio  = 1;
            minimes_order_recordService orderrecordService = new minimes_order_recordService();
            List <minimes_order_record> orderrecordList    = orderrecordService.GetModelList(ParamQuery.Instance().AndWhere("OrderNo", OrderNo));

            if (orderrecordList.Count != 0)
            {
                UPH    = orderrecordList[0].UPH;
                Person = orderrecordList[0].Person;
                Ratio  = orderrecordList[0].Ratio;
            }
            var result = new
            {
                UPH    = UPH,
                Person = Person,
                Ratio  = Ratio
            };
            string js = JsonConvert.SerializeObject(result);

            return(Json(js, "application/json", JsonRequestBehavior.AllowGet));
        }
Пример #7
0
        /// <summary>
        /// 获取当前车间各机台生产状态
        /// </summary>
        /// <param name="WorkShopId"></param>
        /// <param name="TenantID"></param>
        /// <returns></returns>
        public dynamic GetLineStatus(string WorkShopId, string TenantID)
        {
            List <minimes_order_record> result = new List <minimes_order_record>();

            try
            {
                List <dynamic> linelist = ApiDataSource.GetLineList(TenantID, WorkShopId, null, null, null).ToObject <List <dynamic> >();
                result = new List <minimes_order_record>();
                minimes_order_recordService reportService = new minimes_order_recordService();
                List <minimes_order_record> reportList    = reportService.GetModelList(ParamQuery.Instance().AndWhere("State", 1).AndWhere("TenantID", TenantID));
                foreach (var item1 in linelist)
                {
                    //屏蔽
                    if (item1.LineId != "2d6a9f23-c1dc-4a6d-baa7-473011e4954c" && item1.LineId != "d3bb37bd-0aff-4c6a-96a0-d544c136a018")
                    {
                        minimes_order_record row = new minimes_order_record();
                        row.LineId    = item1.LineId + "";   //产线ID
                        row.LineName  = item1.LineName + ""; //产线名称
                        row.Color     = "grey";              //状态颜色
                        row.StateName = "未切单";               //状态名称

                        result.Add(row);

                        foreach (var item in reportList)
                        {
                            if (row.LineId == item.LineId)
                            {
                                row.Qty        = item.Qty;
                                row.PlanQty    = item.PlanQty;
                                row.ReserveQty = item.ReserveQty;

                                minimes_resttimeService resttimeService = new minimes_resttimeService();
                                List <minimes_resttime> resttimeList    = resttimeService.GetModelList(ParamQuery.Instance().AndWhere("WorkShopId", WorkShopId).AndWhere("TenantId", TenantID));

                                string IsRest = "0";//默认值
                                if (resttimeList.Count != 0)
                                {
                                    foreach (var item_rest in resttimeList)
                                    {
                                        string   Time      = item_rest.RestTime;
                                        string[] TimeArr   = Time.Split('-');
                                        DateTime StartTime = Convert.ToDateTime(TimeArr[0]);
                                        DateTime EndTime   = Convert.ToDateTime(TimeArr[1]);
                                        DateTime nowTime   = Convert.ToDateTime(DateTime.Now.ToShortTimeString());
                                        if ((nowTime >= StartTime && nowTime <= EndTime))
                                        {
                                            IsRest = "1";//在休息时间区间
                                        }
                                    }
                                }

                                if (row.PlanQty + row.ReserveQty <= row.Qty)//已完成 注;实际产量大于等于计划产量加备存数据 工单才完工
                                {
                                    row.StateName = "已完成";
                                    row.Color     = "green";
                                }
                                else if (item.MachineState == 1)
                                {
                                    row.StateName = "生产中";
                                    row.Color     = "blue";
                                }
                                else if (item.MachineState == 0 && IsRest == "1")
                                {
                                    row.StateName = "休息中";
                                    row.Color     = "orange";
                                }
                                else
                                {
                                    row.StateName = "停机中";
                                    row.Color     = "red";
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Пример #8
0
        /// <summary>
        /// 确认切单
        /// </summary>
        /// <param name="WorkSheetNo">工单号</param>
        /// <param name="UPH">UPH</param>
        /// <param name="Ratio">拼板数</param>
        /// <param name="Person">人数</param>
        /// <param name="PlanPerson">计划人数</param>
        /// <param name="LineId">线体ID</param>
        /// <param name="TenantID">企业ID</param>
        /// <returns></returns>
        public ActionResult OrderOK(string WorkSheetNo, string UPH, string Ratio, string Person, string PlanPerson, string LineId, string TenantID, string ActualMould, string StandardMould)
        {
            string js = "";

            try
            {
                if (!string.IsNullOrEmpty(WorkSheetNo))
                {
                    DateTime OrderPlanDate = DateTime.Now.Date;
                    //List < dynamic > worksheetlist = ApiDataSource.GetWorkSheetList(TenantID, OrderPlanDate, null, WorkSheetNo, null).ToObject<List<dynamic>>();
                    //List<dynamic> worksheetlist = ApiDataSource.GetWorkSheetList(TenantID, WorkSheetNo, null, null, null, null, null, null, null, null).ToObject<List<dynamic>>();
                    //获取工单详细信息


                    List <dynamic> worksheetlist = ApiDataSource.GetWorkSheetDetail(TenantID, WorkSheetNo).ToObject <List <dynamic> >();
                    string         OrderNo       = worksheetlist[0].WorkSheetNo;
                    string         LineName      = worksheetlist[0].LineName;
                    string         ProductCode   = worksheetlist[0].ProductCode;
                    string         MaterialCode  = worksheetlist[0].MaterialCode;
                    string         ProductName   = worksheetlist[0].ProductName;
                    DateTime       PlanDate      = DateTime.Now.Date;
                    int            PlanQty       = worksheetlist[0].PlanCount;
                    int            ReserveQty    = worksheetlist[0].BackupsCount;//备存数量


                    string APSLineId   = worksheetlist[0].LineId;
                    string APSLineName = worksheetlist[0].LineName;

                    List <dynamic> linelist = ApiDataSource.GetLineList(TenantID, null, null, LineId, null).ToObject <List <dynamic> >();
                    if (linelist != null && linelist.Count > 0)
                    {
                        LineName = linelist[0].LineName;
                    }

                    string  WorkShopId   = "";
                    string  WorkShopName = "";
                    dynamic LineList     = ApiDataSource.GetLineList(TenantID, null, null, LineId, null);
                    foreach (var item_line in LineList)
                    {
                        WorkShopId   = item_line.WorkShopId;
                        WorkShopName = item_line.WorkShopName;
                    }
                    minimes_order_recordService reportService = new minimes_order_recordService();
                    using (var db = Db.Context("MiniMes"))
                    {
                        List <minimes_order_record> reportList = reportService.GetModelList(
                            ParamQuery.Instance()
                            //.AndWhere("LineId", LineId)
                            //.AndWhere("OrderPlanDate", OrderPlanDate)
                            .AndWhere("OrderNo", WorkSheetNo)
                            .AndWhere("TenantID", TenantID)
                            );
                        //修改状态
                        db.Update("minimes_order_record")
                        .Column("State", 0)
                        .Where("LineId", LineId)
                        .Execute();
                        if (reportList.Count > 0)//该工单已经生产过
                        {
                            if (!reportList[0].LineId.Equals(LineId))
                            {
                                db.Update("minimes_hoursreport").Column("LineId", LineId).Column("LineName", LineName).Where("OrderNo", OrderNo).Execute();
                                ApiDataSource.EditWorkSheetCount(TenantID, OrderNo, LineId, LineName);
                                #region 记录换线的工单

                                db.Insert("minimes_changeorderno")
                                .Column("ID", Guid.NewGuid())
                                .Column("BeforeLineId", APSLineId)     //换线之前产线ID
                                .Column("BeforeLineName", APSLineName) //换线之前产线名称
                                .Column("AfterLineId", LineId)         //换线之后产线ID
                                .Column("AfterLineName", LineName)     //换线之后产线名称
                                .Column("OrderNo", OrderNo)            //工单号
                                .Column("CreateDate", DateTime.Now)    //创建时间
                                .Execute();

                                #endregion
                            }

                            db.Update("minimes_order_record")
                            .Column("UPH", UPH)
                            .Column("Ratio", Ratio)
                            .Column("State", 1)
                            .Column("LineId", LineId)
                            .Column("LineName", LineName)
                            .Column("PlanDate", PlanDate)
                            .Column("Person", Person)
                            .Column("PlanPerson", PlanPerson)
                            .Where("ID", reportList[0].ID)
                            .Execute();
                        }
                        else//该工单未生产过
                        {
                            db.Insert("minimes_order_record")
                            .Column("OrderNo", OrderNo)
                            .Column("WorkShopId", WorkShopId)     //车间ID
                            .Column("WorkShopName", WorkShopName) //车间名称
                            .Column("LineId", LineId)
                            .Column("LineName", LineName)
                            .Column("ProductCode", ProductCode)
                            .Column("ProductName", ProductName)
                            .Column("PlanDate", PlanDate)
                            .Column("OrderPlanDate", OrderPlanDate)
                            .Column("UPH", UPH)
                            .Column("Ratio", Ratio)
                            .Column("QtyNG", 0)
                            .Column("Qty", 0)
                            .Column("PlanQty", PlanQty)
                            .Column("ReserveQty", ReserveQty)
                            .Column("StandardMould", StandardMould) //标准模穴
                            .Column("ActualMould", ActualMould)     //实际模穴
                            .Column("State", 1)
                            .Column("MachineState", 1)
                            .Column("StopCount", 0)
                            .Column("StopTime", 0)
                            .Column("Person", Person)
                            .Column("PlanPerson", PlanPerson)
                            .Column("CreateDate", DateTime.Now)
                            .Column("TenantID", TenantID)
                            .Execute();
                        }
                    }
                }
                else
                {
                    js = "无产品数据";
                }
            }
            catch (Exception ex)
            {
                js = ex.Message;

                #region log

                ILog log = LogManager.GetLogger("logs");
                log.Error("nizeheng 时间:" + DateTime.Now + "----" + "【工单】:" + WorkSheetNo + " 【异常】:" + ex.Message);

                #endregion
            }
            return(Json(js, "application/json", JsonRequestBehavior.AllowGet));
        }
Пример #9
0
        /// <summary>
        /// 下拉框改变
        /// </summary>
        /// <param name="ProductCode">产品型号</param>
        /// <param name="TenantID">企业ID</param>
        /// <returns></returns>
        public ActionResult SelectChange(string ProductCode, string TenantID, string OrderNo)
        {
            int    Ratio         = 1;
            int    UPH           = 1;
            int    StandardMould = 1;
            int    Person        = 1;
            string ActualMould   = "";

            try
            {
                //minimes_productService reportService = new minimes_productService();
                //List<minimes_product> reportList = reportService.GetModelList(
                //ParamQuery.Instance()
                //.AndWhere("InventoryCode", ProductCode)
                //.AndWhere("TenantId", TenantID)
                //);
                //if (reportList.Count > 0)
                //    Ratio = reportList[0].TallyRatio.Value;
                //List<dynamic> worksheetlist = ApiDataSource.GetInventoryList(TenantID, ProductCode, null, null, null, null).ToObject<List<dynamic>>();
                //if (worksheetlist.Count > 0)
                //    UPH = worksheetlist[0].StandardUPH;
                minimes_uphService uphService = new minimes_uphService();
                List <minimes_uph> uphList    = uphService.GetModelList(ParamQuery.Instance().AndWhere("ProductCode", ProductCode).AndWhere("TenantID", TenantID));
                if (uphList.Count != 0)
                {
                    int iStandardUPH = 0;
                    if (uphList[0].StandardUPH != null)
                    {
                        if (int.TryParse(Convert.ToString(uphList[0].StandardUPH), out iStandardUPH))
                        {
                            UPH = iStandardUPH;
                        }
                    }
                    int iRatio = 0;
                    if (uphList[0].Ratio != null)
                    {
                        if (int.TryParse(Convert.ToString(uphList[0].Ratio), out iRatio))
                        {
                            StandardMould = iRatio;;
                        }
                    }
                }


                minimes_order_recordService orderrecordService = new minimes_order_recordService();
                List <minimes_order_record> orderrecordList    = orderrecordService.GetModelList(ParamQuery.Instance().AndWhere("OrderNo", OrderNo));
                if (orderrecordList.Count != 0)
                {
                    Ratio         = orderrecordList[0].Ratio;
                    UPH           = orderrecordList[0].UPH;
                    StandardMould = orderrecordList[0].StandardMould;
                    Person        = orderrecordList[0].Person;
                    ActualMould   = orderrecordList[0].ActualMould.ToString();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            var result = new
            {
                Ratio         = Ratio,
                UPH           = UPH,
                StandardMould = StandardMould,
                Person        = Person,
                ActualMould   = ActualMould
            };
            string js = JsonConvert.SerializeObject(result);

            return(Json(js, "application/json", JsonRequestBehavior.AllowGet));;
        }
Пример #10
0
        /// <summary>
        /// 获取实时数据
        /// </summary>
        /// <param name="LineId">线体ID</param>
        /// <param name="TenantID">企业ID</param>
        /// <returns></returns>
        public ActionResult GetLineOrderData(string LineId, string TenantID)
        {
            ResponseObject result = new ResponseObject();
            minimes_order_recordService reportService = new minimes_order_recordService();
            List <minimes_order_record> reportList    = reportService.GetModelList(
                ParamQuery.Instance()
                .AndWhere("LineId", LineId)
                //.AndWhere("PlanDate", DateTime.Now.Date)
                .AndWhere("State", 1)
                .AndWhere("TenantID", TenantID)
                );

            if (reportList.Count > 0)
            {
                minimes_order_record row     = reportList[0];
                string         WorkSheetNo   = row.OrderNo;
                List <dynamic> worksheetlist = ApiDataSource.GetWorkSheetDetail(TenantID, WorkSheetNo).ToObject <List <dynamic> >();

                string WorkShopId = "";
                minimes_resttimeService resttimeService = new minimes_resttimeService();
                dynamic LineList = ApiDataSource.GetLineList(TenantID, null, null, LineId, null);
                foreach (var item_line in LineList)
                {
                    WorkShopId = item_line.WorkShopId;
                }
                List <minimes_resttime> resttimeList = resttimeService.GetModelList(ParamQuery.Instance().AndWhere("WorkShopId", WorkShopId).AndWhere("TenantId", TenantID));

                string IsRest = "0";//默认值
                if (resttimeList.Count != 0)
                {
                    foreach (var item_rest in resttimeList)
                    {
                        string   Time      = item_rest.RestTime;
                        string[] TimeArr   = Time.Split('-');
                        DateTime StartTime = Convert.ToDateTime(TimeArr[0]);
                        DateTime EndTime   = Convert.ToDateTime(TimeArr[1]);
                        DateTime nowTime   = Convert.ToDateTime(DateTime.Now.ToShortTimeString());
                        if ((nowTime >= StartTime && nowTime <= EndTime))
                        {
                            IsRest = "1";//在休息时间区间
                        }
                    }
                }

                if (row.PlanQty + row.ReserveQty <= row.Qty)//已完成 注;实际产量大于等于计划产量加备存数据 工单才完工
                {
                    row.StateName = "已完成";
                    row.Color     = "green";
                }
                else if (row.MachineState == 0 && IsRest == "1")//设备停机且当前时间在休息时间内
                {
                    row.StateName = "休息中";
                    row.Color     = "orange";
                }
                else if (row.MachineState == 0)
                {
                    row.StateName = "停机中";
                    row.Color     = "red";
                }
                else
                {
                    row.StateName = "生产中";
                    row.Color     = "blue";
                }

                //生产时间
                row.ProductTime = GetProductTime(row.OrderNo, TenantID) - GetLostTime(row.OrderNo, TenantID);//分钟
                double Utilization = 0;
                if (row.ProductTime != 0)
                {
                    //稼动率
                    Utilization = Math.Round((double)(row.ProductTime - row.StopTime) * 100 / (row.ProductTime), 2);
                }
                row.Utilization = Utilization + "%";

                #region 计划达成率&备存计划达成率

                int ReserveQty = 0;
                if (row.Qty <= row.PlanQty)
                {
                    if (row.PlanQty == 0)
                    {
                        row.RatioQty = "0%";
                    }
                    else
                    {
                        row.RatioQty = Math.Round((double)row.Qty * 100 / row.PlanQty, 2) + "%";//计划达成率
                    }
                    row.ReserveRate = "0%";
                }
                else
                {
                    row.RatioQty = "100%";
                    if (row.PlanQty == 0)
                    {
                        row.ReserveRate = "0%";
                    }
                    else
                    {
                        if (row.Qty > row.PlanQty)//当实际产量>计划产量时,才有备存数量
                        {
                            ReserveQty = row.Qty - row.PlanQty;
                        }
                        row.ReserveRate = Math.Round((double)ReserveQty * 100 / row.PlanQty, 2) + "%";//备存计划达成率
                    }
                }

                #endregion

                #region  模穴率=实际模穴/标准模穴

                if (row.StandardMould == 0)
                {
                    row.MouldRate = "0%";
                }
                else
                {
                    row.MouldRate = Math.Round((double)(row.ActualMould * 100 / row.StandardMould), 2) + "%";
                }

                #endregion

                row.DifferQty     = row.PlanQty - row.Qty;
                row.CreateDateStr = row.CreateDate.ToString("yyyy-MM-dd HH:mm:ss");
                if (row.ProductTime == 0)
                {
                    row.CurUPH = 0;
                    row.CT     = "0";
                }
                else
                {
                    row.CurUPH = (row.Qty / row.ProductTime) * 60;                    //实际UPH
                    row.CT     = Math.Round((double)3600 / row.CurUPH, 2).ToString(); //实际CT
                }
                if (row.UPH > 0)
                {
                    row.PlanRatio = Math.Round((double)row.CurUPH * 100 / row.UPH, 2) + "%";//生产效率
                }
                #region 日计划
                string dayRatioQty = "";
                int    dayPlanQty  = 0;
                int    dayQty      = 0;
                if (worksheetlist != null)
                {
                    string Scheduling = worksheetlist[0].Scheduling;
                    string Production = worksheetlist[0].Production;
                    if (Scheduling != null && !string.IsNullOrWhiteSpace(Scheduling))
                    {
                        string[] array = Scheduling.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (var item in array)
                        {
                            string[] val = item.Split(new char[] { ',' });
                            if (val != null && val.Length == 2)
                            {
                                DateTime date   = DateTime.Now;
                                int      iCount = 0;
                                if (DateTime.TryParse(val[0], out date) && int.TryParse(val[1], out iCount))
                                {
                                    if (date.ToString("yyyy-MM-dd").Equals(DateTime.Now.ToString("yyyy-MM-dd")))
                                    {
                                        dayPlanQty = iCount;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (Production != null && !string.IsNullOrWhiteSpace(Production))
                    {
                        string[] array = Production.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (var item in array)
                        {
                            string[] val = item.Split(new char[] { ',' });
                            if (val != null && val.Length == 2)
                            {
                                DateTime date   = DateTime.Now;
                                int      iCount = 0;
                                if (DateTime.TryParse(val[0], out date) && int.TryParse(val[1], out iCount))
                                {
                                    if (date.ToString("yyyy-MM-dd").Equals(DateTime.Now.ToString("yyyy-MM-dd")))
                                    {
                                        dayQty = iCount;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (dayPlanQty == 0)
                    {
                        dayRatioQty = "0%";
                    }
                    else
                    {
                        dayRatioQty = Math.Round((double)dayQty * 100 / dayPlanQty, 2) + "%";//计划达成率
                    }
                }
                #endregion
                dynamic rows = new
                {
                    DayRatioQty = dayRatioQty,
                    DayPlanQty  = dayPlanQty,
                    DayQty      = dayQty,

                    StateName     = row.StateName,     //设备状态
                    RatioQty      = row.RatioQty,      //计划达成率
                    Qty           = row.Qty,           //实际产量
                    DifferQty     = row.DifferQty,     //差异产量
                    PlanRatio     = row.PlanRatio,     //生产效率
                    CurUPH        = row.CurUPH,        //实际UPH
                    CurCT         = row.CT,            // 实际C/T
                    CreateDateStr = row.CreateDateStr, //开始时间
                    Utilization   = row.Utilization,   //时间稼动率
                    ProductTime   = row.ProductTime,   //生产时间
                    StopCount     = row.StopCount,     //停机次数
                    StopTime      = row.StopTime,      //停机时间
                    Color         = row.Color,         //颜色
                    ReserveRate   = row.ReserveRate,   //备存计划达成率
                    ActualMould   = row.ActualMould,   //实际模穴
                    StandardMould = row.StandardMould, //标准模穴
                    MouldRate     = row.MouldRate,     //模穴率
                };
                result.status  = true;
                result.message = "";
                result.rows    = rows;
            }
            else
            {
                result.message = "获取不到数据。";
            }
            string js = JsonConvert.SerializeObject(result);
            return(Json(js, "application/json", JsonRequestBehavior.AllowGet));
        }
Пример #11
0
        /// <summary>
        /// 获取看板基础信息
        /// </summary>
        /// <param name="DepartCode"></param>
        /// <param name="TenantID"></param>
        /// <returns></returns>
        public ActionResult LoadWorkshopBoard(string DepartCode, string TenantID)
        {
            List <minimes_order_record> result        = new List <minimes_order_record>();
            List <dynamic> linelist                   = ApiDataSource.GetLineList(TenantID, DepartCode, null, null, null).ToObject <List <dynamic> >();
            minimes_order_recordService reportService = new minimes_order_recordService();
            List <minimes_order_record> reportList    = reportService.GetModelList(
                ParamQuery.Instance()
                //.AndWhere("PlanDate", DateTime.Now.Date)
                .AndWhere("State", 1)
                .AndWhere("TenantID", TenantID)
                );

            foreach (var item1 in linelist)
            {
                //屏蔽
                if (item1.LineId != "2d6a9f23-c1dc-4a6d-baa7-473011e4954c" && item1.LineId != "d3bb37bd-0aff-4c6a-96a0-d544c136a018")
                {
                    minimes_order_record row = new minimes_order_record();
                    row.Color         = "tag-grey";
                    row.LineId        = item1.LineId + "";
                    row.LineName      = item1.LineName + "";
                    row.OrderNo       = "";
                    row.ProductCode   = "";
                    row.Qty           = 0;
                    row.PlanQty       = 0;
                    row.State         = 1;
                    row.StateName     = "未切单";
                    row.StopCount     = 0;
                    row.StopTime      = 0;
                    row.CreateDateStr = "";
                    result.Add(row);

                    foreach (var item in reportList)
                    {
                        if (row.LineId == item.LineId)
                        {
                            row.OrderNo       = item.OrderNo;
                            row.ProductCode   = item.ProductCode;
                            row.Qty           = item.Qty;
                            row.PlanQty       = item.PlanQty;
                            row.StopCount     = item.StopCount;
                            row.StopTime      = item.StopTime;
                            row.CreateDateStr = item.CreateDate.ToString("yyyy-MM-dd hh:mm:ss");
                            row.ActualMould   = item.ActualMould;
                            row.StandardMould = item.StandardMould;
                            row.ReserveQty    = item.ReserveQty;

                            string WorkShopId = "";
                            minimes_resttimeService resttimeService = new minimes_resttimeService();
                            dynamic LineList = ApiDataSource.GetLineList(TenantID, null, null, row.LineId, null);
                            foreach (var item_line in LineList)
                            {
                                WorkShopId = item_line.WorkShopId;
                            }
                            List <minimes_resttime> resttimeList = resttimeService.GetModelList(ParamQuery.Instance().AndWhere("WorkShopId", WorkShopId).AndWhere("TenantId", TenantID));

                            string IsRest = "0";//默认值
                            if (resttimeList.Count != 0)
                            {
                                foreach (var item_rest in resttimeList)
                                {
                                    string   Time      = item_rest.RestTime;
                                    string[] TimeArr   = Time.Split('-');
                                    DateTime StartTime = Convert.ToDateTime(TimeArr[0]);
                                    DateTime EndTime   = Convert.ToDateTime(TimeArr[1]);
                                    DateTime nowTime   = Convert.ToDateTime(DateTime.Now.ToShortTimeString());
                                    if ((nowTime >= StartTime && nowTime <= EndTime))
                                    {
                                        IsRest = "1";//在休息时间区间
                                    }
                                }
                            }

                            if (row.PlanQty + row.ReserveQty <= row.Qty)//已完成 注;实际产量大于等于计划产量加备存数据 工单才完工
                            {
                                row.StateName = "已完成";
                                row.Color     = "green";
                            }
                            else if (item.MachineState == 1)
                            {
                                row.StateName = "生产中";
                                row.Color     = "blue";
                            }
                            else if (item.MachineState == 0 && IsRest == "1")
                            {
                                row.StateName = "休息中";
                                row.Color     = "orange";
                            }
                            else
                            {
                                row.StateName = "停机中";
                                row.Color     = "red";
                            }
                        }
                    }
                }
            }
            string js = JsonConvert.SerializeObject(result);

            return(Json(js, "application/json", JsonRequestBehavior.AllowGet));
        }
Пример #12
0
        public dynamic Get(RequestWrapper query)
        {
            try
            {
                query.LoadSettingXmlString(@"
            <settings defaultOrderBy='OrderPlanDate DESC'>
                <select>WorkShopName,WorkShopId,LineId,LineName,OrderNo,ProductName,ProductCode,
                PlanDate,OrderPlanDate,Qty,PlanQty,ActualMould,StandardMould,StopTime,TenantID, UPH</select>
                <from> minimes_order_record</from>
                <where defaultForAll='true' defaultCp='equal' defaultIgnoreEmpty='true' >
                     <field name='WorkShopId'		cp='equal'></field>   
                     <field name='LineId'		cp='equal'></field>   
                     <field name='OrderPlanDate'		cp='DateRange'></field>   
                     <field name='OrderNo'		cp='equal'></field>   
                     <field name='ProductName'		cp='equal'></field>
                     <field name='ProductCode'		cp='equal'></field>   
                </where>
            </settings>");
                var service = new minimes_order_recordService();
                var pQuery  = query.ToParamQuery();
                var result  = service.GetDynamicListWithPaging(pQuery);
                foreach (var item in result.rows)
                {
                    #region 时间稼动率&实际UPH&生产效率

                    //生产时间
                    int    ProductTime = lineboardController.GetProductTime(item.OrderNo, item.TenantID) - lineboardController.GetLostTime(item.OrderNo, item.TenantID);
                    double Utilization = 0;
                    if (ProductTime != 0)
                    {
                        Utilization = Math.Round((double)(ProductTime - item.StopTime) * 100 / (ProductTime), 2);
                    }
                    //时间稼动率
                    ((IDictionary <string, object>)item).Add("Utilization", Utilization);

                    //生产时间
                    ((IDictionary <string, object>)item).Add("ProductTime", ProductTime);

                    double PlanRatio = 0;
                    int    CurUPH    = 0;
                    if (ProductTime != 0)
                    {
                        CurUPH = item.Qty / ProductTime * 60;
                    }
                    if (item.UPH > 0)
                    {
                        PlanRatio = Math.Round((double)CurUPH * 100 / item.UPH, 2);
                    }
                    //实际UPH
                    ((IDictionary <string, object>)item).Add("CurUPH", CurUPH);

                    //生产效率
                    ((IDictionary <string, object>)item).Add("PlanRatio", PlanRatio);

                    #endregion

                    #region 计划达成率&备存数量&备存计划达成率

                    double RatioQty    = 0;
                    double ReserveRate = 0;
                    int    ReserveQty  = 0;

                    if (item.Qty <= item.PlanQty)
                    {
                        RatioQty    = Math.Round((double)item.Qty * 100 / item.PlanQty, 2);
                        ReserveRate = 0;
                    }
                    else
                    {
                        RatioQty = 100;
                        if (item.Qty > item.PlanQty)//当实际产量>计划产量时,才有备存数量
                        {
                            ReserveQty = item.Qty - item.PlanQty;
                        }
                        ReserveRate = Math.Round((double)ReserveQty * 100 / item.PlanQty, 2);
                    }
                    //计划达成率
                    ((IDictionary <string, object>)item).Add("RatioQty", RatioQty);

                    //备存数量
                    ((IDictionary <string, object>)item).Add("ReserveQty", ReserveQty);

                    //备存计划达成率
                    ((IDictionary <string, object>)item).Add("ReserveRate", ReserveRate);

                    #endregion

                    #region 模穴率

                    //模穴率
                    double MouldRate = 0;
                    if (item.StandardMould != 0)
                    {
                        MouldRate = Math.Round((double)item.ActualMould * 100 / item.StandardMould, 2);
                    }
                    ((IDictionary <string, object>)item).Add("MouldRate", MouldRate);

                    #endregion
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }