Browse Source

修改导出特殊SN

callm 2 weeks ago
parent
commit
1348536815

+ 21 - 5
UAS_MES_LGDZ/DataOperate/ExcelHandler.cs

@@ -79,11 +79,13 @@ namespace UAS_MES_NEW.DataOperate
             //表格数据游标
             int DataRowCount = 8;
             string sumqty = "";
+            int endrow = 0;
             for (int i = 0; i < 10; i++)
             {
                 if (sumqty == "")
                     sumqty = DataTable.Rows[i]["sumqty"].ToString();
             }
+            List<int> id=new List<int>();
             for (int i = 0; i < DataTable.Rows.Count; i++)
             {
                 if (DataTable.Rows[i]["STF_MACHINE"].ToString() != "" && DataTable.Rows[i]["STF_MACHINE"].ToString() != "***" && i != DataTable.Rows.Count - 1)
@@ -253,16 +255,30 @@ namespace UAS_MES_NEW.DataOperate
                         row.CreateCell(5);
                         row.CreateCell(6);
                         row.CreateCell(7);
+                        Console.WriteLine(DataTable.Rows[i]["STF_MODEL"].ToString() + " " + DataTable.Rows[i]["STF_FEEDER"].ToString() + " " + DataTable.Rows[i]["STF_FEEDERNO"].ToString());
+                        for (int k = i+1; k < DataTable.Rows.Count; k++)
+                        {
+                            if (k < DataTable.Rows.Count && DataTable.Rows[k]["STF_MODEL"].ToString() == "" &&
+                            DataTable.Rows[k]["STF_FEEDER"].ToString() == "" &&
+                            DataTable.Rows[k]["STF_FEEDERNO"].ToString() != "" && !id.Contains(k))
+                            {
+                                endrow++;
+                                id.Add(k);
+                            }
+                            else
+                            {
+                                break;
+                            }
+                        }
                         //位置编号
-                        if (i + 1 < DataTable.Rows.Count && DataTable.Rows[i + 1]["STF_MODEL"].ToString() == "" &&
-                            DataTable.Rows[i + 1]["STF_FEEDER"].ToString() == "" &&
-                            DataTable.Rows[i + 1]["STF_FEEDERNO"].ToString() != "")
+                        if (i + endrow < DataTable.Rows.Count && DataTable.Rows[i]["STF_MODEL"].ToString() != "")
                         {
-                            CellRangeAddress cellRangeAddress = new CellRangeAddress(DataRowCount, DataRowCount + 1, 0, 0);
+                            CellRangeAddress cellRangeAddress = new CellRangeAddress(DataRowCount, DataRowCount + endrow, 0, 0);
                             sheet.AddMergedRegion(cellRangeAddress);
                             //飞达规格
-                            CellRangeAddress cellRangeAddress1 = new CellRangeAddress(DataRowCount, DataRowCount + 1, 1, 1);
+                            CellRangeAddress cellRangeAddress1 = new CellRangeAddress(DataRowCount, DataRowCount + endrow, 1, 1);
                             sheet.AddMergedRegion(cellRangeAddress1);
+                            endrow = 0;
                         }
                         row.Cells[0].SetCellValue(DataTable.Rows[i]["STF_MODEL"].ToString());
                         row.Cells[0].CellStyle = style;

+ 12 - 2
UAS_MES_LGDZ/FunctionCode/Query/Query_SpecialReport.cs

@@ -203,8 +203,18 @@ namespace UAS_MES_NEW.Query
                     new string[] { "STF_MODEL", "STF_FEEDER", "STF_FEEDERNO", "STF_LOCATION", "STF_MACHINE" }, STF_MODEL.ToArray(), STF_FEEDER.ToArray(), STF_FEEDERNO.ToArray(), STF_LOCATION.ToArray(), STF_MACHINE.ToArray());
                 dh.ExecuteSql("delete from SMTTRACEFILE where ( STF_MODEL is null and  STF_FEEDER is null and STF_FEEDERNO is null and STF_MACHINE is null ) or stf_model in ('料槽','数量','印刷板') or STF_MACHINE in('贴片生产线:','设置:','***') ", "delete");
                 dataGridView1.DataSource = dt;
-                DataTable dt1 = (DataTable)dh.ExecuteSql("select STF_ID, STF_MODEL,STF_MACHINE, STF_FEEDER, STF_FEEDERNO, STF_LOCATION,replace(pr_orispeccode,' ','\n')pr_orispeccode,bo_mothercode,bd_baseqty,bd_soncode,bd_location, STF_CODE, STF_INDATE, STF_INMAN,sumqty from SMTTRACEFILE left join (select bo_mothercode,bd_baseqty,bd_soncode,replace(bd_location,',',' ')bd_location from BOMDetail LEFT JOIN bom on bd_bomid=bo_id left join Product ON bd_soncode=pr_code where bo_mothercode='" + pr_code.Text + "' ) on bo_mothercode=stf_prodcode and bd_soncode=STF_LOCATION left join product on pr_code=STF_LOCATION " +
-                    "left join (select sum(bd_baseqty)-1 sumqty,bo_mothercode mothercode from BOMDetail LEFT JOIN bom on bd_bomid=bo_id left join Product ON bd_soncode=pr_code where bo_mothercode='" + pr_code.Text + "' group by bo_mothercode)on mothercode=bo_mothercode where stf_prodcode='" + pr_code.Text + "' order by stf_id", "select");
+                //DataTable dt1 = (DataTable)dh.ExecuteSql("select STF_ID, STF_MODEL,STF_MACHINE, STF_FEEDER, STF_FEEDERNO, STF_LOCATION,replace(pr_orispeccode,' ','\n')pr_orispeccode,bo_mothercode,bd_baseqty,bd_soncode,bd_location, STF_CODE, STF_INDATE, STF_INMAN,sumqty from SMTTRACEFILE left join (select bo_mothercode,bd_baseqty,bd_soncode,replace(bd_location,',',' ')bd_location from BOMDetail LEFT JOIN bom on bd_bomid=bo_id left join Product ON bd_soncode=pr_code where bo_mothercode='" + pr_code.Text + "' ) on bo_mothercode=stf_prodcode and bd_soncode=STF_LOCATION left join product on pr_code=STF_LOCATION " +
+                //    "left join (select sum(bd_baseqty)-1 sumqty,bo_mothercode mothercode from BOMDetail LEFT JOIN bom on bd_bomid=bo_id left join Product ON bd_soncode=pr_code where bo_mothercode='" + pr_code.Text + "' group by bo_mothercode)on mothercode=bo_mothercode where stf_prodcode='" + pr_code.Text + "' order by stf_id", "select");
+                DataTable dt1 = (DataTable)dh.ExecuteSql("select * from (select STF_ID, STF_MODEL,STF_MACHINE, STF_FEEDER, STF_FEEDERNO, STF_LOCATION,replace(pr_orispeccode,' ','\n')pr_orispeccode, bo_mothercode,to_char(bd_baseqty)bd_baseqty,bd_soncode," +
+                    "bd_location, STF_CODE, STF_INDATE, STF_INMAN,sumqty from SMTTRACEFILE  left join (select bo_mothercode,bd_baseqty,bd_soncode,replace(bd_location,',',' ')bd_location from BOMDetail  " +
+                    "LEFT JOIN bom on bd_bomid=bo_id left join Product ON bd_soncode=pr_code where bo_mothercode='"+pr_code.Text+"') on bo_mothercode=stf_prodcode and bd_soncode=STF_LOCATION left join product on " +
+                    "pr_code=STF_LOCATION  left join (select sum(bd_baseqty)-1 sumqty,bo_mothercode mothercode from BOMDetail  LEFT JOIN bom on bd_bomid=bo_id left join Product ON bd_soncode=pr_code where " +
+                    "bo_mothercode='"+pr_code.Text+"'  group by bo_mothercode)on mothercode=bo_mothercode where stf_prodcode='"+pr_code.Text+"'  union  select max(stf_id),'',max(STF_MACHINE),''," +
+                    "'代',max(pr_code),replace(max(pr_orispeccode),' ','\n')pr_orispeccode, max(bo_mothercode),'',pr_code,'',max(STF_CODE),max(STF_INDATE),max(stf_inman),0  from " +
+                    " SMTTRACEFILE left join (select bd_repcode,bo_mothercode,bd_baseqty,bd_soncode,replace(bd_location,',',' ')bd_location from BOMDetail LEFT JOIN bom on bd_bomid=bo_id where " +
+                    "bo_mothercode='"+pr_code.Text+"' and bd_repcode is not null) on bo_mothercode=stf_prodcode  and bd_soncode=STF_LOCATION left join product  on instr(bd_repcode,pr_code)>0 where " +
+                    "stf_prodcode='"+pr_code.Text+ "' and bd_repcode is not null group by stf_id,bd_repcode,pr_code order by stf_id) ", "select");
+                
                 ExportFileDialog.Description = "选择导出的路径";
                 DialogResult result1 = ExportFileDialog.ShowDialog();
                 if (result1 == DialogResult.OK)