using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; using System.Data; using cuidian.Sql; using WdtUtils.Proxy; using WdtUtils.UpLoad; using WdtUtils; using cuidian.Common; namespace TempDbToWang { /// /// 其他入库单从中间库上传到旺店通 /// public class UploadRdrecord08 : BaseUpload { protected override void _PrepareData(Hashtable args) { string sql = "select sysid,id,ccode from wtu..rdrecord08 where processflag=0 and direction=0 "; _data = DbUtils.Fill(sql, ConnectionUtils.Instance.GetConnection()); } public List _results=new List(); protected override AddResult _Upload(DataRow dr) { Rdrecord08Upload upload = new Rdrecord08Upload(); string data = string.Empty; AddResult result = upload.UploadToWang(_GetData(dr)); _results.Add(result); return result; } protected override void _WriteLog(AddResult result, DataRow dr) { int id = Convert.ToInt32(dr["sysid"]); string sql; if (result.IsSucess) { //sql = "update wtu..rdrecord08 set processdate=getdate(),processflag=1 where sysid=" + id.ToString(); sql = "update wtu..rdrecord08 set processdate=getdate(),processflag=1,newcode='"+ result.DocCode + "' where sysid=" + id.ToString(); OperationLog.Utils.UpdateTempRecord(sql); } else { OperationLog.Utils.WriteErrorLog("上传旺店通其他入库单", "其他入库单:" + dr["ccode"].ToString() + "\t\r" + result.Message); } } protected override string _GetData(DataRow dr) { Dictionary args = new Dictionary(); string id = dr["id"].ToString(); args.Add("rdrecord08", "select * from wtu..rdrecord08 where id=" + id); args.Add("rdrecords08", "select * from wtu..rdrecords08 where id=" + id); DataSet ds = DbUtils.Fill(args, ConnectionUtils.Instance.GetConnection()); //StockinProxy stockin = new StockinProxy(); //Stockin_List[] list = new Stockin_List[1]; Stockin_List head = __GetHead(ds); head.goods_list = __GetDetails(ds); //list[0] = head; //stockin.stockin_list = list; //return JsonUtils.GetJsonString(stockin); return JsonUtils.GetJsonString(head);//只能传单个 } private Stockin_List __GetHead(DataSet ds) { Stockin_List rtn = new Stockin_List(); DataTable dt = ds.Tables["rdrecord08"]; //rtn.outer_no = dt.Rows[0]["ccode"].ToString(); //rtn.warehouse_no = "yilv2test"; rtn.warehouse_no = dt.Rows[0]["cWhCode"].ToString(); rtn.outer_no = dt.Rows[0]["ccode"].ToString(); rtn.remark = "来源U8"; return rtn; } private Goods_List[] __GetDetails(DataSet ds) { int cnt = ds.Tables["rdrecords08"].Rows.Count; DataTable dt = ds.Tables["rdrecords08"]; Goods_List[] rtn = new Goods_List[cnt]; for (int i = 0; i < cnt; i++) { Goods_List item = new Goods_List(); item.spec_no = dt.Rows[i]["cInvCode"].ToString(); item.stockin_num = _ConvertNotStr(dt.Rows[i]["iQuantity"].ToString()); item.src_price = _ConvertNotStr(dt.Rows[i]["iUnitCost"].ToString()); item.stockin_price = _ConvertNotStr(dt.Rows[i]["iUnitCost"].ToString()); rtn[i] = item; } return rtn; } private string _ConvertNotStr(string valueStr) { return string.IsNullOrWhiteSpace(valueStr) ? "0" : valueStr; } } }