| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[MES报废补单工单查询] |
| | | public static ToMessage MesBadOrderSearch(string mesordercode, string sourceorder, string partcode, string partname, string partspec, int startNum, string creatuser, string createdate, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | | try |
| | | { |
| | | if (mesordercode != "" && mesordercode != null) |
| | | { |
| | | search += "and A.wo_code like '%'+@mesordercode+'%' "; |
| | | dynamicParams.Add("@mesordercode", mesordercode); |
| | | } |
| | | if (sourceorder != "" && sourceorder != null) |
| | | { |
| | | search += "and A.m_po like '%'+@sourceorder+'%' "; |
| | | dynamicParams.Add("@sourceorder", sourceorder); |
| | | } |
| | | if (partcode != "" && partcode != null) |
| | | { |
| | | search += "and A.materiel_code like '%'+@partcode+'%' "; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | } |
| | | if (partname != "" && partname != null) |
| | | { |
| | | search += "and B.partname like '%'+@partname+'%' "; |
| | | dynamicParams.Add("@partname", partname); |
| | | } |
| | | if (partspec != "" && partspec != null) |
| | | { |
| | | search += "and B.partspec like '%'+@partspec+'%' "; |
| | | dynamicParams.Add("@partspec", partspec); |
| | | } |
| | | if (createdate != "" && createdate != null) |
| | | { |
| | | search += "and CONVERT(varchar(100),A.lm_date,23)=@createdate "; |
| | | dynamicParams.Add("@createdate", createdate); |
| | | } |
| | | if (creatuser != "" && creatuser != null) |
| | | { |
| | | search += "and U.username like '%'+@creatuser+'%' "; |
| | | dynamicParams.Add("@creatuser", creatuser); |
| | | } |
| | | |
| | | if (search == "") |
| | | { |
| | | search = "and 1=1 "; |
| | | } |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.plan_qty,A.wkshp_code,C.org_name as wkshp_name, |
| | | A.route_code,E.name as route_name,A.stck_code,F.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,U.username as lm_user,A.lm_date,S.bad_qty |
| | | from TK_Wrk_Man A |
| | | left join (select wo_code,sum(bad_qty) as bad_qty from TK_Wrk_Step where bad_qty>0 group by wo_code) S on A.wo_code=S.wo_code |
| | | left join TMateriel_Info B on A.materiel_code=B.partcode |
| | | left join TOrganization C on A.wkshp_code=C.org_code |
| | | left join T_Sec_Stck D on A.stck_code=D.code |
| | | left join TFlw_Rout E on A.route_code=E.code |
| | | left join T_Sec_Stck F on A.stck_code=F.code |
| | | left join TUser U on A.lm_user=U.usercode |
| | | where A.is_delete<>'1' and A.status='START' and A.wotype='PO' and S.bad_qty>0 " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.count = total; |
| | | mes.data = data.ToList(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[产品编码查找工艺路线下拉接口] |
| | | public static ToMessage PartSelectRoute(string partcode) |
| | | { |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[工单派发选择工艺路线或选择生产车间时判断绑定条件] |
| | | public static ToMessage SelectRouteOrWkshop(string partcode, string routecode, string wkshopcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | mes.code = "200"; |
| | | mes.Message = ""; |
| | | mes.data = null; |
| | | //判断工艺路线对应工序是否都有关联工作站 |
| | | sql = @"select B.step_code,C.eqp_code from TFlw_Rout A |
| | | inner join TFlw_Rtdt B on A.code=B.rout_code |
| | | left join TFlw_Rteqp C on B.step_code=C.step_code |
| | | where A.code=@routecode"; |
| | | dynamicParams.Add("@routecode", routecode); |
| | | var dtck = DapperHelper.selectdata(sql, dynamicParams); |
| | | for (int i = 0; i < dtck.Rows.Count; i++) |
| | | { |
| | | if (dtck.Rows[i].IsNull("eqp_code")) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前工艺路线对应工序【" + dtck.Rows[i]["step_code"].ToString() + "】,未关联设备,请关联所有工序对应设备!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | //判断工艺路线对应工序关联的工作站是否有设置节拍工价 |
| | | sql = @"select AA.step_code,AA.eqp_code,AA.flwtype,S.unprice from ( |
| | | select A.code,B.step_code,C.eqp_code,S.flwtype from TFlw_Rout A |
| | | inner join TFlw_Rtdt B on A.code=B.rout_code |
| | | left join TFlw_Rteqp C on B.step_code=C.step_code |
| | | left join TStep S on B.step_code=S.stepcode |
| | | where A.code=@route_code |
| | | ) as AA |
| | | left join (select * from TPrteEqp_Stad where materiel_code=@partcode and route_code=@route_code) as S on |
| | | AA.code=S.route_code and AA.step_code=S.step_code and AA.eqp_code=S.eqp_code"; |
| | | dynamicParams.Add("@partcode", partcode); |
| | | dynamicParams.Add("@route_code", routecode); |
| | | var dtc = DapperHelper.selectdata(sql, dynamicParams); |
| | | for (int i = 0; i < dtc.Rows.Count; i++) |
| | | { |
| | | if (dtc.Rows[i]["flwtype"].ToString() == "Z") //判断工序是否为自制 |
| | | { |
| | | if (dtc.Rows[i].IsNull("unprice") || decimal.Parse(dtc.Rows[i]["unprice"].ToString()) == 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "节拍工价中:当前产品【" + partcode + "】,对应工艺路线【" + routecode + "】未设置(或未设置全)或工价小于等于0!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[MES工单新增、编辑提交] |
| | | public static ToMessage AddUpdateMesOrder(string mesorderstus, string sourceorder, string ordertype, string mesordercode, string partcode, string mesqty, string routecode, string wkshopcode, string planstartdate, string planenddate, string orderlev, string username, string opertype) |
| | | { |
| | |
| | | CreateDate = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | |
| | | //写入工单工艺路线工序工价复制表 |
| | | sql = @"insert into TWoPrteEqp_Stad(wo,materiel_code,eqp_code,stand_value,opc_conver,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,torg_code,is_delete,step_code) |
| | | select distinct @mesordercode as wo,S.materiel_code,S.eqp_code,S.stand_value,S.opc_conver,S.route_code,S.unprice, |
| | | S.eqp_value,S.cavity_qty,S.wkspcode,S.lm_user,S.lm_date,S.torg_code,S.is_delete,S.step_code |
| | | from TFlw_Rtdt A |
| | | inner join TFlw_Rteqp C on A.step_code=C.step_code |
| | | inner join (select * from TPrteEqp_Stad where materiel_code=@materiel_code and route_code=@routecode) as S on C.step_code=S.step_code and C.eqp_code=S.eqp_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | mesordercode = mesordercode, |
| | | materiel_code = partcode, |
| | | routecode = routecode |
| | | } |
| | | }); |
| | | |
| | | //if (is_aps == "Y") //是否排程 |
| | | //{ |
| | | // string sql1 = "select id from TBom_Main where materiel_code='" + PartNumber + "' and status='Y' and version='" + VsionId + "'"; |
| | |
| | | CreateDate = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | |
| | | //删除工单工艺路线工序工价复制表 |
| | | sql = @"delete TWoPrteEqp_Stad where wo=@mesordercode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | mesordercode = mesordercode |
| | | } |
| | | }); |
| | | //写入工单工艺路线工序工价复制表 |
| | | sql = @"insert into TWoPrteEqp_Stad(wo,materiel_code,eqp_code,stand_value,opc_conver,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,torg_code,is_delete,step_code) |
| | | select distinct @mesordercode as wo,S.materiel_code,S.eqp_code,S.stand_value,S.opc_conver,S.route_code,S.unprice, |
| | | S.eqp_value,S.cavity_qty,S.wkspcode,S.lm_user,S.lm_date,S.torg_code,S.is_delete,S.step_code |
| | | from TFlw_Rtdt A |
| | | inner join TFlw_Rteqp C on A.step_code=C.step_code |
| | | inner join (select * from TPrteEqp_Stad where materiel_code=@materiel_code and route_code=@routecode) as S on C.step_code=S.step_code and C.eqp_code=S.eqp_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | mesordercode = mesordercode, |
| | | materiel_code = partcode, |
| | | routecode = routecode |
| | | } |
| | | }); |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | |
| | | try |
| | | { |
| | | //判断工单是否为未开始状态或者已派发状态(满足其中一种都可删除,否则不允许删除) |
| | | sql = @"select * from TK_Wrk_Man where wo_code=@wocode and status='NEW' or status='ALLO'"; |
| | | sql = @"select * from TK_Wrk_Man where wo_code=@wocode and status in('NEW','ALLO')"; |
| | | dynamicParams.Add("@wocode", wocode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | |
| | | left join TStep B on A.step_code=B.stepcode |
| | | left join TK_Wrk_Man M on A.wo_code=M.wo_code |
| | | left join TMateriel_Info P on M.materiel_code=P.partcode |
| | | where A.wo_code=@wo_code"; |
| | | where A.wo_code=@wo_code order by A.seq"; |
| | | dynamicParams.Add("@wo_code", wo_code); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | |
| | | List<CapaPlan> list4 = ids1.Except(ids).ToList(); //表示ids1中哪些值是ids中所不存在的; |
| | | list4 = list3.Union(list4).ToList(); |
| | | //查找关键工序设备、工位群组的所有设备 |
| | | string sql3 = @"select * from( |
| | | select distinct A.code,A.name from TEqpInfo A |
| | | string sql3 = @"select distinct A.code,A.name from TEqpInfo A |
| | | left join TFlw_Rteqp B on A.code=B.eqp_code |
| | | left join TFlw_Rtdt D on B.step_code=D.step_code |
| | | where A.wksp_code=@wkshopcode and D.first_choke='Y' order by A.code)"; |
| | | where A.wksp_code=@wkshopcode and D.first_choke='Y' order by A.code"; |
| | | dynamicParams.Add("@wkshopcode", wkshopcode); |
| | | var dt3 = DapperHelper.selectdata(sql3, dynamicParams); |
| | | if (list4.Count > 0) //如果日期有变动 |
| | |
| | | } |
| | | } |
| | | //更新排产生产资源主表 |
| | | sql = @"update gn_wkm_capac_plan set wkshift_code=@wkshift_code,classtype=@classtype,lm_user=@lm_user,lm_time=@lm_time where id=@id"; |
| | | sql = @"update TWkm_capac_plan set wkshift_code=@wkshift_code,classtype=@classtype,lm_user=@lm_user,lm_date=@lm_time where id=@id"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | //循环写入排产生产资源子表 |
| | | for (int i = 0; i < objs.Count; i++) |
| | | { |
| | | sql = @"insert into TWkm_capac_plan_sub(m_id,wkdate,wkshift_code) values()"; |
| | | sql = @"insert into TWkm_capac_plan_sub(m_id,wkdate,wkshift_code) values(@m_id,@wkdate,@wkshift_code)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |