public dynamic GetSettingList(string id) { var pQuery = ParamQuery.Instance().Where("UserCode", id); var service = new sys_userSettingService(); var result = service.GetModelList(pQuery); var keys = result.ToDictionary(x => x.SettingCode).Keys; foreach (var item in AppSettings.DefaultUserSettings.Where(x => !keys.Contains(x.Key))) { var row = new sys_userSetting() { SettingCode = item.Key, SettingValue = item.Value, Description = AppSettings.DefaultUserSettingDesc.ContainsKey(item.Key)? AppSettings.DefaultUserSettingDesc[item.Key]:item.Key }; result.Add(row); } return(result.OrderBy(x => x.SettingCode)); }
public string ChangePassword(string PasswordOld, string PasswordNew) { var UserCode = FormsAuth.GetLoginer().UserCode; var pQuery = ParamQuery.Instance() .Where("UserCode", UserCode) .Where("Password", EncryptHelper.MD5(PasswordOld)); var list = GetModelList(pQuery); if (list.Count == 0) { return("原密码不正确!"); } db.Update("sys_user") .Column("Password", EncryptHelper.MD5(PasswordNew)) .Where("UserCode", UserCode) .Execute(); return(string.Empty); }
public ActionResult Index() { var loginer = FormsAuth.GetUserData <LoginerBase>(); var user = new SYS_BN_UserService().GetModel(ParamQuery.Instance().AndWhere("IsEnable", 1).AndWhere("UserCode", MmsHelper.GetUserCode())); var Department = new SYS_BN_DepartmentService().GetModel(ParamQuery.Instance().AndWhere("IsEnable", 1).AndWhere("DepartmentCode", user.DepartmentCode)); var model = new { urls = new { query = "/api/Mms/MES_MaterialPickMain", remove = "/api/Mms/MES_MaterialPickMain/", billno = "/api/Mms/MES_MaterialPickMain/getnewbillno", audit = "/api/Mms/MES_MaterialPickMain/audit/", edit1 = "/Mms/MES_MaterialPickMain/edit/" }, resx = new { detailTitle = "车间领料明细", noneSelect = "请先选择一条单据!", deleteConfirm = "确定要删除选中的单据吗?", deleteSuccess = "删除成功!", auditSuccess = "单据已审核!" }, dataSource = new { //dsPurpose = new sys_codeService().GetValueTextListByType("Purpose") }, form = new { BillCode = "", DepartmentID = Department.DepartmentCode ?? "", DepartmentName = Department.DepartmentName ?? "", PickingDate = "", BillState = "1", }, idField = "ID" }; return(View(model)); }
// GET: /Mms/Inspectionwell/ #region 查询页面 public ActionResult Index() { var currentProject = MmsHelper.GetCurrentProject(); var model = new { dataSource = new { warehouseItems = new mms_warehouseService().GetWarehouseItems(currentProject), Category = new sys_codeService().GetDynamicList(ParamQuery.Instance().Select("Value as value,Text as text").AndWhere("CodeType", "InspectionWellCategory")), AdministrativeArea = new sys_codeService().GetDynamicList(ParamQuery.Instance().Select("Value as value,Text as text").AndWhere("CodeType", "AdministrativeArea")), FacilityStatus = new sys_codeService().GetDynamicList(ParamQuery.Instance().Select("Value as value,Text as text").AndWhere("CodeType", "FacilityStatus")) }, urls = new { query = "/api/mms/riverestuary", remove = "/api/mms/riverestuary/", billno = "/api/mms/riverestuary/getnewbillno", audit = "/api/mms/riverestuary/audit/", edit = "/mms/riverestuary/edit/" }, resx = new { detailTitle = "信息维护", noneSelect = "请先选择条信息!", deleteConfirm = "确定要删除选中的信息吗?", deleteSuccess = "删除成功!", auditSuccess = "信息已审核!" }, form = new { IdentificationCode = "", Address = "", AdministrativeArea = "", Category = "", DrainageCode = "" } }; return(View(model)); }
public ActionResult Edit(string id = "") { var data = new PickingApiController().GetEditMaster(id); var model = new { form = data.form, scrollKeys = data.scrollKeys, dataSource = new { warehouseItems = new psi_warehouseService().GetDynamicList(ParamQuery.Instance().Select("Id as value,Name as text")) }, urls = new { getdetail = "/api/psi/picking/getdetail/", getmaster = "/api/psi/picking/geteditmaster/", edit = "/api/psi/picking/edit", audit = "/api/psi/picking/audit/", getrowid = "/api/psi/picking/getnewrowid/", }, resx = new { rejected = "已撤消修改!", editSuccess = "保存成功!", auditSuccess = "单据已审核!" }, defaultRow = new { Num = 1, UnitPrice = 0, Money = 0 }, setting = new { postFormKeys = new string[] { "BillNo" }, postListFields = new string[] { "BillNo", "RowId", "GoodNo", "Num", "UnitPrice", "Money", "Remark" } } }; return(View(model)); }
// // GET: /Mms/TestABC/ public ActionResult Index() { var model = new { dataSource = new { UnitItems = new sys_codeService().GetDynamicList(ParamQuery.Instance().Select("Code as value,Text as text").Where("CodeType", "MeasureUnit")) }, urls = new { query = "/api/mms/product", newkey = "/api/mms/product/getnewkey", edit = "/api/mms/product/edit" }, resx = new { noneSelect = "请先选择一条产品数据!", editSuccess = "保存成功!", auditSuccess = "单据已审核!" }, form = new { ProductName = "", Color = "", Price = "", Unit = "", Remark = "", CreateDate = "" }, defaultRow = new { }, setting = new { postListFields = new string[] { "ID", "ProductName", "Color", "Price", "Unit", "Money", "Qty", "Remark", "CreateDate" } } }; return(View(model)); }
//动作:根据角色代码查询角色的用户数据 // GET: /Sys/Base_Role/GetRoleUsers public JsonResult GetRoleUsers(Dictionary <string, string> data) { string rolecode = data.Value <string>("rolecode"); if (rolecode.IsNullOrEmpty()) { dynamic result = new ExpandoObject(); result.rows = new List <dynamic>(); result.total = 0; return(JsonNet(result)); } int pageIndex = data.Value <int>("page"); int pageSize = data.Value <int>("rows"); ParamQuery pq = ParamQuery.Instance().From("V_Base_UserRole").OrderBy("Sort ASC").Paging(pageIndex, pageSize).ClearWhere().AndWhere("RoleCode", rolecode); var list = Base_RoleService.Instance.GetDynamicPageList(pq); //var list = Base_UserService.Instance.GetPageList(where, pageIndex, pageSize, out pageCount, out totalRows); //var jsonData = this.CreateJsonData_DataGrid(totalRows, list, null); //return JsonNet(jsonData); //var list = Base_RoleService.Instance.GetRoleUser(rolecode); return(JsonNet(list)); }
public ActionResult Stock() { var model = new { dataSource = new { warehouseItems = new psi_warehouseService().GetDynamicList(ParamQuery.Instance().Select("Id as value,Name as text")), stateItems = new sys_codeService().GetDynamicList(ParamQuery.Instance().Select("value,text").AndWhere("CodeType", "StockState")) }, urls = new { query = "/api/psi/warehouse/getstocklist", newkey = "/api/psi/warehouse/getnewkey", edit = "/api/psi/warehouse/edit"//audit = "/api/psi/audit"; }, resx = new { noneSelect = "请先选择一条库存记录!", editSuccess = "保存成功!", auditSuccess = "已审核!" }, form = new { Id = "", Name = "", ChargePerson = "", Tel = "" }, defaultRow = new { }, setting = new { postListFields = new string[] { "Id", "Name", "ChargePerson", "Tel", "Addr", "Remark" } } }; return(View(model)); }
public void Edit(dynamic data) { var id = data.form["ID"].ToString(); var pQuery = ParamQuery.Instance().Select("*").AndWhere("ID", id); var re = new PRS_RectificationMainService().GetModelList(pQuery); if (re.Count > 0 && re[0].BillState == 1) { MmsHelper.ThrowHttpExceptionWhen(true, "已审核数据不能修改!"); return; } var formWrapper = RequestWrapper.Instance().LoadSettingXmlString(@" <settings> <table> PRS_RectificationMain </table> <where> <field name='ID' cp='equal'></field> </where> </settings> "); var tabsWrapper = new List <RequestWrapper>(); tabsWrapper.Add(RequestWrapper.Instance().LoadSettingXmlString(@" <settings> <table>PRS_RectificationDetail</table> <where> <field name='ID' cp='equal'></field> </where> </settings>")); if (data.form["BillCode"] == "系统生成") { string documentNo = MmsHelper.GetOrderNumber("PRS_RectificationMain", "BillCode", "SCZG", "", ""); data.form["BillCode"] = documentNo; } var service = new PRS_RectificationMainService(); var result = service.EditPage(data, formWrapper, tabsWrapper); }
public ActionResult Edit(string id = "") { // var model = new // { // urls = new { // getdata = "/api/Mms/PMS_ContractInfo/GetPageData/", //获取主表数据及数据滚动数据api // edit = "/api/Mms/PMS_ContractInfo/edit/", //数据保存api // audit = "/api/Mms/PMS_ContractInfo/audit/", //审核api // newkey = "/api/Mms/PMS_ContractInfo/GetNewRowId/" //获取新的明细数据的主键(日语叫采番) // }, // resx = new { // rejected = "已撤消修改!", // editSuccess = "保存成功!", // auditPassed ="单据已通过审核!", // auditReject = "单据已取消审核!" // }, // dataSource = new{ // pageData=new PMS_ContractInfoApiController().GetPageData(id) // //payKinds = codeService.GetValueTextListByType("PayType") // }, // form = new{ // defaults = new PMS_ContractInfo().Extend(new { }), // primaryKeys = new string[]{"ID"} // }, // tabs = new object[]{ // new{ // type = "form", // primaryKeys = new string[]{"ID"}, // defaults = new {ID = "",ContractCode = "",ProjectName = "",ProjectForShort = "",AdvancePaymentDate = "",Is0tSartProduct = "",IsEnable = "",Remark = "",ProductReport = ""} // } //} // }; // return View(model); var pQuery = ParamQuery.Instance().Select("top 1 *").AndWhere("IsEnable", "1").OrderBy("ProjectID desc"); var model = new PMS_BN_ProjectService().GetModel(pQuery); ViewData["cinfo"] = model; return(View()); }
public ActionResult Index() { var user = new SYS_BN_UserService().GetModel(ParamQuery.Instance().AndWhere("IsEnable", 1).AndWhere("UserCode", MmsHelper.GetUserCode())); string workshopName = new SYS_BN_DepartmentService().GetModel(ParamQuery.Instance().AndWhere("IsEnable", 1).AndWhere("DepartmentCode", user.DepartmentCode ?? "")).DepartmentName ?? ""; var model = new { urls = new { query = "/api/Mms/MES_WorkshopBatching", remove = "/api/Mms/MES_WorkshopBatching/", billno = "/api/Mms/MES_WorkshopBatching/getnewbillno", audit = "/api/Mms/MES_WorkshopBatching/audit/", edit1 = "/Mms/MES_WorkshopBatching/edit/" }, resx = new { detailTitle = "单据明细", noneSelect = "请先选择一条单据!", deleteConfirm = "确定要删除选中的单据吗?", deleteSuccess = "删除成功!", auditSuccess = "单据已审核!" }, dataSource = new { //dsPurpose = new sys_codeService().GetValueTextListByType("Purpose") }, form = new { BatchingCode = "", ContractCode = "", DepartmentName = workshopName, //WorkshopCode = "", }, idField = "BatchingCode" }; return(View(model)); }
public ActionResult Claim() { var model = new { dataSource = new { warehouseItems = new psi_warehouseService().GetDynamicList(ParamQuery.Instance().Select("Id as value,Name as text")) }, urls = new { query = "/api/psi/goods", newkey = "/api/psi/goods/getnewkey", edit = "/api/psi/goods/edit"//audit = "/api/psi/audit"; }, resx = new { noneSelect = "请先选择一条货物数据!", editSuccess = "保存成功!", auditSuccess = "单据已审核!" }, form = new { Id = "", Name = "", Catagory = "", Brand = "" }, defaultRow = new { }, setting = new { postListFields = new string[] { "Id", "Name", "Catagory", "Brand", "Model", "Unit", "Remark" } } }; return(View(model)); }
//页面:角色权限设置页面 SaveRoleMenuButton // GET: /Sys/Base_Role/RoleRights?rolecode=000 public ActionResult RoleRights(string rolecode) { var expando = (IDictionary <string, object>) new ExpandoObject(); expando["menulist"] = string.Format("/{0}/{1}/GetList_Meuns", "Sys", "Base_Role"); expando["saverolemenus"] = string.Format("/{0}/{1}/SaveRoleMenus", "Sys", "Base_Role"); expando["saverolemenubutton"] = string.Format("/{0}/{1}/SaveRoleMenuButton", "Sys", "Base_Role"); expando["saverolemenubutton_all"] = string.Format("/{0}/{1}/SaveRoleMenuButton_All", "Sys", "Base_Role"); ParamQuery pq = ParamQuery.Instance().From("V_Base_MenuButton").OrderBy("order by MenuCode asc,ButtonSort asc"); var listMenuButtons = Base_MenuService.Instance.GetMenuButtons(); var listRoleMenus = Base_RoleService.Instance.GetRoleMenus(rolecode); var listRoleMenuButtons = Base_RoleService.Instance.GetRoleMenuButtons(rolecode); var model = new { urls = ControllerHelper.GetIndexUrls("Sys", "Base_Role", expando), data = new { rolecode = rolecode }, list_menu_buttons = listMenuButtons, list_role_menus = listRoleMenus, list_role_menu_buttons = listRoleMenuButtons }; return(View("RoleMenuButton", model)); }
public void RecursionDelete(string id) { db.UseTransaction(true); var pQuery = ParamQuery.Instance().Where("ParentCode", id); var list = base.BuilderParse(pQuery).QueryManyDynamic(); foreach (var item in list) { RecursionDelete(item.OrganizeCode); } db.Sql(@" -- 删除机构角色Map delete from sys_organizeRoleMap where OrganizeCode = @0; -- 删除用户机构Map delete from sys_userOrganizeMap where OrganizeCode = @0", id).Execute(); var pDelete = ParamDelete.Instance().Where("OrganizeCode", id); base.BuilderParse(pDelete).Execute(); db.Commit(); }
public ActionResult Index() { var model = new { dataSource = new { warehouseItems = new psi_warehouseService().GetDynamicList(ParamQuery.Instance().Select("Id as value,Name as text")) }, urls = new { query = "/api/psi/receive", remove = "/api/psi/receive/", billno = "/api/psi/receive/getnewbillno", audit = "/api/psi/receive/audit/", edit = "/psi/receive/edit/" }, resx = new { detailTitle = "收货单明细", noneSelect = "请先选择一条收货单!", deleteConfirm = "确定要删除选中的收货单吗?", deleteSuccess = "删除成功!", auditSuccess = "单据已审核!" }, form = new { BillNo = "", ReceivePerson = "", SupplierName = "", Warehouse = "", Contract = "", ReceiveDate = "" } }; return(View(model)); }
public ActionResult Index() { var model = new { urls = MmsHelper.GetIndexUrls("transfer"), resx = MmsHelper.GetIndexResx("调拨单"), dataSource = new { PriceKind = new sys_codeService().GetDynamicList(ParamQuery.Instance().Select("Code as value,Text as text").Where("CodeType", "Pricing")), warehouseItems = new mms_warehouseService().GetWarehouseItems(MmsHelper.GetCurrentProject()) }, form = new { BillNo = "", ReceiveUnitName = "", DoPerson = "", WarehouseCode = "", PriceKind = "", TransferDate = "" } }; return(View(model)); }
public dynamic GetPageData(string id = "") { var pQuery = ParamQuery.Instance(); if (id == "") { var result = new { tab0 = "", }; return(result); } else { List <dynamic> data = new List <dynamic>(); data = new PMS_BN_ProjectDetailService().GetDynamicList(pQuery.AndWhere("MainID", id)); var result = new { rows = data, total = data.Count }; return(result); } }
public string GetDelete(string id) { string msg = "删除成功!"; var pQuery = ParamQuery.Instance().Select("*").AndWhere("ID", id); var re = new APS_ProductPurchaseMainService().GetModel(pQuery); if (re == null || re.BillState == 2) { msg = "已审核不能删除!"; } else { var result = new APS_ProductPurchaseMainService().GetDelete(id); var pQuery2 = ParamQuery.Instance().Select("*").AndWhere("MainID", id); var services = new APS_ProductPurchaseDetailService(); var list = services.GetModelList(pQuery2); foreach (var item in list) { services.GetDelete(item.ID.ToString()); } } return(msg); }
public ActionResult Index(string id) { WorkTicketCode = id; //查询工票表信息 var WorkTicketCodeModel = new MES_WorkingTicketService().GetModelList(ParamQuery.Instance().AndWhere("WorkTicketCode", WorkTicketCode)).FirstOrDefault(); var WorkshopCode = WorkTicketCodeModel.WorkshopCode; //工票信息车间编码 var WorkshopName = WorkTicketCodeModel.WorkshopName; //工票信息车间名称 var PartCode = WorkTicketCodeModel.PartCode; //工票信息零件编码 //var WorkQuantity = WorkTicketCodeModel.WorkQuantity;//工票信息派工数量 var ApsCode = WorkTicketCodeModel.ApsCode; //计划编码 var ApproveState = WorkTicketCodeModel.ApproveState ?? 1; //查询计划中产品数量 var PlanNumber = new APS_ProjectProduceDetialService().GetField <int>( ParamQuery.Instance() .Select("Quantity/BomQty") .From("APS_ProjectProduceDetial") .AndWhere("ApsCode", ApsCode)); var MES_WorkshopBatchingList = new MES_WorkshopBatchingService().GetModelList(ParamQuery.Instance().AndWhere("WorkshopCode", WorkshopCode).AndWhere("PartCode", PartCode).AndWhere("IsEnable", 1)); var MES_WorkshopBatchingDetailList = new List <MES_WorkshopBatchingDetail>(); var MES_WorkTicketMateList = new List <dynamic>(); MES_WorkTicketMateList = new MES_WorkTicketMateService().GetDynamicList(ParamQuery.Instance().AndWhere("WorkTicketCode", WorkTicketCode)); if (MES_WorkTicketMateList.Count == 0) { var PRS_Process_BOMList = new PRS_Process_BOMService() .GetModelList(); if (MES_WorkshopBatchingList.Count > 0) { string BatchingCodeStr = "'" + string.Join("','", MES_WorkshopBatchingList.Select(a => a.BatchingCode)) + "'"; MES_WorkshopBatchingDetailList = new MES_WorkshopBatchingDetailService().GetModelList(ParamQuery.Instance().AndWhere("BatchingCode", BatchingCodeStr, Cp.In)); } if (MES_WorkshopBatchingDetailList.Count > 0) { MES_WorkTicketMateList = MES_WorkshopBatchingDetailList .Join(PRS_Process_BOMList, a => new { PartCode = a.PartCode, ParentCode = a.ParentCode }, b => new { PartCode = b.PartCode, ParentCode = b.ParentCode }, (a, b) => new { a, b }) //.Join(PRS_Process_BOMList, c => new { ParentCode = c.b.ParentCode }, d => new { ParentCode = d.PartCode }, (c, d) => { c,d }) .Select(r => new { InventoryCode = r.b.InventoryCode, PartCode = r.b.PartCode, ParentCode = r.b.ParentCode, InventoryName = r.a.PartName, RequiredQuantity = r.a.BatchingNum, //需求数量 TotalQuantity = r.b.PartQuantity * PlanNumber, //需求总数 WorkTicketCode = WorkTicketCode, WorkshopCode = WorkshopCode, WorkshopName = WorkshopName, IsEnable = 1, IsCrux = r.b.IsCrux }).ToList <dynamic>(); } } var code = new sys_codeService(); var model = new { dataSource = new { MES_WorkTicketMateList = MES_WorkTicketMateList, ApproveState = ApproveState }, urls = new { query = "/api/Mms/MES_WorkTicketMate", newkey = "/api/Mms/MES_WorkTicketMate/getnewkey", edit = "/api/Mms/MES_WorkTicketMate/edit" }, resx = new { noneSelect = "请先选择一条数据!", editSuccess = "保存成功!", auditSuccess = "单据已审核!" }, form = new { WorkTicketCode = "" }, defaultRow = new { }, setting = new { idField = "ID", postListFields = new string[] { "ID", "WorkTicketCode", "InventoryCode", "PartCode", "ParentCode", "InventoryName", "RequiredQuantity", "TotalQuantity", "WorkshopCode", "WorkshopName", "CreatePerson", "CreateTime", "IsEnable", "IsCrux" } } }; return(View(model)); }
public void Cover_MES_BN_MatchingTableDetail(List <MES_BN_MatchingTableDetail> MES_BN_MatchingTableDetailList, List <PRS_Process_BOM> ProcessBomList) { try { db.UseTransaction(true); var MaxID = new MES_BN_MatchingTableDetailService().GetField <int>(ParamQuery.Instance().Select("max(ID) as ID").From("MES_BN_MatchingTableDetail")); string MES_BN_MatchingTableDetailListStr = string.Join(",", MES_BN_MatchingTableDetailList.Select(a => a.ID)); db.Sql($"update MES_BN_MatchingTableDetail set IsEnable=0 where ID in({MES_BN_MatchingTableDetailListStr})").Execute(); var PMS_BN_ProjectList = new PMS_BN_ProjectService().GetModelList(); var PMS_BN_ProjectDetailList = new PMS_BN_ProjectDetailService().GetModelList(); var UpdateList = new List <int>(); ProcessBomList.ForEach(item => { var PartCode = item.PartCode; var ParentCode = item.ParentCode; var IsExist = MES_BN_MatchingTableDetailList.Where(a => a.PartCode == PartCode && a.PPartCode == ParentCode).Select(a => a.ID); if (IsExist.Count() > 0) { UpdateList.Add(IsExist.FirstOrDefault()); } else { MES_BN_MatchingTableDetail model = new MES_BN_MatchingTableDetail(); model.ID = ++MaxID; model.PartCode = PartCode; model.PartName = item.PartName; model.PPartCode = item.ParentCode; model.ContractCode = item.ContractCode; model.ProjectDetailID = item.ProductID; model.ProjectName = PMS_BN_ProjectDetailList.Where(a => a.ID == item.ProductID).FirstOrDefault().ProductName; model.NeedQuantity = item.PartQuantity ?? 0 * PMS_BN_ProjectDetailList.Where(a => a.ID == item.ProductID).FirstOrDefault().Quantity ?? 0; model.Type = item.IsSelfMade; model.TypeName = item.IsSelfMade == "0" ? "成品件" : "加工件"; model.BomQuantity = item.PartQuantity ?? 0; model.IsMaterial = 0; model.IsEnable = 1; model.ApproveState = "1"; model.CreatePerson = MmsHelper.GetUserName(); model.CreateTime = DateTime.Now; //db.Insert<MES_BN_MatchingTableDetail>("MES_BN_MatchingTableDetail", model).AutoMap(a => a.ID).ExecuteReturnLastId<int>(); string sql = WinFormClientService.GetInsertSQL <MES_BN_MatchingTableDetail>(model); db.Sql(sql).Execute(); } }); if (UpdateList.Count > 0) { db.Sql($"update MES_BN_MatchingTableDetail set IsEnable=1 where ID in({string.Join(",", UpdateList)})").Execute(); } db.Commit(); } catch (Exception ex) { db.Rollback(); } }
public IEnumerable <dynamic> GetButtons() { var pQuery = ParamQuery.Instance().OrderBy("ButtonSeq"); return(new sys_buttonService().GetModelList(pQuery)); }
/// <summary> /// 获取工单进度 /// </summary> /// <param name="WorkShopId"></param> /// <param name="TenantID"></param> /// <returns></returns> public dynamic GetOrderNoProgress(string WorkShopId, string TenantID) { LineBoardController lineboardController = new LineBoardController(); List <dynamic> result = new List <dynamic>(); try { minimes_order_recordService reportService = new minimes_order_recordService(); List <minimes_order_record> reportList = reportService.GetModelList(ParamQuery.Instance().AndWhere("WorkShopId", WorkShopId).AndWhere("State", 1).AndWhere("TenantID", TenantID).OrderBy("LineId ASC")); foreach (var item in reportList) { minimes_order_record row = new minimes_order_record(); row.LineId = item.LineId; //产线ID row.LineName = item.LineName; //产线名称 row.OrderNo = item.OrderNo; //工单编号 row.ProductCode = item.ProductCode; //产品编号 row.ProductName = item.ProductName; //产品名称 row.Qty = item.Qty; //实际产量 row.PlanQty = item.PlanQty; //计划产量 row.StopCount = item.StopTime; //停机时间 if (row.PlanQty == 0) { row.PlanRatio = "0%"; } else { row.PlanRatio = Math.Round((double)row.Qty * 100 / row.PlanQty, 2) + "%";//计划达成率 } //生产时间 int ProductTime = lineboardController.GetProductTime(row.OrderNo, TenantID) - lineboardController.GetLostTime(row.OrderNo, TenantID);//分钟 //稼动率 double Utilization = 0; if (ProductTime != 0) { Utilization = Math.Round((double)(ProductTime - row.StopTime) * 100 / (ProductTime), 2); } row.Utilization = Utilization + "%"; result.Add(row); } } catch (Exception ex) { throw ex; } return(result); }
public void PostCreateProductRequest(dynamic data) { var list = data.list; foreach (dynamic item in list) { string ContractCode = item["ContractCode"]; string CreateType = item["CreateType"]; var BoardOrBarData = new List <dynamic>(); switch (CreateType) { case "板材": BoardOrBarData = new PRS_BoardCreateMateService().GetDynamicList(ParamQuery.Instance().AndWhere("ContractCode", ContractCode)); break; case "棒材": BoardOrBarData = new PRS_BarCreateMateService().GetDynamicList(ParamQuery.Instance().AndWhere("ContractCode", ContractCode)); break; case "车间": int MainID = item["ID"]; BoardOrBarData = new MES_WorkshopPurchaseDetailService().GetDynamicList ( ParamQuery .Instance() .Select("InventoryCode,PurchaseQuantity as InventoryNum,Remark") .From("MES_WorkshopPurchaseDetail") .AndWhere("MainID", MainID) ); break; default: break; } using (var db = Db.Context("Mms")) { db.UseTransaction(true); try { int MainID = new APS_ProductPurchaseMainService().GetModelList().Count > 0 ? new APS_ProductPurchaseMainService().GetModelList().Max(a => a.ID) + 1 : 1; db.Insert("APS_ProductPurchaseMain") .Column("ID", MainID) .Column("PurchaseDocumentCode", MmsHelper.GetOrderNumber("APS_ProductPurchaseMain", "PurchaseDocumentCode", "SCQG", "", "")) .Column("ContractCode", ContractCode) .Column("DepartmentCode", "0202") .Column("PurchaseDate", DateTime.Now) .Column("IsEnable", 1) .Column("BillState", 1) .Column("PurchaseType", CreateType.Equals("板材") ? 2 : CreateType.Equals("棒材") ? 3 : CreateType.Equals("车间") ? 4 : 1) .Column("CreateTime", DateTime.Now) .Column("CreatePerson", MmsHelper.GetUserName()).Execute(); foreach (var item_board in BoardOrBarData) { double PurchaseQuantity = Convert.ToDouble(item_board.InventoryNum); string InventoryCode = item_board.New_InventoryCode; string Remark = item_board.Remark; string unit = ""; if (CreateType != "车间") { unit = item_board.Unit; } db.Insert("APS_ProductPurchaseDetail") .Column("MainID", MainID) //.Column("InventoryCode", InventoryCode) .Column("InventoryCode", InventoryCode) .Column("TotalRequestQuantity", Convert.ToInt32(PurchaseQuantity)) .Column("PurchaseQuantity", PurchaseQuantity) .Column("StockQuantity", 0) .Column("PurchaseState", 0) .Column("DepartmentCode", "0202") .Column("DepartmentName", "供应") .Column("IsEnable", 1) .Column("CreateTime", DateTime.Now) .Column("Remark", Remark) .Column("Unit", unit) .Column("CreatePerson", MmsHelper.GetUserName()).ExecuteReturnLastId <int>(); } db.Commit(); } catch (Exception ex) { db.Rollback(); break; } } } }
public List <PRS_Process_BOM_Blanking> GetIsSum2(string BomList = "") { var PRS_BarCreateMateList = new List <dynamic>(); List <PRS_Process_BOM_Blanking> barDataList = new PRS_Process_BOM_BlankingService().GetModelList(ParamQuery.Instance().AndWhere("ID", BomList, Cp.In)); return(barDataList); }
public int AuditBillCode(string mainID, out string msg) { msg = string.Empty; var rowsAffected = 0; string sql = String.Format(@" select * FROM MES_PurchaseOrderMain t1 left join MES_PurchaseOrderDetail t2 on t1.ID=t2.MainID where t1.ID='{0}'", mainID); //if sql.Contains var resList = db.Sql(sql).QueryMany <dynamic>(); if (resList[0].BillState == 2) { msg = "单据已审核"; return(0); } else if (resList.Count == 0) { msg = "请先保存数据再审核"; return(0); } else { int isFalse = 0; int res = 0; try { db.UseTransaction(true); sql = string.Format(@"update MES_PurchaseOrderMain set BillState=2 where BillCode='{0}'", resList[0].BillCode); rowsAffected = db.Sql(sql).Execute(); if (rowsAffected > 0) { msg = "采购订单审核成功"; sql = String.Format(@" select t2.ID as id from MES_PurchaseOrderMain t1 left join APS_ProductPurchaseMain t2 on t1.ProductPurchaseCode=t2.PurchaseDocumentCode where t1.ID='{0}'", mainID); string mID = db.Sql(sql).QuerySingle <string>(); sql = ""; foreach (var item in resList) { res++; sql = sql + string.Format(@" update APS_ProductPurchaseDetail set PurchaseState=2 where MainID='{0}' and InventoryCode='{1}' ", mID, item.InventoryCode); } rowsAffected = db.Sql(sql).Execute(); //遍历采购订单明细表,生成采购过程数据 foreach (var item in resList) { //item.MatchTableID MES_BN_MatchingTableDetail MatchingTable = new MES_BN_MatchingTableDetailService().GetModel(ParamQuery.Instance().AndWhere("IsEnable", 1).AndWhere("ID", item.MatchTableID)); MatchingTable = MatchingTable ?? new MES_BN_MatchingTableDetail(); string sqlMaterial = string.Format(@" SELECT MaterialCode from dbo.PRS_Process_BOM WHERE InventoryCode='{0}' AND IsEnable=1", item.InventoryCode); Mes_PurchaseProcess process = new Mes_PurchaseProcess(); process.ContractCode = item.ContractCode; //process.ProductID = MatchingTable.ID ?? 0; //process.ProductID = item.ProcessCode; process.UserCode = item.UserCode; if (MatchingTable.ProjectDetailID != null) { process.ProductID = MatchingTable.ProjectDetailID; } process.SaleMan = item.SaleMan; process.InventoryCode = item.InventoryCode; process.InventoryName = item.InventoryName; process.Model = item.Model; process.MaterialCode = db.Sql(sqlMaterial).QuerySingle <string>(); process.SupplierCode = item.SupplierCode; process.Quantity = item.OrderQuantity; process.PurchaseCode = item.BillCode; process.PrchaseDate = item.OrderDate; process.IsEnable = 1; process.PlanArrivelDate = item.PlanArrivelDate; process.CreatePerson = MmsHelper.GetUserName(); process.CreateTime = DateTime.Now; process.ModifyPerson = MmsHelper.GetUserName(); process.ModifyTime = DateTime.Now; var detailID = db.Insert <Mes_PurchaseProcess>("Mes_PurchaseProcess", process) .AutoMap(x => x.ID).ExecuteReturnLastId <int>(); } if (rowsAffected == res) { msg = "操作成功"; db.Commit(); return(1); } else { isFalse++; return(0); } //return rowsAffected; } else { msg = "采购订单审核失败"; db.Rollback(); return(0); } } catch (Exception ex) { msg = "采购订单审核失败"; db.Rollback(); return(0); } //sql = string.Format(@"update APS_ProductPurchaseMain set BillState=2 where PurchaseDocumentCode='{0}'", res.ProductPurchaseCode); } }
public List <dynamic> GetBomList(string BomList = "") { var PRS_BarCreateMateList = new List <dynamic>(); List <PRS_Process_BOM_Blanking> barDataList = new PRS_Process_BOM_BlankingService().GetModelList(ParamQuery.Instance().AndWhere("ID", BomList, Cp.In)); //.AndWhere(Cp.In("ID", BomList))) if (!string.IsNullOrWhiteSpace(BomList)) { #region 原SQL /* * select a.ContractCode,a.New_InventoryCode InventoryCode,b.InventoryName,b.Model,b.Spec as Specs,b.FigureCode,sum(a.SetMateNum) TotalNum,0 RealNum,sum(a.SetMateNum) NeedNum * from PRS_Process_BOM a * left join SYS_Part b on a.New_InventoryCode=b.InventoryCode * where a.MateType=2 and a.ID in({0}) AND ContractCode NOT IN (SELECT ContractCode FROM PRS_BarCreateMate WHERE a.IsEnable=1) * group by a.ContractCode,a.New_InventoryCode,b.InventoryName,b.Model,b.Spec,b.FigureCode */ #endregion var query = RequestWrapper.Instance().LoadSettingXmlString(@" <settings defaultOrderBy='temp.InventoryCode'> <select>*</select> <from>( SELECT a.ContractCode, a.New_InventoryCode InventoryCode, b.InventoryName, b.Model, b.Spec AS Specs, b.FigureCode, SUM(a.SetMateNum) TotalNum, 0 RealNum, SUM(a.SetMateNum) NeedNum FROM dbo.PRS_Process_BOM_Blanking a LEFT JOIN SYS_Part b ON a.New_InventoryCode = b.InventoryCode WHERE a.MateType IN (2,3) AND a.ID IN ( {0} ) AND NOT EXISTS ( SELECT 1 FROM PRS_BarCreateMate WHERE a.IsEnable = 1 AND ContractCode = a.ContractCode AND InventoryCode = a.New_InventoryCode ) GROUP BY a.ContractCode, a.New_InventoryCode, b.InventoryName, b.Model, b.Spec, b.FigureCode ) temp</from> </settings>", BomList); var service = new PRS_BarCreateMateService(); PRS_BarCreateMateList = service.GetDynamicList(query.ToParamQuery()).ToList <dynamic>(); } return(PRS_BarCreateMateList); }
public int AuditBillCode(string mainID, out string msg) { msg = string.Empty; var rowsAffected = 0; string sql = String.Format(@" select BillState FROM PRS_BlankingRecord where ID='{0}'", mainID); var state = db.Sql(sql).QuerySingle <int>(); if (state == 2) { msg = "单据已审核"; return(0); } else { try { using (db.UseTransaction(true)) { int isFalse = 0; sql = string.Format(@"update PRS_BlankingRecord set BillState=2 where ID='{0}'", mainID); rowsAffected = db.Sql(sql).Execute(); if (rowsAffected > 0) { msg = "生产请购单据审核成功"; var pQuery = ParamQuery.Instance().AndWhere("IsEnable", 1).AndWhere("MainID", mainID); List <PRS_BlankingResult> resList = new PRS_BlankingResultService().GetModelList(pQuery); foreach (var result in resList) { for (int i = 0; i < result.PartBlankingQuntity; i++) { pQuery = ParamQuery.Instance().AndWhere("IsEnable", 1).AndWhere("MainID", result.ID); List <PRS_BlankingPlateDetail> plateList = new PRS_BlankingPlateDetailService().GetModelList(pQuery); foreach (var plate in plateList) { int res = db.Insert("Mes_BlankingResult") .Column("BlankingResultID", plate.MainID) .Column("BlankingQuantity", 1) .Column("IsEnable", 1) .Column("Ispicking", 0) .Column("BiankingSize", plate.PlateSize) .Column("CreateTime", DateTime.Now) .Column("CreatePerson", MmsHelper.GetUserName()) .Column("ModifyTime", DateTime.Now) .Column("ModifyPerson", MmsHelper.GetUserName()).Execute(); if (res <= 0) { isFalse++; } } } } //return rowsAffected; } else { msg = "生产请购单据审核失败,请先保存数据后审核"; db.Rollback(); return(0); } if (isFalse > 0) { db.Rollback(); return(0); } else { db.Commit(); msg = "生产请购单据审核成功"; return(1); } } } catch { msg = "生产请购单据审核失败"; return(0); } } }
/// <summary> /// 获取当前车间各机台生产状态 /// </summary> /// <param name="WorkShopId"></param> /// <param name="TenantID"></param> /// <returns></returns> public dynamic GetLineStatus(string WorkShopId, string TenantID) { List <minimes_order_record> result = new List <minimes_order_record>(); try { List <dynamic> linelist = ApiDataSource.GetLineList(TenantID, WorkShopId, null, null, null).ToObject <List <dynamic> >(); result = new List <minimes_order_record>(); minimes_order_recordService reportService = new minimes_order_recordService(); List <minimes_order_record> reportList = reportService.GetModelList(ParamQuery.Instance().AndWhere("State", 1).AndWhere("TenantID", TenantID)); foreach (var item1 in linelist) { //屏蔽 if (item1.LineId != "2d6a9f23-c1dc-4a6d-baa7-473011e4954c" && item1.LineId != "d3bb37bd-0aff-4c6a-96a0-d544c136a018") { minimes_order_record row = new minimes_order_record(); row.LineId = item1.LineId + ""; //产线ID row.LineName = item1.LineName + ""; //产线名称 row.Color = "grey"; //状态颜色 row.StateName = "未切单"; //状态名称 result.Add(row); foreach (var item in reportList) { if (row.LineId == item.LineId) { row.Qty = item.Qty; row.PlanQty = item.PlanQty; row.ReserveQty = item.ReserveQty; minimes_resttimeService resttimeService = new minimes_resttimeService(); List <minimes_resttime> resttimeList = resttimeService.GetModelList(ParamQuery.Instance().AndWhere("WorkShopId", WorkShopId).AndWhere("TenantId", TenantID)); string IsRest = "0";//默认值 if (resttimeList.Count != 0) { foreach (var item_rest in resttimeList) { string Time = item_rest.RestTime; string[] TimeArr = Time.Split('-'); DateTime StartTime = Convert.ToDateTime(TimeArr[0]); DateTime EndTime = Convert.ToDateTime(TimeArr[1]); DateTime nowTime = Convert.ToDateTime(DateTime.Now.ToShortTimeString()); if ((nowTime >= StartTime && nowTime <= EndTime)) { IsRest = "1";//在休息时间区间 } } } if (row.PlanQty + row.ReserveQty <= row.Qty)//已完成 注;实际产量大于等于计划产量加备存数据 工单才完工 { row.StateName = "已完成"; row.Color = "green"; } else if (item.MachineState == 1) { row.StateName = "生产中"; row.Color = "blue"; } else if (item.MachineState == 0 && IsRest == "1") { row.StateName = "休息中"; row.Color = "orange"; } else { row.StateName = "停机中"; row.Color = "red"; } } } } } } catch (Exception ex) { throw ex; } return(result); }
public List <dynamic> GetDoPerson(string q) { var pQuery = ParamQuery.Instance().Select("top 10 DoPerson").Where(c => c.And("DoPerson", q).Symbol("StartWithPY")); return(masterService.GetDynamicList(pQuery)); }
protected override void OnAfterHandleExcel(ref DataTable dtSheet) { var service = new SYS_PartService(); var prsbomServices = new PRS_Process_BOMService(); foreach (DataRow item in dtSheet.Rows) { var PartCode = item["InventoryCode"].ToString(); List <PRS_Process_BOM> part = prsbomServices.GetModelList(ParamQuery.Instance().AndWhere("InventoryCode", PartCode).AndWhere("IsEnable", 1)); if (part.Count > 0) { item["PartCode"] = part[part.Count - 1].PartCode; item["PartName"] = part[part.Count - 1].PartName; item["Weight"] = part[part.Count - 1].Weight; var Query = ParamDelete.Instance().AndWhere("InventoryCode", PartCode); service.Delete(Query); } string dName = item["WarehouseCode"].ToString(); string sql = string.Format(@"select WarehouseName from SYS_BN_Warehouse where WarehouseCode='{0}'", dName); string hID = db.Sql(sql).QuerySingle <string>(); item["WarehouseName"] = hID; string isSelfMade = item["IsSelfMade"].ToString(); if (isSelfMade == "否") { item["IsSelfMade"] = 0; } else { item["IsSelfMade"] = 1; } string isSupplyMade = item["IsSupplyMade"].ToString(); if (isSupplyMade == "否") { item["IsSupplyMade"] = 0; } else { item["IsSupplyMade"] = 1; } string isCastforgeMatch = item["IsCastforgeMatch"].ToString(); if (isCastforgeMatch == "否") { item["IsCastforgeMatch"] = 0; } else { item["IsCastforgeMatch"] = 1; } string isOutsouceWeiding = item["IsOutsouceWeiding"].ToString(); if (isOutsouceWeiding == "否") { item["IsOutsouceWeiding"] = 0; } else { item["IsOutsouceWeiding"] = 1; } string isElectroHydraulicMatch = item["IsElectroHydraulicMatch"].ToString(); if (isElectroHydraulicMatch == "否") { item["IsElectroHydraulicMatch"] = 0; } else { item["IsElectroHydraulicMatch"] = 1; } string isMarketMatch = item["IsMarketMatch"].ToString(); if (isMarketMatch == "否") { item["IsMarketMatch"] = 0; } else { item["IsMarketMatch"] = 1; } string isEnable = item["IsEnable"].ToString(); if (isEnable == "否") { item["IsEnable"] = 0; } else { item["IsEnable"] = 1; } //dName = item["PartTypeCode"].ToString(); //sql = string.Format(@"select PartTypeCode from SYS_PartType where TypeName='{0}'", dName); //hID = db.Sql(sql).QuerySingle<string>(); //item["PartTypeCode"] = hID; } base.OnAfterHandleExcel(ref dtSheet); }