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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package com.tanpu.feo.feojob.service.impl;
import com.tanpu.feo.feojob.dto.WorkDataDto;
import com.tanpu.feo.feojob.entity.*;
import com.tanpu.feo.feojob.mapper.*;
import com.tanpu.feo.feojob.service.OrgSyncByWxcpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
@Slf4j
public class OrgSyncByWxcpServiceImpl implements OrgSyncByWxcpService {
@Resource
private UserInfoMapper userInfoMapper;
@Resource
private DepartmentMapper departmentMapper;
@Resource
private DepartmentEmployeeMapper departmentEmployeeMapper;
@Resource
private EmployeeMapper employeeMapper;
@Resource
private EmployeeRoleMapper employeeRoleMapper;
@Transactional
public List<IfaAssetsEntity> execute(WorkDataDto<UserInfoEntity> workUserInfo, WorkDataDto<EmployeeEntity> workEmployee, WorkDataDto<DepartmentEntity> workDepartment,
WorkDataDto<DepartmentEmployeeEntity> workDepartmentEmployee, WorkDataDto<EmployeeRoleEntity> workEmployeeRole) {
ArrayList<IfaAssetsEntity> assetsArrayList = new ArrayList<>();
Date now = new Date();
log.info("==========开始 执行数据修改==========");
// 1
List<UserInfoEntity> workUserInfoInsertList = workUserInfo.getInsertList();
for (UserInfoEntity userInfoEntity : workUserInfoInsertList) {
userInfoEntity.setCreateby("SYS");
userInfoEntity.setCreatetime(now);
userInfoEntity.setUpdateby("SYS");
userInfoEntity.setUpdatetime(now);
userInfoEntity.setDeletetag("0");
userInfoMapper.insert(userInfoEntity);
}
List<UserInfoEntity> workUserInfoUpdateList = workUserInfo.getUpdateList();
for (UserInfoEntity userInfoEntity : workUserInfoUpdateList) {
userInfoEntity.setUpdateby("SYS");
userInfoEntity.setUpdatetime(now);
userInfoEntity.setDeletetag("0");
userInfoMapper.updateById(userInfoEntity);
}
List<UserInfoEntity> workUserInfoDeleteList = workUserInfo.getDeleteList();
for (UserInfoEntity userInfoEntity : workUserInfoDeleteList) {
userInfoEntity.setUpdateby("SYS");
userInfoEntity.setUpdatetime(now);
userInfoEntity.setDeletetag("1");
userInfoMapper.updateById(userInfoEntity);
}
//2
List<EmployeeEntity> workEmployeeInsertList = workEmployee.getInsertList();
for (EmployeeEntity employeeEntity : workEmployeeInsertList) {
employeeEntity.setCreateBy("SYS");
employeeEntity.setCreateTime(now);
employeeEntity.setUpdateBy("SYS");
employeeEntity.setUpdateTime(now);
employeeEntity.setDeleteTag("0");
employeeMapper.insert(employeeEntity);
IfaAssetsEntity ifaAssetsEntity = new IfaAssetsEntity();
ifaAssetsEntity.setIfaId(employeeEntity.getEmployeeId());
ifaAssetsEntity.setId(employeeEntity.getEmployeeId());
ifaAssetsEntity.setCreateTime(now);
ifaAssetsEntity.setCreateBy("SYS");
ifaAssetsEntity.setUpdateTime(now);
ifaAssetsEntity.setUpdateBy("SYS");
ifaAssetsEntity.setDeleteTag("0");
assetsArrayList.add(ifaAssetsEntity);
// ifaAssetsService.insertIfaAssets(ifaAssetsEntity);
}
List<EmployeeEntity> workEmployeeDeleteList = workEmployee.getDeleteList();
for (EmployeeEntity employeeEntity : workEmployeeDeleteList) {
employeeEntity.setUpdateBy("SYS");
employeeEntity.setUpdateTime(now);
employeeEntity.setDeleteTag("1");
employeeMapper.updateById(employeeEntity);
}
List<EmployeeEntity> workEmployeeUpdateList = workEmployee.getUpdateList();
for (EmployeeEntity employeeEntity : workEmployeeUpdateList) {
employeeEntity.setUpdateBy("SYS");
employeeEntity.setUpdateTime(now);
employeeEntity.setDeleteTag("0");
employeeMapper.updateById(employeeEntity);
}
//3
List<DepartmentEntity> workDepartmentInsertList = workDepartment.getInsertList();
for (DepartmentEntity departmentEntity : workDepartmentInsertList) {
departmentEntity.setCreateBy("SYS");
departmentEntity.setCreateTime(now);
departmentEntity.setUpdateBy("SYS");
departmentEntity.setUpdateTime(now);
departmentEntity.setDeleteTag("0");
departmentMapper.insert(departmentEntity);
}
List<DepartmentEntity> workDepartmentDeleteList = workDepartment.getDeleteList();
for (DepartmentEntity departmentEntity : workDepartmentDeleteList) {
departmentEntity.setUpdateBy("SYS");
departmentEntity.setUpdateTime(now);
departmentEntity.setDeleteTag("1");
departmentMapper.updateById(departmentEntity);
}
List<DepartmentEntity> workDepartmentUpdateList = workDepartment.getUpdateList();
for (DepartmentEntity departmentEntity : workDepartmentUpdateList) {
departmentEntity.setUpdateBy("SYS");
departmentEntity.setUpdateTime(now);
departmentEntity.setDeleteTag("0");
departmentMapper.updateById(departmentEntity);
}
//4
List<DepartmentEmployeeEntity> workDepartmentEmployeeInsertList = workDepartmentEmployee.getInsertList();
for (DepartmentEmployeeEntity departmentEmployeeEntity : workDepartmentEmployeeInsertList) {
departmentEmployeeEntity.setCreateBy("SYS");
departmentEmployeeEntity.setCreateTime(now);
departmentEmployeeEntity.setUpdateBy("SYS");
departmentEmployeeEntity.setUpdateTime(now);
departmentEmployeeEntity.setDeleteTag("0");
departmentEmployeeMapper.insert(departmentEmployeeEntity);
}
List<DepartmentEmployeeEntity> workDepartmentEmployeeDeleteList = workDepartmentEmployee.getDeleteList();
for (DepartmentEmployeeEntity departmentEmployeeEntity : workDepartmentEmployeeDeleteList) {
departmentEmployeeEntity.setUpdateBy("SYS");
departmentEmployeeEntity.setUpdateTime(now);
departmentEmployeeEntity.setDeleteTag("1");
departmentEmployeeMapper.updateById(departmentEmployeeEntity);
}
List<DepartmentEmployeeEntity> workDepartmentEmployeeUpdateList = workDepartmentEmployee.getUpdateList();
for (DepartmentEmployeeEntity departmentEmployeeEntity : workDepartmentEmployeeUpdateList) {
departmentEmployeeEntity.setUpdateBy("SYS");
departmentEmployeeEntity.setUpdateTime(now);
departmentEmployeeEntity.setDeleteTag("0");
departmentEmployeeMapper.updateById(departmentEmployeeEntity);
}
//5
List<EmployeeRoleEntity> workEmployeeRoleInsertList = workEmployeeRole.getInsertList();
for (EmployeeRoleEntity employeeRoleEntity : workEmployeeRoleInsertList) {
employeeRoleEntity.setCreateBy("SYS");
employeeRoleEntity.setCreateTime(now);
employeeRoleEntity.setUpdateBy("SYS");
employeeRoleEntity.setUpdateTime(now);
employeeRoleEntity.setDeleteTag("0");
employeeRoleMapper.insert(employeeRoleEntity);
}
List<EmployeeRoleEntity> workEmployeeRoleDeleteList = workEmployeeRole.getDeleteList();
for (EmployeeRoleEntity employeeRoleEntity : workEmployeeRoleDeleteList) {
employeeRoleEntity.setUpdateBy("SYS");
employeeRoleEntity.setUpdateTime(now);
employeeRoleEntity.setDeleteTag("1");
employeeRoleMapper.updateById(employeeRoleEntity);
}
List<EmployeeRoleEntity> workEmployeeRoleUpdateList = workEmployeeRole.getUpdateList();
for (EmployeeRoleEntity employeeRoleEntity : workEmployeeRoleUpdateList) {
employeeRoleEntity.setUpdateBy("SYS");
employeeRoleEntity.setUpdateTime(now);
employeeRoleEntity.setDeleteTag("0");
employeeRoleMapper.updateById(employeeRoleEntity);
}
log.info("==========结束 执行数据修改==========");
return assetsArrayList;
}
}