コード例 #1
0
        private string GetCellLotList(string materialType, string lineCode, string routeStepName, string orderNumber, string equipmentCode)
        {
            string materialLot = null;
            string sql2        = string.Format(@"SELECT TOP 1 t1.MATERIAL_LOT
                                          FROM [dbo].[LSM_MATERIAL_LOADING_DETAIL] t1 
                                              INNER JOIN dbo.LSM_MATERIAL_LOADING t2  ON t2.LOADING_KEY=t1.LOADING_KEY
                                              INNER JOIN [dbo].[FMM_MATERIAL] t3 ON t3.MATERIAL_CODE=t1.MATERILA_CODE
                                          WHERE t3.MATERIAL_TYPE like '{0}%' AND t2.LINE_CODE='{1}'
		                                             AND t2.ROUTE_OPERATION_NAME='{2}' AND t1.ORDER_NUMBER='{3}'
		                                             AND t2.EQUIPMENT_CODE='{4}' AND t1.CURRENT_QTY>0
                                          ORDER BY t1.EDIT_TIME DESC,t1.ITEM_NO ASC"
                                               , materialType
                                               , lineCode
                                               , routeStepName
                                               , orderNumber
                                               , equipmentCode
                                               );
            DataTable dt2 = new DataTable();

            using (DBServiceClient client = new DBServiceClient())
            {
                MethodReturnResult <DataTable> dtResult = client.ExecuteQuery(sql2);
                if (dtResult.Code <= 0 && dtResult.Data.Rows.Count > 0)
                {
                    dt2         = dtResult.Data;
                    materialLot = dt2.Rows[0][0].ToString();
                }
            }
            return(materialLot);
        }
コード例 #2
0
        public ActionResult Query(ContrastColorViewModel mode)
        {
            String countTotal = string.Format(@"select count(*) from dbo.v_LotColor where create_time>'{0}' and create_time<'{1}'", mode.StartTestTime, mode.EndTestTime);
            String countSame  = string.Format(@"select count(*)  from dbo.v_LotColor where  Color=InspctResult and create_time>'{0}' and create_time<'{1}'", mode.StartTestTime, mode.EndTestTime);

            DataTable dtCountTotal = new DataTable();
            DataTable dtCountSame  = new DataTable();
            String    Proportion;

            using (DBServiceClient client = new DBServiceClient())
            {
                MethodReturnResult <DataTable> resultCountTotal = client.ExecuteQuery(countTotal);
                MethodReturnResult <DataTable> resultCountSame  = client.ExecuteQuery(countSame);
                if (resultCountSame.Code == 0 && resultCountTotal.Code == 0)
                {
                    dtCountSame        = resultCountSame.Data;
                    dtCountTotal       = resultCountTotal.Data;
                    Proportion         = (Convert.ToDouble(dtCountSame.Rows[0][0]) / Convert.ToDouble(dtCountTotal.Rows[0][0]) * 100).ToString().Substring(0, 4) + "%";
                    ViewBag.Proportion = Proportion;
                }
            }
            return(PartialView("_ListPartial"));
        }
コード例 #3
0
        public async Task<ActionResult> ExportToExcelPackage(IVTestDataForPackageQueryViewModel model)
        {


            JsonResult JsonResult = null;

            StringBuilder where = new StringBuilder();
            char[] splitChars = new char[] { ',', '$' };
            string[] packageNos = model.PackageNo.TrimEnd(splitChars).Split(splitChars);


            if (packageNos.Length <= 1)
            {
                where.AppendFormat("'" + packageNos[0] + "'");
            }
            else
            {
                foreach (string package in packageNos)
                {
                    where.AppendFormat("'{0}',", package);
                }
                where.Remove(where.Length - 1, 1);
            }
            String sql = string.Format(@"select 
											    t1.PACKAGE_NO,
											    t1.ITEM_NO,
											    t1.OBJECT_NUMBER,
											    t1.MATERIAL_CODE,
											    t5.MAIN_RAW_QTY,
                                                t3.GRADE,
                                                t3.COLOR,
                                                convert(decimal(18,2), t2.COEF_PMAX) COEF_PMAX ,
											    convert(decimal(18,2), t2.COEF_ISC)COEF_ISC,
											    convert(decimal(18,2), t2.COEF_VOC)COEF_VOC,
											    convert(decimal(18,2), t2.COEF_IMAX)COEF_IMAX,
											    convert(decimal(18,2), t2.COEF_VMAX)COEF_VMAX,
											    convert(decimal(18,2), t2.COEF_FF)COEF_FF,
											    t4.PM_NAME,
											    t2.PS_SUBCODE
                                                from WIP_PACKAGE_DETAIL t1
                                                inner join WIP_LOT t3 on t1.OBJECT_NUMBER =t3.LOT_NUMBER
                                                left join ZWIP_IV_TEST t2  on t1.OBJECT_NUMBER =t2.LOT_NUMBER
                                                inner join ZFMM_POWERSET t4 on t2.PS_CODE = t4.PS_CODE and t2.PS_ITEM_NO = t4.ITEM_NO
											    inner join FMM_MATERIAL t5 on t1.MATERIAL_CODE =t5.MATERIAL_CODE
                                            where 
                                                t2.IS_DEFAULT =1
                                                and t1.PACKAGE_NO 
											    in ({0}) 
											order by PACKAGE_NO,ITEM_NO", where);
            DataTable dt = new DataTable();
            using (DBServiceClient client = new DBServiceClient())
            {
                MethodReturnResult<DataTable> result = client.ExecuteQuery(sql);
                if (result.Code == 0)
                {
                    dt = result.Data;
                }
            }

            string template_path = Server.MapPath("~\\Labels\\");//模板路径
            string template_file = template_path + "Flash report 模板.xls";
            FileInfo tempFileInfo = new FileInfo(template_file);
            FileStream file = new FileStream(template_file, FileMode.Open, FileAccess.Read);
            IWorkbook hssfworkbook = new HSSFWorkbook(file);

            //创建sheet
            //Number Pallet No.  Type S/N  Pmp [W]  Isc [A]  Voc [V]  Imp [A]  Vmp [V]  FF  Pnom (W)  Current(A)
            NPOI.SS.UserModel.ISheet sheet1 = hssfworkbook.GetSheet("Sheet0");

            //创建单元格和单元格样式

            ICellStyle styles = hssfworkbook.CreateCellStyle();
            styles.FillForegroundColor = 10;
            styles.BorderBottom = BorderStyle.Thin;
            styles.BorderLeft = BorderStyle.Thin;
            styles.BorderRight = BorderStyle.Thin;
            styles.BorderTop = BorderStyle.Thin;
            styles.VerticalAlignment = VerticalAlignment.Center;
            styles.Alignment = HorizontalAlignment.Center;

            IFont font = hssfworkbook.CreateFont();
            font.Boldweight = 10;
            styles.SetFont(font);
            ICellStyle style = hssfworkbook.CreateCellStyle();
            style.FillForegroundColor = 10;
            style.BorderBottom = BorderStyle.Thin;
            style.BorderLeft = BorderStyle.Thin;
            style.BorderRight = BorderStyle.Thin;
            style.BorderTop = BorderStyle.Thin;
            style.VerticalAlignment = VerticalAlignment.Center;
            IFont fonts = hssfworkbook.CreateFont();
            font.Boldweight = 10;
            //style.DataFormat = format.GetFormat("yyyy年m月d日");  

            for (int j = 0; j < dt.Rows.Count; j++)
            {
                ICell cellData = null;
                IRow rowData = null;

                rowData = sheet1.CreateRow(j + 3);

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

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["PACKAGE_NO"].ToString());


                String a = dt.Rows[j]["MATERIAL_CODE"].ToString();
                int b = Convert.ToInt32(dt.Rows[j]["MAIN_RAW_QTY"]);
                String Type = string.Format("JNM{0}{1}"
                             , a.StartsWith("1201") ? "M" : "P"
                             , b.ToString());

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


                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["OBJECT_NUMBER"].ToString());

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["COEF_PMAX"].ToString());

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["COEF_ISC"].ToString());

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["COEF_IMAX"].ToString());

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["COEF_VOC"].ToString());

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["COEF_VMAX"].ToString());

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["COEF_FF"].ToString());

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["PM_NAME"].ToString());

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["PS_SUBCODE"].ToString());

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["GRADE"].ToString());

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["COLOR"].ToString());



                #endregion
            }
            MemoryStream ms = new MemoryStream();
            hssfworkbook.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return File(ms, "application/vnd.ms-excel", "IVTestDataData.xls");

        }
コード例 #4
0
        MethodReturnResult GetLot(string lotNumber)
        {
            bool IsMapChkLotState = false;

            //获取是否允许无限制条件(批次状态)匹配优化器
            using (BaseAttributeValueServiceClient ClientOfBASE = new BaseAttributeValueServiceClient())
            {
                IList <BaseAttributeValue> lstBaseAttributeValue = new List <BaseAttributeValue>();
                PagingConfig pg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Key.CategoryName='SystemParameters' and Key.AttributeName='MapChkLotState' ")
                };
                MethodReturnResult <IList <BaseAttributeValue> > r = ClientOfBASE.Get(ref pg);
                if (r.Code <= 0 && r.Data != null)
                {
                    lstBaseAttributeValue = r.Data;
                    IsMapChkLotState      = Convert.ToBoolean(lstBaseAttributeValue[0].Value);
                }
            }
            MethodReturnResult       result = new MethodReturnResult();
            MethodReturnResult <Lot> rst    = null;
            Lot obj = null;

            using (LotQueryServiceClient client = new LotQueryServiceClient())
            {
                rst = client.Get(lotNumber);
                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 || obj.Status == EnumObjectStatus.Disabled)
            {
                result.Code    = 2001;
                result.Message = string.Format(WIPResources.StringResource.LotIsNotExists, lotNumber);
                return(result);
            }
            if (IsMapChkLotState)
            {
                if (obj.StateFlag == EnumLotState.Finished)
                {
                    result.Code    = 2002;
                    result.Message = string.Format("批次({0})已完成。", lotNumber);
                    return(result);
                }
                else if (obj.Status == EnumObjectStatus.Disabled || obj.DeletedFlag == true)
                {
                    result.Code    = 2003;
                    result.Message = string.Format("批次({0})已结束。", lotNumber);
                    return(result);
                }
                else if (obj.HoldFlag == true)
                {
                    string    res  = null;
                    string    res2 = null;
                    string    sql  = string.Format(@"select ATTR_4  from WIP_LOT where LOT_NUMBER='{0}'", lotNumber);
                    DataTable dt   = new DataTable();
                    using (DBServiceClient client = new DBServiceClient())
                    {
                        MethodReturnResult <DataTable> dtResult = client.ExecuteQuery(sql);
                        if (result.Code == 0)
                        {
                            dt  = dtResult.Data;
                            res = dt.Rows[0][0].ToString();
                        }
                    }

                    string    sql2 = string.Format(@"select top 1 t2.HOLD_DESCRIPTION  from  WIP_TRANSACTION  t1
                                                   inner join [dbo].[WIP_TRANSACTION_HOLD_RELEASE]  t2 on  t1.TRANSACTION_KEY=t2.TRANSACTION_KEY
                                                   inner join WIP_LOT t3  on t3.LOT_NUMBER = t1.LOT_NUMBER  
                                                   where t1.LOT_NUMBER='{0}'
                                                   order by t2.HOLD_TIME  desc", lotNumber);
                    DataTable dt2  = new DataTable();
                    using (DBServiceClient client2 = new DBServiceClient())
                    {
                        MethodReturnResult <DataTable> dtResult2 = client2.ExecuteQuery(sql2);
                        if (result.Code == 0 && dtResult2.Data != null && dtResult2.Data.Rows.Count > 0)
                        {
                            dt2  = dtResult2.Data;
                            res2 = dt2.Rows[0][0].ToString();
                        }
                    }

                    if (dt != null && dt.Rows.Count > 0 && res != null && res != "")
                    {
                        result.Code    = 2004;
                        result.Message = string.Format("批次({0})已暂停,原因为:{1}。", lotNumber, res);
                    }
                    else if (dt != null && dt.Rows.Count > 0 && res2 != null && res2 != "")
                    {
                        result.Code    = 2004;
                        result.Message = string.Format("批次({0})已暂停。", lotNumber);
                    }
                    else
                    {
                        result.Code    = 2004;
                        result.Message = string.Format("批次({0})已暂停。", lotNumber);
                    }
                    return(result);
                }
            }
            return(rst);
        }