Browse Source

整合安勤調整的程式

master
Gitea 7 months ago
parent
commit
fba2d43dce
  1. 15
      AMESCoreStudio.Web/AppSetting.cs
  2. 115
      AMESCoreStudio.Web/Controllers/FQCController.cs
  3. 79
      AMESCoreStudio.Web/Controllers/JIGController.cs
  4. 88
      AMESCoreStudio.Web/Controllers/LABController.cs
  5. 193
      AMESCoreStudio.Web/Controllers/PCSController.cs
  6. 605
      AMESCoreStudio.Web/Controllers/REPController.cs
  7. 181
      AMESCoreStudio.Web/Controllers/SPCController.cs
  8. 62
      AMESCoreStudio.Web/Startup.cs
  9. 34
      AMESCoreStudio.Web/Views/FQC/FQC007D.cshtml
  10. 10
      AMESCoreStudio.Web/Views/FQC/FQC008.cshtml
  11. 22
      AMESCoreStudio.Web/Views/JIG/JIG004R.cshtml
  12. 36
      AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml
  13. 68
      AMESCoreStudio.Web/Views/PCS/PCS003.cshtml
  14. 37
      AMESCoreStudio.Web/Views/PCS/PCS005.cshtml
  15. 6
      AMESCoreStudio.Web/Views/PCS/PCS009R.cshtml
  16. 68
      AMESCoreStudio.Web/Views/PCS/PCS021.cshtml
  17. 144
      AMESCoreStudio.Web/Views/PCS/PCS041C.cshtml
  18. 8
      AMESCoreStudio.Web/Views/PTD/PTD002.cshtml
  19. 4
      AMESCoreStudio.Web/Views/PTD/PTD002Old.cshtml
  20. 6
      AMESCoreStudio.Web/Views/PTD/PTD006.cshtml
  21. 4
      AMESCoreStudio.Web/Views/PTD/PTD006Old.cshtml
  22. 8
      AMESCoreStudio.Web/Views/QRS/QRS014.cshtml
  23. 7
      AMESCoreStudio.Web/Views/QRS/QRS028A.cshtml
  24. 155
      AMESCoreStudio.Web/Views/REP/REP001R.cshtml
  25. 6
      AMESCoreStudio.Web/Views/RPT/RPT002.cshtml
  26. 36
      AMESCoreStudio.Web/Views/SPC/SPC004.cshtml
  27. 40
      AMESCoreStudio.Web/Views/SPC/SPC005R.cshtml
  28. 12
      AMESCoreStudio.Web/Views/SYS/SYS008.cshtml
  29. 5
      AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs
  30. 3
      AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs
  31. 10
      AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterController.cs
  32. 400
      AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs
  33. 38
      AMESCoreStudio.WebApi/Controllers/PTD/PTDController.cs
  34. 3
      AMESCoreStudio.WebApi/Controllers/SYS/UserInfoesController.cs
  35. 4
      AMESCoreStudio.WebApi/DTO/AMES/QRS016Detail.cs
  36. 6
      AMESCoreStudio.WebApi/DTO/AMES/RPT002VIiewDto.cs
  37. 11
      AMESCoreStudio.WebApi/DTO/AMES/WipQueryDto.cs
  38. 2
      AMESCoreStudio.WebApi/Models/AMES/BarcodeInfo.cs
  39. 2
      AMESCoreStudio.WebApi/Models/AMES/FqcInhouseMaster.cs
  40. 24
      AMESCoreStudio.WebApi/Models/AMES/PTD101AMESModel.cs
  41. 20
      AMESCoreStudio.WebApi/Models/AMES/WipInfo.cs
  42. 8
      AMESCoreStudio.WebApi/Models/SYS/UserInfo.cs

15
AMESCoreStudio.Web/AppSetting.cs

@ -8,18 +8,23 @@ namespace AMESCoreStudio.Web
public class AppSetting public class AppSetting
{ {
/// <summary> /// <summary>
/// MVC网站访问IP端口 /// MVC網站訪問地址
/// </summary> /// </summary>
public string Urls { get; set; } public string Urls { get; set; }
/// <summary> /// <summary>
/// WebApi访问地址 /// WebApi網站訪問地址
/// </summary> /// </summary>
public string ApiUrl { get; set; } public string ApiUrl { get; set; }
//Yiru Add ------------------------------------------------------------------- /// <summary>
/// 倉庫位置
/// </summary>
public string Location { get; set; } public string Location { get; set; }
//2023-02-12 add /// <summary>
///
/// </summary>
public string PTD101Key { get; set; } public string PTD101Key { get; set; }
/// <summary> /// <summary>
@ -27,8 +32,6 @@ namespace AMESCoreStudio.Web
/// </summary> /// </summary>
public int FQC014FileSize { get; set; } public int FQC014FileSize { get; set; }
//Yiru End -------------------------------------------------------------------
public static AppSetting Setting { get; set; } = new AppSetting(); public static AppSetting Setting { get; set; } = new AppSetting();
} }
} }

115
AMESCoreStudio.Web/Controllers/FQCController.cs

@ -3,8 +3,6 @@ using AMESCoreStudio.Web.Models;
using AMESCoreStudio.WebApi.DTO.AMES; using AMESCoreStudio.WebApi.DTO.AMES;
using AMESCoreStudio.WebApi.Enum; using AMESCoreStudio.WebApi.Enum;
using AMESCoreStudio.WebApi.Models.AMES; using AMESCoreStudio.WebApi.Models.AMES;
using AMESCoreStudio.WebApi.Models.BAS;
//using AspNetCore.Reporting;
using Microsoft.Reporting.NETCore; using Microsoft.Reporting.NETCore;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
@ -19,6 +17,8 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using System.Net.Http;
namespace AMESCoreStudio.Web.Controllers namespace AMESCoreStudio.Web.Controllers
@ -28,15 +28,18 @@ namespace AMESCoreStudio.Web.Controllers
/// </summary> /// </summary>
public class FQCController : Controller public class FQCController : Controller
{ {
private readonly ILogger<PCSController> _logger;
public readonly IFQC _fqcApi; public readonly IFQC _fqcApi;
private readonly IWebHostEnvironment _env;
public readonly IPCS _pcsApi; public readonly IPCS _pcsApi;
public readonly IBAS _basApi; public readonly IBAS _basApi;
public readonly IBLL _bllApi; public readonly IBLL _bllApi;
public readonly ISYS _sysApi; public readonly ISYS _sysApi;
private readonly ILogger<PCSController> _logger;
private readonly IWebHostEnvironment _env;
private readonly IConfiguration _config;
public readonly IESUN _esuncApi; public readonly IESUN _esuncApi;
public FQCController(ILogger<PCSController> logger, IFQC fqcApi, IWebHostEnvironment env, IPCS pcsApi, IBLL bllApi, IBAS basApi, ISYS sysApi, IESUN esuncApi)
public FQCController(ILogger<PCSController> logger, IFQC fqcApi, IWebHostEnvironment env, IPCS pcsApi,
IBLL bllApi, IBAS basApi, ISYS sysApi, IESUN esuncApi, IConfiguration config)
{ {
_logger = logger; _logger = logger;
_fqcApi = fqcApi; _fqcApi = fqcApi;
@ -45,6 +48,7 @@ namespace AMESCoreStudio.Web.Controllers
_bllApi = bllApi; _bllApi = bllApi;
_basApi = basApi; _basApi = basApi;
_sysApi = sysApi; _sysApi = sysApi;
_config = config;
_esuncApi = esuncApi; _esuncApi = esuncApi;
} }
@ -1481,6 +1485,8 @@ namespace AMESCoreStudio.Web.Controllers
private async Task CheckFQCToMail(string Material, string Result, string inhouseNo, int seqID) private async Task CheckFQCToMail(string Material, string Result, string inhouseNo, int seqID)
{ {
var result = await _fqcApi.GetFqcNoticeMailQuery(material: Material, fqcResult: Result, status: "Y"); var result = await _fqcApi.GetFqcNoticeMailQuery(material: Material, fqcResult: Result, status: "Y");
var UploadFolderFQCPath = _config["ImagePath:UploadFolderFQCPath"];
if (result.Data.Count() != 0) if (result.Data.Count() != 0)
{ {
var MailGroup = result.Data.Select(s => s.MailGroup).ToArray(); var MailGroup = result.Data.Select(s => s.MailGroup).ToArray();
@ -1494,8 +1500,7 @@ namespace AMESCoreStudio.Web.Controllers
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱 //為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
//NewName = Path.GetRandomFileName() + fileExt; //NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名 //指定要寫入的路徑、檔名和副檔名
FilePath = $@"{_env.WebRootPath}\UploadFolder\FQC\Temp"; var path = UploadFolderFQCPath + FileName;
var path = $@"{FilePath}\{FileName}";
if (!Directory.Exists(FilePath)) if (!Directory.Exists(FilePath))
{ {
@ -1539,6 +1544,7 @@ namespace AMESCoreStudio.Web.Controllers
var fqcResult = await _fqcApi.GetFqcResultMaster(fqc); var fqcResult = await _fqcApi.GetFqcResultMaster(fqc);
if (fqcResult != null) if (fqcResult != null)
fqcDto.StatusName = fqcResult.QaResult; fqcDto.StatusName = fqcResult.QaResult;
ViewBag.FileUploadUrl = _config["ImagePath:FileUploadUrl"];
return View(fqcDto); return View(fqcDto);
} }
@ -1546,33 +1552,34 @@ namespace AMESCoreStudio.Web.Controllers
public async Task<IActionResult> FQC007DAsync(FqcDto model, string Result, IFormFile formFile) public async Task<IActionResult> FQC007DAsync(FqcDto model, string Result, IFormFile formFile)
{ {
FqcResultMaster fqcResultMaster = await _fqcApi.GetFqcResultMaster(model.FqcID); FqcResultMaster fqcResultMaster = await _fqcApi.GetFqcResultMaster(model.FqcID);
var rootFolderPath = _config["ImagePath:RootPath"];
var uploadFolderFQCPath = _config["ImagePath:UploadFolderFQCPath"];
if (fqcResultMaster == null) if (fqcResultMaster == null)
{ {
ModelState.AddModelError("error", "找不到FQC開單紀錄"); ModelState.AddModelError("error", "找不到FQC開單紀錄");
return View("FQC007D", model); return View("FQC007D", model);
} }
if (formFile != null) if (formFile != null && formFile.Length > 0)
{
if (formFile.Length > 0)
{ {
// 檔案上傳
string FileName = string.Empty;
string NewName = string.Empty;
string FilePath = string.Empty;
//取得使用者上傳檔案的原始檔名 //取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(formFile.FileName); var imageName = Path.GetFileName(formFile.FileName);
//取原始檔名中的副檔名
//var fileExt = Path.GetExtension(FileName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
//NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名 //指定要寫入的路徑、檔名和副檔名
FilePath = $@"{_env.WebRootPath}\UploadFolder\FQC\{fqcResultMaster.InhouseNo}-{fqcResultMaster.SeqID}"; var rootPath = $@"{rootFolderPath}\{uploadFolderFQCPath}\{fqcResultMaster.InhouseNo}-{fqcResultMaster.SeqID}";
var path = $@"{FilePath}\{FileName}"; var filePath = $@"\{uploadFolderFQCPath}\{fqcResultMaster.InhouseNo}-{fqcResultMaster.SeqID}\";
var path = $@"{rootPath}\{imageName}";
if (!System.IO.Directory.Exists(FilePath)) if (!System.IO.Directory.Exists(rootPath))
{
try
{ {
System.IO.Directory.CreateDirectory(FilePath); System.IO.Directory.CreateDirectory(rootPath);
}
catch (Exception ex)
{
ModelState.AddModelError("error", $"無法建立路徑: {rootPath}, 錯誤: {ex.Message}");
return BadRequest(ModelState);
}
} }
using (var stream = new FileStream(path, FileMode.Create)) using (var stream = new FileStream(path, FileMode.Create))
@ -1583,8 +1590,8 @@ namespace AMESCoreStudio.Web.Controllers
FqcResultMasterBlob fqcResultMasterBlob = new FqcResultMasterBlob() FqcResultMasterBlob fqcResultMasterBlob = new FqcResultMasterBlob()
{ {
FqcID = model.FqcID, FqcID = model.FqcID,
ImageName = FileName, ImageName = imageName,
Filepath = $@"\UploadFolder\FQC\{fqcResultMaster.InhouseNo}-{fqcResultMaster.SeqID}\", Filepath = filePath,
CreateUserID = GetLogInUserID(), CreateUserID = GetLogInUserID(),
UpdateUserID = GetLogInUserID() UpdateUserID = GetLogInUserID()
}; };
@ -1599,7 +1606,7 @@ namespace AMESCoreStudio.Web.Controllers
{ {
ModelState.AddModelError("error", "上傳失敗,錯誤訊息:" + result.Msg); ModelState.AddModelError("error", "上傳失敗,錯誤訊息:" + result.Msg);
} }
}
} }
else else
{ {
@ -1615,20 +1622,39 @@ namespace AMESCoreStudio.Web.Controllers
/// <param name="Path">路徑</param> /// <param name="Path">路徑</param>
/// <param name="FileName">檔名</param> /// <param name="FileName">檔名</param>
/// <returns></returns> /// <returns></returns>
public async Task<IActionResult> FileDownload(string Path, string FileName) public async Task<IActionResult> FileDownload(string fileUrl)
{ {
var path = $@"{_env.WebRootPath}\{Path}{FileName}"; fileUrl = fileUrl.Replace("\\", "/");
var memoryStream = new MemoryStream(); try
using (var stream = new FileStream(path, FileMode.Open)) {
if (string.IsNullOrEmpty(fileUrl))
{
return StatusCode(500, $"找不到檔案路徑: {fileUrl}");
}
// 使用 HttpClient 從遠端 URL 下載檔案
using (var httpClient = new HttpClient())
{
var response = await httpClient.GetAsync(fileUrl);
if (!response.IsSuccessStatusCode)
{
return StatusCode(500, $"使用 HttpClient 從遠端 URL 下載檔案錯誤");
}
var fileStream = await response.Content.ReadAsStreamAsync();
var fileName = Path.GetFileName(new Uri(fileUrl).LocalPath);
var contentType = response.Content.Headers.ContentType?.MediaType ?? "application/octet-stream";
return File(fileStream, contentType, fileName);
}
}
catch (Exception ex)
{ {
await stream.CopyToAsync(memoryStream); return StatusCode(500, $"下載檔案錯誤: {ex.Message}");
} }
memoryStream.Seek(0, SeekOrigin.Begin);
string contentType = await GetFileContentTypeAsync(FileName);
// 回傳檔案到 Client 需要附上 Content Type,否則瀏覽器會解析失敗。
return File(memoryStream, contentType, FileName);
} }
/// <summary> /// <summary>
/// 刪除工單檔案 /// 刪除工單檔案
/// </summary> /// </summary>
@ -2936,25 +2962,6 @@ namespace AMESCoreStudio.Web.Controllers
} }
/// <summary>
/// 檔案下載
/// </summary>
/// <param name="Path">路徑</param>
/// <param name="FileName">檔名</param>
/// <returns></returns>
public async Task<IActionResult> FileDownload_byPath(string Path, string FileName)
{
var path = $@"{Path}{FileName}";
var memoryStream = new MemoryStream();
using (var stream = new FileStream(path, FileMode.Open))
{
await stream.CopyToAsync(memoryStream);
}
memoryStream.Seek(0, SeekOrigin.Begin);
string contentType = await GetFileContentTypeAsync(FileName);
// 回傳檔案到 Client 需要附上 Content Type,否則瀏覽器會解析失敗。
return File(memoryStream, contentType, FileName);
}
#endregion #endregion
#endregion #endregion

79
AMESCoreStudio.Web/Controllers/JIGController.cs

@ -5,8 +5,10 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -24,8 +26,10 @@ namespace AMESCoreStudio.Web.Controllers
public readonly ISYS _sysApi; public readonly ISYS _sysApi;
public readonly IPPS _ppsApi; public readonly IPPS _ppsApi;
private readonly IWebHostEnvironment _env; private readonly IWebHostEnvironment _env;
private readonly IConfiguration _config;
public JIGController(ILogger<JIGController> logger, IJIG jigApi, IWHS whsApi, IBAS basApi, IPCS pcsApi, ISYS sysApi, IPPS ppsApi, IWebHostEnvironment env) public JIGController(ILogger<JIGController> logger, IJIG jigApi, IWHS whsApi, IBAS basApi, IPCS pcsApi, ISYS sysApi, IPPS ppsApi,
IWebHostEnvironment env, IConfiguration config)
{ {
_logger = logger; _logger = logger;
_jigApi = jigApi; _jigApi = jigApi;
@ -34,7 +38,10 @@ namespace AMESCoreStudio.Web.Controllers
_pcsApi = pcsApi; _pcsApi = pcsApi;
_sysApi = sysApi; _sysApi = sysApi;
_ppsApi = ppsApi; _ppsApi = ppsApi;
_config = config;
_env = env; _env = env;
} }
#region #region
@ -208,7 +215,7 @@ namespace AMESCoreStudio.Web.Controllers
return Json(new { data = "" }); return Json(new { data = "" });
else else
return Json(new { data = result.ItemNO}); return Json(new { data = result.ItemNO });
} }
//yiru add end //yiru add end
@ -736,9 +743,7 @@ namespace AMESCoreStudio.Web.Controllers
} }
else else
{ {
msg = result.Msg; msg = result.Msg;
} }
} }
if (msg == "") msg = "缺少必填資料"; if (msg == "") msg = "缺少必填資料";
@ -756,9 +761,14 @@ namespace AMESCoreStudio.Web.Controllers
public async Task<IActionResult> JIG004RSaveAsync(OutfitInfoBlob model, IFormFile formFile) public async Task<IActionResult> JIG004RSaveAsync(OutfitInfoBlob model, IFormFile formFile)
{ {
IResultModel result; IResultModel result;
//設備基本數據維護的圖片根目錄路徑
var rootFolderPath = _config["ImagePath:RootPath"];
//設備基本數據維護的圖片資料夾
var jigFilePathPath = _config["ImagePath:JigFilePath"];
var userID = ""; var userID = "";
HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
int user_id = 0; int user_id = 0;
HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
if (userID != null) if (userID != null)
{ {
if (int.Parse(userID.ToString()) >= 0) if (int.Parse(userID.ToString()) >= 0)
@ -770,70 +780,73 @@ namespace AMESCoreStudio.Web.Controllers
model.CreateDate = System.DateTime.Now; model.CreateDate = System.DateTime.Now;
model.UpdateUserID = user_id; model.UpdateUserID = user_id;
model.UpdateDate = System.DateTime.Now; model.UpdateDate = System.DateTime.Now;
string FileName = string.Empty;
string NewName = string.Empty;
string FilePath = string.Empty;
if (formFile != null && formFile.Length > 0)
if (formFile != null)
{
if (formFile.Length > 0)
{ {
//取得使用者上傳檔案的原始檔名 //取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(formFile.FileName); var imageName = Path.GetFileName(formFile.FileName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個名稱 設備代號-原檔名 //為避免使用者上傳的檔案名稱發生重複,重新給一個名稱 設備代號-原檔名
NewName = model.OutfitID + "-" + FileName;//Path.GetRandomFileName() + fileExt; var newName = model.OutfitID + "-" + imageName;
//指定要寫入的路徑、檔名和副檔名 //指定要寫入的路徑、檔名和副檔名
FilePath = $"\\JIGFile\\";//本機目錄 var rootPath = $@"{rootFolderPath}\{jigFilePathPath}";
using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create)) var filePath = $@"\{jigFilePathPath}\";
var path = $@"{rootPath}\{imageName}";
if (!System.IO.Directory.Exists(rootPath))
{
try
{
System.IO.Directory.CreateDirectory(rootPath);
}
catch (Exception ex)
{
ModelState.AddModelError("error", $"無法建立路徑: {rootPath}, 錯誤: {ex.Message}");
return BadRequest(ModelState); // 或適當的錯誤處理
}
}
using (var stream = new FileStream(path, FileMode.Create))
{ {
await formFile.CopyToAsync(stream); await formFile.CopyToAsync(stream);
} }
//var fileProvider = _fileServerProvider.GetProvider("/aa"); model.NewName = newName;
//var fileInfo = fileProvider.GetFileInfo(formFile.FileName); model.ImageName = imageName;
//fileInfo = fileProvider.GetFileInfo(formFile.FileName); model.FilePath = filePath;
////遠端目錄
//using (var stream = new FileStream(fileInfo.PhysicalPath, FileMode.Create))
//{
// await formFile.CopyToAsync(stream);
model.NewName = NewName;
model.ImageName = FileName;
model.FilePath = FilePath;// fileInfo.PhysicalPath;
var result1 = await _jigApi.GetOutfitInfoBlobByOutfitID(model.OutfitID); var result1 = await _jigApi.GetOutfitInfoBlobByOutfitID(model.OutfitID);
if (result1.Count > 0) if (result1.Count > 0)
{ {
result = await _jigApi.PutOutfitInfoBlob(model.OutfitID, JsonConvert.SerializeObject(model)); result = await _jigApi.PutOutfitInfoBlob(model.OutfitID, JsonConvert.SerializeObject(model));
string ExitingFile = Path.Combine(_env.WebRootPath + FilePath, result1.Select(s => s.NewName).FirstOrDefault()); string ExitingFile = Path.Combine(rootPath, result1.Select(s => s.NewName).FirstOrDefault());
System.IO.File.Delete(ExitingFile); System.IO.File.Delete(ExitingFile);
} }
else else
{
result = await _jigApi.PostOutfitInfoBlob(JsonConvert.SerializeObject(model)); result = await _jigApi.PostOutfitInfoBlob(JsonConvert.SerializeObject(model));
}
if (result.Success) if (result.Success)
{ {
//var _msg = "上傳成功!";
ViewBag.OutfitID = model.OutfitID; ViewBag.OutfitID = model.OutfitID;
ViewBag.FileUploadUrl = _config["ImagePath:FileUploadUrl"];
return View("JIG004R"); return View("JIG004R");
} }
else else
{ {
ModelState.AddModelError("error", result.Msg); ModelState.AddModelError("error", result.Msg);
} }
}
} }
else else
{ {
ModelState.AddModelError("error", "請選擇要上傳檔案"); ModelState.AddModelError("error", "請選擇要上傳檔案");
} }
ViewBag.OutfitID = model.OutfitID; ViewBag.OutfitID = model.OutfitID;
ViewBag.FileUploadUrl = _config["ImagePath:FileUploadUrl"];
return View("JIG004R"); return View("JIG004R");
} }

88
AMESCoreStudio.Web/Controllers/LABController.cs

@ -12,13 +12,11 @@ using AMESCoreStudio.CommonTools.Result;
using static AMESCoreStudio.Web.ViewModels.LAB.LAB003ViewModel; using static AMESCoreStudio.Web.ViewModels.LAB.LAB003ViewModel;
using AMESCoreStudio.WebApi.Models.AMES; using AMESCoreStudio.WebApi.Models.AMES;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;
using AMESCoreStudio.WebApi.DTO.AMES;
using AMESCoreStudio.Web.ViewModels.LAB; using AMESCoreStudio.Web.ViewModels.LAB;
using System.Dynamic;
using System.IO; using System.IO;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
namespace AMESCoreStudio.Web.Controllers namespace AMESCoreStudio.Web.Controllers
{ {
@ -28,15 +26,18 @@ namespace AMESCoreStudio.Web.Controllers
public readonly ILAB _labApi; public readonly ILAB _labApi;
public readonly IPCS _pcsApi; public readonly IPCS _pcsApi;
private readonly IWebHostEnvironment _env; private readonly IWebHostEnvironment _env;
private readonly IConfiguration _config;
public LABController(ILogger<LABController> logger, ILAB labApi, ISYS sysApi, IPCS pcsApi, IWebHostEnvironment env, IStringLocalizer<SharedResource> sharedLocalizer) public LABController(ILogger<LABController> logger, ILAB labApi, ISYS sysApi, IPCS pcsApi, IWebHostEnvironment env,
IStringLocalizer<SharedResource> sharedLocalizer)
{ {
_sysApi = sysApi; _sysApi = sysApi;
_labApi = labApi; _labApi = labApi;
_pcsApi = pcsApi; _pcsApi = pcsApi;
_env = env; _env = env;
_config = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build();
} }
private void GetFlagList() private void GetFlagList()
@ -147,9 +148,9 @@ namespace AMESCoreStudio.Web.Controllers
[ResponseCache(Duration = 0)] [ResponseCache(Duration = 0)]
[HttpGet] [HttpGet]
public async Task<IActionResult> GetLabParamsAsync(string status = "*" ,int page = 0, int limit = 10) public async Task<IActionResult> GetLabParamsAsync(string status = "*", int page = 0, int limit = 10)
{ {
var result = await _labApi.GetLabParamsByStatus(status,page, limit); var result = await _labApi.GetLabParamsByStatus(status, page, limit);
if (result.Data.Count() > 0) if (result.Data.Count() > 0)
{ {
@ -172,7 +173,7 @@ namespace AMESCoreStudio.Web.Controllers
/// <param name="page"></param> /// <param name="page"></param>
/// <param name="limit"></param> /// <param name="limit"></param>
/// <returns></returns> /// <returns></returns>
public async Task<IActionResult> LAB002Async(string LabelMatnr, int page = 0, int limit = 10) public IActionResult LAB002Async(string LabelMatnr, int page = 0, int limit = 10)
{ {
return View(); return View();
} }
@ -196,17 +197,17 @@ namespace AMESCoreStudio.Web.Controllers
if (System.IO.File.Exists(ImgFile)) if (System.IO.File.Exists(ImgFile))
{ {
var FileName = Path.GetFileName(ImgFile); var FileName = Path.GetFileName(ImgFile);
var LABFilePath = _config["ImagePath:LABFilePath"];
//指定要寫入的路徑、檔名和副檔名 //指定要寫入的路徑、檔名和副檔名
var FilePath = $"\\LABFile\\" + LabMatnr + "\\";//本機目錄 var FilePath = LABFilePath + LabMatnr + "\\";//本機目錄
if (!System.IO.Directory.Exists(_env.WebRootPath + FilePath)) if (!System.IO.Directory.Exists(FilePath))
{ {
System.IO.Directory.CreateDirectory(_env.WebRootPath + FilePath); System.IO.Directory.CreateDirectory(FilePath);
} }
var targetFilePath = _env.WebRootPath + FilePath + FileName; var targetFilePath = FilePath + FileName;
System.IO.File.Copy(ImgFile, targetFilePath, true); System.IO.File.Copy(ImgFile, targetFilePath, true);
return Json(new Result() { success = true, msg = FilePath + FileName }); return Json(new Result() { success = true, msg = FilePath + FileName });
@ -237,7 +238,7 @@ namespace AMESCoreStudio.Web.Controllers
if (PlmMeterial.Count > 0) if (PlmMeterial.Count > 0)
{ {
var Master = await _labApi.LabelTemplatebyMatnr(LabelMatnr,0,10); var Master = await _labApi.LabelTemplatebyMatnr(LabelMatnr, 0, 10);
if (Master.DataTotal > 0) if (Master.DataTotal > 0)
return Json(new Table() { count = 0, msg = "料號已存在", data = null }); return Json(new Table() { count = 0, msg = "料號已存在", data = null });
else else
@ -298,12 +299,11 @@ namespace AMESCoreStudio.Web.Controllers
string FileName = string.Empty; string FileName = string.Empty;
string NewName = string.Empty; string NewName = string.Empty;
string FilePath = string.Empty; string LABFilePath = _config["ImagePath:LABFilePath"];
if (formFile != null) if (formFile != null && formFile.Length > 0)
{
if (formFile.Length > 0)
{ {
//取得使用者上傳檔案的原始檔名 //取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(formFile.FileName); FileName = Path.GetFileName(formFile.FileName);
//取原始檔名中的副檔名 //取原始檔名中的副檔名
@ -311,18 +311,16 @@ namespace AMESCoreStudio.Web.Controllers
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱 //為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
NewName = Path.GetRandomFileName() + fileExt; NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名 //指定要寫入的路徑、檔名和副檔名
FilePath = $"\\LABFile\\";//本機目錄 if (!System.IO.Directory.Exists(LABFilePath))
if (!System.IO.Directory.Exists(_env.WebRootPath + FilePath))
{ {
System.IO.Directory.CreateDirectory(_env.WebRootPath + FilePath); System.IO.Directory.CreateDirectory(LABFilePath);
} }
using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create)) using (var stream = new FileStream(LABFilePath + NewName, FileMode.Create))
{ {
await formFile.CopyToAsync(stream); await formFile.CopyToAsync(stream);
} }
model.IMAGE_NAME = FilePath+ NewName; model.IMAGE_NAME = LABFilePath + NewName;
}
} }
else else
{ {
@ -401,11 +399,11 @@ namespace AMESCoreStudio.Web.Controllers
string FileName = string.Empty; string FileName = string.Empty;
string NewName = string.Empty; string NewName = string.Empty;
string FilePath = string.Empty; var RootPath = _config["ImagePath:RootPath"];
if (formFile != null) var LABFilePath = _config["ImagePath:LABFilePath"];
{ if (formFile != null && formFile.Length > 0)
if (formFile.Length > 0)
{ {
//取得使用者上傳檔案的原始檔名 //取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(formFile.FileName); FileName = Path.GetFileName(formFile.FileName);
//取原始檔名中的副檔名 //取原始檔名中的副檔名
@ -413,42 +411,34 @@ namespace AMESCoreStudio.Web.Controllers
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱 //為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
NewName = Path.GetRandomFileName() + fileExt; NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名 //指定要寫入的路徑、檔名和副檔名
FilePath = $"\\LABFile\\";//本機目錄 if (!System.IO.Directory.Exists(LABFilePath))
if (!System.IO.Directory.Exists(_env.WebRootPath + FilePath))
{ {
System.IO.Directory.CreateDirectory(_env.WebRootPath + FilePath); System.IO.Directory.CreateDirectory(LABFilePath);
} }
using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create)) using (var stream = new FileStream(LABFilePath + NewName, FileMode.Create))
{ {
await formFile.CopyToAsync(stream); await formFile.CopyToAsync(stream);
} }
model.IMAGE_NAME = FilePath + NewName; model.IMAGE_NAME = LABFilePath + NewName;
} }
else
{
ModelState.AddModelError("error", "請選擇要上傳檔案");
} }
result = await _labApi.PutLabeTemplateMaster(JsonConvert.SerializeObject(model)); result = await _labApi.PutLabeTemplateMaster(JsonConvert.SerializeObject(model));
if (result.Success) if (result.Success)
{ {
//var _msg = "添加成功!";
return Json(new Result() { success = true, msg = result.Msg }); return Json(new Result() { success = true, msg = result.Msg });
} }
else else
{ {
ModelState.AddModelError("error", result.Msg); ModelState.AddModelError("error", result.Msg);
} }
} }
return Json(new Result() { success = false, msg = "資料有誤!!" }); return Json(new Result() { success = false, msg = "資料有誤!!" });
//else
//{
// ModelState.AddModelError("error", "缺少必填資料");
// return View("LAB002C", model);
//}
} }
public async Task<IActionResult> LAB002UListSaveAsync(LabelTemplateDetail model) public async Task<IActionResult> LAB002UListSaveAsync(LabelTemplateDetail model)
@ -505,7 +495,7 @@ namespace AMESCoreStudio.Web.Controllers
} }
[HttpGet] [HttpGet]
public async Task<IActionResult> LAB003U(string OrderNo,string Operate) public async Task<IActionResult> LAB003U(string OrderNo, string Operate)
{ {
LabelItemReqModel model = new LabelItemReqModel(); LabelItemReqModel model = new LabelItemReqModel();
model = await _labApi.GetLabelItemReq(OrderNo); model = await _labApi.GetLabelItemReq(OrderNo);
@ -514,7 +504,7 @@ namespace AMESCoreStudio.Web.Controllers
} }
[HttpGet] [HttpGet]
public async Task<IActionResult> GetLab004(string OrderNo, string ModelNo, DateTime? strdate, DateTime? enddate, string UserNo,string Status) public async Task<IActionResult> GetLab004(string OrderNo, string ModelNo, DateTime? strdate, DateTime? enddate, string UserNo, string Status)
{ {
List<dynamic> xx = new List<dynamic>(); List<dynamic> xx = new List<dynamic>();
UserInfo User = new UserInfo(); UserInfo User = new UserInfo();
@ -580,11 +570,11 @@ namespace AMESCoreStudio.Web.Controllers
} }
[HttpGet] [HttpGet]
public async Task<JsonResult> GetLabelField(string Labmat,string ItemNo) public async Task<JsonResult> GetLabelField(string Labmat, string ItemNo)
{ {
ResultModel<dynamic> result = new ResultModel<dynamic>(); ResultModel<dynamic> result = new ResultModel<dynamic>();
result = await _labApi.GetLabelField(Labmat, ItemNo); result = await _labApi.GetLabelField(Labmat, ItemNo);
if(result.Data.Count()>0) if (result.Data.Count() > 0)
return Json(new Result() { success = result.Success, msg = result.Msg, data = result.Data }); return Json(new Result() { success = result.Success, msg = result.Msg, data = result.Data });
else else
return Json(new Result() { success = false, msg = result.Msg, data = null }); return Json(new Result() { success = false, msg = result.Msg, data = null });
@ -597,7 +587,7 @@ namespace AMESCoreStudio.Web.Controllers
{ {
int Sn = 1; int Sn = 1;
ResultModel<dynamic> result = new ResultModel<dynamic>(); ResultModel<dynamic> result = new ResultModel<dynamic>();
result = await _labApi.GetLabelItemMaster(OrderNo, null, null, null, -1,"A"); result = await _labApi.GetLabelItemMaster(OrderNo, null, null, null, -1, "A");
if (result.Data.Any()) if (result.Data.Any())
{ {
var r2 = result.Data.Max(x => x.ordeR_NO).ToString(); var r2 = result.Data.Max(x => x.ordeR_NO).ToString();

193
AMESCoreStudio.Web/Controllers/PCSController.cs

@ -23,6 +23,7 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AMESCoreStudio.Web.Controllers namespace AMESCoreStudio.Web.Controllers
@ -49,6 +50,7 @@ namespace AMESCoreStudio.Web.Controllers
/// </summary> /// </summary>
public static int NoLength = 4; public static int NoLength = 4;
public PCSController(ILogger<PCSController> logger, ILogger<LoginController> log, ISYS sysApi, IPCS pcsApi, IBAS basApi, IPPS ppsApi, IFQC fqcApi public PCSController(ILogger<PCSController> logger, ILogger<LoginController> log, ISYS sysApi, IPCS pcsApi, IBAS basApi, IPPS ppsApi, IFQC fqcApi
, IFileServerProvider fileServerProvider, IWebHostEnvironment env, IKCS kcsApi, IStringLocalizer<SharedResource> sharedLocalizer , IFileServerProvider fileServerProvider, IWebHostEnvironment env, IKCS kcsApi, IStringLocalizer<SharedResource> sharedLocalizer
, IConfiguration configuration, IBLL bllApi) , IConfiguration configuration, IBLL bllApi)
@ -64,7 +66,7 @@ namespace AMESCoreStudio.Web.Controllers
_fileServerProvider = fileServerProvider; _fileServerProvider = fileServerProvider;
_env = env; _env = env;
_sharedLocalizer = sharedLocalizer; _sharedLocalizer = sharedLocalizer;
_configuration = configuration; _configuration = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build();
_bllApi = bllApi; _bllApi = bllApi;
} }
@ -1739,6 +1741,7 @@ namespace AMESCoreStudio.Web.Controllers
if (wipInfoQuery.Any()) if (wipInfoQuery.Any())
{ // 判斷工單號碼 在工單基本資料檔只能有一筆(不判斷是否不同製程) { // 判斷工單號碼 在工單基本資料檔只能有一筆(不判斷是否不同製程)
ViewBag.MoidByOnlyOne = _configuration["MoidByOnlyOne"]; ViewBag.MoidByOnlyOne = _configuration["MoidByOnlyOne"];
if (ViewBag.MoidByOnlyOne == "Y") if (ViewBag.MoidByOnlyOne == "Y")
{ {
if (wipInfoQuery.Count() != 0) if (wipInfoQuery.Count() != 0)
@ -2338,7 +2341,11 @@ namespace AMESCoreStudio.Web.Controllers
return View("PCS001", model); return View("PCS001", model);
} }
/// <summary>
/// 工單資料查詢
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<IActionResult> PCS001R(int id) public async Task<IActionResult> PCS001R(int id)
{ {
// 針對安勤 工單基本資料統一打開工程資訊 // 針對安勤 工單基本資料統一打開工程資訊
@ -2460,6 +2467,7 @@ namespace AMESCoreStudio.Web.Controllers
GetCheckboxSMD(model.wipBoard != null ? model.wipBoard.Smd : null); GetCheckboxSMD(model.wipBoard != null ? model.wipBoard.Smd : null);
GetCheckboxSMDSolderMa(model.wipBoard != null ? model.wipBoard.SmdSolderMask : null); GetCheckboxSMDSolderMa(model.wipBoard != null ? model.wipBoard.SmdSolderMask : null);
GetCheckboxWipLN(model.wipLabel != null ? model.wipLabel.LN : "N"); GetCheckboxWipLN(model.wipLabel != null ? model.wipLabel.LN : "N");
ViewBag.FileUploadUrl = _configuration["ImagePath:FileUploadUrl"];
return View(model); return View(model);
} }
@ -2467,7 +2475,7 @@ namespace AMESCoreStudio.Web.Controllers
{ {
// 針對安勤 工單基本資料統一打開工程資訊 // 針對安勤 工單基本資料統一打開工程資訊
ViewBag.WipSpecial = _configuration["WipSpecial"]; ViewBag.WipSpecial = _configuration["WipSpecial"];
ViewBag.FileUploadUrl = _configuration["ImagePath:FileUploadUrl"];
WipDataViewModel model = new WipDataViewModel(); WipDataViewModel model = new WipDataViewModel();
var q = await _pcsApi.GetWipInfo(id); var q = await _pcsApi.GetWipInfo(id);
if (q.Count != 0) if (q.Count != 0)
@ -2619,6 +2627,7 @@ namespace AMESCoreStudio.Web.Controllers
GetCheckboxSMD(model.wipBoard != null ? model.wipBoard.Smd : ""); GetCheckboxSMD(model.wipBoard != null ? model.wipBoard.Smd : "");
GetCheckboxSMDSolderMa(model.wipBoard != null ? model.wipBoard.SmdSolderMask : ""); GetCheckboxSMDSolderMa(model.wipBoard != null ? model.wipBoard.SmdSolderMask : "");
GetCheckboxWipLN(model.wipLabel != null ? model.wipLabel.LN : "N"); GetCheckboxWipLN(model.wipLabel != null ? model.wipLabel.LN : "N");
ViewBag.FileUploadUrl = _configuration["ImagePath:FileUploadUrl"];
return View(model); return View(model);
} }
@ -2810,18 +2819,36 @@ namespace AMESCoreStudio.Web.Controllers
/// <param name="Path">路徑</param> /// <param name="Path">路徑</param>
/// <param name="FileName">檔名</param> /// <param name="FileName">檔名</param>
/// <returns></returns> /// <returns></returns>
public async Task<IActionResult> FileDownload(string Path, string FileName) public async Task<IActionResult> FileDownload(string fileUrl)
{ {
var path = $@"{_env.WebRootPath}\{Path}{FileName}"; fileUrl = fileUrl.Replace("\\", "/");
var memoryStream = new MemoryStream(); try
using (var stream = new FileStream(path, FileMode.Open))
{ {
await stream.CopyToAsync(memoryStream); if (string.IsNullOrEmpty(fileUrl))
{
return StatusCode(500, $"找不到檔案路徑: {fileUrl}");
}
// 使用 HttpClient 從遠端 URL 下載檔案
using (var httpClient = new HttpClient())
{
var response = await httpClient.GetAsync(fileUrl);
if (!response.IsSuccessStatusCode)
{
return StatusCode(500, $"HttpClient 從遠端 URL 下載檔案錯誤");
}
var fileStream = await response.Content.ReadAsStreamAsync();
var fileName = Path.GetFileName(new Uri(fileUrl).LocalPath);
var contentType = response.Content.Headers.ContentType?.MediaType ?? "application/octet-stream";
return File(fileStream, contentType, fileName);
}
}
catch (Exception ex)
{
return StatusCode(500, $"下載檔案錯誤: {ex.Message}");
} }
memoryStream.Seek(0, SeekOrigin.Begin);
string contentType = await GetFileContentTypeAsync(FileName);
// 回傳檔案到 Client 需要附上 Content Type,否則瀏覽器會解析失敗。
return File(memoryStream, contentType, FileName);
} }
/// <summary> /// <summary>
@ -6899,6 +6926,7 @@ namespace AMESCoreStudio.Web.Controllers
{ {
var bNo = model.B.BarcodeNo; var bNo = model.B.BarcodeNo;
model.PartNo = model.PartNo.Trim();
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
IResultModel result; IResultModel result;
@ -7181,61 +7209,6 @@ namespace AMESCoreStudio.Web.Controllers
[HttpPost] [HttpPost]
public async Task<IActionResult> PCS030Async(MaterialSop model, IFormFile formFile) public async Task<IActionResult> PCS030Async(MaterialSop model, IFormFile formFile)
{ {
//string FileName = string.Empty;
//string NewName = string.Empty;
//string FilePath = string.Empty;
////var fileProvider = _fileServerProvider.GetProvider("/aa");
////var fileInfo = fileProvider.GetFileInfo("/");
//if (formFile != null)
//{
// if (formFile.Length > 0)
// {
// //取得使用者上傳檔案的原始檔名
// FileName = Path.GetFileName(formFile.FileName);
// //取原始檔名中的副檔名
// var fileExt = Path.GetExtension(FileName);
// //為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
// NewName = Path.GetRandomFileName() + fileExt;
// //指定要寫入的路徑、檔名和副檔名
// FilePath = $"\\PDF\\";//本機目錄
// using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create))
// {
// await formFile.CopyToAsync(stream);
// }
// var fileProvider = _fileServerProvider.GetProvider("/aa");
// //var fileInfo = fileProvider.GetFileInfo(formFile.FileName);
// //fileInfo = fileProvider.GetFileInfo(formFile.FileName);
// ////遠端目錄
// //using (var stream = new FileStream(fileInfo.PhysicalPath, FileMode.Create))
// //{
// // await formFile.CopyToAsync(stream);
// //}
// IResultModel result;
// model.FileName = FileName;
// model.NewName = NewName;
// model.FilePath = FilePath;// fileInfo.PhysicalPath;
// result = await _pcsApi.PostMaterialSop(JsonConvert.SerializeObject(model));
// if (result.Success)
// {
// var _msg = model.MaterialSopID == 0 ? "新增成功!" : "修改成功!";
// return RedirectToAction("Refresh", "Home", new { msg = _msg });
// }
// else
// {
// ModelState.AddModelError("error", result.Msg);
// }
// }
//}
//else
//{
// ModelState.AddModelError("error", "請選擇要上傳檔案");
//}
await GetFactoryUnit(false); await GetFactoryUnit(false);
GetSOPTypeSelect(); GetSOPTypeSelect();
@ -7558,6 +7531,7 @@ namespace AMESCoreStudio.Web.Controllers
IResultModel result; IResultModel result;
IResultModel result2; IResultModel result2;
model.PartNo = model.PartNo.Trim();
var barcodeItemOldList = await _pcsApi.GetBarcodeItem(model.BarcodeItemID); var barcodeItemOldList = await _pcsApi.GetBarcodeItem(model.BarcodeItemID);
var barcodeItemOld = barcodeItemOldList[0]; var barcodeItemOld = barcodeItemOldList[0];
var barcodeItemChange = new BarcodeItemChange(); var barcodeItemChange = new BarcodeItemChange();
@ -8891,28 +8865,30 @@ namespace AMESCoreStudio.Web.Controllers
} }
model.WipSops = model.WipSops.Where(w => w.WipSOPID != -1); model.WipSops = model.WipSops.Where(w => w.WipSOPID != -1);
// 檔案上傳 // 圖片上傳
string FileName = string.Empty; var rootFolderPath = _configuration["ImagePath:RootPath"];
string NewName = string.Empty; var uploadFolderPath = _configuration["ImagePath:UploadFolderPath"];
string FilePath = string.Empty;
if (formFile != null) if (formFile != null)
{ {
if (formFile.Length > 0) if (formFile.Length > 0)
{ {
//取得使用者上傳檔案的原始檔名 //取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(formFile.FileName); var imageName = Path.GetFileName(formFile.FileName);
//取原始檔名中的副檔名
//var fileExt = Path.GetExtension(FileName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
//NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名 //指定要寫入的路徑、檔名和副檔名
FilePath = $@"{_env.WebRootPath}\UploadFolder\{model.wipInfo.WipNO}"; var rootPath = $@"{rootFolderPath}\{uploadFolderPath}\{model.wipInfo.WipNO}";
var path = $@"{FilePath}\{FileName}"; var filePath = $@"\{uploadFolderPath}\{model.wipInfo.WipNO}";
var path = $@"{rootPath}\{imageName}";
if (!System.IO.Directory.Exists(FilePath)) if (!System.IO.Directory.Exists(rootPath))
{ {
System.IO.Directory.CreateDirectory(FilePath); try
{
System.IO.Directory.CreateDirectory(rootPath);
}
catch (Exception ex)
{
ModelState.AddModelError("error", $"無法建立路徑: {rootPath}, 錯誤: {ex.Message}");
}
} }
using (var stream = new FileStream(path, FileMode.Create)) using (var stream = new FileStream(path, FileMode.Create))
@ -8921,8 +8897,8 @@ namespace AMESCoreStudio.Web.Controllers
} }
model.wipInfoBlob.WipNo = model.wipInfo.WipNO; model.wipInfoBlob.WipNo = model.wipInfo.WipNO;
model.wipInfoBlob.ImageName = FileName; model.wipInfoBlob.ImageName = imageName;
model.wipInfoBlob.Filepath = $@"\UploadFolder\{model.wipInfo.WipNO}\"; model.wipInfoBlob.Filepath = filePath;
model.wipInfoBlob.CreateUserID = UserID; model.wipInfoBlob.CreateUserID = UserID;
model.wipInfoBlob.UpdateUserID = UserID; model.wipInfoBlob.UpdateUserID = UserID;
result = await _pcsApi.PostWipInfoBlob(JsonConvert.SerializeObject(model.wipInfoBlob)); result = await _pcsApi.PostWipInfoBlob(JsonConvert.SerializeObject(model.wipInfoBlob));
@ -8931,7 +8907,12 @@ namespace AMESCoreStudio.Web.Controllers
Msg += result.Msg; Msg += result.Msg;
} }
} }
else
{
ModelState.AddModelError("error", "請選擇要上傳檔案");
}
} }
} }
} }
catch (Exception ex) catch (Exception ex)
@ -10073,7 +10054,7 @@ namespace AMESCoreStudio.Web.Controllers
#region PCS041 生產注意事項 #region PCS041 生產注意事項
/// <summary> /// <summary>
/// /// 生產注意事項
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<IActionResult> PCS041() public async Task<IActionResult> PCS041()
@ -10083,6 +10064,12 @@ namespace AMESCoreStudio.Web.Controllers
return View(); return View();
} }
/// <summary>
/// 生產注意事項新增
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public async Task<IActionResult> PCS041C(PCS041CViewModel model) public async Task<IActionResult> PCS041C(PCS041CViewModel model)
{ {
await GetStation(); await GetStation();
@ -10106,18 +10093,21 @@ namespace AMESCoreStudio.Web.Controllers
{ {
PCS041CImageViewModel b = new PCS041CImageViewModel(); PCS041CImageViewModel b = new PCS041CImageViewModel();
b.Filename = blob.FileName; b.Filename = blob.FileName;
b.FilePath = blob.FilePath; b.FilePath = _configuration["ImagePath:ProductionMemoPath"];
b.Description = blob.FileDescription; b.Description = blob.FileDescription;
model.Images.Add(b); model.Images.Add(b);
} }
model.Image = new PCS041CImageViewModel(); model.Image = new PCS041CImageViewModel();
} }
ViewBag.FileUploadUrl = _configuration["ImagePath:FileUploadUrl"];
return View(model); return View(model);
} }
/// <summary> /// <summary>
/// Delete /// 生產注意事項刪除
/// </summary> /// </summary>
/// <param name="ppid">PK</param> /// <param name="ppid">PK</param>
/// <returns></returns> /// <returns></returns>
@ -10129,8 +10119,9 @@ namespace AMESCoreStudio.Web.Controllers
var r2 = await _pcsApi.DeleteProductionNoticeBlobByPPID(ppid); var r2 = await _pcsApi.DeleteProductionNoticeBlobByPPID(ppid);
return Json(new Result() { success = r1.Success, msg = r1.Msg, data = null }); return Json(new Result() { success = r1.Success, msg = r1.Msg, data = null });
} }
/// <summary> /// <summary>
/// View /// 生產注意事項檢視
/// </summary> /// </summary>
/// <param name="ppid">PK</param> /// <param name="ppid">PK</param>
/// <returns></returns> /// <returns></returns>
@ -10167,7 +10158,9 @@ namespace AMESCoreStudio.Web.Controllers
model.Image = new PCS041CImageViewModel(); model.Image = new PCS041CImageViewModel();
return View("PCS041V", model); return View("PCS041V", model);
} /// <summary> }
/// <summary>
/// View /// View
/// </summary> /// </summary>
/// <param name="ppid">PK</param> /// <param name="ppid">PK</param>
@ -10201,9 +10194,6 @@ namespace AMESCoreStudio.Web.Controllers
} }
} }
//model.Image = new PCS041CImageViewModel();
return View("PCS041V2", model); return View("PCS041V2", model);
} }
/// <summary> /// <summary>
@ -10230,30 +10220,13 @@ namespace AMESCoreStudio.Web.Controllers
} }
return Json(new Table() { count = 0, data = null }); return Json(new Table() { count = 0, data = null });
} }
public async Task<IActionResult> PCS041GetImage(string path) public async Task<IActionResult> PCS041GetImage(string path)
{ {
byte[] fileBytes = await System.IO.File.ReadAllBytesAsync(path); byte[] fileBytes = await System.IO.File.ReadAllBytesAsync(path);
return File(fileBytes, "image/jpeg"); return File(fileBytes, "image/jpeg");
} }
/// <summary>
/// 檔案下載
/// </summary>
/// <param name="Path">路徑</param>
/// <param name="FileName">檔名</param>
/// <returns></returns>
public async Task<IActionResult> PCS041FileDownload(string Path, string FileName)
{
var path = Path + FileName;
var memoryStream = new MemoryStream();
using (var stream = new FileStream(path, FileMode.Open))
{
await stream.CopyToAsync(memoryStream);
}
memoryStream.Seek(0, SeekOrigin.Begin);
string contentType = await GetFileContentTypeAsync(FileName);
// 回傳檔案到 Client 需要附上 Content Type,否則瀏覽器會解析失敗。
return File(memoryStream, contentType, FileName);
}
//頁面提交,id=0 添加,id>0 修改 //頁面提交,id=0 添加,id>0 修改
public async Task<IActionResult> PCS041CSave(PCS041CViewModel model) public async Task<IActionResult> PCS041CSave(PCS041CViewModel model)
{ {

605
AMESCoreStudio.Web/Controllers/REPController.cs

@ -8,13 +8,13 @@ using AMESCoreStudio.CommonTools.Result;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;
using AMESCoreStudio.Web.ViewModels; using AMESCoreStudio.Web.ViewModels;
using System.ComponentModel.DataAnnotations;
using System.IO; using System.IO;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using AMESCoreStudio.WebApi.DTO.AMES; using AMESCoreStudio.WebApi.DTO.AMES;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.Extensions.Configuration;
using System;
namespace AMESCoreStudio.Web.Controllers namespace AMESCoreStudio.Web.Controllers
{ {
@ -27,8 +27,10 @@ namespace AMESCoreStudio.Web.Controllers
public readonly IPCS _pcsApi; public readonly IPCS _pcsApi;
public readonly ISYS _sysApi; public readonly ISYS _sysApi;
private readonly IWebHostEnvironment _env; private readonly IWebHostEnvironment _env;
private readonly IConfiguration _config;
public REPController(ILogger<REPController> logger, IREP repApi, IPPS ppsApi, IBAS basApi, IPCS pcsApi, ISYS sysApi, IWebHostEnvironment env) public REPController(ILogger<REPController> logger, IREP repApi, IPPS ppsApi, IBAS basApi,
IPCS pcsApi, ISYS sysApi, IWebHostEnvironment env, IConfiguration config)
{ {
_logger = logger; _logger = logger;
_repApi = repApi; _repApi = repApi;
@ -37,6 +39,7 @@ namespace AMESCoreStudio.Web.Controllers
_pcsApi = pcsApi; _pcsApi = pcsApi;
_sysApi = sysApi; _sysApi = sysApi;
_env = env; _env = env;
_config = config;
} }
private async Task GetProductTypeList() private async Task GetProductTypeList()
@ -196,7 +199,7 @@ namespace AMESCoreStudio.Web.Controllers
} }
[HttpPost] [HttpPost]
public async Task<JsonResult> GetMaterialNoJson(string wip_no,string location_no) public async Task<JsonResult> GetMaterialNoJson(string wip_no, string location_no)
{ {
var wip_att = await _pcsApi.GetWipAtt(wip_no); var wip_att = await _pcsApi.GetWipAtt(wip_no);
//E9695A4S001R //E9695A4S001R
@ -469,7 +472,8 @@ namespace AMESCoreStudio.Web.Controllers
public IActionResult REP001B(string id) public IActionResult REP001B(string id)
{ {
ViewBag.ImageUrl = $"\\REPImage\\" + id; string REPImagePath = _config["ImagePath:REPImagePath"];
ViewBag.ImageUrl = REPImagePath + id;
return View(); return View();
} }
@ -479,7 +483,7 @@ namespace AMESCoreStudio.Web.Controllers
return Json(new Result() { success = true, msg = "" }); return Json(new Result() { success = true, msg = "" });
} }
public async Task<JsonResult> SaveRepairDesc(int ng_id,int component_id,string repair_desc) public async Task<JsonResult> SaveRepairDesc(int ng_id, int component_id, string repair_desc)
{ {
IResultModel result; IResultModel result;
var userID = ""; var userID = "";
@ -519,7 +523,7 @@ namespace AMESCoreStudio.Web.Controllers
return Json(new { _msg = string.Format("維修描述保存成功!") }); return Json(new { _msg = string.Format("維修描述保存成功!") });
} }
public async Task<JsonResult> SaveNgKeypart(int component_id, string old_part_no,string new_part_no) public async Task<JsonResult> SaveNgKeypart(int component_id, string old_part_no, string new_part_no)
{ {
IResultModel result; IResultModel result;
var userID = ""; var userID = "";
@ -564,6 +568,9 @@ namespace AMESCoreStudio.Web.Controllers
var userID = ""; var userID = "";
HttpContext.Request.Cookies.TryGetValue("UserID", out userID); HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
int user_id = 0; int user_id = 0;
string REPImagePath = _config["ImagePath:REPImagePath"];
if (userID != null) if (userID != null)
{ {
if (int.Parse(userID.ToString()) >= 0) if (int.Parse(userID.ToString()) >= 0)
@ -616,7 +623,7 @@ namespace AMESCoreStudio.Web.Controllers
model.ngReason = null; model.ngReason = null;
} }
if (result1[0].ErrorDesc == "" || result1[0].ErrorDesc == null ) if (result1[0].ErrorDesc == "" || result1[0].ErrorDesc == null)
{ {
result1[0].ErrorDesc = ng_reason[0].NGReasonDesc; result1[0].ErrorDesc = ng_reason[0].NGReasonDesc;
} }
@ -665,9 +672,9 @@ namespace AMESCoreStudio.Web.Controllers
} }
else else
{ {
ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image1Url = REPImagePath + "noimage.jfif";
ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image2Url = REPImagePath + "noimage.jfif";
ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image3Url = REPImagePath + "noimage.jfif";
} }
} }
else else
@ -675,9 +682,9 @@ namespace AMESCoreStudio.Web.Controllers
NgRepair ngRepair = new NgRepair(); NgRepair ngRepair = new NgRepair();
model.ngRepair = ngRepair; model.ngRepair = ngRepair;
ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image1Url = REPImagePath + "noimage.jfif";
ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image2Url = REPImagePath + "noimage.jfif";
ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image3Url = REPImagePath + "noimage.jfif";
} }
} }
@ -694,13 +701,15 @@ namespace AMESCoreStudio.Web.Controllers
await GetNGReasonList(); await GetNGReasonList();
await GetRepairResponsibleUnitList(); await GetRepairResponsibleUnitList();
var REPImagePath = _config["ImagePath:REPImagePath"];
var userID = HttpContext.Request.Cookies["UserID"]; var userID = HttpContext.Request.Cookies["UserID"];
HttpContext.Response.Cookies.Append("UserID4REP001", userID.ToString()); HttpContext.Response.Cookies.Append("UserID4REP001", userID.ToString());
REP001NewViewModel model = new REP001NewViewModel();
var result1 = await _repApi.GetNgComponent(id);
var result1 = await _repApi.GetNgComponent(id);
var ng_reason = await _ppsApi.GetNGReason(result1[0].NgNo); var ng_reason = await _ppsApi.GetNGReason(result1[0].NgNo);
REP001NewViewModel model = new REP001NewViewModel();
if (ng_reason.Count != 0) if (ng_reason.Count != 0)
{ {
model.ngReason = ng_reason[0]; model.ngReason = ng_reason[0];
@ -735,7 +744,7 @@ namespace AMESCoreStudio.Web.Controllers
var result31 = await _repApi.GetRepairRecordByNgID((int)result1[0].NgID); var result31 = await _repApi.GetRepairRecordByNgID((int)result1[0].NgID);
string repair_desc = ""; string repair_desc = "";
for(int r=0;r<result31.Count;r++) for (int r = 0; r < result31.Count; r++)
{ {
repair_desc = repair_desc + result31[r].RepairDesc + "\r\n"; repair_desc = repair_desc + result31[r].RepairDesc + "\r\n";
} }
@ -781,9 +790,9 @@ namespace AMESCoreStudio.Web.Controllers
} }
else else
{ {
ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image1Url = REPImagePath + "noimage.jfif";
ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image2Url = REPImagePath + "noimage.jfif";
ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image3Url = REPImagePath + "noimage.jfif";
} }
} }
else else
@ -791,9 +800,9 @@ namespace AMESCoreStudio.Web.Controllers
NgRepair ngRepair = new NgRepair(); NgRepair ngRepair = new NgRepair();
model.ngRepair = ngRepair; model.ngRepair = ngRepair;
ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image1Url = REPImagePath + "noimage.jfif";
ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image2Url = REPImagePath + "noimage.jfif";
ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image3Url = REPImagePath + "noimage.jfif";
} }
} }
@ -806,8 +815,9 @@ namespace AMESCoreStudio.Web.Controllers
{ {
IResultModel result; IResultModel result;
var userID = ""; var userID = "";
var rootFolderPath = _config["ImagePath:RootPath"];
//userID = HttpContext.Request.Cookies["UserID4REP001"]; var repFolderPath = _config["ImagePath:REPImagePath"];
var repImagePath = $@"{rootFolderPath}\{repFolderPath}";
userID = User.FindFirst("UserID")?.Value; userID = User.FindFirst("UserID")?.Value;
//HttpContext.Request.Cookies.TryGetValue("UserID", out userID); //HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
@ -824,14 +834,9 @@ namespace AMESCoreStudio.Web.Controllers
model.ngComponent.Status = 1; model.ngComponent.Status = 1;
model.ngComponent.UpdateUserID = user_id; model.ngComponent.UpdateUserID = user_id;
string FileName = string.Empty;
string NewName = string.Empty;
string FilePath = string.Empty;
string[] newFileName = null; string[] newFileName = null;
if (formFile != null) if (formFile != null && formFile.Count > 0)
{
if (formFile.Count > 0)
{ {
newFileName = new string[formFile.Count]; newFileName = new string[formFile.Count];
int idx = 0; int idx = 0;
@ -840,23 +845,21 @@ namespace AMESCoreStudio.Web.Controllers
if (item.Length > 0) if (item.Length > 0)
{ {
//取得使用者上傳檔案的原始檔名 //取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(item.FileName); var imageName = Path.GetFileName(item.FileName);
//取原始檔名中的副檔名 //取原始檔名中的副檔名
var fileExt = Path.GetExtension(FileName); var fileExt = Path.GetExtension(imageName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱 //為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
NewName = Path.GetRandomFileName() + fileExt; var newName = Path.GetRandomFileName() + fileExt;
newFileName[idx] = NewName; var path = $@"{repImagePath}\{newName}";
newFileName[idx] = newName;
idx = idx + 1; idx = idx + 1;
//指定要寫入的路徑、檔名和副檔名 //指定要寫入的路徑、檔名和副檔名
FilePath = $"\\REPImage\\";//本機目錄 using (var stream = new FileStream(path, FileMode.Create))
using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create))
{ {
await item.CopyToAsync(stream); await item.CopyToAsync(stream);
} }
} }
} }
}
} }
else else
{ {
@ -903,7 +906,7 @@ namespace AMESCoreStudio.Web.Controllers
result = await _repApi.PostNgRepair(JsonConvert.SerializeObject(model.ngRepair)); result = await _repApi.PostNgRepair(JsonConvert.SerializeObject(model.ngRepair));
} }
if (newFileName==null) if (newFileName == null)
{ } { }
else else
{ {
@ -1106,250 +1109,249 @@ namespace AMESCoreStudio.Web.Controllers
} }
//頁面提交,id=0 添加,id>0 修改 //頁面提交,id=0 添加,id>0 修改
[HttpPost] //[HttpPost]
public async Task<IActionResult> REP001RSave1Async(REP001ViewModel model, IFormFile formFile) //public async Task<IActionResult> REP001RSave1Async(REP001ViewModel model, IFormFile formFile)
{
IResultModel result;
var userID = "";
HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
int user_id = 0;
if (userID != null)
{
if (int.Parse(userID.ToString()) >= 0)
{
user_id = int.Parse(userID.ToString());
}
}
model.ngComponent.ReplyUserID = user_id;
model.ngComponent.ReplyDate = System.DateTime.Now;
model.ngComponent.Status = 1;
model.ngComponent.UpdateUserID = user_id;
string FileName = string.Empty;
string NewName = string.Empty;
string FilePath = string.Empty;
if (formFile != null)
{
if (formFile.Length > 0)
{
//取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(formFile.FileName);
//取原始檔名中的副檔名
var fileExt = Path.GetExtension(FileName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名
FilePath = $"\\REPImage\\";//本機目錄
using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create))
{
await formFile.CopyToAsync(stream);
}
}
}
else
{
var ng_repiar_blob = await _repApi.GetNgRepairBlob(model.ngRepair.RepairID);
if (ng_repiar_blob.Count == 0)
{
ModelState.AddModelError("error", "請選擇要上傳檔案");
}
}
if (model.ngRepair.Missing == "Y")
{
model.ngRepair.RepairNo = "N/A";
model.ngComponent.Status = 2;
}
result = await _repApi.PutNgComponent((int)model.ngComponent.ComponentID, JsonConvert.SerializeObject(model.ngComponent));
if (model.repairRecord.ComponentID > 0)
{
model.repairRecord.UpdateUserID = user_id;
result = await _repApi.PutRepairRecord((int)model.repairRecord.ComponentID, JsonConvert.SerializeObject(model.repairRecord));
}
else
{
model.repairRecord.CreateUserID = user_id;
model.repairRecord.NgID = model.ngComponent.NgID;
model.repairRecord.ComponentID = model.ngComponent.ComponentID;
model.repairRecord.RepairDesc = model.ngRepair.RepairDesc;
result = await _repApi.PostRepairRecord(JsonConvert.SerializeObject(model.repairRecord));
}
if (model.ngRepair.RepairID > 0)
{
model.ngRepair.UpdateUserID = user_id;
result = await _repApi.PutNgRepair((int)model.ngRepair.RepairID, JsonConvert.SerializeObject(model.ngRepair));
}
else
{
model.ngRepair.CreateUserID = user_id;
model.ngRepair.NgID = model.ngComponent.NgID;
model.ngRepair.ComponentID = model.ngComponent.ComponentID;
result = await _repApi.PostNgRepair(JsonConvert.SerializeObject(model.ngRepair));
}
if (NewName == string.Empty)
{ }
else
{
decimal repairID = 0;
if (model.ngRepair.RepairID == 0)
{
var ng_repair = await _repApi.GetNgRepairByComponent(model.ngRepair.ComponentID);
repairID = ng_repair[0].RepairID;
}
else
{
repairID = model.ngRepair.RepairID;
}
if (model.ngRepairBlob == null)
{
NgRepairBlob ng_repair_blob = new NgRepairBlob();
ng_repair_blob.ImageName = NewName;
ng_repair_blob.RepairID = repairID;
model.ngRepairBlob = ng_repair_blob;
}
else
{
model.ngRepairBlob.ImageName = NewName;
model.ngRepairBlob.RepairID = repairID;
}
result = await _repApi.PostNgRepairBlob(JsonConvert.SerializeObject(model.ngRepairBlob));
}
//if (result.Success)
//{
// var _msg = model.ngRepairBlob.RepairID == 0 ? "新增成功!" : "修改成功!";
// return RedirectToAction("Refresh", "Home", new { msg = _msg });
//}
//else
//{ //{
// IResultModel result;
// var userID = "";
// var REPImagePath = _config["ImagePath:REPImagePath"];
// HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
// int user_id = 0;
// if (userID != null)
// {
// if (int.Parse(userID.ToString()) >= 0)
// {
// user_id = int.Parse(userID.ToString());
// }
// }
// model.ngComponent.ReplyUserID = user_id;
// model.ngComponent.ReplyDate = System.DateTime.Now;
// model.ngComponent.Status = 1;
// model.ngComponent.UpdateUserID = user_id;
// string FileName = string.Empty;
// string NewName = string.Empty;
// if (formFile != null)
// {
// if (formFile.Length > 0)
// {
// //取得使用者上傳檔案的原始檔名
// FileName = Path.GetFileName(formFile.FileName);
// //取原始檔名中的副檔名
// var fileExt = Path.GetExtension(FileName);
// //為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
// NewName = Path.GetRandomFileName() + fileExt;
// //指定要寫入的路徑、檔名和副檔名
// using (var stream = new FileStream(REPImagePath + NewName, FileMode.Create))
// {
// await formFile.CopyToAsync(stream);
// }
// }
// }
// else
// {
// var ng_repiar_blob = await _repApi.GetNgRepairBlob(model.ngRepair.RepairID);
// if (ng_repiar_blob.Count == 0)
// {
// ModelState.AddModelError("error", "請選擇要上傳檔案");
// }
// }
// if (model.ngRepair.Missing == "Y")
// {
// model.ngRepair.RepairNo = "N/A";
// model.ngComponent.Status = 2;
// }
// result = await _repApi.PutNgComponent((int)model.ngComponent.ComponentID, JsonConvert.SerializeObject(model.ngComponent));
// if (model.repairRecord.ComponentID > 0)
// {
// model.repairRecord.UpdateUserID = user_id;
// result = await _repApi.PutRepairRecord((int)model.repairRecord.ComponentID, JsonConvert.SerializeObject(model.repairRecord));
// }
// else
// {
// model.repairRecord.CreateUserID = user_id;
// model.repairRecord.NgID = model.ngComponent.NgID;
// model.repairRecord.ComponentID = model.ngComponent.ComponentID;
// model.repairRecord.RepairDesc = model.ngRepair.RepairDesc;
// result = await _repApi.PostRepairRecord(JsonConvert.SerializeObject(model.repairRecord));
// }
// if (model.ngRepair.RepairID > 0)
// {
// model.ngRepair.UpdateUserID = user_id;
// result = await _repApi.PutNgRepair((int)model.ngRepair.RepairID, JsonConvert.SerializeObject(model.ngRepair));
// }
// else
// {
// model.ngRepair.CreateUserID = user_id;
// model.ngRepair.NgID = model.ngComponent.NgID;
// model.ngRepair.ComponentID = model.ngComponent.ComponentID;
// result = await _repApi.PostNgRepair(JsonConvert.SerializeObject(model.ngRepair));
// }
// if (NewName == string.Empty)
// { }
// else
// {
// decimal repairID = 0;
// if (model.ngRepair.RepairID == 0)
// {
// var ng_repair = await _repApi.GetNgRepairByComponent(model.ngRepair.ComponentID);
// repairID = ng_repair[0].RepairID;
// }
// else
// {
// repairID = model.ngRepair.RepairID;
// }
// if (model.ngRepairBlob == null)
// {
// NgRepairBlob ng_repair_blob = new NgRepairBlob();
// ng_repair_blob.ImageName = NewName;
// ng_repair_blob.RepairID = repairID;
// model.ngRepairBlob = ng_repair_blob;
// }
// else
// {
// model.ngRepairBlob.ImageName = NewName;
// model.ngRepairBlob.RepairID = repairID;
// }
// result = await _repApi.PostNgRepairBlob(JsonConvert.SerializeObject(model.ngRepairBlob));
// }
// //if (result.Success)
// //{
// // var _msg = model.ngRepairBlob.RepairID == 0 ? "新增成功!" : "修改成功!";
// // return RedirectToAction("Refresh", "Home", new { msg = _msg });
// //}
// //else
// //{
// // ModelState.AddModelError("error", result.Msg);
// //}
// bool repairComplete = true;
// var ng_component = await _repApi.GetNgComponentByNGID(model.ngInfo.NgID);
// for (int i = 0; i < ng_component.Count; i++)
// {
// if (ng_component[i].Status == 0)
// {
// repairComplete = false;
// break;
// }
// }
// List<BarCodeCheckDto.inputItem> items = new List<BarCodeCheckDto.inputItem>();
// //判斷組件是否更換
// for (int i = 0; i < ng_component.Count; i++)
// {
// if (ng_component[i].NewPartNo != "" && ng_component[i].NewPartNo != null)
// {
// items.Add(new BarCodeCheckDto.inputItem
// {
// inputType = "KP",
// inputData = ng_component[i].NewPartNo,
// oldInputData = ng_component[i].OldPartNo
// });
// }
// }
// if (items.Count == 0)
// {
// items = null;
// }
// if (repairComplete)
// {
// //判断全部维修完成过站
// int repairStationID = -1;
// //獲取流程ID
// int wip_id = model.ngInfo.Barcode.WipID;
// var wip_info = await _pcsApi.GetWipInfo(wip_id);
// int flow_rule_id = wip_info[0].FlowRuleID;
// var rules = await _basApi.GetRules2(flow_rule_id, model.ngInfo.Barcode.StationID, model.ngInfo.Barcode.RuleStatus, repairStationID);
// if (rules.Count > 0)
// {
// for (int i = 0; i < rules.Count; i++)
// {
// if (rules[i].RuleStatus == model.ngInfo.Barcode.RuleStatus)
// {
// repairStationID = rules[i].NextStationID;
// break;
// }
// }
// }
// int lineID = -1;
// if (model.ngInfo.Wip.LineID != null)
// {
// lineID = model.ngInfo.Wip.LineID.Value;
// }
// //准备资料
// var barCode = new BarCodeCheckDto
// {
// wipNo = model.ngInfo.Wip.WipNO,
// barcode = model.ngInfo.Barcode.BarcodeNo,
// barcodeType = "S",
// stationID = repairStationID,
// line = lineID,
// unitNo = model.ngInfo.Wip.UnitNO,
// inputItems = items,
// userID = user_id
// };
// var barcode_result = new ResultModel<string>();
// try
// {
// barcode_result = await _pcsApi.PassIngByCheck(JsonConvert.SerializeObject(barCode));
// }
// catch { }
// if (barcode_result.Success)
// {
// //更新NG_INFO
// //var ng_info = await _repApi.GetNgInfo((int)model.ngInfo.NgID);
// //ng_info[0].Status = 1;
// model.ngInfo.Status = 1;
// result = await _repApi.PutNgInfo(JsonConvert.SerializeObject(model.ngInfo));
// }
// else
// {
// return RedirectToAction("Refresh", "Home", new { id = model.ngComponent.NgID, msg = barcode_result.Msg });
// }
// }
// if (result.Success)
// {
// var _msg = "儲存成功!";
// //return RedirectToAction("REP001V", "REP", new { id = model.ngComponent.NgID, msg = _msg });
// return RedirectToAction("Refresh", "Home", new { id = model.ngComponent.NgID, msg = _msg });
// }
// else
// {
// if (result.Errors != null)
// {
// ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg);
// }
// else
// {
// ModelState.AddModelError("error", result.Msg); // ModelState.AddModelError("error", result.Msg);
//} // }
// }
bool repairComplete = true;
var ng_component = await _repApi.GetNgComponentByNGID(model.ngInfo.NgID); // return View("REP001R", model);
for (int i = 0; i < ng_component.Count; i++) // //return RedirectToAction("REP001V", "REP", new { id = model.ngComponent.NgID });
{ //}
if (ng_component[i].Status == 0)
{
repairComplete = false;
break;
}
}
List<BarCodeCheckDto.inputItem> items = new List<BarCodeCheckDto.inputItem>();
//判斷組件是否更換
for (int i = 0; i < ng_component.Count; i++)
{
if (ng_component[i].NewPartNo != "" && ng_component[i].NewPartNo != null)
{
items.Add(new BarCodeCheckDto.inputItem
{
inputType = "KP",
inputData = ng_component[i].NewPartNo,
oldInputData = ng_component[i].OldPartNo
});
}
}
if (items.Count == 0)
{
items = null;
}
if (repairComplete)
{
//判断全部维修完成过站
int repairStationID = -1;
//獲取流程ID
int wip_id = model.ngInfo.Barcode.WipID;
var wip_info = await _pcsApi.GetWipInfo(wip_id);
int flow_rule_id = wip_info[0].FlowRuleID;
var rules = await _basApi.GetRules2(flow_rule_id, model.ngInfo.Barcode.StationID, model.ngInfo.Barcode.RuleStatus, repairStationID);
if (rules.Count > 0)
{
for (int i = 0; i < rules.Count; i++)
{
if (rules[i].RuleStatus == model.ngInfo.Barcode.RuleStatus)
{
repairStationID = rules[i].NextStationID;
break;
}
}
}
int lineID = -1;
if (model.ngInfo.Wip.LineID != null)
{
lineID = model.ngInfo.Wip.LineID.Value;
}
//准备资料
var barCode = new BarCodeCheckDto
{
wipNo = model.ngInfo.Wip.WipNO,
barcode = model.ngInfo.Barcode.BarcodeNo,
barcodeType = "S",
stationID = repairStationID,
line = lineID,
unitNo = model.ngInfo.Wip.UnitNO,
inputItems = items,
userID = user_id
};
var barcode_result = new ResultModel<string>();
try
{
barcode_result = await _pcsApi.PassIngByCheck(JsonConvert.SerializeObject(barCode));
}
catch { }
if (barcode_result.Success)
{
//更新NG_INFO
//var ng_info = await _repApi.GetNgInfo((int)model.ngInfo.NgID);
//ng_info[0].Status = 1;
model.ngInfo.Status = 1;
result = await _repApi.PutNgInfo(JsonConvert.SerializeObject(model.ngInfo));
}
else
{
return RedirectToAction("Refresh", "Home", new { id = model.ngComponent.NgID, msg = barcode_result.Msg });
}
}
if (result.Success)
{
var _msg = "儲存成功!";
//return RedirectToAction("REP001V", "REP", new { id = model.ngComponent.NgID, msg = _msg });
return RedirectToAction("Refresh", "Home", new { id = model.ngComponent.NgID, msg = _msg });
}
else
{
if (result.Errors != null)
{
ModelState.AddModelError(result.Errors[0].Id, result.Errors[0].Msg);
}
else
{
ModelState.AddModelError("error", result.Msg);
}
}
return View("REP001R", model);
//return RedirectToAction("REP001V", "REP", new { id = model.ngComponent.NgID });
}
#endregion #endregion
@ -1398,8 +1400,8 @@ namespace AMESCoreStudio.Web.Controllers
await GetRepairResponsibleUnitList(); await GetRepairResponsibleUnitList();
REP001ViewModel model = new REP001ViewModel(); REP001ViewModel model = new REP001ViewModel();
var REPImagePath = _config["ImagePath:REPImagePath"];
var result1 = await _repApi.GetNgComponent(id); var result1 = await _repApi.GetNgComponent(id);
var ng_reason = await _ppsApi.GetNGReason(result1[0].NgNo); var ng_reason = await _ppsApi.GetNGReason(result1[0].NgNo);
if (ng_reason.Count != 0) if (ng_reason.Count != 0)
{ {
@ -1447,36 +1449,12 @@ namespace AMESCoreStudio.Web.Controllers
{ {
model.ngRepairBlob = result5[0]; model.ngRepairBlob = result5[0];
//if (result5[0].ImageName1 != "" && result5[0].ImageName1 != null)
//{
// ViewBag.Image1Url = $"\\REPImage\\" + result5[0].ImageName1;
//}
//else
//{
// ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif";
//}
//if (result5[0].ImageName2 != "" && result5[0].ImageName2 != null)
//{
// ViewBag.Image2Url = $"\\REPImage\\" + result5[0].ImageName2;
//}
//else
//{
// ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif";
//}
//if (result5[0].ImageName3 != "" && result5[0].ImageName3 != null)
//{
// ViewBag.Image3Url = $"\\REPImage\\" + result5[0].ImageName3;
//}
//else
//{
// ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif";
//}
} }
else else
{ {
ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image1Url = REPImagePath + "noimage.jfif";
ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image2Url = REPImagePath + "noimage.jfif";
ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image3Url = REPImagePath + "noimage.jfif";
} }
} }
else else
@ -1484,9 +1462,9 @@ namespace AMESCoreStudio.Web.Controllers
NgRepair ngRepair = new NgRepair(); NgRepair ngRepair = new NgRepair();
model.ngRepair = ngRepair; model.ngRepair = ngRepair;
ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image1Url = REPImagePath + "noimage.jfif";
ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image2Url = REPImagePath + "noimage.jfif";
ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif"; ViewBag.Image3Url = REPImagePath + "noimage.jfif";
} }
} }
@ -1498,6 +1476,7 @@ namespace AMESCoreStudio.Web.Controllers
{ {
IResultModel result; IResultModel result;
var userID = ""; var userID = "";
var REPImagePath = _config["ImagePath:REPImagePath"];
HttpContext.Request.Cookies.TryGetValue("UserID", out userID); HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
int user_id = 0; int user_id = 0;
if (userID != null) if (userID != null)
@ -1516,7 +1495,6 @@ namespace AMESCoreStudio.Web.Controllers
string FileName = string.Empty; string FileName = string.Empty;
string NewName = string.Empty; string NewName = string.Empty;
string FilePath = string.Empty;
if (formFile != null) if (formFile != null)
{ {
@ -1529,8 +1507,7 @@ namespace AMESCoreStudio.Web.Controllers
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱 //為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
NewName = Path.GetRandomFileName() + fileExt; NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名 //指定要寫入的路徑、檔名和副檔名
FilePath = $"\\REPImage\\";//本機目錄 using (var stream = new FileStream(REPImagePath + NewName, FileMode.Create))
using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create))
{ {
await formFile.CopyToAsync(stream); await formFile.CopyToAsync(stream);
} }

181
AMESCoreStudio.Web/Controllers/SPCController.cs

@ -3,11 +3,9 @@ using System.Threading.Tasks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using AMESCoreStudio.Web.Models; using AMESCoreStudio.Web.Models;
using Newtonsoft.Json; using Newtonsoft.Json;
using AMESCoreStudio.WebApi;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;
using AMESCoreStudio.WebApi.Models.AMES; using AMESCoreStudio.WebApi.Models.AMES;
using AMESCoreStudio.WebApi.Models.BAS;
using AMESCoreStudio.CommonTools.Result; using AMESCoreStudio.CommonTools.Result;
using System.IO; using System.IO;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
@ -16,6 +14,7 @@ using AMESCoreStudio.WebApi.DTO.AMES;
using System.Linq; using System.Linq;
using AspNetCore.Reporting; using AspNetCore.Reporting;
using System; using System;
using Microsoft.Extensions.Configuration;
namespace AMESCoreStudio.Web.Controllers namespace AMESCoreStudio.Web.Controllers
{ {
@ -30,8 +29,10 @@ namespace AMESCoreStudio.Web.Controllers
public readonly IPPS _ppsApi; public readonly IPPS _ppsApi;
public readonly IBLL _bllApi; public readonly IBLL _bllApi;
private readonly IWebHostEnvironment _env; private readonly IWebHostEnvironment _env;
private readonly IConfiguration _config;
public SPCController(ILogger<SPCController> logger, ISPC spcApi, IWHS whsApi,IBAS basApi, IPCS pcsApi, ISYS sysApi, IPPS ppsApi, IWebHostEnvironment env, IBLL bllApi) public SPCController(ILogger<SPCController> logger, ISPC spcApi, IWHS whsApi, IBAS basApi,
IPCS pcsApi, ISYS sysApi, IPPS ppsApi, IWebHostEnvironment env, IBLL bllApi, IConfiguration config)
{ {
_logger = logger; _logger = logger;
_spcApi = spcApi; _spcApi = spcApi;
@ -42,6 +43,7 @@ namespace AMESCoreStudio.Web.Controllers
_ppsApi = ppsApi; _ppsApi = ppsApi;
_env = env; _env = env;
_bllApi = bllApi; _bllApi = bllApi;
_config = config;
} }
@ -50,8 +52,6 @@ namespace AMESCoreStudio.Web.Controllers
{ {
var FlagList = new List<SelectListItem>(); var FlagList = new List<SelectListItem>();
FlagList.Add(new SelectListItem("Y", "Y")); FlagList.Add(new SelectListItem("Y", "Y"));
FlagList.Add(new SelectListItem("N", "N")); FlagList.Add(new SelectListItem("N", "N"));
@ -117,7 +117,7 @@ namespace AMESCoreStudio.Web.Controllers
private void GetSideList() private void GetSideList()
{ {
var SideItems = new List<SelectListItem>() ; var SideItems = new List<SelectListItem>();
SideItems.Add(new SelectListItem("N/A", "N/A")); SideItems.Add(new SelectListItem("N/A", "N/A"));
SideItems.Add(new SelectListItem("正面", "正面")); SideItems.Add(new SelectListItem("正面", "正面"));
SideItems.Add(new SelectListItem("背面", "背面")); SideItems.Add(new SelectListItem("背面", "背面"));
@ -141,10 +141,10 @@ namespace AMESCoreStudio.Web.Controllers
StationItems.Add(new SelectListItem("N/A", "0")); StationItems.Add(new SelectListItem("N/A", "0"));
for (int i = 0; i < result.Count; i++) for (int i = 0; i < result.Count; i++)
{ {
if(result[i].UnitNo==unit) if (result[i].UnitNo == unit)
StationItems.Add(new SelectListItem(result[i].StationName, result[i].StationID.ToString())); StationItems.Add(new SelectListItem(result[i].StationName, result[i].StationID.ToString()));
} }
if(StationItems.Count==0) if (StationItems.Count == 0)
StationItems.Add(new SelectListItem("N/A", "")); StationItems.Add(new SelectListItem("N/A", ""));
ViewBag.StationList = StationItems; ViewBag.StationList = StationItems;
@ -164,23 +164,66 @@ namespace AMESCoreStudio.Web.Controllers
ViewBag.FlagList = FlagList; ViewBag.FlagList = FlagList;
} }
/// <summary>
/// 取得登入帳號 廠別代碼
/// </summary>
/// <returns></returns>
private async Task<string> GetLoginFactoryNo()
{
int user_id = -1;
HttpContext.Request.Cookies.TryGetValue("UserID", out string userID);
if (userID != null)
{
if (int.Parse(userID.ToString()) >= 0)
{
user_id = int.Parse(userID.ToString());
var userData = await _sysApi.GetUserData(user_id);
if (userData.Data.Any())
return (string)userData.Data.FirstOrDefault().factoryNo;
}
}
return "";
}
/// <summary>
/// 巡檢類型下拉選項
/// </summary>
/// <returns></returns>
private async Task GetInspectionTypesList() private async Task GetInspectionTypesList()
{ {
var result = await _spcApi.GetInspectionTypes(); var result = await _spcApi.GetInspectionTypes();
var factoryNo = await GetLoginFactoryNo();
var GroupList = new List<SelectListItem>(); var GroupList = new List<SelectListItem>();
if (factoryNo != "YS00")
{
GroupList.Add(new SelectListItem("首件檢查表", "1000"));
}
else
{
for (int i = 0; i < result.Count; i++) for (int i = 0; i < result.Count; i++)
{ {
GroupList.Add(new SelectListItem(result[i].InspectionNo, result[i].InspectionTypeID.ToString())); GroupList.Add(new SelectListItem(result[i].InspectionNo, result[i].InspectionTypeID.ToString()));
} }
}
ViewBag.TypesList = GroupList; ViewBag.TypesList = GroupList;
} }
private async Task GetInspectionFormsList() //yiru modify 2022-09-30
/// <summary>
/// 巡檢表單下拉選項
/// </summary>
/// <returns></returns>
private async Task GetInspectionFormsList()
{ {
var result = await _spcApi.GetInspectionForms(); var result = await _spcApi.GetInspectionForms();
var GroupList = new List<SelectListItem>(); var GroupList = new List<SelectListItem>();
for (int i = 0; i < result.Where(w => w.StatusNo =="Y").ToList().Count; i++) for (int i = 0; i < result.Where(w => w.StatusNo == "Y").ToList().Count; i++)
{ {
GroupList.Add(new SelectListItem(result[i].InspectionName, result[i].InspectionFormID.ToString())); GroupList.Add(new SelectListItem(result[i].InspectionName, result[i].InspectionFormID.ToString()));
} }
@ -241,7 +284,7 @@ namespace AMESCoreStudio.Web.Controllers
UserItems.Add(new SelectListItem("N/A", "-1")); UserItems.Add(new SelectListItem("N/A", "-1"));
foreach (var item in result.Data) foreach (var item in result.Data)
{ {
UserItems.Add(new SelectListItem(item.LoginNo +"_" +item.UserName, item.UserID.ToString())); UserItems.Add(new SelectListItem(item.LoginNo + "_" + item.UserName, item.UserID.ToString()));
} }
ViewBag.UserList = UserItems; ViewBag.UserList = UserItems;
} }
@ -492,7 +535,8 @@ namespace AMESCoreStudio.Web.Controllers
{ {
ModelState.AddModelError("error", result.Msg); ModelState.AddModelError("error", result.Msg);
} }
} } }
}
} }
return View("SPC002C", model); return View("SPC002C", model);
} }
@ -540,9 +584,9 @@ namespace AMESCoreStudio.Web.Controllers
return Json(new Table() { count = 0, data = null }); return Json(new Table() { count = 0, data = null });
} }
[HttpGet] [HttpGet]
public async Task<IActionResult> GetInspectionFormsByQueryAsync(int id,string status) public async Task<IActionResult> GetInspectionFormsByQueryAsync(int id, string status)
{ {
if(id == 0) if (id == 0)
return Json(new Table() { count = 0, data = null }); return Json(new Table() { count = 0, data = null });
var result = await _spcApi.GetInspectionFormsByQuery(id, status); var result = await _spcApi.GetInspectionFormsByQuery(id, status);
@ -571,7 +615,7 @@ namespace AMESCoreStudio.Web.Controllers
//await GetStationListByUnit(unit); //await GetStationListByUnit(unit);
var result = await _spcApi.GetInspectionForm(id); var result = await _spcApi.GetInspectionForm(id);
ViewBag.FormID = result[0].InspectionFormID; ViewBag.FormID = result[0].InspectionFormID;
ViewBag.FormName = "正在新增["+result[0].InspectionName+"]細項"; ViewBag.FormName = "正在新增[" + result[0].InspectionName + "]細項";
await GetUserID(); await GetUserID();
return View(); return View();
} }
@ -706,7 +750,7 @@ namespace AMESCoreStudio.Web.Controllers
{ {
return View(); return View();
} }
var FormResult = await _spcApi.GetInspectionForm(result.Select(s=>s.InspectionFormID).FirstOrDefault()); var FormResult = await _spcApi.GetInspectionForm(result.Select(s => s.InspectionFormID).FirstOrDefault());
ViewBag.FormType = FormResult.Select(s => s.InspectionTypeID).FirstOrDefault(); ; ViewBag.FormType = FormResult.Select(s => s.InspectionTypeID).FirstOrDefault(); ;
@ -723,7 +767,7 @@ namespace AMESCoreStudio.Web.Controllers
[HttpGet] [HttpGet]
public async Task<IActionResult> SPC004UAsync(int id, int Iid) public async Task<IActionResult> SPC004UAsync(int id, int Iid)
{ {
var result = await _spcApi.GetInspectionResultDetailByQuery(id,Iid); var result = await _spcApi.GetInspectionResultDetailByQuery(id, Iid);
var userID = ""; var userID = "";
int user_id = 0; int user_id = 0;
HttpContext.Request.Cookies.TryGetValue("UserID", out userID); HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
@ -759,14 +803,14 @@ namespace AMESCoreStudio.Web.Controllers
var result_Master = await _spcApi.GetInspectionResultMasters(model.InspectionID); var result_Master = await _spcApi.GetInspectionResultMasters(model.InspectionID);
if (result_Master.Count() > 0 ) if (result_Master.Count() > 0)
{ {
model.ReplyReason = model.ReplyReason == null ? model.ReplyReason : model.ReplyReason.Replace("\r\n", "<br />"); model.ReplyReason = model.ReplyReason == null ? model.ReplyReason : model.ReplyReason.Replace("\r\n", "<br />");
model.ReplyMethod = model.ReplyMethod == null ? model.ReplyMethod : model.ReplyMethod.Replace("\r\n", "<br />"); model.ReplyMethod = model.ReplyMethod == null ? model.ReplyMethod : model.ReplyMethod.Replace("\r\n", "<br />");
#region 寄mail 給IPQC_REPLY #region 寄mail 給IPQC_REPLY
string MailGroup = "IPQC_REPLY"; string MailGroup = "IPQC_REPLY";
string Subject = $"[AMES系統通知] ,IPQC巡檢異常回覆通知"; string Subject = $"[AMES系統通知] ,IPQC巡檢異常回覆通知";
string Body = $@"檢驗單號: { result_Master.Select(s=>s.BarcodeNo).FirstOrDefault()} <br /> string Body = $@"檢驗單號: {result_Master.Select(s => s.BarcodeNo).FirstOrDefault()} <br />
: {result_Master.Select(s => s.WipNo).FirstOrDefault()} <br /> : {result_Master.Select(s => s.WipNo).FirstOrDefault()} <br />
: {result_Master.Select(s => s.ItemNo).FirstOrDefault()} <br /> : {result_Master.Select(s => s.ItemNo).FirstOrDefault()} <br />
: <br /> : <br />
@ -857,9 +901,9 @@ namespace AMESCoreStudio.Web.Controllers
var EmailMsg = string.Empty; var EmailMsg = string.Empty;
foreach (var item in stringList) foreach (var item in stringList)
{ {
if( !IsValidEmail(item)) if (!IsValidEmail(item))
{ {
EmailMsg += item +","; EmailMsg += item + ",";
} }
} }
if (!string.IsNullOrEmpty(EmailMsg)) if (!string.IsNullOrEmpty(EmailMsg))
@ -871,10 +915,10 @@ namespace AMESCoreStudio.Web.Controllers
else else
{ {
model.RejectReason = model.RejectReason == null ? model.RejectReason: model.RejectReason.Replace("\r\n", "<br />"); model.RejectReason = model.RejectReason == null ? model.RejectReason : model.RejectReason.Replace("\r\n", "<br />");
#region 寄mail 給IPQC_REPLY #region 寄mail 給IPQC_REPLY
string Subject = $"[AMES系統通知] ,IPQC巡檢異常回覆退回"; string Subject = $"[AMES系統通知] ,IPQC巡檢異常回覆退回";
string Body = $@"檢驗單號: { model.BarcodeNo} <br /> string Body = $@"檢驗單號: {model.BarcodeNo} <br />
: {model.WipNo} <br /> : {model.WipNo} <br />
: {model.ItemNo} <br /> : {model.ItemNo} <br />
退 <br /> {model.RejectReason} <br /> 退 <br /> {model.RejectReason} <br />
@ -917,12 +961,12 @@ namespace AMESCoreStudio.Web.Controllers
[ResponseCache(Duration = 0)] [ResponseCache(Duration = 0)]
[HttpGet] [HttpGet]
public async Task<IActionResult> GetInspectionResultMastersByQueryAsync(string WipNo, string ItemNo, string BarcodeNo,string Status_No) public async Task<IActionResult> GetInspectionResultMastersByQueryAsync(string WipNo, string ItemNo, string BarcodeNo, string Status_No)
{ {
if (string.IsNullOrWhiteSpace(WipNo)) if (string.IsNullOrWhiteSpace(WipNo))
WipNo=" "; WipNo = " ";
if (string.IsNullOrWhiteSpace(ItemNo)) if (string.IsNullOrWhiteSpace(ItemNo))
ItemNo = " "; ItemNo = " ";
if (string.IsNullOrWhiteSpace(BarcodeNo)) if (string.IsNullOrWhiteSpace(BarcodeNo))
@ -940,7 +984,7 @@ namespace AMESCoreStudio.Web.Controllers
return Json(new Table() { count = 0, data = null }); return Json(new Table() { count = 0, data = null });
} }
public async Task<IActionResult> GetInspectionResultDetailQueryAsync(int id ,string Line,string RuleStation,string InspectionResult) public async Task<IActionResult> GetInspectionResultDetailQueryAsync(int id, string Line, string RuleStation, string InspectionResult)
{ {
var result = await _spcApi.GetInspectionResultDetailQuery(id); var result = await _spcApi.GetInspectionResultDetailQuery(id);
@ -1010,10 +1054,11 @@ namespace AMESCoreStudio.Web.Controllers
} }
//新增頁面 //新增頁面
public async Task<IActionResult> SPC005R(int id,int itemID) public async Task<IActionResult> SPC005R(int id, int itemID)
{ {
ViewBag.ItemID = itemID; ViewBag.ItemID = itemID;
ViewBag.MasterID = id; ViewBag.MasterID = id;
ViewBag.FileUploadUrl = _config["ImagePath:FileUploadUrl"];
await GetStationList(); await GetStationList();
return View(); return View();
@ -1039,7 +1084,7 @@ namespace AMESCoreStudio.Web.Controllers
{ {
return View(); return View();
} }
var result1 = await _spcApi.GetInspectionForm(result.Select(s=>s.InspectionFormID).FirstOrDefault()); var result1 = await _spcApi.GetInspectionForm(result.Select(s => s.InspectionFormID).FirstOrDefault());
ViewBag.InspectionTypeID = result1[0].InspectionTypeID; ViewBag.InspectionTypeID = result1[0].InspectionTypeID;
return View(result[0]); return View(result[0]);
} }
@ -1112,20 +1157,23 @@ namespace AMESCoreStudio.Web.Controllers
result = await _spcApi.PostInspectionResultDetail(JsonConvert.SerializeObject(model)); result = await _spcApi.PostInspectionResultDetail(JsonConvert.SerializeObject(model));
if (result.Success) if (result.Success)
{ {
//var _msg = "添加成功!";
return Json(new Result() { success = true, msg = result.Msg }); return Json(new Result() { success = true, msg = result.Msg });
} }
else else
{ {
return Json(new Result() { success = false, msg = "資料有誤!!" }); return Json(new Result() { success = false, msg = "資料有誤!!" });
} }
//return Json(new Result() { success = true, msg = "資料有誤!!" });
} }
public async Task<IActionResult> SPC005RSaveAsync(InspectionResultBlob model, IFormFile formFile) public async Task<IActionResult> SPC005RSaveAsync(InspectionResultBlob model, IFormFile formFile)
{ {
IResultModel result; IResultModel result;
var userID = ""; var userID = "";
//巡檢結果維護的圖片根目錄路徑
var rootFolderPath = _config["ImagePath:RootPath"];
//巡檢結果維護的圖片資料夾
var pcsFileFolder = _config["ImagePath:PCSFilePath"];
HttpContext.Request.Cookies.TryGetValue("UserID", out userID); HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
int user_id = 0; int user_id = 0;
if (userID != null) if (userID != null)
@ -1135,50 +1183,54 @@ namespace AMESCoreStudio.Web.Controllers
user_id = int.Parse(userID.ToString()); user_id = int.Parse(userID.ToString());
} }
} }
model.CreateUserID = user_id; model.CreateUserID = user_id;
model.CreateDate = System.DateTime.Now; model.CreateDate = System.DateTime.Now;
model.UpdateUserID = user_id; model.UpdateUserID = user_id;
model.UpdateDate = System.DateTime.Now; model.UpdateDate = System.DateTime.Now;
string FileName = string.Empty;
string NewName = string.Empty;
string FilePath = string.Empty;
if (formFile != null && formFile.Length > 0)
if (formFile != null)
{
if (formFile.Length > 0)
{ {
//取得使用者上傳檔案的原始檔名 //取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(formFile.FileName); var imageName = Path.GetFileName(formFile.FileName);
//取原始檔名中的副檔名 //取原始檔名中的副檔名
var fileExt = Path.GetExtension(FileName); var fileExt = Path.GetExtension(imageName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱 //為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
NewName = Path.GetRandomFileName() + fileExt; var newName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名 //指定要寫入的路徑、檔名和副檔名
FilePath = $"\\PCSFile\\";//本機目錄 var rootPath = $@"{rootFolderPath}\{pcsFileFolder}";
using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create)) var filePath = $@"\{pcsFileFolder}\";
var path = $@"{rootPath}\{newName}";
if (!System.IO.Directory.Exists(rootPath))
{ {
await formFile.CopyToAsync(stream); try
{
System.IO.Directory.CreateDirectory(rootPath);
}
catch (Exception ex)
{
ModelState.AddModelError("error", $"無法建立路徑: {rootPath}, 錯誤: {ex.Message}");
return BadRequest(ModelState); // 或適當的錯誤處理
}
} }
//var fileProvider = _fileServerProvider.GetProvider("/aa"); using (var stream = new FileStream(path, FileMode.Create))
//var fileInfo = fileProvider.GetFileInfo(formFile.FileName); {
//fileInfo = fileProvider.GetFileInfo(formFile.FileName); await formFile.CopyToAsync(stream);
////遠端目錄 }
//using (var stream = new FileStream(fileInfo.PhysicalPath, FileMode.Create))
//{
// await formFile.CopyToAsync(stream);
model.ImageName = FileName; model.ImageName = imageName;
model.NewName = NewName; model.NewName = newName;
model.FilePath = FilePath;// fileInfo.PhysicalPath; model.FilePath = filePath;
result = await _spcApi.PostInspectionResultBlob(JsonConvert.SerializeObject(model)); result = await _spcApi.PostInspectionResultBlob(JsonConvert.SerializeObject(model));
if (result.Success) if (result.Success)
{ {
//var _msg = "上傳成功!";
ViewBag.ItemID = model.InspectionItemID; ViewBag.ItemID = model.InspectionItemID;
ViewBag.MasterID = model.InspectionID; ViewBag.MasterID = model.InspectionID;
ViewBag.FileUploadUrl = _config["ImagePath:FileUploadUrl"];
return View("SPC005R"); return View("SPC005R");
} }
else else
@ -1186,15 +1238,14 @@ namespace AMESCoreStudio.Web.Controllers
ModelState.AddModelError("error", result.Msg); ModelState.AddModelError("error", result.Msg);
} }
} }
}
else else
{ {
ModelState.AddModelError("error", "請選擇要上傳檔案"); ModelState.AddModelError("error", "請選擇要上傳檔案");
} }
ViewBag.ItemID = model.InspectionItemID; ViewBag.ItemID = model.InspectionItemID;
ViewBag.MasterID = model.InspectionID; ViewBag.MasterID = model.InspectionID;
ViewBag.FileUploadUrl = _config["ImagePath:FileUploadUrl"];
return View("SPC005R"); return View("SPC005R");
} }
@ -1262,14 +1313,12 @@ namespace AMESCoreStudio.Web.Controllers
result = await _spcApi.PutInspectionResultDetail(model.InspectionID, JsonConvert.SerializeObject(model)); result = await _spcApi.PutInspectionResultDetail(model.InspectionID, JsonConvert.SerializeObject(model));
if (result.Success) if (result.Success)
{ {
//var _msg = "添加成功!";
return Json(new Result() { success = true, msg = result.Msg }); return Json(new Result() { success = true, msg = result.Msg });
} }
else else
{ {
return Json(new Result() { success = false, msg = "資料有誤!!" }); return Json(new Result() { success = false, msg = "資料有誤!!" });
} }
//return Json(new Result() { success = true, msg = "資料有誤!!" });
} }
@ -1319,11 +1368,9 @@ namespace AMESCoreStudio.Web.Controllers
return Json(new Table() { count = 0, data = null }); return Json(new Table() { count = 0, data = null });
} }
public async Task<IActionResult> GetInspectionResultMastersByQueryAllAsync(int type,int id, string WipNo, string ItemNo, string BarcodeNo, string StatusNo, string sdate, string edate, int page = 0, int limit = 10) public async Task<IActionResult> GetInspectionResultMastersByQueryAllAsync(int type, int id, string WipNo, string ItemNo, string BarcodeNo, string StatusNo, string sdate, string edate, int page = 0, int limit = 10)
{ {
//yiru 2022-11-17
//if (id == 0)
// return Json(new Table() { count = 0, data = null });
if (string.IsNullOrEmpty(WipNo)) if (string.IsNullOrEmpty(WipNo))
WipNo = "*"; WipNo = "*";
if (string.IsNullOrEmpty(ItemNo)) if (string.IsNullOrEmpty(ItemNo))
@ -1340,7 +1387,7 @@ namespace AMESCoreStudio.Web.Controllers
edate = "*"; edate = "*";
var result = await _spcApi.GetInspectionResultMastersByQueryAll(type, id, WipNo, ItemNo, BarcodeNo, StatusNo, sdate, edate, page , limit ); var result = await _spcApi.GetInspectionResultMastersByQueryAll(type, id, WipNo, ItemNo, BarcodeNo, StatusNo, sdate, edate, page, limit);
if (result.DataTotal > 0) if (result.DataTotal > 0)
@ -1373,7 +1420,7 @@ namespace AMESCoreStudio.Web.Controllers
{ {
foreach (var item in result) foreach (var item in result)
{ {
var Bolbresult= await _spcApi.GetInspectionResultBlobsByQuery(item.InspectionID, item.InspectionItemID); var Bolbresult = await _spcApi.GetInspectionResultBlobsByQuery(item.InspectionID, item.InspectionItemID);
item.Stations.NewCno = Bolbresult.Count(); item.Stations.NewCno = Bolbresult.Count();
} }
return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); return Json(new Table() { code = 0, msg = "", data = result, count = result.Count });
@ -1447,7 +1494,7 @@ namespace AMESCoreStudio.Web.Controllers
/// <param name="id"></param> /// <param name="id"></param>
/// <param name="Types"></param> /// <param name="Types"></param>
/// <returns></returns> /// <returns></returns>
public async Task<IActionResult> SPC005_PDF(int id,string Types) public async Task<IActionResult> SPC005_PDF(int id, string Types)
{ {
string mimeType = ""; string mimeType = "";
int extension = 1; int extension = 1;
@ -1759,7 +1806,7 @@ namespace AMESCoreStudio.Web.Controllers
public async Task<IActionResult> SPC006QueryAsync(string wipNo, string itemNo, int page = 0, int limit = 10) public async Task<IActionResult> SPC006QueryAsync(string wipNo, string itemNo, int page = 0, int limit = 10)
{ {
IResultModel<IPQCTaskNotice> result = await _spcApi.GetIPQCTaskNoticesByQuery(wipNo: wipNo , itemNo: itemNo, page: page, limit: limit); IResultModel<IPQCTaskNotice> result = await _spcApi.GetIPQCTaskNoticesByQuery(wipNo: wipNo, itemNo: itemNo, page: page, limit: limit);
if (result.Data != null) if (result.Data != null)
{ {

62
AMESCoreStudio.Web/Startup.cs

@ -28,7 +28,6 @@ namespace AMESCoreStudio.Web
public IConfiguration Configuration { get; } public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
// ÂX¥RJSON // ÂX¥RJSON
@ -47,33 +46,11 @@ namespace AMESCoreStudio.Web
options.MaxModelBindingCollectionSize = int.MaxValue; options.MaxModelBindingCollectionSize = int.MaxValue;
}); });
// ValidationVisitor exceeded the maximum configured validation depth '32'
services.AddMvc().AddMvcOptions(options => services.AddMvc().AddMvcOptions(options =>
{ {
options.MaxModelValidationErrors = 999999; options.MaxModelValidationErrors = 999999;
}); });
// 郎�ヘ魁
//Add our IFileServerProvider implementation as a singleton
//services.AddSingleton<IFileServerProvider>(new FileServerProvider(
// new List<FileServerOptions>
// {
// new FileServerOptions
// {
// // 龟砰隔畖
// FileProvider = new PhysicalFileProvider(@"\\10.0.8.7\\shop"),
// // 店览隔畖
// RequestPath = new PathString("/aa"),
// EnableDirectoryBrowsing = true
// }
// new FileServerOptions
// {
// FileProvider = new PhysicalFileProvider(@"//qasrv-n/Web/ISOZone/"),
// RequestPath = new PathString("/DocEsop"),
// EnableDirectoryBrowsing = true
// }
// }));
var config = Configuration.Get<VirtualPathConfig>().VirtualPath; var config = Configuration.Get<VirtualPathConfig>().VirtualPath;
var fileServerOptions = new List<FileServerOptions>(); var fileServerOptions = new List<FileServerOptions>();
if (config != null) if (config != null)
@ -93,7 +70,7 @@ namespace AMESCoreStudio.Web
}; };
services.AddSingleton<IFileServerProvider>(new FileServerProvider(fileServerOptions)); services.AddSingleton<IFileServerProvider>(new FileServerProvider(fileServerOptions));
// 配置跨域处理,允许所有来源 // CORS設定
services.AddCors(options => services.AddCors(options =>
options.AddPolicy("AMESPolicy", options.AddPolicy("AMESPolicy",
p => p.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod())); p => p.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()));
@ -104,22 +81,19 @@ namespace AMESCoreStudio.Web
o.ResourcesPath = "Resources"; o.ResourcesPath = "Resources";
}); });
// Add framework services.
//services.AddMvc();
//services.AddMvc().AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix);
services.AddMvc() services.AddMvc()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix) .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization(options => .AddDataAnnotationsLocalization(options =>
{ {
options.DataAnnotationLocalizerProvider = (type, factory) => factory.Create(typeof(SharedResource)); options.DataAnnotationLocalizerProvider = (type, factory) => factory.Create(typeof(SharedResource));
}); });
//services.AddControllersWithViews();
services.AddControllersWithViews().AddRazorRuntimeCompilation(); services.AddControllersWithViews().AddRazorRuntimeCompilation();
//使用Session // Session設定
services.AddSession(); services.AddSession();
// 權限設定
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options => .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
{ {
@ -127,14 +101,11 @@ namespace AMESCoreStudio.Web
options.LogoutPath = new PathString("/Login/Logout"); options.LogoutPath = new PathString("/Login/Logout");
options.AccessDeniedPath = new PathString("/Home/Error"); options.AccessDeniedPath = new PathString("/Home/Error");
options.Cookie.Name = "_AMESCookie"; options.Cookie.Name = "_AMESCookie";
//options.Cookie.SameSite = SameSiteMode.None;
//当Cookie 过期时间已达一半时,是否重置为ExpireTimeSpan
options.SlidingExpiration = true; options.SlidingExpiration = true;
options.Cookie.HttpOnly = true; options.Cookie.HttpOnly = true;
}); });
//添加HttpClient相关 // HttpClient設定
var types = typeof(Startup).Assembly.GetTypes() var types = typeof(Startup).Assembly.GetTypes()
.Where(type => type.IsInterface .Where(type => type.IsInterface
&& ((System.Reflection.TypeInfo)type).ImplementedInterfaces != null && ((System.Reflection.TypeInfo)type).ImplementedInterfaces != null
@ -151,7 +122,6 @@ namespace AMESCoreStudio.Web
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IFileServerProvider fileServerprovider) public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IFileServerProvider fileServerprovider)
{ {
if (env.IsDevelopment()) if (env.IsDevelopment())
@ -161,13 +131,11 @@ namespace AMESCoreStudio.Web
else else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts(); app.UseHsts();
} }
app.UseCors("AMESPolicy"); app.UseCors("AMESPolicy");
//app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
IList<CultureInfo> supportedCultures = new List<CultureInfo> IList<CultureInfo> supportedCultures = new List<CultureInfo>
@ -189,6 +157,28 @@ namespace AMESCoreStudio.Web
app.UseAuthentication(); app.UseAuthentication();
app.UseSession(); app.UseSession();
// VersionCode設定值
app.Use(async (context, next) =>
{
var currentVersion = Configuration["VersionCode"];
var webVersion = context.Request.Cookies["VersionCode"];
if (string.IsNullOrEmpty(context.Request.Cookies["VersionCode"]))
{
context.Response.Cookies.Append("VersionCode", currentVersion);
}
else
{
if ( webVersion != currentVersion)
{
context.Response.ContentType = "text/html; charset=utf-8";
await context.Response.WriteAsync("AMES版本已經更新!!<br>1. 請先關閉所有已經打開的網頁頁籤<br>2. 再重新打開AMES網頁");
}
}
await next.Invoke();
});
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapControllerRoute( endpoints.MapControllerRoute(

34
AMESCoreStudio.Web/Views/FQC/FQC007D.cshtml

@ -1,6 +1,7 @@
@model AMESCoreStudio.WebApi.DTO.AMES.FqcDto @model AMESCoreStudio.WebApi.DTO.AMES.FqcDto
@{ @{
Layout = "~/Views/Shared/_AMESLayout.cshtml"; } Layout = "~/Views/Shared/_AMESLayout.cshtml";
}
<style> <style>
.control-label { .control-label {
@ -65,8 +66,10 @@
</div> </div>
@section Scripts { @section Scripts {
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); @{
await Html.RenderPartialAsync("_FileinputScriptsPartial"); } await Html.RenderPartialAsync("_ValidationScriptsPartial");
await Html.RenderPartialAsync("_FileinputScriptsPartial");
}
<script type="text/javascript"> <script type="text/javascript">
layui.use(['form'], function () { layui.use(['form'], function () {
@ -74,20 +77,28 @@
}); });
//通过行tool編輯,lay-event="show" //預覽
function show(obj) { function show(obj) {
var Path = $(obj).closest("TR").find('span[id*=Filepath]').text();; var Path = $(obj).closest("TR").find('span[id*=Filepath]').text();;
var FileName = $(obj).closest("TR").find('span[id*=FileName]').text();; var FileName = $(obj).closest("TR").find('span[id*=FileName]').text();;
var FileUploadUrl = '@ViewBag.FileUploadUrl';
if(!FileUploadUrl)
{
FileUploadUrl = 'https://ames.avalue.com.tw:9443';
}
console.log('FileName', FileName)
console.log('Path', Path)
console.log('content', FileUploadUrl + Path + FileName)
layui.use('layer', function () { layui.use('layer', function () {
var layer = layui.layer; var layer = layui.layer;
layer.open({ layer.open({
type: 2, type: 2,
title: '預覽文件', title: '預覽文件',
shadeClose: true,//点击遮罩关闭层 shadeClose: true,
shade: 0.8, shade: 0.8,
area: ['90%', '90%'], area: ['90%', '90%'],
zIndex: 19891014, zIndex: 19891014,
content: "../../" + Path + FileName content: FileUploadUrl + Path + FileName
}); });
}); });
}; };
@ -96,7 +107,16 @@
function filedownload(obj) { function filedownload(obj) {
var Path = $(obj).closest("TR").find('span[id*=Filepath]').text(); var Path = $(obj).closest("TR").find('span[id*=Filepath]').text();
var FileName = $(obj).closest("TR").find('span[id*=FileName]').text(); var FileName = $(obj).closest("TR").find('span[id*=FileName]').text();
filePath = `/PCS/FileDownload?Path=${Path}&FileName=${FileName}`; var FileUploadUrl = '@ViewBag.FileUploadUrl';
var RootPath = FileUploadUrl + Path + FileName;
if(!FileUploadUrl)
{
FileUploadUrl = 'https://ames.avalue.com.tw:9443';
}
console.log("FileName",FileName)
console.log("Path", Path)
console.log('RootPath',RootPath)
filePath = `/FQC/FileDownload?fileUrl=${RootPath}`;
$(obj).attr("href", filePath); $(obj).attr("href", filePath);
}; };

10
AMESCoreStudio.Web/Views/FQC/FQC008.cshtml

@ -282,10 +282,12 @@
if (obj.data.inhouseNo) { if (obj.data.inhouseNo) {
hg.open('FQC抽驗作業', '/FQC/FQC007?inhouseNo=' + obj.data.inhouseNo + '&seqID=' + obj.data.seqID, '', '', true); hg.open('FQC抽驗作業', '/FQC/FQC007?inhouseNo=' + obj.data.inhouseNo + '&seqID=' + obj.data.seqID, '', '', true);
var tempwindow = window.open('_blank'); // 先打開頁面 var tempwindow = window.open('_blank'); // SMS異常
tempwindow.location = 'https://sms.avalue.com/SMS/SUP/SFIS_SMS001.aspx?MODEL_NO=' + obj.data.modelNo; tempwindow.location = 'https://sms.avalue.com/SMS/SUP/SFIS_SMS001.aspx?MODEL_NO=' + obj.data.modelNo;
var tempwindow1 = window.open('_blank'); // 先打開頁面 var tempwindow1 = window.open('_blank'); // QAZone異常
tempwindow1.location = 'http://qazone.avalue.com.tw/qazone/sfislinktocfqr.aspx?QF=2&QA_PRDID=' + obj.data.itemNo; tempwindow1.location = 'http://qazone.avalue.com.tw/qazone/sfislinktocfqr.aspx?QF=2&QA_PRDID=' + obj.data.itemNo;
var tempwindow2 = window.open('_blank'); // DOA異常
tempwindow2.location = 'http://10.168.245.119:1234/?productId=' + obj.data.itemNo;
} }
} }
else { else {
@ -308,8 +310,8 @@
tempwindow.location = 'https://sms.avalue.com/SMS/SUP/SFIS_SMS001.aspx?MODEL_NO=' + obj.data.modelNo; tempwindow.location = 'https://sms.avalue.com/SMS/SUP/SFIS_SMS001.aspx?MODEL_NO=' + obj.data.modelNo;
var tempwindow1 = window.open('_blank'); // QAZone異常 var tempwindow1 = window.open('_blank'); // QAZone異常
tempwindow1.location = 'http://qazone.avalue.com.tw/qazone/sfislinktocfqr.aspx?QF=2&QA_PRDID=' + obj.data.itemNo; tempwindow1.location = 'http://qazone.avalue.com.tw/qazone/sfislinktocfqr.aspx?QF=2&QA_PRDID=' + obj.data.itemNo;
var tempwindow1 = window.open('_blank'); // DOA異常 var tempwindow2 = window.open('_blank'); // DOA異常
tempwindow1.location = 'http://10.168.245.119:1234/?productId=' + obj.data.itemNo; tempwindow2.location = 'http://10.168.245.119:1234/?productId=' + obj.data.itemNo;
} }
} }

22
AMESCoreStudio.Web/Views/JIG/JIG004R.cshtml

@ -51,35 +51,27 @@
await Html.RenderPartialAsync("_FileinputScriptsPartial"); } await Html.RenderPartialAsync("_FileinputScriptsPartial"); }
<script type="text/javascript"> <script type="text/javascript">
//layui.use(['form', 'layer', 'laydate'], function () {
// form = layui.form;
//
// form.on('select(Type)', function (data) {
// var data = $("#Type").val();
// getInspectionForms(data);
// });
//
//});
hg.form.onsubmit('asubmit', function (data) { hg.form.onsubmit('asubmit', function (data) {
tt(); tt();
//table && table.reload(data); //table && table.reload(data);
}); });
//通过行tool编辑,lay-event="show" //預覽
function show(obj) { function show(obj) {
layui.use('layer', function () { layui.use('layer', function () {
var layer = layui.layer; var layer = layui.layer;
var FileUploadUrl = '@ViewBag.FileUploadUrl';
if(!FileUploadUrl)
{
FileUploadUrl = 'https://ames.avalue.com.tw:9443';
}
layer.open({ layer.open({
type: 2, type: 2,
title: '預覽文件', title: '預覽文件',
shadeClose: true,//点击遮罩关闭层 shadeClose: true,//点击遮罩关闭层
shade: 0.8, shade: 0.8,
area: ['90%', '90%'], area: ['90%', '90%'],
content: obj.data.filePath + obj.data.newName, //iframe的url content: FileUploadUrl + obj.data.filePath + obj.data.imageName,
zIndex: 19891014, zIndex: 19891014,
//iframe: {
// src:obj.data.filePath + obj.data.newName
//
//}
}); });
}); });

36
AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml

@ -1160,19 +1160,20 @@
alert("TAB"); alert("TAB");
table && table.reload(data); table && table.reload(data);
}); });
////转换静态表格
//table.init('demo', {
// height: 315 //设置高度
// , limit: 10 //注意:请务必确保 limit 参数(默认:10)是与你服务端限定的数据条数一致
// //支持所有基础参数
//});
}); });
//通过行tool编辑,lay-event="show" // 預覽
function show(obj) { function show(obj) {
var Path = $(obj).closest("TR").find('span[id*=Filepath]').text();; var Path = $(obj).closest("TR").find('span[id*=Filepath]').text();
var FileName = $(obj).closest("TR").find('span[id*=FileName]').text();; var FileName = $(obj).closest("TR").find('span[id*=FileName]').text();
var FileUploadUrl = '@ViewBag.FileUploadUrl';
if(!FileUploadUrl)
{
FileUploadUrl = 'https://ames.avalue.com.tw:9443';
}
console.log('FileName', FileName)
console.log('Path', Path)
console.log('content', FileUploadUrl + Path + '/' + FileName)
layui.use('layer', function () { layui.use('layer', function () {
var layer = layui.layer; var layer = layui.layer;
layer.open({ layer.open({
@ -1182,7 +1183,7 @@
shade: 0.8, shade: 0.8,
area: ['90%', '90%'], area: ['90%', '90%'],
zIndex: 19891014, zIndex: 19891014,
content: "../../" + Path + FileName content: FileUploadUrl + Path + '/' + FileName
}); });
}); });
}; };
@ -1191,11 +1192,20 @@
function filedownload(obj) { function filedownload(obj) {
var Path = $(obj).closest("TR").find('span[id*=Filepath]').text(); var Path = $(obj).closest("TR").find('span[id*=Filepath]').text();
var FileName = $(obj).closest("TR").find('span[id*=FileName]').text(); var FileName = $(obj).closest("TR").find('span[id*=FileName]').text();
filePath = `/PCS/FileDownload?Path=${Path}&FileName=${FileName}`; var FileUploadUrl = '@ViewBag.FileUploadUrl';
console.log(filePath); if(!FileUploadUrl)
{
FileUploadUrl = 'https://ames.avalue.com.tw:9443';
}
var RootPath = FileUploadUrl + Path + '/' + FileName;
console.log("FileName",FileName)
console.log("Path", Path)
console.log('RootPath',RootPath)
filePath = `/PCS/FileDownload?fileUrl=${RootPath}`;
$(obj).attr("href", filePath); $(obj).attr("href", filePath);
}; };
var tableCols = [[ var tableCols = [[
{ {
field: 'unitName', field: 'unitName',

68
AMESCoreStudio.Web/Views/PCS/PCS003.cshtml

@ -524,9 +524,18 @@
<label class="layui-form-label">DIP</label> <label class="layui-form-label">DIP</label>
<div class="layui-input-block"> <div class="layui-input-block">
<cl-checkbox asp-items="@ViewBag.GetCheckboxDIP" asp-for="wipBoard.DipSides" asp-skin="defult"></cl-checkbox> <cl-checkbox asp-items="@ViewBag.GetCheckboxDIP" asp-for="wipBoard.DipSides" asp-skin="defult"></cl-checkbox>
<input @if (Model.wipBoard != null) { @(Model.wipBoard.DipCarrier == "Y" ? "checked" : "") } type="checkbox" title="CARRIER" name="wipBoard.DipCarrier" /> <input @if (Model.wipBoard != null)
<input @if (Model.wipBoard != null) { @(Model.wipBoard.DipTape == "Y" ? "checked" : "") } type="checkbox" title="貼付膠帶" name="wipBoard.DipTape" /> {
<input @if (Model.wipBoard != null) { @(Model.wipBoard.DipSolderMask == "Y" ? "checked" : "") } type="checkbox" title="點防焊膠" name="wipBoard.DipSolderMask" /> @(Model.wipBoard.DipCarrier == "Y" ? "checked" : "")
} type="checkbox" title="CARRIER" name="wipBoard.DipCarrier" />
<input @if (Model.wipBoard != null)
{
@(Model.wipBoard.DipTape == "Y" ? "checked" : "")
} type="checkbox" title="貼付膠帶" name="wipBoard.DipTape" />
<input @if (Model.wipBoard != null)
{
@(Model.wipBoard.DipSolderMask == "Y" ? "checked" : "")
} type="checkbox" title="點防焊膠" name="wipBoard.DipSolderMask" />
</div> </div>
</div> </div>
</div> </div>
@ -542,7 +551,10 @@
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">燒錄</label> <label class="layui-form-label">燒錄</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input @if (Model.wipBoard != null) { @(Model.wipBoard.Burn == "Y" ? "checked" : "") } type="checkbox" title="是否燒入" name="wipBoard.Burn" /> <input @if (Model.wipBoard != null)
{
@(Model.wipBoard.Burn == "Y" ? "checked" : "")
} type="checkbox" title="是否燒入" name="wipBoard.Burn" />
</div> </div>
<label class="layui-form-label">燒機位置</label> <label class="layui-form-label">燒機位置</label>
@ -563,7 +575,10 @@
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">零件烘烤</label> <label class="layui-form-label">零件烘烤</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input @if (Model.wipBoard != null) { @(Model.wipBoard.ISPartsBake == "Y" ? "checked" : "") } type="checkbox" title="零件是否需要烘烤" name="wipBoard.ISPartsBake" /> <input @if (Model.wipBoard != null)
{
@(Model.wipBoard.ISPartsBake == "Y" ? "checked" : "")
} type="checkbox" title="零件是否需要烘烤" name="wipBoard.ISPartsBake" />
</div> </div>
<label class="layui-form-label">零件烘烤溫度</label> <label class="layui-form-label">零件烘烤溫度</label>
<div class="layui-input-inline" style="width:100px"> <div class="layui-input-inline" style="width:100px">
@ -576,7 +591,10 @@
</div> </div>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input @if (Model.wipBoard != null) { @(Model.wipBoard.PartsBakeOvertime == "Y" ? "checked" : "") } type="checkbox" title="零件烘烤超過48hrs" name="wipBoard.PartsBakeOvertime" /> <input @if (Model.wipBoard != null)
{
@(Model.wipBoard.PartsBakeOvertime == "Y" ? "checked" : "")
} type="checkbox" title="零件烘烤超過48hrs" name="wipBoard.PartsBakeOvertime" />
</div> </div>
</div> </div>
</div> </div>
@ -592,7 +610,10 @@
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">PCB烘烤</label> <label class="layui-form-label">PCB烘烤</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input @if (Model.wipBoard != null) { @(Model.wipBoard.ISPcbBake == "Y" ? "checked" : "") } type="checkbox" title="PCB是否需要烘烤" name="wipBoard.ISPcbBake" /> <input @if (Model.wipBoard != null)
{
@(Model.wipBoard.ISPcbBake == "Y" ? "checked" : "")
} type="checkbox" title="PCB是否需要烘烤" name="wipBoard.ISPcbBake" />
</div> </div>
<div class="layui-input-inline"> <div class="layui-input-inline">
<select asp-items="@ViewBag.GetPCBBakeTypeSelect" asp-for="wipBoard.PcbBake" class=""></select> <select asp-items="@ViewBag.GetPCBBakeTypeSelect" asp-for="wipBoard.PcbBake" class=""></select>
@ -881,7 +902,10 @@
<div class="layui-input-inline" style="width: 300px;"> <div class="layui-input-inline" style="width: 300px;">
<input class="layui-input" asp-for="wipSystem.OsVer_Desc" readonly="readonly" /> <input class="layui-input" asp-for="wipSystem.OsVer_Desc" readonly="readonly" />
</div> </div>
<input @if (Model.wipSystem != null) { @(Model.wipSystem.Antivirus == "Y" ? "checked" : "") } <input @if (Model.wipSystem != null)
{
@(Model.wipSystem.Antivirus == "Y" ? "checked" : "")
}
type="checkbox" title="T3是否需掃毒" id="wipSystem_Antivirus" name="wipSystem.Antivirus" /> type="checkbox" title="T3是否需掃毒" id="wipSystem_Antivirus" name="wipSystem.Antivirus" />
</div> </div>
</div> </div>
@ -903,7 +927,10 @@
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">FINE_PACKAGE</label> <label class="layui-form-label">FINE_PACKAGE</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input @if (Model.wipSystem != null) { @(Model.wipSystem.FinePackage == "Y" ? "checked" : "") } type="checkbox" title="是否為精裝" name="wipSystem.FinePackage" /> <input @if (Model.wipSystem != null)
{
@(Model.wipSystem.FinePackage == "Y" ? "checked" : "")
} type="checkbox" title="是否為精裝" name="wipSystem.FinePackage" />
</div> </div>
</div> </div>
</div> </div>
@ -1460,10 +1487,18 @@
}); });
}); });
//通过行tool编辑,lay-event="show" // 檔案預覽
function show(obj) { function show(obj) {
var Path = $(obj).closest("TR").find('span[id*=Filepath]').text();; var Path = $(obj).closest("TR").find('span[id*=Filepath]').text();
var FileName = $(obj).closest("TR").find('span[id*=FileName]').text();; var FileName = $(obj).closest("TR").find('span[id*=FileName]').text();
var FileUploadUrl = '@ViewBag.FileUploadUrl';
if(!FileUploadUrl)
{
FileUploadUrl = 'https://ames.avalue.com.tw:9443';
}
console.log("Path", Path)
console.log("FileName", FileName)
console.log("content", FileUploadUrl + Path + "/" + FileName)
layui.use('layer', function () { layui.use('layer', function () {
var layer = layui.layer; var layer = layui.layer;
layer.open({ layer.open({
@ -1473,7 +1508,7 @@
shade: 0.8, shade: 0.8,
area: ['90%', '90%'], area: ['90%', '90%'],
zIndex: 19891014, zIndex: 19891014,
content: "../../" + Path + FileName content: FileUploadUrl + Path + "/" + FileName
}); });
}); });
}; };
@ -1482,7 +1517,12 @@
function filedownload(obj) { function filedownload(obj) {
var Path = $(obj).closest("TR").find('span[id*=Filepath]').text(); var Path = $(obj).closest("TR").find('span[id*=Filepath]').text();
var FileName = $(obj).closest("TR").find('span[id*=FileName]').text(); var FileName = $(obj).closest("TR").find('span[id*=FileName]').text();
filePath = `/PCS/FileDownload?Path=${Path}&FileName=${FileName}`; var FileUploadUrl = '@ViewBag.FileUploadUrl';
var RootPath = FileUploadUrl + Path + "/" + FileName;
console.log("Path", Path)
console.log("FileName", FileName)
console.log("RootPath", RootPath)
filePath = `/PCS/FileDownload?fileUrl=${RootPath}`;
$(obj).attr("href", filePath); $(obj).attr("href", filePath);
}; };

37
AMESCoreStudio.Web/Views/PCS/PCS005.cshtml

@ -77,28 +77,20 @@
</div> </div>
</div> </div>
@section Scripts{ @section Scripts {
<script type="text/javascript"> <script type="text/javascript">
layui.use('table', function () { layui.use('table', function () {
form = layui.form; form = layui.form;
form.on('select(unit)', function (data) { form.on('select(unit)', function (data) {
$("#unitNo").val(data.value); $("#unitNo").val(data.value);
//roleName = data.elem[data.elem.selectedIndex].text;
var qs = $('button[lay-filter="querysubmit"]'); var qs = $('button[lay-filter="querysubmit"]');
qs.click(); qs.click();
//hg.msghide("刷新数据!");
//table && table.reload();
}); });
form.on('select(statusNo)', function (data) { form.on('select(statusNo)', function (data) {
//roleName = data.elem[data.elem.selectedIndex].text;
var qs = $('button[lay-filter="querysubmit"]'); var qs = $('button[lay-filter="querysubmit"]');
qs.click(); qs.click();
//hg.msghide("刷新数据!");
//table && table.reload();
}); });
var table = layui.table; var table = layui.table;
@ -164,9 +156,10 @@
templet: '<div>{{ layui.util.toDateString(d.wipScheduleDate, "yyyy/MM/dd") }}</div>' templet: '<div>{{ layui.util.toDateString(d.wipScheduleDate, "yyyy/MM/dd") }}</div>'
}, },
{ {
field: 'workDate', field: 'startDate',
title: '開工日', title: '開工日',
sort: true sort: true,
templet: '<div>{{ layui.util.toDateString(d.startDate, "yyyy/MM/dd") }}</div>'
}, },
{ {
field: 'wipDueDate', field: 'wipDueDate',
@ -180,8 +173,10 @@
templet: '#statusNoName' templet: '#statusNoName'
}, },
{ {
field: 'fqcDate', field: 'fqcClearDate',
title: '檢驗完成日' title: '檢驗完成日',
sort: true,
templet: '<div>{{ layui.util.toDateString(d.fqcClearDate, "yyyy/MM/dd") }}</div>'
}, },
{ {
field: 'right', field: 'right',
@ -233,23 +228,7 @@
}); });
} }
//var toolbar = [{
// text: '新增',
// layuiicon: '&#xe608;',
// class: 'layui-btn-normal',
// handler: function () {
// hg.open('新增工單資料', '/PCS/PCS001', '', '', true);
// }
//}
//];
//基本数据表格
//alert(factoryNo.value);
//alert(unitNo.value);
//alert(wipNo.value);
//alert(itemNo.value);
var param = unitNo.value + '_' + wipNo.value + '_' + itemNo.value + '_' + factoryNo.value; var param = unitNo.value + '_' + wipNo.value + '_' + itemNo.value + '_' + factoryNo.value;
//alert(param);
var table = hg.table.datatable('query', '工單資料查詢', '/PCS/PCS005Query/' + param, {}, tableCols, {}, true, 'full-100', ['filter', 'print', 'exports']); var table = hg.table.datatable('query', '工單資料查詢', '/PCS/PCS005Query/' + param, {}, tableCols, {}, true, 'full-100', ['filter', 'print', 'exports']);
$(document).off('mousedown', '.layui-table-grid-down'). $(document).off('mousedown', '.layui-table-grid-down').

6
AMESCoreStudio.Web/Views/PCS/PCS009R.cshtml

@ -345,6 +345,9 @@
<table class="layui-table" lay-even lay-size="sm"> <table class="layui-table" lay-even lay-size="sm">
<thead> <thead>
<tr> <tr>
<th>
工單號碼
</th>
<th> <th>
站別名稱 站別名稱
</th> </th>
@ -369,6 +372,9 @@
@foreach (var index in Model.BarCodeKPs) @foreach (var index in Model.BarCodeKPs)
{ {
<tr> <tr>
<td>
@index.WipNo
</td>
<td> <td>
@index.StationName @index.StationName
</td> </td>

68
AMESCoreStudio.Web/Views/PCS/PCS021.cshtml

@ -361,7 +361,7 @@
</form> </form>
</div> </div>
@section Scripts{ @section Scripts {
@{ @{
await Html.RenderPartialAsync("_ValidationScriptsPartial"); await Html.RenderPartialAsync("_ValidationScriptsPartial");
await Html.RenderPartialAsync("_FileinputScriptsPartial"); await Html.RenderPartialAsync("_FileinputScriptsPartial");
@ -390,17 +390,7 @@
else else
{ {
<text>$("#Memo").hide(); </text> <text>$("#Memo").hide(); </text>
} } });
////if (!string.IsNullOrWhiteSpace(Model.KpItemName))
//{
// <text>$("#KpItemDiv").show(); </text>
//}
//else
//{
// <text>$("#KpItemDiv").hide(); </text>
//}
});
// Jquery 將兩邊DIV設定同高度 // Jquery 將兩邊DIV設定同高度
jQuery(function ($) { jQuery(function ($) {
@ -441,9 +431,6 @@
if (e.keyCode == 13) { if (e.keyCode == 13) {
var Inputs = GetAllEmpData(); var Inputs = GetAllEmpData();
var data = $("#PCS021Form").serialize(); var data = $("#PCS021Form").serialize();
//$.each(Inputs, function (i, item) {
// data += "&Inputs[" + i + "]=" + item;
//});
var InputsTotal = Inputs.length; var InputsTotal = Inputs.length;
for (i = 0; i < InputsTotal; i++) { for (i = 0; i < InputsTotal; i++) {
data += "&Inputs[" + i + "].Input=" + Inputs[i].Input; data += "&Inputs[" + i + "].Input=" + Inputs[i].Input;
@ -475,9 +462,13 @@
} }
// 回傳有值 // 回傳有值
else if (result.data.length != 0) { else if (result.data.length != 0) {
var checkData = CheckData(result.data)
if (checkData != "DuplicateData") {
// 新增資料 // 新增資料
TableAddRow(result.data); TableAddRow(result.data);
} }
}
else { else {
$("#tblCustomersBody").empty(); $("#tblCustomersBody").empty();
InputQty(); InputQty();
@ -541,35 +532,18 @@
'<td><a class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" onclick="Remove(this);">刪除</a></td>' + '<td><a class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" onclick="Remove(this);">刪除</a></td>' +
'</tr>'; '</tr>';
$('#tblCustomers').append(contactdiv); $('#tblCustomers').append(contactdiv);
AutoWindowSize(); //AutoWindowSize();
}; };
// Table 刪除 // Table 刪除
function Remove(button) { function Remove(button) {
//Determine the reference of the Row using the Button.
var row = $(button).closest("TR"); var row = $(button).closest("TR");
var table = $("#tblCustomers")[0]; var table = $("#tblCustomers")[0];
table.deleteRow(row[0].rowIndex); table.deleteRow(row[0].rowIndex);
//var name = $("TD", row).eq(0).html();
//if (confirm("Do you want to delete: " + name)) {
// //Get the reference of the Table.
// var table = $("#tblCustomers")[0];
// //Delete the Table row using it's Index.
// table.deleteRow(row[0].rowIndex);
//}
}; };
// 紀錄表格欄位 // 紀錄表格欄位
function GetAllEmpData() { function GetAllEmpData() {
// 單筆
//var data = [];
//$('tr.data-contact-person').each(function () {
// var firstName = $(this).find('.td-Input').val();
// data.push(firstName);
//});
//return data;
var data = []; var data = [];
$('tr.data-contact-person').each(function () { $('tr.data-contact-person').each(function () {
var Input = $(this).find('.td-Input').val(); var Input = $(this).find('.td-Input').val();
@ -579,14 +553,29 @@
return data; return data;
} }
//檢查輸入的值是否有重複
function CheckData(InputData) {
var Rowdata = []; // 初始化存儲行數據的陣列
// 遍歷每一個動態行,提取 Input 和 InputNo
$('tr.data-contact-person').each(function () {
var RowInput = $(this).find('.td-Input').val(); // 獲取當前行的 Input
var RowInputNo = $(this).find('.td-InputNo').val(); // 獲取當前行的 InputNo
Rowdata.push({ Input: RowInput, InputNo: RowInputNo }); // 添加到 Rowdata
});
// 檢查是否有重複的 Input
if (Rowdata.some(item => item.Input === InputData)) {
ShowInputError("刷讀條碼輸入重複的值" + InputData);
return "DuplicateData";
}
return "Data";
}
function AutoWindowSize() { function AutoWindowSize() {
$(window).on('resize', function () { $(window).on('resize', function () {
//AdminInit();
//var $content = $('#nav_xbs_tab .layui-tab-content');
//$content.height($(this).height() - 125);
//$content.find('iframe').each(function () {
// $(this).height($content.height());
//});
}).resize(); }).resize();
} }
@ -608,7 +597,6 @@
var next = layfull.next(); var next = layfull.next();
if (next.length > 0) { if (next.length > 0) {
setTimeout(function () { setTimeout(function () {
//console.log(next.height());
if (next.height() === 99) { if (next.height() === 99) {
hgfull(); hgfull();
return false; return false;

144
AMESCoreStudio.Web/Views/PCS/PCS041C.cshtml

@ -13,7 +13,6 @@
<div class="layui-card"> <div class="layui-card">
<form enctype="multipart/form-data" method="post" asp-action="PCS041CSave" class="layui-form"> <form enctype="multipart/form-data" method="post" asp-action="PCS041CSave" class="layui-form">
<div asp-validation-summary="ModelOnly" class="text-danger"></div> <div asp-validation-summary="ModelOnly" class="text-danger"></div>
@*<fieldset class="layui-elem-field layui-field-title">*@
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-inline"> <div class="layui-inline">
@ -26,13 +25,11 @@
<div class="layui-input-inline" style="width:150px"> <div class="layui-input-inline" style="width:150px">
<select id="Station" lay-filter="unit" name="Station" asp-for="Station" lay-submit asp-items="@ViewBag.GetStationList"> <select id="Station" lay-filter="unit" name="Station" asp-for="Station" lay-submit asp-items="@ViewBag.GetStationList">
</select> </select>
@*<input id="unitNo" type="hidden" name="unitNo" value="@ViewBag.UnitNo" />*@
</div> </div>
<label class="layui-form-label">產品類型:</label> <label class="layui-form-label">產品類型:</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<select name="TypeID" id="TypeID" asp-for="TypeID" class="custom-select col-sm-2"> <select name="TypeID" id="TypeID" asp-for="TypeID" class="custom-select col-sm-2">
@*<option value="0">全部</option>*@
<option value="1">單板</option> <option value="1">單板</option>
<option value="2">系統</option> <option value="2">系統</option>
<option value="3">醫療</option> <option value="3">醫療</option>
@ -48,12 +45,8 @@
</div> </div>
<label class="layui-form-label">問題描述:</label> <label class="layui-form-label">問題描述:</label>
<textarea id="description" name="description" class="layui-textarea" placeholder="請輸入問題描述" asp-for ="Description"></textarea> <textarea id="description" name="description" class="layui-textarea" placeholder="請輸入問題描述" asp-for="Description"></textarea>
@*<label class="layui-form-label">生產注意事項說明:</label>
<textarea id="processDescription" name="processDescription" class="layui-textarea" placeholder="請輸入生產注意事項說明"></textarea>*@
</div> </div>
@*</div>*@
@*</fieldset>*@
<span style="color:red">**預覽只能顯示圖檔、PDF、文字檔**</span> <span style="color:red">**預覽只能顯示圖檔、PDF、文字檔**</span>
<div class="layui-form-item"> <div class="layui-form-item">
<table lay-filter="demo" class="layui-table" id="ImageTable"> <table lay-filter="demo" class="layui-table" id="ImageTable">
@ -95,7 +88,6 @@
<input type="file" name="formFile"> <input type="file" name="formFile">
</label> </label>
<input type="hidden" asp-for="Image.Filename"> <input type="hidden" asp-for="Image.Filename">
@*<input type="hidden" asp-for="Images" value=@Model.Images>*@
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
@ -105,48 +97,13 @@
</div> </div>
</div> </div>
<input id="PPID" asp-for="PPID" type="hidden" value="@Model.PPID" /> <input id="PPID" asp-for="PPID" type="hidden" value="@Model.PPID" />
<!--<div class="layui-form-item">
<div style="text-align:center">-->
@*<button class="layui-btn" id="uploadButton" type="button">上傳圖片</button>*@
<!--<input type="submit" value="保存" name="action" class="layui-btn" />
</div>
</div>-->
@*<table class="layui-hide" id="imageTable" lay-filter="imageTable"></table>*@
<span style="color: firebrick;word-break: break-all;" class="text-danger offset-sm-3">@Html.ValidationMessage("error")</span> <span style="color: firebrick;word-break: break-all;" class="text-danger offset-sm-3">@Html.ValidationMessage("error")</span>
<div class="layui-form-item"> <div class="layui-form-item">
<div style="text-align:center"> <div style="text-align:center">
<input type="submit" value="儲存" name="action" class="layui-btn" /> <input type="submit" value="儲存" name="action" class="layui-btn" />
</div> </div>
</div> </div>
</form> </form>
@*<form id="PCS041CSaveImage" enctype="multipart/form-data" method="post" asp-action="PCS041CSaveImage" class="layui-form">
</form>*@
@*<form class="layui-form2" lay-filter="uploadForm">
<div class="layui-form" id="imageUploadForm" style="margin-top: 20px;">
<div class="layui-form-item">
<div class="layui-upload">
<button type="button" class="layui-btn" id="selectImage">選擇圖片</button>
<div class="layui-upload-list">
<img class="layui-upload-img" id="imagePreview">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">圖片描述:</label>
<div class="layui-input-block">
<textarea class="layui-textarea" id="imageDescription" placeholder="請輸入圖片描述"></textarea>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" id="uploadButton" lay-filter="uploadForm">上傳圖片</button>
</div>
</div>
</div>
</form>*@
</div> </div>
@section Scripts { @section Scripts {
@ -156,80 +113,21 @@
}); });
layui.use('table', function () { layui.use('table', function () {
form = layui.form; form = layui.form;
//form.on('select(unit)', function (data) {
// $("#unitNo").val(data.value);
// //roleName = data.elem[data.elem.selectedIndex].text;
// var qs = $('button[lay-filter="querysubmit"]');
// qs.click();
// //hg.msghide("刷新数据!");
// //table && table.reload();
//});
var table = layui.table; var table = layui.table;
}); });
//layui.use(['upload', 'form'], function () {
// var upload = layui.upload;
// var form = layui.form;
// var uploadInst = upload.render({
// elem: '#selectImage',
// //url: '/api/ImageUpload/upload',
// auto: false,
// choose: function (obj) {
// obj.preview(function (index, file, result) {
// $('#imagePreview').attr('src', result);
// });
// }
// });
//// 监听上传按钮点击事件
//$('#uploadButton').on('click', function () {
// var file = document.querySelector('input[type=file]').files[0];
// var description = $('#imageDescription').val();
// if (file && description) { // 預覽
// var formData = new FormData();
// formData.append('file', file);
// formData.append('description', description);
// // 提交图片和描述数据到后端
// $.ajax({
// url: '/PCS/PCS041CSaveImage',
// type: 'POST',
// data: formData,
// processData: false,
// contentType: false,
// success: function (res) {
// // 假設 response 是從後端返回的 JSON 物件,包含要更新的資料
// var tableBody = $('#ImageTable tbody'); // 取得表格的 tbody 元素
// tableBody.empty();
// // 更新表格內容
// response.forEach(function(item) {
// var newRow = '<tr>' +
// '<td><span>' + item.Filename + '</span></td>' +
// '<td><span>' + item.FilePath + '</span></td>' +
// '<td><span>' + item.Description + '</span></td>' +
// '<td>' +
// '<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-read" onclick="show(this)">預覽</a>' +
// '<a class="layui-btn layui-btn-normal layui-btn-xs" onclick="filedownload(this)">下載</a>' +
// '<a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-danger" onclick="deleteFile(this)">刪除</a>' +
// '</td>' +
// '</tr>';
// tableBody.append(newRow);
// });
// },
// error: function (err) {
// console.error(err); // 处理上传失败的情况
// layer.msg('上传失败,请重试');
// }
// });
// } else {
// layer.msg('请先选择图片并输入描述');
// }
//});
//通过行tool编辑,lay-event="show"
function show(obj) { function show(obj) {
var Path = $(obj).closest("TR").find('span[id*=FilePath]').text();; var Path = $(obj).closest("TR").find('span[id*=FilePath]').text();
var FileName = $(obj).closest("TR").find('span[id*=Filename]').text();; var FileName = $(obj).closest("TR").find('span[id*=Filename]').text();
var FileUploadUrl = '@ViewBag.FileUploadUrl';
if(!FileUploadUrl)
{
FileUploadUrl = 'https://ames.avalue.com.tw:9443';
}
console.log('FileName', FileName)
console.log('Path', Path)
console.log('content', FileUploadUrl + '/' + Path + '/' + FileName)
layui.use('layer', function () { layui.use('layer', function () {
var layer = layui.layer; var layer = layui.layer;
layer.open({ layer.open({
@ -239,8 +137,7 @@
shade: 0.8, shade: 0.8,
area: ['90%', '90%'], area: ['90%', '90%'],
zIndex: 19891014, zIndex: 19891014,
content: "/PCS/PCS041GetImage?path="+ Path + FileName content: FileUploadUrl + '/' + Path + '/' + FileName
/*content: "../../" + Path + FileName*/
}); });
}); });
}; };
@ -249,7 +146,16 @@
function filedownload(obj) { function filedownload(obj) {
var Path = $(obj).closest("TR").find('span[id*=FilePath]').text(); var Path = $(obj).closest("TR").find('span[id*=FilePath]').text();
var FileName = $(obj).closest("TR").find('span[id*=Filename]').text(); var FileName = $(obj).closest("TR").find('span[id*=Filename]').text();
filePath = `/PCS/PCS041FileDownload?Path=${Path}&FileName=${FileName}`; var FileUploadUrl = '@ViewBag.FileUploadUrl';
if(!FileUploadUrl)
{
FileUploadUrl = 'https://ames.avalue.com.tw:9443';
}
var RootPath = FileUploadUrl +'/'+ Path + '/' + FileName;
console.log("FileName",FileName)
console.log("Path", Path)
console.log('RootPath',RootPath)
filePath = `/PCS/FileDownload?fileUrl=${RootPath}`;
$(obj).attr("href", filePath); $(obj).attr("href", filePath);
}; };
@ -326,7 +232,6 @@
field: 'picture', field: 'picture',
title: '圖片', title: '圖片',
}, },
{ {
field: 'createUser', field: 'createUser',
@ -373,7 +278,6 @@
}; };
//关闭弹出层 //关闭弹出层
if ('@ViewBag.Msg' != '') { if ('@ViewBag.Msg' != '') {
//hg.close();
hg.msg('@ViewBag.Msg'); hg.msg('@ViewBag.Msg');
} }
}); });

8
AMESCoreStudio.Web/Views/PTD/PTD002.cshtml

@ -108,13 +108,13 @@
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-inline" style="margin-right: 100px;"> <div class="layui-inline" style="margin-right: 100px;">
<label class="layui-form-label">資料群組:</label> <label class="layui-form-label">資料群組:</label>
<input type="radio" name="StockUnit" value="1" title="Box No(安勤或昶亨生產)" lay-filter="radio-filter" checked /> @* <input type="radio" name="StockUnit" value="1" title="Box No(安勤或昶亨生產)" lay-filter="radio-filter" /> *@
<input type="radio" name="StockUnit" value="0" title="PCS" lay-filter="radio-filter" /> <input type="radio" name="StockUnit" value="0" title="PCS" lay-filter="radio-filter" checked />
</div> </div>
<div class="layui-inline" style="margin-right: 150px;"> <div class="layui-inline" style="margin-right: 150px;">
<div class="layui-input-inline" style="width:100px"> <div class="layui-input-inline" style="width:100px">
<input type="checkbox" id="PCSUnit" lay-skin="primary" title="單筆輸入" lay-filter="check-filter" disabled /> <input type="checkbox" id="PCSUnit" lay-skin="primary" title="單筆輸入" lay-filter="check-filter" />
</div> </div>
</div> </div>
</div> </div>
@ -474,7 +474,7 @@
var loginNo = document.getElementById('loginNo').value; var loginNo = document.getElementById('loginNo').value;
var tableData = layui.table.cache['query']; var tableData = layui.table.cache['query'];
console.log("tableData",tableData)
if (material === "") { if (material === "") {
hg.msg('料號不得為空!'); hg.msg('料號不得為空!');
return; // Do not add the row return; // Do not add the row

4
AMESCoreStudio.Web/Views/PTD/PTD002Old.cshtml

@ -108,13 +108,13 @@
<div class="layui-inline" style="margin-right: 100px;"> <div class="layui-inline" style="margin-right: 100px;">
<label class="layui-form-label">資料群組:</label> <label class="layui-form-label">資料群組:</label>
<input type="radio" name="StockUnit" id="box" value="1" title="Box No(安勤或昶亨生產)" lay-filter="radio-filter" checked /> @* <input type="radio" name="StockUnit" id="box" value="1" title="Box No(安勤或昶亨生產)" lay-filter="radio-filter" /> *@
<input type="radio" name="StockUnit" id="pcs" value="0" title="PCS" lay-filter="radio-filter" /> <input type="radio" name="StockUnit" id="pcs" value="0" title="PCS" lay-filter="radio-filter" />
</div> </div>
<div class="layui-inline" style="margin-right: 150px;"> <div class="layui-inline" style="margin-right: 150px;">
<div class="layui-input-inline" style="width:100px"> <div class="layui-input-inline" style="width:100px">
<input type="checkbox" id="PCSUnit" lay-skin="primary" title="單筆輸入" lay-filter="check-filter" disabled /> <input type="checkbox" id="PCSUnit" lay-skin="primary" title="單筆輸入" lay-filter="check-filter" />
</div> </div>
</div> </div>
</div> </div>

6
AMESCoreStudio.Web/Views/PTD/PTD006.cshtml

@ -100,13 +100,13 @@
<div class="layui-inline" style="margin-right: 100px;"> <div class="layui-inline" style="margin-right: 100px;">
<label class="layui-form-label">資料群組:</label> <label class="layui-form-label">資料群組:</label>
<input type="radio" name="StockUnit" id="box" value="1" title="Box No(安勤或昶亨生產)" lay-filter="radio-filter" checked /> @* <input type="radio" name="StockUnit" id="box" value="1" title="Box No(安勤或昶亨生產)" lay-filter="radio-filter" /> *@
<input type="radio" name="StockUnit" id="pcs" value="0" title="PCS" lay-filter="radio-filter" /> <input type="radio" name="StockUnit" id="pcs" value="0" title="PCS" lay-filter="radio-filter" checked />
</div> </div>
<div class="layui-inline" style="margin-right: 150px;"> <div class="layui-inline" style="margin-right: 150px;">
<div class="layui-input-inline" style="width:100px"> <div class="layui-input-inline" style="width:100px">
<input type="checkbox" id="PCSUnit" lay-skin="primary" title="單筆輸入" lay-filter="check-filter" disabled /> <input type="checkbox" id="PCSUnit" lay-skin="primary" title="單筆輸入" lay-filter="check-filter" />
</div> </div>
</div> </div>
</div> </div>

4
AMESCoreStudio.Web/Views/PTD/PTD006Old.cshtml

@ -100,13 +100,13 @@
<div class="layui-inline" style="margin-right: 100px;"> <div class="layui-inline" style="margin-right: 100px;">
<label class="layui-form-label">資料群組:</label> <label class="layui-form-label">資料群組:</label>
<input type="radio" name="StockUnit" id="box" value="1" title="Box No(安勤或昶亨生產)" lay-filter="radio-filter" checked /> @* <input type="radio" name="StockUnit" id="box" value="1" title="Box No(安勤或昶亨生產)" lay-filter="radio-filter" /> *@
<input type="radio" name="StockUnit" id="pcs" value="0" title="PCS" lay-filter="radio-filter" /> <input type="radio" name="StockUnit" id="pcs" value="0" title="PCS" lay-filter="radio-filter" />
</div> </div>
<div class="layui-inline" style="margin-right: 150px;"> <div class="layui-inline" style="margin-right: 150px;">
<div class="layui-input-inline" style="width:100px"> <div class="layui-input-inline" style="width:100px">
<input type="checkbox" id="PCSUnit" lay-skin="primary" title="單筆輸入" lay-filter="check-filter" disabled /> <input type="checkbox" id="PCSUnit" lay-skin="primary" title="單筆輸入" lay-filter="check-filter" />
</div> </div>
</div> </div>
</div> </div>

8
AMESCoreStudio.Web/Views/QRS/QRS014.cshtml

@ -130,7 +130,13 @@
var dateStart = $("#dateStart").val(); var dateStart = $("#dateStart").val();
var dateEnd = $("#dateEnd").val(); var dateEnd = $("#dateEnd").val();
var modelNO = $("#modelNO").val(); var modelNO = $("#modelNO").val();
if(dateStart == "" ) {
layer.alert('請選擇開始日期', {icon: 2});
return;
}else if (dateEnd == ""){
layer.alert('請選擇結束日期', {icon: 2});
return;
}
var query = "?unitNo=" + unitNo + "&werksNo=" + werksNo + "&itemNO=" + itemNO + "&wipNO=" + wipNO + "&dateStart=" + dateStart + "&dateEnd=" + dateEnd + "&modelNO=" + modelNO + "&dateType=" + date_type; var query = "?unitNo=" + unitNo + "&werksNo=" + werksNo + "&itemNO=" + itemNO + "&wipNO=" + wipNO + "&dateStart=" + dateStart + "&dateEnd=" + dateEnd + "&modelNO=" + modelNO + "&dateType=" + date_type;
hg.open('直通率', '/QRS/QRS014A' + query, '', '', true); hg.open('直通率', '/QRS/QRS014A' + query, '', '', true);

7
AMESCoreStudio.Web/Views/QRS/QRS028A.cshtml

@ -34,7 +34,6 @@
table && table.reload(data); table && table.reload(data);
}); });
var tableCols1 = [[ var tableCols1 = [[
{ {
field: 'wipNO', field: 'wipNO',
@ -79,6 +78,12 @@
title: '執行狀態', title: '執行狀態',
width: 80 width: 80
}, },
{
field: 'startDate',
width: 160,
title: '進站時間',
templet: '<div>{{ layui.util.toDateString(d.createDate, "yyyy/MM/dd HH:mm:ss") }}</div>'
},
{ {
field: 'inputDateHMS', field: 'inputDateHMS',
width: 160, width: 160,

155
AMESCoreStudio.Web/Views/REP/REP001R.cshtml

@ -333,12 +333,10 @@
<label asp-for="NgKeypart.OldPartNo" class="layui-form-label"></label> <label asp-for="NgKeypart.OldPartNo" class="layui-form-label"></label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input id="txtOldPartNo" asp-for="NgKeypart.OldPartNo" class="layui-input" /> <input id="txtOldPartNo" asp-for="NgKeypart.OldPartNo" class="layui-input" />
@*<span asp-validation-for="NgKeypart.OldPartNo" class="layui-bg-red"></span>*@
</div> </div>
<label asp-for="NgKeypart.NewPartNo" class="layui-form-label"></label> <label asp-for="NgKeypart.NewPartNo" class="layui-form-label"></label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input id="txtNewPartNo" asp-for="NgKeypart.NewPartNo" class="layui-input" /> <input id="txtNewPartNo" asp-for="NgKeypart.NewPartNo" class="layui-input" />
@*<span asp-validation-for="NgKeypart.NewPartNo" class="layui-bg-red"></span>*@
</div> </div>
<button type="button" id="btnKeypartInsert" class="layui-btn">新增</button>&nbsp;&nbsp; <button type="button" id="btnKeypartInsert" class="layui-btn">新增</button>&nbsp;&nbsp;
@ -373,13 +371,6 @@
<select id="responsible" lay-filter="responsible" lay-verify="required" asp-for="ngRepair.RepairResponsibleID" asp-items="@ViewBag.RepairResponsibleUnitList" class=""></select> <select id="responsible" lay-filter="responsible" lay-verify="required" asp-for="ngRepair.RepairResponsibleID" asp-items="@ViewBag.RepairResponsibleUnitList" class=""></select>
<span asp-validation-for="ngRepair.RepairResponsibleID" class="layui-bg-red"></span> <span asp-validation-for="ngRepair.RepairResponsibleID" class="layui-bg-red"></span>
</div> </div>
<!--
<label asp-for="ngRepair.RmaNo" class="layui-form-label"></label>
<div class="layui-input-inline">
<input asp-for="ngRepair.RmaNo" class="layui-input" autocomplete="off" />
<span asp-validation-for="ngRepair.RmaNo" class="layui-bg-red"></span>
</div>
-->
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
@ -400,7 +391,6 @@
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-btn"> <label class="layui-btn">
<input type="file" name="formFile" multiple> <input type="file" name="formFile" multiple>
@*<i class="layui-icon">&#xe67c;</i>上傳文件*@
</label> </label>
</div> </div>
</div> </div>
@ -452,9 +442,7 @@
success: function (result) success: function (result)
{ {
console.info(result.data); console.info(result.data);
//$("#responsible").empty();//清空下拉框的值
$.each(result.data, function (index, item) { $.each(result.data, function (index, item) {
//$("#responsible").append(new Option(item.text, item.value));// 下拉菜单里添加元素
$("#responsible").val(item.value); $("#responsible").val(item.value);
}); });
@ -573,7 +561,6 @@
$('#txtRepairTypeNo').on('keypress', function (event) { $('#txtRepairTypeNo').on('keypress', function (event) {
if (event.keyCode == 13) { if (event.keyCode == 13) {
//alert($('#txtRepairTypeNo').val());
getRepairType($('#txtRepairTypeNo').val()); getRepairType($('#txtRepairTypeNo').val());
} }
@ -599,7 +586,6 @@
$('#txtNgNo').on('keypress', function (event) { $('#txtNgNo').on('keypress', function (event) {
if (event.keyCode == 13) { if (event.keyCode == 13) {
//alert($('#txtNgNo').val());
getErrorCode($('#txtNgNo').val()); getErrorCode($('#txtNgNo').val());
} }
@ -688,61 +674,62 @@
}); });
var tableCols = [[ //圖片Table(目前沒有用到)
{ // var tableCols = [[
field: 'repairID', // {
title: '維修編號', // field: 'repairID',
width: 120 // title: '維修編號',
}, // width: 120
{ // },
field: 'imageName', // {
title: '維修圖片' // field: 'imageName',
}, // title: '維修圖片'
{ // },
field: 'right', // {
width: 200, // field: 'right',
title: '操作', // width: 200,
align: 'center', // title: '操作',
fixed: 'right', // align: 'center',
templet: function (d) { // fixed: 'right',
return '<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-read" lay-event="detail"> 預覽 </a> <a class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" lay-event="del"> 删除 </a>' // templet: function (d) {
} // return '<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-read" lay-event="detail"> 預覽 </a> <a class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" lay-event="del"> 删除 </a>'
}] // }
]; // }]
// ];
function detail(obj) {
if (obj.data.imageName) { //圖片預覽(目前沒有用到)
//alert(obj.data.imageName); // function detail(obj) {
hg.open('預覽圖片資料', '/REP/REP001B/' + obj.data.imageName, '', '', true); // if (obj.data.imageName) {
} // hg.open('預覽圖片資料', '/REP/REP001B/' + obj.data.imageName, '', '', true);
} // }
// }
//通过行tool删除,lay-event="del2"
function del(obj) { //圖片刪除(目前沒有用到)
if (obj.data.imageName) { // function del(obj) {
hg.confirm("圖片資料:" + obj.data.imageName + ",确定要删除吗?", function () { // if (obj.data.imageName) {
$.ajax({ // hg.confirm("圖片資料:" + obj.data.imageName + ",确定要删除吗?", function () {
url: '/REP/REP001D', // $.ajax({
data: { id: obj.data.imageName }, // url: '/REP/REP001D',
type: 'POST', // data: { id: obj.data.imageName },
success: function (data) { // type: 'POST',
if (data.success) { // success: function (data) {
obj.del(); //只删本地数据 // if (data.success) {
hg.msghide("删除成功!"); // obj.del(); //只删本地数据
} // hg.msghide("删除成功!");
else { // }
hg.msg(data.msg); // else {
} // hg.msg(data.msg);
}, // }
error: function () { // },
hg.msg("网络请求失败!"); // error: function () {
} // hg.msg("网络请求失败!");
}); // }
}); // });
} // });
} // }
// }
// Table 刪除
//組件刪除
function Remove(button, OldNo, NewNo, KeypartID) { function Remove(button, OldNo, NewNo, KeypartID) {
hg.confirm("舊組件序號:" + OldNo + ",新組件序號:" + NewNo + ",確定要删除嗎?", function () { hg.confirm("舊組件序號:" + OldNo + ",新組件序號:" + NewNo + ",確定要删除嗎?", function () {
@ -769,34 +756,8 @@
}); });
}; };
//圖片表格(目前沒有用到)
//通过行tool删除,lay-event="del" //var table = hg.table.datatable('test', '維修圖片資料', '/REP/GetNgRepairBlob/' + @Model.ngRepair.RepairID, {}, tableCols, false, false, 'full-100');
function del2(obj) {
if (obj.data.oldPartNo) {
hg.confirm("組件資料:" + obj.data.oldPartNo + ",确定要删除吗?", function () {
$.ajax({
url: '/REP/REP001KD',
data: { id: obj.data.keypartID },
type: 'POST',
success: function (data) {
if (data.success) {
obj.del(); //只删本地数据
hg.msghide("删除成功!");
}
else {
hg.msg(data.msg);
}
},
error: function () {
hg.msg("网络请求失败!");
}
});
});
}
}
//基本数据表格
var table = hg.table.datatable('test', '維修圖片資料', '/REP/GetNgRepairBlob/' + @Model.ngRepair.RepairID, {}, tableCols, false, false, 'full-100');
</script> </script>

6
AMESCoreStudio.Web/Views/RPT/RPT002.cshtml

@ -208,7 +208,7 @@
<div class="layui-col-md4 ColDetailTitle vertical">Board</div> <div class="layui-col-md4 ColDetailTitle vertical">Board</div>
<div class="layui-col-md8"> <div class="layui-col-md8">
<div class="layui-col-md12 spanDetailNumberClass <div class="layui-col-md12 spanDetailNumberClass
@if(Model.FQCRRBoard <= 0.20) @if(Model.FQCRRBoard <= 0.20m)
{ {
<text>ColorGreen</text> <text>ColorGreen</text>
} }
@ -224,7 +224,7 @@
<div class="layui-col-md4 ColDetailTitle vertical">System</div> <div class="layui-col-md4 ColDetailTitle vertical">System</div>
<div class="layui-col-md8"> <div class="layui-col-md8">
<div class="layui-col-md12 spanDetailNumberClass <div class="layui-col-md12 spanDetailNumberClass
@if(Model.FQCRRSystem <= 1.37) @if(Model.FQCRRSystem <= 1.37m)
{ {
<text>ColorGreen</text> <text>ColorGreen</text>
} }
@ -240,7 +240,7 @@
<div class="layui-col-md4 ColDetailTitle vertical">Medical</div> <div class="layui-col-md4 ColDetailTitle vertical">Medical</div>
<div class="layui-col-md8"> <div class="layui-col-md8">
<div class="layui-col-md12 spanDetailNumberClass <div class="layui-col-md12 spanDetailNumberClass
@if(Model.FQCRRMedical <= 0.59) @if(Model.FQCRRMedical <= 0.59m)
{ {
<text>ColorGreen</text> <text>ColorGreen</text>
} }

36
AMESCoreStudio.Web/Views/SPC/SPC004.cshtml

@ -84,7 +84,7 @@
</div> </div>
</div> </div>
@section Scripts{ @section Scripts {
<!-- input输入 --> <!-- input输入 -->
<script type="text/html" id="purchaseTotal"> <script type="text/html" id="purchaseTotal">
<input type="number" min="0" class="layui-input" lay-vertype="tips" name="purchase_total" value="" lay-event="purchaseTotal" lay-filter="purchaseTotal"> <input type="number" min="0" class="layui-input" lay-vertype="tips" name="purchase_total" value="" lay-event="purchaseTotal" lay-filter="purchaseTotal">
@ -105,7 +105,6 @@
, theme: 'grid' , theme: 'grid'
, isInitValue: true , isInitValue: true
, ready: function (date) { , ready: function (date) {
// $("#dateStrh").val($("#dateStrh").val());
} }
, change: function (value, date, endDate) { , change: function (value, date, endDate) {
$("#dateStrh").val(value); $("#dateStrh").val(value);
@ -121,8 +120,6 @@
, theme: 'grid' , theme: 'grid'
, isInitValue: true , isInitValue: true
, ready: function (date) { , ready: function (date) {
//$("#dateEndh").val(value);
//console.log(date.y);// 得到初始化的日期时间对象
} }
, change: function (value, date, endDate) { , change: function (value, date, endDate) {
$("#dateEndh").val(value); $("#dateEndh").val(value);
@ -136,7 +133,8 @@
var data = $("#Type").val(); var data = $("#Type").val();
console.info(data); console.info(data);
if (data) { if (data) {
getInspectionForms(data); } getInspectionForms(data);
}
else { else {
$("#Form").empty(); $("#Form").empty();
$('#Form').append(new Option("請選擇", "-99")); $('#Form').append(new Option("請選擇", "-99"));
@ -150,7 +148,6 @@
$.ajax({ $.ajax({
url: "/SPC/GetInspectionForms", url: "/SPC/GetInspectionForms",
dataType: 'json', dataType: 'json',
//data: { id: data },
contentType: "application/json", contentType: "application/json",
type: 'get', type: 'get',
success: function (result) { success: function (result) {
@ -238,59 +235,36 @@
{ {
field: 'detailFail', field: 'detailFail',
title: '檢驗狀態', title: '檢驗狀態',
templet: function (d) { // yiru modify 22-12-09 templet: function (d) {
if (d.detailFail != "0") if (d.detailFail != "0")
return "F"; return "F";
else else
return "P"; return "P";
// return "Total:" + d.detailItem + " Pass:" + d.detailPass + " Fail:" + d.detailFail + " N/A:" + d.detailNA;
}, },
sort: true sort: true
}, },
//{
// field: 'detailItem1',
// title: '明細狀態1',
// width: 200,
// templet: function (d) { // yiru modify 22-12-09
// var Tmp = GetdetailQuery(d.inspectionID);
// return Tmp;
// }
//},
{ {
align: 'center', title: '操作', width: 100, fixed: 'right', align: 'center', title: '操作', width: 100, fixed: 'right',
sort: true, sort: true,
templet: function (item) { templet: function (item) {
var btns = ''; var btns = '';
//btns = btns + '<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>';
// if (item.statusNo == "暫存")
// btns = btns + '<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>';
// else if (item.statusNo == "儲存")
btns = btns + '<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="view">檢視</a>'; btns = btns + '<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="view">檢視</a>';
return btns; return btns;
} }
} }
]]; ]];
//通过行tool编辑,lay-event="view" //通过行tool编辑,lay-event="view"
function view(obj) { function view(obj) {
if (obj.data.inspectionID) { if (obj.data.inspectionID) {
hg.open('檢視巡檢結果', '/SPC/SPC004V/' + obj.data.inspectionID, '', '', true); hg.open('檢視巡檢結果', '/SPC/SPC004V/' + obj.data.inspectionID, '', '', true);
} }
} }
//通过行tool删除,lay-event="del"
//基本数据表格 //基本数据表格
var table; var table;
//$(function () {
// tt();
//});
function tt() { function tt() {
//基本数据表格
var form = ""; var form = "";
var WipNo = ""; var WipNo = "";
var ItemNo = ""; var ItemNo = "";
@ -350,7 +324,6 @@
var F = 0; var F = 0;
var NA = 0; var NA = 0;
var Total = 0; var Total = 0;
// $.each(result.data, (index, item) {
$.each(result.data, function () { $.each(result.data, function () {
Total += 1; Total += 1;
if (result.data.result == "P") { if (result.data.result == "P") {
@ -367,7 +340,6 @@
str = "F" str = "F"
else else
str = "P" str = "P"
// str = "Total:" + Total.toString + " P:" + P.toString() + " F:" + F.toString + " NA:" + NA.toString;
return str; return str;
} }

40
AMESCoreStudio.Web/Views/SPC/SPC005R.cshtml

@ -2,8 +2,10 @@
@{ ViewData["Title"] = "SPC005R"; @{
Layout = "~/Views/Shared/_AMESLayout.cshtml"; } ViewData["Title"] = "SPC005R";
Layout = "~/Views/Shared/_AMESLayout.cshtml";
}
<style> <style>
.control-label { .control-label {
@ -47,26 +49,22 @@
</div> </div>
@section Scripts { @section Scripts {
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); @{
await Html.RenderPartialAsync("_FileinputScriptsPartial"); } await Html.RenderPartialAsync("_ValidationScriptsPartial");
await Html.RenderPartialAsync("_FileinputScriptsPartial");
<script type="text/javascript"> }
//layui.use(['form', 'layer', 'laydate'], function () {
// form = layui.form; <script type="text/javascript">
//
// form.on('select(Type)', function (data) {
// var data = $("#Type").val();
// getInspectionForms(data);
// });
//
//});
hg.form.onsubmit('asubmit', function (data) { hg.form.onsubmit('asubmit', function (data) {
tt(); tt();
//table && table.reload(data);
}); });
//通过行tool编辑,lay-event="show" //檔案預覽
function show(obj) { function show(obj) {
layui.use('layer', function () { layui.use('layer', function () {
var FileUploadUrl = '@ViewBag.FileUploadUrl'; if(!FileUploadUrl)
{
FileUploadUrl = 'https://ames.avalue.com.tw:9443';
}
var layer = layui.layer; var layer = layui.layer;
layer.open({ layer.open({
type: 2, type: 2,
@ -74,12 +72,8 @@
shadeClose: true,//点击遮罩关闭层 shadeClose: true,//点击遮罩关闭层
shade: 0.8, shade: 0.8,
area: ['90%', '90%'], area: ['90%', '90%'],
content: obj.data.filePath + obj.data.newName, //iframe的url content: FileUploadUrl + obj.data.filePath + obj.data.newName,
zIndex: 19891014, zIndex: 19891014,
//iframe: {
// src:obj.data.filePath + obj.data.newName
//
//}
}); });
}); });
@ -148,7 +142,7 @@
} }
}); });
</script> </script>
} }

12
AMESCoreStudio.Web/Views/SYS/SYS008.cshtml

@ -75,24 +75,24 @@
}] }]
]; ];
//通过行tool编辑,lay-event="edit" //修改
function edit(obj) { function edit(obj) {
if (obj.data.userID) { if (obj.data.userID) {
hg.open('修改用', '/SYS/SYS008U/' + obj.data.userID, 640, 640); hg.open('修改用', '/SYS/SYS008U/' + obj.data.userID, 640, 640);
} }
} }
//通过行tool编辑,lay-event="edit" //停用
function stop(obj) { function stop(obj) {
if (obj.data.userID) { if (obj.data.userID) {
hg.open('停用用', '/SYS/SYS008S/' + obj.data.userID, 640, 640); hg.open('停用用', '/SYS/SYS008S/' + obj.data.userID, 640, 640);
} }
} }
//通过行tool删除,lay-event="del" //通过行tool删除,lay-event="del"
function del(obj) { function del(obj) {
if (obj.data.userID) { if (obj.data.userID) {
hg.confirm("用户:" + obj.data.userName + ",确定要删除吗?", function () { hg.confirm("用戶:" + obj.data.userName + ",確定要刪除嗎?", function () {
$.ajax({ $.ajax({
url: '/SYS/SYS008D', url: '/SYS/SYS008D',
data: { id: obj.data.userID }, data: { id: obj.data.userID },
@ -107,7 +107,7 @@
} }
}, },
error: function () { error: function () {
hg.msg("网络请求失败!"); hg.msg("刪除失敗!");
} }
}); });
}); });

5
AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs

@ -251,8 +251,10 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
join q2 in _context.Items on q1.ItemNo equals q2.ItemNo join q2 in _context.Items on q1.ItemNo equals q2.ItemNo
join q3 in _context.Stationses on q1.StationID equals q3.StationID join q3 in _context.Stationses on q1.StationID equals q3.StationID
join q4 in _context.UserInfoes on q1.CreateUserID equals q4.UserID join q4 in _context.UserInfoes on q1.CreateUserID equals q4.UserID
join q5 in _context.WipInfos on q1.WipID equals q5.WipID
select new BarcodeItemDTO select new BarcodeItemDTO
{ {
BarcodeID = q1.BarcodeID, BarcodeID = q1.BarcodeID,
WipID = q1.WipID, WipID = q1.WipID,
PartNo = q1.PartNo, PartNo = q1.PartNo,
@ -262,7 +264,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
StationID = q1.StationID, StationID = q1.StationID,
CreateUser = q4.UserName, CreateUser = q4.UserName,
CreateDate = q1.CreateDate, CreateDate = q1.CreateDate,
SysType = q1.SysType SysType = q1.SysType,
WipNo = q5.WipNO
}; };
return await q.ToListAsync(); return await q.ToListAsync();

3
AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs

@ -406,7 +406,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
q1.InputDate, q1.InputDate,
q3.WerksNO, q3.WerksNO,
q7.UserNo, q7.UserNo,
q7.UserName q7.UserName,
q1.StartDate
}; };
if (wipNo != null && wipNo != "") if (wipNo != null && wipNo != "")

10
AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterController.cs

@ -209,15 +209,15 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
var query = new List<DTO.AMES.QRS016Detail>(); var query = new List<DTO.AMES.QRS016Detail>();
int allQty = 0; int allQty = 0;
int passQty = 0; int passQty = 0;
int failQty = 0; decimal failQty = 0;
double rejectRate = 0; decimal rejectRate = 0;
// 醫療 // 醫療
var data = q.Where(w => w.customerMedical == "Y" && w.qaResult != "A").ToList(); var data = q.Where(w => w.customerMedical == "Y" && w.qaResult != "A").ToList();
allQty = data.Count(); allQty = data.Count();
passQty = data.Where(w => w.qaResult == "P").Count(); passQty = data.Where(w => w.qaResult == "P").Count();
failQty = data.Where(w => w.qaResult == "R").Count(); failQty = data.Where(w => w.qaResult == "R").Count();
rejectRate = failQty == 0 ? 0 : Math.Round(((double)failQty / (double)allQty), 2, MidpointRounding.AwayFromZero) * 100; rejectRate = failQty == 0 ? 0 : Math.Round((failQty / allQty) * 100, 2, MidpointRounding.AwayFromZero);
query.Add(new DTO.AMES.QRS016Detail query.Add(new DTO.AMES.QRS016Detail
{ {
@ -234,7 +234,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
allQty = data.Count(); allQty = data.Count();
passQty = data.Where(w => w.qaResult == "P").Count(); passQty = data.Where(w => w.qaResult == "P").Count();
failQty = data.Where(w => w.qaResult == "R").Count(); failQty = data.Where(w => w.qaResult == "R").Count();
rejectRate = failQty == 0 ? 0 : Math.Round(((double)failQty / (double)allQty), 2, MidpointRounding.AwayFromZero) * 100; rejectRate = failQty == 0 ? 0 : Math.Round((failQty / allQty) * 100, 2, MidpointRounding.AwayFromZero);
query.Add(new DTO.AMES.QRS016Detail query.Add(new DTO.AMES.QRS016Detail
{ {
type = "系統組裝", type = "系統組裝",
@ -250,7 +250,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
allQty = data.Count(); allQty = data.Count();
passQty = data.Where(w => w.qaResult == "P").Count(); passQty = data.Where(w => w.qaResult == "P").Count();
failQty = data.Where(w => w.qaResult == "R").Count(); failQty = data.Where(w => w.qaResult == "R").Count();
rejectRate = failQty == 0 ? 0 : Math.Round(((double)failQty / (double)allQty), 2, MidpointRounding.AwayFromZero) * 100; rejectRate = failQty == 0 ? 0 : Math.Round((failQty / allQty) * 100, 2, MidpointRounding.AwayFromZero);
query.Add(new DTO.AMES.QRS016Detail query.Add(new DTO.AMES.QRS016Detail
{ {
type = "單板", type = "單板",

400
AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs

@ -33,6 +33,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
private readonly ESUNContext _esun_context; private readonly ESUNContext _esun_context;
private readonly IConfiguration _config; private readonly IConfiguration _config;
private readonly string _PTDContext; private readonly string _PTDContext;
private string SFISDbContext = "SFIS..";
/// <summary> /// <summary>
/// ///
@ -43,6 +44,11 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
_config = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build(); _config = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build();
_context = context; _context = context;
_PTDContext = _config.GetConnectionString("PTDContext"); _PTDContext = _config.GetConnectionString("PTDContext");
if (_PTDContext.IndexOf("SFIS_PTD_T") > 0)
{
SFISDbContext = "SFIS_T..";
}
} }
/// <summary> /// <summary>
@ -803,13 +809,6 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
WriteTraceLog("query wip_kp rows qty:" + dtKp.Rows.Count); WriteTraceLog("query wip_kp rows qty:" + dtKp.Rows.Count);
} }
/*
string sql = @" select c.wip_no as WipNo,b.barcode_no as BarcodeNo,b.extra_barcode_no as ExtraBarcodeNo,d.model_no as ModelNO,d.item_no as ItemNO";
sql = sql + " from jhames.barcode_info b,jhames.wip_info c,jhames.wip_att d";
sql = sql + " where b.wip_id = c.wip_id and c.wip_no = d.wip_no";
sql = sql + " and c.wip_no = '" + wipNO + "'";
*/
string sql = @" select c.wip_no as WipNo,b.barcode_no as BarcodeNo,b.extra_barcode_no as ExtraBarcodeNo,e.station_name as StationName,b.box_no as BoxNo,d.model_no as ModelNO,d.item_no as ItemNO"; string sql = @" select c.wip_no as WipNo,b.barcode_no as BarcodeNo,b.extra_barcode_no as ExtraBarcodeNo,e.station_name as StationName,b.box_no as BoxNo,d.model_no as ModelNO,d.item_no as ItemNO";
sql = sql + " from jhames.barcode_info b,jhames.wip_barcode c,jhames.wip_att d,jhames.stations e"; sql = sql + " from jhames.barcode_info b,jhames.wip_barcode c,jhames.wip_att d,jhames.stations e";
sql = sql + " where b.barcode_no between c.start_no and c.end_no and c.wip_no = d.wip_no and b.station_id = e.station_id"; sql = sql + " where b.barcode_no between c.start_no and c.end_no and c.wip_no = d.wip_no and b.station_id = e.station_id";
@ -915,55 +914,8 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{ {
if (kp_no.StartsWith("MB") && !kp_no.StartsWith("MB_MAC")) if (kp_no.StartsWith("MB") && !kp_no.StartsWith("MB_MAC"))
{ {
/*
WriteTraceLog("query mac by mb trace 001");
ESUNContext _esun_context = new ESUNContext();
WriteTraceLog("query mac by mb trace 002");
//读取MAC
DbConnection esun_conn = _esun_context.Database.GetDbConnection();
WriteTraceLog("query mac by mb trace 003");
if (esun_conn.State != ConnectionState.Open)
{
await esun_conn.OpenAsync();
}
WriteTraceLog("query mac by mb trace 004");
*/
bool createMacCol = true; bool createMacCol = true;
//part_no = "91000237320038";
/*
string mac_sql = string.Format(@"select distinct a.工單編號 as mo_id,e.客戶工單編號 as customer_moid,a.工單序號 as product_sn,
case substring(f.avalue_kp_typeid, 1, 3) when 'MAC' then isnull(z.item_prefix,'')+b.SUB_ITEM_SN else b.SUB_ITEM_SN end as part_barcode,
f.avalue_kp_typeid as class,c.material_id,d.r_stn as routeid,'' as workerid,rtrim(g.sn_date) + ' ' + rtrim(g.sn_time) as create_date
from or_sn_story a
left join sub_item_db b on a. = b.or_sn and a. = b.or_sal
left join jh_sub_item c on a. = c.mo_id and b.class = c.part_typeid
left join jh_sub_item_prefix z on c.mo_id = z.mo_id
left join or_sub_db d on a. = d.or_sn and b.class = d.class
join or_list e on a. = e. and e.[] = 'EV'
left join jh_sub_item_mapping f on b.class = f.eversun_kp_typeid
join jh_sn_list g on a. = g.sn
where g.sn_result = 'OK'
AND a. = '{0}'
AND c.material_id LIKE 'MAC%'", part_no);
*/
/*
string mac_sql = string.Format(@"SELECT B.[ProductSN], B.[PartBarcode], B.[MFID], B.[MOID], B.[PartTypeID], B.[MaterialID], B.[IsActive]
FROM [SFIS].[dbo].[ZPDKeyPart] B WHERE B.[IsActive] = 1 AND B.[ProductSN] = (SELECT A.[PartBarcode] FROM [SFIS].[dbo].[ZPDKeyPart] A WHERE A.[IsActive] = 1 AND A.[PartTypeID] = 'MAC' AND A.[PartBarcode] = '{0}')", part_no);
WriteTraceLog("query mac by mb sql:" + mac_sql);
*/
bool findFlag = false; bool findFlag = false;
string mac_sql = string.Format("select partbarcode from jhames.c_sfis_keyparts where productsn = '{0}' and parttypeid='MAC'", part_no); string mac_sql = string.Format("select partbarcode from jhames.c_sfis_keyparts where productsn = '{0}' and parttypeid='MAC'", part_no);
@ -1043,7 +995,11 @@ FROM [SFIS].[dbo].[ZPDKeyPart] B WHERE B.[IsActive] = 1 AND B.[ProductSN] = (S
//从barcode_item读取结转数据 //从barcode_item读取结转数据
if (!findFlag) if (!findFlag)
{ {
string mac_sql2 = string.Format("select a.part_no from jhames.barcode_item a,jhames.barcode_info b where a.barcode_id = b.barcode_id and b.barcode_no = '{0}' and item_no like 'MAC%'", part_no); string mac_sql2 = string.Format("select a.part_no from jhames.barcode_item a,jhames.barcode_info b " +
" where a.barcode_id = b.barcode_id " +
" and b.barcode_no = '{0}' " +
" and item_no like 'MAC%' " +
" order by a.ITEM_NO, a.PART_NO ", part_no);
using (var esun_cmd = conn.CreateCommand()) using (var esun_cmd = conn.CreateCommand())
{ {
@ -1096,7 +1052,6 @@ FROM [SFIS].[dbo].[ZPDKeyPart] B WHERE B.[IsActive] = 1 AND B.[ProductSN] = (S
string mac = ""; string mac = "";
for (int m = 0; m < esun_table.Rows.Count; m++) for (int m = 0; m < esun_table.Rows.Count; m++)
{ {
//mac = esun_table.Rows[m]["part_barcode"].ToString().Trim();
mac = esun_table.Rows[m]["PART_NO"].ToString().Trim(); mac = esun_table.Rows[m]["PART_NO"].ToString().Trim();
if (dtItem.Rows.Count == 1) if (dtItem.Rows.Count == 1)
{ {
@ -2145,7 +2100,9 @@ FROM [SFIS].[dbo].[ZPDKeyPart] B WHERE B.[IsActive] = 1 AND B.[ProductSN] = (S
lineDesc = q3.LineDesc, lineDesc = q3.LineDesc,
unitName = q4.UnitName, unitName = q4.UnitName,
wipType = q1.WipType, wipType = q1.WipType,
factoryNo = q1.WerksNO factoryNo = q1.WerksNO,
startDate = q1.StartDate,
fqcClearDate = q1.FQCClearDate
}; };
@ -2208,27 +2165,7 @@ FROM [SFIS].[dbo].[ZPDKeyPart] B WHERE B.[IsActive] = 1 AND B.[ProductSN] = (S
q = q.Skip((page - 1) * limit).Take(limit); q = q.Skip((page - 1) * limit).Take(limit);
} }
var qq = await q.ToListAsync(); result.Data = await q.ToListAsync();
// 塞入開工日
foreach (var item in qq)
{
var workDate = _context.WipStations.Where(w => w.WipID == item.wipID)
.OrderBy(s => s.CreateDate)
.FirstOrDefault();
item.workDate = workDate == null ? "" : workDate.CreateDate.ToString("yyyy/MM/dd");
}
// 塞檢驗完成日期
foreach (var item in qq)
{
var fqcDate = _context.FqcResultMasters.Where(w => w.WipNo == item.wipNo && w.QaResult != "A")
.OrderByDescending(s => s.EndTime)
.FirstOrDefault();
item.fqcDate = fqcDate == null ? "" : fqcDate.EndTime.ToString("yyyy/MM/dd");
}
result.Data = qq;
if (result == null) if (result == null)
{ {
@ -2991,7 +2928,7 @@ FROM [SFIS].[dbo].[ZPDKeyPart] B WHERE B.[IsActive] = 1 AND B.[ProductSN] = (S
} }
string strSQL = $@"select DNNO,DNLineNO,ProductID,ShipQty,ShipCustomerID,SoldCustomerID,ExpectShipDate , string strSQL = $@"select DNNO,DNLineNO,ProductID,ShipQty,ShipCustomerID,SoldCustomerID,ExpectShipDate ,
CurrentShipDate CurrentShipDate
from SFIS_PTD.dbo.ZDNDetail where DNNO ='{dnNo}' "; from ZDNDetail where DNNO ='{dnNo}' ";
if (!string.IsNullOrEmpty(lineNo)) if (!string.IsNullOrEmpty(lineNo))
{ {
strSQL += $@"And DNLineNO ='{lineNo}'"; strSQL += $@"And DNLineNO ='{lineNo}'";
@ -3065,7 +3002,7 @@ FROM [SFIS].[dbo].[ZPDKeyPart] B WHERE B.[IsActive] = 1 AND B.[ProductSN] = (S
} }
string strSQL = $@"select RecordNumber as DN單號,MOID as WipNo,ProductID as ItemNO,SerialNumber as ExtraBarcodeNo,'' as BarcodeNo, string strSQL = $@"select RecordNumber as DN單號,MOID as WipNo,ProductID as ItemNO,SerialNumber as ExtraBarcodeNo,'' as BarcodeNo,
RecordDate as StartDate RecordDate as StartDate
from SFIS_PTD.dbo.ZProductTrans where RecordNumber ='{dnNo}' and RCLineNO ='{lineNo}' from ZProductTrans where RecordNumber ='{dnNo}' and RCLineNO ='{lineNo}'
order by SerialNumber"; order by SerialNumber";
DataTable dtZProductTrans = new DataTable(); DataTable dtZProductTrans = new DataTable();
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
@ -3467,6 +3404,9 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{ {
string customer = data.Customer; string customer = data.Customer;
string strDNNo = data.TableData[0].DnNo; string strDNNo = data.TableData[0].DnNo;
string dnLineNo = data.TableData[0].LineNo;
int shipQty = data.TableData[0].ShipQty;
string productID = data.TableData[0].Material;
var pdtMail = await new PTD.PTDController().GetCustomerItemMailGroup(customer); var pdtMail = await new PTD.PTDController().GetCustomerItemMailGroup(customer);
if (pdtMail.Any(a => a.StatusNo != "S")) if (pdtMail.Any(a => a.StatusNo != "S"))
@ -3482,7 +3422,10 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
worksheet.Cells[1, 1].Value = "DN單號"; worksheet.Cells[1, 1].Value = "DN單號";
worksheet.Cells[1, 2].Value = "LineNo"; worksheet.Cells[1, 2].Value = "LineNo";
worksheet.Cells[1, 3].Value = "Material(料號)"; worksheet.Cells[1, 3].Value = "Material(料號)";
worksheet.Cells[1, 4].Value = "SN"; worksheet.Cells[1, 4].Value = "出貨數量";
worksheet.Cells[1, 5].Value = "SN";
worksheet.Cells[1, 6].Value = "StartDate";
worksheet.Cells[1, 7].Value = "工單號碼";
worksheet.Row(1).Style.Font.Bold = true; worksheet.Row(1).Style.Font.Bold = true;
int i = 0; int i = 0;
@ -3492,19 +3435,50 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
worksheet.Cells[i + 2, 1].Value = SNData.DnNo; worksheet.Cells[i + 2, 1].Value = SNData.DnNo;
worksheet.Cells[i + 2, 2].Value = SNData.LineNo; worksheet.Cells[i + 2, 2].Value = SNData.LineNo;
worksheet.Cells[i + 2, 3].Value = SNData.Material; worksheet.Cells[i + 2, 3].Value = SNData.Material;
worksheet.Cells[i + 2, 4].Value = SNData.Sn; worksheet.Cells[i + 2, 4].Value = SNData.ShipQty;
worksheet.Cells[i + 2, 5].Value = SNData.Sn;
worksheet.Cells[i + 2, 6].Value = SNData.StartDate;
worksheet.Cells[i + 2, 7].Value = SNData.CurrentMOID;
i++; i++;
} }
// 自動調整欄寬 // 自動調整欄寬
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns(); worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
fileContents = package.GetAsByteArray(); fileContents = package.GetAsByteArray();
// 寫入實體 Excel 檔案
} }
var firstItem = pdtMail.FirstOrDefault(); var firstItem = pdtMail.FirstOrDefault();
string toMail = firstItem.MailGroup; string toMail = firstItem.MailGroup;
string Subject = $"[AMES系統通知] 出貨單號:" + strDNNo; string Subject = firstItem.CustomerName + "_" + strDNNo;
string emailBody = ""; string emailBody = $@"
<html>
<body>
<p>Dear Team,</p>
<p>Please find the details below:</p>
<table border='1' style='border-collapse: collapse; width: 100%;'>
<thead style='background-color: #0000FF; color: #FFFFFF; text-align: left;'>
<tr>
<th style='padding: 8px;'>DNLineNO</th>
<th style='padding: 8px;'>ProductID</th>
<th style='padding: 8px;'>ShipQty</th>
<th style='padding: 8px;'>SerialNumber?</th>
</tr>
</thead>
<tbody>
<tr>
<td style='padding: 8px;'>{dnLineNo}</td>
<td style='padding: 8px;'>{productID}</td>
<td style='padding: 8px;'>{shipQty}</td>
<td style='padding: 8px;'>Yes</td>
</tr>
</tbody>
</table>
</body>
</html>";
//string filePath = $"D:\\Alex\\EXCEL\\{strDNNo}.xlsx";
//System.IO.File.WriteAllBytes(filePath, fileContents);
await new MailController(_context, _config).PostMailByByteFile(Subject, emailBody, "", toMail, false, fileContents: fileContents, fileName: $"{strDNNo}.xlsx"); await new MailController(_context, _config).PostMailByByteFile(Subject, emailBody, "", toMail, false, fileContents: fileContents, fileName: $"{strDNNo}.xlsx");
} }
} }
@ -3565,7 +3539,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{ {
salesOrderNumber = dnDetail.FirstOrDefault().OrderNo; salesOrderNumber = dnDetail.FirstOrDefault().OrderNo;
sOLineNO = dnDetail.FirstOrDefault().OrderLineNO; sOLineNO = dnDetail.FirstOrDefault().OrderLineNO;
eRP_CustomerID = dnDetail.FirstOrDefault().ShipCustomerID; eRP_CustomerID = dnDetail.FirstOrDefault().SoldCustomerID;
} }
} }
@ -3573,7 +3547,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
strMaterial = SNData.Material; strMaterial = SNData.Material;
string strLatest; string strLatest;
//確認此出貨序號是否有ZHistoryKeyDefine //確認此出貨序號是否有ZHistoryKeyDefine
strSQL = $@"select Seed FROM [SFIS_PTD].[dbo].[ZHistoryKeyDefine] where serialnumber ='{SNData.Sn}'"; strSQL = $@"select Seed FROM ZHistoryKeyDefine where serialnumber ='{SNData.Sn}'";
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
{ {
cmd.CommandText = strSQL; cmd.CommandText = strSQL;
@ -3585,12 +3559,12 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
int nIdx = seed + 1; int nIdx = seed + 1;
strLatest = SNData.Sn + nIdx.ToString().PadLeft(4, '0');//組成HistoryID strLatest = SNData.Sn + nIdx.ToString().PadLeft(4, '0');//組成HistoryID
//HistoryKeyDefine //HistoryKeyDefine
strSQL = @$"UPDATE [SFIS_PTD].[dbo].[ZHistoryKeyDefine] strSQL = @$"UPDATE ZHistoryKeyDefine
SET [Seed] = {nIdx} where [SerialNumber]='{SNData.Sn}'"; SET Seed = {nIdx} where SerialNumber ='{SNData.Sn}'";
Console.WriteLine(strSQL); Console.WriteLine(strSQL);
colSQL.Add(strSQL); colSQL.Add(strSQL);
//ZSNInfo //ZSNInfo
strSQL = @$"Update SFIS_PTD..ZSNInfo SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}', strSQL = @$"Update ZSNInfo SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}',
CurrentProductID='{SNData.Material}' CurrentProductID='{SNData.Material}'
where SerialNumber='{SNData.Sn}'"; where SerialNumber='{SNData.Sn}'";
Console.WriteLine(strSQL); Console.WriteLine(strSQL);
@ -3600,15 +3574,15 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{ {
strLatest = SNData.Sn + 1.ToString().PadLeft(4, '0');//組成HistoryID strLatest = SNData.Sn + 1.ToString().PadLeft(4, '0');//組成HistoryID
//ZHistoryKeyDefine //ZHistoryKeyDefine
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZHistoryKeyDefine] ([SerialNumber],[Seed]) strSQL = @$"INSERT INTO ZHistoryKeyDefine (SerialNumber, Seed)
VALUES ('{SNData.Sn}',1)"; VALUES ('{SNData.Sn}',1)";
Console.WriteLine(strSQL); Console.WriteLine(strSQL);
colSQL.Add(strSQL); colSQL.Add(strSQL);
//ZSNInfo //ZSNInfo
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZSNInfo] ([SerialNumber],[CurrentProductID],[OriginalProductID], strSQL = @$"INSERT INTO ZSNInfo (SerialNumber, CurrentProductID, OriginalProductID,
[LocationID],[LatestHistoryID],[RecordTypeID], LocationID, LatestHistoryID, RecordTypeID,
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID], OwnerPlantID, OwnerCompanyID, CreatePlantID, CreateCompanyID,
[ModifyDate]) VALUES ModifyDate) VALUES
('{SNData.Sn}','{SNData.Material}','{SNData.Material}', ('{SNData.Sn}','{SNData.Material}','{SNData.Material}',
'{strLocation}','{strLatest}','{strRecordType}', '{strLocation}','{strLatest}','{strRecordType}',
'{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}', '{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}',
@ -3617,13 +3591,13 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
colSQL.Add(strSQL); colSQL.Add(strSQL);
} }
//ZProductTrans //ZProductTrans
strSQL = $@"INSERT INTO [SFIS_PTD].[dbo].[ZProductTrans] strSQL = $@"INSERT INTO ZProductTrans
([HistoryID],[SerialNumber],[RecordTypeID],[RecordNumber],[RCLineNO],[RecordDate], (HistoryID,SerialNumber,RecordTypeID,RecordNumber,RCLineNO,RecordDate,
[ProductID],[IsChangeID],[LocationID],[EmplID],[IsDelete], ProductID,IsChangeID,LocationID,EmplID,IsDelete,
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID], OwnerPlantID,OwnerCompanyID,CreatePlantID,CreateCompanyID,
[CreatorID],[CreateDate],[ModifierID],[ModifyDate], CreatorID, CreateDate, ModifierID, ModifyDate,
[chkflag],[IsBranchCoReceived],[MOID], chkflag, IsBranchCoReceived, MOID,
[SalesOrderNumber],[SOLineNO],[ERP_CustomerID]) VALUES SalesOrderNumber, SOLineNO, ERP_CustomerID) VALUES
('{strLatest}','{SNData.Sn}','{strRecordType}','{SNData.DnNo}','{SNData.LineNo}','{strRecordDate}', ('{strLatest}','{SNData.Sn}','{strRecordType}','{SNData.DnNo}','{SNData.LineNo}','{strRecordDate}',
'{SNData.Material}',0,'{strLocation}','{strEmpId}',0, '{SNData.Material}',0,'{strLocation}','{strEmpId}',0,
'{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}', '{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}',
@ -3700,9 +3674,9 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
//查剩餘數 //查剩餘數
string strSQL = $@"select ShipQty - string strSQL = $@"select ShipQty -
(SELECT count(1) (SELECT count(1)
FROM [SFIS_PTD].[dbo].[ZWHPickListDetail] FROM ZWHPickListDetail
where RecordNumber =DNNO and RCLineNO =DNLineNO) as surplusQty where RecordNumber =DNNO and RCLineNO =DNLineNO) as surplusQty
from [SFIS_PTD].[dbo].ZDNDetail where DNNO ='{recordNumber}' and DNLineNO ='{lineNo}'"; from ZDNDetail where DNNO ='{recordNumber}' and DNLineNO ='{lineNo}'";
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
{ {
cmd.CommandText = strSQL; cmd.CommandText = strSQL;
@ -3747,8 +3721,8 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{ {
//用ZProductTrans最新RecordType 檢查PTDFlowRules邏輯 //用ZProductTrans最新RecordType 檢查PTDFlowRules邏輯
bool bolChkFlow = false; bool bolChkFlow = false;
string strSQL = $@"Select [FormID] FROM [SFIS_PTD].[dbo].[PTDFlowRules] string strSQL = $@"Select FormID FROM PTDFlowRules
where [ToID] ='{recordType}'"; where ToID ='{recordType}'";
DataTable dtPTDFlowRules = new DataTable(); DataTable dtPTDFlowRules = new DataTable();
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
{ {
@ -3763,9 +3737,9 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
} }
strSQL = @$"Select [RecordTypeID] FROM [SFIS_PTD].[dbo].[ZProductTrans] strSQL = @$"Select RecordTypeID FROM ZProductTrans
where [SerialNumber] ='{serialNumber}' where SerialNumber ='{serialNumber}'
Order by [RecordDate] Desc"; Order by RecordDate Desc";
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
{ {
cmd.CommandText = strSQL; cmd.CommandText = strSQL;
@ -3825,9 +3799,9 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
// //查剩餘數 // //查剩餘數
// string strSQL = $@"select ShipQty - // string strSQL = $@"select ShipQty -
// (SELECT count(1) // (SELECT count(1)
// FROM [SFIS_PTD].[dbo].[ZWHPickListDetail] // FROM ZWHPickListDetail
// where RecordNumber =DNNO and RCLineNO =DNLineNO and TaskStatus ='Picked') as surplusQty // where RecordNumber =DNNO and RCLineNO =DNLineNO and TaskStatus ='Picked') as surplusQty
// from [SFIS_PTD].[dbo].ZDNDetail where DNNO ='{recordNumber}' and DNLineNO ='{lineNo}'"; // from ZDNDetail where DNNO ='{recordNumber}' and DNLineNO ='{lineNo}'";
// using (var cmd = connPTD.CreateCommand()) // using (var cmd = connPTD.CreateCommand())
// { // {
// cmd.CommandText = strSQL; // cmd.CommandText = strSQL;
@ -3869,7 +3843,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
// } // }
// //用ZProductTrans最新RecordType 檢查PTDFlowRules邏輯 // //用ZProductTrans最新RecordType 檢查PTDFlowRules邏輯
// bool bolChkFlow = false; // bool bolChkFlow = false;
// string strSQL = $@"Select [FormID] FROM [SFIS_PTD].[dbo].[PTDFlowRules] // string strSQL = $@"Select [FormID] FROM PTDFlowRules
// where [ToID] ='{recordType}'"; // where [ToID] ='{recordType}'";
// DataTable dtPTDFlowRules = new DataTable(); // DataTable dtPTDFlowRules = new DataTable();
// using (var cmd = connPTD.CreateCommand()) // using (var cmd = connPTD.CreateCommand())
@ -3885,7 +3859,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
// } // }
// } // }
// strSQL = @$"Select [RecordTypeID] FROM [SFIS_PTD].[dbo].[ZProductTrans] // strSQL = @$"Select [RecordTypeID] FROM ZProductTrans
// where [SerialNumber] ='{serialNumber}' // where [SerialNumber] ='{serialNumber}'
// Order by [RecordDate] Desc"; // Order by [RecordDate] Desc";
// using (var cmd = connPTD.CreateCommand()) // using (var cmd = connPTD.CreateCommand())
@ -3936,8 +3910,8 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
try try
{ {
string strSQL = $@"select a.RecordTypeID,(select distinct TypeName from SFIS_PTD.dbo.RecordTypeInfo where ID = a.RecordTypeID ) as TypeName string strSQL = $@"select a.RecordTypeID,(select distinct TypeName from RecordTypeInfo where ID = a.RecordTypeID ) as TypeName
from SFIS_PTD.dbo.ZProductTrans a group by a.RecordTypeID"; from ZProductTrans a group by a.RecordTypeID";
DataTable dtRecordTypes = new DataTable(); DataTable dtRecordTypes = new DataTable();
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
{ {
@ -3999,7 +3973,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
SWITCHOFFSET(CONVERT(datetimeoffset, SWITCHOFFSET(CONVERT(datetimeoffset,
a.RecordDate), a.RecordDate),
DATENAME(TzOffset, SYSDATETIMEOFFSET()))) as RecordDate DATENAME(TzOffset, SYSDATETIMEOFFSET()))) as RecordDate
FROM SFIS_PTD.dbo.ZProductTrans a where 1=1 "; FROM ZProductTrans a where 1=1 ";
if (recordType != null && recordType != "" && recordType != "全部") if (recordType != null && recordType != "" && recordType != "全部")
{ {
strSQL += $" And a.RecordTypeID ='{recordType}'"; strSQL += $" And a.RecordTypeID ='{recordType}'";
@ -4113,7 +4087,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
a.SerialNumber 'SN',a.ProductID ,a.LocationID 'Location', a.SerialNumber 'SN',a.ProductID ,a.LocationID 'Location',
a.EmplID as empID , a.CreateDate , a.ExtNotes ,a.RecordDate , a.EmplID as empID , a.CreateDate , a.ExtNotes ,a.RecordDate ,
a.SalesOrderNumber AS soNumber , a.SOLineNO AS soLineNo ,a.ERP_CustomerID 'Customer' a.SalesOrderNumber AS soNumber , a.SOLineNO AS soLineNo ,a.ERP_CustomerID 'Customer'
FROM SFIS_PTD.dbo.ZProductTrans a where 1=1 "; FROM ZProductTrans a where 1=1 ";
if (recordType != null && recordType != "" && recordType != "全部") if (recordType != null && recordType != "" && recordType != "全部")
{ {
@ -4239,7 +4213,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
try try
{ {
string strSQL = $@"Select top 1 SoldCustomerID 'Customer' from SFIS_PTD.dbo.ZDNDetail where DNNo ='{recordNumber}'"; string strSQL = $@"Select top 1 SoldCustomerID 'Customer' from ZDNDetail where DNNo ='{recordNumber}'";
string strCustomer = ""; string strCustomer = "";
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
@ -4287,7 +4261,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
try try
{ {
string strSQL = $@"select * from SFIS_PTD.dbo.RecordTypeInfo"; string strSQL = $@"select * from RecordTypeInfo";
DataTable dtRecordTypeInfo = new DataTable(); DataTable dtRecordTypeInfo = new DataTable();
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
@ -4346,7 +4320,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
try try
{ {
string strSQL = $@"select * from SFIS_PTD.dbo.RecordTypeInfo Where SEQ ='{id}'"; string strSQL = $@"select * from RecordTypeInfo Where SEQ ='{id}'";
DataTable dtRecordTypeInfo = new DataTable(); DataTable dtRecordTypeInfo = new DataTable();
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
@ -4407,7 +4381,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
try try
{ {
string strSQL = $@"INSERT INTO SFIS_PTD.dbo.RecordTypeInfo (ID, RBU, TypeName, TypeDesc, Source, PrefixCode, Length,Status) string strSQL = $@"INSERT INTO RecordTypeInfo (ID, RBU, TypeName, TypeDesc, Source, PrefixCode, Length,Status)
VALUES ('{RecordTypeInfo.ID}','{RecordTypeInfo.RBU}', '{RecordTypeInfo.TypeName}', '{RecordTypeInfo.TypeDesc}', VALUES ('{RecordTypeInfo.ID}','{RecordTypeInfo.RBU}', '{RecordTypeInfo.TypeName}', '{RecordTypeInfo.TypeDesc}',
'{RecordTypeInfo.Source}', '{RecordTypeInfo.PrefixCode}', {RecordTypeInfo.Length} '{RecordTypeInfo.Source}', '{RecordTypeInfo.PrefixCode}', {RecordTypeInfo.Length}
,'{RecordTypeInfo.Status}' )"; ,'{RecordTypeInfo.Status}' )";
@ -4458,7 +4432,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
try try
{ {
string strSQL = $@"UPDATE SFIS_PTD.dbo.RecordTypeInfo string strSQL = $@"UPDATE RecordTypeInfo
SET RBU = '{RecordTypeInfo.RBU}', SET RBU = '{RecordTypeInfo.RBU}',
ID = '{RecordTypeInfo.ID}', ID = '{RecordTypeInfo.ID}',
TypeName = '{RecordTypeInfo.TypeName}', TypeName = '{RecordTypeInfo.TypeName}',
@ -4507,7 +4481,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
try try
{ {
string strSQL = $@"DELETE FROM SFIS_PTD.dbo.RecordTypeInfo string strSQL = $@"DELETE FROM RecordTypeInfo
WHERE SEQ = '{id}'"; WHERE SEQ = '{id}'";
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
@ -4551,7 +4525,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
try try
{ {
string strSQL = $@"select * from SFIS_PTD.dbo.CustomerItemMailGroup"; string strSQL = $@"select * from CustomerItemMailGroup";
DataTable dtCustomerItemMailGroup = new DataTable(); DataTable dtCustomerItemMailGroup = new DataTable();
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
{ {
@ -4604,7 +4578,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
try try
{ {
string strSQL = $@"select * from SFIS_PTD.dbo.CustomerItemMailGroup Where 1=1"; string strSQL = $@"select * from CustomerItemMailGroup Where 1=1";
if (id != null && id != "") if (id != null && id != "")
{ {
strSQL += $@" And CustomerCode ='{id}'"; strSQL += $@" And CustomerCode ='{id}'";
@ -4662,7 +4636,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
try try
{ {
string strSQL = $@"INSERT INTO SFIS_PTD.dbo.[CustomerItemMailGroup] ([ItemNumber],[CustomerCode],[MailGroup],[StatusNo]) string strSQL = $@"INSERT INTO CustomerItemMailGroup (ItemNumber, CustomerCode, MailGroup, StatusNo)
VALUES ('{CustomerItemMailGroup.ItemNumber}','{CustomerItemMailGroup.CustomerCode}', VALUES ('{CustomerItemMailGroup.ItemNumber}','{CustomerItemMailGroup.CustomerCode}',
'{CustomerItemMailGroup.MailGroup}', '{CustomerItemMailGroup.StatusNo}')"; '{CustomerItemMailGroup.MailGroup}', '{CustomerItemMailGroup.StatusNo}')";
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
@ -4711,7 +4685,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
try try
{ {
string strSQL = $@"UPDATE SFIS_PTD.dbo.CustomerItemMailGroup string strSQL = $@"UPDATE CustomerItemMailGroup
SET ItemNumber = '{CustomerItemMailGroup.ItemNumber}', SET ItemNumber = '{CustomerItemMailGroup.ItemNumber}',
MailGroup = '{CustomerItemMailGroup.MailGroup}' MailGroup = '{CustomerItemMailGroup.MailGroup}'
WHERE CustomerCode = '{id}'"; WHERE CustomerCode = '{id}'";
@ -4754,7 +4728,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
try try
{ {
string strSQL = $@"UPDATE SFIS_PTD.dbo.CustomerItemMailGroup string strSQL = $@"UPDATE CustomerItemMailGroup
SET StatusNo = SET StatusNo =
CASE CASE
WHEN StatusNo = 'A' THEN 'S' WHEN StatusNo = 'A' THEN 'S'
@ -4954,8 +4928,8 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
//用ZProductTrans最新RecordType 檢查PTDFlowRules邏輯 //用ZProductTrans最新RecordType 檢查PTDFlowRules邏輯
bool bolChkFlow = false; bool bolChkFlow = false;
strSQL = $@"Select [FormID] FROM [SFIS_PTD].[dbo].[PTDFlowRules] strSQL = $@"Select FormID FROM PTDFlowRules
where [ToID] ='{Data.RecordTypeID}'"; where ToID ='{Data.RecordTypeID}'";
DataTable dtPTDFlowRules = new DataTable(); DataTable dtPTDFlowRules = new DataTable();
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
{ {
@ -4970,9 +4944,9 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
} }
strSQL = @$"Select [RecordTypeID] FROM [SFIS_PTD].[dbo].[ZProductTrans] strSQL = @$"Select RecordTypeID FROM ZProductTrans
where [SerialNumber] ='{Data.ShipmentSN}' where SerialNumber ='{Data.ShipmentSN}'
Order by [RecordDate] Desc"; Order by RecordDate Desc";
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
{ {
cmd.CommandText = strSQL; cmd.CommandText = strSQL;
@ -5047,8 +5021,8 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
try try
{ {
string strSQL = $@"DELETE FROM SFIS_PTD.dbo.[ZWHPickListDetail] string strSQL = $@"DELETE FROM ZWHPickListDetail
WHERE [TaskStatus] = 'Picked' And [ShipmentSN] ='{sn}'"; WHERE TaskStatus = 'Picked' And ShipmentSN ='{sn}'";
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
{ {
cmd.CommandText = strSQL; cmd.CommandText = strSQL;
@ -5089,8 +5063,8 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
try try
{ {
string strSQL = $@"DELETE FROM SFIS_PTD.dbo.[ZWHPickListDetail] string strSQL = $@"DELETE FROM ZWHPickListDetail
WHERE [TaskStatus] = 'Picked' And [RecordNumber] ='{recordNo}' AND [RCLineNO] = '{lineNo}'"; WHERE TaskStatus = 'Picked' And RecordNumber ='{recordNo}' AND RCLineNO = '{lineNo}'";
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
{ {
cmd.CommandText = strSQL; cmd.CommandText = strSQL;
@ -5240,15 +5214,28 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{ {
salesOrderNumber = dnDetail.FirstOrDefault().OrderNo; salesOrderNumber = dnDetail.FirstOrDefault().OrderNo;
sOLineNO = dnDetail.FirstOrDefault().OrderLineNO; sOLineNO = dnDetail.FirstOrDefault().OrderLineNO;
eRP_CustomerID = dnDetail.FirstOrDefault().ShipCustomerID; eRP_CustomerID = dnDetail.FirstOrDefault().SoldCustomerID;
} }
} }
var mailDataItem = new List<SNDataModel>(); var mailDataItem = new List<SNDataModel>();
//ZWHPickListDetail查SN資訊 //ZWHPickListDetail查SN資訊
strSQL = $@"Select * FROM [SFIS_PTD].[dbo].[ZWHPickListDetail] strSQL = $@" SELECT
where RecordNumber='{SNData.dnno}' and RCLineNO='{SNData.dnLineNO}' and ProductID ='{SNData.productID}'"; ShipmentSN,
StartDate,
ExpectStartDate,
a.ProductID,
b.CurrentMOID
FROM ZWHPickListDetail a --
LEFT JOIN {SFISDbContext}ZProductSN b
ON a.ShipmentSN = b.CurrentShipmentSN
LEFT JOIN {SFISDbContext}ZMO c
ON b.CurrentMOID = c.MOID
WHERE
RecordNumber = '{SNData.dnno}'
AND RCLineNO = '{SNData.dnLineNO}'
AND a.ProductID = '{SNData.productID}'";
var q = await ptdConnection.QueryAsync<dynamic>(strSQL); var q = await ptdConnection.QueryAsync<dynamic>(strSQL);
@ -5256,7 +5243,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{ {
string strLatest; string strLatest;
//確認此出貨序號是否有ZHistoryKeyDefine //確認此出貨序號是否有ZHistoryKeyDefine
strSQL = $@"select Seed FROM [SFIS_PTD].[dbo].[ZHistoryKeyDefine] where serialnumber ='{row.ShipmentSN}'"; strSQL = $@"select Seed FROM ZHistoryKeyDefine where serialnumber ='{row.ShipmentSN}'";
var q1 = await ptdConnection.QueryAsync<dynamic>(strSQL); var q1 = await ptdConnection.QueryAsync<dynamic>(strSQL);
@ -5266,11 +5253,11 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
int nIdx = seed + 1; int nIdx = seed + 1;
strLatest = row.ShipmentSN + nIdx.ToString().PadLeft(4, '0');//組成HistoryID strLatest = row.ShipmentSN + nIdx.ToString().PadLeft(4, '0');//組成HistoryID
//HistoryKeyDefine //HistoryKeyDefine
strSQL = @$"UPDATE [SFIS_PTD].[dbo].[ZHistoryKeyDefine] strSQL = @$"UPDATE ZHistoryKeyDefine
SET [Seed] = {nIdx} where [SerialNumber]='{row.ShipmentSN}'"; SET Seed = {nIdx} where SerialNumber ='{row.ShipmentSN}'";
colSQL.Add(strSQL); colSQL.Add(strSQL);
//ZSNInfo //ZSNInfo
strSQL = @$"Update [SFIS_PTD].[dbo].[ZSNInfo] SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}', strSQL = @$"Update ZSNInfo SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}',
CurrentProductID='{row.ProductID}' CurrentProductID='{row.ProductID}'
where SerialNumber='{row.ShipmentSN}'"; where SerialNumber='{row.ShipmentSN}'";
colSQL.Add(strSQL); colSQL.Add(strSQL);
@ -5279,14 +5266,14 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{ {
strLatest = row.ShipmentSN + 1.ToString().PadLeft(4, '0');//組成HistoryID strLatest = row.ShipmentSN + 1.ToString().PadLeft(4, '0');//組成HistoryID
//ZHistoryKeyDefine //ZHistoryKeyDefine
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZHistoryKeyDefine] ([SerialNumber],[Seed]) strSQL = @$"INSERT INTO ZHistoryKeyDefine (SerialNumber, Seed)
VALUES ('{row.ShipmentSN}',1)"; VALUES ('{row.ShipmentSN}',1)";
colSQL.Add(strSQL); colSQL.Add(strSQL);
//ZSNInfo //ZSNInfo
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZSNInfo] ([SerialNumber],[CurrentProductID],[OriginalProductID], strSQL = @$"INSERT INTO ZSNInfo (SerialNumber, CurrentProductID, OriginalProductID,
[LocationID],[LatestHistoryID],[RecordTypeID], LocationID, LatestHistoryID, RecordTypeID,
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID], OwnerPlantID, OwnerCompanyID, CreatePlantID, CreateCompanyID,
[ModifyDate]) VALUES ModifyDate) VALUES
('{row.ShipmentSN}','{row.ProductID}','{row.ProductID}', ('{row.ShipmentSN}','{row.ProductID}','{row.ProductID}',
'9000','{strLatest}','{strRecordType}', '9000','{strLatest}','{strRecordType}',
'{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}', '{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}',
@ -5294,13 +5281,13 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
colSQL.Add(strSQL); colSQL.Add(strSQL);
} }
//ZProductTrans //ZProductTrans
strSQL = $@"INSERT INTO [SFIS_PTD].[dbo].[ZProductTrans] strSQL = $@"INSERT INTO ZProductTrans
([HistoryID],[SerialNumber],[RecordTypeID],[RecordNumber],[RCLineNO],[RecordDate], (HistoryID, SerialNumber, RecordTypeID, RecordNumber, RCLineNO, RecordDate,
[ProductID],[IsChangeID],[LocationID],[EmplID],[IsDelete], ProductID, IsChangeID, LocationID, EmplID, IsDelete,
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID], OwnerPlantID, OwnerCompanyID, CreatePlantID, CreateCompanyID,
[CreatorID],[CreateDate],[ModifierID],[ModifyDate], CreatorID, CreateDate, ModifierID, ModifyDate,
[chkflag],[IsBranchCoReceived],[MOID], chkflag, IsBranchCoReceived, MOID,
[SalesOrderNumber],[SOLineNO],[ERP_CustomerID]) VALUES SalesOrderNumber, SOLineNO, ERP_CustomerID) VALUES
('{strLatest}','{row.ShipmentSN}','{strRecordType}','{SNData.dnno}','{SNData.dnLineNO}','{strRecordDate}', ('{strLatest}','{row.ShipmentSN}','{strRecordType}','{SNData.dnno}','{SNData.dnLineNO}','{strRecordDate}',
'{SNData.productID}',0,'9000','{strEmpId}',0, '{SNData.productID}',0,'9000','{strEmpId}',0,
'{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}', '{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}',
@ -5313,10 +5300,13 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
DnNo = SNData.dnno, DnNo = SNData.dnno,
LineNo = SNData.dnLineNO, LineNo = SNData.dnLineNO,
Material = SNData.productID, Material = SNData.productID,
Sn = row.ShipmentSN ShipQty = SNData.shipQty,
Sn = row.ShipmentSN,
StartDate = row.StartDate ?? row.ExpectStartDate, //StartDate(實際開工日),ExpectStartDate(預計開工日)
CurrentMOID = row.CurrentMOID
}); });
} }
strSQL = $@"Update [SFIS_PTD].[dbo].[ZWHPickListDetail] set TaskStatus ='Recorded' strSQL = $@"Update ZWHPickListDetail set TaskStatus ='Recorded'
where RecordNumber='{SNData.dnno}' and RCLineNO='{SNData.dnLineNO}'"; where RecordNumber='{SNData.dnno}' and RCLineNO='{SNData.dnLineNO}'";
colSQL.Add(strSQL); colSQL.Add(strSQL);
@ -5397,7 +5387,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
foreach (PTD007TableDataModel SNData in Data.TableData) foreach (PTD007TableDataModel SNData in Data.TableData)
{ {
//ZWHPickListDetail查SN資訊 //ZWHPickListDetail查SN資訊
strSQL = $@"Select * FROM [SFIS_PTD].[dbo].[ZWHPickListDetail] strSQL = $@"Select * FROM ZWHPickListDetail
where RecordNumber='{SNData.dnno}' and RCLineNO='{SNData.dnLineNO}'"; where RecordNumber='{SNData.dnno}' and RCLineNO='{SNData.dnLineNO}'";
DataTable dtSNData = new DataTable(); DataTable dtSNData = new DataTable();
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
@ -5416,7 +5406,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{ {
string strLatest; string strLatest;
//確認此出貨序號是否有ZHistoryKeyDefine //確認此出貨序號是否有ZHistoryKeyDefine
strSQL = $@"select Seed FROM [SFIS_PTD].[dbo].[ZHistoryKeyDefine] where serialnumber ='{row["ShipmentSN"]}'"; strSQL = $@"select Seed FROM ZHistoryKeyDefine where serialnumber ='{row["ShipmentSN"]}'";
using (var cmd = connPTD.CreateCommand()) using (var cmd = connPTD.CreateCommand())
{ {
cmd.CommandText = strSQL; cmd.CommandText = strSQL;
@ -5428,11 +5418,11 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
int nIdx = seed + 1; int nIdx = seed + 1;
strLatest = row["ShipmentSN"].ToString() + nIdx.ToString().PadLeft(4, '0');//組成HistoryID strLatest = row["ShipmentSN"].ToString() + nIdx.ToString().PadLeft(4, '0');//組成HistoryID
//HistoryKeyDefine //HistoryKeyDefine
strSQL = @$"UPDATE [SFIS_PTD].[dbo].[ZHistoryKeyDefine] strSQL = @$"UPDATE ZHistoryKeyDefine
SET [Seed] = {nIdx} where [SerialNumber]='{row["ShipmentSN"]}'"; SET Seed = {nIdx} where SerialNumber ='{row["ShipmentSN"]}'";
colSQL.Add(strSQL); colSQL.Add(strSQL);
//ZSNInfo //ZSNInfoF
strSQL = @$"Update [SFIS_PTD].[dbo].[ZSNInfo] SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}', strSQL = @$"Update ZSNInfo SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}',
CurrentProductID='{row["ProductID"]}' CurrentProductID='{row["ProductID"]}'
where SerialNumber='{row["ShipmentSN"]}'"; where SerialNumber='{row["ShipmentSN"]}'";
colSQL.Add(strSQL); colSQL.Add(strSQL);
@ -5441,14 +5431,14 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{ {
strLatest = row["ShipmentSN"].ToString() + 1.ToString().PadLeft(4, '0');//組成HistoryID strLatest = row["ShipmentSN"].ToString() + 1.ToString().PadLeft(4, '0');//組成HistoryID
//ZHistoryKeyDefine //ZHistoryKeyDefine
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZHistoryKeyDefine] ([SerialNumber],[Seed]) strSQL = @$"INSERT INTO ZHistoryKeyDefine (SerialNumber, Seed)
VALUES ('{row["ShipmentSN"]}',1)"; VALUES ('{row["ShipmentSN"]}',1)";
colSQL.Add(strSQL); colSQL.Add(strSQL);
//ZSNInfo //ZSNInfo
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZSNInfo] ([SerialNumber],[CurrentProductID],[OriginalProductID], strSQL = @$"INSERT INTO ZSNInfo (SerialNumber, CurrentProductID, OriginalProductID,
[LocationID],[LatestHistoryID],[RecordTypeID], LocationID, LatestHistoryID, RecordTypeID,
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID], OwnerPlantID, OwnerCompanyID, CreatePlantID, CreateCompanyID,
[ModifyDate]) VALUES ModifyDate) VALUES
('{row["ShipmentSN"]}','{row["ProductID"]}','{row["ProductID"]}', ('{row["ShipmentSN"]}','{row["ProductID"]}','{row["ProductID"]}',
'9000','{strLatest}','{strRecordType}', '9000','{strLatest}','{strRecordType}',
'{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}', '{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}',
@ -5456,12 +5446,12 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
colSQL.Add(strSQL); colSQL.Add(strSQL);
} }
//ZProductTrans //ZProductTrans
strSQL = $@"INSERT INTO [SFIS_PTD].[dbo].[ZProductTrans] strSQL = $@"INSERT INTO ZProductTrans
([HistoryID],[SerialNumber],[RecordTypeID],[RecordNumber],[RCLineNO],[RecordDate], (HistoryID, SerialNumber, RecordTypeID, RecordNumber, RCLineNO, RecordDate,
[ProductID],[IsChangeID],[LocationID],[EmplID],[IsDelete], ProductID, IsChangeID, LocationID, EmplID, IsDelete,
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID], OwnerPlantID, OwnerCompanyID,[CreatePlantID, CreateCompanyID,
[CreatorID],[CreateDate],[ModifierID],[ModifyDate], CreatorID, CreateDate, ModifierID, ModifyDate,
[chkflag],[IsBranchCoReceived],[MOID]) VALUES chkflag, IsBranchCoReceived, MOID) VALUES
('{strLatest}','{row["ShipmentSN"]}','{strRecordType}','{SNData.dnno}','{SNData.dnLineNO}','{strRecordDate}', ('{strLatest}','{row["ShipmentSN"]}','{strRecordType}','{SNData.dnno}','{SNData.dnLineNO}','{strRecordDate}',
'{SNData.productID}',0,'9000','{SNData.soldCustomerID.ToString()}',0, '{SNData.productID}',0,'9000','{SNData.soldCustomerID.ToString()}',0,
'{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}', '{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}',
@ -5470,7 +5460,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
} }
} }
} }
strSQL = $@"Update [SFIS_PTD].[dbo].[ZWHPickListDetail] set TaskStatus ='Recorded' strSQL = $@"Update ZWHPickListDetail set TaskStatus ='Recorded'
where RecordNumber='{SNData.dnno}' and RCLineNO='{SNData.dnLineNO}'"; where RecordNumber='{SNData.dnno}' and RCLineNO='{SNData.dnLineNO}'";
colSQL.Add(strSQL); colSQL.Add(strSQL);
} }
@ -5556,14 +5546,14 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
EmplID AS SoldCustomerID , EmplID AS SoldCustomerID ,
count(*) as Qty , count(*) as Qty ,
OwnerPlantID OwnerPlantID
FROM SFIS_PTD.dbo.ZProductTrans FROM ZProductTrans
WHERE ERP_CustomerID IN ({string.Join(", ", erpCustomerId.ConvertAll(id => $"N'{id}'"))}) WHERE ERP_CustomerID IN ({string.Join(", ", erpCustomerId.ConvertAll(id => $"N'{id}'"))})
AND RecordNumber = @RecordNumber AND RecordNumber = @RecordNumber
AND IsBranchCoReceived = 0 AND IsBranchCoReceived = 0
AND RecordTypeID in (N'601',N'633',N'601DB') AND RecordTypeID in (N'601',N'633',N'601DB')
GROUP BY RecordNumber, RCLineNO, ProductID, OwnerPlantID ,EmplID GROUP BY RecordNumber, RCLineNO, ProductID, OwnerPlantID ,EmplID
) A ) A
LEFT JOIN SFIS_PTD.dbo.ZDNDetail B on A.DNNO = B.DNNO AND A.DNLineNO = B.DNLineNO LEFT JOIN ZDNDetail B on A.DNNO = B.DNNO AND A.DNLineNO = B.DNLineNO
ORDER BY A.DNNO, A.DNLineNO "; ORDER BY A.DNNO, A.DNLineNO ";
DynamicParameters p = new DynamicParameters(); DynamicParameters p = new DynamicParameters();
@ -5634,7 +5624,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
var mailDataItem = new List<SNDataModel>(); var mailDataItem = new List<SNDataModel>();
//ZProductTrans //ZProductTrans
strSQL = $@" SELECT * FROM SFIS_PTD.dbo.ZProductTrans strSQL = $@" SELECT * FROM ZProductTrans
WHERE ERP_CustomerID IN ({string.Join(", ", erpCustomerId.ConvertAll(id => $"N'{id}'"))}) WHERE ERP_CustomerID IN ({string.Join(", ", erpCustomerId.ConvertAll(id => $"N'{id}'"))})
AND IsBranchCoReceived = 0 AND IsBranchCoReceived = 0
AND RecordTypeID in (N'601',N'633',N'601DB') AND RecordTypeID in (N'601',N'633',N'601DB')
@ -5647,7 +5637,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{ {
string strLatest; string strLatest;
//確認此出貨序號是否有ZHistoryKeyDefine //確認此出貨序號是否有ZHistoryKeyDefine
strSQL = $@"select Seed FROM [SFIS_PTD].[dbo].[ZHistoryKeyDefine] where serialnumber ='{row.SerialNumber}'"; strSQL = $@"select Seed FROM ZHistoryKeyDefine where serialnumber ='{row.SerialNumber}'";
var q1 = await ptdConnection.QueryAsync<dynamic>(strSQL); var q1 = await ptdConnection.QueryAsync<dynamic>(strSQL);
if (q1.Any()) if (q1.Any())
@ -5656,11 +5646,11 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
int nIdx = seed + 1; int nIdx = seed + 1;
strLatest = row.SerialNumber + nIdx.ToString().PadLeft(4, '0');//組成HistoryID strLatest = row.SerialNumber + nIdx.ToString().PadLeft(4, '0');//組成HistoryID
//HistoryKeyDefine //HistoryKeyDefine
strSQL = @$"UPDATE [SFIS_PTD].[dbo].[ZHistoryKeyDefine] strSQL = @$"UPDATE ZHistoryKeyDefine
SET [Seed] = {nIdx} where [SerialNumber]='{row.SerialNumber}'"; SET Seed = {nIdx} where SerialNumber ='{row.SerialNumber}'";
colSQL.Add(strSQL); colSQL.Add(strSQL);
//ZSNInfo //ZSNInfo
strSQL = @$"Update [SFIS_PTD].[dbo].[ZSNInfo] SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}', strSQL = @$"Update ZSNInfo SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}',
CurrentProductID='{row.ProductID}' CurrentProductID='{row.ProductID}'
where SerialNumber='{row.SerialNumber}'"; where SerialNumber='{row.SerialNumber}'";
colSQL.Add(strSQL); colSQL.Add(strSQL);
@ -5669,14 +5659,14 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{ {
strLatest = row.SerialNumber + 1.ToString().PadLeft(4, '0');//組成HistoryID strLatest = row.SerialNumber + 1.ToString().PadLeft(4, '0');//組成HistoryID
//ZHistoryKeyDefine //ZHistoryKeyDefine
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZHistoryKeyDefine] ([SerialNumber],[Seed]) strSQL = @$"INSERT INTO ZHistoryKeyDefine (SerialNumber, Seed)
VALUES ('{row.SerialNumber}',1)"; VALUES ('{row.SerialNumber}',1)";
colSQL.Add(strSQL); colSQL.Add(strSQL);
//ZSNInfo //ZSNInfo
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZSNInfo] ([SerialNumber],[CurrentProductID],[OriginalProductID], strSQL = @$"INSERT INTO ZSNInfo (SerialNumber, CurrentProductID, OriginalProductID,
[LocationID],[LatestHistoryID],[RecordTypeID], LocationID, LatestHistoryID, RecordTypeID,
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID], OwnerPlantID, OwnerCompanyID, CreatePlantID, CreateCompanyID,
[ModifyDate]) VALUES ModifyDate) VALUES
('{row.SerialNumber}','{row.ProductID}','{row.ProductID}', ('{row.SerialNumber}','{row.ProductID}','{row.ProductID}',
'9000','{strLatest}','{strRecordType}', '9000','{strLatest}','{strRecordType}',
'{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}', '{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}',
@ -5684,12 +5674,12 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
colSQL.Add(strSQL); colSQL.Add(strSQL);
} }
//ZProductTrans //ZProductTrans
strSQL = $@"INSERT INTO [SFIS_PTD].[dbo].[ZProductTrans] strSQL = $@"INSERT INTO ZProductTrans
([HistoryID],[SerialNumber],[RecordTypeID],[RecordNumber],[RCLineNO],[RecordDate], (HistoryID, SerialNumber, RecordTypeID, RecordNumber, RCLineNO, RecordDate,
[ProductID],[IsChangeID],[LocationID],[EmplID],[IsDelete], ProductID, IsChangeID, LocationID, EmplID, IsDelete,
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID], OwnerPlantID, OwnerCompanyID, CreatePlantID, CreateCompanyID,
[CreatorID],[CreateDate],[ModifierID],[ModifyDate], CreatorID, CreateDate, ModifierID, ModifyDate,
[chkflag],[IsBranchCoReceived],[MOID]) VALUES chkflag, IsBranchCoReceived, MOID) VALUES
('{strLatest}','{row.SerialNumber}','{strRecordType}','{SNData.dnno}','{SNData.dnLineNO}','{strRecordDate}', ('{strLatest}','{row.SerialNumber}','{strRecordType}','{SNData.dnno}','{SNData.dnLineNO}','{strRecordDate}',
'{SNData.productID}',0,'9000','{SNData.soldCustomerID.ToString()}',0, '{SNData.productID}',0,'9000','{SNData.soldCustomerID.ToString()}',0,
'{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}', '{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}',
@ -5704,7 +5694,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
Sn = row.SerialNumber Sn = row.SerialNumber
}); });
} }
strSQL = $@" Update SFIS_PTD.dbo.ZProductTrans set IsBranchCoReceived ='1' strSQL = $@" Update ZProductTrans set IsBranchCoReceived ='1'
WHERE ERP_CustomerID IN ({string.Join(", ", erpCustomerId.ConvertAll(id => $"N'{id}'"))}) WHERE ERP_CustomerID IN ({string.Join(", ", erpCustomerId.ConvertAll(id => $"N'{id}'"))})
AND IsBranchCoReceived = 0 AND IsBranchCoReceived = 0
AND RecordTypeID in (N'601',N'633',N'601DB') AND RecordTypeID in (N'601',N'633',N'601DB')
@ -5766,7 +5756,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
string strSQL = $@"SELECT RecordTypeID,RecordNumber,RCLineNO 'LineNo', string strSQL = $@"SELECT RecordTypeID,RecordNumber,RCLineNO 'LineNo',
SerialNumber 'SN',ProductID , CreateDate SerialNumber 'SN',ProductID , CreateDate
FROM SFIS_PTD.dbo.ZProductTrans where RecordNumber ='{recordNumber}' And RCLineNO ='{lineNo}' FROM ZProductTrans where RecordNumber ='{recordNumber}' And RCLineNO ='{lineNo}'
And ProductID = '{materialNo}'"; And ProductID = '{materialNo}'";
if (shippingSN != null && shippingSN != "") if (shippingSN != null && shippingSN != "")
{ {
@ -5853,7 +5843,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
if (Data.type == 0) //還原 if (Data.type == 0) //還原
{ {
//SQL Server 2012後才能使用 //SQL Server 2012後才能使用
//strSQL = $"Select HistoryID,RecordTypeID,ModifyDate from [SFIS_PTD].[dbo].[ZProductTrans] " + //strSQL = $"Select HistoryID,RecordTypeID,ModifyDate from ZProductTrans " +
// $"where [SerialNumber] = '{SNData.sn}' " + // $"where [SerialNumber] = '{SNData.sn}' " +
// $"Order by HistoryID desc offset 1 row fetch next 1 rows only "; // $"Order by HistoryID desc offset 1 row fetch next 1 rows only ";
@ -5863,8 +5853,8 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
RecordTypeID, RecordTypeID,
ModifyDate, ModifyDate,
ROW_NUMBER() OVER (ORDER BY HistoryID DESC) AS RowNum ROW_NUMBER() OVER (ORDER BY HistoryID DESC) AS RowNum
FROM [SFIS_PTD].[dbo].[ZProductTrans] FROM ZProductTrans
WHERE [SerialNumber] = '{SNData.sn}' WHERE SerialNumber = '{SNData.sn}'
) )
SELECT SELECT
HistoryID, HistoryID,
@ -5880,21 +5870,21 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{ {
if (reader.Read()) if (reader.Read())
{ {
strSQL = $"Update [SFIS_PTD].[dbo].[ZSNInfo] set RecordTypeID ='{reader["RecordTypeID"]}',ModifyDate ='{reader["ModifyDate"]}',LatestHistoryID ='{reader["HistoryID"]}' " + strSQL = $"Update ZSNInfo set RecordTypeID ='{reader["RecordTypeID"]}',ModifyDate ='{reader["ModifyDate"]}',LatestHistoryID ='{reader["HistoryID"]}' " +
$"where SerialNumber ='{SNData.sn}'"; $"where SerialNumber ='{SNData.sn}'";
colSQL.Add(strSQL); colSQL.Add(strSQL);
int seed = int.Parse(reader["HistoryID"].ToString().Substring(reader["HistoryID"].ToString().Length - 4)); int seed = int.Parse(reader["HistoryID"].ToString().Substring(reader["HistoryID"].ToString().Length - 4));
strSQL = @$"UPDATE [SFIS_PTD].[dbo].[ZHistoryKeyDefine] strSQL = @$"UPDATE ZHistoryKeyDefine
SET [Seed] = {seed} where [SerialNumber]='{SNData.sn}'"; SET Seed = {seed} where SerialNumber ='{SNData.sn}'";
colSQL.Add(strSQL); colSQL.Add(strSQL);
} }
else else
{ {
strSQL = $"Delete [SFIS_PTD].[dbo].[ZSNInfo] where SerialNumber ='{SNData.sn}'"; strSQL = $"Delete ZSNInfo where SerialNumber ='{SNData.sn}'";
colSQL.Add(strSQL); colSQL.Add(strSQL);
strSQL = $"Delete [SFIS_PTD].[dbo].[ZHistoryKeyDefine] where SerialNumber ='{SNData.sn}'"; strSQL = $"Delete ZHistoryKeyDefine where SerialNumber ='{SNData.sn}'";
colSQL.Add(strSQL); colSQL.Add(strSQL);
} }
} }
@ -5906,13 +5896,13 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
throw new Exception(SNData.recordTypeID + "狀態不能刪除!"); throw new Exception(SNData.recordTypeID + "狀態不能刪除!");
} }
strSQL = $"Delete [SFIS_PTD].[dbo].[ZProductTrans] " + strSQL = $"Delete ZProductTrans " +
$"where [SerialNumber] = '{SNData.sn}' " + $"where [SerialNumber] = '{SNData.sn}' " +
$"and RecordNumber = '{SNData.recordNumber}' and RCLineNO ='{SNData.lineNo}' " + $"and RecordNumber = '{SNData.recordNumber}' and RCLineNO ='{SNData.lineNo}' " +
$"and ProductID ='{SNData.productID}'"; $"and ProductID ='{SNData.productID}'";
colSQL.Add(strSQL); colSQL.Add(strSQL);
strSQL = $@"Delete [SFIS_PTD].[dbo].[ZWHPickListDetail] strSQL = $@"Delete ZWHPickListDetail
where InputSN = '{SNData.sn}' where InputSN = '{SNData.sn}'
and RecordNumber='{SNData.recordNumber}' and RecordNumber='{SNData.recordNumber}'
and RCLineNO='{SNData.lineNo}'"; and RCLineNO='{SNData.lineNo}'";

38
AMESCoreStudio.WebApi/Controllers/PTD/PTDController.cs

@ -47,7 +47,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
{ {
ptdConnection.Open(); ptdConnection.Open();
} }
var query = @$" SELECT * FROM SFIS_PTD.dbo.PTDFlowRules WHERE FORMID=@id"; var query = @$" SELECT * FROM PTDFlowRules WHERE FORMID=@id";
DynamicParameters p = new DynamicParameters(); DynamicParameters p = new DynamicParameters();
p.Add("id", id, DbType.String); p.Add("id", id, DbType.String);
var q = await ptdConnection.QueryAsync<dynamic>(query, p); var q = await ptdConnection.QueryAsync<dynamic>(query, p);
@ -73,7 +73,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
{ {
ptdConnection.Open(); ptdConnection.Open();
} }
var query = @$" SELECT * FROM SFIS_PTD.dbo.RecordTypeInfo WHERE ID=@id"; var query = @$" SELECT * FROM RecordTypeInfo WHERE ID=@id";
DynamicParameters p = new DynamicParameters(); DynamicParameters p = new DynamicParameters();
p.Add("id", id, DbType.String); p.Add("id", id, DbType.String);
var q = await ptdConnection.QueryAsync<dynamic>(query, p); var q = await ptdConnection.QueryAsync<dynamic>(query, p);
@ -100,7 +100,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
{ {
ptdConnection.Open(); ptdConnection.Open();
} }
var query = @$" SELECT * FROM SFIS_PTD.dbo.ZDNDetail var query = @$" SELECT * FROM ZDNDetail
WHERE DNNO = @dnNo WHERE DNNO = @dnNo
AND DNLineNO = @dnlineNo "; AND DNLineNO = @dnlineNo ";
DynamicParameters p = new DynamicParameters(); DynamicParameters p = new DynamicParameters();
@ -127,7 +127,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
{ {
ptdConnection.Open(); ptdConnection.Open();
} }
var query = @" UPDATE SFIS_PTD.dbo.ZDNDetail var query = @" UPDATE ZDNDetail
SET IsRecord = @isRecord SET IsRecord = @isRecord
WHERE DNNO = @dnNo WHERE DNNO = @dnNo
AND DNLineNO = @dnlineNo "; AND DNLineNO = @dnlineNo ";
@ -159,7 +159,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
{ {
ptdConnection.Open(); ptdConnection.Open();
} }
var query = @$" SELECT * FROM SFIS_PTD.dbo.ZSNInfo var query = @$" SELECT * FROM ZSNInfo
WHERE SerialNumber BETWEEN @strNumber AND @endNumber WHERE SerialNumber BETWEEN @strNumber AND @endNumber
AND LEN(SerialNumber) = LEN(@strNumber) "; AND LEN(SerialNumber) = LEN(@strNumber) ";
DynamicParameters p = new DynamicParameters(); DynamicParameters p = new DynamicParameters();
@ -184,7 +184,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
{ {
ptdConnection.Open(); ptdConnection.Open();
} }
var query = @$" SELECT * FROM SFIS_PTD.dbo.ZSNInfo var query = @$" SELECT * FROM ZSNInfo
WHERE SerialNumber = @number "; WHERE SerialNumber = @number ";
DynamicParameters p = new DynamicParameters(); DynamicParameters p = new DynamicParameters();
p.Add("number", number); p.Add("number", number);
@ -215,7 +215,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
{ {
ptdConnection.Open(); ptdConnection.Open();
} }
var query = @$" SELECT * FROM SFIS_PTD.dbo.ZProductTrans WHERE 1=1 "; var query = @$" SELECT * FROM ZProductTrans WHERE 1=1 ";
DynamicParameters p = new DynamicParameters(); DynamicParameters p = new DynamicParameters();
if (!string.IsNullOrWhiteSpace(serialNumber)) if (!string.IsNullOrWhiteSpace(serialNumber))
@ -272,7 +272,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
{ {
ptdConnection.Open(); ptdConnection.Open();
} }
var query = @$" SELECT * FROM SFIS_PTD.dbo.ZWHPickListDetail var query = @$" SELECT * FROM ZWHPickListDetail
WHERE InputSN BETWEEN @strNumber AND @endNumber WHERE InputSN BETWEEN @strNumber AND @endNumber
AND LEN(InputSN) = LEN(@strNumber) "; AND LEN(InputSN) = LEN(@strNumber) ";
DynamicParameters p = new DynamicParameters(); DynamicParameters p = new DynamicParameters();
@ -297,7 +297,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
{ {
ptdConnection.Open(); ptdConnection.Open();
} }
var query = @$" SELECT * FROM SFIS_PTD.dbo.ZWHPickListDetail var query = @$" SELECT * FROM ZWHPickListDetail
WHERE InputSN = @number "; WHERE InputSN = @number ";
DynamicParameters p = new DynamicParameters(); DynamicParameters p = new DynamicParameters();
p.Add("number", number); p.Add("number", number);
@ -324,7 +324,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
{ {
ptdConnection.Open(); ptdConnection.Open();
} }
var query = @$" SELECT * FROM SFIS_PTD.dbo.CustomerItemMailGroup var query = @$" SELECT * FROM CustomerItemMailGroup
WHERE CustomerCode=@id"; WHERE CustomerCode=@id";
DynamicParameters p = new DynamicParameters(); DynamicParameters p = new DynamicParameters();
p.Add("id", id.ToUpper().Trim(), DbType.String); p.Add("id", id.ToUpper().Trim(), DbType.String);
@ -359,7 +359,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
try try
{ {
// 刪除 ZProductTrans // 刪除 ZProductTrans
var query = @" DELETE SFIS_PTD.dbo.ZProductTrans var query = @" DELETE ZProductTrans
WHERE SerialNumber = @serialNumber WHERE SerialNumber = @serialNumber
AND RecordNumber = @recordNumber AND RecordNumber = @recordNumber
AND RCLineNO = @lineNo AND RCLineNO = @lineNo
@ -374,10 +374,10 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
await ptdConnection.ExecuteAsync(query, p, tran); await ptdConnection.ExecuteAsync(query, p, tran);
// 更新 ZSNInfo // 更新 ZSNInfo
query = @" UPDATE SFIS_PTD.dbo.ZSNInfo SET query = @" UPDATE ZSNInfo SET
RecordTypeID = RecordTypeID =
(SELECT TOP (1) [RecordTypeID] (SELECT TOP (1) [RecordTypeID]
FROM SFIS_PTD.dbo.ZProductTrans FROM ZProductTrans
WHERE SerialNumber =@serialNumber WHERE SerialNumber =@serialNumber
ORDER BY CREATEDATE DESC) ORDER BY CREATEDATE DESC)
WHERE SerialNumber =@serialNumber "; WHERE SerialNumber =@serialNumber ";
@ -386,7 +386,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
await ptdConnection.ExecuteAsync(query, p, tran); await ptdConnection.ExecuteAsync(query, p, tran);
// 刪除 ZWHPickListDetail // 刪除 ZWHPickListDetail
query = @" DELETE SFIS_PTD.dbo.ZWHPickListDetail query = @" DELETE ZWHPickListDetail
WHERE InputSN = @serialNumber WHERE InputSN = @serialNumber
AND RecordNumber = @recordNumber AND RecordNumber = @recordNumber
AND RCLineNO = @lineNo AND RCLineNO = @lineNo
@ -399,7 +399,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
await ptdConnection.ExecuteAsync(query, p, tran); await ptdConnection.ExecuteAsync(query, p, tran);
// 更新 ZHistoryKeyDefine // 更新 ZHistoryKeyDefine
query = @" UPDATE SFIS_PTD.dbo.ZHistoryKeyDefine SET Seed = Seed - 1 query = @" UPDATE ZHistoryKeyDefine SET Seed = Seed - 1
WHERE SerialNumber = @serialNumber "; WHERE SerialNumber = @serialNumber ";
p = new DynamicParameters(); p = new DynamicParameters();
@ -441,7 +441,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
try try
{ {
// 刪除 ZProductTrans // 刪除 ZProductTrans
var query = @" DELETE SFIS_PTD.dbo.ZProductTrans var query = @" DELETE ZProductTrans
WHERE SerialNumber = @serialNumber WHERE SerialNumber = @serialNumber
AND RecordNumber = @recordNumber AND RecordNumber = @recordNumber
AND RCLineNO = @lineNo AND RCLineNO = @lineNo
@ -454,14 +454,14 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
await ptdConnection.ExecuteAsync(query, p , tran); await ptdConnection.ExecuteAsync(query, p , tran);
// 刪除 ZSNInfo // 刪除 ZSNInfo
query = @" DELETE SFIS_PTD.dbo.ZSNInfo query = @" DELETE ZSNInfo
WHERE SerialNumber = @serialNumber "; WHERE SerialNumber = @serialNumber ";
p = new DynamicParameters(); p = new DynamicParameters();
p.Add("serialNumber", serialNumber); p.Add("serialNumber", serialNumber);
await ptdConnection.ExecuteAsync(query, p, tran); await ptdConnection.ExecuteAsync(query, p, tran);
// 刪除 ZWHPickListDetail // 刪除 ZWHPickListDetail
query = @" DELETE SFIS_PTD.dbo.ZWHPickListDetail query = @" DELETE ZWHPickListDetail
WHERE InputSN = @serialNumber WHERE InputSN = @serialNumber
AND RecordNumber = @recordNumber AND RecordNumber = @recordNumber
AND RCLineNO = @lineNo AND RCLineNO = @lineNo
@ -474,7 +474,7 @@ namespace AMESCoreStudio.WebApi.Controllers.PTD
await ptdConnection.ExecuteAsync(query, p, tran); await ptdConnection.ExecuteAsync(query, p, tran);
// 刪除 ZHistoryKeyDefine // 刪除 ZHistoryKeyDefine
query = @" DELETE SFIS_PTD.dbo.ZHistoryKeyDefine query = @" DELETE ZHistoryKeyDefine
WHERE SerialNumber = @serialNumber "; WHERE SerialNumber = @serialNumber ";
p = new DynamicParameters(); p = new DynamicParameters();

3
AMESCoreStudio.WebApi/Controllers/SYS/UserInfoesController.cs

@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using AMESCoreStudio.WebApi.Models.SYS; using AMESCoreStudio.WebApi.Models.SYS;
using AMESCoreStudio.CommonTools.Result; using AMESCoreStudio.CommonTools.Result;
using AMESCoreStudio.WebApi.Models.AMES;
namespace AMESCoreStudio.WebApi.Controllers.SYS namespace AMESCoreStudio.WebApi.Controllers.SYS
{ {
@ -234,8 +235,6 @@ namespace AMESCoreStudio.WebApi.Controllers.SYS
} }
_context.Entry(userInfo).State = EntityState.Modified; _context.Entry(userInfo).State = EntityState.Modified;
//userInfo.UpdateUserId = 0;
userInfo.UpdateDateTime = DateTime.Now; userInfo.UpdateDateTime = DateTime.Now;
try try

4
AMESCoreStudio.WebApi/DTO/AMES/QRS016Detail.cs

@ -85,13 +85,13 @@ namespace AMESCoreStudio.WebApi.DTO.AMES
/// 批退數 /// 批退數
/// </summary> /// </summary>
[DataMember] [DataMember]
public int failQty { get; set; } = 0; public decimal failQty { get; set; } = 0;
/// <summary> /// <summary>
/// 批退率 /// 批退率
/// </summary> /// </summary>
[DataMember] [DataMember]
public double rejectRate { get; set; } = 0; public decimal rejectRate { get; set; } = 0;
} }
} }

6
AMESCoreStudio.WebApi/DTO/AMES/RPT002VIiewDto.cs

@ -77,17 +77,17 @@ namespace AMESCoreStudio.WebApi.DTO.AMES
/// <summary> /// <summary>
/// FQC批退率 Board /// FQC批退率 Board
/// </summary> /// </summary>
public double FQCRRBoard { get; set; } = 0.0; public decimal FQCRRBoard { get; set; } = 0.0m;
/// <summary> /// <summary>
/// FQC批退率 System /// FQC批退率 System
/// </summary> /// </summary>
public double FQCRRSystem { get; set; } = 0.0; public decimal FQCRRSystem { get; set; } = 0.0m;
/// <summary> /// <summary>
/// FQC批退率 Medical /// FQC批退率 Medical
/// </summary> /// </summary>
public double FQCRRMedical { get; set; } = 0.0; public decimal FQCRRMedical { get; set; } = 0.0m;
/// <summary> /// <summary>
/// DOA Board /// DOA Board

11
AMESCoreStudio.WebApi/DTO/AMES/WipQueryDto.cs

@ -99,5 +99,16 @@ namespace AMESCoreStudio.WebApi.DTO.AMES
/// 工單類型 /// 工單類型
/// </summary> /// </summary>
public string wipType { get; set; } public string wipType { get; set; }
/// <summary>
/// 開工日
/// </summary>
public DateTime? startDate { get; set; }
/// <summary>
/// 檢驗完成日
/// </summary>
public DateTime? fqcClearDate { get; set; }
} }
} }

2
AMESCoreStudio.WebApi/Models/AMES/BarcodeInfo.cs

@ -60,7 +60,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
public int StationID { get; set; } public int StationID { get; set; }
/// <summary> /// <summary>
/// 條碼過站狀態 P:PASS F:不良 /// 條碼過站狀態 P:PASS F:不良 C:報廢(再也不能用) S:轉出(再也不能用)
/// </summary> /// </summary>
[Column("RULE_STATUS")] [Column("RULE_STATUS")]
[DataMember] [DataMember]

2
AMESCoreStudio.WebApi/Models/AMES/FqcInhouseMaster.cs

@ -216,7 +216,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
[DataMember] [DataMember]
[Display(Name = "入庫單備註")] [Display(Name = "入庫單備註")]
[Column("INHOUSE_MEMO")] [Column("INHOUSE_MEMO")]
[StringLength(100)] [StringLength(200)]
public string InhouseMemo { get; set; } public string InhouseMemo { get; set; }
} }

24
AMESCoreStudio.WebApi/Models/AMES/PTD101AMESModel.cs

@ -88,8 +88,26 @@ namespace AMESCoreStudio.WebApi.Models.AMES
public int ItemNo { get; set; } public int ItemNo { get; set; }
public string DnNo { get; set; } public string DnNo { get; set; }
public string LineNo { get; set; } public string LineNo { get; set; }
/// <summary>
/// 料號
/// </summary>
public string Material { get; set; } public string Material { get; set; }
/// <summary>
/// 出貨數量
/// </summary>
public int? ShipQty { get; set; }
/// <summary>
/// 出貨序號
/// </summary>
public string Sn { get; set; } public string Sn { get; set; }
/// <summary>
/// 實際開工日
/// </summary>
public string StartDate { get; set; }
/// <summary>
/// 工單號碼
/// </summary>
public string CurrentMOID { get; set; }
} }
public class RecordTypeInfo public class RecordTypeInfo
@ -224,7 +242,13 @@ namespace AMESCoreStudio.WebApi.Models.AMES
public string productID { get; set; } public string productID { get; set; }
public string? soldCustomerID { get; set; } public string? soldCustomerID { get; set; }
public string? expectShipDate { get; set; } public string? expectShipDate { get; set; }
/// <summary>
/// 預計出貨量(出貨數量)
/// </summary>
public int? shipQty { get; set; } public int? shipQty { get; set; }
/// <summary>
/// 備貨數量
/// </summary>
public int qty { get; set; } public int qty { get; set; }
} }

20
AMESCoreStudio.WebApi/Models/AMES/WipInfo.cs

@ -348,6 +348,26 @@ namespace AMESCoreStudio.WebApi.Models.AMES
[Display(Name = "序號領退料量")] [Display(Name = "序號領退料量")]
public int ReceivedQty { get; set; } = 0; public int ReceivedQty { get; set; } = 0;
/// <summary>
/// 開工日
/// </summary>
[Column("STARTDATE")]
[DataMember]
[DataType(DataType.Text), DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", ApplyFormatInEditMode = true)]
[Display(Name = "開工日")]
public DateTime? StartDate { get; set; }
/// <summary>
/// 檢驗完成日
/// </summary>
[Column("FQCCLEARDATE")]
[DataMember]
[DataType(DataType.Text), DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", ApplyFormatInEditMode = true)]
[Display(Name = "檢驗完成日")]
public DateTime? FQCClearDate { get; set; }
/// <summary> /// <summary>
/// 生產單位 /// 生產單位
/// </summary> /// </summary>

8
AMESCoreStudio.WebApi/Models/SYS/UserInfo.cs

@ -13,7 +13,7 @@ namespace AMESCoreStudio.WebApi.Models.SYS
public class UserInfo public class UserInfo
{ {
/// <summary> /// <summary>
/// 用編號 /// 用編號
/// </summary> /// </summary>
[Key] [Key]
[Column("USER_ID")] [Column("USER_ID")]
@ -31,11 +31,11 @@ namespace AMESCoreStudio.WebApi.Models.SYS
public string UserNo { get; set; } public string UserNo { get; set; }
/// <summary> /// <summary>
/// 用户名称 /// 用戶名稱
/// </summary> /// </summary>
[Column("USER_NAME")] [Column("USER_NAME")]
[DataMember] [DataMember]
[Display(Name = "用户名称")] [Display(Name = "用戶名稱")]
[Required(ErrorMessage = "{0},不能空白")] [Required(ErrorMessage = "{0},不能空白")]
[StringLength(20, ErrorMessage = "{0},不能大于{1}")] [StringLength(20, ErrorMessage = "{0},不能大于{1}")]
public string UserName { get; set; } public string UserName { get; set; }
@ -98,7 +98,7 @@ namespace AMESCoreStudio.WebApi.Models.SYS
public string UserCellPhone { get; set; } public string UserCellPhone { get; set; }
/// <summary> /// <summary>
/// 用戶狀態 /// 用戶狀態 0(未激活) 1(正常) 2(禁用) 3(註銷)
/// </summary> /// </summary>
[Column("USER_STATUSID")] [Column("USER_STATUSID")]
[Display(Name = "用戶狀態")] [Display(Name = "用戶狀態")]

Loading…
Cancel
Save