|
|
using CommonFunc.Tools;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using XGL.Models.Model.FoamingMac;
|
|
|
|
|
|
namespace XGL.Data.DBService
|
|
|
{
|
|
|
public class FormingMachineService
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 获取成型机在产物料信息
|
|
|
/// </summary>
|
|
|
/// <param name="bdt"></param>
|
|
|
/// <param name="edt"></param>
|
|
|
/// <returns></returns>
|
|
|
public DataTable GetFormingMachineInfo(string devicecode)
|
|
|
{
|
|
|
string sql = $@"SELECT DISTINCT ord.workorder_id,ord.workorder_code,res.OrderCode,ord.product_name,product_code,isnull(car_num,0) as car_num,
|
|
|
isnull(plan_time,'1900-01-01 08:00:00') as plan_time,ord.status ,ord.route_code,ord.attr1,COUNT(*) OVER () AS totalCount
|
|
|
FROM pro_order_workorder ord
|
|
|
left JOIN pro_wet_material_plan_detail wet on wet.workorder_id = ord.workorder_id
|
|
|
LEFT JOIN mes_material_transfer_result res on ord.workorder_id = res.OrderCode
|
|
|
LEFT JOIN pro_rfid_process_detail rfid on rfid.workorder_code = ord.workorder_code and rfid.rfid = res.rfid
|
|
|
where equipmentCode = '{devicecode}' and CONVERT(VARCHAR(10), res.update_time , 120)= CONVERT(VARCHAR(10), GetDate() , 120); ";
|
|
|
|
|
|
DataSet dtset = Utils.netClientDBHelper.getDataSet(sql);
|
|
|
if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
return dtset.Tables[0];
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取成型机状态
|
|
|
/// </summary>
|
|
|
/// <param name="bdt"></param>
|
|
|
/// <param name="edt"></param>
|
|
|
/// <returns></returns>
|
|
|
public DataTable GetFormingMachineState(string devicecode)
|
|
|
{
|
|
|
|
|
|
string sql = $@"select status from base_equipment where equipment_code = '{devicecode}'; ";
|
|
|
|
|
|
DataSet dtset = Utils.netClientDBHelper.getDataSet(sql);
|
|
|
if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
return dtset.Tables[0];
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查询出入记录
|
|
|
/// </summary>
|
|
|
/// <param name="bdt"></param>
|
|
|
/// <param name="edt"></param>
|
|
|
/// <returns></returns>
|
|
|
public DataTable GetInOutHistoryList(string devicecode)
|
|
|
{
|
|
|
string sql = $@"SELECT ord.workorder_id,ord.workorder_code,res.OrderCode,ord.product_name,product_code,isnull(car_num,0) as car_num,
|
|
|
isnull([begin],'1900-01-01 08:00:00') as [begin],ord.status,ord.route_code,ord.attr1,work_batch_code,res.taskcode,res.rfid,plan_time ,res.update_time
|
|
|
FROM [dbo].[mes_material_transfer_result] res
|
|
|
LEFT JOIN pro_order_workorder ord on res.OrderCode = ord.workorder_id
|
|
|
left JOIN pro_wet_material_plan_detail wet on wet.workorder_id = ord.workorder_id
|
|
|
LEFT JOIN pro_rfid_process_detail rfid on rfid.workorder_code = ord.workorder_code and rfid.rfid = res.rfid
|
|
|
where equipmentCode = '{devicecode}' and res.OrderCode is not null ORDER BY plan_time desc; ";
|
|
|
|
|
|
DataSet dtset = Utils.netClientDBHelper.getDataSet(sql);
|
|
|
if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
return dtset.Tables[0];
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查询完成记录
|
|
|
/// </summary>
|
|
|
/// <param name="bdt"></param>
|
|
|
/// <param name="edt"></param>
|
|
|
/// <returns></returns>
|
|
|
public DataTable GetCompleteHistoryList(string devicecode)
|
|
|
{
|
|
|
//taskcode=1,当前机台完成,ord.status = 'w3'当前工单完成
|
|
|
// string sql = $@"SELECT workorder_code,product_name,product_code,isnull(car_num,0) as car_num,isnull([begin],'1900-00-00') as [begin],beout,ord.status,product_date,ord.create_time FROM [dbo].[mes_material_transfer_result] res
|
|
|
//LEFT JOIN pro_order_workorder ord on res.OrderCode = ord.workorder_id
|
|
|
//where res.taskcode = '1' and equipmentCode = '{devicecode}'; ";
|
|
|
string sql = $@"SELECT ord.workorder_id,ord.workorder_code,res.OrderCode,ord.product_name,product_code,isnull(car_num,0) as car_num,
|
|
|
isnull([begin],'1900-01-01 08:00:00') as [begin],ord.status ,ord.route_code,ord.attr1,work_batch_code,res.taskcode,res.rfid,plan_time ,res.update_time
|
|
|
FROM [dbo].[mes_material_transfer_result] res
|
|
|
LEFT JOIN pro_order_workorder ord on res.OrderCode = ord.workorder_id
|
|
|
left JOIN pro_wet_material_plan_detail wet on wet.workorder_id = ord.workorder_id
|
|
|
LEFT JOIN pro_rfid_process_detail rfid on rfid.workorder_code = ord.workorder_code and rfid.rfid = res.rfid
|
|
|
where res.taskcode = '0' and equipmentCode = 'C6' and res.OrderCode is not null ORDER BY plan_time; ";
|
|
|
|
|
|
DataSet dtset = Utils.netClientDBHelper.getDataSet(sql);
|
|
|
if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
return dtset.Tables[0];
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取工单当前状态,弃用
|
|
|
/// </summary>
|
|
|
/// <param name="bdt"></param>
|
|
|
/// <param name="edt"></param>
|
|
|
/// <returns></returns>
|
|
|
public string GetWorkOrderStatus(string orderCode)
|
|
|
{
|
|
|
|
|
|
string sql = $@"select status from pro_order_workorder where workorder_code = '{orderCode}'";
|
|
|
var obj = Utils.netClientDBHelper.getScalar(sql, null);
|
|
|
string issucc = obj == null ? "" : obj.ToString();
|
|
|
|
|
|
return issucc;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新工单
|
|
|
/// </summary>
|
|
|
/// <param name="bdt"></param>
|
|
|
/// <param name="edt"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool UpdateWorkOrder(string orderCode,string status)
|
|
|
{
|
|
|
|
|
|
string sql = $@"update pro_order_workorder set status = '{status}' where workorder_code = '{orderCode}'";
|
|
|
|
|
|
int issucc = Utils.netClientDBHelper.executeUpdate(sql);
|
|
|
|
|
|
return issucc > 0 ? true : false;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新工单
|
|
|
/// </summary>
|
|
|
/// <param name="bdt"></param>
|
|
|
/// <param name="edt"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool InsertData(FoamingMacModel formingModel)
|
|
|
{
|
|
|
|
|
|
string sql = $@"INSERT INTO [lanju_op_xiaolan_ds].[dbo].[mes_material_transfer_result] (
|
|
|
[id],
|
|
|
[begin],
|
|
|
[beout],
|
|
|
[equipmentCode],
|
|
|
[OrderCode],
|
|
|
[sku],
|
|
|
[planID],
|
|
|
[rfid],
|
|
|
[now_process_id],
|
|
|
[status],
|
|
|
[create_time],
|
|
|
[rfid_status],
|
|
|
[taskcode],
|
|
|
[state],
|
|
|
[update_time]
|
|
|
)
|
|
|
VALUES
|
|
|
(
|
|
|
'{CommonFunc.Common.GetUUID()}',
|
|
|
'GetDate()',
|
|
|
'GetDate()',
|
|
|
'{Utils.GetAppSetting("DeviceCode")}',
|
|
|
'{formingModel.workorder_id}',
|
|
|
'{formingModel.product_code}',
|
|
|
'',
|
|
|
'{formingModel.rfid}',
|
|
|
'',
|
|
|
'4',
|
|
|
'GetDate()',
|
|
|
'1',
|
|
|
'0',
|
|
|
'1',
|
|
|
'GetDate()'
|
|
|
);";
|
|
|
|
|
|
int issucc = Utils.netClientDBHelper.executeUpdate(sql);
|
|
|
|
|
|
return issucc > 0 ? true : false;
|
|
|
}
|
|
|
}
|
|
|
}
|