You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
257 lines
7.0 KiB
257 lines
7.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Entity.Validation;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using Warehouse.Models.DTO;
|
|
using Warehouse.Models.mesLevel4;
|
|
using Warehouse.Models.mesModel;
|
|
using Z.EntityFramework.Plus;
|
|
|
|
namespace Warehouse.DAL.Config.WorkOrder
|
|
{
|
|
public class WorkOrderMSDal
|
|
{
|
|
public int Create(wo_mfg WO)
|
|
{
|
|
using (var context = new mesModel())
|
|
{
|
|
try
|
|
{
|
|
context.wo_mfg.Add(WO);
|
|
return context.SaveChanges();
|
|
}
|
|
catch (DbEntityValidationException dbEx)
|
|
{
|
|
var a = dbEx.EntityValidationErrors;
|
|
throw dbEx;
|
|
}
|
|
}
|
|
}
|
|
|
|
public int Update(WorkOrderDto WO)
|
|
{
|
|
using (var context = new mesModel())
|
|
{
|
|
return context.wo_mfg.Where(a => a.workorder == WO.workorder).Update(a => new wo_mfg
|
|
{
|
|
plan_qty = WO.planQty,
|
|
target_qty = WO.workorderQty,
|
|
warnning_qty = WO.warnningQty,
|
|
customer = WO.customer,
|
|
power_grade_group_id = WO.powerRule
|
|
});
|
|
}
|
|
}
|
|
|
|
public List<dynamic> QueryDDL(string Type)
|
|
{
|
|
using (var context = new mesModel())
|
|
{
|
|
//context.df_source.Where(a=>a.source_group_name == Type).Select()
|
|
var Res = from a in context.df_source
|
|
where (a.source_group_name == Type)
|
|
select new
|
|
{
|
|
name = a.source_desc,
|
|
value = a.source_value
|
|
};
|
|
return ((IEnumerable<dynamic>)Res).ToList();
|
|
}
|
|
}
|
|
|
|
//客户
|
|
public IEnumerable<dynamic> QueryCustomer()
|
|
{
|
|
using (var context = new mesLevel4Model())
|
|
{
|
|
var Res = from a in context.customers
|
|
select new
|
|
{
|
|
value = a.cust_id,
|
|
name = a.cust_desc
|
|
};
|
|
return Res.ToList();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 通过产品id查询产品model
|
|
/// </summary>
|
|
/// <param name="ProductId"></param>
|
|
/// <returns></returns>
|
|
public config_products QueryProduct(string ProductId)
|
|
{
|
|
using (var context = new mesModel())
|
|
{
|
|
return context.config_products.Find(ProductId);
|
|
}
|
|
}
|
|
|
|
//产品
|
|
public IEnumerable<dynamic> QueryProduct()
|
|
{
|
|
using (var context = new mesLevel4Model())
|
|
{
|
|
var Res = from a in context.master_part
|
|
where a.part_type == "MODULE"
|
|
select new
|
|
{
|
|
name = a.bom_part_nbr + "-" + a.descriptions,
|
|
value = a.bom_part_nbr
|
|
};
|
|
return Res.ToList();
|
|
}
|
|
}
|
|
//工单类型
|
|
public IEnumerable<dynamic> QueryWorkOrderType()
|
|
{
|
|
using (var context = new mesModel())
|
|
{
|
|
var Res = from a in context.df_wo_type
|
|
select new
|
|
{
|
|
name = a.descriptions,
|
|
value = a.workorder_type
|
|
};
|
|
return Res.ToList();
|
|
}
|
|
}
|
|
|
|
//订单类型
|
|
public IEnumerable<dynamic> QuerySaleType()
|
|
{
|
|
using (var context = new mesModel())
|
|
{
|
|
var Res = from a in context.df_order_type
|
|
select new
|
|
{
|
|
name = a.descriptions,
|
|
value = a.order_type
|
|
};
|
|
return Res.ToList();
|
|
}
|
|
}
|
|
|
|
//分档规则
|
|
public IEnumerable<dynamic> QueryPowerRule()
|
|
{
|
|
using (var context = new mesModel())
|
|
{
|
|
var Res = from a in context.config_power_group
|
|
where a.active_flag == 1
|
|
select new
|
|
{
|
|
name = a.descriptions,
|
|
value = a.power_grade_group_id
|
|
};
|
|
return Res.ToList();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 车间
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public IEnumerable<dynamic> QueryWorkshop()
|
|
{
|
|
using (var context = new mesModel())
|
|
{
|
|
var Res = from a in context.df_areas
|
|
where a.active_flag == 1
|
|
select new
|
|
{
|
|
name = a.descriptions,
|
|
value = a.area_code
|
|
};
|
|
return Res.ToList();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询工单
|
|
/// </summary>
|
|
/// <param name="WorkOrder"></param>
|
|
/// <returns></returns>
|
|
public List<WorkOrderDto> QueryWorkOrderById(string WorkOrder)
|
|
{
|
|
using (var context = new mesModel())
|
|
{
|
|
var Res= context.wo_mfg.Where(a => a.workorder == WorkOrder).Select(a => new WorkOrderDto()
|
|
{
|
|
cellQty = a.cell_qty,
|
|
crystalType = a.crys_type,
|
|
customer = a.customer,
|
|
oemCustomer = a.OEMcustomer,
|
|
sale = a.sale_order,
|
|
saleType = a.Order_Type,
|
|
gridLineType = a.busbar_type,
|
|
cellType = a.cell_type,
|
|
moduleColor = a.mod_color,
|
|
planQty = a.plan_qty,
|
|
powerRule = a.power_grade_group_id,
|
|
products = a.product_code,
|
|
moduleType = a.mod_type,
|
|
warnningQty = a.warnning_qty,
|
|
workorder = a.workorder,
|
|
workorderQty = a.target_qty,
|
|
workorderType = a.workorder_type,
|
|
endDate = a.finish_time,
|
|
startDate = a.plan_date,
|
|
workshop = a.area_code
|
|
}).ToList();
|
|
return Res;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询工单
|
|
/// </summary>
|
|
/// <param name="WorkShop"></param>
|
|
/// <returns></returns>
|
|
public List<dynamic> Query(string WorkShop)
|
|
{
|
|
using (var context = new mesModel())
|
|
{
|
|
string sql = @"
|
|
SELECT a.workorder,
|
|
a.area_code,e.descriptions area_desc,
|
|
a.product_code as product,
|
|
b.workorder_type,
|
|
b.descriptions workordertype,
|
|
a.sale_order as sales
|
|
,a.customer,d.cust_desc,a.wo_status,
|
|
c.descriptions workorderstatus
|
|
,a.plan_qty as planqty
|
|
,a.create_date as createtime,
|
|
a.create_user,
|
|
a.target_qty as targetqty
|
|
,a.pack_qty,
|
|
a.warnning_qty as warnningqty,
|
|
a.sn_qty as lotqty,
|
|
a.plan_qty-a.sn_qty remainning_Qty,f.descriptions product_code_desc,a.power_grade_group_id,
|
|
g.descriptions powerrule,
|
|
a.workorder_ex,
|
|
a.plan_date as plandate,
|
|
a.cell_supplier_code,a.cell_supplier_desc,a.container_threshold,a.mod_color,a.mod_type,a.busbar_type,a.cell_type,a.cell_qty,a.crys_type
|
|
,a.OEMcustomer,a.finish_time,a.Order_Type
|
|
FROM mes_main.dbo.wo_mfg a
|
|
left join mes_main.dbo.df_wo_type b
|
|
on a.workorder_type=b.workorder_type
|
|
left join mes_main.dbo.df_wo_status c
|
|
on a.wo_status=c.wo_status
|
|
left join mes_main.dbo.df_areas e
|
|
on a.area_code=e.area_code
|
|
left join mes_level4_iface.dbo.customers d
|
|
on a.customer=d.cust_id
|
|
left join mes_level4_iface.dbo.master_part f
|
|
on a.product_code=f.bom_part_nbr
|
|
left join mes_main.dbo.config_power_group g
|
|
on g.power_grade_group_id=a.power_grade_group_id
|
|
where a.area_code=@workshop
|
|
order by a.create_date desc";
|
|
var res = context.DynamicListFromSql(sql, new Dictionary<string, object> { { "workshop", WorkShop } });
|
|
return res.ToList();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|