MaterialUpCict.cs
3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using Hh.Mes.Common.config;
using Hh.Mes.Common.log;
using Hh.Mes.Pojo.System;
using Hh.Mes.POJO.ApiEntity;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.POJO.Response;
using Newtonsoft.Json;
using NPOI.POIFS.FileSystem;
using System;
using System.Collections.Generic;
namespace Hh.Mes.Service.ApiService
{
public partial class UpstreamService
{
/// <summary>
/// 信科物料基础信息 同步
/// </summary>
/// <param name=""></param>
/// <returns></returns>
public Response MaterialUpCict()
{
var response = new Response();
return ExceptionsHelp.Instance.ExecuteT<Response>(() =>
{
var urlDic = "UrlMaterialCict" + ConfigRead.GetInstance.GetAppsetConnection().AppCustomExtend1;//AppCustomExtend1:"_onLine/_off"
var url = GetDictionaryDictValue(urlDic, "GetUrl")+ "api/BulletinBoard/Mes/V1/ReadData1";
//var url = GetDictionaryDictValue(urlDic, "GetUrl") + "wms/sszx/material/queryForMes";//海能发实际地址
response = HttpMan(url, null, EnumLog.Cict物料信息反馈.ToString(), method:"get");
if (response.Code == 200)
{
//do someing
var cictResult = JsonConvert.DeserializeObject<MaterialUpCictEntity>(response.Result);
response.Message = SystemVariable.dataActionOk;
response.Result = null;
return response;
}
//Log4NetHelper.Instance.Error($"【返回结果】" + response.Result);
response.Result =null;
return response.ResponseError($"【信科】物料基础信息同步错误,原因:{response.Message}");
});
}
private dynamic HandleData(List<base_material> list)
{
var response = new Response();
return ExceptionsHelp.Instance.ExecuteT(() =>
{
foreach (var model in list)
{
var isExist = Context.Queryable<base_material>().Where(i => i.id == model.id).ToList();
if (isExist.Count < 0)
{
var rate = new base_material_rate
{
materialCode = model.materialCode,
materialName = model.materialName,
mtClassify = model.mtClassify,
unitCode = model.unitCode,
specifications = model.specifications,
materialKeys = model.keys,
quantityRate = 1,
createBy = model.createBy,
createTime = DateTime.Now,//?
};
Context.Insertable<base_material>(model).AddQueue();
Context.Insertable<base_material_rate>(model).AddQueue();
Context.SaveQueues();
}
else
{
response.Status = Context.Updateable(model).Where(u => u.id == model.id).ExecuteCommand() > 0;
if (!response.Status) response.Message = SystemVariable.dataActionError;
}
}
return response;
});
}
}
}