| | |
| | | //dynamicParams.Add("@purchordercode", purchordercode); |
| | | } |
| | | //查询未关闭且未全部到货的采购订单 |
| | | sql = @"select distinct A.ordercode from T_PurchaseOrder A |
| | | sql = @"select distinct A.orderid,A.ordercode from T_PurchaseOrder A |
| | | inner join T_PurchaseOrder_sub B on A.ordercode=B.purchaseorder_code |
| | | where (isnull(B.quantity,0)-isnull(B.countarrivalquantity,0)+isnull(B.countreturnquantity,0))>0 and A.status<>'CLOSED'" + search; |
| | | dynamicParams.Add("@purchordercode", purchordercode); |
| | |
| | | try |
| | | { |
| | | //根据采购订单号查询物料信息,供应商信息 |
| | | sql = @"select B.rownumber, B.materiel_code as partcode,M.partname,M.partspec,M.is_batchno,M.is_incheck, |
| | | sql = @"select B.rownumber,B.sbid, B.materiel_code as partcode,M.partname,M.partspec,M.is_batchno,M.is_incheck, |
| | | B.quantity,B.customercode,C.name as customername,A.departmentcode,T.org_name as departmentname,U.code as uomcode,U.name as uomname, |
| | | A.ordercode,B.countarrivalquantity,A.acceptdate |
| | | from T_PurchaseOrder A |
| | |
| | | hbillno = djwo, |
| | | hbilltype = "1103", //采购到货单类型 |
| | | hbarcode = json[i].children[j].labcode, |
| | | qualitystatus= json[i].hischeck=="Y"? "TS" : "CS", |
| | | qualitystatus = json[i].hischeck == "Y" ? "TS" : "CS", |
| | | hbarcodestatus = "Y", |
| | | hbarcodetype = "P", |
| | | hmaterialcode = json[i].children[j].partnumber, |
| | |
| | | #endregion |
| | | |
| | | #region[采购入库扫描标签条码带出到货单信息] |
| | | public static ToMessage MesAppPurchInStorScanLabCode(string labcode, string ordercode) |
| | | public static ToMessage MesAppPurchInStorScanLabCode(string labcode) |
| | | { |
| | | string sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "当前条码已入库!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | //判断扫描标签是否为当前选择采购订单下的到货单所生成标签 |
| | | sql = @"select * from T_BarCodeBill where hsourcebillno=@ordercode"; |
| | | dynamicParams.Add("@ordercode", ordercode); |
| | | var data0 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data0.Rows.Count < 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "当前条码不是采购订单【" + ordercode + "】生成条码!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | |
| | | JArray arra = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(incontent); |
| | | list.Clear(); |
| | | //写入入库记录主表 |
| | | sql = @"insert into TK_WMS_Inwh_Main(docu_typecode,hbillno,hsoucenillno,status,hcustomer,hdempart,lm_user,lm_date) |
| | | values(@docu_typecode,@hbillno,@hsoucenillno,@status,@hcustomer,@hdempart,@lm_user,@lm_date)"; |
| | | sql = @"insert into TK_WMS_Inwh_Main(docu_typecode,hbillno,hsoucenillnoid,hsoucenillno,status,hcustomer,hdempart,lm_user,lm_date) |
| | | values(@docu_typecode,@hbillno,@hsoucenillnoid,@hsoucenillno,@status,@hcustomer,@hdempart,@lm_user,@lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | { |
| | | docu_typecode = "1201", |
| | | hbillno = djwo, |
| | | hsoucenillnoid= arra[0]["hsoucenillnoid"].ToString(), |
| | | hsoucenillno = ordercode, |
| | | status = "NEW", |
| | | hcustomer = arra[0]["customercode"].ToString(), |
| | |
| | | string labcode = "";//标签信息 |
| | | decimal suminqty = 0; //单标签入库总数量 |
| | | string batchno = ""; //批次号 |
| | | |
| | | |
| | | //查询汇总标签信息 |
| | | for (int j = 0; j < arra[i]["labcont"].Count(); j++)//循环获取标签信息 |
| | | { |
| | |
| | | hinqty = decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()) |
| | | } |
| | | }); |
| | | labcode = labcode + arra[i]["labcont"][j]["labcode"].ToString() + ","; |
| | | |
| | | //写入库存表 |
| | | sql = @"insert into TK_WMS_Stock(labcode,materiel_code,batchno,storehouse_code,location_code,customercode,qty,lm_user,lm_date) |
| | | values(@labcode,materiel_code,batchno,storehouse_code,location_code,customercode,qty,lm_user,lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | labcode = arra[i]["labcont"][j]["labcode"].ToString(), |
| | | materiel_code = arra[i]["partcode"].ToString(), |
| | | batchno = batchno, |
| | | storehouse_code = arra[i]["storehousecode"].ToString(), |
| | | location_code = arra[i]["warehousecode"].ToString(), |
| | | customercode = arra[i]["customercode"].ToString(), |
| | | qty = suminqty, |
| | | lm_user = username, |
| | | lm_date = datetime, |
| | | } |
| | | }); |
| | | |
| | | |
| | | //labcode = labcode + arra[i]["labcont"][j]["labcode"].ToString() + ","; |
| | | suminqty = suminqty + decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()); |
| | | partlabqty = partlabqty + decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()); |
| | | batchno = arra[i]["labcont"][j]["batch"].ToString(); |
| | | |
| | | } |
| | | |
| | | //更新采购订单子表入库数量 |
| | |
| | | }); |
| | | |
| | | //写入采购入库单子表 |
| | | sql = @"insert into TK_WMS_Inwh_Sub(hbillno,labcode,rownumber,materiel_code,storehouse_code,location_code,qty,batchno) |
| | | values(@hbillno,@labcode,@rownumber,@materiel_code,@storehouse_code,@location_code,@qty,@batchno)"; |
| | | labcode = string.Format("'{0}'", labcode.Substring(0, labcode.Length - 1).Replace(",", "','")); |
| | | sql = @"insert into TK_WMS_Inwh_Sub(hbillno,rownumber,materiel_code,storehouse_code,location_code,qty,batchno) |
| | | values(@hbillno,@rownumber,@materiel_code,@storehouse_code,@location_code,@qty,@batchno)"; |
| | | //labcode = string.Format("'{0}'", labcode.Substring(0, labcode.Length - 1).Replace(",", "','")); |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | |
| | | batchno = batchno |
| | | } |
| | | }); |
| | | //写入库存表前查询当前物料在库存表中是否存在,写入或更新库存表 |
| | | sql = @"select * from TK_WMS_Stock where materiel_code=@materiel_code"; |
| | | dynamicParams.Add("@materiel_code", arra[i]["partcode"].ToString()); |
| | | var data1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data1.Rows.Count > 0) |
| | | { |
| | | sql = @"update TK_WMS_Stock set qty=qty+@suminqty |
| | | where materiel_code=@materiel_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | materiel_code = arra[i]["partcode"].ToString(), |
| | | suminqty = suminqty |
| | | } |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | sql = @"insert into TK_WMS_Stock(materiel_code,batchno,storehouse_code,location_code,customercode,qty,lm_user,lm_date) |
| | | values(materiel_code,batchno,storehouse_code,location_code,customercode,qty,lm_user,lm_date)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | materiel_code = arra[i]["partcode"].ToString(), |
| | | batchno = batchno, |
| | | storehouse_code= arra[i]["storehousecode"].ToString(), |
| | | location_code= arra[i]["warehousecode"].ToString(), |
| | | customercode= arra[i]["customercode"].ToString(), |
| | | qty= suminqty, |
| | | lm_user=username, |
| | | lm_date= datetime, |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /*写入ERP采购入库单************ |
| | | * *********************** |
| | | * ********************** |
| | |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | orderdate= datetime, |
| | | ordercode= djwo, |
| | | status="NEW", |
| | | departmentcode= arra[0]["departmentcode"].ToString(), |
| | | customercode= arra[0]["customercode"].ToString(), |
| | | saleorderid= orderid, |
| | | saleordercode=ordercode, |
| | | lm_user= username, |
| | | lm_date= datetime |
| | | orderdate = datetime, |
| | | ordercode = djwo, |
| | | status = "NEW", |
| | | departmentcode = arra[0]["departmentcode"].ToString(), |
| | | customercode = arra[0]["customercode"].ToString(), |
| | | saleorderid = orderid, |
| | | saleordercode = ordercode, |
| | | lm_user = username, |
| | | lm_date = datetime |
| | | } |
| | | }); |
| | | //根据源单+物料查询采购订单到货总数、入库总数 |
| | |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | hbarcodestatus="N", |
| | | hbarcodestatus = "N", |
| | | hsourcebillno = ordercode, |
| | | hbarcode = arra[i]["labcont"][j]["labcode"].ToString() |
| | | } |
| | |
| | | hinqty = decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()) |
| | | } |
| | | }); |
| | | |
| | | //更新库存表 |
| | | sql = @"update TK_WMS_Stock set qty=qty-@inqty |
| | | where materiel_code=@materiel_code and labcode=@labcode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | labcode = arra[i]["labcont"][j]["labcode"].ToString(), |
| | | materiel_code = arra[i]["partcode"].ToString(), |
| | | inqty = decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()) |
| | | } |
| | | }); |
| | | |
| | | labcode = labcode + arra[i]["labcont"][j]["labcode"].ToString() + ","; |
| | | suminqty = suminqty + decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()); |
| | | partlabqty = partlabqty + decimal.Parse(arra[i]["labcont"][j]["qty"].ToString()); |
| | |
| | | batchno = batchno |
| | | } |
| | | }); |
| | | //写入库存表前查询当前物料在库存表中是否存在,写入或更新库存表 |
| | | sql = @"select * from TK_WMS_Stock where materiel_code=@materiel_code"; |
| | | dynamicParams.Add("@materiel_code", arra[i]["partcode"].ToString()); |
| | | var data1 = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data1.Rows.Count > 0) |
| | | { |
| | | sql = @"update TK_WMS_Stock set qty=qty-@suminqty |
| | | where materiel_code=@materiel_code"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | materiel_code = arra[i]["partcode"].ToString(), |
| | | suminqty = suminqty |
| | | } |
| | | }); |
| | | } |
| | | /*写入ERP采购退货单************ |
| | | * *********************** |
| | | * ********************** |
| | |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | } |
| | | } |