Browse Source

整合安勤調整的程式

master
Gitea 4 months ago
parent
commit
fba2d43dce
  1. 15
      AMESCoreStudio.Web/AppSetting.cs
  2. 153
      AMESCoreStudio.Web/Controllers/FQCController.cs
  3. 117
      AMESCoreStudio.Web/Controllers/JIGController.cs
  4. 154
      AMESCoreStudio.Web/Controllers/LABController.cs
  5. 201
      AMESCoreStudio.Web/Controllers/PCSController.cs
  6. 643
      AMESCoreStudio.Web/Controllers/REPController.cs
  7. 263
      AMESCoreStudio.Web/Controllers/SPCController.cs
  8. 62
      AMESCoreStudio.Web/Startup.cs
  9. 36
      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. 47
      AMESCoreStudio.Web/Views/PCS/PCS005.cshtml
  15. 6
      AMESCoreStudio.Web/Views/PCS/PCS009R.cshtml
  16. 76
      AMESCoreStudio.Web/Views/PCS/PCS021.cshtml
  17. 188
      AMESCoreStudio.Web/Views/PCS/PCS041C.cshtml
  18. 8
      AMESCoreStudio.Web/Views/PTD/PTD002.cshtml
  19. 6
      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. 54
      AMESCoreStudio.Web/Views/SPC/SPC004.cshtml
  27. 184
      AMESCoreStudio.Web/Views/SPC/SPC005R.cshtml
  28. 12
      AMESCoreStudio.Web/Views/SYS/SYS008.cshtml
  29. 5
      AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs
  30. 7
      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
{
/// <summary>
/// MVC网站访问IP端口
/// MVC網站訪問地址
/// </summary>
public string Urls { get; set; }
/// <summary>
/// WebApi访问地址
/// WebApi網站訪問地址
/// </summary>
public string ApiUrl { get; set; }
//Yiru Add -------------------------------------------------------------------
/// <summary>
/// 倉庫位置
/// </summary>
public string Location { get; set; }
//2023-02-12 add
/// <summary>
///
/// </summary>
public string PTD101Key { get; set; }
/// <summary>
@ -27,8 +32,6 @@ namespace AMESCoreStudio.Web
/// </summary>
public int FQC014FileSize { get; set; }
//Yiru End -------------------------------------------------------------------
public static AppSetting Setting { get; set; } = new AppSetting();
}
}

153
AMESCoreStudio.Web/Controllers/FQCController.cs

@ -3,8 +3,6 @@ using AMESCoreStudio.Web.Models;
using AMESCoreStudio.WebApi.DTO.AMES;
using AMESCoreStudio.WebApi.Enum;
using AMESCoreStudio.WebApi.Models.AMES;
using AMESCoreStudio.WebApi.Models.BAS;
//using AspNetCore.Reporting;
using Microsoft.Reporting.NETCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
@ -19,6 +17,8 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using System.Net.Http;
namespace AMESCoreStudio.Web.Controllers
@ -28,15 +28,18 @@ namespace AMESCoreStudio.Web.Controllers
/// </summary>
public class FQCController : Controller
{
private readonly ILogger<PCSController> _logger;
public readonly IFQC _fqcApi;
private readonly IWebHostEnvironment _env;
public readonly IPCS _pcsApi;
public readonly IBAS _basApi;
public readonly IBLL _bllApi;
public readonly ISYS _sysApi;
private readonly ILogger<PCSController> _logger;
private readonly IWebHostEnvironment _env;
private readonly IConfiguration _config;
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;
_fqcApi = fqcApi;
@ -45,6 +48,7 @@ namespace AMESCoreStudio.Web.Controllers
_bllApi = bllApi;
_basApi = basApi;
_sysApi = sysApi;
_config = config;
_esuncApi = esuncApi;
}
@ -1481,6 +1485,8 @@ namespace AMESCoreStudio.Web.Controllers
private async Task CheckFQCToMail(string Material, string Result, string inhouseNo, int seqID)
{
var result = await _fqcApi.GetFqcNoticeMailQuery(material: Material, fqcResult: Result, status: "Y");
var UploadFolderFQCPath = _config["ImagePath:UploadFolderFQCPath"];
if (result.Data.Count() != 0)
{
var MailGroup = result.Data.Select(s => s.MailGroup).ToArray();
@ -1494,8 +1500,7 @@ namespace AMESCoreStudio.Web.Controllers
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
//NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名
FilePath = $@"{_env.WebRootPath}\UploadFolder\FQC\Temp";
var path = $@"{FilePath}\{FileName}";
var path = UploadFolderFQCPath + FileName;
if (!Directory.Exists(FilePath))
{
@ -1539,6 +1544,7 @@ namespace AMESCoreStudio.Web.Controllers
var fqcResult = await _fqcApi.GetFqcResultMaster(fqc);
if (fqcResult != null)
fqcDto.StatusName = fqcResult.QaResult;
ViewBag.FileUploadUrl = _config["ImagePath:FileUploadUrl"];
return View(fqcDto);
}
@ -1546,60 +1552,61 @@ namespace AMESCoreStudio.Web.Controllers
public async Task<IActionResult> FQC007DAsync(FqcDto model, string Result, IFormFile formFile)
{
FqcResultMaster fqcResultMaster = await _fqcApi.GetFqcResultMaster(model.FqcID);
var rootFolderPath = _config["ImagePath:RootPath"];
var uploadFolderFQCPath = _config["ImagePath:UploadFolderFQCPath"];
if (fqcResultMaster == null)
{
ModelState.AddModelError("error", "找不到FQC開單紀錄");
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 fileExt = Path.GetExtension(FileName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
//NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名
FilePath = $@"{_env.WebRootPath}\UploadFolder\FQC\{fqcResultMaster.InhouseNo}-{fqcResultMaster.SeqID}";
var path = $@"{FilePath}\{FileName}";
//取得使用者上傳檔案的原始檔名
var imageName = Path.GetFileName(formFile.FileName);
//指定要寫入的路徑、檔名和副檔名
var rootPath = $@"{rootFolderPath}\{uploadFolderFQCPath}\{fqcResultMaster.InhouseNo}-{fqcResultMaster.SeqID}";
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);
}
using (var stream = new FileStream(path, FileMode.Create))
catch (Exception ex)
{
await formFile.CopyToAsync(stream);
ModelState.AddModelError("error", $"無法建立路徑: {rootPath}, 錯誤: {ex.Message}");
return BadRequest(ModelState);
}
}
FqcResultMasterBlob fqcResultMasterBlob = new FqcResultMasterBlob()
{
FqcID = model.FqcID,
ImageName = FileName,
Filepath = $@"\UploadFolder\FQC\{fqcResultMaster.InhouseNo}-{fqcResultMaster.SeqID}\",
CreateUserID = GetLogInUserID(),
UpdateUserID = GetLogInUserID()
};
using (var stream = new FileStream(path, FileMode.Create))
{
await formFile.CopyToAsync(stream);
}
var result = await _fqcApi.PostFqcResultMasterBlob(JsonConvert.SerializeObject(fqcResultMasterBlob));
FqcResultMasterBlob fqcResultMasterBlob = new FqcResultMasterBlob()
{
FqcID = model.FqcID,
ImageName = imageName,
Filepath = filePath,
CreateUserID = GetLogInUserID(),
UpdateUserID = GetLogInUserID()
};
if (result.Success)
{
ModelState.AddModelError("error", "上傳成功!");
}
else
{
ModelState.AddModelError("error", "上傳失敗,錯誤訊息:" + result.Msg);
}
var result = await _fqcApi.PostFqcResultMasterBlob(JsonConvert.SerializeObject(fqcResultMasterBlob));
if (result.Success)
{
ModelState.AddModelError("error", "上傳成功!");
}
else
{
ModelState.AddModelError("error", "上傳失敗,錯誤訊息:" + result.Msg);
}
}
else
{
@ -1615,20 +1622,39 @@ namespace AMESCoreStudio.Web.Controllers
/// <param name="Path">路徑</param>
/// <param name="FileName">檔名</param>
/// <returns></returns>
public async Task<IActionResult> FileDownload(string Path, string FileName)
public async Task<IActionResult> FileDownload(string fileUrl)
{
var path = $@"{_env.WebRootPath}\{Path}{FileName}";
var memoryStream = new MemoryStream();
using (var stream = new FileStream(path, FileMode.Open))
fileUrl = fileUrl.Replace("\\", "/");
try
{
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>
@ -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

117
AMESCoreStudio.Web/Controllers/JIGController.cs

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

154
AMESCoreStudio.Web/Controllers/LABController.cs

@ -12,13 +12,11 @@ using AMESCoreStudio.CommonTools.Result;
using static AMESCoreStudio.Web.ViewModels.LAB.LAB003ViewModel;
using AMESCoreStudio.WebApi.Models.AMES;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Microsoft.AspNetCore.Mvc.Rendering;
using AMESCoreStudio.WebApi.DTO.AMES;
using AMESCoreStudio.Web.ViewModels.LAB;
using System.Dynamic;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
namespace AMESCoreStudio.Web.Controllers
{
@ -28,15 +26,18 @@ namespace AMESCoreStudio.Web.Controllers
public readonly ILAB _labApi;
public readonly IPCS _pcsApi;
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;
_labApi = labApi;
_pcsApi = pcsApi;
_env = env;
_config = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build();
}
private void GetFlagList()
@ -147,9 +148,9 @@ namespace AMESCoreStudio.Web.Controllers
[ResponseCache(Duration = 0)]
[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)
{
@ -172,7 +173,7 @@ namespace AMESCoreStudio.Web.Controllers
/// <param name="page"></param>
/// <param name="limit"></param>
/// <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();
}
@ -196,17 +197,17 @@ namespace AMESCoreStudio.Web.Controllers
if (System.IO.File.Exists(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);
return Json(new Result() { success = true, msg = FilePath + FileName });
@ -215,7 +216,7 @@ namespace AMESCoreStudio.Web.Controllers
{
return Json(new Result() { success = false, msg = "圖片檔案不存在" });
}
}
@ -232,12 +233,12 @@ namespace AMESCoreStudio.Web.Controllers
{
//判斷為E209開頭的料號才可輸入
if (LabelMatnr.StartsWith("E209"))
{
{
var PlmMeterial = await _pcsApi.GetPlmMeterialInfo(LabelMatnr);
if (PlmMeterial.Count > 0)
{
var Master = await _labApi.LabelTemplatebyMatnr(LabelMatnr,0,10);
var Master = await _labApi.LabelTemplatebyMatnr(LabelMatnr, 0, 10);
if (Master.DataTotal > 0)
return Json(new Table() { count = 0, msg = "料號已存在", data = null });
else
@ -298,31 +299,28 @@ namespace AMESCoreStudio.Web.Controllers
string FileName = 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);
//取原始檔名中的副檔名
var fileExt = Path.GetExtension(FileName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名
if (!System.IO.Directory.Exists(LABFilePath))
{
//取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(formFile.FileName);
//取原始檔名中的副檔名
var fileExt = Path.GetExtension(FileName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名
FilePath = $"\\LABFile\\";//本機目錄
if (!System.IO.Directory.Exists(_env.WebRootPath + FilePath))
{
System.IO.Directory.CreateDirectory(_env.WebRootPath + FilePath);
}
using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create))
{
await formFile.CopyToAsync(stream);
}
model.IMAGE_NAME = FilePath+ NewName;
System.IO.Directory.CreateDirectory(LABFilePath);
}
using (var stream = new FileStream(LABFilePath + NewName, FileMode.Create))
{
await formFile.CopyToAsync(stream);
}
model.IMAGE_NAME = LABFilePath + NewName;
}
else
{
@ -340,12 +338,12 @@ namespace AMESCoreStudio.Web.Controllers
else
{
ModelState.AddModelError("error", result.Msg);
ModelState.AddModelError("error", result.Msg);
}
}
return Json(new Result() { success = false, msg = "缺少必填資料!!" });
}
public async Task<IActionResult> DeleteLabelTemplateDetailAsync(int id)
@ -360,7 +358,7 @@ namespace AMESCoreStudio.Web.Controllers
return Json(new Result() { success = false, msg = "資料有誤!!" });
}
}
public async Task<IActionResult> LAB002CListSaveAsync(LabelTemplateDetail model)
{
@ -377,18 +375,18 @@ namespace AMESCoreStudio.Web.Controllers
}
}
//修改页面
//修改页面
[HttpGet]
public async Task<IActionResult> LAB002UAsync(int id)
{
GetUserID();
var result = await _labApi.GetLabelTemplateMaster(id);
var result = await _labApi.GetLabelTemplateMaster(id);
if (result.LABEL_FILE == null)
{
return View();
}
return View(result);
}
//頁面提交,id=0 添加,id>0 修改
@ -401,54 +399,46 @@ namespace AMESCoreStudio.Web.Controllers
string FileName = string.Empty;
string NewName = string.Empty;
string FilePath = string.Empty;
if (formFile != null)
var RootPath = _config["ImagePath:RootPath"];
var LABFilePath = _config["ImagePath:LABFilePath"];
if (formFile != null && formFile.Length > 0)
{
if (formFile.Length > 0)
//取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(formFile.FileName);
//取原始檔名中的副檔名
var fileExt = Path.GetExtension(FileName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名
if (!System.IO.Directory.Exists(LABFilePath))
{
//取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(formFile.FileName);
//取原始檔名中的副檔名
var fileExt = Path.GetExtension(FileName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名
FilePath = $"\\LABFile\\";//本機目錄
if (!System.IO.Directory.Exists(_env.WebRootPath + FilePath))
{
System.IO.Directory.CreateDirectory(_env.WebRootPath + FilePath);
}
using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create))
{
await formFile.CopyToAsync(stream);
}
model.IMAGE_NAME = FilePath + NewName;
System.IO.Directory.CreateDirectory(LABFilePath);
}
using (var stream = new FileStream(LABFilePath + NewName, FileMode.Create))
{
await formFile.CopyToAsync(stream);
}
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)
{
//var _msg = "添加成功!";
return Json(new Result() { success = true, msg = result.Msg });
}
else
{
ModelState.AddModelError("error", result.Msg);
}
}
return Json(new Result() { success = false, msg = "資料有誤!!" });
//else
//{
// ModelState.AddModelError("error", "缺少必填資料");
// return View("LAB002C", model);
//}
}
public async Task<IActionResult> LAB002UListSaveAsync(LabelTemplateDetail model)
@ -505,7 +495,7 @@ namespace AMESCoreStudio.Web.Controllers
}
[HttpGet]
public async Task<IActionResult> LAB003U(string OrderNo,string Operate)
public async Task<IActionResult> LAB003U(string OrderNo, string Operate)
{
LabelItemReqModel model = new LabelItemReqModel();
model = await _labApi.GetLabelItemReq(OrderNo);
@ -514,7 +504,7 @@ namespace AMESCoreStudio.Web.Controllers
}
[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>();
UserInfo User = new UserInfo();
@ -547,7 +537,7 @@ namespace AMESCoreStudio.Web.Controllers
System.IO.File.Copy(ImgFile, targetFilePath, true);
// var x = result.Data.FirstOrDefault();
// var x = result.Data.FirstOrDefault();
ViewBag.Picture = FilePath + FileName;
return View(result.Data);
}
@ -580,11 +570,11 @@ namespace AMESCoreStudio.Web.Controllers
}
[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>();
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 });
else
return Json(new Result() { success = false, msg = result.Msg, data = null });
@ -597,7 +587,7 @@ namespace AMESCoreStudio.Web.Controllers
{
int Sn = 1;
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())
{
var r2 = result.Data.Max(x => x.ordeR_NO).ToString();
@ -677,7 +667,7 @@ namespace AMESCoreStudio.Web.Controllers
return user_id;
}
#endregion

201
AMESCoreStudio.Web/Controllers/PCSController.cs

@ -23,6 +23,7 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
namespace AMESCoreStudio.Web.Controllers
@ -49,6 +50,7 @@ namespace AMESCoreStudio.Web.Controllers
/// </summary>
public static int NoLength = 4;
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
, IConfiguration configuration, IBLL bllApi)
@ -64,7 +66,7 @@ namespace AMESCoreStudio.Web.Controllers
_fileServerProvider = fileServerProvider;
_env = env;
_sharedLocalizer = sharedLocalizer;
_configuration = configuration;
_configuration = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build();
_bllApi = bllApi;
}
@ -1739,6 +1741,7 @@ namespace AMESCoreStudio.Web.Controllers
if (wipInfoQuery.Any())
{ // 判斷工單號碼 在工單基本資料檔只能有一筆(不判斷是否不同製程)
ViewBag.MoidByOnlyOne = _configuration["MoidByOnlyOne"];
if (ViewBag.MoidByOnlyOne == "Y")
{
if (wipInfoQuery.Count() != 0)
@ -2338,7 +2341,11 @@ namespace AMESCoreStudio.Web.Controllers
return View("PCS001", model);
}
/// <summary>
/// 工單資料查詢
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<IActionResult> PCS001R(int id)
{
// 針對安勤 工單基本資料統一打開工程資訊
@ -2460,6 +2467,7 @@ namespace AMESCoreStudio.Web.Controllers
GetCheckboxSMD(model.wipBoard != null ? model.wipBoard.Smd : null);
GetCheckboxSMDSolderMa(model.wipBoard != null ? model.wipBoard.SmdSolderMask : null);
GetCheckboxWipLN(model.wipLabel != null ? model.wipLabel.LN : "N");
ViewBag.FileUploadUrl = _configuration["ImagePath:FileUploadUrl"];
return View(model);
}
@ -2467,7 +2475,7 @@ namespace AMESCoreStudio.Web.Controllers
{
// 針對安勤 工單基本資料統一打開工程資訊
ViewBag.WipSpecial = _configuration["WipSpecial"];
ViewBag.FileUploadUrl = _configuration["ImagePath:FileUploadUrl"];
WipDataViewModel model = new WipDataViewModel();
var q = await _pcsApi.GetWipInfo(id);
if (q.Count != 0)
@ -2619,6 +2627,7 @@ namespace AMESCoreStudio.Web.Controllers
GetCheckboxSMD(model.wipBoard != null ? model.wipBoard.Smd : "");
GetCheckboxSMDSolderMa(model.wipBoard != null ? model.wipBoard.SmdSolderMask : "");
GetCheckboxWipLN(model.wipLabel != null ? model.wipLabel.LN : "N");
ViewBag.FileUploadUrl = _configuration["ImagePath:FileUploadUrl"];
return View(model);
}
@ -2810,18 +2819,36 @@ namespace AMESCoreStudio.Web.Controllers
/// <param name="Path">路徑</param>
/// <param name="FileName">檔名</param>
/// <returns></returns>
public async Task<IActionResult> FileDownload(string Path, string FileName)
public async Task<IActionResult> FileDownload(string fileUrl)
{
var path = $@"{_env.WebRootPath}\{Path}{FileName}";
var memoryStream = new MemoryStream();
using (var stream = new FileStream(path, FileMode.Open))
fileUrl = fileUrl.Replace("\\", "/");
try
{
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>
@ -6899,6 +6926,7 @@ namespace AMESCoreStudio.Web.Controllers
{
var bNo = model.B.BarcodeNo;
model.PartNo = model.PartNo.Trim();
if (ModelState.IsValid)
{
IResultModel result;
@ -7181,61 +7209,6 @@ namespace AMESCoreStudio.Web.Controllers
[HttpPost]
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);
GetSOPTypeSelect();
@ -7558,6 +7531,7 @@ namespace AMESCoreStudio.Web.Controllers
IResultModel result;
IResultModel result2;
model.PartNo = model.PartNo.Trim();
var barcodeItemOldList = await _pcsApi.GetBarcodeItem(model.BarcodeItemID);
var barcodeItemOld = barcodeItemOldList[0];
var barcodeItemChange = new BarcodeItemChange();
@ -8891,28 +8865,30 @@ namespace AMESCoreStudio.Web.Controllers
}
model.WipSops = model.WipSops.Where(w => w.WipSOPID != -1);
// 檔案上傳
string FileName = string.Empty;
string NewName = string.Empty;
string FilePath = string.Empty;
// 圖片上傳
var rootFolderPath = _configuration["ImagePath:RootPath"];
var uploadFolderPath = _configuration["ImagePath:UploadFolderPath"];
if (formFile != null)
{
if (formFile.Length > 0)
{
//取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(formFile.FileName);
//取原始檔名中的副檔名
//var fileExt = Path.GetExtension(FileName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
//NewName = Path.GetRandomFileName() + fileExt;
var imageName = Path.GetFileName(formFile.FileName);
//指定要寫入的路徑、檔名和副檔名
FilePath = $@"{_env.WebRootPath}\UploadFolder\{model.wipInfo.WipNO}";
var path = $@"{FilePath}\{FileName}";
var rootPath = $@"{rootFolderPath}\{uploadFolderPath}\{model.wipInfo.WipNO}";
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))
@ -8921,8 +8897,8 @@ namespace AMESCoreStudio.Web.Controllers
}
model.wipInfoBlob.WipNo = model.wipInfo.WipNO;
model.wipInfoBlob.ImageName = FileName;
model.wipInfoBlob.Filepath = $@"\UploadFolder\{model.wipInfo.WipNO}\";
model.wipInfoBlob.ImageName = imageName;
model.wipInfoBlob.Filepath = filePath;
model.wipInfoBlob.CreateUserID = UserID;
model.wipInfoBlob.UpdateUserID = UserID;
result = await _pcsApi.PostWipInfoBlob(JsonConvert.SerializeObject(model.wipInfoBlob));
@ -8931,7 +8907,12 @@ namespace AMESCoreStudio.Web.Controllers
Msg += result.Msg;
}
}
else
{
ModelState.AddModelError("error", "請選擇要上傳檔案");
}
}
}
}
catch (Exception ex)
@ -10073,7 +10054,7 @@ namespace AMESCoreStudio.Web.Controllers
#region PCS041 生產注意事項
/// <summary>
///
/// 生產注意事項
/// </summary>
/// <returns></returns>
public async Task<IActionResult> PCS041()
@ -10083,6 +10064,12 @@ namespace AMESCoreStudio.Web.Controllers
return View();
}
/// <summary>
/// 生產注意事項新增
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public async Task<IActionResult> PCS041C(PCS041CViewModel model)
{
await GetStation();
@ -10106,18 +10093,21 @@ namespace AMESCoreStudio.Web.Controllers
{
PCS041CImageViewModel b = new PCS041CImageViewModel();
b.Filename = blob.FileName;
b.FilePath = blob.FilePath;
b.FilePath = _configuration["ImagePath:ProductionMemoPath"];
b.Description = blob.FileDescription;
model.Images.Add(b);
}
model.Image = new PCS041CImageViewModel();
}
ViewBag.FileUploadUrl = _configuration["ImagePath:FileUploadUrl"];
return View(model);
}
/// <summary>
/// Delete
/// 生產注意事項刪除
/// </summary>
/// <param name="ppid">PK</param>
/// <returns></returns>
@ -10129,8 +10119,9 @@ namespace AMESCoreStudio.Web.Controllers
var r2 = await _pcsApi.DeleteProductionNoticeBlobByPPID(ppid);
return Json(new Result() { success = r1.Success, msg = r1.Msg, data = null });
}
/// <summary>
/// View
/// 生產注意事項檢視
/// </summary>
/// <param name="ppid">PK</param>
/// <returns></returns>
@ -10167,11 +10158,13 @@ namespace AMESCoreStudio.Web.Controllers
model.Image = new PCS041CImageViewModel();
return View("PCS041V", model);
} /// <summary>
/// View
/// </summary>
/// <param name="ppid">PK</param>
/// <returns></returns>
}
/// <summary>
/// View
/// </summary>
/// <param name="ppid">PK</param>
/// <returns></returns>
public async Task<IActionResult> PCS041V2(string productTypeID, string material, string productionSID)
{
@ -10201,9 +10194,6 @@ namespace AMESCoreStudio.Web.Controllers
}
}
//model.Image = new PCS041CImageViewModel();
return View("PCS041V2", model);
}
/// <summary>
@ -10230,30 +10220,13 @@ namespace AMESCoreStudio.Web.Controllers
}
return Json(new Table() { count = 0, data = null });
}
public async Task<IActionResult> PCS041GetImage(string path)
{
byte[] fileBytes = await System.IO.File.ReadAllBytesAsync(path);
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 修改
public async Task<IActionResult> PCS041CSave(PCS041CViewModel model)
{

643
AMESCoreStudio.Web/Controllers/REPController.cs

@ -8,13 +8,13 @@ using AMESCoreStudio.CommonTools.Result;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Rendering;
using AMESCoreStudio.Web.ViewModels;
using System.ComponentModel.DataAnnotations;
using System.IO;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Hosting;
using AMESCoreStudio.WebApi.DTO.AMES;
using Newtonsoft.Json.Linq;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.Extensions.Configuration;
using System;
namespace AMESCoreStudio.Web.Controllers
{
@ -27,8 +27,10 @@ namespace AMESCoreStudio.Web.Controllers
public readonly IPCS _pcsApi;
public readonly ISYS _sysApi;
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;
_repApi = repApi;
@ -37,6 +39,7 @@ namespace AMESCoreStudio.Web.Controllers
_pcsApi = pcsApi;
_sysApi = sysApi;
_env = env;
_config = config;
}
private async Task GetProductTypeList()
@ -196,7 +199,7 @@ namespace AMESCoreStudio.Web.Controllers
}
[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);
//E9695A4S001R
@ -469,7 +472,8 @@ namespace AMESCoreStudio.Web.Controllers
public IActionResult REP001B(string id)
{
ViewBag.ImageUrl = $"\\REPImage\\" + id;
string REPImagePath = _config["ImagePath:REPImagePath"];
ViewBag.ImageUrl = REPImagePath + id;
return View();
}
@ -479,7 +483,7 @@ namespace AMESCoreStudio.Web.Controllers
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;
var userID = "";
@ -501,7 +505,7 @@ namespace AMESCoreStudio.Web.Controllers
repair_record[0].UpdateUserID = user_id;
repair_record[0].UpdateDate = System.DateTime.Now;
repair_record[0].RepairDesc = repair_desc;
result = await _repApi.PutRepairRecord((int)repair_record[0].ComponentID, JsonConvert.SerializeObject(repair_record[0]));
result = await _repApi.PutRepairRecord((int)repair_record[0].ComponentID, JsonConvert.SerializeObject(repair_record[0]));
}
else
{
@ -519,7 +523,7 @@ namespace AMESCoreStudio.Web.Controllers
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;
var userID = "";
@ -564,6 +568,9 @@ namespace AMESCoreStudio.Web.Controllers
var userID = "";
HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
int user_id = 0;
string REPImagePath = _config["ImagePath:REPImagePath"];
if (userID != null)
{
if (int.Parse(userID.ToString()) >= 0)
@ -616,7 +623,7 @@ namespace AMESCoreStudio.Web.Controllers
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;
}
@ -665,9 +672,9 @@ namespace AMESCoreStudio.Web.Controllers
}
else
{
ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image1Url = REPImagePath + "noimage.jfif";
ViewBag.Image2Url = REPImagePath + "noimage.jfif";
ViewBag.Image3Url = REPImagePath + "noimage.jfif";
}
}
else
@ -675,9 +682,9 @@ namespace AMESCoreStudio.Web.Controllers
NgRepair ngRepair = new NgRepair();
model.ngRepair = ngRepair;
ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image1Url = REPImagePath + "noimage.jfif";
ViewBag.Image2Url = REPImagePath + "noimage.jfif";
ViewBag.Image3Url = REPImagePath + "noimage.jfif";
}
}
@ -694,13 +701,15 @@ namespace AMESCoreStudio.Web.Controllers
await GetNGReasonList();
await GetRepairResponsibleUnitList();
var REPImagePath = _config["ImagePath:REPImagePath"];
var userID = HttpContext.Request.Cookies["UserID"];
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);
REP001NewViewModel model = new REP001NewViewModel();
if (ng_reason.Count != 0)
{
model.ngReason = ng_reason[0];
@ -735,7 +744,7 @@ namespace AMESCoreStudio.Web.Controllers
var result31 = await _repApi.GetRepairRecordByNgID((int)result1[0].NgID);
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";
}
@ -781,9 +790,9 @@ namespace AMESCoreStudio.Web.Controllers
}
else
{
ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image1Url = REPImagePath + "noimage.jfif";
ViewBag.Image2Url = REPImagePath + "noimage.jfif";
ViewBag.Image3Url = REPImagePath + "noimage.jfif";
}
}
else
@ -791,9 +800,9 @@ namespace AMESCoreStudio.Web.Controllers
NgRepair ngRepair = new NgRepair();
model.ngRepair = ngRepair;
ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image1Url = REPImagePath + "noimage.jfif";
ViewBag.Image2Url = REPImagePath + "noimage.jfif";
ViewBag.Image3Url = REPImagePath + "noimage.jfif";
}
}
@ -806,8 +815,9 @@ namespace AMESCoreStudio.Web.Controllers
{
IResultModel result;
var userID = "";
//userID = HttpContext.Request.Cookies["UserID4REP001"];
var rootFolderPath = _config["ImagePath:RootPath"];
var repFolderPath = _config["ImagePath:REPImagePath"];
var repImagePath = $@"{rootFolderPath}\{repFolderPath}";
userID = User.FindFirst("UserID")?.Value;
//HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
@ -824,38 +834,31 @@ namespace AMESCoreStudio.Web.Controllers
model.ngComponent.Status = 1;
model.ngComponent.UpdateUserID = user_id;
string FileName = string.Empty;
string NewName = string.Empty;
string FilePath = string.Empty;
string[] newFileName = null;
if (formFile != null)
if (formFile != null && formFile.Count > 0)
{
if (formFile.Count > 0)
newFileName = new string[formFile.Count];
int idx = 0;
foreach (var item in formFile)
{
newFileName = new string[formFile.Count];
int idx = 0;
foreach (var item in formFile)
if (item.Length > 0)
{
if (item.Length > 0)
//取得使用者上傳檔案的原始檔名
var imageName = Path.GetFileName(item.FileName);
//取原始檔名中的副檔名
var fileExt = Path.GetExtension(imageName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
var newName = Path.GetRandomFileName() + fileExt;
var path = $@"{repImagePath}\{newName}";
newFileName[idx] = newName;
idx = idx + 1;
//指定要寫入的路徑、檔名和副檔名
using (var stream = new FileStream(path, FileMode.Create))
{
//取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(item.FileName);
//取原始檔名中的副檔名
var fileExt = Path.GetExtension(FileName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
NewName = Path.GetRandomFileName() + fileExt;
newFileName[idx] = NewName;
idx = idx + 1;
//指定要寫入的路徑、檔名和副檔名
FilePath = $"\\REPImage\\";//本機目錄
using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create))
{
await item.CopyToAsync(stream);
}
await item.CopyToAsync(stream);
}
}
}
}
else
@ -903,7 +906,7 @@ namespace AMESCoreStudio.Web.Controllers
result = await _repApi.PostNgRepair(JsonConvert.SerializeObject(model.ngRepair));
}
if (newFileName==null)
if (newFileName == null)
{ }
else
{
@ -923,14 +926,14 @@ namespace AMESCoreStudio.Web.Controllers
for (int f = 0; f < newFileName.Length; f++)
{
NgRepairBlob ng_repair_blob = new NgRepairBlob();
ng_repair_blob.ImageName = newFileName[f];
ng_repair_blob.ImageName = newFileName[f];
ng_repair_blob.RepairID = repairID;
model.ngRepairBlob = ng_repair_blob;
result = await _repApi.PostNgRepairBlob(JsonConvert.SerializeObject(model.ngRepairBlob));
}
}
else
{
@ -944,7 +947,7 @@ namespace AMESCoreStudio.Web.Controllers
}
}
//if (result.Success)
@ -1106,250 +1109,249 @@ namespace AMESCoreStudio.Web.Controllers
}
//頁面提交,id=0 添加,id>0 修改
[HttpPost]
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
//{
// 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);
}
}
return View("REP001R", model);
//return RedirectToAction("REP001V", "REP", new { id = model.ngComponent.NgID });
}
//[HttpPost]
//public async Task<IActionResult> REP001RSave1Async(REP001ViewModel model, IFormFile formFile)
//{
// 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);
// }
// }
// return View("REP001R", model);
// //return RedirectToAction("REP001V", "REP", new { id = model.ngComponent.NgID });
//}
#endregion
@ -1398,8 +1400,8 @@ namespace AMESCoreStudio.Web.Controllers
await GetRepairResponsibleUnitList();
REP001ViewModel model = new REP001ViewModel();
var REPImagePath = _config["ImagePath:REPImagePath"];
var result1 = await _repApi.GetNgComponent(id);
var ng_reason = await _ppsApi.GetNGReason(result1[0].NgNo);
if (ng_reason.Count != 0)
{
@ -1447,36 +1449,12 @@ namespace AMESCoreStudio.Web.Controllers
{
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
{
ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image1Url = REPImagePath + "noimage.jfif";
ViewBag.Image2Url = REPImagePath + "noimage.jfif";
ViewBag.Image3Url = REPImagePath + "noimage.jfif";
}
}
else
@ -1484,20 +1462,21 @@ namespace AMESCoreStudio.Web.Controllers
NgRepair ngRepair = new NgRepair();
model.ngRepair = ngRepair;
ViewBag.Image1Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image2Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image3Url = $"\\REPImage\\" + "noimage.jfif";
ViewBag.Image1Url = REPImagePath + "noimage.jfif";
ViewBag.Image2Url = REPImagePath + "noimage.jfif";
ViewBag.Image3Url = REPImagePath + "noimage.jfif";
}
}
return View(model);
}
public async Task<IActionResult> REP002CSaveAsync(REP001ViewModel model, IFormFile formFile)
{
IResultModel result;
var userID = "";
var REPImagePath = _config["ImagePath:REPImagePath"];
HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
int user_id = 0;
if (userID != null)
@ -1516,7 +1495,6 @@ namespace AMESCoreStudio.Web.Controllers
string FileName = string.Empty;
string NewName = string.Empty;
string FilePath = string.Empty;
if (formFile != null)
{
@ -1529,8 +1507,7 @@ namespace AMESCoreStudio.Web.Controllers
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名
FilePath = $"\\REPImage\\";//本機目錄
using (var stream = new FileStream(_env.WebRootPath + FilePath + NewName, FileMode.Create))
using (var stream = new FileStream(REPImagePath + NewName, FileMode.Create))
{
await formFile.CopyToAsync(stream);
}

263
AMESCoreStudio.Web/Controllers/SPCController.cs

@ -3,11 +3,9 @@ using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using AMESCoreStudio.Web.Models;
using Newtonsoft.Json;
using AMESCoreStudio.WebApi;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Rendering;
using AMESCoreStudio.WebApi.Models.AMES;
using AMESCoreStudio.WebApi.Models.BAS;
using AMESCoreStudio.CommonTools.Result;
using System.IO;
using Microsoft.AspNetCore.Http;
@ -16,6 +14,7 @@ using AMESCoreStudio.WebApi.DTO.AMES;
using System.Linq;
using AspNetCore.Reporting;
using System;
using Microsoft.Extensions.Configuration;
namespace AMESCoreStudio.Web.Controllers
{
@ -30,8 +29,10 @@ namespace AMESCoreStudio.Web.Controllers
public readonly IPPS _ppsApi;
public readonly IBLL _bllApi;
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;
_spcApi = spcApi;
@ -42,6 +43,7 @@ namespace AMESCoreStudio.Web.Controllers
_ppsApi = ppsApi;
_env = env;
_bllApi = bllApi;
_config = config;
}
@ -50,8 +52,6 @@ namespace AMESCoreStudio.Web.Controllers
{
var FlagList = new List<SelectListItem>();
FlagList.Add(new SelectListItem("Y", "Y"));
FlagList.Add(new SelectListItem("N", "N"));
@ -117,7 +117,7 @@ namespace AMESCoreStudio.Web.Controllers
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("正面", "正面"));
SideItems.Add(new SelectListItem("背面", "背面"));
@ -141,10 +141,10 @@ namespace AMESCoreStudio.Web.Controllers
StationItems.Add(new SelectListItem("N/A", "0"));
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()));
}
if(StationItems.Count==0)
if (StationItems.Count == 0)
StationItems.Add(new SelectListItem("N/A", ""));
ViewBag.StationList = StationItems;
@ -164,25 +164,68 @@ namespace AMESCoreStudio.Web.Controllers
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()
{
var result = await _spcApi.GetInspectionTypes();
var factoryNo = await GetLoginFactoryNo();
var GroupList = new List<SelectListItem>();
for (int i = 0; i < result.Count; i++)
if (factoryNo != "YS00")
{
GroupList.Add(new SelectListItem("首件檢查表", "1000"));
}
else
{
GroupList.Add(new SelectListItem(result[i].InspectionNo, result[i].InspectionTypeID.ToString()));
for (int i = 0; i < result.Count; i++)
{
GroupList.Add(new SelectListItem(result[i].InspectionNo, result[i].InspectionTypeID.ToString()));
}
}
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 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()));
}
ViewBag.FromsList = GroupList;
}
@ -241,7 +284,7 @@ namespace AMESCoreStudio.Web.Controllers
UserItems.Add(new SelectListItem("N/A", "-1"));
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;
}
@ -467,13 +510,13 @@ namespace AMESCoreStudio.Web.Controllers
if (ModelState.IsValid)
{
IResultModel result;
var GetResult = await _spcApi.GetInspectionForms(); //yiru add 22-10-11
if (GetResult.Where(w => w.InspectionName == model.InspectionName && w.InspectionTypeID == model.InspectionTypeID).ToList().Count > 0)
var GetResult = await _spcApi.GetInspectionForms(); //yiru add 22-10-11
if (GetResult.Where(w => w.InspectionName == model.InspectionName && w.InspectionTypeID == model.InspectionTypeID).ToList().Count > 0)
{
ModelState.AddModelError("error", "巡檢表單名稱重覆");
}
else
{
{
result = await _spcApi.PostInspectionForm(JsonConvert.SerializeObject(model));
@ -492,7 +535,8 @@ namespace AMESCoreStudio.Web.Controllers
{
ModelState.AddModelError("error", result.Msg);
}
} }
}
}
}
return View("SPC002C", model);
}
@ -540,9 +584,9 @@ namespace AMESCoreStudio.Web.Controllers
return Json(new Table() { count = 0, data = null });
}
[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 });
var result = await _spcApi.GetInspectionFormsByQuery(id, status);
@ -571,7 +615,7 @@ namespace AMESCoreStudio.Web.Controllers
//await GetStationListByUnit(unit);
var result = await _spcApi.GetInspectionForm(id);
ViewBag.FormID = result[0].InspectionFormID;
ViewBag.FormName = "正在新增["+result[0].InspectionName+"]細項";
ViewBag.FormName = "正在新增[" + result[0].InspectionName + "]細項";
await GetUserID();
return View();
}
@ -580,7 +624,7 @@ namespace AMESCoreStudio.Web.Controllers
public async Task<IActionResult> SPC003UAsync(int id)
{
var result = await _spcApi.GetInspectionItem(id);
if (result.Count == 0)
{
@ -706,7 +750,7 @@ namespace AMESCoreStudio.Web.Controllers
{
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(); ;
@ -723,7 +767,7 @@ namespace AMESCoreStudio.Web.Controllers
[HttpGet]
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 = "";
int user_id = 0;
HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
@ -756,17 +800,17 @@ namespace AMESCoreStudio.Web.Controllers
if (result.Success)
{
var _msg = "修改成功!";
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.ReplyMethod = model.ReplyMethod == null ? model.ReplyMethod : model.ReplyMethod.Replace("\r\n", "<br />");
#region 寄mail 給IPQC_REPLY
string MailGroup = "IPQC_REPLY";
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.ItemNo).FirstOrDefault()} <br />
: <br />
@ -857,10 +901,10 @@ namespace AMESCoreStudio.Web.Controllers
var EmailMsg = string.Empty;
foreach (var item in stringList)
{
if( !IsValidEmail(item))
{
EmailMsg += item +",";
}
if (!IsValidEmail(item))
{
EmailMsg += item + ",";
}
}
if (!string.IsNullOrEmpty(EmailMsg))
{
@ -871,10 +915,10 @@ namespace AMESCoreStudio.Web.Controllers
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
string Subject = $"[AMES系統通知] ,IPQC巡檢異常回覆退回";
string Body = $@"檢驗單號: { model.BarcodeNo} <br />
string Body = $@"檢驗單號: {model.BarcodeNo} <br />
: {model.WipNo} <br />
: {model.ItemNo} <br />
退 <br /> {model.RejectReason} <br />
@ -917,18 +961,18 @@ namespace AMESCoreStudio.Web.Controllers
[ResponseCache(Duration = 0)]
[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))
WipNo=" ";
WipNo = " ";
if (string.IsNullOrWhiteSpace(ItemNo))
ItemNo = " ";
if (string.IsNullOrWhiteSpace(BarcodeNo))
BarcodeNo = " ";
// if (string.IsNullOrWhiteSpace(Status_No))
// Status_No = " ";
// if (string.IsNullOrWhiteSpace(Status_No))
// Status_No = " ";
var result = await _spcApi.GetInspectionResultMastersByQuery(WipNo, ItemNo, BarcodeNo, "C");
@ -940,7 +984,7 @@ namespace AMESCoreStudio.Web.Controllers
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);
@ -965,13 +1009,13 @@ namespace AMESCoreStudio.Web.Controllers
return Json(new Table() { count = 0, data = null });
}
/// <summary>
/// 判斷eMail格式正確性
/// </summary>
/// <param name="email"></param>
/// <returns></returns>
public bool IsValidEmail(string email)
public bool IsValidEmail(string email)
{
// 定义一个电子邮件地址的正则表达式模式
string pattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";
@ -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.MasterID = id;
ViewBag.FileUploadUrl = _config["ImagePath:FileUploadUrl"];
await GetStationList();
return View();
@ -1039,7 +1084,7 @@ namespace AMESCoreStudio.Web.Controllers
{
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;
return View(result[0]);
}
@ -1073,7 +1118,7 @@ namespace AMESCoreStudio.Web.Controllers
[HttpPost]
public async Task<IActionResult> SPC005TSaveAsync(InspectionResultMaster model)
{
if (ModelState.IsValid)
{
IResultModel result;
@ -1112,20 +1157,23 @@ namespace AMESCoreStudio.Web.Controllers
result = await _spcApi.PostInspectionResultDetail(JsonConvert.SerializeObject(model));
if (result.Success)
{
//var _msg = "添加成功!";
return Json(new Result() { success = true, msg = result.Msg });
}
else
{
return Json(new Result() { success = false, msg = "資料有誤!!" });
}
//return Json(new Result() { success = true, msg = "資料有誤!!" });
}
public async Task<IActionResult> SPC005RSaveAsync(InspectionResultBlob model, IFormFile formFile)
{
IResultModel result;
var userID = "";
//巡檢結果維護的圖片根目錄路徑
var rootFolderPath = _config["ImagePath:RootPath"];
//巡檢結果維護的圖片資料夾
var pcsFileFolder = _config["ImagePath:PCSFilePath"];
HttpContext.Request.Cookies.TryGetValue("UserID", out userID);
int user_id = 0;
if (userID != null)
@ -1135,66 +1183,69 @@ namespace AMESCoreStudio.Web.Controllers
user_id = int.Parse(userID.ToString());
}
}
model.CreateUserID = user_id;
model.CreateDate = System.DateTime.Now;
model.UpdateUserID = user_id;
model.UpdateDate = System.DateTime.Now;
string FileName = string.Empty;
string NewName = string.Empty;
string FilePath = string.Empty;
if (formFile != null)
if (formFile != null && formFile.Length > 0)
{
if (formFile.Length > 0)
{
//取得使用者上傳檔案的原始檔名
FileName = Path.GetFileName(formFile.FileName);
//取原始檔名中的副檔名
var fileExt = Path.GetExtension(FileName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
NewName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名
FilePath = $"\\PCSFile\\";//本機目錄
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);
model.ImageName = FileName;
model.NewName = NewName;
model.FilePath = FilePath;// fileInfo.PhysicalPath;
result = await _spcApi.PostInspectionResultBlob(JsonConvert.SerializeObject(model));
if (result.Success)
//取得使用者上傳檔案的原始檔名
var imageName = Path.GetFileName(formFile.FileName);
//取原始檔名中的副檔名
var fileExt = Path.GetExtension(imageName);
//為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱
var newName = Path.GetRandomFileName() + fileExt;
//指定要寫入的路徑、檔名和副檔名
var rootPath = $@"{rootFolderPath}\{pcsFileFolder}";
var filePath = $@"\{pcsFileFolder}\";
var path = $@"{rootPath}\{newName}";
if (!System.IO.Directory.Exists(rootPath))
{
try
{
//var _msg = "上傳成功!";
ViewBag.ItemID = model.InspectionItemID;
ViewBag.MasterID = model.InspectionID;
return View("SPC005R");
System.IO.Directory.CreateDirectory(rootPath);
}
else
catch (Exception ex)
{
ModelState.AddModelError("error", result.Msg);
ModelState.AddModelError("error", $"無法建立路徑: {rootPath}, 錯誤: {ex.Message}");
return BadRequest(ModelState); // 或適當的錯誤處理
}
}
using (var stream = new FileStream(path, FileMode.Create))
{
await formFile.CopyToAsync(stream);
}
model.ImageName = imageName;
model.NewName = newName;
model.FilePath = filePath;
result = await _spcApi.PostInspectionResultBlob(JsonConvert.SerializeObject(model));
if (result.Success)
{
ViewBag.ItemID = model.InspectionItemID;
ViewBag.MasterID = model.InspectionID;
ViewBag.FileUploadUrl = _config["ImagePath:FileUploadUrl"];
return View("SPC005R");
}
else
{
ModelState.AddModelError("error", result.Msg);
}
}
else
{
ModelState.AddModelError("error", "請選擇要上傳檔案");
}
ViewBag.ItemID = model.InspectionItemID;
ViewBag.MasterID = model.InspectionID;
ViewBag.FileUploadUrl = _config["ImagePath:FileUploadUrl"];
return View("SPC005R");
}
@ -1262,14 +1313,12 @@ namespace AMESCoreStudio.Web.Controllers
result = await _spcApi.PutInspectionResultDetail(model.InspectionID, JsonConvert.SerializeObject(model));
if (result.Success)
{
//var _msg = "添加成功!";
return Json(new Result() { success = true, msg = result.Msg });
}
else
{
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 });
}
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))
WipNo = "*";
if (string.IsNullOrEmpty(ItemNo))
@ -1338,14 +1385,14 @@ namespace AMESCoreStudio.Web.Controllers
sdate = "*";
if (string.IsNullOrEmpty(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)
{
return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal });
}
@ -1373,7 +1420,7 @@ namespace AMESCoreStudio.Web.Controllers
{
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();
}
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="Types"></param>
/// <returns></returns>
public async Task<IActionResult> SPC005_PDF(int id,string Types)
public async Task<IActionResult> SPC005_PDF(int id, string Types)
{
string mimeType = "";
int extension = 1;
@ -1543,7 +1590,7 @@ namespace AMESCoreStudio.Web.Controllers
SPC005Master.Detail2_ASSY.Add(new SPC005Detail2
{
BarcodeNO = item.BarcodeNO,
SEQ = item.Seq.ToString(),
SEQ = item.Seq.ToString(),
InspectionItemDesc = item.InspectionItemDesc,
InspectionResults = item.InspectionResult
});
@ -1683,7 +1730,7 @@ namespace AMESCoreStudio.Web.Controllers
BarcodeNO = item.BarcodeNO,
Result = item.Result == "P" ? "PASS" : "FAIL",
Defect = item.Defect,
Station = item.Station
Station = item.Station
});
}
@ -1698,7 +1745,7 @@ namespace AMESCoreStudio.Web.Controllers
});
}
#region 圖檔轉BASE64
string ApprovedSign = null;
@ -1759,7 +1806,7 @@ namespace AMESCoreStudio.Web.Controllers
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)
{
@ -1808,7 +1855,7 @@ namespace AMESCoreStudio.Web.Controllers
{
var tt = Request.Cookies["UserID"];
ViewBag.UserID = tt;
var result = await _spcApi.GetIPQCTaskNotice(id);
@ -1823,7 +1870,7 @@ namespace AMESCoreStudio.Web.Controllers
var result1 = await _pcsApi.GetWipInfoByWipNO(WipNO);
//站別
var Wipinfo = await _basApi.GetRuleStationsByFlow(result1.Select(s => s.FlowRuleID).FirstOrDefault(), 0, 20);
if (Wipinfo.Count() > 0)
{
foreach (var item in Wipinfo)
@ -1935,7 +1982,7 @@ namespace AMESCoreStudio.Web.Controllers
return Json(new Table() { count = 0, data = null });
}
[ResponseCache(Duration = 0)]
@ -1951,7 +1998,7 @@ namespace AMESCoreStudio.Web.Controllers
return Json(new Table() { count = 0, data = null });
}
#endregion
}

62
AMESCoreStudio.Web/Startup.cs

@ -28,7 +28,6 @@ namespace AMESCoreStudio.Web
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)
{
// ÂX¥RJSON
@ -47,33 +46,11 @@ namespace AMESCoreStudio.Web
options.MaxModelBindingCollectionSize = int.MaxValue;
});
// ValidationVisitor exceeded the maximum configured validation depth '32'
services.AddMvc().AddMvcOptions(options =>
{
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 fileServerOptions = new List<FileServerOptions>();
if (config != null)
@ -93,7 +70,7 @@ namespace AMESCoreStudio.Web
};
services.AddSingleton<IFileServerProvider>(new FileServerProvider(fileServerOptions));
// 配置跨域处理,允许所有来源
// CORS設定
services.AddCors(options =>
options.AddPolicy("AMESPolicy",
p => p.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()));
@ -104,22 +81,19 @@ namespace AMESCoreStudio.Web
o.ResourcesPath = "Resources";
});
// Add framework services.
//services.AddMvc();
//services.AddMvc().AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix);
services.AddMvc()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization(options =>
{
options.DataAnnotationLocalizerProvider = (type, factory) => factory.Create(typeof(SharedResource));
});
//services.AddControllersWithViews();
services.AddControllersWithViews().AddRazorRuntimeCompilation();
//使用Session
// Session設定
services.AddSession();
// 權限設定
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
{
@ -127,14 +101,11 @@ namespace AMESCoreStudio.Web
options.LogoutPath = new PathString("/Login/Logout");
options.AccessDeniedPath = new PathString("/Home/Error");
options.Cookie.Name = "_AMESCookie";
//options.Cookie.SameSite = SameSiteMode.None;
//当Cookie 过期时间已达一半时,是否重置为ExpireTimeSpan
options.SlidingExpiration = true;
options.Cookie.HttpOnly = true;
});
//添加HttpClient相关
// HttpClient設定
var types = typeof(Startup).Assembly.GetTypes()
.Where(type => type.IsInterface
&& ((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)
{
if (env.IsDevelopment())
@ -161,13 +131,11 @@ namespace AMESCoreStudio.Web
else
{
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.UseCors("AMESPolicy");
//app.UseHttpsRedirection();
app.UseStaticFiles();
IList<CultureInfo> supportedCultures = new List<CultureInfo>
@ -189,6 +157,28 @@ namespace AMESCoreStudio.Web
app.UseAuthentication();
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 =>
{
endpoints.MapControllerRoute(

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

@ -1,6 +1,7 @@
@model AMESCoreStudio.WebApi.DTO.AMES.FqcDto
@{
Layout = "~/Views/Shared/_AMESLayout.cshtml"; }
@{
Layout = "~/Views/Shared/_AMESLayout.cshtml";
}
<style>
.control-label {
@ -65,8 +66,10 @@
</div>
@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'], function () {
@ -74,20 +77,28 @@
});
//通过行tool編輯,lay-event="show"
//預覽
function show(obj) {
var Path = $(obj).closest("TR").find('span[id*=Filepath]').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 () {
var layer = layui.layer;
layer.open({
type: 2,
title: '預覽文件',
shadeClose: true,//点击遮罩关闭层
shadeClose: true,
shade: 0.8,
area: ['90%', '90%'],
zIndex: 19891014,
content: "../../" + Path + FileName
content: FileUploadUrl + Path + FileName
});
});
};
@ -96,7 +107,16 @@
function filedownload(obj) {
var Path = $(obj).closest("TR").find('span[id*=Filepath]').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);
};

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

@ -282,10 +282,12 @@
if (obj.data.inhouseNo) {
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;
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;
var tempwindow2 = window.open('_blank'); // DOA異常
tempwindow2.location = 'http://10.168.245.119:1234/?productId=' + obj.data.itemNo;
}
}
else {
@ -308,8 +310,8 @@
tempwindow.location = 'https://sms.avalue.com/SMS/SUP/SFIS_SMS001.aspx?MODEL_NO=' + obj.data.modelNo;
var tempwindow1 = window.open('_blank'); // QAZone異常
tempwindow1.location = 'http://qazone.avalue.com.tw/qazone/sfislinktocfqr.aspx?QF=2&QA_PRDID=' + obj.data.itemNo;
var tempwindow1 = window.open('_blank'); // DOA異常
tempwindow1.location = 'http://10.168.245.119:1234/?productId=' + obj.data.itemNo;
var tempwindow2 = window.open('_blank'); // DOA異常
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"); }
<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) {
tt();
//table && table.reload(data);
});
//通过行tool编辑,lay-event="show"
//預覽
function show(obj) {
layui.use('layer', function () {
var layer = layui.layer;
var FileUploadUrl = '@ViewBag.FileUploadUrl';
if(!FileUploadUrl)
{
FileUploadUrl = 'https://ames.avalue.com.tw:9443';
}
layer.open({
type: 2,
title: '預覽文件',
shadeClose: true,//点击遮罩关闭层
shade: 0.8,
area: ['90%', '90%'],
content: obj.data.filePath + obj.data.newName, //iframe的url
content: FileUploadUrl + obj.data.filePath + obj.data.imageName,
zIndex: 19891014,
//iframe: {
// src:obj.data.filePath + obj.data.newName
//
//}
});
});

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

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

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

@ -524,9 +524,18 @@
<label class="layui-form-label">DIP</label>
<div class="layui-input-block">
<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) { @(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" />
<input @if (Model.wipBoard != null)
{
@(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>
@ -542,7 +551,10 @@
<div class="layui-inline">
<label class="layui-form-label">燒錄</label>
<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>
<label class="layui-form-label">燒機位置</label>
@ -563,7 +575,10 @@
<div class="layui-inline">
<label class="layui-form-label">零件烘烤</label>
<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>
<label class="layui-form-label">零件烘烤溫度</label>
<div class="layui-input-inline" style="width:100px">
@ -576,7 +591,10 @@
</div>
<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>
@ -592,7 +610,10 @@
<div class="layui-inline">
<label class="layui-form-label">PCB烘烤</label>
<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 class="layui-input-inline">
<select asp-items="@ViewBag.GetPCBBakeTypeSelect" asp-for="wipBoard.PcbBake" class=""></select>
@ -881,7 +902,10 @@
<div class="layui-input-inline" style="width: 300px;">
<input class="layui-input" asp-for="wipSystem.OsVer_Desc" readonly="readonly" />
</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" />
</div>
</div>
@ -903,7 +927,10 @@
<div class="layui-inline">
<label class="layui-form-label">FINE_PACKAGE</label>
<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>
@ -1460,10 +1487,18 @@
});
});
//通过行tool编辑,lay-event="show"
// 檔案預覽
function show(obj) {
var Path = $(obj).closest("TR").find('span[id*=Filepath]').text();;
var FileName = $(obj).closest("TR").find('span[id*=FileName]').text();;
var Path = $(obj).closest("TR").find('span[id*=Filepath]').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 () {
var layer = layui.layer;
layer.open({
@ -1473,7 +1508,7 @@
shade: 0.8,
area: ['90%', '90%'],
zIndex: 19891014,
content: "../../" + Path + FileName
content: FileUploadUrl + Path + "/" + FileName
});
});
};
@ -1482,7 +1517,12 @@
function filedownload(obj) {
var Path = $(obj).closest("TR").find('span[id*=Filepath]').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);
};

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

@ -6,11 +6,11 @@
@inject IHtmlLocalizer<AMESCoreStudio.Web.SharedResource> sharedLocalizer
<style>
/* .layui-table-col-special .layui-table-cell {
height:auto;
overflow:visible;
text-overflow:inherit;
white-space: normal;
}*/
height:auto;
overflow:visible;
text-overflow:inherit;
white-space: normal;
}*/
</style>
<div class="layui-card">
<div class="layui-card-header">
@ -77,28 +77,20 @@
</div>
</div>
@section Scripts{
@section Scripts {
<script type="text/javascript">
layui.use('table', function () {
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();
});
form.on('select(statusNo)', function (data) {
//roleName = data.elem[data.elem.selectedIndex].text;
var qs = $('button[lay-filter="querysubmit"]');
qs.click();
//hg.msghide("刷新数据!");
//table && table.reload();
});
var table = layui.table;
@ -164,9 +156,10 @@
templet: '<div>{{ layui.util.toDateString(d.wipScheduleDate, "yyyy/MM/dd") }}</div>'
},
{
field: 'workDate',
field: 'startDate',
title: '開工日',
sort: true
sort: true,
templet: '<div>{{ layui.util.toDateString(d.startDate, "yyyy/MM/dd") }}</div>'
},
{
field: 'wipDueDate',
@ -180,8 +173,10 @@
templet: '#statusNoName'
},
{
field: 'fqcDate',
title: '檢驗完成日'
field: 'fqcClearDate',
title: '檢驗完成日',
sort: true,
templet: '<div>{{ layui.util.toDateString(d.fqcClearDate, "yyyy/MM/dd") }}</div>'
},
{
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;
//alert(param);
var table = hg.table.datatable('query', '工單資料查詢', '/PCS/PCS005Query/' + param, {}, tableCols, {}, true, 'full-100', ['filter', 'print', 'exports']);
$(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">
<thead>
<tr>
<th>
工單號碼
</th>
<th>
站別名稱
</th>
@ -369,6 +372,9 @@
@foreach (var index in Model.BarCodeKPs)
{
<tr>
<td>
@index.WipNo
</td>
<td>
@index.StationName
</td>

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

@ -294,7 +294,7 @@
<td>
<input type="text" class="layui-input" asp-for="@index.PartNoName" name="wipOutfits[@k].PartNoName" readonly="readonly" />
<input type="hidden" asp-for="@index.PartNo" value="@index.PartNo" name="wipOutfits[@k].PartNo" />
</td>
<td>
<input type="text" class="layui-input" asp-for="@index.UnitNoName" name="wipOutfits[@k].UnitNoName" readonly="readonly" />
@ -361,7 +361,7 @@
</form>
</div>
@section Scripts{
@section Scripts {
@{
await Html.RenderPartialAsync("_ValidationScriptsPartial");
await Html.RenderPartialAsync("_FileinputScriptsPartial");
@ -390,17 +390,7 @@
else
{
<text>$("#Memo").hide(); </text>
}
////if (!string.IsNullOrWhiteSpace(Model.KpItemName))
//{
// <text>$("#KpItemDiv").show(); </text>
//}
//else
//{
// <text>$("#KpItemDiv").hide(); </text>
//}
});
} });
// Jquery 將兩邊DIV設定同高度
jQuery(function ($) {
@ -441,9 +431,6 @@
if (e.keyCode == 13) {
var Inputs = GetAllEmpData();
var data = $("#PCS021Form").serialize();
//$.each(Inputs, function (i, item) {
// data += "&Inputs[" + i + "]=" + item;
//});
var InputsTotal = Inputs.length;
for (i = 0; i < InputsTotal; i++) {
data += "&Inputs[" + i + "].Input=" + Inputs[i].Input;
@ -475,8 +462,12 @@
}
// 回傳有值
else if (result.data.length != 0) {
// 新增資料
TableAddRow(result.data);
var checkData = CheckData(result.data)
if (checkData != "DuplicateData") {
// 新增資料
TableAddRow(result.data);
}
}
else {
$("#tblCustomersBody").empty();
@ -506,7 +497,7 @@
$("#KpItemName").val('');
layui.form.render("select");//重新渲染 固定写法
});
form.on('select(stations)', function (data) {
$("#KpItemName").val('');
@ -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>' +
'</tr>';
$('#tblCustomers').append(contactdiv);
AutoWindowSize();
//AutoWindowSize();
};
// Table 刪除
function Remove(button) {
//Determine the reference of the Row using the Button.
var row = $(button).closest("TR");
var table = $("#tblCustomers")[0];
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() {
// 單筆
//var data = [];
//$('tr.data-contact-person').each(function () {
// var firstName = $(this).find('.td-Input').val();
// data.push(firstName);
//});
//return data;
var data = [];
$('tr.data-contact-person').each(function () {
var Input = $(this).find('.td-Input').val();
@ -579,14 +553,29 @@
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() {
$(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();
}
@ -608,7 +597,6 @@
var next = layfull.next();
if (next.length > 0) {
setTimeout(function () {
//console.log(next.height());
if (next.height() === 99) {
hgfull();
return false;

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

@ -13,7 +13,6 @@
<div class="layui-card">
<form enctype="multipart/form-data" method="post" asp-action="PCS041CSave" class="layui-form">
<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-inline">
@ -26,13 +25,11 @@
<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>
@*<input id="unitNo" type="hidden" name="unitNo" value="@ViewBag.UnitNo" />*@
</div>
<label class="layui-form-label">產品類型:</label>
<div class="layui-input-inline">
<select name="TypeID" id="TypeID" asp-for="TypeID" class="custom-select col-sm-2">
@*<option value="0">全部</option>*@
<option value="1">單板</option>
<option value="2">系統</option>
<option value="3">醫療</option>
@ -48,12 +45,8 @@
</div>
<label class="layui-form-label">問題描述:</label>
<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>*@
<textarea id="description" name="description" class="layui-textarea" placeholder="請輸入問題描述" asp-for="Description"></textarea>
</div>
@*</div>*@
@*</fieldset>*@
<span style="color:red">**預覽只能顯示圖檔、PDF、文字檔**</span>
<div class="layui-form-item">
<table lay-filter="demo" class="layui-table" id="ImageTable">
@ -68,22 +61,22 @@
<tbody>
@foreach (var index in Model.Images)
{
<tr>
<td>
<span id="Filename">@index.Filename</span>
</td>
<td>
<span id="FilePath">@index.FilePath</span>
</td>
<td>
<span id="Description">@index.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>
<tr>
<td>
<span id="Filename">@index.Filename</span>
</td>
<td>
<span id="FilePath">@index.FilePath</span>
</td>
<td>
<span id="Description">@index.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>
}
</tbody>
</table>
@ -95,7 +88,6 @@
<input type="file" name="formFile">
</label>
<input type="hidden" asp-for="Image.Filename">
@*<input type="hidden" asp-for="Images" value=@Model.Images>*@
</div>
</div>
<div class="layui-form-item">
@ -105,48 +97,13 @@
</div>
</div>
<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>
<div class="layui-form-item">
<div style="text-align:center">
<input type="submit" value="儲存" name="action" class="layui-btn" />
</div>
</div>
</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>
<span style="color: firebrick;word-break: break-all;" class="text-danger offset-sm-3">@Html.ValidationMessage("error")</span>
<div class="layui-form-item">
<div style="text-align:center">
<input type="submit" value="儲存" name="action" class="layui-btn" />
</div>
</form>*@
</div>
</form>
</div>
@section Scripts {
@ -156,80 +113,21 @@
});
layui.use('table', function () {
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;
});
//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) {
var Path = $(obj).closest("TR").find('span[id*=FilePath]').text();;
var FileName = $(obj).closest("TR").find('span[id*=Filename]').text();;
var Path = $(obj).closest("TR").find('span[id*=FilePath]').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 () {
var layer = layui.layer;
layer.open({
@ -239,17 +137,25 @@
shade: 0.8,
area: ['90%', '90%'],
zIndex: 19891014,
content: "/PCS/PCS041GetImage?path="+ Path + FileName
/*content: "../../" + Path + FileName*/
content: FileUploadUrl + '/' + Path + '/' + FileName
});
});
};
// 檔案下載
// 檔案下載
function filedownload(obj) {
var Path = $(obj).closest("TR").find('span[id*=FilePath]').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);
};
@ -326,7 +232,6 @@
field: 'picture',
title: '圖片',
},
{
field: 'createUser',
@ -373,7 +278,6 @@
};
//关闭弹出层
if ('@ViewBag.Msg' != '') {
//hg.close();
hg.msg('@ViewBag.Msg');
}
});

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

@ -108,13 +108,13 @@
<div class="layui-form-item">
<div class="layui-inline" style="margin-right: 100px;">
<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="0" title="PCS" lay-filter="radio-filter" />
@* <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" checked />
</div>
<div class="layui-inline" style="margin-right: 150px;">
<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>
@ -474,7 +474,7 @@
var loginNo = document.getElementById('loginNo').value;
var tableData = layui.table.cache['query'];
console.log("tableData",tableData)
if (material === "") {
hg.msg('料號不得為空!');
return; // Do not add the row

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

@ -108,13 +108,13 @@
<div class="layui-inline" style="margin-right: 100px;">
<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="pcs" value="0" title="PCS" lay-filter="radio-filter" />
@* <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" />
</div>
<div class="layui-inline" style="margin-right: 150px;">
<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>

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

@ -100,13 +100,13 @@
<div class="layui-inline" style="margin-right: 100px;">
<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="pcs" value="0" title="PCS" lay-filter="radio-filter" />
@* <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" checked />
</div>
<div class="layui-inline" style="margin-right: 150px;">
<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>

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

@ -100,13 +100,13 @@
<div class="layui-inline" style="margin-right: 100px;">
<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" />
</div>
<div class="layui-inline" style="margin-right: 150px;">
<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>

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

@ -130,7 +130,13 @@
var dateStart = $("#dateStart").val();
var dateEnd = $("#dateEnd").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;
hg.open('直通率', '/QRS/QRS014A' + query, '', '', true);

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

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

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

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

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

@ -41,7 +41,7 @@
<input id="WipNo" style="width: 250px;" class="layui-input">
</div>
</div>
<div class="layui-inline">
<div class="layui-inline">
<label class="layui-form-label">料號:</label>
@ -50,14 +50,14 @@
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<div class="layui-inline">
<label class="layui-form-label">檢驗編號:</label>
<input id="BarcodeNo" style="width: 250px;" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">日期:</label>
<div class="layui-input-inline">
@ -84,7 +84,7 @@
</div>
</div>
@section Scripts{
@section Scripts {
<!-- input输入 -->
<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">
@ -105,7 +105,6 @@
, theme: 'grid'
, isInitValue: true
, ready: function (date) {
// $("#dateStrh").val($("#dateStrh").val());
}
, change: function (value, date, endDate) {
$("#dateStrh").val(value);
@ -121,8 +120,6 @@
, theme: 'grid'
, isInitValue: true
, ready: function (date) {
//$("#dateEndh").val(value);
//console.log(date.y);// 得到初始化的日期时间对象
}
, change: function (value, date, endDate) {
$("#dateEndh").val(value);
@ -136,7 +133,8 @@
var data = $("#Type").val();
console.info(data);
if (data) {
getInspectionForms(data); }
getInspectionForms(data);
}
else {
$("#Form").empty();
$('#Form').append(new Option("請選擇", "-99"));
@ -150,7 +148,6 @@
$.ajax({
url: "/SPC/GetInspectionForms",
dataType: 'json',
//data: { id: data },
contentType: "application/json",
type: 'get',
success: function (result) {
@ -178,7 +175,7 @@
}
});
};
$("#BarcodeNo").change(function () {
var BarcodeNo = $("#BarcodeNo").val();
@ -238,59 +235,36 @@
{
field: 'detailFail',
title: '檢驗狀態',
templet: function (d) { // yiru modify 22-12-09
templet: function (d) {
if (d.detailFail != "0")
return "F";
else
return "P";
// return "Total:" + d.detailItem + " Pass:" + d.detailPass + " Fail:" + d.detailFail + " N/A:" + d.detailNA;
},
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',
sort: true,
templet: function (item) {
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;
}
}
]];
//通过行tool编辑,lay-event="view"
function view(obj) {
if (obj.data.inspectionID) {
hg.open('檢視巡檢結果', '/SPC/SPC004V/' + obj.data.inspectionID, '', '', true);
}
}
//通过行tool删除,lay-event="del"
//基本数据表格
var table;
//$(function () {
// tt();
//});
function tt() {
//基本数据表格
var form = "";
var WipNo = "";
var ItemNo = "";
@ -319,7 +293,7 @@
};
function CheckBarcodeNo(BarcodeNo, WipNo) {
$.ajax({
url: '/SPC/CheckBarcodeNO?BarcodeNo=' + BarcodeNo + '&WipNo=' + WipNo,
dataType: 'json',
@ -335,7 +309,7 @@
};
function GetdetailQuery(id) {
var str = "";
@ -350,7 +324,6 @@
var F = 0;
var NA = 0;
var Total = 0;
// $.each(result.data, (index, item) {
$.each(result.data, function () {
Total += 1;
if (result.data.result == "P") {
@ -367,14 +340,13 @@
str = "F"
else
str = "P"
// str = "Total:" + Total.toString + " P:" + P.toString() + " F:" + F.toString + " NA:" + NA.toString;
return str;
}
}
});
};
</script>

184
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>
.control-label {
@ -47,108 +49,100 @@
</div>
@section Scripts {
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial");
await Html.RenderPartialAsync("_FileinputScriptsPartial"); }
<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) {
tt();
//table && table.reload(data);
});
//通过行tool编辑,lay-event="show"
function show(obj) {
layui.use('layer', function () {
var layer = layui.layer;
layer.open({
type: 2,
title: '預覽文件',
shadeClose: true,//点击遮罩关闭层
shade: 0.8,
area: ['90%', '90%'],
content: obj.data.filePath + obj.data.newName, //iframe的url
zIndex: 19891014,
//iframe: {
// src:obj.data.filePath + obj.data.newName
//
//}
});
});
@{
await Html.RenderPartialAsync("_ValidationScriptsPartial");
await Html.RenderPartialAsync("_FileinputScriptsPartial");
}
};
//通过行tool删除,lay-event="del"
function del(obj) {
if (obj.data.imageName) {
hg.confirm("圖片資料:" + obj.data.imageName + ",确定要删除吗?", function () {
$.ajax({
url: '/REP/REP001D',
data: { id: obj.data.imageName },
type: 'POST',
success: function (data) {
if (data.success) {
obj.del(); //只删本地数据
hg.msghide("删除成功!");
<script type="text/javascript">
hg.form.onsubmit('asubmit', function (data) {
tt();
});
//檔案預覽
function show(obj) {
layui.use('layer', function () {
var FileUploadUrl = '@ViewBag.FileUploadUrl'; if(!FileUploadUrl)
{
FileUploadUrl = 'https://ames.avalue.com.tw:9443';
}
else {
hg.msg(data.msg);
var layer = layui.layer;
layer.open({
type: 2,
title: '預覽文件',
shadeClose: true,//点击遮罩关闭层
shade: 0.8,
area: ['90%', '90%'],
content: FileUploadUrl + obj.data.filePath + obj.data.newName,
zIndex: 19891014,
});
});
};
//通过行tool删除,lay-event="del"
function del(obj) {
if (obj.data.imageName) {
hg.confirm("圖片資料:" + obj.data.imageName + ",确定要删除吗?", function () {
$.ajax({
url: '/REP/REP001D',
data: { id: obj.data.imageName },
type: 'POST',
success: function (data) {
if (data.success) {
obj.del(); //只删本地数据
hg.msghide("删除成功!");
}
else {
hg.msg(data.msg);
}
},
error: function () {
hg.msg("网络请求失败!");
}
},
error: function () {
hg.msg("网络请求失败!");
}
});
});
});
}
}
}
@* SOP文件 sheet *@
var tableCols = [[
{
field: 'imageName',
title: '檔案名稱',
sort: true
},
{
field: 'createDate',
templet: '<div>{{ layui.util.toDateString(d.createDate, "yyyy/MM/dd") }}</div>'
},
{
field: 'right',
width: 80,
title: '操作',
align: 'center',
fixed: 'right',
templet: function (d) {
return '<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-read" lay-event="show">預覽</a>'
}
}]
];
//基本数据表格
var table;
$(function () {
tt();
});
function tt() {
var tableCols = [[
{
field: 'imageName',
title: '檔案名稱',
sort: true
},
{
field: 'createDate',
templet: '<div>{{ layui.util.toDateString(d.createDate, "yyyy/MM/dd") }}</div>'
},
{
field: 'right',
width: 80,
title: '操作',
align: 'center',
fixed: 'right',
templet: function (d) {
return '<a class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-read" lay-event="show">預覽</a>'
}
}]
];
//基本数据表格
table = hg.table.datatable('sop', '巡檢上傳文件', '/SPC/GetInspectionResultBlobsByQuery?id=' + @ViewBag.MasterID +'&itemID=' + @ViewBag.ItemID, {}, tableCols, false, 'full-100');
};
$(document).ready(function () {
var error = '@Html.ValidationMessage("error")';
if ($(error).text() != '') {
parent.hg.msg(error);
}
});
var table;
$(function () {
tt();
});
function tt() {
//基本数据表格
table = hg.table.datatable('sop', '巡檢上傳文件', '/SPC/GetInspectionResultBlobsByQuery?id=' + @ViewBag.MasterID +'&itemID=' + @ViewBag.ItemID, {}, tableCols, false, 'full-100');
};
$(document).ready(function () {
var error = '@Html.ValidationMessage("error")';
if ($(error).text() != '') {
parent.hg.msg(error);
}
});
</script>
</script>
}

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

@ -75,24 +75,24 @@
}]
];
//通过行tool编辑,lay-event="edit"
//修改
function edit(obj) {
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) {
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"
function del(obj) {
if (obj.data.userID) {
hg.confirm("用户:" + obj.data.userName + ",确定要删除吗?", function () {
hg.confirm("用戶:" + obj.data.userName + ",確定要刪除嗎?", function () {
$.ajax({
url: '/SYS/SYS008D',
data: { id: obj.data.userID },
@ -107,7 +107,7 @@
}
},
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 q3 in _context.Stationses on q1.StationID equals q3.StationID
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
{
BarcodeID = q1.BarcodeID,
WipID = q1.WipID,
PartNo = q1.PartNo,
@ -262,7 +264,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
StationID = q1.StationID,
CreateUser = q4.UserName,
CreateDate = q1.CreateDate,
SysType = q1.SysType
SysType = q1.SysType,
WipNo = q5.WipNO
};
return await q.ToListAsync();

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

@ -384,13 +384,13 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
join q7 in _context.UserInfoes on q1.CreateUserID equals q7.UserID
into s6
from q7 in s6.DefaultIfEmpty()
join q8 in _context.NgInfos on new { q1.BarcodeID, WipID = q1.WipID, StationID = q1.StationID } equals new { q8.BarcodeID, WipID = q8.WipId, StationID = q8.StationId }
join q8 in _context.NgInfos on new { q1.BarcodeID, WipID = q1.WipID, StationID = q1.StationID } equals new { q8.BarcodeID, WipID = q8.WipId, StationID = q8.StationId }
into s7
from q8 in s7.DefaultIfEmpty()
join q9 in _context.NGReasons on q8.ReasonNo equals q9.NGReasonNo
into s8
from q9 in s8.DefaultIfEmpty()
//因linq 的 join 對應 sql 的 inner join所以資料有限制,只抓有NG的資料
//因linq 的 join 對應 sql 的 inner join所以資料有限制,只抓有NG的資料
select new
{
q3.WipNO,
@ -406,7 +406,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
q1.InputDate,
q3.WerksNO,
q7.UserNo,
q7.UserName
q7.UserName,
q1.StartDate
};
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>();
int allQty = 0;
int passQty = 0;
int failQty = 0;
double rejectRate = 0;
decimal failQty = 0;
decimal rejectRate = 0;
// 醫療
var data = q.Where(w => w.customerMedical == "Y" && w.qaResult != "A").ToList();
allQty = data.Count();
passQty = data.Where(w => w.qaResult == "P").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
{
@ -234,7 +234,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
allQty = data.Count();
passQty = data.Where(w => w.qaResult == "P").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
{
type = "系統組裝",
@ -250,7 +250,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
allQty = data.Count();
passQty = data.Where(w => w.qaResult == "P").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
{
type = "單板",

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

@ -33,6 +33,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
private readonly ESUNContext _esun_context;
private readonly IConfiguration _config;
private readonly string _PTDContext;
private string SFISDbContext = "SFIS..";
/// <summary>
///
@ -43,6 +44,11 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
_config = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build();
_context = context;
_PTDContext = _config.GetConnectionString("PTDContext");
if (_PTDContext.IndexOf("SFIS_PTD_T") > 0)
{
SFISDbContext = "SFIS_T..";
}
}
/// <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);
}
/*
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";
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";
@ -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"))
{
/*
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;
//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;
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读取结转数据
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())
{
@ -1096,7 +1052,6 @@ FROM [SFIS].[dbo].[ZPDKeyPart] B WHERE B.[IsActive] = 1 AND B.[ProductSN] = (S
string mac = "";
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();
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,
unitName = q4.UnitName,
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);
}
var qq = 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;
result.Data = await q.ToListAsync();
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 ,
CurrentShipDate
from SFIS_PTD.dbo.ZDNDetail where DNNO ='{dnNo}' ";
from ZDNDetail where DNNO ='{dnNo}' ";
if (!string.IsNullOrEmpty(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,
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";
DataTable dtZProductTrans = new DataTable();
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 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);
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, 2].Value = "LineNo";
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;
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, 2].Value = SNData.LineNo;
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++;
}
// 自動調整欄寬
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
fileContents = package.GetAsByteArray();
// 寫入實體 Excel 檔案
}
var firstItem = pdtMail.FirstOrDefault();
string toMail = firstItem.MailGroup;
string Subject = $"[AMES系統通知] 出貨單號:" + strDNNo;
string emailBody = "";
string Subject = firstItem.CustomerName + "_" + strDNNo;
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");
}
}
@ -3565,7 +3539,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{
salesOrderNumber = dnDetail.FirstOrDefault().OrderNo;
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;
string strLatest;
//確認此出貨序號是否有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())
{
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;
strLatest = SNData.Sn + nIdx.ToString().PadLeft(4, '0');//組成HistoryID
//HistoryKeyDefine
strSQL = @$"UPDATE [SFIS_PTD].[dbo].[ZHistoryKeyDefine]
SET [Seed] = {nIdx} where [SerialNumber]='{SNData.Sn}'";
strSQL = @$"UPDATE ZHistoryKeyDefine
SET Seed = {nIdx} where SerialNumber ='{SNData.Sn}'";
Console.WriteLine(strSQL);
colSQL.Add(strSQL);
//ZSNInfo
strSQL = @$"Update SFIS_PTD..ZSNInfo SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}',
strSQL = @$"Update ZSNInfo SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}',
CurrentProductID='{SNData.Material}'
where SerialNumber='{SNData.Sn}'";
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
//ZHistoryKeyDefine
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZHistoryKeyDefine] ([SerialNumber],[Seed])
strSQL = @$"INSERT INTO ZHistoryKeyDefine (SerialNumber, Seed)
VALUES ('{SNData.Sn}',1)";
Console.WriteLine(strSQL);
colSQL.Add(strSQL);
//ZSNInfo
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZSNInfo] ([SerialNumber],[CurrentProductID],[OriginalProductID],
[LocationID],[LatestHistoryID],[RecordTypeID],
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID],
[ModifyDate]) VALUES
strSQL = @$"INSERT INTO ZSNInfo (SerialNumber, CurrentProductID, OriginalProductID,
LocationID, LatestHistoryID, RecordTypeID,
OwnerPlantID, OwnerCompanyID, CreatePlantID, CreateCompanyID,
ModifyDate) VALUES
('{SNData.Sn}','{SNData.Material}','{SNData.Material}',
'{strLocation}','{strLatest}','{strRecordType}',
'{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);
}
//ZProductTrans
strSQL = $@"INSERT INTO [SFIS_PTD].[dbo].[ZProductTrans]
([HistoryID],[SerialNumber],[RecordTypeID],[RecordNumber],[RCLineNO],[RecordDate],
[ProductID],[IsChangeID],[LocationID],[EmplID],[IsDelete],
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID],
[CreatorID],[CreateDate],[ModifierID],[ModifyDate],
[chkflag],[IsBranchCoReceived],[MOID],
[SalesOrderNumber],[SOLineNO],[ERP_CustomerID]) VALUES
strSQL = $@"INSERT INTO ZProductTrans
(HistoryID,SerialNumber,RecordTypeID,RecordNumber,RCLineNO,RecordDate,
ProductID,IsChangeID,LocationID,EmplID,IsDelete,
OwnerPlantID,OwnerCompanyID,CreatePlantID,CreateCompanyID,
CreatorID, CreateDate, ModifierID, ModifyDate,
chkflag, IsBranchCoReceived, MOID,
SalesOrderNumber, SOLineNO, ERP_CustomerID) VALUES
('{strLatest}','{SNData.Sn}','{strRecordType}','{SNData.DnNo}','{SNData.LineNo}','{strRecordDate}',
'{SNData.Material}',0,'{strLocation}','{strEmpId}',0,
'{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 -
(SELECT count(1)
FROM [SFIS_PTD].[dbo].[ZWHPickListDetail]
FROM ZWHPickListDetail
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())
{
cmd.CommandText = strSQL;
@ -3747,8 +3721,8 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{
//用ZProductTrans最新RecordType 檢查PTDFlowRules邏輯
bool bolChkFlow = false;
string strSQL = $@"Select [FormID] FROM [SFIS_PTD].[dbo].[PTDFlowRules]
where [ToID] ='{recordType}'";
string strSQL = $@"Select FormID FROM PTDFlowRules
where ToID ='{recordType}'";
DataTable dtPTDFlowRules = new DataTable();
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]
where [SerialNumber] ='{serialNumber}'
Order by [RecordDate] Desc";
strSQL = @$"Select RecordTypeID FROM ZProductTrans
where SerialNumber ='{serialNumber}'
Order by RecordDate Desc";
using (var cmd = connPTD.CreateCommand())
{
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 -
// (SELECT count(1)
// FROM [SFIS_PTD].[dbo].[ZWHPickListDetail]
// FROM ZWHPickListDetail
// 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())
// {
// cmd.CommandText = strSQL;
@ -3869,7 +3843,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
// }
// //用ZProductTrans最新RecordType 檢查PTDFlowRules邏輯
// bool bolChkFlow = false;
// string strSQL = $@"Select [FormID] FROM [SFIS_PTD].[dbo].[PTDFlowRules]
// string strSQL = $@"Select [FormID] FROM PTDFlowRules
// where [ToID] ='{recordType}'";
// DataTable dtPTDFlowRules = new DataTable();
// 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}'
// Order by [RecordDate] Desc";
// using (var cmd = connPTD.CreateCommand())
@ -3936,8 +3910,8 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
}
try
{
string strSQL = $@"select a.RecordTypeID,(select distinct TypeName from SFIS_PTD.dbo.RecordTypeInfo where ID = a.RecordTypeID ) as TypeName
from SFIS_PTD.dbo.ZProductTrans a group by a.RecordTypeID";
string strSQL = $@"select a.RecordTypeID,(select distinct TypeName from RecordTypeInfo where ID = a.RecordTypeID ) as TypeName
from ZProductTrans a group by a.RecordTypeID";
DataTable dtRecordTypes = new DataTable();
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,
a.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 != "全部")
{
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.EmplID as empID , a.CreateDate , a.ExtNotes ,a.RecordDate ,
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 != "全部")
{
@ -4239,7 +4213,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
}
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 = "";
using (var cmd = connPTD.CreateCommand())
@ -4287,7 +4261,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
}
try
{
string strSQL = $@"select * from SFIS_PTD.dbo.RecordTypeInfo";
string strSQL = $@"select * from RecordTypeInfo";
DataTable dtRecordTypeInfo = new DataTable();
using (var cmd = connPTD.CreateCommand())
@ -4346,7 +4320,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
}
try
{
string strSQL = $@"select * from SFIS_PTD.dbo.RecordTypeInfo Where SEQ ='{id}'";
string strSQL = $@"select * from RecordTypeInfo Where SEQ ='{id}'";
DataTable dtRecordTypeInfo = new DataTable();
using (var cmd = connPTD.CreateCommand())
@ -4407,7 +4381,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
}
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}',
'{RecordTypeInfo.Source}', '{RecordTypeInfo.PrefixCode}', {RecordTypeInfo.Length}
,'{RecordTypeInfo.Status}' )";
@ -4458,7 +4432,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
try
{
string strSQL = $@"UPDATE SFIS_PTD.dbo.RecordTypeInfo
string strSQL = $@"UPDATE RecordTypeInfo
SET RBU = '{RecordTypeInfo.RBU}',
ID = '{RecordTypeInfo.ID}',
TypeName = '{RecordTypeInfo.TypeName}',
@ -4507,7 +4481,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
}
try
{
string strSQL = $@"DELETE FROM SFIS_PTD.dbo.RecordTypeInfo
string strSQL = $@"DELETE FROM RecordTypeInfo
WHERE SEQ = '{id}'";
using (var cmd = connPTD.CreateCommand())
@ -4551,7 +4525,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
}
try
{
string strSQL = $@"select * from SFIS_PTD.dbo.CustomerItemMailGroup";
string strSQL = $@"select * from CustomerItemMailGroup";
DataTable dtCustomerItemMailGroup = new DataTable();
using (var cmd = connPTD.CreateCommand())
{
@ -4604,7 +4578,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
try
{
string strSQL = $@"select * from SFIS_PTD.dbo.CustomerItemMailGroup Where 1=1";
string strSQL = $@"select * from CustomerItemMailGroup Where 1=1";
if (id != null && id != "")
{
strSQL += $@" And CustomerCode ='{id}'";
@ -4662,7 +4636,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
}
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}',
'{CustomerItemMailGroup.MailGroup}', '{CustomerItemMailGroup.StatusNo}')";
using (var cmd = connPTD.CreateCommand())
@ -4711,7 +4685,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
try
{
string strSQL = $@"UPDATE SFIS_PTD.dbo.CustomerItemMailGroup
string strSQL = $@"UPDATE CustomerItemMailGroup
SET ItemNumber = '{CustomerItemMailGroup.ItemNumber}',
MailGroup = '{CustomerItemMailGroup.MailGroup}'
WHERE CustomerCode = '{id}'";
@ -4754,7 +4728,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
}
try
{
string strSQL = $@"UPDATE SFIS_PTD.dbo.CustomerItemMailGroup
string strSQL = $@"UPDATE CustomerItemMailGroup
SET StatusNo =
CASE
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邏輯
bool bolChkFlow = false;
strSQL = $@"Select [FormID] FROM [SFIS_PTD].[dbo].[PTDFlowRules]
where [ToID] ='{Data.RecordTypeID}'";
strSQL = $@"Select FormID FROM PTDFlowRules
where ToID ='{Data.RecordTypeID}'";
DataTable dtPTDFlowRules = new DataTable();
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]
where [SerialNumber] ='{Data.ShipmentSN}'
Order by [RecordDate] Desc";
strSQL = @$"Select RecordTypeID FROM ZProductTrans
where SerialNumber ='{Data.ShipmentSN}'
Order by RecordDate Desc";
using (var cmd = connPTD.CreateCommand())
{
cmd.CommandText = strSQL;
@ -5047,8 +5021,8 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
}
try
{
string strSQL = $@"DELETE FROM SFIS_PTD.dbo.[ZWHPickListDetail]
WHERE [TaskStatus] = 'Picked' And [ShipmentSN] ='{sn}'";
string strSQL = $@"DELETE FROM ZWHPickListDetail
WHERE TaskStatus = 'Picked' And ShipmentSN ='{sn}'";
using (var cmd = connPTD.CreateCommand())
{
cmd.CommandText = strSQL;
@ -5089,8 +5063,8 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
}
try
{
string strSQL = $@"DELETE FROM SFIS_PTD.dbo.[ZWHPickListDetail]
WHERE [TaskStatus] = 'Picked' And [RecordNumber] ='{recordNo}' AND [RCLineNO] = '{lineNo}'";
string strSQL = $@"DELETE FROM ZWHPickListDetail
WHERE TaskStatus = 'Picked' And RecordNumber ='{recordNo}' AND RCLineNO = '{lineNo}'";
using (var cmd = connPTD.CreateCommand())
{
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;
sOLineNO = dnDetail.FirstOrDefault().OrderLineNO;
eRP_CustomerID = dnDetail.FirstOrDefault().ShipCustomerID;
eRP_CustomerID = dnDetail.FirstOrDefault().SoldCustomerID;
}
}
var mailDataItem = new List<SNDataModel>();
//ZWHPickListDetail查SN資訊
strSQL = $@"Select * FROM [SFIS_PTD].[dbo].[ZWHPickListDetail]
where RecordNumber='{SNData.dnno}' and RCLineNO='{SNData.dnLineNO}' and ProductID ='{SNData.productID}'";
strSQL = $@" SELECT
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);
@ -5256,7 +5243,7 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{
string strLatest;
//確認此出貨序號是否有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);
@ -5266,11 +5253,11 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
int nIdx = seed + 1;
strLatest = row.ShipmentSN + nIdx.ToString().PadLeft(4, '0');//組成HistoryID
//HistoryKeyDefine
strSQL = @$"UPDATE [SFIS_PTD].[dbo].[ZHistoryKeyDefine]
SET [Seed] = {nIdx} where [SerialNumber]='{row.ShipmentSN}'";
strSQL = @$"UPDATE ZHistoryKeyDefine
SET Seed = {nIdx} where SerialNumber ='{row.ShipmentSN}'";
colSQL.Add(strSQL);
//ZSNInfo
strSQL = @$"Update [SFIS_PTD].[dbo].[ZSNInfo] SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}',
strSQL = @$"Update ZSNInfo SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}',
CurrentProductID='{row.ProductID}'
where SerialNumber='{row.ShipmentSN}'";
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
//ZHistoryKeyDefine
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZHistoryKeyDefine] ([SerialNumber],[Seed])
strSQL = @$"INSERT INTO ZHistoryKeyDefine (SerialNumber, Seed)
VALUES ('{row.ShipmentSN}',1)";
colSQL.Add(strSQL);
//ZSNInfo
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZSNInfo] ([SerialNumber],[CurrentProductID],[OriginalProductID],
[LocationID],[LatestHistoryID],[RecordTypeID],
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID],
[ModifyDate]) VALUES
strSQL = @$"INSERT INTO ZSNInfo (SerialNumber, CurrentProductID, OriginalProductID,
LocationID, LatestHistoryID, RecordTypeID,
OwnerPlantID, OwnerCompanyID, CreatePlantID, CreateCompanyID,
ModifyDate) VALUES
('{row.ShipmentSN}','{row.ProductID}','{row.ProductID}',
'9000','{strLatest}','{strRecordType}',
'{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);
}
//ZProductTrans
strSQL = $@"INSERT INTO [SFIS_PTD].[dbo].[ZProductTrans]
([HistoryID],[SerialNumber],[RecordTypeID],[RecordNumber],[RCLineNO],[RecordDate],
[ProductID],[IsChangeID],[LocationID],[EmplID],[IsDelete],
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID],
[CreatorID],[CreateDate],[ModifierID],[ModifyDate],
[chkflag],[IsBranchCoReceived],[MOID],
[SalesOrderNumber],[SOLineNO],[ERP_CustomerID]) VALUES
strSQL = $@"INSERT INTO ZProductTrans
(HistoryID, SerialNumber, RecordTypeID, RecordNumber, RCLineNO, RecordDate,
ProductID, IsChangeID, LocationID, EmplID, IsDelete,
OwnerPlantID, OwnerCompanyID, CreatePlantID, CreateCompanyID,
CreatorID, CreateDate, ModifierID, ModifyDate,
chkflag, IsBranchCoReceived, MOID,
SalesOrderNumber, SOLineNO, ERP_CustomerID) VALUES
('{strLatest}','{row.ShipmentSN}','{strRecordType}','{SNData.dnno}','{SNData.dnLineNO}','{strRecordDate}',
'{SNData.productID}',0,'9000','{strEmpId}',0,
'{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,
LineNo = SNData.dnLineNO,
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}'";
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)
{
//ZWHPickListDetail查SN資訊
strSQL = $@"Select * FROM [SFIS_PTD].[dbo].[ZWHPickListDetail]
strSQL = $@"Select * FROM ZWHPickListDetail
where RecordNumber='{SNData.dnno}' and RCLineNO='{SNData.dnLineNO}'";
DataTable dtSNData = new DataTable();
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;
//確認此出貨序號是否有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())
{
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;
strLatest = row["ShipmentSN"].ToString() + nIdx.ToString().PadLeft(4, '0');//組成HistoryID
//HistoryKeyDefine
strSQL = @$"UPDATE [SFIS_PTD].[dbo].[ZHistoryKeyDefine]
SET [Seed] = {nIdx} where [SerialNumber]='{row["ShipmentSN"]}'";
strSQL = @$"UPDATE ZHistoryKeyDefine
SET Seed = {nIdx} where SerialNumber ='{row["ShipmentSN"]}'";
colSQL.Add(strSQL);
//ZSNInfo
strSQL = @$"Update [SFIS_PTD].[dbo].[ZSNInfo] SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}',
//ZSNInfoF
strSQL = @$"Update ZSNInfo SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}',
CurrentProductID='{row["ProductID"]}'
where SerialNumber='{row["ShipmentSN"]}'";
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
//ZHistoryKeyDefine
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZHistoryKeyDefine] ([SerialNumber],[Seed])
strSQL = @$"INSERT INTO ZHistoryKeyDefine (SerialNumber, Seed)
VALUES ('{row["ShipmentSN"]}',1)";
colSQL.Add(strSQL);
//ZSNInfo
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZSNInfo] ([SerialNumber],[CurrentProductID],[OriginalProductID],
[LocationID],[LatestHistoryID],[RecordTypeID],
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID],
[ModifyDate]) VALUES
strSQL = @$"INSERT INTO ZSNInfo (SerialNumber, CurrentProductID, OriginalProductID,
LocationID, LatestHistoryID, RecordTypeID,
OwnerPlantID, OwnerCompanyID, CreatePlantID, CreateCompanyID,
ModifyDate) VALUES
('{row["ShipmentSN"]}','{row["ProductID"]}','{row["ProductID"]}',
'9000','{strLatest}','{strRecordType}',
'{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);
}
//ZProductTrans
strSQL = $@"INSERT INTO [SFIS_PTD].[dbo].[ZProductTrans]
([HistoryID],[SerialNumber],[RecordTypeID],[RecordNumber],[RCLineNO],[RecordDate],
[ProductID],[IsChangeID],[LocationID],[EmplID],[IsDelete],
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID],
[CreatorID],[CreateDate],[ModifierID],[ModifyDate],
[chkflag],[IsBranchCoReceived],[MOID]) VALUES
strSQL = $@"INSERT INTO ZProductTrans
(HistoryID, SerialNumber, RecordTypeID, RecordNumber, RCLineNO, RecordDate,
ProductID, IsChangeID, LocationID, EmplID, IsDelete,
OwnerPlantID, OwnerCompanyID,[CreatePlantID, CreateCompanyID,
CreatorID, CreateDate, ModifierID, ModifyDate,
chkflag, IsBranchCoReceived, MOID) VALUES
('{strLatest}','{row["ShipmentSN"]}','{strRecordType}','{SNData.dnno}','{SNData.dnLineNO}','{strRecordDate}',
'{SNData.productID}',0,'9000','{SNData.soldCustomerID.ToString()}',0,
'{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}'";
colSQL.Add(strSQL);
}
@ -5556,14 +5546,14 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
EmplID AS SoldCustomerID ,
count(*) as Qty ,
OwnerPlantID
FROM SFIS_PTD.dbo.ZProductTrans
FROM ZProductTrans
WHERE ERP_CustomerID IN ({string.Join(", ", erpCustomerId.ConvertAll(id => $"N'{id}'"))})
AND RecordNumber = @RecordNumber
AND IsBranchCoReceived = 0
AND RecordTypeID in (N'601',N'633',N'601DB')
GROUP BY RecordNumber, RCLineNO, ProductID, OwnerPlantID ,EmplID
) 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 ";
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>();
//ZProductTrans
strSQL = $@" SELECT * FROM SFIS_PTD.dbo.ZProductTrans
strSQL = $@" SELECT * FROM ZProductTrans
WHERE ERP_CustomerID IN ({string.Join(", ", erpCustomerId.ConvertAll(id => $"N'{id}'"))})
AND IsBranchCoReceived = 0
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;
//確認此出貨序號是否有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);
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;
strLatest = row.SerialNumber + nIdx.ToString().PadLeft(4, '0');//組成HistoryID
//HistoryKeyDefine
strSQL = @$"UPDATE [SFIS_PTD].[dbo].[ZHistoryKeyDefine]
SET [Seed] = {nIdx} where [SerialNumber]='{row.SerialNumber}'";
strSQL = @$"UPDATE ZHistoryKeyDefine
SET Seed = {nIdx} where SerialNumber ='{row.SerialNumber}'";
colSQL.Add(strSQL);
//ZSNInfo
strSQL = @$"Update [SFIS_PTD].[dbo].[ZSNInfo] SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}',
strSQL = @$"Update ZSNInfo SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}',
CurrentProductID='{row.ProductID}'
where SerialNumber='{row.SerialNumber}'";
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
//ZHistoryKeyDefine
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZHistoryKeyDefine] ([SerialNumber],[Seed])
strSQL = @$"INSERT INTO ZHistoryKeyDefine (SerialNumber, Seed)
VALUES ('{row.SerialNumber}',1)";
colSQL.Add(strSQL);
//ZSNInfo
strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZSNInfo] ([SerialNumber],[CurrentProductID],[OriginalProductID],
[LocationID],[LatestHistoryID],[RecordTypeID],
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID],
[ModifyDate]) VALUES
strSQL = @$"INSERT INTO ZSNInfo (SerialNumber, CurrentProductID, OriginalProductID,
LocationID, LatestHistoryID, RecordTypeID,
OwnerPlantID, OwnerCompanyID, CreatePlantID, CreateCompanyID,
ModifyDate) VALUES
('{row.SerialNumber}','{row.ProductID}','{row.ProductID}',
'9000','{strLatest}','{strRecordType}',
'{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);
}
//ZProductTrans
strSQL = $@"INSERT INTO [SFIS_PTD].[dbo].[ZProductTrans]
([HistoryID],[SerialNumber],[RecordTypeID],[RecordNumber],[RCLineNO],[RecordDate],
[ProductID],[IsChangeID],[LocationID],[EmplID],[IsDelete],
[OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID],
[CreatorID],[CreateDate],[ModifierID],[ModifyDate],
[chkflag],[IsBranchCoReceived],[MOID]) VALUES
strSQL = $@"INSERT INTO ZProductTrans
(HistoryID, SerialNumber, RecordTypeID, RecordNumber, RCLineNO, RecordDate,
ProductID, IsChangeID, LocationID, EmplID, IsDelete,
OwnerPlantID, OwnerCompanyID, CreatePlantID, CreateCompanyID,
CreatorID, CreateDate, ModifierID, ModifyDate,
chkflag, IsBranchCoReceived, MOID) VALUES
('{strLatest}','{row.SerialNumber}','{strRecordType}','{SNData.dnno}','{SNData.dnLineNO}','{strRecordDate}',
'{SNData.productID}',0,'9000','{SNData.soldCustomerID.ToString()}',0,
'{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
});
}
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}'"))})
AND IsBranchCoReceived = 0
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',
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}'";
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) //還原
{
//SQL Server 2012後才能使用
//strSQL = $"Select HistoryID,RecordTypeID,ModifyDate from [SFIS_PTD].[dbo].[ZProductTrans] " +
//strSQL = $"Select HistoryID,RecordTypeID,ModifyDate from ZProductTrans " +
// $"where [SerialNumber] = '{SNData.sn}' " +
// $"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,
ModifyDate,
ROW_NUMBER() OVER (ORDER BY HistoryID DESC) AS RowNum
FROM [SFIS_PTD].[dbo].[ZProductTrans]
WHERE [SerialNumber] = '{SNData.sn}'
FROM ZProductTrans
WHERE SerialNumber = '{SNData.sn}'
)
SELECT
HistoryID,
@ -5880,21 +5870,21 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
{
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}'";
colSQL.Add(strSQL);
int seed = int.Parse(reader["HistoryID"].ToString().Substring(reader["HistoryID"].ToString().Length - 4));
strSQL = @$"UPDATE [SFIS_PTD].[dbo].[ZHistoryKeyDefine]
SET [Seed] = {seed} where [SerialNumber]='{SNData.sn}'";
strSQL = @$"UPDATE ZHistoryKeyDefine
SET Seed = {seed} where SerialNumber ='{SNData.sn}'";
colSQL.Add(strSQL);
}
else
{
strSQL = $"Delete [SFIS_PTD].[dbo].[ZSNInfo] where SerialNumber ='{SNData.sn}'";
strSQL = $"Delete ZSNInfo where SerialNumber ='{SNData.sn}'";
colSQL.Add(strSQL);
strSQL = $"Delete [SFIS_PTD].[dbo].[ZHistoryKeyDefine] where SerialNumber ='{SNData.sn}'";
strSQL = $"Delete ZHistoryKeyDefine where SerialNumber ='{SNData.sn}'";
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 + "狀態不能刪除!");
}
strSQL = $"Delete [SFIS_PTD].[dbo].[ZProductTrans] " +
strSQL = $"Delete ZProductTrans " +
$"where [SerialNumber] = '{SNData.sn}' " +
$"and RecordNumber = '{SNData.recordNumber}' and RCLineNO ='{SNData.lineNo}' " +
$"and ProductID ='{SNData.productID}'";
colSQL.Add(strSQL);
strSQL = $@"Delete [SFIS_PTD].[dbo].[ZWHPickListDetail]
strSQL = $@"Delete ZWHPickListDetail
where InputSN = '{SNData.sn}'
and RecordNumber='{SNData.recordNumber}'
and RCLineNO='{SNData.lineNo}'";

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

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

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

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

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

@ -85,13 +85,13 @@ namespace AMESCoreStudio.WebApi.DTO.AMES
/// 批退數
/// </summary>
[DataMember]
public int failQty { get; set; } = 0;
public decimal failQty { get; set; } = 0;
/// <summary>
/// 批退率
/// </summary>
[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>
/// FQC批退率 Board
/// </summary>
public double FQCRRBoard { get; set; } = 0.0;
public decimal FQCRRBoard { get; set; } = 0.0m;
/// <summary>
/// FQC批退率 System
/// </summary>
public double FQCRRSystem { get; set; } = 0.0;
public decimal FQCRRSystem { get; set; } = 0.0m;
/// <summary>
/// FQC批退率 Medical
/// </summary>
public double FQCRRMedical { get; set; } = 0.0;
public decimal FQCRRMedical { get; set; } = 0.0m;
/// <summary>
/// DOA Board

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

@ -99,5 +99,16 @@ namespace AMESCoreStudio.WebApi.DTO.AMES
/// 工單類型
/// </summary>
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; }
/// <summary>
/// 條碼過站狀態 P:PASS F:不良
/// 條碼過站狀態 P:PASS F:不良 C:報廢(再也不能用) S:轉出(再也不能用)
/// </summary>
[Column("RULE_STATUS")]
[DataMember]

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

@ -216,7 +216,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES
[DataMember]
[Display(Name = "入庫單備註")]
[Column("INHOUSE_MEMO")]
[StringLength(100)]
[StringLength(200)]
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 string DnNo { get; set; }
public string LineNo { get; set; }
/// <summary>
/// 料號
/// </summary>
public string Material { get; set; }
/// <summary>
/// 出貨數量
/// </summary>
public int? ShipQty { get; set; }
/// <summary>
/// 出貨序號
/// </summary>
public string Sn { get; set; }
/// <summary>
/// 實際開工日
/// </summary>
public string StartDate { get; set; }
/// <summary>
/// 工單號碼
/// </summary>
public string CurrentMOID { get; set; }
}
public class RecordTypeInfo
@ -224,7 +242,13 @@ namespace AMESCoreStudio.WebApi.Models.AMES
public string productID { get; set; }
public string? soldCustomerID { get; set; }
public string? expectShipDate { get; set; }
/// <summary>
/// 預計出貨量(出貨數量)
/// </summary>
public int? shipQty { get; set; }
/// <summary>
/// 備貨數量
/// </summary>
public int qty { get; set; }
}

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

@ -348,6 +348,26 @@ namespace AMESCoreStudio.WebApi.Models.AMES
[Display(Name = "序號領退料量")]
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>

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

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

Loading…
Cancel
Save