123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using cuidian.Common;
- using cuidian.OpenApi.Api;
- using cuidian.OpenApi.Model;
- using cuidian.OpenApi.Utils;
- using OperationLog;
- using cuidian.Sql;
- namespace TempDbToUfida.OpenApi
- {
- /// <summary>
- /// 从中间库将其他出库资料下载到U8数据库
- /// </summary>
- public class DownLoadOtherout : BaseDataDownLoad
- {
- protected override void _Init()
- {
- _loadSql = "select * from RdRecord09 where processflag=0 and direction=1";
- base._Init();
- }
- protected override BusinessObject _ImportData(DataRow row)
- {
- OtheroutApi api = new OtheroutApi();
- Dictionary<string, string> args = new Dictionary<string, string>();
- string id = row["ID"].ToString();
- args.Add("RdRecord09", "select * from wtu..RdRecord09 where ID=" + id);
- args.Add("RdRecords09", "select * from wtu..RdRecords09 where ID=" + id);
- DataSet ds = DbUtils.Fill(args, ConnectionUtils.Instance.GetConnection());
- Otherout v = __GetHead(ds);
- v.entry = __GetDetails(ds);
- OtheroutRoot vr = new OtheroutRoot();
- vr.otherout = v;
- BusinessObject result = api.Add(JsonUtils.GetJsonString(vr));
- return result;
- }
- protected override void _Audit(string id)
- {
- OtheroutApi api = new OtheroutApi();
- api.Audit(id);
- }
- private Otherout __GetHead(DataSet ds)
- {
- Otherout v = new Otherout();
- DataTable dt = ds.Tables["RdRecord09"];
- v.code = dt.Rows[0]["cCode"].ToString();
- DateTime date = DateTime.Parse(dt.Rows[0]["dDate"].ToString());
- v.date = date.ToString("yyyy-MM-dd");
- v.maker = dt.Rows[0]["cMaker"].ToString();
- v.warehousecode = dt.Rows[0]["cWhCode"].ToString();
- v.memory = dt.Rows[0]["cMemo"].ToString();
- //define5 用友 U8 API中 其他出库单 的 单据头自定义项5
- v.define5 = dt.Rows[0]["ID"].ToString();//其他出库单 标识ID
- v.define1 = "来源旺店通";
- string cDefine15 = dt.Rows[0]["cDefine15"].ToString();
- if (cDefine15.Equals("2"))
- {
- v.receivecode = AppSeting.Instance.GetValue("receivecodeOut2");//收发类型默认F
- }
- else if (cDefine15.Equals("4"))
- {
- v.receivecode = AppSeting.Instance.GetValue("receivecodeOut4");//收发类型默认F
- }
- else if (cDefine15.Equals("7"))
- {
- v.receivecode = AppSeting.Instance.GetValue("receivecodeOut7");//收发类型默认F
- }
-
- return v;
- }
- private Entry[] __GetDetails(DataSet ds)
- {
- int cnt = ds.Tables["RdRecords09"].Rows.Count;
- DataTable dt = ds.Tables["RdRecords09"];
- Entry[] rtn = new Entry[cnt];
- for (int i = 0; i < cnt; i++)
- {
- Entry e = new Entry();
- e.inventorycode = dt.Rows[i]["cInvCode"].ToString().Replace(" ", "");
- e.quantity = dt.Rows[i]["iQuantity"].ToString();
- e.price = dt.Rows[i]["iUnitCost"].ToString();//
- e.cost = (Double.Parse(string.IsNullOrEmpty(e.quantity) ? "0" : e.quantity) * Double.Parse(string.IsNullOrEmpty(e.price)?"0":e.price)).ToString();
-
- //define27 用友U8 API中 其他出库单 的
- e.define27 = dt.Rows[i]["ID"].ToString();// 其他出库单 标识ID
- e.rowno = (i + 1).ToString();
- rtn[i] = e;
- }
- return rtn;
- }
- protected override void _LogError(int id, string msg)
- {
- OperationLog.Utils.WriteErrorLog("向U8导入其他出库资料", "sysid = " + id.ToString() + " " + msg);
- }
- protected override void _LogSucess(int id,string newCode)
- {
- string sql = "update RdRecord09 set processflag = 1,processdate = getdate(),newcode='" + newCode + "'" + " where sysid = " + id.ToString();
- //string sql = "update RdRecord09 set processflag = 1,processdate = getdate(),newcode=(select cCode from wtu..RdRecord09 where sysid = " + id.ToString() + ") where sysid = " + id.ToString();
- OperationLog.Utils.UpdateTempRecord(sql);
- }
- protected override string _GetReturnCode(BusinessObject result)
- {
- //string ID = DbUtils.ExecuteScalar(string.Format("select ID from RdRecord09 where cCode='{0}' ", result.Id), ConnectionUtils.Instance.GetConnection("003")).ToString();
- return result.Id;
- }
- }
- }
|