///////////////////// protected VM_MachineProperty GetMachineProperty(int Id) { log = LogFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.FullName + ":" + MethodBase.GetCurrentMethod().Name); var machLayout = bllLayout.GetModel(Id); var machPty = new VM_MachineProperty(); if (machLayout != null) { if (machLayout.LayoutTypeID == (int)LAYOUT_TPYE.MACHINE) { try { var bllMach = new MesWeb.BLL.T_Machine(); var bllCurData = new MesWeb.BLL.T_CurrentData(); var bllEmployee = new MesWeb.BLL.T_Employee(); var bllSpec = new MesWeb.BLL.T_Specification(); var bllColData = new MesWeb.BLL.T_CollectedDataParameters(); var mach = bllMach.GetModel((int)machLayout.TableRowID); if (mach == null) { return(null); } var curData = bllCurData.GetModelList("MachineID = " + mach.MachineID).FirstOrDefault(); if (curData == null) { return(null); } /// var emmployee = bllEmployee.GetModel((int)curData.EmployeeID_Main); var spec = bllSpec.GetModel((int)curData.SpecificationID); var curMeters = bllColData.GetModelList("MachineID = " + mach.MachineID + " AND ParameterCodeID = " + (int)SPEC_PARAM_CODE.METERS_COUNT_FACT).FirstOrDefault().CollectedValue; var materialRFID = bllColData.GetModelList("MachineID = " + mach.MachineID + " AND ParameterCodeID = " + (int)SPEC_PARAM_CODE.MATERIAL_RFID).FirstOrDefault().CollectedValue; var linearSpeed = bllColData.GetModelList("MachineID = " + mach.MachineID + " AND ParameterCodeID = " + (int)SPEC_PARAM_CODE.LINEAR_SPEED).FirstOrDefault().CollectedValue; machPty.MachineName = mach.MachineName; machPty.TaskNum = "4000"; machPty.AxisNum = curData.Axis_No; // machPty.ManuMan = emmployee.EmployeeName; machPty.ManuMan = "张三"; machPty.SpecNum = spec.SpecificationName; machPty.ODMax = spec.ODMax; machPty.ODMin = spec.ODMin; machPty.SpecColor = spec.SpecificationColor; machPty.UnitPrice = spec.SpecificationPrice; machPty.MaterialRFID = materialRFID; machPty.CurrentMeters = curMeters; machPty.BatchNum = "Na"; machPty.ContUnit = "Na"; machPty.JobNum = "Na"; machPty.EstTime = ((40000 - double.Parse(curMeters)) / double.Parse(linearSpeed) / 60).ToString("0.00") + "分钟"; machPty.ReachedNum = (double.Parse(curMeters) * 100 / 4000 + "%").ToString(); } catch (Exception e) { log.Error("数据库操作失败", e); return(null); } } else { log.Error("该标志不属于机台"); return(null); } } else { log.Error("查找机台失败!"); return(null); } return(machPty); }
//获取同一年的轴号数据集合 private List <List <MesWeb.Model.T_HisMain> > getSameYearData(DateTime?startTime, DateTime?endTime, string machineType = "5") { var bllCodeUsed = new MesWeb.BLL.T_CodeUsed(); var usedCodeList = new List <MesWeb.Model.T_CodeUsed>(); var bllSpec = new MesWeb.BLL.T_Specification(); List <MesWeb.Model.T_HisMain> hisMainList = new List <MesWeb.Model.T_HisMain>(); var startMonth = startTime.Value.Month; var endMonth = endTime.Value.Month; List <List <MesWeb.Model.T_HisMain> > hisMainListArray = new List <List <MesWeb.Model.T_HisMain> >(); string cp = "CP0" + machineType; List <MesWeb.Model.T_HisMain> hisMainTmps; try { if (startTime.Value.Year > DateTime.Now.Year) { return(hisMainListArray); } for (var i = startMonth; i <= endMonth; ++i) { if (i > DateTime.Now.Month) { hisMainListArray.Add(hisMainList); return(hisMainListArray); } var tableName = "HISMAIN" + startTime.Value.Year + i.ToString("00") + machineType; var bllHisMain = new MesWeb.BLL.T_HisMain(tableName); //同一月 if (startMonth == endMonth) { for (var j = startTime.Value.Day; j <= endTime.Value.Day; ++j) { hisMainTmps = bllHisMain.GetModelList("Axis_No like '" + cp + "" + startTime.Value.Year + i.ToString("00") + j.ToString("00") + "%" + "'"); if (hisMainTmps.Count > 0) { hisMainList.AddRange(hisMainTmps); } hisMainTmps = bllHisMain.GetModelList("Axis_No like 'ZD" + startTime.Value.Year + i.ToString("00") + j.ToString("00") + "%" + "'"); if (hisMainTmps.Count > 0) { hisMainList.AddRange(hisMainTmps); } } //不是同一月 } else { //起始月 if (i == startMonth) { //遍历起始月 for (var j = startTime.Value.Day; j <= 31; ++j) { hisMainTmps = bllHisMain.GetModelList("Axis_No like '" + cp + "" + startTime.Value.Year + i.ToString("00") + j.ToString("00") + "%" + "'"); if (hisMainTmps.Count > 0) { hisMainList.AddRange(hisMainTmps); } hisMainTmps = bllHisMain.GetModelList("Axis_No like 'ZD" + startTime.Value.Year + i.ToString("00") + j.ToString("00") + "%" + "'"); if (hisMainTmps.Count > 0) { hisMainList.AddRange(hisMainTmps); } } //遍历终止月 } else if (i == endMonth) { for (var j = 1; j <= endTime.Value.Day; ++j) { hisMainTmps = bllHisMain.GetModelList("Axis_No like '" + cp + "" + startTime.Value.Year + i.ToString("00") + j.ToString("00") + "%" + "'"); if (hisMainTmps.Count > 0) { hisMainList.AddRange(hisMainTmps); } hisMainTmps = bllHisMain.GetModelList("Axis_No like 'ZD" + startTime.Value.Year + i.ToString("00") + j.ToString("00") + "%" + "'"); if (hisMainTmps.Count > 0) { hisMainList.AddRange(hisMainTmps); } } //遍历其它月 } else { for (var j = 1; j <= 31; ++j) { hisMainTmps = bllHisMain.GetModelList("Axis_No like '" + cp + "" + startTime.Value.Year + i.ToString("00") + j.ToString("00") + "%" + "'"); if (hisMainTmps.Count > 0) { hisMainList.AddRange(hisMainTmps); } hisMainTmps = bllHisMain.GetModelList("Axis_No like 'ZD" + startTime.Value.Year + i.ToString("00") + j.ToString("00") + "%" + "'"); if (hisMainTmps.Count > 0) { hisMainList.AddRange(hisMainTmps); } } } } } hisMainListArray.Add(hisMainList); } catch (Exception e) { return(hisMainListArray); } return(hisMainListArray); }
public JsonResult GetProcDetail(VM_ProcDetail procDetail) { var retData = new VM_Result_Data(); if (procDetail == null) { procDetail = new VM_ProcDetail(); } //procDetail.CertProduct = "<a href='javascript:void(0)' onclick='showCertProduct()'>成品证书</a> <a href='javascript:void(0)' onclick='showCertPlastic()'>塑料证书</a>"; var procDetailList = new List <VM_ProcDetail>(); var bllMachine = new MesWeb.BLL.T_Machine(); var bllEmp = new MesWeb.BLL.T_Employee(); var bllSpec = new MesWeb.BLL.T_Specification(); var bllAxis = new MesWeb.BLL.T_Axis(); try { if (!string.IsNullOrEmpty(procDetail.BatchNo)) { var searchCond = new List <string>(); searchCond.Add(procDetail.BatchNo); try { var gumId = MaterialController.SearchReportId(searchCond, MaterialController.gumReportType); procDetail.CertPlastic = "<a href='javascript: void(0)' onclick='showReportPlastic(this)' id='" + gumId + "'>胶料表</a>"; } catch { } } try { //找到历史数据表 HisData hisData = new HisData(procDetail.Axis_No); //查询OD的最值 var hisDs = DbHelperSQL.Query("SELECT MAX(CollectedValue) AS Max,MIN(CollectedValue) AS Min" + " FROM " + hisData.TableName + " WHERE(ParameterCodeID = " + (int)SPEC_PARAM_CODE.OUTTER_OD + ") AND(Axis_No = '" + hisData.AxisNumStr + "')" + " GROUP BY Axis_No"); var hisRow = hisDs.Tables[0].Rows[0]; var odMax = hisRow["max"].ToString(); var odMin = hisRow["min"].ToString(); procDetail.ODMax = odMax; procDetail.ODMin = odMin; var axis = new HisMain(procDetail.Axis_No); procDetail.GeneratorTime = axis.Year + "-" + axis.Month + "-" + axis.Day; } catch { } //获取回溯信息 var axisInfo = bllAxis.GetModelList("Axis_No = '" + procDetail.Axis_No + "'").FirstOrDefault(); if (axisInfo != null) { procDetail.Comment = axisInfo.comment; } //机台 var machine = bllMachine.GetModel((int)procDetail.MachineID); if (machine != null) { //只有挤绝缘和挤护套有数据 if (machine.MachineTypeID == 2 || machine.MachineTypeID == 5) { var machineName = machine.MachineName ?? ""; var axisColor = procDetail.SpecColor ?? ""; var printCode = procDetail.Printcode ?? ""; procDetail.MachineName = "<a href='javascript: void(0)' machineType='" + machine.MachineTypeID + "' employee='" + procDetail.EmployeeName + "' printCode='" + printCode + "' axisColor='" + axisColor + "' machineName='" + machineName + "' axisNum='" + procDetail.Axis_No + "' onclick='viewHisMachine(this)' machineId='" + machine.MachineID + "'>" + machine.MachineName + "</a>"; } else { procDetail.MachineName = machine.MachineName; } } retData.Code = RESULT_CODE.OK; TempData[SERACH_ASIX] = procDetail.Axis_No; } catch (Exception e) { retData.Content = "查询失败,请联系管理员"; retData.Code = RESULT_CODE.OK; retData.Appendix = procDetail; } procDetailList.Add(procDetail); retData.Appendix = procDetailList; return(Json(retData)); }
public JsonResult GetAxisDetailAction(string axisNumStr) { log = LogFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.FullName + ":" + MethodBase.GetCurrentMethod().Name); var retData = new VM_Result_Data(); var procDetailList = new List <VM_ProcDetail>(); var hisData = new VM_ProcDetail(); axisNumStr = axisNumStr.Trim(); HisMain axisNum = new HisMain(axisNumStr); var tabName = axisNum.GetHisDataTableName(); if (string.IsNullOrEmpty(tabName)) { retData.Content = "轴号有误"; return(Json(retData)); } try { var bllHisData = new MesWeb.BLL.T_HisMain(tabName); var findData = bllHisData.GetModelList("Axis_No = '" + axisNumStr + "'").FirstOrDefault(); hisData = new VM_ProcDetail { Axis_No = findData.Axis_No, CurrentDataID = findData.CurrentDataID, SpecificationID = findData.SpecificationID, MachineID = findData.MachineID, MachineTypeID = findData.MachineTypeID, EmployeeID_Main = findData.EmployeeID_Main, EmployeeID_Assistant = findData.EmployeeID_Assistant, Start_Axis_No = findData.Start_Axis_No, Printcode = findData.Printcode }; var specID = hisData.SpecificationID; var bllMachine = new MesWeb.BLL.T_Machine(); var bllEmp = new MesWeb.BLL.T_Employee(); var bllSpec = new MesWeb.BLL.T_Specification(); var bllCodeUsed = new MesWeb.BLL.T_CodeUsed(); var bllLayout = new MesWeb.BLL.T_LayoutPicture(); var spec = bllSpec.GetModel((int)specID); hisData.SpecName = spec.SpecificationName; hisData.ODMax = spec.ODMax.ToString(); hisData.ODMin = spec.ODMin.ToString(); hisData.SpecColor = spec.SpecificationColor; hisData.RolledYield = "100%"; hisData.GeneratorTime = bllCodeUsed.GetModelList("Axis_No = '" + hisData.Axis_No + "'").FirstOrDefault().GeneratorTime.Value.ToShortDateString(); var machine = bllMachine.GetModel((int)hisData.MachineID); var machineLayout = bllLayout.GetModelList("LayoutTypeID = " + 1).Find(s => { return(s.TableRowID == machine.MachineID); }); // hisData.EmployeeName = bllEmp.GetModel((int)hisData.EmployeeID_Main).EmployeeName; hisData.EmployeeName = hisData.EmployeeID_Main; var tableName = axisNum.Year + axisNum.Month + ((int)(machine.MachineTypeID)).ToString("00"); hisData.MachineName = "<a href='/HistoryQuery/HistoryMachine/" + tableName + "," + axisNumStr + "'>" + machine.MachineName + "</a>"; retData.Code = RESULT_CODE.OK; } catch (Exception e) { log.Error("查询轴号信息失败", e); retData.Content = "查询失败,请联系管理员"; } procDetailList.Add(hisData); retData.Appendix = procDetailList; return(Json(retData)); }