public MES_SY_LANGUAGE_TABLEZD_SELECT SELECT_TABLEZD(MES_SY_LANGUAGE_TABLEZD model, string ptoken)
 {
     return(client.SELECT_TABLEZD(model, ptoken));
 }
Beispiel #2
0
        public string EXPORT_RWQD(string datastring)
        {
            string        token = AppClass.GetSession("token").ToString();
            MES_RETURN_UI rst   = new MES_RETURN_UI();

            try
            {
                MES_SY_LANGUAGE_TABLEZD model_MES_SY_LANGUAGE_TABLEZD = new MES_SY_LANGUAGE_TABLEZD();
                model_MES_SY_LANGUAGE_TABLEZD.YMAREA       = "MES";
                model_MES_SY_LANGUAGE_TABLEZD.YMCONTROLLER = "PD";
                model_MES_SY_LANGUAGE_TABLEZD.YMVIEW       = "RW_SELECT_ALL";
                model_MES_SY_LANGUAGE_TABLEZD.TABLEDM      = "dc_tb_PDRW";
                model_MES_SY_LANGUAGE_TABLEZD.YMXM         = "SONLUKPC";
                model_MES_SY_LANGUAGE_TABLEZD.LB           = 1;
                MES_SY_LANGUAGE_TABLEZD_SELECT rst_MES_SY_LANGUAGE_TABLEZD_SELECT = mesModels.SY_LANGUAGE_YM.SELECT_TABLEZD(model_MES_SY_LANGUAGE_TABLEZD, token);
                if (rst_MES_SY_LANGUAGE_TABLEZD_SELECT.MES_RETURN.TYPE != "S")
                {
                    return(Newtonsoft.Json.JsonConvert.SerializeObject(rst_MES_SY_LANGUAGE_TABLEZD_SELECT.MES_RETURN));
                }
                if (rst_MES_SY_LANGUAGE_TABLEZD_SELECT.MES_SY_LANGUAGE_TABLEZD.Length > 0)
                {
                    AppClass.SetSession("EXPORT_RWQD", rst_MES_SY_LANGUAGE_TABLEZD_SELECT.MES_SY_LANGUAGE_TABLEZD[0].TABLENAME);
                }
                else
                {
                    AppClass.SetSession("EXPORT_RWQD", "NO HEAD");
                }
                MES_PD_SCRW_LIST[] model = Newtonsoft.Json.JsonConvert.DeserializeObject <MES_PD_SCRW_LIST[]>(datastring);
                //FileStream file = new FileStream(Server.MapPath("~") + @"/Areas/MES/ExportFile/生产任务导出.xls", FileMode.Open, FileAccess.Read);
                FileStream file      = new FileStream(Server.MapPath("~") + @"/Areas/HR/ExportFile/导出模版.xlsx", FileMode.Open, FileAccess.Read);
                IWorkbook  workbook  = new XSSFWorkbook(file);
                ISheet     sheet     = workbook.GetSheetAt(0);
                int        rowcount  = 0;
                IRow       rowtt     = sheet.CreateRow(rowcount++);
                int        cellIndex = 0;
                for (int a = 0; a < rst_MES_SY_LANGUAGE_TABLEZD_SELECT.MES_SY_LANGUAGE_TABLEZD.Length; a++)
                {
                    rowtt.CreateCell(cellIndex++).SetCellValue(rst_MES_SY_LANGUAGE_TABLEZD_SELECT.MES_SY_LANGUAGE_TABLEZD[a].TABLEZDNAME);
                }

                //IWorkbook workbook = new HSSFWorkbook(file);
                //ISheet sheet = workbook.GetSheetAt(0);
                //int rowcount = 1;
                for (int i = 0; i < model.Length; i++)
                {
                    cellIndex = 0;
                    IRow row = sheet.CreateRow(rowcount++);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].RWBH);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].WLH);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].WLMS);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].GC);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].GZZXBH);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].GZZXNAME);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].SBH);
                    row.CreateCell(cellIndex++).SetCellValue((double)model[i].SL);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].UNITSNAME);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].PFDH);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].PLDH);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].TH);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].XFCDNAME);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].PC);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].GDDH);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].ERPNO);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].JLRMS);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].JLTIME);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].TLSJ);
                    row.CreateCell(cellIndex++).SetCellValue(model[i].CCSJ);
                }
                string     now   = DateTime.Now.ToString("yyyyMMddHHmmss.fff");
                FileStream file1 = new FileStream(string.Format(@"{0}/Areas/MES/ExportFile/{1}.xlsx", Server.MapPath("~"), now), FileMode.Create);
                workbook.Write(file1);
                file1.Close();
                rst.TYPE    = "S";
                rst.MESSAGE = now;
            }
            catch
            {
                rst.TYPE    = "E";
                rst.MESSAGE = "生产文件失败!";
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(rst));
        }