| | |
| | | using NewPdaSqlServer.DB; |
| | | using NewPdaSqlServer.Dto.service; |
| | | using NewPdaSqlServer.entity; |
| | | using NewPdaSqlServer.service.@base; |
| | | using NewPdaSqlServer.util; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | |
| | | using System.Security.Cryptography; |
| | | using System.Text; |
| | | using static Azure.Core.HttpHeader; |
| | | using static Microsoft.EntityFrameworkCore.DbLoggerCategory; |
| | | using static NewPdaSqlServer.Controllers.Warehouse.MesXkyController; |
| | | |
| | | namespace NewPdaSqlServer.service.QC; |
| | | |
| | | public class MesXkyService : RepositoryNoEntity |
| | | { |
| | | public bool XKY_GET_DHD(dynamic entity) |
| | | public dynamic XKY_GET_DHD(XKYGetDhdRequest entity) |
| | | { |
| | | string ErrorMsg = ""; |
| | | ApiCommonParam Apiparam = ApiCommonParam.NewApiCommon(); |
| | | try |
| | | { |
| | | string data_inserted = "{\r\n \"startDate\": 1745260800000,\r\n \"endDate\": 1745261100000,\r\n \"erpCode\": \"GXF001\"\r\n}"; |
| | | string ErrorMsg = ""; |
| | | ApiCommonParam Apiparam = ApiCommonParam.NewApiCommon(); |
| | | |
| | | //string data_inserted = "{\r\n \"startDate\": 1746759300000,\r\n \"endDate\": 1746762300000,\r\n \"erpCode\": \"GXF001\"\r\n}"; |
| | | string sendJson = JsonConvert.SerializeObject(entity); |
| | | ArrayList SQLStringList = new ArrayList(); |
| | | // var client = new HttpClient(); |
| | | var url = "https://openapi.xiekeyun.com/delivery/getNoList.json"; |
| | | HttpClient httpClient = new HttpClient(); |
| | | httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); |
| | | |
| | | string json = "{\"commonParam\":" + JsonConvert.SerializeObject(Apiparam) + ",\"body\":" + data_inserted + "}"; |
| | | string json = "{\"commonParam\":" + JsonConvert.SerializeObject(Apiparam) + ",\"body\":" + sendJson + "}"; |
| | | byte[] postData = Encoding.UTF8.GetBytes(json); |
| | | |
| | | // 创建请求对象 |
| | |
| | | string result2 = reader.ReadToEnd(); |
| | | |
| | | responseJson = JsonConvert.DeserializeObject(result2); |
| | | |
| | | } |
| | | |
| | | if (responseJson.result != 1) |
| | | throw new ApplicationException(responseJson.errorMsg); |
| | | |
| | | var result = 0; |
| | | // 新增数据存储逻辑 |
| | | List<DeliveryNotice> noticeList = JsonConvert.DeserializeObject<List<DeliveryNotice>>(responseJson.dataList.ToString()); |
| | | noticeList.ForEach(n => n.Id = Guid.NewGuid()); // 新增GUID赋值 |
| | | Db.Ado.UseTran(() => |
| | | { |
| | | result = Db.Insertable(noticeList).ExecuteCommand(); |
| | | }, ex => |
| | | { |
| | | throw new Exception($"数据库插入失败:{ex.Message}\n{ex.InnerException?.Message}"); |
| | | }); |
| | | |
| | | return responseJson; |
| | | } |
| | | catch (Exception ex) |
| | | catch (Exception e) |
| | | { |
| | | ErrorMsg = ex.Message; |
| | | return false; |
| | | throw new Exception(e.Message); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | public dynamic GetXkyDHD(dynamic entity) |
| | | public dynamic GetXkyDHD(XKYGetDhdRequest entity) |
| | | { |
| | | |
| | | return XKY_GET_DHD(entity); |