|
@@ -0,0 +1,156 @@
|
|
|
|
|
+package com.ydtech.modules.admin.service.impl;
|
|
|
|
|
+
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.ydtech.modules.admin.dao.SysDeptMapper;
|
|
|
|
|
+import com.ydtech.modules.admin.dao.SysUserLinkFrontLineDeptMapper;
|
|
|
|
|
+import com.ydtech.modules.admin.model.SysDept;
|
|
|
|
|
+import com.ydtech.modules.admin.model.dto.SysUserDto;
|
|
|
|
|
+import com.ydtech.modules.admin.model.dto.SysUserLinkFrontLineDeptDto;
|
|
|
|
|
+import com.ydtech.modules.admin.model.po.SysUserLinkFrontLineDept;
|
|
|
|
|
+import com.ydtech.modules.admin.model.vo.SysAreaVo;
|
|
|
|
|
+import com.ydtech.modules.admin.model.vo.SysUserBaseVO;
|
|
|
|
|
+import com.ydtech.modules.admin.model.vo.SysUserLinkFrontLineDeptAddVo;
|
|
|
|
|
+import com.ydtech.modules.admin.model.vo.SysUserLinkFrontLineDeptQueryVo;
|
|
|
|
|
+import com.ydtech.modules.admin.service.SysUserLinkFrontLineDeptService;
|
|
|
|
|
+import com.ydtech.modules.base.controller.BaseController;
|
|
|
|
|
+import com.ydtech.modules.order.entity.BasePageResult;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+* @author Administrator
|
|
|
|
|
+* @description 针对表【sys_user_link_front_line_dept(后线人员配置内部机构表)】的数据库操作Service实现
|
|
|
|
|
+* @createDate 2024-06-26 17:28:18
|
|
|
|
|
+*/
|
|
|
|
|
+@Service
|
|
|
|
|
+public class SysUserLinkFrontLineDeptServiceImpl extends ServiceImpl<SysUserLinkFrontLineDeptMapper, SysUserLinkFrontLineDept>
|
|
|
|
|
+ implements SysUserLinkFrontLineDeptService {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysUserLinkFrontLineDeptMapper sysUserLinkFrontLineDeptMapper;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysDeptMapper sysDeptMapper;
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @version
|
|
|
|
|
+ * @author: hxl
|
|
|
|
|
+ * @Date: 2024/6/26 18:55
|
|
|
|
|
+ * @Description: 查看前线机构数据
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<SysDept> queryQxOrgTree(String userId) {
|
|
|
|
|
+ List<SysDept> sysDeptAll =new ArrayList<SysDept>();
|
|
|
|
|
+ if(StringUtils.isNotBlank(userId)){
|
|
|
|
|
+ //通过用户查询机构树
|
|
|
|
|
+ sysDeptAll=sysUserLinkFrontLineDeptMapper.findDeptListByUserId(userId);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //查询所有的数据 机构等级 =3 或者 机构等级>2 且机构id 包含M 和D 的机构
|
|
|
|
|
+ sysDeptAll = sysDeptMapper.queryListByQXDept();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<SysDept> resultList =new ArrayList<SysDept>();
|
|
|
|
|
+ List<SysDept> sysDeptTop = sysDeptAll.stream().filter(item ->"3".equals(item.getComlevel())).collect(Collectors.toList());
|
|
|
|
|
+ for (SysDept dept : sysDeptTop) {
|
|
|
|
|
+ resultList.add(buildDeptTree(dept,sysDeptAll));
|
|
|
|
|
+ }
|
|
|
|
|
+ return resultList;
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @version
|
|
|
|
|
+ * @author: hxl
|
|
|
|
|
+ * @Date: 2024/6/27 8:42
|
|
|
|
|
+ * @Description: 获取顶级机构的数据
|
|
|
|
|
+ */
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 递归构建树形结构
|
|
|
|
|
+ */
|
|
|
|
|
+ private SysDept buildDeptTree(SysDept dept, List<SysDept> deptList){
|
|
|
|
|
+ for (SysDept d : deptList) {
|
|
|
|
|
+ if (dept.getId().equals(d.getParentId())) {
|
|
|
|
|
+ if (null == dept.getChildren()) {
|
|
|
|
|
+ dept.setChildren(new ArrayList<SysDept>());
|
|
|
|
|
+ }
|
|
|
|
|
+ //递归调用
|
|
|
|
|
+ dept.getChildren().add(buildDeptTree(d, deptList));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return dept;
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @version
|
|
|
|
|
+ * @author: hxl
|
|
|
|
|
+ * @Date: 2024/6/26 18:55
|
|
|
|
|
+ * @Description: 添加或修改
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void addOrUpdate(SysUserLinkFrontLineDeptAddVo sysUserLinkFrontLineDeptAddVo) {
|
|
|
|
|
+ String userId = sysUserLinkFrontLineDeptAddVo.getUserId();
|
|
|
|
|
+ List<String> deptIds = sysUserLinkFrontLineDeptAddVo.getDeptIds();
|
|
|
|
|
+ //删除数据重新添加
|
|
|
|
|
+ sysUserLinkFrontLineDeptMapper.deleteByUserId(userId);
|
|
|
|
|
+ List<SysUserLinkFrontLineDept> addList= new ArrayList<>();
|
|
|
|
|
+ //重新添加
|
|
|
|
|
+ if(deptIds!=null && deptIds.size()>0){
|
|
|
|
|
+ for (String deptId : deptIds) {
|
|
|
|
|
+ SysUserLinkFrontLineDept add=new SysUserLinkFrontLineDept(userId,deptId,new Date(),
|
|
|
|
|
+ new BaseController().getUser().getId(),new Date(),new BaseController().getUser().getId());
|
|
|
|
|
+ addList.add(add);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ this.saveBatch(addList);
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @version
|
|
|
|
|
+ * @author: hxl
|
|
|
|
|
+ * @Date: 2024/6/26 18:56
|
|
|
|
|
+ * @Description: 删除
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void deleteByIds(List<String> ids) {
|
|
|
|
|
+ sysUserLinkFrontLineDeptMapper.deleteBatchIds(ids);
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @version
|
|
|
|
|
+ * @author: hxl
|
|
|
|
|
+ * @Date: 2024/6/26 18:56
|
|
|
|
|
+ * @Description: 查询对象
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<SysAreaVo> findSysUserLinkFrontLineDeptById(String id) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @version
|
|
|
|
|
+ * @author: hxl
|
|
|
|
|
+ * @Date: 2024/6/26 18:56
|
|
|
|
|
+ * @Description: 分页
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public BasePageResult<SysUserLinkFrontLineDeptDto> queryPage(SysUserLinkFrontLineDeptQueryVo sysUserLinkFrontLineDeptQueryVo) {
|
|
|
|
|
+ Page<SysUserLinkFrontLineDeptDto> page = new Page<>(sysUserLinkFrontLineDeptQueryVo.getPageNum(),
|
|
|
|
|
+ sysUserLinkFrontLineDeptQueryVo.getPageSize());
|
|
|
|
|
+ Page<SysUserLinkFrontLineDeptDto> pageResult = sysUserLinkFrontLineDeptMapper.queryPage(page, sysUserLinkFrontLineDeptQueryVo);
|
|
|
|
|
+ return new BasePageResult<>(sysUserLinkFrontLineDeptQueryVo.getPageNum(), page.getSize(), pageResult.getTotal(), page.getPages(),
|
|
|
|
|
+ pageResult.getRecords());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public BasePageResult<SysUserBaseVO> findUserListByPage(SysUserDto sysUserDto) {
|
|
|
|
|
+ Page<SysUserBaseVO> page = new Page<>(sysUserDto.getPageNum(),
|
|
|
|
|
+ sysUserDto.getPageSize());
|
|
|
|
|
+ Page<SysUserBaseVO> userPageResult = sysUserLinkFrontLineDeptMapper.findUserListByDeptPage(page, sysUserDto);
|
|
|
|
|
+ return new BasePageResult<>(sysUserDto.getPageNum(), page.getSize(), userPageResult.getTotal(), page.getPages(),
|
|
|
|
|
+ userPageResult.getRecords());
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|