| | |
| | | using MES.Service.Dto.service; |
| | | using MES.Service.Modes; |
| | | using MES.Service.util; |
| | | using MySqlConnector; |
| | | using Newtonsoft.Json; |
| | | using SharpCompress.Factories; |
| | | using SqlSugar; |
| | | using System.ComponentModel; |
| | | using System.Data; |
| | | using System.Xml.Linq; |
| | | using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; |
| | | using DbType = System.Data.DbType; |
| | | |
| | |
| | | |
| | | var pageList = db |
| | | .Queryable<LtsLlj, IqcBefore, VMesQaItemsDetect01, SysUser, |
| | | IqcBeforeFrom, SysUser>((a, b, d, e, f, g) => |
| | | IqcBeforeFrom, SysUser, InspectorChangeLog, SysUser>((a, b, d, e, f, g,h,i) => |
| | | new JoinQueryInfos(JoinType.Left, a.ItemId == b.ItemId, |
| | | JoinType.Inner, a.Id == d.Id, |
| | | JoinType.Left, a.CreateBy == e.Fcode, |
| | | JoinType.Left, f.Id == b.PID, |
| | | JoinType.Left, f.Sid == g.Fid |
| | | JoinType.Left, f.Sid == g.Fid, |
| | | JoinType.Left,a.ReleaseNo==h.InspectionNo && h.IsValid=="Y", |
| | | JoinType.Left,i.Fcode==h.Inspector |
| | | )) |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.result) && |
| | |
| | | // itemIds is { Length: > 0 }, |
| | | // (a, b, c) => itemIds.Contains(a.ItemId)) |
| | | .WhereIF(id > 0, (a, b, d) => a.Id == id) |
| | | .WhereIF(true, (a, b, d, e, f, g) => (g.Fcode == queryObj.createUser || g.Fcode == null)) |
| | | //加筛选条件,根据供应商,物料编码,物料名称搜索 |
| | | //.WhereIF(queryObj.SearchValue!=null && queryObj.SearchValue!="", (a) => a.SuppName == queryObj.SearchValue|| a.ItemName == queryObj.SearchValue || a.ItemNo == queryObj.SearchValue ) |
| | | .WhereIF(queryObj.SearchValue != null && queryObj.SearchValue != "", |
| | | (a, b, d) => (a.SuppName.ToLower().Contains(queryObj.SearchValue.ToLower()) |
| | | || a.ItemName.ToLower().Contains(queryObj.SearchValue.ToLower()) |
| | | || a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower()) |
| | | || d.ProjectCodes.ToLower().Contains(queryObj.SearchValue.ToLower()) |
| | | )) |
| | | .OrderByDescending((a, b, d) => a.Id) |
| | | .Select((a, b, d, e, f, g) => new LtsLlj |
| | | .WhereIF(queryObj.createUser!="PL017"&& queryObj.UserIndex=="0", (a, b, d, e, f, g,h, i) => (g.Fcode == queryObj.createUser || i.Fcode == queryObj.createUser))//判断此单的检验员,或者检验为空就显示此单据 |
| | | //加筛选条件,根据供应商,物料编码,物料名称,项目搜索 |
| | | //.WhereIF(queryObj.SearchValue != null && queryObj.SearchValue != "", |
| | | //(a, b, d) => (a.SuppName.ToLower().Contains(queryObj.SearchValue.ToLower()) |
| | | //|| a.ItemName.ToLower().Contains(queryObj.SearchValue.ToLower()) |
| | | //|| a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower()) |
| | | //|| d.ProjectCodes.ToLower().Contains(queryObj.SearchValue.ToLower()) |
| | | //)) |
| | | |
| | | //根据下拉框搜索条件筛选(0项目, 1物料编号, 2物料名称, 3供应商, 4采购员) |
| | | .WhereIF(queryObj.SelectedIndex == "0" && queryObj.SearchValue != null && queryObj.SearchValue != "", (a, b, d) => (d.ProjectCodes.ToLower().Contains(queryObj.SearchValue.ToLower()))) |
| | | .WhereIF(queryObj.SelectedIndex == "1" && queryObj.SearchValue != null && queryObj.SearchValue != "", (a, b, d) => (a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower()))) |
| | | .WhereIF(queryObj.SelectedIndex == "2" && queryObj.SearchValue != null && queryObj.SearchValue != "", (a, b, d) => (a.ItemName.ToLower().Contains(queryObj.SearchValue.ToLower()))) |
| | | .WhereIF(queryObj.SelectedIndex == "3" && queryObj.SearchValue != null && queryObj.SearchValue != "", (a, b, d) => (a.SuppName.ToLower().Contains(queryObj.SearchValue.ToLower()))) |
| | | .WhereIF(queryObj.result== "已完成", (a, b, d, e) => (a.IqcDate>= queryObj.startDate.ToDateTime()&& a.IqcDate <= queryObj.endDate.ToDateTime().AddDays(1))) |
| | | .WhereIF(queryObj.result == "已完成" && queryObj.state!= "所有状态",(a, b, d, e) => (a.FcheckResu == queryObj.state)) |
| | | // .WhereIF(queryObj.result == "未完成" && queryObj.SearchValue != null && queryObj.SearchValue != "", (a, b, d, e) => (e.Fname.ToLower().Contains(queryObj.SearchValue.ToLower()))) |
| | | //.OrderByDescending((a, b, d) => a.Id) |
| | | .Select((a, b, d, e, f, g,h,i) => new LtsLlj |
| | | { |
| | | UserName = g.Fname, |
| | | //UserName = g.Fname, |
| | | //UserName = (i.Fname!=null ||i.Fname!="") ? i.Fname : g.Fname, |
| | | UserName = (i.Fname!=null ||i.Fname!="") ? i.Fname : g.Fname, |
| | | FIRST = d.First, |
| | | CreateUserName = e.Fname, |
| | | NewFngDesc = d.NewFngDesc, |
| | |
| | | //} |
| | | |
| | | |
| | | //根据检验标准来计算检验个数 |
| | | /// <summary> |
| | | /// 调用存储过程,重新获取检验项目 |
| | | /// </summary> |
| | | /// <param name="itemNo"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <param name="releaseNo"></param> |
| | | /// <returns></returns> |
| | | public string[] SetItems(string itemNo, |
| | | decimal quantity, string releaseNo) |
| | | { |
| | |
| | | DbType.String, ParameterDirection.Input), |
| | | outputResult, |
| | | outputMessage |
| | | }; |
| | | }; |
| | | |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | |
| | | msg[1] = messageValue; |
| | | return msg; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 保存新检验员 |
| | | /// </summary> |
| | | /// <param name="NewStaffUserID">新检验员ID</param> |
| | | /// <param name="userID">修改人</param> |
| | | /// <param name="releaseNo">检验单号</param> |
| | | /// <returns></returns> |
| | | public string[] SaveCheckBy(string NewStaffUserID, string userID, string releaseNo) |
| | | { |
| | | // 定义输出参数 |
| | | var outputResult = new SugarParameter("o_Result", null, |
| | | DbType.Int32, ParameterDirection.Output, |
| | | 4000); |
| | | |
| | | var outputMessage = new SugarParameter("o_Msg", null, |
| | | DbType.String, |
| | | ParameterDirection.Output, 4000); |
| | | |
| | | // 定义输入参数 |
| | | var parameters = new List<SugarParameter> |
| | | { |
| | | new("P_FCHECK_BY", NewStaffUserID, |
| | | DbType.String, ParameterDirection.Input), |
| | | new("p_Release_No", releaseNo, |
| | | DbType.String, ParameterDirection.Input), |
| | | new("p_User", userID, |
| | | DbType.String, ParameterDirection.Input), |
| | | |
| | | outputResult, |
| | | outputMessage |
| | | }; |
| | | |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | // 使用 SqlSugar 执行存储过程 |
| | | db.Ado.ExecuteCommand( |
| | | "BEGIN Prc_Mes_Iqc_Qa_Update_CheckBy(:P_FCHECK_BY,:p_Release_No,:p_User, :o_Result, :o_Msg); END;", |
| | | parameters.ToArray()); |
| | | |
| | | // 获取输出参数的值 |
| | | var resultValue = outputResult.Value?.ToString(); |
| | | var messageValue = outputMessage.Value?.ToString(); |
| | | string[] msg = new string[2]; |
| | | msg[0] = resultValue; |
| | | msg[1] = messageValue; |
| | | return msg; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | public string[] SaveSysSubmit(SysSubmit sysSubmit) |
| | | { |
| | | // 定义输出参数 |
| | | var outputResult = new SugarParameter("o_Result", null, |
| | | DbType.Int32, ParameterDirection.Output, |
| | | 4000); |
| | | |
| | | var outputMessage = new SugarParameter("o_Msg", null, |
| | | DbType.String, |
| | | ParameterDirection.Output, 4000); |
| | | |
| | | // 定义输入参数 |
| | | var parameters = new List<SugarParameter> |
| | | { |
| | | new("PI_BILLNO", sysSubmit.PI_BILLNO, |
| | | DbType.String, ParameterDirection.Input), |
| | | new("PI_USER", sysSubmit.PI_USER, |
| | | DbType.String, ParameterDirection.Input), |
| | | new("PI_SAMPLE_STATUS", sysSubmit.PI_SAMPLE_STATUS, |
| | | DbType.String, ParameterDirection.Input), |
| | | new("PI_SAMPLE_TYPE", sysSubmit.PI_SAMPLE_TYPE, |
| | | DbType.String, ParameterDirection.Input), |
| | | new("PI_SAMPLE_REASON", sysSubmit.PI_SAMPLE_REASON, |
| | | DbType.String, ParameterDirection.Input), |
| | | new("PI_INSPECT_TYPE", sysSubmit.PI_INSPECT_TYPE, |
| | | DbType.String, ParameterDirection.Input), |
| | | new("PI_SAMPLE_PREPARATION", sysSubmit.PI_SAMPLE_PREPARATION, |
| | | DbType.String, ParameterDirection.Input), |
| | | new("PI_URGENCY", sysSubmit.PI_URGENCY, |
| | | DbType.String, ParameterDirection.Input), |
| | | new("PI_FIRMWAREVERSION", sysSubmit.PI_FIRMWAREVERSION, |
| | | DbType.String, ParameterDirection.Input), |
| | | new("PI_HARDWAREVERSION", sysSubmit.PI_HARDWAREVERSION, |
| | | DbType.String, ParameterDirection.Input), |
| | | new("PI_REMARK", sysSubmit.PI_REMARK, |
| | | DbType.String, ParameterDirection.Input), |
| | | outputResult, |
| | | outputMessage |
| | | }; |
| | | |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | |
| | | // 使用 SqlSugar 执行存储过程 |
| | | db.Ado.ExecuteCommand( |
| | | "BEGIN PRC_MES_IQC_QC_SYSSUBMIT(:PI_BILLNO,:PI_USER,:PI_SAMPLE_STATUS,:PI_SAMPLE_TYPE,:PI_SAMPLE_REASON,:PI_INSPECT_TYPE,:PI_SAMPLE_PREPARATION,:PI_URGENCY,:PI_FIRMWAREVERSION,:PI_HARDWAREVERSION,:PI_REMARK, :o_Result, :o_Msg); END;", |
| | | parameters.ToArray()); |
| | | |
| | | // 获取输出参数的值 |
| | | var resultValue = outputResult.Value?.ToString(); |
| | | var messageValue = outputMessage.Value?.ToString(); |
| | | string[] msg = new string[2]; |
| | | msg[0] = resultValue; |
| | | msg[1] = messageValue; |
| | | return msg; |
| | | |
| | | } |
| | | private string ExtractSubstring(string input, char startChar, char endChar) |
| | |
| | | new JoinQueryInfos(JoinType.Left, a.Id == b.MainId)) |
| | | .Where((a, b) => a.ReleaseNo == releaseNo) |
| | | // .WhereIF(id > 0, (a, b) => a.Id == id) |
| | | .OrderByDescending((a, b) => a.FcheckItem) |
| | | .GroupBy((a, b) => new |
| | | { |
| | | a.Id, |
| | |
| | | FcheckItemDesc = a.FcheckItemDesc |
| | | }).ToList(); |
| | | } |
| | | |
| | | |
| | | |
| | | public DataTable getAllInspectors() |
| | | { |
| | | OracleSQLHelper SQLHelper = new(); |
| | | var sql =string.Format(@"select a.USER_NAME label,U.FCODE value from IQC_BEFORE_FROM a JOIN SYS_USER U ON U.FID=A.SID"); |
| | | return SQLHelper.ExecuteQuery(sql); |
| | | } |
| | | |
| | | |
| | | public int SetQSItemDetail(MesQaItemsDetectDetail12 detail) |
| | | { |
| | |
| | | return rkjDto; |
| | | } |
| | | |
| | | |
| | | public DataTable getFromInfo(string BarCode) |
| | | { |
| | | OracleSQLHelper SQLHelper = new(); |
| | | var sql = string.Format(@"select b.ID,b.LOT_NO,b.RELEASE_NO,b.FSUBMIT from MES_INV_ITEM_BARCODES A |
| | | left join MES_QA_ITEMS_DETECT_01 B on A.BILL_NO=b.LOT_NO and A.ITEM_ID=b.ITEM_ID |
| | | where ITEM_BARCODE='"+ BarCode + "'"); |
| | | return SQLHelper.ExecuteQuery(sql); |
| | | } |
| | | public DataTable getImgBDlist(string id) |
| | | { |
| | | OracleSQLHelper SQLHelper = new(); |
| | | var sql = string.Format(@"select id,FID,IMAGE_DATA from MES_QS_IMAGE where FID="+id+""); |
| | | return SQLHelper.ExecuteQuery(sql); |
| | | } |
| | | /// <summary> |
| | | /// 一致性项目 |
| | | /// </summary> |
| | | public class Component |
| | | { |
| | | public string Name { get; set; } |
| | | public List<string> Specs { get; set; } |
| | | public List<string> Manufacturers { get; set; } |
| | | public List<string> Id { get; set; } |
| | | public int SelectedSpec { get; set; } |
| | | public int SelectedMfg { get; set; } |
| | | } |
| | | public List<Component> getYzxBDlist(string id) |
| | | { |
| | | OracleSQLHelper SQLHelper = new(); |
| | | //查元器件 |
| | | var sql1 = string.Format(@"select ITEMNAME from MES_IQC_CONSISTENCY_ck where PID='"+id+"' group by ITEMNAME order by ITEMNAME"); |
| | | //查明细 |
| | | var sql2 = string.Format(@"select * from MES_IQC_CONSISTENCY_ck where PID='"+id+"' order by ITEMNAME,ITEMMODE,SUPPNAME"); |
| | | DataTable dataTable1= SQLHelper.ExecuteQuery(sql1); |
| | | DataTable dataTable2 = SQLHelper.ExecuteQuery(sql2); |
| | | List<Component> Components = new List<Component>(); |
| | | |
| | | |
| | | |
| | | for (int i = 0; i <dataTable1.Rows.Count; i++) |
| | | { |
| | | Component component = new Component(); |
| | | component.Name= dataTable1.Rows[i]["ITEMNAME"].ToString(); |
| | | component.Specs= new List<string>(); |
| | | component.Manufacturers = new List<string>(); |
| | | component.Id = new List<string>(); |
| | | component.SelectedSpec = -1; |
| | | component.SelectedMfg = -1; |
| | | int index = 0; |
| | | for (int j = 0; j < dataTable2.Rows.Count; j++) |
| | | { |
| | | |
| | | if (dataTable2.Rows[j]["ITEMNAME"].ToString()== dataTable1.Rows[i]["ITEMNAME"].ToString()) |
| | | { |
| | | component.Specs.Add(dataTable2.Rows[j]["ITEMMODE"].ToString()); |
| | | component.Manufacturers.Add(dataTable2.Rows[j]["SUPPNAME"].ToString()); |
| | | component.Id.Add(dataTable2.Rows[j]["ID"].ToString()); |
| | | if (dataTable2.Rows[j]["ISCHACK"].ToString()=="1") |
| | | { |
| | | component.SelectedSpec = index; |
| | | component.SelectedMfg = index; |
| | | } |
| | | index++; |
| | | } |
| | | } |
| | | |
| | | Components.Add(component); |
| | | } |
| | | return Components; |
| | | } |
| | | |
| | | public DataTable getBlmsItem() |
| | | { |
| | | OracleSQLHelper SQLHelper = new(); |
| | | //查不良描述 |
| | | var sql1 = string.Format(@"select DEFECT_NAME |
| | | from MES_DEFECT_CODE A |
| | | left join MES_DEFECT_TYPE X ON X.TYPE_NO = A.DEFECT_SORT AND X.COMPANY = A.COMPANY AND X.FACTORY = A.FACTORY"); |
| | | |
| | | return SQLHelper.ExecuteQuery(sql1); |
| | | } |
| | | public DataTable getBlmsItem(string id) |
| | | { |
| | | OracleSQLHelper SQLHelper = new(); |
| | | //查不良描述 |
| | | var sql1 = string.Format(@"select FCHECK_ITEM,FUNIT from mes_qa_items_detect_detail5 f where RELEASE_NO='"+id+"' and FUNIT is not null order by FCHECK_ITEM"); |
| | | |
| | | return SQLHelper.ExecuteQuery(sql1); |
| | | } |
| | | public void saveYzxBDlist(string id,DataTable DB) |
| | | { |
| | | OracleSQLHelper SQLHelper = new(); |
| | | //先把结果清空 |
| | | var sql1 = string.Format(@"update MES_IQC_CONSISTENCY_ck set ISCHACK=0 where PID='"+ id + "' "); |
| | | SQLHelper.ExecuteQuery(sql1); |
| | | string rowId = ""; |
| | | for (int i = 0; i < DB.Rows.Count; i++) |
| | | { |
| | | rowId += "'" + DB.Rows[i]["id"] + "',"; |
| | | } |
| | | rowId = rowId.Substring(0, rowId.Length - 1); |
| | | |
| | | |
| | | //修改结果 |
| | | var sql2 = string.Format(@"update MES_IQC_CONSISTENCY_ck set ISCHACK=1 where PID='" + id + "'and id in("+ rowId + ") "); |
| | | SQLHelper.ExecuteQuery(sql2); |
| | | |
| | | } |
| | | |
| | | public string[] YzxImgVerify(string id) |
| | | { |
| | | string[] msgStr = new string[2]; |
| | | |
| | | OracleSQLHelper SQLHelper = new(); |
| | | //修改结果 |
| | | var sql2 = string.Format(@"select A.ITEMNAME from ( select 888||min(id) id,ITEMNAME from MES_IQC_CONSISTENCY_CK where pid='"+ id + "' group by ITEMNAME) A " + |
| | | "left join MES_QS_IMAGE b on a.id=b.fid where B.id is null order by ITEMNAME"); |
| | | DataTable db= SQLHelper.ExecuteQuery(sql2); |
| | | if (db.Rows.Count > 0) |
| | | { |
| | | msgStr[1] = "元器件:"; |
| | | for (int i = 0; i < db.Rows.Count; i++) |
| | | { |
| | | msgStr[1] += db.Rows[i]["ITEMNAME"]+ ","; |
| | | } |
| | | msgStr[1] += "未完成图片上传,请上传!"; |
| | | msgStr[0] = "1"; |
| | | } |
| | | else |
| | | { |
| | | msgStr[0] = "0"; |
| | | msgStr[1] = "ok"; |
| | | } |
| | | |
| | | return msgStr; |
| | | } |
| | | |
| | | public int UpdateQSItemDetail(MesQaItemsDetectDetail12 detail) |
| | | { |
| | | var withOracle = SqlSugarHelper.UseTransactionWithOracle(db => |
| | |
| | | return SqlSugarHelper.UseTransactionWithOracle(db => |
| | | { |
| | | return db.Updateable<MesQaItemsDetectDetail5>() |
| | | // .SetColumns(it => |
| | | // it.Remarks == dto.Remarks) //SetColumns是可以叠加的 写2个就2个字段赋值 |
| | | .SetColumns(it => |
| | | it.Funit == dto.Remarks) //SetColumns是可以叠加的 写2个就2个字段赋值 |
| | | .Where(it => it.Id == dto.pid) |
| | | .ExecuteCommand(); |
| | | }); |
| | |
| | | return withOracle; |
| | | } |
| | | |
| | | public bool IqcQaSubmit(LLJDto dto) |
| | | public string[] IqcQaSubmit(LLJDto dto) |
| | | { |
| | | var (factory, company) = UserUtil.GetFactory(dto.userNo); |
| | | try |
| | |
| | | // 获取输出参数的值 |
| | | var resultValue = outputResult.Value?.ToString(); |
| | | var messageValue = outputMessage.Value?.ToString(); |
| | | |
| | | if ("1".Equals(resultValue)) throw new Exception(messageValue); |
| | | |
| | | return true; |
| | | string[] msg = new string[2]; |
| | | msg[0] = resultValue; |
| | | msg[1] = messageValue; |
| | | return msg; |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |