UpstreamSendUser.cs
3.27 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
using Hh.Mes.Common;
using Hh.Mes.Common.config;
using Hh.Mes.Common.Json;
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.Request;
using Hh.Mes.POJO.Response;
using System;
namespace Hh.Mes.Service.ApiService
{
public partial class UpstreamService
{
public dynamic SendUser(SysUserEntity requestData)
{
return ExceptionsHelp.Instance.ExecuteT(() =>
{
//var reqData = DynamicJson.Parse(requestData); reqData.data
SysUserEntity entity = requestData ;
var response = new ResponseUpstream<string>(entity.plmeid);
if (!typeValidation(entity.type, response).Status) return response;
var user = new sys_user
{
plmeid = entity.plmeid,
account = entity.code,
name = entity.name,
sex = entity.gender == "男" ? 1 : 0,
password = Encryption.Encrypt(ConfigRead.GetInstance.GetAppsetConnection().ResetPwd),
otherCode = entity.code,
phoneNumber = entity.tel,
remarks = entity.remarks,
status = AddOrUpdateFlag,
};
int resultCount = 0;
if (entity.type == EnumAction.I.ToString())
{
if (Context.Queryable<sys_user>().Any(t => t.plmeid == user.plmeid && t.status == 1&&t.account==user.account))
{
return response.ResponseError($"【上位系统】【name,plmeid】用户信息[{entity.name},{entity.plmeid}]已经存在,请勿重复添加!");
}
user.createTime = DateTime.Now;
resultCount=Context.Insertable(user).ExecuteCommand();
if (resultCount > 0)
{
//var deptId = Context.Queryable<sys_dept>().Select(x => x.id).First();
var deptId = ConfigRead.GetInstance.GetAppsetConnection().Extend1;
var userId = Context.Queryable<sys_user>().First(x => x.plmeid == user.plmeid && x.status == AddOrUpdateFlag).id;
var relevance = new sys_relevance
{
relKey = "UserOrg",
firstId = userId,
secondId = Convert.ToInt32(deptId),
createTime = DateTime.Now,
createBy = entity.code,
};
Context.Insertable(relevance).ExecuteCommand();
}
}
else if (entity.type == EnumAction.U.ToString())
{
user.updateTime = DateTime.Now;
resultCount = Context.Updateable(user)
.IgnoreColumns(it => new { it.createBy, it.createTime })
.Where(x => x.plmeid == entity.plmeid && x.status == AddOrUpdateFlag).ExecuteCommand();
}
return resultCount > 0 ? response.ResponseSuccess() : response.ResponseError();
});
}
}
}