Пример #1
0
        public RPTpackagelistParameter GetQueryConditionP(PackageTransactionViewModel model)
        {
            RPTpackagelistParameter p = new RPTpackagelistParameter()
            {
                PackageNo = model.PackageNo, //包装号
                PageNo    = model.PageNo,    //页号
                PageSize  = model.PageSize   //页码尺寸
            };

            return(p);
        }
Пример #2
0
 /// <summary>
 /// 获取包装号数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public ActionResult GetRPTPackageNoInfo(PackageNoAddDesViewModel model)
 {
     using (PackageQueryServiceClient client = new PackageQueryServiceClient())
     {
         RPTpackagelistParameter param = new RPTpackagelistParameter();
         param.PackageNo = model.PackageNo;
         MethodReturnResult <DataSet> result = client.GetRPTPackageNoInfo(param);
         if (result.Code == 0)
         {
             ViewBag.List = result.Data.Tables[0];
         }
         ;
     }
     return(PartialView("_ListPartial"));
 }
Пример #3
0
        //public ActionResult GetPackageTransaction(PackageTransactionQueryViewModel model)
        //{
        //    using (PackageQueryServiceClient client = new PackageQueryServiceClient())
        //    {

        //            MethodReturnResult<DataSet> result = client.GetPackageTransaction(model.PackageNo);

        //            if (result.Code == 0)
        //            {
        //                ViewBag.List = result.Data.Tables[0];
        //            };
        //    }
        //    return PartialView("_ListPartial");

        //}
        /// <summary>包装历史记录数据查询(存储过程获取数据) </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult GetPackageTransaction(PackageTransactionViewModel model)
        {
            string strErrorMessage = string.Empty;
            MethodReturnResult <DataSet> result = new MethodReturnResult <DataSet>();

            try
            {
                RPTpackagelistParameter param = GetQueryConditionP(model);
                using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {
                    MethodReturnResult <DataSet> ds = client.GetPackageTransactionQueryDb(ref param);
                    ViewBag.ListData     = ds.Data.Tables[0];
                    ViewBag.PagingConfig = new PagingConfig()
                    {
                        PageNo   = model.PageNo,
                        PageSize = model.PageSize,
                        Records  = param.TotalRecords
                    };
                    model.TotalRecords = param.TotalRecords;
                }
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = ex.Message;
                result.Detail  = ex.ToString();
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ListPartial", model));
            }
            else
            {
                return(View("Index", model));
            }
        }
Пример #4
0
        public async Task<ActionResult> ExportToExcel(IVTestDataForPackageQueryViewModel model)
        {


            JsonResult JsonResult = null;

            StringBuilder where = new StringBuilder();
            char[] splitChars = new char[] { ',', '$' };


            DataTable dt = new DataTable();
            using (PackageQueryServiceClient client = new PackageQueryServiceClient())
            {
                RPTpackagelistParameter p = new RPTpackagelistParameter();
                if (model.PackageNo != "" && model.PackageNo != null)
                {
                    p.PackageNo = model.PackageNo;
                    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);
                    }
                }
                else
                {
                    p.PackageNo = "";
                }
                if (model.LotNumber != "" && model.LotNumber != null)
                {
                    p.LotNumber = model.LotNumber;
                    string[] LotNumbers = model.LotNumber.TrimEnd(splitChars).Split(splitChars);


                    if (LotNumbers.Length <= 1)
                    {
                        where.AppendFormat("'" + LotNumbers[0] + "'");
                    }
                    else
                    {
                        foreach (string LotNumber in LotNumbers)
                        {
                            where.AppendFormat("'{0}',", LotNumber);
                        }
                        where.Remove(where.Length - 1, 1);
                    }
                }
                else
                {
                    p.LotNumber = "";

                }
                p.PageSize = model.PageSize;
                p.PageNo = -1;
                MethodReturnResult<DataSet> result = client.GetRPTpackagelistQueryDb(ref p);

                if (result.Code == 0 && result.Data != null && result.Data.Tables.Count > 0)
                {
                    dt = result.Data.Tables[0];
                }

            }

            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);  //序号

                //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]["PACKAGE_NO"].ToString());//包装号


                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["ITEM_NO"].ToString());//项目号


                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]["ORDER_NUMBER"].ToString());//工单号

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["MATERIAL_CODE"].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());//花色

                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]["DEC_CTM"].ToString());//CTM

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["CellEfficiency"].ToString());//电池片效率

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["PS_CODE"].ToString());//分档代码

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["PS_ITEM_NO"].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]["AMBIENTTEMP"].ToString());//测试温度

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["TEST_TIME"].ToString());//测试时间

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["RS"].ToString());//串联电阻

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["RSH"].ToString());//并联电阻

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

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

        }
Пример #5
0
        public async Task<ActionResult> ExportToExcelEx(IVTestDataForPackageQueryViewModel model)
        {
            //            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.ORDER_NUMBER,t1.MATERIAL_CODE,
            //                                            t3.GRADE,t3.COLOR,
            //                                            t2.PM,t2.ISC,t2.IPM,t2.VOC,t2.VPM,t2.FF,t2.EFF,t2.RS,t2.RSH,t2.AMBIENTTEMP,t2.SENSORTEMP,t2.INTENSITY, 
            //                                            t2.COEF_PMAX,t2.COEF_ISC,t2.COEF_IMAX,t2.COEF_VOC,t2.COEF_VMAX,t2.COEF_FF,t2.DEC_CTM,t3.ATTR_1, 
            //                                            t2.PS_CODE,t2.PS_ITEM_NO,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 
            //                                            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;
            //                }
            //            }
            DataTable dt = new DataTable();
            using (PackageQueryServiceClient client = new PackageQueryServiceClient())
            {
                RPTpackagelistParameter param = new RPTpackagelistParameter();
                param.PackageNo = model.PackageNo;
                param.LotNumber = model.LotNumber;
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key.PackageNo,ItemNo",
                        Where = GetQueryCondition(model)
                    };
                    // MethodReturnResult<IList<PackageDetail>> result = client.GetDetail(ref cfg);
                    MethodReturnResult<DataSet> ds = client.GetRPTpackagelist(param);
                    dt = ds.Data.Tables[0];
                    //if (result.Code == 0)
                    //{
                    //    ViewBag.PagingConfig = cfg;
                    //    ViewBag.List = result.Data;
                    //    ViewBag.HistoryList = ds;
                    //}
                });
            }
            //创建工作薄。
            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 < dt.Rows.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("背板温度");

                    //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("CTM");

                    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;
                }
                IRow rowData = ws.CreateRow(j + 1);

                #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(dt.Rows[j]["PACKAGE_NO"].ToString());

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

                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]["ORDER_NUMBER"].ToString());

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["MATERIAL_CODE"].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());

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

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

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

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

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

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

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

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

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

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

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

                //cellData = rowData.CreateCell(rowData.Cells.Count);
                //cellData.CellStyle = style;
                //cellData.SetCellValue(dt.Rows[j]["INTENSITY"].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]["DEC_CTM"].ToString());

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

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

                cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(dt.Rows[j]["PS_ITEM_NO"].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());

                #endregion
            }

            MemoryStream ms = new MemoryStream();
            wb.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return File(ms, "application/vnd.ms-excel", "IVTestDataData.xls");
        }
Пример #6
0
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public async Task<ActionResult> Query(IVTestDataForPackageQueryViewModel model)
        //{
        //    MethodReturnResult<ActionResult> result = new MethodReturnResult<ActionResult>();
        //    try
        //    {
        //        if (ModelState.IsValid)
        //        {
        //            using (PackageQueryServiceClient client = new PackageQueryServiceClient())
        //            {
        //                RPTpackagelistParameter param = new RPTpackagelistParameter();
        //                if (model.PackageNo != "" && model.PackageNo != null)
        //                {
        //                    param.PackageNo = model.PackageNo;

        //                }
        //                else
        //                {
        //                    param.PackageNo = "";
        //                }
        //                if (model.LotNumber != "" && model.LotNumber != null)
        //                {
        //                    param.LotNumber = model.LotNumber;
        //                }
        //                else
        //                {
        //                    param.LotNumber = "";

        //                }

        //                await Task.Run(() =>
        //                {
        //                    PagingConfig cfg = new PagingConfig()
        //                    {
        //                        OrderBy = "Key.PackageNo,ItemNo",
        //                        Where = GetQueryCondition(model)
        //                    };
        //                    // MethodReturnResult<IList<PackageDetail>> result = client.GetDetail(ref cfg);
        //                    MethodReturnResult<DataSet> ds = client.GetRPTpackagelistQueryDb(ref param);
        //                    ViewBag.HistoryList = ds;


        //                    if (ds.Code > 0)
        //                    {
        //                        result.Message = ds.Message;
        //                        result.Detail = ds.ToString();
        //                        //return Json(result);
        //                    }
        //                });
        //            }
        //        }
        //        if (Request.IsAjaxRequest())
        //        {
        //            return PartialView("_ListPartial", new IVTestDataForPackageViewModel());
        //        }
        //        else
        //        {
        //            return View("Index", model);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        result.Code = 1000;
        //        result.Message = ex.Message;
        //        result.Detail = ex.ToString();

        //    }
        //    return Json(result);

        //}


        public ActionResult Query(IVTestDataForPackageQueryViewModel model)
        {

            string strErrorMessage = string.Empty;
            MethodReturnResult<DataSet> result = new MethodReturnResult<DataSet>();
            try
            {
                RPTpackagelistParameter param = new RPTpackagelistParameter();
                if (model.PackageNo != "" && model.PackageNo != null)
                {
                    param.PackageNo = model.PackageNo;

                }
                else
                {
                    param.PackageNo = "";
                }
                if (model.LotNumber != "" && model.LotNumber != null)
                {
                    param.LotNumber = model.LotNumber;
                }
                else
                {
                    param.LotNumber = "";

                }
                param.PageSize = model.PageSize;
                param.PageNo = model.PageNo;
                using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {
                    //RPTLotMateriallistParameter param = new RPTLotMateriallistParameter();
                    //param.LotNumber = model.LotNumber;
                    
                    MethodReturnResult<DataSet> ds = client.GetRPTpackagelistQueryDb(ref param);

                    if (ds.Code > 0)
                    {
                        result.Code = ds.Code;
                        result.Message = ds.Message;
                        result.Detail = ds.Detail;

                        return Json(result);
                    }

                    ViewBag.ListData = ds.Data.Tables[0];
                    ViewBag.PagingConfig = new PagingConfig()
                    {
                        PageNo = model.PageNo,
                        PageSize = model.PageSize,
                        Records = param.TotalRecords

                    };
                    model.TotalRecords = param.TotalRecords;

                }
            }
            catch (Exception ex)
            {
                result.Code = 1000;
                result.Message = ex.Message;
                result.Detail = ex.ToString();
            }

            if (Request.IsAjaxRequest())
            {
                return PartialView("_ListPartial", model);
            }
            else
            {
                return View("Index", model);
            }
        }
Пример #7
0
        public async Task <ActionResult> ExportToXML(LotPackageSEModulesViewModel model)
        {
            IList <Package> lstLotPackage = new List <Package>();
            string          ftpServerIP   = System.Configuration.ConfigurationManager.AppSettings["ftpServerIP"];
            string          ftpUserID     = System.Configuration.ConfigurationManager.AppSettings["ftpUserID"];
            string          ftpPassword   = System.Configuration.ConfigurationManager.AppSettings["ftpPassword"];
            string          fileDate      = DateTime.Now.ToString("yyyyMMdd");

            if (!GetFile(ftpServerIP, ftpUserID, ftpPassword, fileDate))//
            {
                MakeDir(ftpServerIP, ftpUserID, ftpPassword, fileDate);
            }
            LotPackageSEModulesViewModel SEModulesModel = new LotPackageSEModulesViewModel();

            try
            {
                using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            IsPaging = false,
                            OrderBy  = "Key",
                            Where    = GetQueryCondition(model)
                        };
                        MethodReturnResult <IList <Package> > resultPackage = client.Get(ref cfg);
                        if (resultPackage.Code == 0)
                        {
                            lstLotPackage = resultPackage.Data;
                        }
                    });
                }

                string successMessage = string.Empty;  //记录导出成功批次
                string failMessage    = string.Empty;; //记录导出失败批次
                for (int i = 0; i < lstLotPackage.Count; i++)
                {
                    string packageNo = lstLotPackage[i].Key;//包装号
                    MethodReturnResult <IList <Lot> > lotDetail = null;

                    using (LotQueryServiceClient client = new LotQueryServiceClient())//取得包装号对应的批次信息
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            Where    = string.Format("PackageNo='{0}'", packageNo),
                            IsPaging = false
                        };
                        lotDetail = client.Get(ref cfg);
                    }
                    //string productType = SEModulesModel.GetProductType();
                    //创建XML文件
                    #region 1.创建类型声明节点
                    XmlDocument xmlDoc = new XmlDocument();     //XML对象
                    XmlNode     node   = xmlDoc.CreateXmlDeclaration("1.0", "ISO-8859-1", "no");
                    xmlDoc.AppendChild(node);
                    #endregion

                    #region 2.创建根节点
                    XmlElement root = xmlDoc.CreateElement("Parts");
                    root.SetAttribute("xmlns:xsi", @"http://www.w3.org/2001/XMLSchema-instance");
                    xmlDoc.AppendChild(root);
                    #endregion

                    #region 3批次数据节点
                    for (int j = 0; j < lotDetail.Data.Count; j++)
                    {
                        string lotNumber = lotDetail.Data[j].Key;//批次号
                        //string packageNo = lotDetail.Data[j].PackageNo;//托号
                        string seModulesNo = string.Empty;
                        //if (lotDetail.Data[j].Attr3 != "" && lotDetail.Data[j].Attr3.Split('-').Length > 1)
                        //{
                        //    seModulesNo = lotDetail.Data[j].Attr3.Split('-')[1];
                        //}
                        //else
                        //{
                        //    seModulesNo = lotDetail.Data[j].Attr3;
                        //}
                        seModulesNo = lotDetail.Data[j].Attr3;

                        string orderNumber  = lotDetail.Data[j].OrderNumber;
                        string materialCode = lotDetail.Data[j].MaterialCode;

                        string pmp     = "";
                        string isc     = "";
                        string imp     = "";
                        string voc     = "";
                        string vmp     = "";
                        string ff      = "";
                        string pnom    = "";
                        string current = "";
                        string colour  = "";

                        if (lotDetail.Data[j].Color == "深蓝")
                        {
                            colour = "Dark Blue";
                        }
                        if (lotDetail.Data[j].Color == "浅蓝")
                        {
                            colour = "Light Blue";
                        }
                        if (lotDetail.Data[j].Color == "正蓝")
                        {
                            colour = "Blue";
                        }

                        IVTestData ivtest             = SEModulesModel.GetIVTestData(lotNumber);
                        RPTpackagelistParameter param = new RPTpackagelistParameter();
                        param.PackageNo = packageNo;
                        param.LotNumber = lotNumber;
                        param.PageSize  = 20;
                        using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                        {
                            MethodReturnResult <DataSet> ds = client.GetRPTpackagelistQueryDb(ref param);
                            if (ds.Code > 0)
                            {
                                //return Content("批次{0}五大参数异常", lotNumber);
                            }
                            else
                            {
                                DataTable dtOfIV = ds.Data.Tables[0];
                                pmp = Convert.ToDecimal(dtOfIV.Rows[0]["COEF_PMAX"]).ToString("F3");
                                isc = Convert.ToDecimal(dtOfIV.Rows[0]["COEF_ISC"]).ToString("F3");
                                imp = Convert.ToDecimal(dtOfIV.Rows[0]["COEF_IMAX"]).ToString("F3");
                                voc = Convert.ToDecimal(dtOfIV.Rows[0]["COEF_VOC"]).ToString("F3");
                                vmp = Convert.ToDecimal(dtOfIV.Rows[0]["COEF_VMAX"]).ToString("F3");
                                if (Convert.ToDecimal(dtOfIV.Rows[0]["COEF_FF"]) < 1)
                                {
                                    ff = (Convert.ToDecimal(dtOfIV.Rows[0]["COEF_FF"]) * 100).ToString("F3");
                                }
                                else
                                {
                                    ff = Convert.ToDecimal(dtOfIV.Rows[0]["COEF_FF"]).ToString("F3");
                                }
                                pnom    = dtOfIV.Rows[0]["PM_NAME"].ToString();
                                current = dtOfIV.Rows[0]["PS_SUBCODE"].ToString();
                                if (current == "α")
                                {
                                    current = "A";
                                }
                                if (current == "β")
                                {
                                    current = "B";
                                }
                                if (current == "γ")
                                {
                                    current = "C";
                                }
                            }
                        }
                        string productType  = SEModulesModel.GetProductType(materialCode, orderNumber, ivtest.PowersetCode, ivtest.PowersetItemNo.Value, lotDetail.Data[j]);  //对应主铭牌上的产品型号
                        string productTypes = SEModulesModel.GetProductTypes(materialCode, orderNumber, ivtest.PowersetCode, ivtest.PowersetItemNo.Value, lotDetail.Data[j]); //对应副标签上的产品型号
                        if (productType == "" || productTypes == "")
                        {
                            return(Content("产片编码:{0}未设置产品对应属性", materialCode));
                        }
                        XmlNode PartDataNode = xmlDoc.CreateNode(XmlNodeType.Element, "PartData", null);
                        root.AppendChild(PartDataNode);
                        CreateNode(xmlDoc, PartDataNode, "ModuleSerialNumber", "JN" + lotNumber);
                        CreateNode(xmlDoc, PartDataNode, "SESerialNumber", seModulesNo);
                        CreateNode(xmlDoc, PartDataNode, "PartNumber", productTypes);
                        CreateNode(xmlDoc, PartDataNode, "PalletNumber", packageNo);

                        //CreateNode(xmlDoc, PartDataNode, "Pmp-W", pmp);
                        //CreateNode(xmlDoc, PartDataNode, "Isc-A", isc);
                        //CreateNode(xmlDoc, PartDataNode, "Imp-A", imp);
                        //CreateNode(xmlDoc, PartDataNode, "Voc-V", voc);
                        //CreateNode(xmlDoc, PartDataNode, "Vmp-V", vmp);
                        //CreateNode(xmlDoc, PartDataNode, "FF-%", ff);
                        //CreateNode(xmlDoc, PartDataNode, "Pnom-W", pnom);
                        //CreateNode(xmlDoc, PartDataNode, "Current-A", current);

                        CreateNode(xmlDoc, PartDataNode, "Pmp", pmp + "W");
                        CreateNode(xmlDoc, PartDataNode, "Isc", isc + "A");
                        CreateNode(xmlDoc, PartDataNode, "Imp", imp + "A");
                        CreateNode(xmlDoc, PartDataNode, "Voc", voc + "V");
                        CreateNode(xmlDoc, PartDataNode, "Vmp", vmp + "V");
                        CreateNode(xmlDoc, PartDataNode, "FF", ff + "%");
                        CreateNode(xmlDoc, PartDataNode, "Pnom", pnom);
                        CreateNode(xmlDoc, PartDataNode, "Current", current);
                        CreateNode(xmlDoc, PartDataNode, "Colour", colour);
                        CreateNode(xmlDoc, PartDataNode, "LabelPN", productType);
                    }
                    #endregion

                    //XML路径
                    string path = Server.MapPath("~/SEModules/");
                    if (Directory.Exists(path) == false)
                    {
                        Directory.CreateDirectory(path);
                    }
                    string fileName = "SEModules" + DateTime.Now.ToString("yyyyMMddHHmm") + packageNo + ".xml";
                    string pathFile = path + fileName;
                    xmlDoc.Save(pathFile);

                    //string ftpServerIP = "seftp.solaredge.com";
                    //string ftpUserID = "jinergy";
                    //string ftpPassword = "******";
                    if (UploadFtp(path, fileDate, fileName, ftpServerIP, ftpUserID, ftpPassword))
                    {
                        successMessage = successMessage + packageNo + ";";
                    }
                    else
                    {
                        failMessage = failMessage + packageNo + ";";
                    }
                }
                if (successMessage.Length > 0)
                {
                    successMessage = successMessage + "导出成功";
                }
                if (failMessage.Length > 0)
                {
                    failMessage = failMessage + "导出失败";
                }
                return(Content("批次号:" + successMessage + failMessage));
            }
            catch (Exception err)
            {
                return(Content(string.Format("导出XML报错:{0}", err.Message)));
            }
        }