inleft
2022-02-09 9bcb19959eeb9da9bde2561e7278f6d0a55eb151
commit | author | age
9bcb19 1 /*
I 2 Copyright [2020] [https://www.xiaonuo.vip]
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8   http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
17
18 1.请不要删除和修改根目录下的LICENSE文件。
19 2.请不要删除和修改Snowy源码头部的版权声明。
20 3.请保留源码和相关描述文件的项目出处,作者声明等。
21 4.分发源码时候,请注明软件出处 https://gitee.com/xiaonuobase/snowy
22 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/xiaonuobase/snowy
23 6.若您的项目无法满足以上几点,可申请商业授权,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
24  */
25 package vip.xiaonuo.sys.modular.emp.service.impl;
26
27 import cn.hutool.core.collection.CollectionUtil;
28 import cn.hutool.core.lang.Dict;
29 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
30 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
31 import org.springframework.stereotype.Service;
32 import vip.xiaonuo.sys.modular.emp.entity.SysEmpExtOrgPos;
33 import vip.xiaonuo.sys.modular.emp.mapper.SysEmpExtOrgPosMapper;
34 import vip.xiaonuo.sys.modular.emp.service.SysEmpExtOrgPosService;
35 import vip.xiaonuo.sys.modular.org.entity.SysOrg;
36 import vip.xiaonuo.sys.modular.org.service.SysOrgService;
37 import vip.xiaonuo.sys.modular.pos.entity.SysPos;
38 import vip.xiaonuo.sys.modular.pos.service.SysPosService;
39
40 import javax.annotation.Resource;
41 import java.util.List;
42
43 /**
44  * 员工附属机构service接口实现类
45  *
46  * @author xuyuxiang
47  * @date 2020/3/13 15:11
48  */
49 @Service
50 public class SysEmpExtOrgPosPosServiceImpl extends ServiceImpl<SysEmpExtOrgPosMapper, SysEmpExtOrgPos> implements SysEmpExtOrgPosService {
51
52     @Resource
53     private SysOrgService sysOrgService;
54
55     @Resource
56     private SysPosService sysPosService;
57
58     /**
59      * 附属机构id参数键
60      */
61     private static final String EXT_ORG_ID_DICT_KEY = "orgId";
62
63     /**
64      * 附属机构编码参数键
65      */
66     private static final String EXT_ORG_CODE_DICT_KEY = "orgCode";
67
68     /**
69      * 附属机构名称参数键
70      */
71     private static final String EXT_ORG_NAME_DICT_KEY = "orgName";
72
73     /**
74      * 附属职位id参数键
75      */
76     private static final String EXT_POS_ID_DICT_KEY = "posId";
77
78     /**
79      * 附属职位编码参数键
80      */
81     private static final String EXT_POS_CODE_DICT_KEY = "posCode";
82
83     /**
84      * 附属职位名称参数键
85      */
86     private static final String EXT_POS_NAME_DICT_KEY = "posName";
87
88     @Override
89     public void addOrEdit(Long empId, List<Dict> extIdList) {
90         LambdaQueryWrapper<SysEmpExtOrgPos> queryWrapper = new LambdaQueryWrapper<>();
91         queryWrapper.eq(SysEmpExtOrgPos::getEmpId, empId);
92         //删除附属信息
93         this.remove(queryWrapper);
94         //保存附属信息
95         extIdList.forEach(dict -> {
96             Long orgId = dict.getLong(EXT_ORG_ID_DICT_KEY);
97             Long posId = dict.getLong(EXT_POS_ID_DICT_KEY);
98             SysEmpExtOrgPos sysEmpExtOrgPos = new SysEmpExtOrgPos();
99             sysEmpExtOrgPos.setEmpId(empId);
100             sysEmpExtOrgPos.setOrgId(orgId);
101             sysEmpExtOrgPos.setPosId(posId);
102             this.save(sysEmpExtOrgPos);
103         });
104     }
105
106     @Override
107     public List<Dict> getEmpExtOrgPosDictList(Long empId, boolean isFillId) {
108         List<Dict> dictList = CollectionUtil.newArrayList();
109
110         LambdaQueryWrapper<SysEmpExtOrgPos> queryWrapper = new LambdaQueryWrapper<>();
111         queryWrapper.eq(SysEmpExtOrgPos::getEmpId, empId);
112
113         this.list(queryWrapper).forEach(sysEmpExtOrgPos -> {
114             Dict dict = Dict.create();
115             Long orgId = sysEmpExtOrgPos.getOrgId();
116             SysOrg sysOrg = sysOrgService.getById(orgId);
117             dict.put(EXT_ORG_CODE_DICT_KEY, sysOrg.getCode());
118             dict.put(EXT_ORG_NAME_DICT_KEY, sysOrg.getName());
119
120             Long posId = sysEmpExtOrgPos.getPosId();
121             SysPos sysPos = sysPosService.getById(posId);
122             dict.put(EXT_POS_CODE_DICT_KEY, sysPos.getCode());
123             dict.put(EXT_POS_NAME_DICT_KEY, sysPos.getName());
124
125             if (isFillId) {
126                 dict.put(EXT_ORG_ID_DICT_KEY, orgId);
127                 dict.put(EXT_POS_ID_DICT_KEY, posId);
128             }
129             dictList.add(dict);
130         });
131
132         return dictList;
133     }
134
135     @Override
136     public boolean hasExtOrgEmp(Long orgId) {
137         LambdaQueryWrapper<SysEmpExtOrgPos> queryWrapper = new LambdaQueryWrapper<>();
138         queryWrapper.eq(SysEmpExtOrgPos::getOrgId, orgId);
139         List<SysEmpExtOrgPos> list = this.list(queryWrapper);
140         return list.size() != 0;
141     }
142
143     @Override
144     public boolean hasExtPosEmp(Long posId) {
145         LambdaQueryWrapper<SysEmpExtOrgPos> queryWrapper = new LambdaQueryWrapper<>();
146         queryWrapper.eq(SysEmpExtOrgPos::getPosId, posId);
147         List<SysEmpExtOrgPos> list = this.list(queryWrapper);
148         return list.size() != 0;
149     }
150
151     @Override
152     public void deleteEmpExtInfoByUserId(Long empId) {
153         LambdaQueryWrapper<SysEmpExtOrgPos> queryWrapper = new LambdaQueryWrapper<>();
154         queryWrapper.eq(SysEmpExtOrgPos::getEmpId, empId);
155         this.remove(queryWrapper);
156     }
157 }