| | |
| | | public object MaterialDataToLocalByKDWebApi(string HDate,int limit) |
| | | { |
| | | bool hasMore = true;//æ¯å¦å¾ªç¯æ¥è¯¢ |
| | | string sJson = ""; |
| | | try |
| | | { |
| | | //访é®éè¶ |
| | |
| | | while (hasMore) //循ç¯åç»æ¥è¯¢ï¼é¿å
æ¼åæ¥ |
| | | { |
| | | //æ¼æ¥åæ®æ¥è¯¢æ¥å£åæ° |
| | | string sJson = $"{{\"FormId\":\"BD_MATERIAL\",\"FieldKeys\":\"{fieldKeys}\",\"FilterString\":\"FApproveDate >= '{HDate}' and FLOCALEID = 2052\",\"Limit\":{limit},\"StartRow\":{startRow},\"TopRowCount\":0}}"; |
| | | sJson = $"{{\"FormId\":\"BD_MATERIAL\",\"FieldKeys\":\"{fieldKeys}\",\"FilterString\":\"FApproveDate >= '{HDate}' and FLOCALEID = 2052\",\"Limit\":{limit},\"StartRow\":{startRow},\"TopRowCount\":0}}"; |
| | | |
| | | //è°ç¨éè¶webapiåæ®æ¥è¯¢æ¥å£ |
| | | var HReurnData = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery", |
| | |
| | | catch (Exception e) |
| | | { |
| | | hasMore = false; |
| | | LogService.Write("åæ®æ¥è¯¢ç©æä¿¡æ¯åçå¼å¸¸ï¼ï¼" + e.ToString() + "=======éå
¥JSONåæ°ï¼" + sJson); |
| | | oCn.RollBack();//åæ»äºå¡ |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®æ¥è¯¢ç©æä¿¡æ¯åçå¼å¸¸ï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 计éåä½åºç¡èµæåæ¥[æ¥å£é颿¥è¯¢ä¸å°å建ç»ç»å使ç¨ç»ç»ï¼å
å0ï¼ç¶åæ°æ®åºå·æ°ä¸] |
| | | [Route("WEBSController/UnitDataToLocalByKDWebApi")] |
| | | [HttpGet] |
| | | public object UnitDataToLocalByKDWebApi(string HDate, int limit) |
| | | { |
| | | bool hasMore = true;//æ¯å¦å¾ªç¯æ¥è¯¢ |
| | | try |
| | | { |
| | | //访é®éè¶ |
| | | string sCLOUDUseName = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "UserName"); |
| | | string sCLOUDPsd = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "PassWord"); |
| | | string dbId = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DbId"); |
| | | ApiClient client = new ApiClient(Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "KDApiUrl")); |
| | | bool bLogin = client.Login(dbId, sCLOUDUseName, sCLOUDPsd, 2052); |
| | | string HReturn; |
| | | int startRow = 0;//å页ï¼ä»ç¬¬1æ¡å¼å§æ¥è¯¢ |
| | | List<JObject> allData = new List<JObject>();//æ¥æ¶åå¨æææ¥è¯¢å°çæ°æ® |
| | | |
| | | if (!bLogin) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "忥åºç¡èµæå¤±è´¥,éè¶è´¦å·ç»å½å¼å¸¸ã"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //è¦éè¿æ¥å£æ¥è¯¢çåæ®µ |
| | | string fieldKeys = "FUNITID,FNumber,FName,FFORBIDSTATUS"; |
| | | |
| | | oCn.BeginTran();//å¼å§äºå¡ |
| | | |
| | | while (hasMore) //循ç¯åç»æ¥è¯¢ï¼é¿å
æ¼åæ¥ |
| | | { |
| | | //æ¼æ¥åæ®æ¥è¯¢æ¥å£åæ° |
| | | string sJson = $"{{\"FormId\":\"BD_UNIT\",\"FieldKeys\":\"{fieldKeys}\",\"FilterString\":\"FApproveDate >= '{HDate}' and FLOCALEID = 2052\",\"Limit\":{limit},\"StartRow\":{startRow},\"TopRowCount\":0}}"; |
| | | |
| | | //è°ç¨éè¶webapiåæ®æ¥è¯¢æ¥å£ |
| | | var HReurnData = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery", |
| | | new object[] { sJson }); |
| | | |
| | | //å°éè¶åæ®æ¥è¯¢WEBAPIæ¥å£è¿åç纯æ°ç»è½¬æ¢ä¸ºå¸¦å段åç对象å表 |
| | | JArray formattedData = ConvertKingdeeResultToObjects(HReurnData, fieldKeys); |
| | | |
| | | if (formattedData.Count < limit) |
| | | { |
| | | hasMore = false; // å¦ææ¬æ¬¡è¿åçæ°éå°äºè¯·æ±ç limitï¼è¯´æå·²ç»æ¯æåä¸é¡µäº |
| | | } |
| | | else |
| | | { |
| | | startRow += limit; // å¦åï¼å¢å èµ·å§è¡ç´¢å¼ï¼åå¤è¯·æ±ä¸ä¸é¡µ |
| | | } |
| | | |
| | | foreach (JObject item in formattedData) |
| | | { |
| | | //å é¤åæè®°å½ |
| | | oCn.RunProc($"delete from Gy_Unit where HItemID = {item["FUNITID"]?.ToString()}"); |
| | | |
| | | oCn.RunProc("set identity_insert Gy_Unit on"); |
| | | |
| | | //éæ°åå
¥è¡¨ |
| | | oCn.RunProc($"insert into Gy_Unit(HItemID,HERPItemID,HNumber,HName,HShortNumber,HParentID" + |
| | | $", HLevel,HEndFlag,HStopflag,HRemark,HUseFlag,HRate" + |
| | | $", HMakeTime,HStandard,HCREATEORGID,HUSEORGID) " + |
| | | $" values ( {item["FUNITID"]?.ToString()},{item["FUNITID"]?.ToString()},'{item["FNumber"]?.ToString()}','{item["FName"]?.ToString()}','{item["FNumber"]?.ToString()}'" + |
| | | $",0,1,1,{(item["FFORBIDSTATUS"]?.ToString() == "A" ? 0 : 1)},'WEBAPI-导å
¥','æªæ£æµ','1',getdate(),1,{0},{0}" + |
| | | $")"); |
| | | |
| | | oCn.RunProc("set identity_insert Gy_Unit off"); |
| | | } |
| | | } |
| | | |
| | | oCn.Commit(); //æäº¤äºå¡ |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "计éåä½ä¿¡æ¯åæ¥æå"; |
| | | objJsonResult.data = ""; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | hasMore = false; |
| | | oCn.RollBack();//åæ»äºå¡ |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®æ¥è¯¢è®¡éåä½ä¿¡æ¯åçå¼å¸¸ï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | #region ä¾åºååºç¡èµæåæ¥ |
| | | [Route("WEBSController/SupplierDataToLocalByKDWebApi")] |
| | |
| | | |
| | | #endregion |
| | | |
| | | |
| | | #region 客æ·åºç¡èµæåæ¥ |
| | | [Route("WEBSController/CustomerDataToLocalByKDWebApi")] |
| | | [HttpGet] |
| | |
| | | |
| | | #endregion |
| | | |
| | | |
| | | #region ç»ç»åºç¡èµæåæ¥ |
| | | [Route("WEBSController/ORGANIZATIONSDataToLocalByKDWebApi")] |
| | | [HttpGet] |
| | |
| | | |
| | | #endregion |
| | | |
| | | |
| | | #region è¾
å©å±æ§åºç¡èµæåæ¥ |
| | | [Route("WEBSController/PropertyDataToLocalByKDWebApi")] |
| | | [HttpGet] |
| | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | } |