Exemple #1
0
        private static void FillMenus(THOK.AF.Config config, DataTable moduleTable, DataTable functionTable)
        {
            DataRow[] moduleRows = moduleTable.Select("PARENTID='000000'", "SHOWORDER");
            foreach (DataRow moduleRow in moduleRows)
            {
                DataRow[] menuRows = moduleTable.Select(string.Format("PARENTID='{0}'", moduleRow["MODULEID"]), "SHOWORDER");
                List<THOK.AF.Menu> menus = new List<THOK.AF.Menu>();

                foreach (DataRow menuRow in menuRows)
                {
                    string menuID = menuRow["MODULEID"].ToString();
                    THOK.AF.Menu menu = new THOK.AF.Menu(menuRow["MODULENAME"].ToString(),
                                                      menuRow["MODULEURL"].ToString(),
                                                      menuID);
                    menus.Add(menu);

                    if (functionTable != null)
                    {
                        DataRow[] functionRows = functionTable.Select(string.Format("MODULEID='{0}'", menuID));
                        foreach (DataRow row in functionRows)
                            config.AddFunction(menuID, row["CONTROLNAME"].ToString());
                    }
                }

                if (menus.Count != 0)
                {
                    THOK.AF.MenuList menuList = new THOK.AF.MenuList(moduleRow["MODULENAME"].ToString(), menus);
                    config.MenuList.Add(menuList);
                }
            }
        }
Exemple #2
0
 public void SetShowColor(THOK.Zeng.ComfixtureHandle.el103.TextColor color)
 {
     throw new NotImplementedException();
 }
Exemple #3
0
 public void SetKeysState(THOK.Zeng.ComfixtureHandle.el103.FuntionState state1, int frequency1, THOK.Zeng.ComfixtureHandle.el103.FuntionState state2, int frequency2, THOK.Zeng.ComfixtureHandle.el103.FuntionState state3, int frequency3)
 {
     throw new NotImplementedException();
 }
Exemple #4
0
 public void SetFunctionType(THOK.Zeng.ComfixtureHandle.el103.ShowModel showModel)
 {
     throw new NotImplementedException();
 }
Exemple #5
0
 public void SetFunction(THOK.Zeng.ComfixtureHandle.el103.FuntionState useBkLight, byte lightFrequency, THOK.Zeng.ComfixtureHandle.el103.FuntionState useInstructions, byte instructionsFrequency, THOK.Zeng.ComfixtureHandle.el103.FuntionState useSinging, byte singFrequency)
 {
     throw new NotImplementedException();
 }
Exemple #6
0
 public void SetFlashState(THOK.Zeng.ComfixtureHandle.el103.FlashState flashState, THOK.Zeng.ComfixtureHandle.el103.FlashModel flashModel, int flashSwitchBit)
 {
     throw new NotImplementedException();
 }
Exemple #7
0
 void Logger_OnLog(THOK.MCP.LogEventArgs args)
 {
     if (InvokeRequired)
     {
         BeginInvoke(new LogEventHandler(Logger_OnLog), args);
     }
     else
     {
         lock (lbLog)
         {
             string msg = string.Format("[{0}] {1} {2}", args.LogLevel, DateTime.Now, args.Message);
             lbLog.Items.Insert(0, msg);
             WriteLoggerFile(msg);
         }
     }
 }
Exemple #8
0
        /// <summary>填充内容</summary>
        static void FillContent(HSSFRow hssfRow
            , DataColumn column, DataRow row
            , HSSFCellStyle contentStyle, HSSFFont contentFont
            , HSSFCellStyle contentDateStyle
            , HSSFCellStyle contentStyleDailyBalance, HSSFFont fontDailyBalance
            , THOK.NPOI.Models.ExportParam ep
            , HSSFSheet sheet, string headTextStrA)
        {
            HSSFCell newCell = hssfRow.CreateCell(column.Ordinal) as HSSFCell;

            #region 当数据访问转换DataTime时生效
            HSSFDataFormat format = workbook.CreateDataFormat() as HSSFDataFormat;
            contentDateStyle.DataFormat = format.GetFormat("yyyy-MM-dd");
            #endregion

            string columnF = row[column].ToString();
            decimal i;
            bool b = decimal.TryParse(columnF, out i);

            #region 判断如果是仓库库存日结核对
            if (ep.ContentModule == "DailyBalance" && sheet == workbook.GetSheet(headTextStrA)
                    && ((column.Ordinal == 5 && b == false)
                    || (column.Ordinal == 6 && b == false)
                    || (column.Ordinal == 7 && b == false)
                    || (column.Ordinal == 8 && b == false)
                    || (column.Ordinal == 9 && b == false)
                    || (column.Ordinal == 10 && b == false)))
            {
                fontDailyBalance.FontName = ep.ColHeadFont;
                fontDailyBalance.FontHeightInPoints = ep.ColHeadSize;
                fontDailyBalance.Color = ep.ContentModuleColor;
                contentStyleDailyBalance.SetFont(fontDailyBalance);
                if (ep.ColHeadBorder == true)
                {
                    contentStyleDailyBalance.BorderBottom = BorderStyle.THIN;
                    contentStyleDailyBalance.BorderLeft = BorderStyle.THIN;
                    contentStyleDailyBalance.BorderRight = BorderStyle.THIN;
                    contentStyleDailyBalance.BorderTop = BorderStyle.THIN;
                }

                hssfRow.GetCell(column.Ordinal).CellStyle = contentStyleDailyBalance;
            }
            #endregion
            else
            {
                contentFont.FontName = ep.ColHeadFont;
                contentFont.FontHeightInPoints = ep.ColHeadSize;
                contentFont.Color = ep.ContentColor;
                contentStyle.SetFont(contentFont);
                //画边框
                if (ep.ColHeadBorder == true)
                {
                    contentStyle.BorderBottom = BorderStyle.THIN;
                    contentStyle.BorderLeft = BorderStyle.THIN;
                    contentStyle.BorderRight = BorderStyle.THIN;
                    contentStyle.BorderTop = BorderStyle.THIN;
                }
                hssfRow.GetCell(column.Ordinal).CellStyle = contentStyle;
            }
            string drValue = row[column].ToString();
            THOK.NPOI.Common.ExportExcelHeper.ChangeFormat(column, drValue, newCell, contentDateStyle);
        }
Exemple #9
0
        /// <summary>导出EXCEL单表双表</summary>
        public static MemoryStream ExportDT(THOK.NPOI.Models.ExportParam ep)
        {
            #region 变量
            string exportDate = "导出时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            double columnWidth = ep.ColHeadSize - 9;
            short printHeight = 0;
            short printWidth = 10;
            int sheetCount = 65500; //一个Sheet中最多存65536行数据
            int page = 0;
            #endregion

            #region 浏览器下载
            THOK.NPOI.Common.ExportExcelHeper.BrowserLoad(ep.HeadTitle1);
            #endregion

            #region 创建工作表
            workbook = new HSSFWorkbook();
            HSSFSheet sheet = null;
            #endregion

            #region 创建样式
            HSSFCellStyle contentDateStyle = workbook.CreateCellStyle() as HSSFCellStyle;           //内容时间 单元格
            HSSFCellStyle styleHead = workbook.CreateCellStyle() as HSSFCellStyle;                  //大标题   单元格
            HSSFFont fontHead = workbook.CreateFont() as HSSFFont;                                  //大标题   字体
            HSSFCellStyle styleDate = workbook.CreateCellStyle() as HSSFCellStyle;                  //导出时间 单元格
            HSSFCellStyle styleColHead = workbook.CreateCellStyle() as HSSFCellStyle;               //列头     单元格
            HSSFFont fontColHead = workbook.CreateFont() as HSSFFont;                               //列头     字体
            HSSFCellStyle contentStyle = workbook.CreateCellStyle() as HSSFCellStyle;               //内容     单元格
            HSSFFont fontContent = workbook.CreateFont() as HSSFFont;                               //内容     字体
            contentStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("0.00");                      //内容     设置所有列整型格式,也可以通过数据访问层来改变内容格式
            HSSFCellStyle contentStyleDailyBalance = workbook.CreateCellStyle() as HSSFCellStyle;   //特殊模块 单元格
            HSSFFont fontDailyBalance = workbook.CreateFont() as HSSFFont;                          //特殊模块 字体
            #endregion

            #region 全局样式
            HSSFCellStyle headStyle = GetTitleStyle(ep.BigHeadFont, ep.BigHeadSize, ep.BigHeadColor, styleHead, fontHead);
            HSSFCellStyle dateStyle = GetExportDate(styleDate);
            HSSFCellStyle colHeadStyle = GetColumnStyle(ep.ColHeadFont, ep.ColHeadSize, ep.ColHeadColor, ep.ColHeadBorder, styleColHead, fontColHead);
            #endregion

            #region 取得列宽
            int[] arrColWidth1 = new int[0];
            int[] arrColWidth2 = new int[0];
            if (ep.DT1 != null && ep.HeadTitle1 != null)
            {
                arrColWidth1 = new int[ep.DT1.Columns.Count];
                GetColumnWidth(ep.DT1, arrColWidth1);
            }
            if (ep.DT2 != null && ep.HeadTitle2 != null)
            {
                arrColWidth2 = new int[ep.DT2.Columns.Count];
                GetColumnWidth(ep.DT2, arrColWidth2);
            }
            #endregion

            #region 创建EXCEL 表一
            if (ep.DT1 != null && ep.HeadTitle1 != null)
            {
                int dt1count = ep.DT1.Rows.Count;

                #region 判断多少页
                if (dt1count % sheetCount == 0)
                {
                    page = dt1count / sheetCount;
                }
                else
                {
                    page = dt1count / sheetCount + 1;
                }
                #endregion

                for (int a = 0; a < page; a++)
                {
                    #region SHEET分页标题
                    string sheetNum = a.ToString();
                    if (a == 0)
                    {
                        sheetNum = sheetNum.Substring(0, a.ToString().Length - 1);
                    }
                    string headTitle1_sheetNum = ep.HeadTitle1 + sheetNum;
                    sheet = workbook.CreateSheet(headTitle1_sheetNum) as HSSFSheet;
                    #endregion

                    #region SHEET打印设置
                    sheet.PrintSetup.FitHeight = printHeight;
                    sheet.PrintSetup.FitWidth = printWidth;
                    #endregion

                    int rowIndex1 = 0;

                    #region 内容分页
                    DataTable newdt1 = THOK.NPOI.Common.ExportExcelHeper.SetPage(ep.DT1, a + 1, sheetCount);
                    #endregion

                    #region 填充数据
                    foreach (DataRow row in newdt1.Rows)
                    {
                        if (rowIndex1 == 0)
                        {
                            if (rowIndex1 != 0)
                            {
                                sheet = workbook.CreateSheet() as HSSFSheet;
                                sheet.PrintSetup.FitHeight = printHeight;
                                sheet.PrintSetup.FitWidth = printWidth;
                            }
                            #region 填充“表头”和它的样式
                            {
                                HSSFRow headerRow = sheet.CreateRow(0) as HSSFRow;
                                headerRow.HeightInPoints = Convert.ToInt16(ep.BigHeadSize * 1.4);
                                headerRow.CreateCell(0).SetCellValue(ep.HeadTitle1);
                                headerRow.GetCell(0).CellStyle = headStyle;
                                CellRangeAddress region = new CellRangeAddress(0, 0, 0, newdt1.Columns.Count - 1);
                                sheet.AddMergedRegion(region);
                                if (ep.BigHeadBorder == true)
                                {
                                    sheet.SetEnclosedBorderOfRegion(region, BorderStyle.THIN, HSSFColor.BLACK.index);//给合并的画线
                                }
                            }
                            #endregion
                            #region 填充“导出时间”和它的样式
                            {
                                HSSFRow headerRow = sheet.CreateRow(1) as HSSFRow;
                                headerRow.CreateCell(0).SetCellValue(exportDate);
                                headerRow.GetCell(0).CellStyle = dateStyle;
                                CellRangeAddress region = new CellRangeAddress(1, 1, 0, newdt1.Columns.Count - 1);
                                sheet.AddMergedRegion(region);
                                if (ep.ColHeadBorder == true)
                                {
                                    sheet.SetEnclosedBorderOfRegion(region, BorderStyle.THIN, HSSFColor.BLACK.index);
                                }
                            }
                            #endregion
                            #region 填充“列头”和它的样式
                            {
                                HSSFRow headerRow = sheet.CreateRow(2) as HSSFRow;
                                headerRow.HeightInPoints = Convert.ToInt16(ep.ColHeadSize * 1.4);
                                foreach (DataColumn column in newdt1.Columns)
                                {
                                    headerRow.CreateCell(column.Ordinal).SetCellValue(column.ColumnName);
                                    headerRow.GetCell(column.Ordinal).CellStyle = colHeadStyle;
                                    sheet.SetColumnWidth(column.Ordinal, Convert.ToInt32((arrColWidth1[column.Ordinal] + columnWidth) * 256));//设置列宽
                                }
                            }
                            #endregion
                            rowIndex1 = 3;
                        }
                        #region 填充内容
                        HSSFRow dataRow = sheet.CreateRow(rowIndex1) as HSSFRow;
                        foreach (DataColumn column in newdt1.Columns)
                        {
                            FillContent(dataRow, column, row, contentStyle, fontContent
                                , contentDateStyle
                                , contentStyleDailyBalance, fontDailyBalance
                                , ep
                                , sheet, headTitle1_sheetNum);
                        }
                        rowIndex1++;
                        #endregion
                    }
                    #endregion
                }
            }
            #endregion

            #region 创建EXCEL 表二
            if (ep.DT2 != null && ep.HeadTitle2 != null)
            {
                int dt2count = ep.DT2.Rows.Count;
                if (dt2count % sheetCount == 0)
                {
                    page = dt2count / sheetCount;
                }
                else
                {
                    page = dt2count / sheetCount + 1;
                }
                for (int a = 0; a < page; a++)
                {
                    int rowIndex2 = 0;
                    DataTable newdt2 = THOK.NPOI.Common.ExportExcelHeper.SetPage(ep.DT2, a + 1, sheetCount);
                    string strA = a.ToString();
                    if (a == 0)
                    {
                        strA = strA.Substring(0, a.ToString().Length - 1);
                    }
                    string headText2strA = ep.HeadTitle2 + strA;

                    #region 填充数据
                    foreach (DataRow row in newdt2.Rows)
                    {
                        if (rowIndex2 == 0)
                        {
                            HSSFRow headerRow;
                            if (rowIndex2 != 1)
                            {
                                sheet = workbook.CreateSheet(headText2strA) as HSSFSheet;
                                sheet.PrintSetup.FitHeight = printHeight;
                                sheet.PrintSetup.FitWidth = printWidth;
                            }
                            #region 填充表头、样式
                            {
                                headerRow = sheet.CreateRow(0) as HSSFRow;
                                headerRow.HeightInPoints = Convert.ToInt16(ep.BigHeadSize * 1.4);
                                headerRow.CreateCell(0).SetCellValue(ep.HeadTitle2);
                                headerRow.GetCell(0).CellStyle = headStyle;
                                CellRangeAddress region = new CellRangeAddress(0, 0, 0, newdt2.Columns.Count - 1);
                                sheet.AddMergedRegion(region);
                                if (ep.BigHeadBorder == true)
                                {
                                    sheet.SetEnclosedBorderOfRegion(region, BorderStyle.THIN, HSSFColor.BLACK.index);
                                }
                            }
                            #endregion
                            #region 导出时间、样式
                            {
                                headerRow = sheet.CreateRow(1) as HSSFRow;
                                headerRow.CreateCell(0).SetCellValue(exportDate);
                                headerRow.GetCell(0).CellStyle = dateStyle;
                                CellRangeAddress region = new CellRangeAddress(1, 1, 0, newdt2.Columns.Count - 1);
                                sheet.AddMergedRegion(region);
                                if (ep.ColHeadBorder == true)
                                {
                                    sheet.SetEnclosedBorderOfRegion(region, BorderStyle.THIN, HSSFColor.BLACK.index);
                                }
                            }
                            #endregion
                            #region 填充列头、样式
                            {
                                headerRow = sheet.CreateRow(2) as HSSFRow;
                                foreach (DataColumn column in newdt2.Columns)
                                {
                                    headerRow.CreateCell(column.Ordinal).SetCellValue(column.ColumnName);
                                    headerRow.GetCell(column.Ordinal).CellStyle = colHeadStyle;
                                    sheet.SetColumnWidth(column.Ordinal, Convert.ToInt32((arrColWidth2[column.Ordinal] + columnWidth) * 256));
                                }
                            }
                            rowIndex2 = 3;
                            #endregion
                        }
                        #region 填充内容
                        HSSFRow dataRow = sheet.CreateRow(rowIndex2) as HSSFRow;
                        foreach (DataColumn column in newdt2.Columns)
                        {
                            FillContent(dataRow, column, row, contentStyle, fontContent
                                , contentDateStyle
                                , contentStyleDailyBalance, fontDailyBalance
                                , ep
                                , sheet, headText2strA);
                        }
                        rowIndex2++;
                        #endregion
                    }
                    #endregion
                }
            }
            #endregion

            #region 页眉 页脚
            sheet.Header.Left = ep.HeaderFooter.ToString();
            sheet.Header.Center = ep.HeaderFooter[1].ToString();
            sheet.Header.Right = ep.HeaderFooter[2].ToString();
            sheet.Footer.Left = ep.HeaderFooter[3].ToString();
            sheet.Footer.Center = ep.HeaderFooter[4].ToString();
            sheet.Footer.Right = ep.HeaderFooter[5].ToString();
            #endregion

            #region 返回内存流
            MemoryStream ms = new MemoryStream();
            workbook.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return ms;
            #endregion
        }
Exemple #10
0
        public void GetBillDetail(THOK.Wms.AutomotiveSystems.Models.BillMaster[] billMasters, string productCode, string OperateType, string OperateAreas, string Operator, Result result)
        {
            THOK.Wms.AutomotiveSystems.Models.BillDetail[] billDetails = new THOK.Wms.AutomotiveSystems.Models.BillDetail[] { };
            var ops = OperateAreas.Split(',').Select(a => Convert.ToInt32(a)).ToArray();

            try
            {
                string billType = string.Empty;
                foreach (var billMaster in billMasters)
                {
                    string billNo = billMaster.BillNo;
                    switch (billMaster.BillType)
                    {
                        #region 读入库单细单
                        case "1"://入库单
                            var inBillDetails = InBillAllotRepository.GetQueryable()
                                .WhereIn(m => m.Cell.Layer, ops)
                                .Where(i => i.BillNo == billNo
                                    && (i.ProductCode == productCode || productCode == string.Empty)
                                    && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator)))
                                .Select(i => new THOK.Wms.AutomotiveSystems.Models.BillDetail()
                                {
                                    BillNo = i.BillNo,
                                    BillType = "1",

                                    DetailID = i.ID,
                                    StorageName = i.Cell.CellName,
                                    StorageRfid = i.Storage.Rfid,
                                    CellRfid = i.Cell.Rfid,
                                    TargetStorageName = "",
                                    TargetStorageRfid = "",

                                    ProductCode = i.ProductCode,
                                    ProductName = i.Product.ProductName,

                                    PieceQuantity = Math.Floor(i.AllotQuantity / i.Product.UnitList.Unit01.Count),
                                    BarQuantity = Math.Floor((i.AllotQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                    OperatePieceQuantity = Math.Floor(i.AllotQuantity / i.Product.UnitList.Unit01.Count),
                                    OperateBarQuantity = Math.Floor((i.AllotQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                    Total = i.RealQuantity / i.Product.UnitList.Unit01.Count,

                                    OperatorCode = string.Empty,
                                    Operator = i.Operator,
                                    Status = i.Status,
                                })
                                .ToArray();
                            billDetails = billDetails.Concat(inBillDetails).ToArray();
                            break;
                        #endregion
                        #region 读出库单细单
                        case "2"://出库单
                            var outBillDetails = OutBillAllotRepository.GetQueryable()
                                .WhereIn(m => m.Cell.Layer, ops)
                                .Where(i => i.BillNo == billNo
                                    && (i.CanRealOperate == "1" || OperateType != "Real")
                                    && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator)))
                                .Select(i => new THOK.Wms.AutomotiveSystems.Models.BillDetail()
                                {
                                    BillNo = i.BillNo,
                                    BillType = "2",

                                    DetailID = i.ID,
                                    StorageName = i.Cell.CellName,
                                    StorageRfid = i.Storage.Rfid,
                                    CellRfid = i.Cell.Rfid,
                                    TargetStorageName = "",
                                    TargetStorageRfid = "",

                                    ProductCode = i.ProductCode,
                                    ProductName = i.Product.ProductName,

                                    PieceQuantity = Math.Floor(i.AllotQuantity / i.Product.UnitList.Unit01.Count),
                                    BarQuantity = Math.Floor((i.AllotQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                    OperatePieceQuantity = Math.Floor(i.AllotQuantity / i.Product.UnitList.Unit01.Count),
                                    OperateBarQuantity = Math.Floor((i.AllotQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                    Total = i.RealQuantity / i.Product.UnitList.Unit01.Count,

                                    OperatorCode = string.Empty,
                                    Operator = i.Operator,
                                    Status = i.Status,
                                })
                                .ToArray();
                            billDetails = billDetails.Concat(outBillDetails).ToArray();

                            var outBillMaster = OutBillMasterRepository.GetQueryable()
                                .Where(i => i.BillNo == billNo)
                                .FirstOrDefault();
                            if (outBillMaster != null && outBillMaster.MoveBillMasterBillNo != null)
                            {
                                billNo = outBillMaster.MoveBillMasterBillNo;
                                //todo;
                                var moveBillDetailss = MoveBillDetailRepository.GetQueryable()
                                        .WhereIn(m => m.InCell.Layer, ops)
                                        .Where(i => i.BillNo == billNo
                                            && (i.CanRealOperate == "1" || OperateType != "Real")
                                            && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator)))
                                        .ToArray()
                                        .Select(i => new THOK.Wms.AutomotiveSystems.Models.BillDetail()
                                        {
                                            BillNo = i.BillNo,
                                            BillType = "3",

                                            DetailID = i.ID,
                                            StorageName = i.OutCell.CellName,
                                            StorageRfid = i.OutCell.Rfid,
                                            TargetStorageName = i.InCell.CellName,
                                            TargetStorageRfid = i.InCell.Rfid,

                                            ProductCode = i.ProductCode,
                                            ProductName = i.Product.ProductName,

                                            PieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count),
                                            BarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                            OperatePieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count),
                                            OperateBarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),

                                            OperatorCode = string.Empty,
                                            Operator = i.Operator,
                                            Status = i.Status,
                                        })
                                        .ToArray();
                                billDetails = billDetails.Concat(moveBillDetailss).ToArray();
                            }
                            break;
                        #endregion
                        #region 读移库单细单
                        case "3"://移库单
                            billType = billMaster.BillType;
                            var moveBillDetails = MoveBillDetailRepository.GetQueryable()
                                .WhereIn(m => m.InCell.Layer, ops)
                                .Where(i => i.BillNo == billNo
                                    && (i.CanRealOperate == "1" || OperateType != "Real")
                                    && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator)))
                                .Select(i => new THOK.Wms.AutomotiveSystems.Models.BillDetail()
                                {
                                    BillNo = i.BillNo,
                                    BillType = "3",

                                    DetailID = i.ID,
                                    StorageName = i.OutCell.CellName,
                                    StorageRfid = i.OutStorage.Rfid,
                                    CellRfid = i.OutCell.Rfid,
                                    TargetStorageName = i.InCell.CellName,
                                    TargetStorageRfid = i.InCell.Rfid,
                                    IsRounding = i.Product.IsRounding,
                                    ProductCode = i.ProductCode,
                                    ProductName = i.Product.ProductName,

                                    PieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count),
                                    BarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                    OperatePieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count),
                                    OperateBarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                    Total = i.RealQuantity / i.Product.UnitList.Unit01.Count,
                                    AbleMerge = i.Product.IsAbnormity != "1" | "012".Contains(i.Product.IsRounding) | "123".Contains(i.Product.AbcTypeCode),

                                    OperatorCode = string.Empty,
                                    Operator = i.Operator,
                                    Status = i.Status,
                                    PalletTag = i.PalletTag ?? 0
                                })
                                .ToArray();
                            billDetails = billDetails.Concat(moveBillDetails).ToArray();
                            break;
                        #endregion
                        #region 读盘点单细单
                        case "4"://盘点单
                            var checkBillDetails = CheckBillDetailRepository.GetQueryable()
                                .WhereIn(m => m.Cell.Layer, ops)
                                .Where(i => i.BillNo == billNo
                                    && (i.Status == "0" || (i.Status == "1" && i.Operator == Operator)))
                                .Select(i => new THOK.Wms.AutomotiveSystems.Models.BillDetail()
                                {
                                    BillNo = i.BillNo,
                                    BillType = "4",

                                    DetailID = i.ID,
                                    StorageName = i.Cell.CellName,
                                    StorageRfid = i.Storage.Rfid,
                                    CellRfid = i.Cell.Rfid,
                                    TargetStorageName = "",
                                    TargetStorageRfid = "",

                                    ProductCode = i.ProductCode,
                                    ProductName = i.Product.ProductName,

                                    PieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count),
                                    BarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                    OperatePieceQuantity = Math.Floor(i.RealQuantity / i.Product.UnitList.Unit01.Count),
                                    OperateBarQuantity = Math.Floor((i.RealQuantity % i.Product.UnitList.Unit01.Count) / i.Product.UnitList.Unit02.Count),
                                    Total = i.RealQuantity / i.Product.UnitList.Unit01.Count,

                                    OperatorCode = string.Empty,
                                    Operator = i.Operator,
                                    Status = i.Status,
                                })
                                .ToArray();
                            billDetails = billDetails.Concat(checkBillDetails).ToArray();
                            break;
                        default:
                            break;
                        #endregion
                    }
                }

                THOK.Wms.AutomotiveSystems.Models.BillDetail[] billDetails1 = new THOK.Wms.AutomotiveSystems.Models.BillDetail[] { };
                THOK.Wms.AutomotiveSystems.Models.BillDetail[] billDetails2 = new THOK.Wms.AutomotiveSystems.Models.BillDetail[] { };

                //查询大于等于30件的数据
                billDetails1 = billDetails.Where(s => s.Total >= 30).OrderByDescending(i => i.Status)
                                                .ThenBy(b => b.StorageName).ThenBy(f => f.ProductCode).ToArray();
                //查询小于30件的数据
                billDetails2 = billDetails.Where(s => s.Total < 30).OrderByDescending(i => i.Status)
                                                .ThenBy(b => b.StorageName).ThenBy(f => f.ProductCode).ToArray();
                //合并显示
                result.IsSuccess = true;
                result.BillDetails = billDetails2.Concat(billDetails1).OrderByDescending(i=>i.Status).ToArray();
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message = "调用服务器服务查询订单细表失败,详情:" + e.InnerException.Message + "  其他错误" + e.Message;
            }
        }
Exemple #11
0
        public void Execute(THOK.Wms.AutomotiveSystems.Models.BillDetail[] billDetails, string useTag, Result result)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    foreach (var billDetail in billDetails)
                    {
                        switch (billDetail.BillType)
                        {
                            #region 完成入库单
                            case "1":
                                var inAllot = InBillAllotRepository.GetQueryable()
                                    .Where(i => i.BillNo == billDetail.BillNo
                                        && i.ID == billDetail.DetailID
                                        && i.Status == "1"
                                        && i.Operator == billDetail.Operator)
                                    .FirstOrDefault();
                                if (inAllot != null
                                    && (inAllot.InBillMaster.Status == "4"
                                    || inAllot.InBillMaster.Status == "5"
                                    ))
                                {
                                    decimal quantity = billDetail.OperatePieceQuantity * inAllot.Product.UnitList.Unit01.Count
                                        + billDetail.OperateBarQuantity * inAllot.Product.UnitList.Unit02.Count;
                                    if (string.IsNullOrEmpty(inAllot.Storage.LockTag)
                                        && inAllot.AllotQuantity >= quantity
                                        && inAllot.Storage.InFrozenQuantity >= quantity)
                                    {
                                        inAllot.Status = "2";
                                        inAllot.Storage.Rfid = billDetail.StorageRfid;
                                        inAllot.RealQuantity += quantity;
                                        inAllot.Storage.Quantity += quantity;
                                        if(inAllot.Storage.Cell.IsSingle=="1")//货位管理更改入库时间
                                            inAllot.Storage.StorageTime = DateTime.Now;
                                        inAllot.Storage.InFrozenQuantity -= quantity;
                                        inAllot.InBillDetail.RealQuantity += quantity;
                                        inAllot.InBillMaster.Status = "5";
                                        inAllot.FinishTime = DateTime.Now;
                                        if (inAllot.InBillMaster.InBillAllots.All(c => c.Status == "2"))
                                        {
                                            inAllot.InBillMaster.Status = "6";
                                        }
                                        if (useTag == "1")
                                            CancelOperateToLabelServer(inAllot.BillNo, inAllot.ID.ToString(), inAllot.Cell.CellName);

                                        result.IsSuccess = true;
                                    }
                                    else
                                    {
                                        result.IsSuccess = false;
                                        result.Message = "需确认入库的数据别人在操作或完成的数量不对,完成出错!";
                                    }
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Message = "需确认入库的数据查询为空或者主单状态不对,完成出错!";
                                }
                                break;
                            #endregion
                            #region 完成出库单
                            case "2":
                                var outAllot = OutBillAllotRepository.GetQueryable()
                                    .Where(i => i.BillNo == billDetail.BillNo
                                        && i.ID == billDetail.DetailID
                                        && i.Status == "1"
                                        && i.Operator == billDetail.Operator)
                                    .FirstOrDefault();
                                if (outAllot != null
                                    && (outAllot.OutBillMaster.Status == "4"
                                    || outAllot.OutBillMaster.Status == "5"
                                    ))
                                {
                                    decimal quantity = billDetail.OperatePieceQuantity * outAllot.Product.UnitList.Unit01.Count
                                        + billDetail.OperateBarQuantity * outAllot.Product.UnitList.Unit02.Count;
                                    if (string.IsNullOrEmpty(outAllot.Storage.LockTag)
                                        && outAllot.AllotQuantity >= quantity
                                        && outAllot.Storage.OutFrozenQuantity >= quantity)
                                    {
                                        outAllot.Status = "2";
                                        outAllot.RealQuantity += quantity;
                                        outAllot.Storage.Quantity -= quantity;
                                        if (outAllot.Storage.Quantity == 0)
                                            outAllot.Storage.Rfid = "";
                                        outAllot.Storage.OutFrozenQuantity -= quantity;
                                        outAllot.OutBillDetail.RealQuantity += quantity;
                                        outAllot.OutBillMaster.Status = "5";
                                        outAllot.FinishTime = DateTime.Now;
                                        if (outAllot.OutBillMaster.OutBillAllots.All(c => c.Status == "2"))
                                        {
                                            outAllot.OutBillMaster.Status = "6";
                                        }
                                        if (useTag == "1")
                                            CancelOperateToLabelServer(outAllot.BillNo, outAllot.ID.ToString(), outAllot.Cell.CellName);

                                        result.IsSuccess = true;
                                    }
                                    else
                                    {
                                        result.IsSuccess = false;
                                        result.Message = "需确认出库的数据别人在操作或完成的数量不对,完成出错!";
                                    }
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Message = "需确认出库的数据查询为空或者主单状态不对,完成出错!";
                                }
                                break;
                            #endregion
                            #region 完成移库单
                            case "3":
                                var moveDetail = MoveBillDetailRepository.GetQueryable()
                                    .Where(i => i.BillNo == billDetail.BillNo
                                        && i.ID == billDetail.DetailID
                                        && i.Status == "1"
                                        && i.Operator == billDetail.Operator)
                                    .FirstOrDefault();
                                if (moveDetail != null
                                    && (moveDetail.MoveBillMaster.Status =="2"
                                    || moveDetail.MoveBillMaster.Status =="3"
                                    ))
                                {
                                    if (string.IsNullOrEmpty(moveDetail.InStorage.LockTag)
                                        && string.IsNullOrEmpty(moveDetail.OutStorage.LockTag)
                                        && moveDetail.InStorage.InFrozenQuantity >= moveDetail.RealQuantity
                                        && moveDetail.OutStorage.OutFrozenQuantity >= moveDetail.RealQuantity)
                                    {
                                        moveDetail.Status = "2";
                                        moveDetail.InStorage.Quantity += moveDetail.RealQuantity;
                                        moveDetail.InStorage.InFrozenQuantity -= moveDetail.RealQuantity;
                                        moveDetail.InStorage.Rfid = billDetail.StorageRfid;
                                        moveDetail.OutStorage.Quantity -= moveDetail.RealQuantity;
                                        moveDetail.OutStorage.OutFrozenQuantity -= moveDetail.RealQuantity;
                                        moveDetail.OutStorage.Rfid = "";
                                        //当移入货位的库存为0时,以移出的货位的时间为移入货位的库存时间
                                        if (moveDetail.InStorage.Quantity - moveDetail.RealQuantity == 0)
                                        {
                                            moveDetail.InStorage.StorageTime = moveDetail.OutStorage.StorageTime;
                                        }
                                        //当移入货位的库存不为0时,以最晚的时间为移入货位的入库时间
                                        else
                                        {
                                            //当移出货位的入库时间早于移入货位的时间,则更新移入货位的入库时间
                                            if (DateTime.Compare(moveDetail.OutStorage.StorageTime, moveDetail.InStorage.StorageTime) == -1)
                                                moveDetail.InStorage.StorageTime = moveDetail.OutStorage.StorageTime;
                                        }

                                        moveDetail.MoveBillMaster.Status = "3";
                                        moveDetail.FinishTime = DateTime.Now;
                                        var sortwork = SortWorkDispatchRepository.GetQueryable().FirstOrDefault(s => s.MoveBillMaster.BillNo == moveDetail.MoveBillMaster.BillNo && s.DispatchStatus == "2");
                                        //修改分拣调度作业状态
                                        if (sortwork != null)
                                        {
                                            sortwork.DispatchStatus = "3";
                                        }
                                        if (moveDetail.MoveBillMaster.MoveBillDetails.All(c => c.Status == "2"))
                                        {
                                            moveDetail.MoveBillMaster.Status = "4";
                                            string errorInfo = "";
                                            MoveBillDetailRepository.SaveChanges();
                                            SettleSortWokDispatch(moveDetail.BillNo, ref errorInfo);
                                        }
                                        if (useTag == "1")
                                            CancelOperateToLabelServer(moveDetail.BillNo, moveDetail.ID.ToString(), moveDetail.OutCell.CellName);

                                        result.IsSuccess = true;
                                    }
                                    else
                                    {
                                        result.IsSuccess = false;
                                        result.Message = "需确认移库的数据别人在操作或者完成的数量不对,完成出错!";
                                    }
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Message = "需确认移库的数据查询为空或者主单状态不对,完成出错!";
                                }
                                break;
                            #endregion
                            #region 完成盘点单
                            case "4":
                                var checkDetail = CheckBillDetailRepository.GetQueryable()
                                    .Where(i => i.BillNo == billDetail.BillNo
                                        && i.ID == billDetail.DetailID
                                        && i.Status == "1"
                                        && i.Operator == billDetail.Operator)
                                    .FirstOrDefault();
                                if (checkDetail != null
                                    && (checkDetail.CheckBillMaster.Status == "2"
                                    || checkDetail.CheckBillMaster.Status == "3"))
                                {
                                    decimal quantity = billDetail.OperatePieceQuantity * checkDetail.Product.UnitList.Unit01.Count
                                                       + billDetail.OperateBarQuantity * checkDetail.Product.UnitList.Unit02.Count;

                                    checkDetail.Status = "2";
                                    checkDetail.RealQuantity = quantity;
                                    checkDetail.Storage.IsLock = "0";
                                    checkDetail.CheckBillMaster.Status = "3";
                                    checkDetail.FinishTime = DateTime.Now;
                                    if (checkDetail.CheckBillMaster.CheckBillDetails.All(c => c.Status == "2"))
                                    {
                                        checkDetail.CheckBillMaster.Status = "4";
                                    }
                                    if (useTag == "1")
                                        CancelOperateToLabelServer(checkDetail.BillNo, checkDetail.ID.ToString(), checkDetail.Cell.CellCode);

                                    result.IsSuccess = true;
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Message = "需确认盘点的数据查询为空或者主单状态不对,完成出错!";
                                }
                                break;
                            default:
                                break;
                            #endregion
                        }
                    }
                    InBillAllotRepository.SaveChanges();
                    //把库存为0,入库,出库冻结量为0,无锁的库存数据的卷烟编码清空
                    UpdateStorageInfo();
                    scope.Complete();
                }
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message = "调用服务器服务执行作业任务失败,详情:" + e.InnerException.Message+"  其他错误:"+e.Message;
            }
        }
Exemple #12
0
        public void Cancel(THOK.Wms.AutomotiveSystems.Models.BillDetail[] billDetails, string useTag, Result result)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    foreach (var billDetail in billDetails)
                    {
                        switch (billDetail.BillType)
                        {
                            case "1":
                                var inAllot = InBillAllotRepository.GetQueryable()
                                    .Where(i => i.BillNo == billDetail.BillNo
                                        && i.ID == billDetail.DetailID
                                        && i.Status == "1"
                                        && i.Operator == billDetail.Operator)
                                    .FirstOrDefault();
                                if (inAllot != null)
                                {
                                    inAllot.Status = "0";
                                    inAllot.Operator = string.Empty;
                                    inAllot.StartTime = null;
                                    if (useTag == "1")
                                        CancelOperateToLabelServer(inAllot.BillNo, inAllot.ID.ToString(), inAllot.Cell.CellName);

                                    result.IsSuccess = true;
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Message = "取消入库申请失败,原因:没有查询到这条数据!";
                                }
                                break;
                            case "2":
                                var outAllot = OutBillAllotRepository.GetQueryable()
                                    .Where(i => i.BillNo == billDetail.BillNo
                                        && i.ID == billDetail.DetailID
                                        && i.Status == "1"
                                        && i.Operator == billDetail.Operator)
                                    .FirstOrDefault();
                                if (outAllot != null)
                                {
                                    outAllot.Status = "0";
                                    outAllot.Operator = string.Empty;
                                    outAllot.StartTime = null;
                                    if (useTag == "1")
                                        CancelOperateToLabelServer(outAllot.BillNo, outAllot.ID.ToString(), outAllot.Cell.CellName);

                                    result.IsSuccess = true;
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Message = "取消出库申请失败,原因:没有查询到这条数据!";
                                }
                                break;
                            case "3":
                                var moveDetail = MoveBillDetailRepository.GetQueryable()
                                    .Where(i => i.BillNo == billDetail.BillNo
                                        && i.ID == billDetail.DetailID
                                        && i.Status == "1"
                                        && i.Operator == billDetail.Operator)
                                    .FirstOrDefault();
                                if (moveDetail != null)
                                {
                                    moveDetail.Status = "0";
                                    moveDetail.Operator = string.Empty;
                                    moveDetail.StartTime = null;
                                    if (useTag == "1")
                                        CancelOperateToLabelServer(moveDetail.BillNo, moveDetail.ID.ToString(), moveDetail.OutCell.CellName);

                                    result.IsSuccess = true;
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Message = "取消移库申请失败,原因:没有查询到这条数据!";
                                }
                                break;
                            case "4":
                                var checkDetail = CheckBillDetailRepository.GetQueryable()
                                    .Where(i => i.BillNo == billDetail.BillNo
                                        && i.ID == billDetail.DetailID
                                        && i.Status == "1"
                                        && i.Operator == billDetail.Operator)
                                    .FirstOrDefault();
                                if (checkDetail != null)
                                {
                                    checkDetail.Status = "0";
                                    checkDetail.Operator = string.Empty;
                                    checkDetail.StartTime = null;
                                    if (useTag == "1")
                                        CancelOperateToLabelServer(checkDetail.BillNo, checkDetail.ID.ToString(), checkDetail.Cell.CellCode);

                                    result.IsSuccess = true;
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Message = "取消盘点申请失败,原因:没有查询到这条数据!";
                                }
                                break;
                            default:
                                break;
                        }
                    }
                    InBillAllotRepository.SaveChanges();
                    scope.Complete();
                }
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message = "调用服务器服务取消作业任务失败,详情:" +e.InnerException.Message+"  其他错误:"+ e.Message;
            }
        }
Exemple #13
0
        public void Apply(THOK.Wms.AutomotiveSystems.Models.BillDetail[] billDetails, string useTag, Result result)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    foreach (var billDetail in billDetails)
                    {
                        switch (billDetail.BillType)
                        {
                            case "1":
                                var inAllot = InBillAllotRepository.GetQueryable()
                                    .Where(i => i.BillNo == billDetail.BillNo
                                        && i.ID == billDetail.DetailID
                                        && i.Status == "0")
                                    .FirstOrDefault();
                                if (inAllot != null)
                                {
                                    inAllot.Status = "1";
                                    inAllot.Operator = billDetail.Operator;
                                    inAllot.StartTime = DateTime.Now;
                                    if (useTag == "1")
                                    {
                                        OperateToLabelServer(inAllot.BillNo, inAllot.ID.ToString(), inAllot.Cell.CellName,
                                            billDetail.BillType, inAllot.Product.ProductName, (int)billDetail.PieceQuantity,
                                            (int)billDetail.BarQuantity, "");
                                    }

                                    result.IsSuccess = true;
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Message = "申请入库失败,原因:没有查询到这条数据!";
                                }
                                break;
                            case "2":
                                var outAllot = OutBillAllotRepository.GetQueryable()
                                    .Where(i => i.BillNo == billDetail.BillNo
                                        && i.ID == billDetail.DetailID
                                        && i.Status == "0")
                                    .FirstOrDefault();
                                if (outAllot != null)
                                {
                                    outAllot.Status = "1";
                                    outAllot.Operator = billDetail.Operator;
                                    outAllot.StartTime = DateTime.Now;
                                    if (useTag == "1")
                                    {
                                        OperateToLabelServer(outAllot.BillNo, outAllot.ID.ToString(), outAllot.Cell.CellName,
                                            billDetail.BillType, outAllot.Product.ProductName, (int)billDetail.PieceQuantity,
                                            (int)billDetail.BarQuantity, "");
                                    }

                                    result.IsSuccess = true;
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Message = "申请出库失败,原因:没有查询到这条数据!";
                                }
                                break;
                            case "3":
                                var moveDetail = MoveBillDetailRepository.GetQueryable()
                                    .Where(i => i.BillNo == billDetail.BillNo
                                        && i.ID == billDetail.DetailID
                                        && i.Status == "0")
                                    .FirstOrDefault();
                                if (moveDetail != null)
                                {
                                    moveDetail.Status = "1";
                                    moveDetail.Operator = billDetail.Operator;
                                    moveDetail.StartTime = DateTime.Now;
                                    if (useTag == "1")
                                    {
                                        OperateToLabelServer(moveDetail.BillNo, moveDetail.ID.ToString(), moveDetail.OutCell.CellName,
                                             billDetail.BillType, moveDetail.Product.ProductName, (int)billDetail.PieceQuantity,
                                             (int)billDetail.BarQuantity, moveDetail.InCell.CellName);
                                    }

                                    result.IsSuccess = true;
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Message = "申请移库失败,原因:没有查询到这条数据!";
                                }
                                break;
                            case "4":
                                var checkDetail = CheckBillDetailRepository.GetQueryable()
                                    .Where(i => i.BillNo == billDetail.BillNo
                                        && i.ID == billDetail.DetailID
                                        && i.Status == "0")
                                    .FirstOrDefault();
                                if (checkDetail != null)
                                {
                                    checkDetail.Status = "1";
                                    checkDetail.Operator = billDetail.Operator;
                                    checkDetail.StartTime = DateTime.Now;
                                    if (useTag == "1")
                                    {
                                        OperateToLabelServer(checkDetail.BillNo, checkDetail.ID.ToString(), checkDetail.Cell.CellName,
                                            billDetail.BillType, checkDetail.Product.ProductName, (int)billDetail.PieceQuantity,
                                            (int)billDetail.BarQuantity, "");
                                    }

                                    result.IsSuccess = true;
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Message = "申请盘点失败,原因:没有查询到这条数据!";
                                }
                                break;
                            default:
                                break;
                        }
                    }
                    InBillAllotRepository.SaveChanges();
                    scope.Complete();
                }
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message = "调用服务器服务申请作业任务失败,详情:" +e.InnerException.Message+" 其他错误 "+ e.Message;
            }
        }
Exemple #14
0
 private THOK.Wms.AutomotiveSystems.Models.BillDetail[] SelectGroup(THOK.Wms.AutomotiveSystems.Models.BillDetail[] details)
 {
     THOK.Wms.AutomotiveSystems.Models.BillDetail[] billDetails = new THOK.Wms.AutomotiveSystems.Models.BillDetail[] { };
     var bills = details.Select(r => new THOK.Wms.AutomotiveSystems.Models.BillDetail()
                       {
                           PieceQuantity = r.PieceQuantity+r.OperatePieceQuantity
                       })
                       .ToArray();
     return billDetails.Concat(bills).ToArray();
 }