|
|
@@ -237,7 +237,7 @@ namespace UAS_MES_NEW.Make
|
|
|
string[] txtFiles = Directory.GetFiles(txtPath.Text, $"*.{currFileType}");
|
|
|
if (txtFiles.Length == 0)
|
|
|
{
|
|
|
- LogMessage($"当前{txtPath.Text},没有{equiType}设备{currFileType.ToUpper()}文件");
|
|
|
+ LogMessage($"当前{txtPath.Text},没有{equiType}设备输出的{currFileType.ToLower()}文件");
|
|
|
return;
|
|
|
}
|
|
|
RefreshFileList();
|
|
|
@@ -312,14 +312,16 @@ namespace UAS_MES_NEW.Make
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
string currentDate = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
+ string currentDate1 = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
XmlWriterSettings settings = new XmlWriterSettings
|
|
|
{
|
|
|
- Indent = true,
|
|
|
- Encoding = System.Text.Encoding.UTF8
|
|
|
+ Indent = true
|
|
|
+ //,Encoding = System.Text.Encoding.UTF8
|
|
|
};
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
{
|
|
|
- var hasFileAry = Directory.GetFiles(outXmlFilePath, $"*.{currFileType}");
|
|
|
+ #region
|
|
|
+ /*var hasFileAry = Directory.GetFiles(outXmlFilePath, $"*.{currFileType}");
|
|
|
string xmlName;
|
|
|
if (hasFileAry.Length > 0)
|
|
|
{
|
|
|
@@ -329,12 +331,14 @@ namespace UAS_MES_NEW.Make
|
|
|
|
|
|
string seqNumStr = lastFile.Substring(lastFile.Length - 7, 3);
|
|
|
string fileSeqNum = (int.Parse(seqNumStr) + 1).ToString().PadLeft(seqNumStr.Length, '0'); ;
|
|
|
- xmlName = $"1.08_{currentDate}_{currentDate}{fileSeqNum}.xml";
|
|
|
+ xmlName = $"1.08_{currentDate}_{currentDate}{fileSeqNum}__RequestTotalProduction.xml";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- xmlName = $"1.08_{currentDate}_{currentDate}001.xml";
|
|
|
- }
|
|
|
+ xmlName = $"1.08_{currentDate}_{currentDate}001__RequestTotalProduction.xml";
|
|
|
+ }*/
|
|
|
+ #endregion
|
|
|
+ string xmlName = $"1.08__{currentDate1}T101505_{currentDate}001__RequestTotalProduction.xml";
|
|
|
string fullPath = Path.Combine(outXmlFilePath, xmlName);
|
|
|
|
|
|
using (XmlWriter writer = XmlWriter.Create(fullPath, settings))
|
|
|
@@ -345,20 +349,16 @@ namespace UAS_MES_NEW.Make
|
|
|
writer.WriteEndElement();
|
|
|
writer.WriteEndDocument();
|
|
|
}
|
|
|
- if (File.Exists(fullPath))
|
|
|
- {
|
|
|
- File.ReadAllText(fullPath);
|
|
|
- }
|
|
|
|
|
|
sql.Clear();
|
|
|
- sql.Append($"UPDATE devicedata SET dd_status = -1 WHERE dd_name = '{dr["dd_name"].ToString()}'");
|
|
|
+ sql.Append($"UPDATE devicedata SET dd_status = -1 WHERE dd_name = '{dr["dd_name"].ToString()}' and dd_status = 0");
|
|
|
dh.ExecuteSql(sql.GetString(), "update");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- MessageBox.Show(this.ParentForm, ex.Message, "警告");
|
|
|
+ LogMessage($"写入指令文件异常: {ex.Message}");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -406,6 +406,12 @@ namespace UAS_MES_NEW.Make
|
|
|
LogMessage($"文件不存在: {file}");
|
|
|
}
|
|
|
|
|
|
+ string outFileMsg = CheckFileAccess(file);
|
|
|
+ if (outFileMsg != "OK")
|
|
|
+ {
|
|
|
+ LogMessage(outFileMsg);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
if (Device.SelectedIndex == 0) // 劲拓SPI
|
|
|
{
|
|
|
@@ -428,10 +434,12 @@ namespace UAS_MES_NEW.Make
|
|
|
LogMessage($"文件: {file},开始上传");
|
|
|
if (UploadFileToFtp(file))
|
|
|
{
|
|
|
+ /*dh.ExecuteSql($@"insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class,std_testresult)
|
|
|
+ select STEPTESTDETAIL_seq.nextval,'{SN}','{ma_code.Text}',sysdate,'思泰克SPI',
|
|
|
+ 'http://112.48.67.154:8088/ftp/mes/TestData/{DateTime.Now.ToString("yyyyMMdd")}/{Path.GetFileName(file)}.xml' from dual", "insert");*/
|
|
|
dh.ExecuteSql($@"insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class,std_testresult)
|
|
|
select STEPTESTDETAIL_seq.nextval,'{SN}','{ma_code.Text}',sysdate,'思泰克SPI',
|
|
|
- 'http://112.48.67.154:8088/ftp/mes/TestData/{DateTime.Now.ToString("yyyyMMdd")}/{Path.GetFileName(file)}.xml' from dual", "insert");
|
|
|
-
|
|
|
+ 'http://192.168.1.92:8088/ftp/mes/TestData/{DateTime.Now.ToString("yyyyMMdd")}/{Path.GetFileName(file)}.xml' from dual", "insert");
|
|
|
string xmlContent = File.ReadAllText(file);
|
|
|
if (ConsoleLog(xmlContent, file))
|
|
|
{
|
|
|
@@ -698,13 +706,13 @@ namespace UAS_MES_NEW.Make
|
|
|
{
|
|
|
ps_id = dh.getFieldDataByCondition("productsmt", "ps_id", "ps_prodcode='" + Part_ + "'").ToString();
|
|
|
}
|
|
|
- if (dh.getRowCount("productsmtlocation", "PSL_PSID=" + ps_id) > 0)
|
|
|
+ if (dh.getRowCount("productsmtlocation", "PSL_PSID='" + ps_id +"'") > 0)
|
|
|
{
|
|
|
- dh.ExecuteSql("delete from productsmtlocation where PSL_PSID" + ps_id, "delete");
|
|
|
+ dh.ExecuteSql("delete from productsmtlocation where PSL_PSID = '" + ps_id +"'", "delete");
|
|
|
}
|
|
|
sql.Clear();
|
|
|
sql.Append("insert into productsmtlocation(PSL_ID, PSL_PSID, PSL_DETNO, PSL_PRODCODE, PSL_REPCODE, PSL_LOCATION, PSL_BASEQTY, PSL_TABLE)" +
|
|
|
- "select productsmtlocation_seq.nextval," + ps_id + ",:letArr, :ReelNo,:ReelNo,:Station,BD_BASEQTY,'A' from bom@ERP " +
|
|
|
+ "select productsmtlocation_seq.nextval,'" + ps_id + "',:letArr, :ReelNo,:ReelNo,:Station,BD_BASEQTY,'A' from bom@ERP " +
|
|
|
"left join bomdetail@ERP on bo_id=bd_bomid where bo_mothercode='" + Part_ + "' and BD_SONCODE=:ReelNo");
|
|
|
dh.BatchInsert(sql.GetString(), new string[] { "letArr", "ReelNo", "ReelNo", "Station", "ReelNo" },
|
|
|
letNo.ToArray(), ReelNo.ToArray(), ReelNo.ToArray(), Station.ToArray(), ReelNo.ToArray());
|
|
|
@@ -727,7 +735,8 @@ namespace UAS_MES_NEW.Make
|
|
|
|
|
|
public bool UploadFileToFtp(string localFilePath)
|
|
|
{
|
|
|
- string ftpServer = "ftp://10.8.0.208:21/mes/TestData/";
|
|
|
+ /*string ftpServer = "ftp://10.8.0.208:21/mes/TestData/";*/
|
|
|
+ string ftpServer = "ftp://192.168.1.92:21/mes/TestData/";
|
|
|
string username = "vsftpd";
|
|
|
string password = "vsftpd3cd79018fl";
|
|
|
|
|
|
@@ -802,6 +811,7 @@ namespace UAS_MES_NEW.Make
|
|
|
|
|
|
using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
|
|
|
{
|
|
|
+ response.Close();
|
|
|
return "OK,目录创建成功: " + response.StatusDescription;
|
|
|
}
|
|
|
}
|
|
|
@@ -847,9 +857,9 @@ namespace UAS_MES_NEW.Make
|
|
|
sql.Clear();
|
|
|
sql.Append($"SELECT a.li_code,b.dl_macode FROM line_ipaoi a, deviceline b WHERE a.ipaddress = '{currItem[2]}' AND a.li_code = b.dl_linecode");
|
|
|
dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
- if (dt.Rows.Count > 0)
|
|
|
+ if (dt.Rows.Count > 0 && !String.IsNullOrEmpty(dt.Rows[0]["dl_macode"].ToString()))
|
|
|
{
|
|
|
- wo = dt.Rows[0]["dd_name"].ToString();
|
|
|
+ wo = dt.Rows[0]["dl_macode"].ToString();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -917,14 +927,7 @@ namespace UAS_MES_NEW.Make
|
|
|
|
|
|
param.Add(item.SN);
|
|
|
param.Add(item.work_order);
|
|
|
- if (item.Result == "PASS")
|
|
|
- {
|
|
|
- param.Add(item.Result);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- param.Add(item.Result);
|
|
|
- }
|
|
|
+ param.Add(item.Result == "PASS" ? "OK" :"NG");
|
|
|
param.Add(equiType);
|
|
|
param.Add(item.Details);
|
|
|
param.Add(User.UserCode);
|
|
|
@@ -1130,6 +1133,7 @@ namespace UAS_MES_NEW.Make
|
|
|
|
|
|
return dataList;
|
|
|
}
|
|
|
+
|
|
|
private SpiData MapToSpiData(string fileName, string[] headers, string[] values,string others,int num)
|
|
|
{
|
|
|
return new SpiData
|
|
|
@@ -1230,6 +1234,30 @@ namespace UAS_MES_NEW.Make
|
|
|
return values[index];
|
|
|
}
|
|
|
|
|
|
+ public string CheckFileAccess(string filePath)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ using (FileStream fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.None))
|
|
|
+ {
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (IOException ex)
|
|
|
+ {
|
|
|
+ return "文件被占用: " + ex.Message;
|
|
|
+ }
|
|
|
+ catch (UnauthorizedAccessException ex)
|
|
|
+ {
|
|
|
+ return "权限不足,无法访问文件: " + ex.Message;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return ex.Message;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private class Log
|
|
|
{
|
|
|
public string work_order { get; set; }
|