氚云--生产报工2

(1)产品进行工艺路线设置。(2)进行生成派工开工修改工序中心中间表第一道工序开工状态

子表自动进行顺序累加

需求:在工艺新增工艺路线时,需要自动进行加工顺序的排序

 详情代码

  OnLoad:function(){
        debugger;
        var parent = this;
        this.D000685F044da22ee9b54a669386935b72c2b7a0.BindChange( "Set", function( data ) {
            debugger;
            //var i = 1;

            debugger;
            var responseData = data[ 0 ]; // 当前行
            var rowsCount = parent.D000685F044da22ee9b54a669386935b72c2b7a0.GetRowsCount();//获取子表总行数 
            var currentRowId = responseData.ObjectId;   //获取行ID 
            parent.D000685F044da22ee9b54a669386935b72c2b7a0.UpdateRow( currentRowId, {
                "D000685F044da22ee9b54a669386935b72c2b7a0.seqence": rowsCount
            });
            

        });

    
    }

生产报工选中开工,进行改变状态及修改工序中心第一道工序数据状况。

将第一道工序状态改为进行中,有上道工序数,才能进行报工,下料的范围在(90%~110%*计划数量),所以将下料的最大值作为第一道工序的上道工序报工数

  protected override void OnSubmit(string actionName, H3.SmartForm.ListViewPostValue postValue, H3.SmartForm.SubmitListViewResponse response)
    {
      
        if(actionName == "kaigong")
        {
            string requestId = this.Request["ObjectIds"] + string.Empty;
            string[] objectids1 = GetObjectIds(requestId);
            for(int i = 0;i < objectids1.Length; i++)
            {
                string obj1 = objectids1[i];
                if(obj1 != "")
                {
                    H3.DataModel.BizObject objin = H3.DataModel.BizObject.Load(H3.Organization.User.SystemUserId, this.Request.Engine, "D00068566c3a33d6987424e9a0d142b1bef2bae", obj1, false);
                    objin["wostatus"] = "进行中";
                    objin["actstartdate"] = DateTime.Now;
                    objin.Update();
                    //主表
                    string sql = "SELECT * FROM i_D00068566c3a33d6987424e9a0d142b1bef2bae where ObjectId='" + obj1 + "'";
                    System.Data.DataTable dtin = this.Engine.Query.QueryTable(sql, null);
                    //查询子表
                    H3.IEngine engine = this.Engine;
                    //表单编码
                    string masterSchemaCode = "D00068566c3a33d6987424e9a0d142b1bef2bae";
                    //表单数据Id
                    string masterBoId = obj1;
                    //子表控件编码
                    string childSchemaCode = "D000685F99add1cdbf3747eeade0bd6eb2ca7216";
                    //Load出要修改数据的主表业务对象
                    H3.DataModel.BizObject masterBo = H3.DataModel.BizObject.Load(H3.Organization.User.SystemUserId, engine, masterSchemaCode, masterBoId, false);
                    //获取子表结构体对象
                    H3.DataModel.BizObjectSchema childSchema = masterBo.Schema.GetChildSchema(childSchemaCode);
                    //定义新的子表数据集合
                    List < H3.DataModel.BizObject > newChildBoList = new List<H3.DataModel.BizObject>();
                    //获取子表内已有数据
                    H3.DataModel.BizObject[] childBoArray = (H3.DataModel.BizObject[]) masterBo[childSchemaCode];
                    if(childBoArray != null && childBoArray.Length > 0)
                    {
                        //第一道
                        for(int c = 0;c < 1; c++) {
                            string schemaCode = "D000685F99add1cdbf3747eeade0bd6eb2ca7216";//子表控件编码
                            string detail = childBoArray[c]["ObjectId"] + string.Empty;//子表ObjectId
                            string gxumc = childBoArray[c]["workcenter"] + string.Empty;//工序
                         
                            if(gxumc == "下料")
                            {
                                H3.DataModel.BizObject   accountBo = H3.DataModel.BizObject.Load(this.Request.UserContext.UserId, this.Request.Engine, schemaCode, detail, false); //Load对象
                                accountBo["F0000009"] = dtin.Rows[0]["woqty"] + string.Empty;  //计划数量==子表的上道工序数
                                accountBo["gxstatus"] = "进行中";//工序状态
                                accountBo.Status = H3.DataModel.BizObjectStatus.Effective; // 将对象状态设为生效
                                accountBo.Update();  //更新对象

                                H3.DataModel.BizObject objingx = H3.DataModel.BizObject.Load(H3.Organization.User.SystemUserId, this.Request.Engine, "D001728bf71c5566608411794824fd32f34a7a3", detail, false);
                                objingx["F0000019"] = "进行中";
                                objingx["F0000008"] = double.Parse(dtin.Rows[0]["F0000023"] + string.Empty); //上道工序数=下料最大范围(下料范围90%到110%)
                                objingx["F0000022"] = double.Parse(dtin.Rows[0]["F0000022"] + string.Empty);//下料90%
                                objingx["F0000023"] = double.Parse(dtin.Rows[0]["F0000023"] + string.Empty);//下料110%
                                objingx.Update();
                            }
                            else
                            {
                                H3.DataModel.BizObject   accountBo = H3.DataModel.BizObject.Load(this.Request.UserContext.UserId, this.Request.Engine, schemaCode, detail, false); //Load对象
                                accountBo["F0000009"] = dtin.Rows[0]["woqty"] + string.Empty;  //修改对象属性值
                                accountBo["gxstatus"] = "进行中";
                                accountBo.Status = H3.DataModel.BizObjectStatus.Effective; // 将对象状态设为生效
                                accountBo.Update();  //更新对象

                                H3.DataModel.BizObject objingx = H3.DataModel.BizObject.Load(H3.Organization.User.SystemUserId, this.Request.Engine, "D001728bf71c5566608411794824fd32f34a7a3", detail, false);
                                objingx["F0000019"] = "进行中";
                                objingx["F0000008"] = dtin.Rows[0]["woqty"] + string.Empty;

                                objingx.Update();
                            }


                        }

                    }

                }
            }
        }
      
      
        base.OnSubmit(actionName, postValue, response);
    }
    public string[] GetObjectIds(string objectIds)
    {
        if(objectIds != string.Empty && objectIds.Length > 10) 
        {
            objectIds = objectIds.Substring(1, objectIds.Length - 2);
            string[] arrayObjectIds = objectIds.Split(',');
            System.Collections.Generic.List < string > listObjectIds = new System.Collections.Generic.List<string>();
            foreach(string s in arrayObjectIds)
            {
                listObjectIds.Add(s.Substring(1, s.Length - 2));
            }

            return listObjectIds.ToArray();
        }

        return null;
    }

 

posted @ 2023-06-08 10:26  山君与见山  阅读(69)  评论(0编辑  收藏  举报