Ejemplo n.º 1
0
        public dynamic PostProjectDetailOnSave(List <PMS_BN_ProjectDetail> model)
        {
            int result = 0;

            if (model.Count > 0)
            {
                if (model[0].ID <= 0)
                {
                    model[0].CreateTime   = DateTime.Now;
                    model[0].ModifyTime   = model[0].CreateTime;
                    model[0].CreatePerson = MmsHelper.GetUserCode();
                    model[0].ModifyPerson = model[0].CreatePerson;
                    result = new PMS_BN_ProjectDetailService().Insert(model[0]);
                }
                else
                {
                    result = new PMS_BN_ProjectDetailService().Update(model[0]);
                }
            }

            return(new
            {
                result = result
            });
        }
Ejemplo n.º 2
0
        public string PostStorage(dynamic data)
        {
            string msg      = "";
            string BillCode = data["BillCode"];
            var    result   = new QMS_ProcessInspectionItemService().AuditBillCode(data["BillCode"].ToString(), out msg);
            //生成物料条码:自制件
            var QMS_ProcessInspectionModel = new QMS_ProcessInspectionService().GetModel(ParamQuery.Instance().AndWhere("BillCode", BillCode));

            if (QMS_ProcessInspectionModel != null)
            {
                string InnerFactoryBatch = QMS_ProcessInspectionModel.BatchCode;         //厂内批次
                string OuterFactoryBatch = QMS_ProcessInspectionModel.OuterFactoryBatch; //厂外批次

                string PartCode       = QMS_ProcessInspectionModel.PartCode;
                string PartName       = QMS_ProcessInspectionModel.PartName;
                string PartFigureCode = QMS_ProcessInspectionModel.partFigure;

                string ContractCode = QMS_ProcessInspectionModel.ContractCode;
                string ProductName  = QMS_ProcessInspectionModel.ProductName;
                int    ProductID    = new PMS_BN_ProjectDetailService().GetModel(ParamQuery.Instance().AndWhere("ProductName", ProductName)).ID;

                var ProcessBomModel = new PRS_Process_BOMService().GetModel(ParamQuery.Instance().AndWhere("PartCode", PartCode));
                if (ProcessBomModel != null)
                {
                    string InventoryCode = ProcessBomModel.InventoryCode; //存货编码
                    string InventoryName = ProcessBomModel.InventoryName; //存货名称

                    var SYS_MaterialBatchModel = new SYS_MaterialBatchService().GetModel(ParamQuery.Instance()
                                                                                         .AndWhere("PartCode", PartCode)
                                                                                         .AndWhere("InnerFactoryBatch", InnerFactoryBatch)
                                                                                         .AndWhere("OuterFactoryBatch", OuterFactoryBatch));

                    if (SYS_MaterialBatchModel == null)
                    {
                        var    model       = new SYS_MaterialBatchService();
                        string MateBarCode = model.CreateMateBarCode(700000000000);
                        model.Insert(ParamInsert.Instance()
                                     .Insert("SYS_MaterialBatch")
                                     .Column("MateBarCode", MateBarCode)
                                     .Column("InventoryCode", InventoryCode)
                                     .Column("InventoryName", InventoryName)
                                     .Column("PartCode", PartCode)
                                     .Column("PartFigureCode", PartFigureCode)
                                     .Column("PartName", PartName)
                                     .Column("InnerFactoryBatch", InnerFactoryBatch)
                                     .Column("OuterFactoryBatch", OuterFactoryBatch)
                                     .Column("ContractCode", ContractCode)
                                     .Column("ProductID", ProductID));
                    }
                }
            }
            return(msg);
        }
        public dynamic GetProductTreeList([FromUri] TreeNodeModel model)
        {
            var PMS_BN_ProjectDetailList     = new PMS_BN_ProjectDetailService().GetModelList();
            var PRS_Process_BOMList          = new PRS_Process_BOMService().GetModelList();
            var APS_ProjectProduceDetialList = new APS_ProjectProduceDetialService().GetModelList();

            var list = TreeNodeManage.GetTreeNodeList <dynamic>(
                TreeNodeManage.Instance()
                .SetNode(model.NodeField)
                .SetParentNode(model.ParentNodeField, model.ParentNodeValue)
                .SetTableName(model.TableName)
                .SetNodeLevel(model.IsLevel)
                .SetTreeSetting(model.TreeSetting)
                .SetWhereSql(model.WhereSql));

            var new_list = new List <dynamic>();

            list.ForEach(item =>
            {
                dynamic item_old = item;

                string ContractCode = item_old.ContractCode;
                int ProductID       = item_old.ProductID;
                string PartCode     = item_old.PartCode;
                var Quantity        = PMS_BN_ProjectDetailList.Where(a => a.ID == ProductID).FirstOrDefault().Quantity ?? 0;                                                                   //合同台数
                var PartQuantity    = PRS_Process_BOMList.Where(a => a.PartCode == PartCode && a.ContractCode == ContractCode && a.ProductID == ProductID).FirstOrDefault().PartQuantity ?? 0; //单台数量
                int ProductTotal    = Quantity * PartQuantity;                                                                                                                                 //生产总数=合同台数*单台数量
                //已生产数量
                //var ProcuctList = APS_ProjectProduceDetialList
                //.Where(a => a.ContractCode == ContractCode && a.ProjectDetailID == ProductID && a.PartCode == PartCode)
                //.GroupBy(a => new { a.ProcessModelType, a.MonthPlanCode })
                //.Select(a => new { ProcessType = a.Key.ProcessModelType, a.Key.MonthPlanCode, Quantity = a.Max(b => b.Quantity) });
                var ProcuctList = APS_ProjectProduceDetialList
                                  .Where(a => a.ContractCode == ContractCode && a.ProjectDetailID == ProductID && a.PartCode == PartCode)
                                  .GroupBy(a => new { a.ProcessModelType, a.ProcessCode })
                                  .Select(a => new { ProcessType = a.Key.ProcessModelType, ProcessCode = a.Key.ProcessCode, Quantity = a.Sum(b => b.Quantity) });

                int BlankingTotal   = ProcuctList.Where(a => a.ProcessType == "1").FirstOrDefault() == null ? 0 : ProcuctList.Where(a => a.ProcessType == "1").FirstOrDefault().Quantity ?? 0;
                int WeldingTotal    = ProcuctList.Where(a => a.ProcessType == "2").FirstOrDefault() == null ? 0 : ProcuctList.Where(a => a.ProcessType == "2").FirstOrDefault().Quantity ?? 0;
                int MachiningTotal  = ProcuctList.Where(a => a.ProcessType == "3").FirstOrDefault() == null ? 0 : ProcuctList.Where(a => a.ProcessType == "3").FirstOrDefault().Quantity ?? 0;
                int AssemblingTotal = ProcuctList.Where(a => a.ProcessType == "4").FirstOrDefault() == null ? 0 : ProcuctList.Where(a => a.ProcessType == "4").FirstOrDefault().Quantity ?? 0;

                item_old.BlankingTotal   = BlankingTotal.ToString() + "/" + ProductTotal.ToString();
                item_old.WeldingTotal    = WeldingTotal.ToString() + "/" + ProductTotal.ToString();
                item_old.MachiningTotal  = MachiningTotal.ToString() + "/" + ProductTotal.ToString();
                item_old.AssemblingTotal = AssemblingTotal.ToString() + "/" + ProductTotal.ToString();

                new_list.Add(item_old);
            });
            return(new_list);
        }
        public void Edit(dynamic data)
        {
            var tabsWrapper = new List <RequestWrapper>();

            tabsWrapper.Add(RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>PMS_BN_ProjectDetail</table>
    <where>
        <field name='ID' cp='equal'></field>      
    </where>
</settings>"));
            var service = new PMS_BN_ProjectDetailService();
            var result  = service.EditPage(data, null, tabsWrapper);
        }
        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 GetNewRowId(string type, string key, int qty = 1)
        {
            var service0 = new PMS_BN_ProjectDetailService();

            return(service0.GetNewKey("ID", "maxplus", qty, ParamQuery.Instance().AndWhere("ID", key, Cp.Equal)));
        }