| | |
| | | // --------------查询指定数据-------------- |
| | | 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 |
| | |
| | | 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 |
| | | ) as AA where 1=1 " + search; |
| | | ) as AA where AA.good_qty>AA.inhouseqty " + search; |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | |
| | | } |
| | | }); |
| | | //写入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 |
| | | { |
| | | labcode=sub_arra[i]["inbarcode"].ToString(), |
| | | 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(), |
| | | qty =decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()), |
| | | qty = decimal.Parse(sub_arra[i]["stinhouseqty"].ToString()), |
| | | lm_user = username, |
| | | lm_date = DateTime.Now.ToString() |
| | | } |
| | |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | docu_typecode="1202", |
| | | hbillno= obj["head"]["hbillno"].ToString(), |
| | | hsoucenillnoid= obj["head"]["sourceVoucherId"].ToString(), |
| | | docu_typecode = "1202", |
| | | hbillno = obj["head"]["hbillno"].ToString(), |
| | | hsoucenillnoid = obj["head"]["sourceVoucherId"].ToString(), |
| | | hsoucenillno = obj["head"]["sourceVoucherCode"].ToString(), |
| | | saleorderid = obj["head"]["saleOrderId"].ToString(), |
| | | saleordercode = obj["head"]["saleOrderCode"].ToString(), |
| | | status = "NEW", |
| | | wkshpcode = obj["head"]["wkshpcode"].ToString(), |
| | | lm_user = username, |
| | | lm_date= DateTime.Now.ToString() |
| | | lm_date = DateTime.Now.ToString() |
| | | } |
| | | }); |
| | | |
| | |
| | | // madedate = obj["head"]["madedate"].ToString(), |
| | | // createdtime = obj["head"]["createdtime"].ToString(), |
| | | // DataSource = obj["head"]["DataSource"].ToString(), |
| | | // idsourcevouchertype= obj["head"]["idsourcevouchertype"].ToString() |
| | | |
| | | // } |
| | | //}); |
| | |
| | | // str = sql, |
| | | // parm = new |
| | | // { |
| | | // code= subsum_arra[j]["code"].ToString(), |
| | | // code = subsum_arra[j]["code"].ToString(), |
| | | // arrivalQuantity = subsum_arra[j]["arrivalQuantity"].ToString(), |
| | | // quantity = subsum_arra[j]["quantity"].ToString(), |
| | | // compositionQuantity = subsum_arra[j]["compositionQuantity"].ToString(), |
| | |
| | | // idbusiTypeByMergedFlow = subsum_arra[j]["idbusiTypeByMergedFlow"].ToString(), |
| | | // idinventory = subsum_arra[j]["idinventory"].ToString(), |
| | | // idbaseunit = subsum_arra[j]["idbaseunit"].ToString(), |
| | | // idunit= subsum_arra[j]["idunit"].ToString(), |
| | | // idunit = subsum_arra[j]["idunit"].ToString(), |
| | | // idwarehouse = subsum_arra[j]["idwarehouse"].ToString(), |
| | | // SourceVoucherIdByMergedFlow = subsum_arra[j]["SourceVoucherIdByMergedFlow"].ToString(), |
| | | // SourceVoucherCodeByMergedFlow = subsum_arra[j]["SourceVoucherCodeByMergedFlow"].ToString(), |
| | |
| | | // DataSource = subsum_arra[j]["DataSource"].ToString() |
| | | // } |
| | | //}); |
| | | //写入ERP现存量查询表 |
| | | //sql = @"" + dt.Rows[2]["cname"].ToString() + ""; |
| | | //list.Add(new |
| | | //{ |
| | | // str = sql, |
| | | // parm = new |
| | | // { |
| | | // idinventory = subsum_arra[j]["idinventory"].ToString(), |
| | | // idwarehouse = subsum_arra[j]["idwarehouse"].ToString(), |
| | | // propertyName = "ProductForReceive", |
| | | // baseQuantity= subsum_arra[j]["quantity"].ToString(), |
| | | // IdMarketingOrgan="1", |
| | | // idbaseunit= subsum_arra[j]["idbaseunit"].ToString(), |
| | | // updated= DateTime.Now.ToString(), |
| | | // isCarriedForwardOut ="0", |
| | | // isCarriedForwardIn = "0" |
| | | // } |
| | | //}); |
| | | |
| | | |
| | | |
| | | //写入MES入库记录子表 |
| | | sql = @"insert into TK_WMS_Inwh_Sub(hbillno,rownumber,materiel_code,storehouse_code,qty) |
| | | values(@hbillno,@rownumber,@materiel_code,@storehouse_code,@qty)"; |
| | |
| | | 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 |
| | | } |
| | | } |