UpstreamSendSupplier.cs
2.74 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
using System;
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 static Microsoft.AspNetCore.Hosting.Internal.HostingApplication;
namespace Hh.Mes.Service.ApiService
{
public partial class UpstreamService
{
public dynamic SendSupplier(SupplierEntity entity)
{
var response = new ResponseUpstream<string>(entity.plmeid);
return ExceptionsHelp.Instance.ExecuteT(() =>
{
var supplier = new base_supplier
{
plmeid = entity.plmeid,
factoryCode = entity.factory,
supplierCode = entity.supplier_code,
supplierName = entity.supplier_name,
address = entity.address,
telePhone = entity.tele_phone,
isDelete = AddOrUpdateFlag
};
var resultCount = 0;
if (entity.type == EnumAction.I.ToString())
{
supplier.createTime = DateTime.Now;
supplier.createBy = SystemVariable.DefaultCreated;
var resultCrudBefore = Context.Queryable<base_supplier>().Any(x => x.supplierCode.Equals(supplier.supplierCode) && x.isDelete == AddOrUpdateFlag);
if (resultCrudBefore)
return response.ResponseError($"【MOM】供应商数据:[{nameof(entity.supplier_code)}]“{supplier.supplierCode}”已经存在!");
resultCount = Context.Insertable(supplier).ExecuteCommand();
}
else if (entity.type == EnumAction.U.ToString())
{
supplier.updateTime = DateTime.Now;
supplier.updateBy = SystemVariable.DefaultCreated;
resultCount = Context.Updateable(supplier)
.IgnoreColumns(it => new { it.createBy, it.createTime })
.Where(x => x.supplierCode == supplier.supplierCode && x.isDelete == AddOrUpdateFlag)
.ExecuteCommand();
}
else if (entity.type == EnumAction.D.ToString())
{
supplier.isDelete = DeleteFlag;
resultCount = Context.Updateable(supplier).UpdateColumns(x => new { x.isDelete })
.Where(x => x.supplierCode == supplier.supplierCode && x.isDelete == AddOrUpdateFlag)
.ExecuteCommand();
}
return resultCount > 0 ? response.ResponseSuccess() : response.ResponseError();
});
}
}
}