コード例 #1
0
        public MES_RETURN_UI Update(FIVES_CHECK_INFODETAIL model, string ptoken)
        {
            MES_RETURN    mr   = client.UPDATE(model, ptoken);
            MES_RETURN_UI mrui = new MES_RETURN_UI();

            mrui.TYPE    = mr.TYPE;
            mrui.MESSAGE = mr.MESSAGE;
            return(mrui);
        }
コード例 #2
0
        public string PFMX_Select(int infoid)
        {
            token = appClass.CRM_Gettoken();
            FIVES_CHECK_INFODETAIL model = new FIVES_CHECK_INFODETAIL();

            model.INFOID = infoid;
            FIVES_CHECK_INFODETAILList[] rst = fivesmodels.CHECK_INFODETAIL.Read(model, token);
            return(Newtonsoft.Json.JsonConvert.SerializeObject(rst));
        }
コード例 #3
0
 public FIVES_CHECK_INFODETAILList[] Read(FIVES_CHECK_INFODETAIL model, string ptoken)
 {
     return(client.Read(model, ptoken));
 }
コード例 #4
0
        public string EXPORT_CHeck_SELECT(string data, int type, string KSTIME, string JSTIME)
        {
            int           STAFFID = Convert.ToInt32(AppClass.GetSession("STAFFID"));
            MES_RETURN_UI rst     = new MES_RETURN_UI();

            token = appClass.CRM_Gettoken();


            try
            {
                if (type == 1)
                {
                    #region checkinfo
                    FIVES_CHECK_INFOList model = Newtonsoft.Json.JsonConvert.DeserializeObject <FIVES_CHECK_INFOList>(data);
                    // model.HG = 1;
                    //FIVES_CHECK_INFOList model = new FIVES_CHECK_INFOList();

                    FIVES_CHECK_INFOList[] checkinfolist = fivesmodels.CHECK_INFO.Read(model, token);
                    FileStream             file          = new FileStream(Server.MapPath("~") + @"/Areas/FIVES/ExcelTemplate/5S不合格点检报表导出.xlsx", FileMode.Open, FileAccess.Read);
                    IWorkbook workbook = new XSSFWorkbook(file);
                    ISheet    sheet    = workbook.GetSheetAt(0);
                    int       rowcount = 1;
                    for (int i = 0; i < checkinfolist.Length; i++)
                    {
                        int  cellIndex = 0;
                        IRow row       = sheet.CreateRow(rowcount++);
                        row.CreateCell(cellIndex++).SetCellValue(checkinfolist[i].OPINTMS);
                        row.CreateCell(cellIndex++).SetCellValue(checkinfolist[i].DEPARTMS);
                        row.CreateCell(cellIndex++).SetCellValue(checkinfolist[i].SHOWNAMEMS);
                        if (checkinfolist[i].HG == 0)
                        {
                            row.CreateCell(cellIndex++).SetCellValue("合格");
                        }
                        else if (checkinfolist[i].HG == 1)
                        {
                            row.CreateCell(cellIndex++).SetCellValue("不合格");
                        }
                        row.CreateCell(cellIndex++).SetCellValue(checkinfolist[i].SHOWTIME);
                        row.CreateCell(cellIndex++).SetCellValue(checkinfolist[i].REMARK);
                        row.CreateCell(cellIndex++).SetCellValue(checkinfolist[i].POSITION);
                    }
                    //获取当前列的宽度,然后对比本列的长度,取最大值
                    for (int columnNum = 0; columnNum <= checkinfolist.Length; columnNum++)
                    {
                        int columnWidth = sheet.GetColumnWidth(columnNum) / 256;
                        for (int rowNum = 1; rowNum <= sheet.LastRowNum; rowNum++)
                        {
                            IRow currentRow;
                            //当前行未被使用过
                            if (sheet.GetRow(rowNum) == null)
                            {
                                currentRow = sheet.CreateRow(rowNum);
                            }
                            else
                            {
                                currentRow = sheet.GetRow(rowNum);
                            }

                            if (currentRow.GetCell(columnNum) != null)
                            {
                                ICell currentCell = currentRow.GetCell(columnNum);
                                int   length      = Encoding.Default.GetBytes(currentCell.ToString()).Length;
                                if (columnWidth < length)
                                {
                                    columnWidth = length;
                                }
                            }
                        }
                        sheet.SetColumnWidth(columnNum, columnWidth * 256);
                    }

                    string     now   = DateTime.Now.ToString("yyyyMMddHHmmss.fff");
                    FileStream file1 = new FileStream(string.Format(@"{0}/Areas/FIVES/ExcelTemplate/{1}.xlsx", Server.MapPath("~"), now + STAFFID + "13"), FileMode.Create);
                    workbook.Write(file1);
                    file1.Close();
                    rst.TYPE    = "S";
                    rst.MESSAGE = now + STAFFID + "13";
                    #endregion
                }
                else if (type == 2)
                {
                    #region checkinfomx
                    FIVES_CHECK_INFOList model = Newtonsoft.Json.JsonConvert.DeserializeObject <FIVES_CHECK_INFOList>(data);
                    // model.HG = 1;
                    //FIVES_CHECK_INFOList model = new FIVES_CHECK_INFOList();

                    FIVES_CHECK_INFOList[]            checkinfolist   = fivesmodels.CHECK_INFO.Read(model, token);
                    List <FIVES_CHECK_INFODETAILList> checkinfomxlist = new List <FIVES_CHECK_INFODETAILList>();
                    for (int i = 0; i < checkinfolist.Length; i++)
                    {
                        FIVES_CHECK_INFODETAIL mxmodel = new FIVES_CHECK_INFODETAIL();
                        mxmodel.INFOID = checkinfolist[i].INFOID;
                        checkinfomxlist.AddRange(fivesmodels.CHECK_INFODETAIL.Read(mxmodel, token));
                    }

                    FileStream file     = new FileStream(Server.MapPath("~") + @"/Areas/FIVES/ExcelTemplate/5S不合格点检报表明细导出.xlsx", FileMode.Open, FileAccess.Read);
                    IWorkbook  workbook = new XSSFWorkbook(file);
                    ISheet     sheet    = workbook.GetSheetAt(0);
                    int        rowcount = 1;
                    for (int i = 0; i < checkinfomxlist.Count; i++)
                    {
                        int  cellIndex = 0;
                        IRow row       = sheet.CreateRow(rowcount++);
                        FIVES_CHECK_INFOList checkinfo = checkinfolist.Where(p => p.INFOID == checkinfomxlist[i].INFOID).ToList()[0];
                        row.CreateCell(cellIndex++).SetCellValue(checkinfo.OPINTMS);
                        row.CreateCell(cellIndex++).SetCellValue(checkinfo.DEPARTMS);
                        row.CreateCell(cellIndex++).SetCellValue(checkinfo.SHOWNAMEMS);
                        row.CreateCell(cellIndex++).SetCellValue(checkinfo.SHOWTIME);
                        row.CreateCell(cellIndex++).SetCellValue(checkinfo.REMARK);
                        row.CreateCell(cellIndex++).SetCellValue(checkinfomxlist[i].TYPEMS);
                        row.CreateCell(cellIndex++).SetCellValue(checkinfomxlist[i].REMARK);
                    }
                    //获取当前列的宽度,然后对比本列的长度,取最大值
                    for (int columnNum = 0; columnNum <= checkinfolist.Length; columnNum++)
                    {
                        int columnWidth = sheet.GetColumnWidth(columnNum) / 256;
                        for (int rowNum = 1; rowNum <= sheet.LastRowNum; rowNum++)
                        {
                            IRow currentRow;
                            //当前行未被使用过
                            if (sheet.GetRow(rowNum) == null)
                            {
                                currentRow = sheet.CreateRow(rowNum);
                            }
                            else
                            {
                                currentRow = sheet.GetRow(rowNum);
                            }

                            if (currentRow.GetCell(columnNum) != null)
                            {
                                ICell currentCell = currentRow.GetCell(columnNum);
                                int   length      = Encoding.Default.GetBytes(currentCell.ToString()).Length;
                                if (columnWidth < length)
                                {
                                    columnWidth = length;
                                }
                            }
                        }
                        sheet.SetColumnWidth(columnNum, columnWidth * 256);
                    }

                    string     now   = DateTime.Now.ToString("yyyyMMddHHmmss.fff");
                    FileStream file1 = new FileStream(string.Format(@"{0}/Areas/FIVES/ExcelTemplate/{1}.xlsx", Server.MapPath("~"), now + STAFFID + "13"), FileMode.Create);
                    workbook.Write(file1);
                    file1.Close();
                    rst.TYPE    = "S";
                    rst.MESSAGE = now + STAFFID + "13";
                    #endregion
                }
                else if (type == 3)
                {
                    FIVES_CHECK_INFOList model = Newtonsoft.Json.JsonConvert.DeserializeObject <FIVES_CHECK_INFOList>(data);
                    //FIVES_CHECK_INFOList model = new FIVES_CHECK_INFOList();

                    FIVES_CHECK_INFOList[] hzarr = fivesmodels.CHECK_INFO.Read_HZINFO(model, token);
                    FileStream             file  = new FileStream(Server.MapPath("~") + @"/Areas/FIVES/ExcelTemplate/点检汇总导出.xlsx", FileMode.Open, FileAccess.Read);
                    IWorkbook workbook           = new XSSFWorkbook(file);
                    ISheet    sheet     = workbook.GetSheetAt(0);
                    ISheet    sheet1    = workbook.GetSheetAt(1);
                    ISheet    sheet2    = workbook.GetSheetAt(2);
                    int       rowcount  = 1;
                    int       rowsecond = 1;
                    int       rowsthird = 1;
                    //  FIVES_CHECK_INFOList[] TTdata = new FIVES_CHECK_INFOList[];

                    for (int i = 0; i < hzarr.Length; i++)
                    {
                        int  Index = 0;
                        IRow row   = sheet.CreateRow(rowcount++);
                        row.CreateCell(Index++).SetCellValue(hzarr[i].OPINTMS);
                        row.CreateCell(Index++).SetCellValue(hzarr[i].DEPARTMS);
                        row.CreateCell(Index++).SetCellValue(hzarr[i].FREQUENCYNAME);
                        row.CreateCell(Index++).SetCellValue(hzarr[i].CHECKCOUNT);
                        row.CreateCell(Index++).SetCellValue(hzarr[i].BHGCOUNT);
                        decimal d = hzarr[i].BHGCOUNT == 0 ? 100.0M : Math.Round(100 - (decimal)(hzarr[i].BHGCOUNT * 100) / hzarr[i].CHECKCOUNT, 1);
                        row.CreateCell(Index++).SetCellValue(d.ToString("##.0") + "%");

                        FIVES_CHECK_INFOList TTmodel = new FIVES_CHECK_INFOList();
                        TTmodel.OPINTID  = hzarr[i].OPINTID;
                        TTmodel.KSTIME   = KSTIME;
                        TTmodel.JSTIME   = JSTIME;
                        TTmodel.HG       = 2;
                        TTmodel.ISDELETE = true;

                        FIVES_CHECK_INFOList[] TTdata = fivesmodels.CHECK_INFO.Read(TTmodel, token);
                        for (int x = 0; x < TTdata.Length; x++)
                        {
                            string str       = "";
                            int    cellIndex = 0;
                            IRow   second    = sheet1.CreateRow(rowsecond++);
                            second.CreateCell(cellIndex++).SetCellValue(TTdata[x].OPINTMS);
                            second.CreateCell(cellIndex++).SetCellValue(TTdata[x].DEPARTMS);
                            if (TTdata[x].HG == 1)
                            {
                                str = "不合格";
                            }
                            else
                            {
                                str = "合格";
                            }
                            second.CreateCell(cellIndex++).SetCellValue(str);
                            second.CreateCell(cellIndex++).SetCellValue(TTdata[x].SHOWNAMEMS);
                            second.CreateCell(cellIndex++).SetCellValue(TTdata[x].SHOWTIME);
                            second.CreateCell(cellIndex++).SetCellValue(TTdata[x].REMARK);

                            FIVES_CHECK_INFODETAIL MXmodel = new FIVES_CHECK_INFODETAIL();
                            MXmodel.INFOID = TTdata[x].INFOID;
                            FIVES_CHECK_INFODETAILList[] MXdata = fivesmodels.CHECK_INFODETAIL.Read(MXmodel, token);
                            for (int j = 0; j < MXdata.Length; j++)
                            {
                                int  cellIthird = 0;
                                IRow third      = sheet2.CreateRow(rowsthird++);
                                third.CreateCell(cellIthird++).SetCellValue(TTdata[x].OPINTMS);
                                third.CreateCell(cellIthird++).SetCellValue(TTdata[x].DEPARTMS);
                                third.CreateCell(cellIthird++).SetCellValue(TTdata[x].SHOWNAMEMS);
                                third.CreateCell(cellIthird++).SetCellValue(TTdata[x].SHOWTIME);
                                third.CreateCell(cellIthird++).SetCellValue(MXdata[j].TYPEMS);
                                third.CreateCell(cellIthird++).SetCellValue(MXdata[j].REMARK);
                            }
                        }
                        for (int columnNum = 0; columnNum <= TTdata.Length; columnNum++)
                        {
                            int columnWidth = sheet1.GetColumnWidth(columnNum) / 256;
                            for (int rowNum = 1; rowNum <= sheet.LastRowNum; rowNum++)
                            {
                                IRow currentRow;
                                //当前行未被使用过
                                if (sheet1.GetRow(rowNum) == null)
                                {
                                    currentRow = sheet1.CreateRow(rowNum);
                                }
                                else
                                {
                                    currentRow = sheet1.GetRow(rowNum);
                                }

                                if (currentRow.GetCell(columnNum) != null)
                                {
                                    ICell currentCell = currentRow.GetCell(columnNum);
                                    int   length      = Encoding.Default.GetBytes(currentCell.ToString()).Length;
                                    if (columnWidth < length)
                                    {
                                        columnWidth = length;
                                    }
                                }
                            }
                            sheet.SetColumnWidth(columnNum, columnWidth * 256);
                        }
                    }
                    //获取当前列的宽度,然后对比本列的长度,取最大值
                    for (int columnNum = 0; columnNum <= hzarr.Length; columnNum++)
                    {
                        int columnWidth = sheet.GetColumnWidth(columnNum) / 256;
                        for (int rowNum = 1; rowNum <= sheet.LastRowNum; rowNum++)
                        {
                            IRow currentRow;
                            //当前行未被使用过
                            if (sheet.GetRow(rowNum) == null)
                            {
                                currentRow = sheet.CreateRow(rowNum);
                            }
                            else
                            {
                                currentRow = sheet.GetRow(rowNum);
                            }

                            if (currentRow.GetCell(columnNum) != null)
                            {
                                ICell currentCell = currentRow.GetCell(columnNum);
                                int   length      = Encoding.Default.GetBytes(currentCell.ToString()).Length;
                                if (columnWidth < length)
                                {
                                    columnWidth = length;
                                }
                            }
                        }
                        sheet.SetColumnWidth(columnNum, columnWidth * 256);
                    }


                    sheet.ForceFormulaRecalculation  = true;
                    sheet1.ForceFormulaRecalculation = true;
                    sheet2.ForceFormulaRecalculation = true;
                    string     now   = DateTime.Now.ToString("yyyyMMddHHmmss.fff");
                    FileStream file1 = new FileStream(string.Format(@"{0}/Areas/FIVES/ExcelTemplate/{1}.xlsx", Server.MapPath("~"), now + STAFFID + "13"), FileMode.Create);
                    workbook.Write(file1);
                    file1.Close();
                    rst.TYPE    = "S";
                    rst.MESSAGE = now + STAFFID + "13";
                }
            }
            catch (Exception e)
            {
                rst.TYPE    = "E";
                rst.MESSAGE = e.Message;
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(rst));
        }