氚云--生产报工3

报工部分:修改生产报工子表的工序记录情况,修改工序中心的数据情况,带当前报工数据、修改工序状态,及修改下一工序的上道工序报工数与下一工序开工状态。
主要是进行第一道工序的判断和最后一道工序的判断



protected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartFormResponse response) { if(actionName == "Remove") { H3.IEngine engine = this.Engine; string masterBoId = this.Request.BizObject["woId"] + string.Empty; //查找两个表的 string ziid = this.Request.BizObject["rtId"] + string.Empty; string sqlzib = "SELECT * FROM i_D000685F99add1cdbf3747eeade0bd6eb2ca7216 where ObjectId='" + ziid + "'"; System.Data.DataTable dtzib = this.Engine.Query.QueryTable(sqlzib, null); string sqlzib4 = "SELECT * FROM i_D00068566c3a33d6987424e9a0d142b1bef2bae where ObjectId='" + masterBoId + "'"; System.Data.DataTable dtzib4 = this.Engine.Query.QueryTable(sqlzib4, null); //当前工序的工序是否完成:报工是否等于派工,更改下道工序为进行中 //改变下一道工序报工数 string zinameshunxu = ""; if(dtzib.Rows.Count > 0) { zinameshunxu = dtzib.Rows[0]["Name"] + string.Empty;//这是工单的名称 } string masterSchemaCode = "D00068566c3a33d6987424e9a0d142b1bef2bae"; H3.DataModel.BulkCommit commit0 = new H3.DataModel.BulkCommit(); // H3.DataModel.BizObject objin2 = new H3.DataModel.BizObject(this.Engine, schemawe, H3.Organization.User.SystemUserId); H3.DataModel.BizObject objin2 = H3.DataModel.BizObject.Load(H3.Organization.User.SystemUserId, engine, masterSchemaCode, masterBoId, false); string childSchemaCode = "D000685F99add1cdbf3747eeade0bd6eb2ca7216"; H3.DataModel.BizObjectSchema childSchema = objin2.Schema.GetChildSchema(childSchemaCode); List < H3.DataModel.BizObject > newChildBoList = new List<H3.DataModel.BizObject>(); //获取子表内已有数据 H3.DataModel.BizObject[] childBoArray = (H3.DataModel.BizObject[]) objin2[childSchemaCode]; if(childBoArray != null && childBoArray.Length > 0) { string gdjs = "on"; int gxcd = childBoArray.Length; int zinameshunxuzi = int.Parse(zinameshunxu);//工单序号查询出的 int baogong = int.Parse(this.Request.BizObject["bcqty"] + string.Empty);//报工 // int blip = int.Parse(this.Request.BizObject["ngqty"] + string.Empty); // int bfei = int.Parse(this.Request.BizObject["bfqty"] + string.Empty); string sdgxzt = "";//上道工序状态 //获取第一道工序的报工数量,及状态 int onebg = 0; string onezt = ""; int one = 1;//是否为第一次 int cishu = 0; int cishut = 0; int zuihou = 0; foreach(H3.DataModel.BizObject itemBo in childBoArray) { //for(int i=0;i<childBoArray.Length;i++) { } int zinamejia = zinameshunxuzi + 1; int zinamej = int.Parse(itemBo["Name"].ToString());//工序名称默认为子表顺序1,2,3.... // string sdgxzt = "";//上道工序状态 if(zinameshunxuzi != 1) { int sdgx = zinameshunxuzi - 1;//上道工序 if(sdgx == zinamej) { sdgxzt = itemBo["gxstatus"] + string.Empty;//工序状态 } } // //获取第一道工序的报工数量,及状态 if(zinamej == one) { if(cishu < 1) { if(itemBo["ybgqty"] + string.Empty != "") { onebg = int.Parse(itemBo["ybgqty"].ToString());//第一道工序报工数 } onezt = itemBo["gxstatus"] + string.Empty;//第一道工序状态 cishu++; } } //当前工序第一道工序 if(zinameshunxuzi == one) { if(cishut < 1) {
                //第一道工序不是下料
if(this.Request.BizObject["seqence"] + string.Empty != "下料") { //itemBo["ybgqty"] = this.Request.BizObject["bcqty"] + string.Empty; //获取所有报工内容,判断是否等于派工。等于结束,不等于,继续进行 int zong = 0; int gonhda = 0;//工单数量 if(this.Request.BizObject["woqty"] + string.Empty != "") { gonhda = int.Parse(this.Request.BizObject["woqty"] + string.Empty); itemBo["F0000009"] = gonhda;//上道工序报工数==计划数 } int yiyou = 0;//已报工 if(this.Request.BizObject["F0000021"] + string.Empty != "") { yiyou = int.Parse(this.Request.BizObject["F0000021"] + string.Empty); }
                    //已有的报工数-当前报工数,判断相减后的总数是否等于计划数,相等就结束工序状态 zong
= /*gonhda +*/ yiyou - baogong; if(gonhda == zong) { itemBo["gxstatus"] = "已结束"; } else { itemBo["gxstatus"] = "进行中"; } cishut++; } else {
                  //第一道工序是下料
int zong = 0; int gonhda = 0;//工单数量0.9 if(this.Request.BizObject["F0000034"] + string.Empty != "") { gonhda = int.Parse(this.Request.BizObject["F0000034"] + string.Empty); //itemBo["F0000009"] = gonhda; } int gonhdabai = 0;//工单数量1.1 if(this.Request.BizObject["F0000035"] + string.Empty != "") { gonhdabai = int.Parse(this.Request.BizObject["F0000035"] + string.Empty); itemBo["F0000009"] = gonhdabai; } int yiyou = 0;//已报工 if(this.Request.BizObject["F0000021"] + string.Empty != "") { yiyou = int.Parse(this.Request.BizObject["F0000021"] + string.Empty); }
                   //拿取下料的90%~110%的范围数目,获取已有报工数-当前报工数,进行范围判断是否在90%到110%之间,在结束工序状态 zong
= /*gonhda +*/ yiyou - baogong; if(gonhda < zong && gonhdabai > zong) { itemBo["gxstatus"] = "已结束"; } else { itemBo["gxstatus"] = "进行中"; } cishut++; } } }//最后一道 gxcd=工序总数,判断当前数目是否等于工序总数 else if(zinameshunxuzi == gxcd) { if(zinamej == gxcd) { if(zuihou < 1) { int yiyou = 0;//已报工 if(this.Request.BizObject["F0000021"] + string.Empty != "") { yiyou = int.Parse(this.Request.BizObject["F0000021"] + string.Empty); }
                    //判断现有的报工数是否等于第一道工序的报工数且第一道工序状态是否为结束
int souyou = yiyou - baogong; if(souyou == onebg && onezt == "已结束") { itemBo["gxstatus"] = "已结束"; gdjs = "off"; } else { itemBo["gxstatus"] = "进行中"; } zuihou++; }
                 //计算完工率与完工数目
if(dtzib4.Rows.Count > 0) { int wang = 0; int hg = 0; int huiy = 0; int cip = 0; int xlpw = 0; if(dtzib4.Rows[0]["F0000018"] + string.Empty != "") { wang = int.Parse(dtzib4.Rows[0]["F0000018"] + string.Empty); } if(this.Request.BizObject["F0000016"] + string.Empty != "") { hg = int.Parse(this.Request.BizObject["F0000016"] + string.Empty); } if(this.Request.BizObject["F0000013"] + string.Empty != "") { huiy = int.Parse(this.Request.BizObject["F0000013"] + string.Empty); } if(this.Request.BizObject["ngqty"] + string.Empty != "") { cip = int.Parse(this.Request.BizObject["ngqty"] + string.Empty); } if(this.Request.BizObject["F0000027"] + string.Empty != "") { xlpw = int.Parse(this.Request.BizObject["F0000027"] + string.Empty); } objin2["F0000018"] = wang - hg - huiy - cip - xlpw; double zonghe = wang - hg - huiy - cip - xlpw; int woqty = 0; if(this.Request.BizObject["woqty"] + string.Empty != "") { woqty = int.Parse(this.Request.BizObject["woqty"] + string.Empty); } double wgl = zonghe / woqty; objin2["F0000019"] = wgl; } } } //中间其他工序 else if(zinameshunxuzi == zinamej && zinameshunxuzi != 1 && zinameshunxuzi != gxcd) { int bao = 0;//上道工序数 if(itemBo["F0000009"] + string.Empty != "") { bao = int.Parse(itemBo["F0000009"] + string.Empty);//本来有的上道工序报工 } int yiyou = 0; if(this.Request.BizObject["F0000021"] + string.Empty != "") { yiyou = int.Parse(this.Request.BizObject["F0000021"] + string.Empty); }
              //减去下道工序的上道工序报工数
int souyou = yiyou - baogong; if(souyou < bao)//小于进行中 { itemBo["gxstatus"] = "进行中"; } else { //获取上道工序的状态 string zt = sdgxzt; if(zt == "已结束") { itemBo["gxstatus"] = "已结束"; } } } else { } //第一道工序与派工进行对比,下面的工序与,上到工序的报工数进行对比 //中间工序改变状态, 下一道工序,改变下一道工序的上一道工序报工数,及状态 if(zinamej == zinamejia) { int bao = 0; if(itemBo["F0000009"] + string.Empty != "") { bao = int.Parse(itemBo["F0000009"] + string.Empty);//本来有的上道工序报工 } // int shangbao = 0; // if(this.Request.BizObject["shangyouliangpin"] + string.Empty != "" ) // { // shangbao = int.Parse(this.Request.BizObject["shangyouliangpin"] + string.Empty); // } itemBo["F0000009"] =bao - baogong;//上到工序报工数 itemBo["gxstatus"] = "进行中"; } //将子表内已有数据循环添加到新的子表数据集合里 newChildBoList.Add(itemBo); } if(gdjs == "off") { objin2["wostatus"] = "结束"; } } //创建 objin2[childSchemaCode] = newChildBoList.ToArray(); objin2.Update(commit0); // objin2.Status = H3.DataModel.BizObjectStatus.Effective; string errorMsg = null; commit0.Commit(this.Engine.BizObjectManager, out errorMsg); //上面都是更改工单派工的工艺路线 //更改工序中心的工艺及查询下一条工序的情况 //下道工序的上道工序数,在上面的工单派工中会一起变更 int baogongshu = int.Parse(this.Request.BizObject["F0000026"] + string.Empty);//总报工 int baogong2 = int.Parse(this.Request.BizObject["bcqty"] + string.Empty);//报工 int jianqubaogong = baogongshu - baogong2; //查询对应工序 string ziid2 = this.Request.BizObject["rtId"] + string.Empty;//工序 string gongdan = this.Request.BizObject["woId"] + string.Empty;//工单 string sqlzib2 = "SELECT * FROM i_D001728bf71c5566608411794824fd32f34a7a3 where ObjectId='" + ziid2 + "'";//查询工序 System.Data.DataTable dtzib2 = this.Engine.Query.QueryTable(sqlzib2, null);//查询工序 //查询工单 string strgongdan = "SELECT * FROM i_D001728bf71c5566608411794824fd32f34a7a3 where F0000020='" + gongdan + "'"; System.Data.DataTable dtgdgls = this.Engine.Query.QueryTable(strgongdan, null); int gongxuzongshu = 0; // string gdjsz = "";//状态 H3.DataModel.BulkCommit commitT = new H3.DataModel.BulkCommit(); if(dtgdgls.Rows.Count > 0) { gongxuzongshu = dtgdgls.Rows.Count;//工序总数 } if(dtzib2.Rows.Count > 0) { string gongxu = dtzib2.Rows[0]["F0000001"] + string.Empty;//工序 int gongxus = int.Parse(gongxu); H3.DataModel.BizObject objingx = H3.DataModel.BizObject.Load(H3.Organization.User.SystemUserId, this.Engine, "D001728bf71c5566608411794824fd32f34a7a3", ziid2, false);//加载工序中心表 if(gongxu == "1") { if(this.Request.BizObject["seqence"] + string.Empty != "下料") { //获取所有报工内容,判断是否等于派工。等于结束,不等于,继续进行 int gonhda = 0;//派工 if(this.Request.BizObject["woqty"] + string.Empty != "") { gonhda = int.Parse(this.Request.BizObject["woqty"] + string.Empty); objingx["F0000008"] = gonhda; } if(jianqubaogong == gonhda) { objingx["F0000019"] = "已结束"; } else { objingx["F0000019"] = "进行中"; } objingx.Update(commitT); string errorMsg2 = null; commitT.Commit(this.Engine.BizObjectManager, out errorMsg2); } else { int gonhda = 0;//工单数量0.9 if(this.Request.BizObject["F0000034"] + string.Empty != "") { gonhda = int.Parse(this.Request.BizObject["F0000034"] + string.Empty); //objingx["F0000009"] = gonhda; } int gonhdabai = 0;//工单数量1.1 if(this.Request.BizObject["F0000035"] + string.Empty != "") { gonhdabai = int.Parse(this.Request.BizObject["F0000035"] + string.Empty); objingx["F0000008"] = gonhdabai; } // int gonhdaw = 0;//派工 // if(this.Request.BizObject["woqty"] + string.Empty != "") // { // gonhdaw = int.Parse(this.Request.BizObject["woqty"] + string.Empty); // objingx["F0000008"] = gonhdaw; // } //比较大小 if(jianqubaogong > gonhda && jianqubaogong < gonhdabai) { objingx["F0000019"] = "已结束"; } else { objingx["F0000019"] = "进行中"; } objingx.Update(commitT); string errorMsg2 = null; commitT.Commit(this.Engine.BizObjectManager, out errorMsg2); } } else if(gongxus == gongxuzongshu) { //查询第一道 string strdiyidao = "SELECT * FROM i_D001728bf71c5566608411794824fd32f34a7a3 where F0000020='" + gongdan + "'" + "and F0000001=1"; System.Data.DataTable dtdiyidao = this.Engine.Query.QueryTable(strdiyidao, null);//查询工序 int onebg = 0; string onezt = ""; if(dtdiyidao.Rows.Count > 0) { if(dtdiyidao.Rows[0]["F0000009"] + string.Empty != "") { onebg = int.Parse(dtdiyidao.Rows[0]["F0000009"] + string.Empty); } onezt = dtdiyidao.Rows[0]["F0000019"] + string.Empty; } int souyou = jianqubaogong; if(souyou == onebg && onezt == "已结束") { objingx["F0000019"] = "已结束"; // gdjsz = "off"; } else { objingx["F0000019"] = "进行中"; } objingx.Update(commitT); string errorMsg2 = null; commitT.Commit(this.Engine.BizObjectManager, out errorMsg2); } else { int shangdaoxu = gongxus - 1; string sxsdgxzt = ""; //获取上道工序状态 string sdgxzthq = "SELECT * FROM i_D001728bf71c5566608411794824fd32f34a7a3 where F0000020='" + gongdan + "'" + "and F0000001=" + shangdaoxu; System.Data.DataTable shangdaogongxuzt = this.Engine.Query.QueryTable(sdgxzthq, null); if(shangdaogongxuzt.Rows.Count > 0) { sxsdgxzt = shangdaogongxuzt.Rows[0]["F0000019"] + string.Empty;//状态 } int bao = 0;//上道工序数 if(dtzib2.Rows[0]["F0000008"] + string.Empty != "") { bao = int.Parse(dtzib2.Rows[0]["F0000008"] + string.Empty);//本来有的上道工序报工 } int souyou = jianqubaogong; if(souyou < bao)//小于进行中 { objingx["F0000019"] = "进行中"; } else { //获取上道工序的状态 string zt = sxsdgxzt; if(zt == "已结束") { objingx["F0000019"] = "已结束"; } } objingx.Update(commitT); string errorMsg2 = null; commitT.Commit(this.Engine.BizObjectManager, out errorMsg2); } } } base.OnSubmit(actionName, postValue, response); }
  //流程完成走,执行下面的代码,与上面的Remove,不同点只是修改工序报工数将减改为加
protected override void OnWorkflowInstanceStateChanged(H3.Workflow.Instance.WorkflowInstanceState oldState, H3.Workflow.Instance.WorkflowInstanceState newState) { if(oldState == H3.Workflow.Instance.WorkflowInstanceState.Running && newState == H3.Workflow.Instance.WorkflowInstanceState.Finished) { H3.IEngine engine = this.Engine; string masterBoId = this.Request.BizObject["woId"] + string.Empty; //查找两个表的 string ziid = this.Request.BizObject["rtId"] + string.Empty; string sqlzib = "SELECT * FROM i_D000685F99add1cdbf3747eeade0bd6eb2ca7216 where ObjectId='" + ziid + "'"; System.Data.DataTable dtzib = this.Engine.Query.QueryTable(sqlzib, null); string sqlzib4 = "SELECT * FROM i_D00068566c3a33d6987424e9a0d142b1bef2bae where ObjectId='" + masterBoId + "'"; System.Data.DataTable dtzib4 = this.Engine.Query.QueryTable(sqlzib4, null); //当前工序的工序是否完成:报工是否等于派工,更改下道工序为进行中 //改变下一道工序报工数 string zinameshunxu = ""; if(dtzib.Rows.Count > 0) { zinameshunxu = dtzib.Rows[0]["Name"] + string.Empty;//这是工单的名称 } string masterSchemaCode = "D00068566c3a33d6987424e9a0d142b1bef2bae"; H3.DataModel.BulkCommit commit0 = new H3.DataModel.BulkCommit(); // H3.DataModel.BizObject objin2 = new H3.DataModel.BizObject(this.Engine, schemawe, H3.Organization.User.SystemUserId); H3.DataModel.BizObject objin2 = H3.DataModel.BizObject.Load(H3.Organization.User.SystemUserId, engine, masterSchemaCode, masterBoId, false); string childSchemaCode = "D000685F99add1cdbf3747eeade0bd6eb2ca7216"; H3.DataModel.BizObjectSchema childSchema = objin2.Schema.GetChildSchema(childSchemaCode); List < H3.DataModel.BizObject > newChildBoList = new List<H3.DataModel.BizObject>(); //获取子表内已有数据 H3.DataModel.BizObject[] childBoArray = (H3.DataModel.BizObject[]) objin2[childSchemaCode]; if(childBoArray != null && childBoArray.Length > 0) { string gdjs = "on"; int gxcd = childBoArray.Length; int zinameshunxuzi = int.Parse(zinameshunxu);//工单序号查询出的 int baogong = int.Parse(this.Request.BizObject["bcqty"] + string.Empty);//报工 // int blip = int.Parse(this.Request.BizObject["ngqty"] + string.Empty); // int bfei = int.Parse(this.Request.BizObject["bfqty"] + string.Empty); string sdgxzt = "";//上道工序状态 //获取第一道工序的报工数量,及状态 int onebg = 0; string onezt = ""; int one = 1;//是否为第一次 int cishu = 0; int cishut = 0; int zuihou = 0; foreach(H3.DataModel.BizObject itemBo in childBoArray) { //for(int i=0;i<childBoArray.Length;i++) { } int zinamejia = zinameshunxuzi + 1; int zinamej = int.Parse(itemBo["Name"].ToString()); // string sdgxzt = "";//上道工序状态 if(zinameshunxuzi != 1) { int sdgx = zinameshunxuzi - 1;//上道工序 if(sdgx == zinamej) { sdgxzt = itemBo["gxstatus"] + string.Empty; } } // //获取第一道工序的报工数量,及状态 // int onebg = 0; // string onezt = ""; if(zinamej == one) { if(cishu < 1) { if(itemBo["ybgqty"] + string.Empty != "") { onebg = int.Parse(itemBo["ybgqty"].ToString()); } onezt = itemBo["gxstatus"] + string.Empty; cishu++; } } //当前工序第一道工序 if(zinameshunxuzi == one) { if(cishut < 1) { if(this.Request.BizObject["seqence"] + string.Empty != "下料") { //itemBo["ybgqty"] = this.Request.BizObject["bcqty"] + string.Empty; //获取所有报工内容,判断是否等于派工。等于结束,不等于,继续进行 int zong = 0; int gonhda = 0;//工单数量 if(this.Request.BizObject["woqty"] + string.Empty != "") { gonhda = int.Parse(this.Request.BizObject["woqty"] + string.Empty); itemBo["F0000009"] = gonhda; } int yiyou = 0;//已报工 if(this.Request.BizObject["F0000021"] + string.Empty != "") { yiyou = int.Parse(this.Request.BizObject["F0000021"] + string.Empty); } zong = /*gonhda +*/ yiyou + baogong; if(gonhda == zong) { itemBo["gxstatus"] = "已结束"; } else { itemBo["gxstatus"] = "进行中"; } cishut++; } else { int zong = 0; int gonhda = 0;//工单数量0.9 if(this.Request.BizObject["F0000034"] + string.Empty != "") { gonhda = int.Parse(this.Request.BizObject["F0000034"] + string.Empty); //itemBo["F0000009"] = gonhda; } int gonhdabai = 0;//工单数量1.1 if(this.Request.BizObject["F0000035"] + string.Empty != "") { gonhdabai = int.Parse(this.Request.BizObject["F0000035"] + string.Empty); itemBo["F0000009"] = gonhdabai; } int yiyou = 0;//已报工 if(this.Request.BizObject["F0000021"] + string.Empty != "") { yiyou = int.Parse(this.Request.BizObject["F0000021"] + string.Empty); } zong = /*gonhda +*/ yiyou + baogong; if(gonhda < zong && gonhdabai > zong) { itemBo["gxstatus"] = "已结束"; } else { itemBo["gxstatus"] = "进行中"; } cishut++; } } }//最后一道 else if(zinameshunxuzi == gxcd) { if(zinamej == gxcd) { if(zuihou < 1) { int yiyou = 0; if(this.Request.BizObject["F0000021"] + string.Empty != "") { yiyou = int.Parse(this.Request.BizObject["F0000021"] + string.Empty); } int souyou = yiyou + baogong; if(souyou == onebg && onezt == "已结束") { itemBo["gxstatus"] = "已结束"; gdjs = "off"; } else { itemBo["gxstatus"] = "进行中"; } zuihou++; } if(dtzib4.Rows.Count > 0) { int wang = 0; int hg = 0; int huiy = 0; int cip = 0; int xlpw = 0; if(dtzib4.Rows[0]["F0000018"] + string.Empty != "") { wang = int.Parse(dtzib4.Rows[0]["F0000018"] + string.Empty); } if(this.Request.BizObject["F0000016"] + string.Empty != "") { hg = int.Parse(this.Request.BizObject["F0000016"] + string.Empty); } if(this.Request.BizObject["F0000013"] + string.Empty != "") { huiy = int.Parse(this.Request.BizObject["F0000013"] + string.Empty); } if(this.Request.BizObject["ngqty"] + string.Empty != "") { cip = int.Parse(this.Request.BizObject["ngqty"] + string.Empty); } if(this.Request.BizObject["F0000027"] + string.Empty != "") { xlpw = int.Parse(this.Request.BizObject["F0000027"] + string.Empty); } objin2["F0000018"] = wang + hg + huiy + cip + xlpw; double zonghe = wang + hg + huiy + cip + xlpw; int woqty = 0; if(this.Request.BizObject["woqty"] + string.Empty != "") { woqty = int.Parse(this.Request.BizObject["woqty"] + string.Empty); } double wgl = zonghe / woqty; objin2["F0000019"] = wgl; } } } //中间其他工序 else if(zinameshunxuzi == zinamej && zinameshunxuzi != 1 && zinameshunxuzi != gxcd) { int bao = 0;//上道工序数 if(itemBo["F0000009"] + string.Empty != "") { bao = int.Parse(itemBo["F0000009"] + string.Empty);//本来有的上道工序报工 } int yiyou = 0; if(this.Request.BizObject["F0000021"] + string.Empty != "") { yiyou = int.Parse(this.Request.BizObject["F0000021"] + string.Empty); } int souyou = yiyou + baogong; if(souyou < bao)//小于进行中 { itemBo["gxstatus"] = "进行中"; } else { //获取上道工序的状态 string zt = sdgxzt; if(zt == "已结束") { itemBo["gxstatus"] = "已结束"; } } } else { } //第一道工序与派工进行对比,下面的工序与,上到工序的报工数进行对比 //中间工序改变状态, 下一道工序,改变下一道工序的上一道工序报工数,及状态 if(zinamej == zinamejia) { int bao = 0; if(itemBo["F0000009"] + string.Empty != "") { bao = int.Parse(itemBo["F0000009"] + string.Empty);//本来有的上道工序报工 } // int shangbao = 0; // if(this.Request.BizObject["shangyouliangpin"] + string.Empty != "" ) // { // shangbao = int.Parse(this.Request.BizObject["shangyouliangpin"] + string.Empty); // } itemBo["F0000009"] = baogong + bao;//上到工序报工数 itemBo["gxstatus"] = "进行中"; } //将子表内已有数据循环添加到新的子表数据集合里 newChildBoList.Add(itemBo); } if(gdjs == "off") { objin2["wostatus"] = "结束"; } } //创建 objin2[childSchemaCode] = newChildBoList.ToArray(); objin2.Update(commit0); // objin2.Status = H3.DataModel.BizObjectStatus.Effective; string errorMsg = null; commit0.Commit(this.Engine.BizObjectManager, out errorMsg); //上面都是更改工单派工的工艺路线 //更改工序中心的工艺及查询下一条工序的情况 //下道工序的上道工序数,在上面的工单派工中会一起变更 int baogongshu = int.Parse(this.Request.BizObject["F0000026"] + string.Empty);//总报工 //查询对应工序 string ziid2 = this.Request.BizObject["rtId"] + string.Empty;//工序 string gongdan = this.Request.BizObject["woId"] + string.Empty;//工单 string sqlzib2 = "SELECT * FROM i_D001728bf71c5566608411794824fd32f34a7a3 where ObjectId='" + ziid2 + "'";//查询工序 System.Data.DataTable dtzib2 = this.Engine.Query.QueryTable(sqlzib2, null);//查询工序 //查询工单 string strgongdan = "SELECT * FROM i_D001728bf71c5566608411794824fd32f34a7a3 where F0000020='" + gongdan + "'"; System.Data.DataTable dtgdgls = this.Engine.Query.QueryTable(strgongdan, null); int gongxuzongshu = 0; // string gdjsz = "";//状态 H3.DataModel.BulkCommit commitT = new H3.DataModel.BulkCommit(); if(dtgdgls.Rows.Count > 0) { gongxuzongshu = dtgdgls.Rows.Count;//工序总数 } if(dtzib2.Rows.Count > 0) { string gongxu = dtzib2.Rows[0]["F0000001"] + string.Empty;//工序 int gongxus = int.Parse(gongxu); H3.DataModel.BizObject objingx = H3.DataModel.BizObject.Load(H3.Organization.User.SystemUserId, this.Engine, "D001728bf71c5566608411794824fd32f34a7a3", ziid2, false);//加载工序中心表 if(gongxu == "1") { if(this.Request.BizObject["seqence"] + string.Empty != "下料") { //获取所有报工内容,判断是否等于派工。等于结束,不等于,继续进行 int gonhda = 0;//派工 if(this.Request.BizObject["woqty"] + string.Empty != "") { gonhda = int.Parse(this.Request.BizObject["woqty"] + string.Empty); objingx["F0000008"] = gonhda; } if(baogongshu == gonhda) { objingx["F0000019"] = "已结束"; } else { objingx["F0000019"] = "进行中"; } objingx.Update(commitT); string errorMsg2 = null; commitT.Commit(this.Engine.BizObjectManager, out errorMsg2); } else { int gonhda = 0;//工单数量0.9 if(this.Request.BizObject["F0000034"] + string.Empty != "") { gonhda = int.Parse(this.Request.BizObject["F0000034"] + string.Empty); //objingx["F0000009"] = gonhda; } int gonhdabai = 0;//工单数量1.1 if(this.Request.BizObject["F0000035"] + string.Empty != "") { gonhdabai = int.Parse(this.Request.BizObject["F0000035"] + string.Empty); objingx["F0000008"] = gonhdabai; } // int gonhdaw = 0;//派工 // if(this.Request.BizObject["woqty"] + string.Empty != "") // { // gonhdaw = int.Parse(this.Request.BizObject["woqty"] + string.Empty); // objingx["F0000008"] = gonhdaw; // } //比较大小 if(baogongshu > gonhda && baogongshu < gonhdabai) { objingx["F0000019"] = "已结束"; } else { objingx["F0000019"] = "进行中"; } objingx.Update(commitT); string errorMsg2 = null; commitT.Commit(this.Engine.BizObjectManager, out errorMsg2); } } else if(gongxus == gongxuzongshu) { //查询第一道 string strdiyidao = "SELECT * FROM i_D001728bf71c5566608411794824fd32f34a7a3 where F0000020='" + gongdan + "'" + "and F0000001=1"; System.Data.DataTable dtdiyidao = this.Engine.Query.QueryTable(strdiyidao, null);//查询工序 int onebg = 0; string onezt = ""; if(dtdiyidao.Rows.Count > 0) { if(dtdiyidao.Rows[0]["F0000009"] + string.Empty != "") { onebg = int.Parse(dtdiyidao.Rows[0]["F0000009"] + string.Empty); } onezt = dtdiyidao.Rows[0]["F0000019"] + string.Empty; } int souyou = baogongshu; if(souyou == onebg && onezt == "已结束") { objingx["F0000019"] = "已结束"; // gdjsz = "off"; } else { objingx["F0000019"] = "进行中"; } objingx.Update(commitT); string errorMsg2 = null; commitT.Commit(this.Engine.BizObjectManager, out errorMsg2); } else { int shangdaoxu = gongxus - 1; string sxsdgxzt = ""; //获取上道工序状态 string sdgxzthq = "SELECT * FROM i_D001728bf71c5566608411794824fd32f34a7a3 where F0000020='" + gongdan + "'" + "and F0000001=" + shangdaoxu; System.Data.DataTable shangdaogongxuzt = this.Engine.Query.QueryTable(sdgxzthq, null); if(shangdaogongxuzt.Rows.Count > 0) { sxsdgxzt = shangdaogongxuzt.Rows[0]["F0000019"] + string.Empty;//状态 } int bao = 0;//上道工序数 if(dtzib2.Rows[0]["F0000008"] + string.Empty != "") { bao = int.Parse(dtzib2.Rows[0]["F0000008"] + string.Empty);//本来有的上道工序报工 } int souyou = baogongshu; if(souyou < bao)//小于进行中 { objingx["F0000019"] = "进行中"; } else { //获取上道工序的状态 string zt = sxsdgxzt; if(zt == "已结束") { objingx["F0000019"] = "已结束"; } } objingx.Update(commitT); string errorMsg2 = null; commitT.Commit(this.Engine.BizObjectManager, out errorMsg2); } } } }

 

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