Exemplo n.º 1
0
        public MethodReturnResult GetLotTransaction(string key)
        {
            MethodReturnResult result = new MethodReturnResult();

            LotTransaction obj = null;

            using (LotQueryServiceClient client = new LotQueryServiceClient())
            {
                MethodReturnResult <LotTransaction> rst = client.GetTransaction(key);
                if (rst.Code <= 0 && rst.Data != null)
                {
                    obj = rst.Data;
                }
                else
                {
                    result.Code    = rst.Code;
                    result.Message = rst.Message;
                    result.Detail  = rst.Detail;
                    return(result);
                }
            }
            if (obj == null)
            {
                result.Code    = 2001;
                result.Message = "被撤销操作不存在。";
                return(result);
            }
            //判断用户拥有的工序权限
            IList <Resource> lstResource = new List <Resource>();

            using (UserAuthenticateServiceClient client = new UserAuthenticateServiceClient())
            {
                MethodReturnResult <IList <Resource> > rst = client.GetResourceList(User.Identity.Name, ResourceType.RouteOperation);
                if (rst.Code <= 0 && rst.Data != null)
                {
                    lstResource = rst.Data;
                }
                else
                {
                    result.Code    = rst.Code;
                    result.Message = rst.Message;
                    result.Detail  = rst.Detail;
                    return(result);
                }
            }
            var lnq = from item in lstResource
                      where item.Data == obj.RouteStepName
                      select item;

            if (lnq.Count() == 0)
            {
                result.Code    = 1;
                result.Message = string.Format("用户({0})权限不足,对工序({1})的操作不能撤销。", User.Identity.Name, obj.RouteStepName);
                return(result);
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary> 获取最新的一条加工历史数据/// </summary>
        /// <param name="LotNumber"></param>
        /// <returns></returns>
        public LotTransaction GetLotLastTransaction(string LotNumber)
        {
            LotTransaction obj = null;

            using (LotQueryServiceClient client = new LotQueryServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("LotNumber='{0}' AND UndoFlag=0 AND Activity!='{1}'"
                                             , LotNumber
                                             , Convert.ToInt32(EnumLotActivity.Undo)),
                    OrderBy = "EditTime DESC"
                };

                MethodReturnResult <IList <LotTransaction> > rst = client.GetTransaction(ref cfg);
                obj = rst.Data[0];
            }
            return(obj);
        }
Exemplo n.º 3
0
        public ActionResult SaveBatchRevocation(string LotNumber)
        {
            MethodReturnResult result          = new MethodReturnResult();
            LotTransaction     LotTransaction  = null;
            LotTransaction     LotTransaction1 = null;
            LotTransaction     LotTransaction2 = null;

            try
            {
                UndoParameter p = new UndoParameter()
                {
                    Creator             = User.Identity.Name,
                    OperateComputer     = Request.UserHostAddress,
                    Operator            = User.Identity.Name,
                    UndoTransactionKeys = new Dictionary <string, IList <string> >(),
                    LotNumbers          = new List <string>()
                };

                char splitChar = ',';

                //获取批次号值

                string[] lotNumbers = Request["LotNumber"].ToUpper().Split(splitChar);
                p.LotNumbers = lotNumbers.ToList();

                for (int i = 0; i < p.LotNumbers.Count; i++)
                {
                    string lotNumber = p.LotNumbers[i];
                    if (i == 0)
                    {
                        //获取第一个批次的最新一条加工历史数据
                        LotTransaction  = GetLotLastTransaction(p.LotNumbers[0]);
                        LotTransaction2 = LotTransaction;
                    }
                    else
                    {
                        //获取除第一个批次的最新一条加工历史数据
                        LotTransaction1 = GetLotLastTransaction(lotNumber);
                        LotTransaction2 = LotTransaction1;
                    }
                    if (LotTransaction != null && LotTransaction1 != null)
                    {
                        //判定批次是否为同一个工艺流程组。
                        if (LotTransaction.RouteEnterpriseName != LotTransaction1.RouteEnterpriseName)
                        {
                            result.Code    = 1001;
                            result.Message = string.Format("批次({0})与批次({1})工艺流程组不相同。", p.LotNumbers[0], lotNumber);
                            return(Json(result));
                        }
                        //判定批次是否为同一个工艺流程。
                        if (LotTransaction.RouteName != LotTransaction1.RouteName)
                        {
                            result.Code    = 1002;
                            result.Message = string.Format("批次({0})与批次({1})工艺流程不相同。", p.LotNumbers[0], lotNumber);
                            return(Json(result));
                        }
                        //判定批次是否为同一个工序。
                        if (LotTransaction.RouteStepName != LotTransaction1.RouteStepName)
                        {
                            result.Code    = 1003;
                            result.Message = string.Format("批次({0})与批次({1})工序不相同。", p.LotNumbers[0], lotNumber);
                            return(Json(result));
                        }
                        //判定批次是否为同一个操作流程。
                        if (LotTransaction.Activity != LotTransaction1.Activity)
                        {
                            result.Code    = 1004;
                            result.Message = string.Format("批次({0})与批次({1})操作名称不相同。", p.LotNumbers[0], lotNumber);
                            return(Json(result));
                        }
                    }
                    //p.LotNumbers.Add(lotNumber);
                    p.UndoTransactionKeys.Add(lotNumber, new List <string>());
                    p.UndoTransactionKeys[lotNumber].Add(LotTransaction2.Key);
                }


                if (result.Code == 0)
                {
                    using (LotUndoServiceClient client = new LotUndoServiceClient())
                    {
                        result = client.Undo(p);
                    }
                }

                if (result.Code == 0)
                {
                    return(Query(LotNumber));
                }
                if (result.Code > 0)
                {
                    return(Json(result));
                }
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = ex.Message;
                result.Detail  = ex.ToString();
            }
            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(Json(result));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> ExportToExcel(LotDefectQueryViewModel model)
        {
            IList <LotTransactionDefect> lst = new List <LotTransactionDefect>();

            using (LotQueryServiceClient client = new LotQueryServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "EditTime",
                        Where    = GetQueryCondition(model)
                    };
                    MethodReturnResult <IList <LotTransactionDefect> > result = client.GetLotTransactionDefect(ref cfg);

                    if (result.Code == 0)
                    {
                        lst = result.Data;
                    }
                });
            }
            //创建工作薄。
            IWorkbook wb = new HSSFWorkbook();
            //设置EXCEL格式
            ICellStyle style = wb.CreateCellStyle();

            style.FillForegroundColor = 10;
            //有边框
            style.BorderBottom = BorderStyle.THIN;
            style.BorderLeft   = BorderStyle.THIN;
            style.BorderRight  = BorderStyle.THIN;
            style.BorderTop    = BorderStyle.THIN;
            IFont font = wb.CreateFont();

            font.Boldweight = 10;
            style.SetFont(font);
            ICell  cell = null;
            IRow   row  = null;
            ISheet ws   = null;

            for (int j = 0; j < lst.Count; j++)
            {
                if (j % 65535 == 0)
                {
                    ws  = wb.CreateSheet();
                    row = ws.CreateRow(0);
                    #region //列名
                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(StringResource.ItemNo);  //项目号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.LotNumber);  //批次号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("工单号");  //工单号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("工序");  //工序

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("线别");  //线别

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.LotDefectViewModel_DefectQuantity);  //数量

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.ReasonCodeCategoryName);  //原因代码组

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.ReasonCodeName);  //原因代码

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.ReasonDescription);  //原因描述

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.LotDefectViewModel_RouteOperationName);  //责任工序

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.LotDefectViewModel_ResponsiblePerson);  //责任人

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(StringResource.Description);  //描述

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("操作时间");  //操作时间

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("操作人");  //操作人
                    #endregion
                    font.Boldweight = 5;
                }
                LotTransactionDefect  obj       = lst[j];
                LotTransaction        transObj  = null;
                LotTransactionHistory lotHisObj = null;
                using (LotQueryServiceClient client = new LotQueryServiceClient())
                {
                    MethodReturnResult <LotTransaction> result = client.GetTransaction(obj.Key.TransactionKey);
                    if (result.Code == 0)
                    {
                        transObj = result.Data;
                    }

                    MethodReturnResult <LotTransactionHistory> result1 = client.GetLotTransactionHistory(obj.Key.TransactionKey);
                    if (result1.Code == 0)
                    {
                        lotHisObj = result1.Data;
                    }
                }
                row = ws.CreateRow(j + 1);

                #region //数据
                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(j + 1);  //项目号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(transObj.LotNumber);  //批次号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(transObj.OrderNumber);  //工单号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(transObj.RouteStepName);  //工序

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(lotHisObj != null ? lotHisObj.LineCode : string.Empty);  //线别

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Quantity);  //数量

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Key.ReasonCodeCategoryName);  //原因代码组

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Key.ReasonCodeName);  //原因代码

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Description);  //原因描述

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.RouteOperationName);  //责任工序

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.ResponsiblePerson);  //责任人

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Description);  //描述

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(string.Format("{0:yyyy-MM-dd HH:mm:ss}", obj.EditTime));  //操作时间

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Editor);  //操作人
                #endregion
            }

            MemoryStream ms = new MemoryStream();
            wb.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return(File(ms, "application/vnd.ms-excel", "LotDefectData.xls"));
        }
Exemplo n.º 5
0
        public async Task <ActionResult> ExportToExcel(CheckDataQueryViewModel model)
        {
            IList <LotTransaction> lstCheckData = new List <LotTransaction>();

            CheckDataViewModel m = new CheckDataViewModel();

            using (LotQueryServiceClient client = new LotQueryServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "CreateTime DESC",
                        Where    = GetQueryCondition(model)
                    };
                    MethodReturnResult <IList <LotTransaction> > result = client.GetTransaction(ref cfg);

                    if (result.Code == 0)
                    {
                        lstCheckData = result.Data;
                    }
                });
            }
            //创建工作薄。
            IWorkbook wb = new HSSFWorkbook();
            //设置EXCEL格式
            ICellStyle style = wb.CreateCellStyle();

            style.FillForegroundColor = 10;
            //有边框
            style.BorderBottom = BorderStyle.Thin;
            style.BorderLeft   = BorderStyle.Thin;
            style.BorderRight  = BorderStyle.Thin;
            style.BorderTop    = BorderStyle.Thin;
            IFont font = wb.CreateFont();

            font.Boldweight = 10;
            style.SetFont(font);
            ISheet ws = null;

            for (int j = 0; j < lstCheckData.Count; j++)
            {
                if (j % 65535 == 0)
                {
                    ws = wb.CreateSheet();
                    IRow row = ws.CreateRow(0);
                    #region //列名
                    ICell cell = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(StringResource.ItemNo);  //项目号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("批次号");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("工单号");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("产品料号");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("线别");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("等级");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("花色");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("实际功率");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("实际电流");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("实际最大电流");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("实际电压");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("实际最大电压");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("实际填充因子");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("分档名称");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("子分档代码");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("备注");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("检验时间");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("检验操作人");
                    #endregion
                    font.Boldweight = 5;
                }
                LotTransaction        obj        = lstCheckData[j];
                IRow                  rowData    = ws.CreateRow(j + 1);
                Lot                   lotObj     = m.GetLot(obj.LotNumber);
                IVTestData            ivtestData = m.GetIVTestData(obj.LotNumber);
                LotTransactionHistory lotHisObj  = m.GetLotTransactionHistory(obj.Key);

                #region //数据
                ICell cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(j + 1);  //项目号

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.LotNumber);  //批次号

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.OrderNumber);  //工单号

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(lotHisObj != null ? lotHisObj.MaterialCode : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(lotHisObj != null ? lotHisObj.LineCode : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(lotObj != null ? lotObj.Grade : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(lotObj != null ? lotObj.Color : string.Empty);

                if (ivtestData != null)
                {
                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtestData.CoefPM);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtestData.CoefISC);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtestData.CoefIPM);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtestData.CoefVOC);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtestData.CoefVPM);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtestData.CoefFF);
                }
                else
                {
                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(string.Empty);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(string.Empty);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(string.Empty);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(string.Empty);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(string.Empty);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(string.Empty);
                }

                if (ivtestData == null || string.IsNullOrEmpty(ivtestData.PowersetCode) || ivtestData.PowersetItemNo == null)
                {
                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(string.Empty);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(string.Empty);
                }
                else
                {
                    string powersetName = m.GetPowersetName(ivtestData.Key.LotNumber, ivtestData.PowersetCode, ivtestData.PowersetItemNo.Value);
                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(powersetName);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtestData.PowersetSubCode);
                }

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.Description);


                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(string.Format("{0:yyyy-MM-dd HH:mm:ss}", obj.CreateTime));

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.Creator);


                #endregion
            }

            MemoryStream ms = new MemoryStream();
            wb.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return(File(ms, "application/vnd.ms-excel", "CheckDataData.xls"));
        }