| | |
| | | // --------------查询指定数据-------------- |
| | | var total = 0; //总条数 |
| | | var sql = @"select * from( |
| | | select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname, |
| | | select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname, |
| | | A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname, |
| | | E.saleOrderqty,E.qty,M.plan_qty,A.good_qty,isnull(A.inhouseqty,0) as inhouseqty,A.good_qty-isnull(A.inhouseqty,0) as stinhouseqty,M.lm_date,A.style |
| | | from TK_Wrk_Record A |
| | |
| | | left join T_Sec_Stck K on E.stck_code=K.code |
| | | where A.style='B' and S.isend='Y' and A.good_qty>0 |
| | | union all |
| | | select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname, |
| | | select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname, |
| | | A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname, |
| | | E.saleOrderqty,E.qty,M.plan_qty,A.sqty as sqty,isnull(A.inhouseqty,0) as inhouseqty,A.sqty-isnull(A.inhouseqty,0) as stinhouseqty,M.lm_date,A.style |
| | | from TK_Wrk_OutRecord A |
| | |
| | | } |
| | | }); |
| | | //写入MES库存表 |
| | | sql = @"insert into TK_WMS_Stock(labcode,materiel_code,storehouse_code,qty,lm_user,lm_date) |
| | | values(@labcode,@materiel_code,@storehouse_code,@qty,@lm_user,@lm_date)"; |
| | | sql = @"insert into TK_WMS_Stock(hbillno,labcode,materiel_code,storehouse_code,qty,lm_user,lm_date) |
| | | values(@hbillno,@labcode,@materiel_code,@storehouse_code,@qty,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | hbillno = obj["head"]["hbillno"].ToString(), |
| | | labcode = sub_arra[i]["inbarcode"].ToString(), |
| | | materiel_code = sub_arra[i]["partcode"].ToString(), |
| | | storehouse_code = sub_arra[i]["stockcode"].ToString(), |
| | |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region[生产入库扫描条码] |
| | | public static ToMessage MesAppProductInHouseOrderBarCodeSearch(string labcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | //判断条码是否存在 |
| | | sql = @"select distinct AA.inbarcode from ( |
| | | select A.inbarcode |
| | | from TK_Wrk_Record A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code |
| | | where A.style='B' and S.isend='Y' and A.good_qty>0 and A.inbarcode=@labcode |
| | | union all |
| | | select A.inbarcode |
| | | from TK_Wrk_OutRecord A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code |
| | | where A.style='S' and S.isend='Y' and A.sqty>0 and A.inbarcode=@labcode |
| | | ) as AA"; |
| | | dynamicParams.Add("@labcode", labcode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count <= 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "无效条码!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | //判断条码是否存可用 |
| | | sql = @"select distinct AA.inbarcode,AA.good_qty,AA.inhouseqty from ( |
| | | select A.inbarcode,sum(A.good_qty) as good_qty,sum(isnull(A.inhouseqty,0)) as inhouseqty |
| | | from TK_Wrk_Record A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code |
| | | where A.style='B' and S.isend='Y' and A.good_qty>0 and A.inbarcode=@labcode |
| | | group by A.inbarcode |
| | | union all |
| | | select A.inbarcode,sum(A.sqty) as good_qty,sum(isnull(A.inhouseqty,0)) as inhouseqty |
| | | from TK_Wrk_OutRecord A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code |
| | | where A.style='S' and S.isend='Y' and A.sqty>0 and A.inbarcode=@labcode |
| | | group by A.inbarcode |
| | | ) as AA where AA.good_qty>AA.inhouseqty "; |
| | | dynamicParams.Add("@labcode", labcode); |
| | | var data1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data1.Rows.Count <= 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "当前条码已入库!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | |
| | | //根据采购订单号查询物料信息,供应商信息 |
| | | sql = @"select * from( |
| | | select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname, |
| | | A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname, |
| | | E.saleOrderqty,E.qty,M.plan_qty,A.good_qty,isnull(A.inhouseqty,0) as inhouseqty,A.good_qty-isnull(A.inhouseqty,0) as stinhouseqty,A.lm_date,A.style |
| | | from TK_Wrk_Record A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code |
| | | inner join TK_Wrk_Man M on S.wo_code=M.wo_code |
| | | inner join TMateriel_Info P on M.materiel_code=P.partcode |
| | | left join TKimp_Ewo E on M.sourceid=E.id |
| | | left join T_Sec_Stck K on E.stck_code=K.code |
| | | where A.style='B' and S.isend='Y' and A.good_qty>0 and A.inbarcode=@labcode |
| | | union all |
| | | select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname, |
| | | A.step_code,E.wkshp_id,M.wkshp_code,stck_id,K.code as stockcode,k.name as stockname, |
| | | E.saleOrderqty,E.qty,M.plan_qty,A.sqty as sqty,isnull(A.inhouseqty,0) as inhouseqty,A.sqty-isnull(A.inhouseqty,0) as stinhouseqty,A.lm_date,A.style |
| | | from TK_Wrk_OutRecord A |
| | | inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code |
| | | inner join TK_Wrk_Man M on S.wo_code=M.wo_code |
| | | inner join TMateriel_Info P on M.materiel_code=P.partcode |
| | | left join TKimp_Ewo E on M.sourceid=E.id |
| | | left join T_Sec_Stck K on E.stck_code=K.code |
| | | where A.style='S' and S.isend='Y' and A.sqty>0 and A.inbarcode=@labcode |
| | | ) as AA where AA.good_qty>AA.inhouseqty"; |
| | | dynamicParams.Add("@labcode", labcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "暂无物料数据!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | } |
| | | } |