|
|
@@ -63,145 +63,189 @@ namespace UAS_MES_NEW.Query
|
|
|
MessageBox.Show("文件不能为空!");
|
|
|
return;
|
|
|
}
|
|
|
- ps_prodcode.Text = FilePath.Text.Substring(FilePath.Text.LastIndexOf(@"\") + 1).Replace(".xls", "").Replace(".xlsx", "");
|
|
|
- pr_code_Leave(new object(), new EventArgs());
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql("select * from productsop where ps_prodcode='" + ps_prodcode.Text + "' ", "select");
|
|
|
- if (dt.Rows.Count == 0)
|
|
|
+ if (JPG.Checked)
|
|
|
{
|
|
|
- string code = LogicHandler.GetPiInoutCode("ProductSOP", "1");
|
|
|
- ps_code.Text = code;
|
|
|
- if (VaildDate.Checked)
|
|
|
+ ps_prodcode.Text = FilePath.Text.Substring(FilePath.Text.LastIndexOf(@"\") + 1).Replace(".xls", "").Replace(".xlsx", "");
|
|
|
+ pr_code_Leave(new object(), new EventArgs());
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select * from productsop where ps_prodcode='" + ps_prodcode.Text + "' ", "select");
|
|
|
+ if (dt.Rows.Count == 0)
|
|
|
{
|
|
|
- dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman,ps_status,ps_statuscode,ps_vailddate)values(productsop_seq.nextval,'" + code + "','" + ps_prodcode.Text + "',sysdate,'" + User.UserName + "','在录入','ENTERING',to_date('" + DateCode.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd'))", "insert");
|
|
|
+ string code = LogicHandler.GetPiInoutCode("ProductSOP", "1");
|
|
|
+ ps_code.Text = code;
|
|
|
+ if (VaildDate.Checked)
|
|
|
+ {
|
|
|
+ dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman,ps_status,ps_statuscode,ps_vailddate)values(productsop_seq.nextval,'" + code + "','" + ps_prodcode.Text + "',sysdate,'" + User.UserName + "','在录入','ENTERING',to_date('" + DateCode.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd'))", "insert");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman,ps_status,ps_statuscode)values(productsop_seq.nextval,'" + code + "','" + ps_prodcode.Text + "',sysdate,'" + User.UserName + "','在录入','ENTERING')", "insert");
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman,ps_status,ps_statuscode)values(productsop_seq.nextval,'" + code + "','" + ps_prodcode.Text + "',sysdate,'" + User.UserName + "','在录入','ENTERING')", "insert");
|
|
|
+ string ps_id = dt.Rows[0]["ps_id"].ToString();
|
|
|
+ dh.ExecuteSql("delete from ProductSOPdetail where psd_psid='" + ps_id + "'", "delete");
|
|
|
+ ps_prodcode.Text = dt.Rows[0]["ps_prodcode"].ToString();
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- string ps_id = dt.Rows[0]["ps_id"].ToString();
|
|
|
- dh.ExecuteSql("delete from ProductSOPdetail where psd_psid='" + ps_id + "'", "delete");
|
|
|
- ps_prodcode.Text = dt.Rows[0]["ps_prodcode"].ToString();
|
|
|
- }
|
|
|
- Workbook workbook = new Workbook(FilePath.Text);
|
|
|
- List<Worksheet> list = new List<Worksheet>();
|
|
|
- List<string> filename = new List<string>();
|
|
|
+ Workbook workbook = new Workbook(FilePath.Text);
|
|
|
+ List<Worksheet> list = new List<Worksheet>();
|
|
|
+ List<string> filename = new List<string>();
|
|
|
|
|
|
- if (VaildDate.Checked)
|
|
|
- {
|
|
|
- dh.ExecuteSql("update ProductSOP set ps_attachsop='',ps_inman='" + User.UserName + "',ps_vailddate=to_date('" + DateCode.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd') where ps_prodcode='" + ps_prodcode.Text + "'", "update");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- dh.ExecuteSql("update ProductSOP set ps_attachsop='',ps_inman='" + User.UserName + "' where ps_prodcode='" + ps_prodcode.Text + "'", "update");
|
|
|
- }
|
|
|
+ if (VaildDate.Checked)
|
|
|
+ {
|
|
|
+ dh.ExecuteSql("update ProductSOP set ps_attachsop='',ps_inman='" + User.UserName + "',ps_vailddate=to_date('" + DateCode.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd') where ps_prodcode='" + ps_prodcode.Text + "'", "update");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dh.ExecuteSql("update ProductSOP set ps_attachsop='',ps_inman='" + User.UserName + "' where ps_prodcode='" + ps_prodcode.Text + "'", "update");
|
|
|
+ }
|
|
|
|
|
|
- OperatResult.AppendText("一共Sheet: " + workbook.Worksheets.Count + "\n");
|
|
|
- for (int i = 0; i < workbook.Worksheets.Count; i++)
|
|
|
- {
|
|
|
- OperatResult.AppendText("正在解析Sheet" + workbook.Worksheets[i].Name + "\n");
|
|
|
- string path = Application.StartupPath + @"\" + ps_prodcode.Text + @"\";
|
|
|
- Worksheet she = workbook.Worksheets[i];
|
|
|
- int lastColIndex = she.Cells.MaxDataColumn;
|
|
|
- string lastColLetter = CellsHelper.ColumnIndexToName(lastColIndex);
|
|
|
- she.PageSetup.LeftMargin = 0;
|
|
|
- she.PageSetup.RightMargin = 0;
|
|
|
- she.PageSetup.TopMargin = 0;
|
|
|
- she.PageSetup.BottomMargin = 0;
|
|
|
- if (JPG.Checked)
|
|
|
+ OperatResult.AppendText("一共Sheet: " + workbook.Worksheets.Count + "\n");
|
|
|
+ for (int i = 0; i < workbook.Worksheets.Count; i++)
|
|
|
{
|
|
|
- try
|
|
|
+ OperatResult.AppendText("正在解析Sheet" + workbook.Worksheets[i].Name + "\n");
|
|
|
+ string path = Application.StartupPath + @"\" + ps_prodcode.Text + @"\";
|
|
|
+ Worksheet she = workbook.Worksheets[i];
|
|
|
+ int lastColIndex = she.Cells.MaxDataColumn;
|
|
|
+ string lastColLetter = CellsHelper.ColumnIndexToName(lastColIndex);
|
|
|
+ she.PageSetup.LeftMargin = 0;
|
|
|
+ she.PageSetup.RightMargin = 0;
|
|
|
+ she.PageSetup.TopMargin = 0;
|
|
|
+ she.PageSetup.BottomMargin = 0;
|
|
|
+ if (JPG.Checked)
|
|
|
{
|
|
|
- if (!Directory.Exists(Application.StartupPath + @"\" + ps_prodcode.Text))
|
|
|
- {
|
|
|
- Directory.CreateDirectory(Application.StartupPath + @"\" + ps_prodcode.Text);
|
|
|
- }
|
|
|
- string sheetname = she.Name;
|
|
|
- // 获取工作表中的所有图片
|
|
|
- List<Picture> pictures = new List<Picture>();
|
|
|
- foreach (Aspose.Cells.Drawing.Picture picture in she.Pictures)
|
|
|
+ try
|
|
|
{
|
|
|
- pictures.Add(picture);
|
|
|
- }
|
|
|
- // 获取使用的行数
|
|
|
- int totalRows = she.Cells.MaxDataRow + 1;
|
|
|
- int imageIndex = 1;
|
|
|
+ if (!Directory.Exists(Application.StartupPath + @"\" + ps_prodcode.Text))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(Application.StartupPath + @"\" + ps_prodcode.Text);
|
|
|
+ }
|
|
|
+ string sheetname = she.Name;
|
|
|
+ // 获取工作表中的所有图片
|
|
|
+ List<Picture> pictures = new List<Picture>();
|
|
|
+ foreach (Aspose.Cells.Drawing.Picture picture in she.Pictures)
|
|
|
+ {
|
|
|
+ pictures.Add(picture);
|
|
|
+ }
|
|
|
+ // 获取使用的行数
|
|
|
+ int totalRows = she.Cells.MaxDataRow + 1;
|
|
|
+ int imageIndex = 1;
|
|
|
|
|
|
- // 每40行生成一张图片
|
|
|
- for (int startRow = 0; startRow < totalRows; startRow += int.Parse(RowCount.Value.ToString()))
|
|
|
- {
|
|
|
- int endRow = Math.Min(startRow + int.Parse(RowCount.Value.ToString()) - 1, totalRows - 1);
|
|
|
- // 创建图片选项
|
|
|
- ImageOrPrintOptions options = new ImageOrPrintOptions();
|
|
|
- options.ImageFormat = ImageFormat.Png;
|
|
|
- options.OnePagePerSheet = false;
|
|
|
- options.PrintingPage = PrintingPageType.IgnoreBlank;
|
|
|
-
|
|
|
- she.PageSetup.PrintArea = $"A{startRow + 1}:{lastColLetter}{endRow + 1}";
|
|
|
- if (File.Exists(PrintPath.Text))
|
|
|
+ // 每40行生成一张图片
|
|
|
+ for (int startRow = 0; startRow < totalRows; startRow += int.Parse(RowCount.Value.ToString()))
|
|
|
{
|
|
|
- if (startRow == 0)
|
|
|
+ int endRow = Math.Min(startRow + int.Parse(RowCount.Value.ToString()) - 1, totalRows - 1);
|
|
|
+ // 创建图片选项
|
|
|
+ ImageOrPrintOptions options = new ImageOrPrintOptions();
|
|
|
+ options.ImageFormat = ImageFormat.Png;
|
|
|
+ options.OnePagePerSheet = false;
|
|
|
+ options.PrintingPage = PrintingPageType.IgnoreBlank;
|
|
|
+
|
|
|
+ she.PageSetup.PrintArea = $"A{startRow + 1}:{lastColLetter}{endRow + 1}";
|
|
|
+ if (File.Exists(PrintPath.Text))
|
|
|
{
|
|
|
- she.Pictures.Add(startRow + int.Parse(Y.Value.ToString()), int.Parse(X.Value.ToString()), PrintPath.Text);
|
|
|
+ if (startRow == 0)
|
|
|
+ {
|
|
|
+ she.Pictures.Add(startRow + int.Parse(Y.Value.ToString()), int.Parse(X.Value.ToString()), PrintPath.Text);
|
|
|
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ she.Pictures.Add(startRow - 4 + int.Parse(Y.Value.ToString()), int.Parse(X.Value.ToString()), PrintPath.Text);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
+ // 创建SheetRender对象
|
|
|
+ SheetRender sr = new SheetRender(she, options);
|
|
|
+
|
|
|
+ string imagename = $"{she.Name}_{imageIndex}.png";
|
|
|
+ // 获取渲染后的图像
|
|
|
+ Bitmap bitmap = sr.ToImage(0);
|
|
|
+ string imagePath = "";
|
|
|
+ // 如果有图片在当前行范围内,将它们添加到最终图像中
|
|
|
+ if (pictures.Count > 0)
|
|
|
{
|
|
|
- she.Pictures.Add(startRow - 4 + int.Parse(Y.Value.ToString()), int.Parse(X.Value.ToString()), PrintPath.Text);
|
|
|
-
|
|
|
+ using (Bitmap finalImage = new Bitmap(bitmap.Width, bitmap.Height))
|
|
|
+ using (Graphics g = Graphics.FromImage(finalImage))
|
|
|
+ {
|
|
|
+ // 绘制Excel内容
|
|
|
+ g.DrawImage(bitmap, 0, 0);
|
|
|
+
|
|
|
+ // 绘制原始Excel中的图片
|
|
|
+ int yOffset = bitmap.Height;
|
|
|
+ // 保存图像
|
|
|
+ imagePath = Path.Combine(path, $"{she.Name}_{imageIndex}.png");
|
|
|
+ finalImage.Save(imagePath, ImageFormat.Png);
|
|
|
+ Console.WriteLine($"Saved: {imagePath}");
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- // 创建SheetRender对象
|
|
|
- SheetRender sr = new SheetRender(she, options);
|
|
|
-
|
|
|
- string imagename = $"{she.Name}_{imageIndex}.png";
|
|
|
- // 获取渲染后的图像
|
|
|
- Bitmap bitmap = sr.ToImage(0);
|
|
|
- string imagePath = "";
|
|
|
- // 如果有图片在当前行范围内,将它们添加到最终图像中
|
|
|
- if (pictures.Count > 0)
|
|
|
- {
|
|
|
- using (Bitmap finalImage = new Bitmap(bitmap.Width, bitmap.Height))
|
|
|
- using (Graphics g = Graphics.FromImage(finalImage))
|
|
|
+ else
|
|
|
{
|
|
|
- // 绘制Excel内容
|
|
|
- g.DrawImage(bitmap, 0, 0);
|
|
|
-
|
|
|
- // 绘制原始Excel中的图片
|
|
|
- int yOffset = bitmap.Height;
|
|
|
- // 保存图像
|
|
|
+ // 如果没有图片,直接保存渲染的图像
|
|
|
imagePath = Path.Combine(path, $"{she.Name}_{imageIndex}.png");
|
|
|
- finalImage.Save(imagePath, ImageFormat.Png);
|
|
|
+ bitmap.Save(imagePath, ImageFormat.Png);
|
|
|
Console.WriteLine($"Saved: {imagePath}");
|
|
|
}
|
|
|
+ imageIndex++;
|
|
|
+ OperatResult.AppendText("解析图片【" + imagePath + ".jpg】" + "\n");
|
|
|
+ Dictionary<string, object> dic = new Dictionary<string, object>();
|
|
|
+ dic.Add("em_name", "管理员");
|
|
|
+ dic.Add("em_code", "ADMIN");
|
|
|
+ dic.Add("caller", "ProductSOP");
|
|
|
+ OperatResult.AppendText("上传文件【" + imagePath + ".jpg" + "】\n");
|
|
|
+ string fp_id = UploadFilesToRemoteUrl("https://mes.lihantech.cn/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + imagename, dic);
|
|
|
+ string ps_id = dh.getFieldDataByCondition("ProductSOP", "ps_id", "ps_prodcode='" + ps_prodcode.Text + "'").ToString();
|
|
|
+ dh.ExecuteSql("insert into ProductSOPdetail(psd_id,psd_psid,psd_attach) select ProductSOPdetail_seq.nextval,ps_id,'" + imagename + ";" + fp_id + "' from ProductSOP where ps_prodcode='" + ps_prodcode.Text + "'", "insert");
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- // 如果没有图片,直接保存渲染的图像
|
|
|
- imagePath = Path.Combine(path, $"{she.Name}_{imageIndex}.png");
|
|
|
- bitmap.Save(imagePath, ImageFormat.Png);
|
|
|
- Console.WriteLine($"Saved: {imagePath}");
|
|
|
- }
|
|
|
- imageIndex++;
|
|
|
- OperatResult.AppendText("解析图片【" + imagePath + ".jpg】" + "\n");
|
|
|
- Dictionary<string, object> dic = new Dictionary<string, object>();
|
|
|
- dic.Add("em_name", "管理员");
|
|
|
- dic.Add("em_code", "ADMIN");
|
|
|
- dic.Add("caller", "ProductSOP");
|
|
|
- OperatResult.AppendText("上传文件【" + imagePath + ".jpg" + "】\n");
|
|
|
- string fp_id = UploadFilesToRemoteUrl("https://mes.lihantech.cn/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + imagename, dic);
|
|
|
- string ps_id = dh.getFieldDataByCondition("ProductSOP", "ps_id", "ps_prodcode='" + ps_prodcode.Text + "'").ToString();
|
|
|
- dh.ExecuteSql("insert into ProductSOPdetail(psd_id,psd_psid,psd_attach) select ProductSOPdetail_seq.nextval,ps_id,'" + imagename + ";" + fp_id + "' from ProductSOP where ps_prodcode='" + ps_prodcode.Text + "'", "insert");
|
|
|
}
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ OperatResult.AppendText(ex.Message + ex.StackTrace);
|
|
|
+ }
|
|
|
+ filename.Add(she.Name + ".jpg");
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (PDF.Checked)
|
|
|
+ {
|
|
|
+ ps_prodcode.Text = FilePath.Text.Substring(FilePath.Text.LastIndexOf(@"\") + 1).Replace(".pdf","");
|
|
|
+ pr_code_Leave(new object(), new EventArgs());
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select * from productsop where ps_prodcode='" + ps_prodcode.Text + "' ", "select");
|
|
|
+ if (dt.Rows.Count == 0)
|
|
|
+ {
|
|
|
+ string code = LogicHandler.GetPiInoutCode("ProductSOP", "1");
|
|
|
+ ps_code.Text = code;
|
|
|
+ if (VaildDate.Checked)
|
|
|
{
|
|
|
- OperatResult.AppendText(ex.Message + ex.StackTrace);
|
|
|
+ dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman,ps_status,ps_statuscode,ps_vailddate)values(productsop_seq.nextval,'" + code + "','" + ps_prodcode.Text + "',sysdate,'" + User.UserName + "','在录入','ENTERING',to_date('" + DateCode.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd'))", "insert");
|
|
|
}
|
|
|
- filename.Add(she.Name + ".jpg");
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman,ps_status,ps_statuscode)values(productsop_seq.nextval,'" + code + "','" + ps_prodcode.Text + "',sysdate,'" + User.UserName + "','在录入','ENTERING')", "insert");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string psid = dt.Rows[0]["ps_id"].ToString();
|
|
|
+ dh.ExecuteSql("delete from ProductSOPdetail where psd_psid='" + psid + "'", "delete");
|
|
|
+ ps_prodcode.Text = dt.Rows[0]["ps_prodcode"].ToString();
|
|
|
+ }
|
|
|
+ if (VaildDate.Checked)
|
|
|
+ {
|
|
|
+ dh.ExecuteSql("update ProductSOP set ps_attachsop='',ps_inman='" + User.UserName + "',ps_vailddate=to_date('" + DateCode.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd') where ps_prodcode='" + ps_prodcode.Text + "'", "update");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dh.ExecuteSql("update ProductSOP set ps_attachsop='',ps_inman='" + User.UserName + "' where ps_prodcode='" + ps_prodcode.Text + "'", "update");
|
|
|
}
|
|
|
+ Dictionary<string, object> dic = new Dictionary<string, object>();
|
|
|
+ dic.Add("em_name", "管理员");
|
|
|
+ dic.Add("em_code", "ADMIN");
|
|
|
+ dic.Add("caller", "ProductSOP");
|
|
|
+ OperatResult.AppendText("上传文件【" + ps_prodcode.Text + "" + "】\n");
|
|
|
+ string fp_id = UploadFilesToRemoteUrl("https://mes.lihantech.cn/mes/MEScommon/uploadFiles.action?_noc=1", FilePath.Text, dic);
|
|
|
+ string ps_id = dh.getFieldDataByCondition("ProductSOP", "ps_id", "ps_prodcode='" + ps_prodcode.Text + "'").ToString();
|
|
|
+ dh.ExecuteSql("insert into ProductSOPdetail(psd_id,psd_psid,psd_attach) select ProductSOPdetail_seq.nextval,ps_id,'" + ps_prodcode.Text + ";" + fp_id + "' from ProductSOP where ps_prodcode='" + ps_prodcode.Text + "'", "insert");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -216,6 +260,7 @@ namespace UAS_MES_NEW.Query
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;
|
|
|
ServicePointManager.DefaultConnectionLimit = 50;
|
|
|
|
|
|
string boundary = DateTime.Now.Ticks.ToString("x");
|
|
|
@@ -303,7 +348,7 @@ namespace UAS_MES_NEW.Query
|
|
|
|
|
|
private void ChooseFile_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- ChoosePath.Filter = "(*.xls)|*.xls|(*.xlsx)|*.xlsx";
|
|
|
+ ChoosePath.Filter = "(*.xlsx)|*.xlsx|(*.xls)|*.xls|(*.pdf)|*.pdf";
|
|
|
DialogResult result = ChoosePath.ShowDialog();
|
|
|
if (result == DialogResult.OK)
|
|
|
{
|