Ver código fonte

人员组织

wangchangsheng 2 anos atrás
pai
commit
4777d58500

+ 14 - 5
ims-service/ims-eval/src/main/java/com/ims/eval/controller/OrganizationStructureController.java

@@ -3,15 +3,12 @@ package com.ims.eval.controller;
 
 import com.ims.eval.dao.result.R;
 import com.ims.eval.entity.EvaluateRuleInfo;
+import com.ims.eval.entity.OrganizationEvaluationRule;
 import com.ims.eval.entity.OrganizationStructure;
 import com.ims.eval.service.IOrganizationStructureService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -52,4 +49,16 @@ public class OrganizationStructureController {
 		}
 	}
 
+
+	@GetMapping(value = "getTree")
+	public R getTree(
+		@RequestParam(value = "id", required = false) String id,
+		@RequestParam(value = "num", required = false) Integer num,
+		@RequestParam(value = "type", required = false) String type) {
+		List<OrganizationStructure> list = organizationStructureService.getTree(id,num,type);
+		return R.ok().data(list);
+	}
+
+
+
 }

+ 83 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/controller/UserController.java

@@ -0,0 +1,83 @@
+package com.ims.eval.controller;
+
+
+import com.ims.eval.dao.result.R;
+import com.ims.eval.entity.Myuser;
+import com.ims.eval.entity.OrganizationEvaluationRule;
+import com.ims.eval.service.IUserService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * <p>
+ * 前端控制器
+ * </p>
+ *
+ * @author wang
+ * @since 2023-03-03
+ */
+@RestController
+@RequestMapping("//user")
+public class UserController {
+
+	@Autowired
+	private IUserService userService;
+
+
+	//@ImsPreAuth("eval:dataDictionary:edit")
+	@PostMapping(value = "/save")
+	@ApiOperation(value = "新增(修改)", notes = "新增(修改)")
+	public R addAll(@RequestBody List<Myuser> user) {
+
+
+		AtomicBoolean b = new AtomicBoolean(false);
+		user.stream().forEach(i -> {
+
+		b.set(userService.saveOrUpdate(i));
+
+		});
+
+
+		if (b.get()) {
+			return R.ok().data(b);
+		} else {
+			return R.error().data("保存失败!");
+		}
+	}
+
+
+	/**
+	 * 查询所有数据
+	 * @param id 主键
+	 * @param orgId 组织id
+	 * @return
+	 */
+	//@ImsPreAuth("eval:organizationEvaluationRule:view")
+	@GetMapping(value = "listAll")
+	public R listAll(
+		@RequestParam(value = "id", required = false) String id,
+		@RequestParam(value = "orgId", required = false) String orgId,
+		@RequestParam(value = "unitId", required = false) String unitId) {
+		List<Myuser> list = userService.listAll(id, orgId,unitId);
+		return R.ok().data(list);
+	}
+
+
+	/**
+	 * 查询所有数据
+	 * @param id 主键
+	 * @return
+	 */
+	//@ImsPreAuth("eval:organizationEvaluationRule:view")
+	@GetMapping(value = "getId")
+	public R getByid(
+		@RequestParam(value = "id", required = false) String id) {
+		Myuser user = userService.getById(id);
+		return R.ok().data(user);
+	}
+
+}

+ 16 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/dao/UserMapper.java

@@ -0,0 +1,16 @@
+package com.ims.eval.dao;
+
+import com.ims.eval.entity.Myuser;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author wang
+ * @since 2023-03-03
+ */
+public interface UserMapper extends BaseMapper<Myuser> {
+
+}

+ 106 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/Myuser.java

@@ -0,0 +1,106 @@
+package com.ims.eval.entity;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import java.util.Date;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author wang
+ * @since 2023-03-03
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class Myuser extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    private String name;
+
+    private String mainPosName;
+
+    private String deptName;
+
+    private String orgId;
+
+    private String orgName;
+
+    private String unitId;
+
+    private String unitName;
+
+    private Boolean admin;
+
+    private Integer age;
+
+    private String companyId;
+
+    private String createBy;
+
+    private String createDate;
+
+    private String dbName;
+
+    private String delFlag;
+
+    private String deptId;
+
+    private String education;
+
+    private String email;
+
+    private String faceimageUrl;
+
+    private String gender;
+
+    private String isNewRecord;
+
+    private String loginFlag;
+
+    private String loginIp;
+
+    private String loginName;
+
+    private String mainPosCode;
+
+    private String mainposId;
+
+    private String mobile;
+
+    private String nation;
+
+    private String no;
+
+    private String oldLoginIp;
+
+    private double partyCost;
+
+    private String phone;
+
+    private String photo;
+
+    private String posCode;
+
+    private String remarks;
+
+    private String residence;
+
+    private String roleNames;
+
+    private String token;
+
+    private String updateBy;
+
+    private Date updateDate;
+
+    private String userType;
+
+
+}

+ 9 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/OrganizationStructure.java

@@ -1,9 +1,12 @@
 package com.ims.eval.entity;
 
 import java.math.BigDecimal;
+
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import java.time.LocalDateTime;
 import java.util.Date;
+import java.util.List;
 
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -102,5 +105,11 @@ public class OrganizationStructure extends Model {
 
     private String status;
 
+	/**
+	 * 子节点
+	 */
+	@TableField(exist = false)
+	private List<OrganizationStructure> children;
+
 
 }

+ 3 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/IOrganizationStructureService.java

@@ -3,6 +3,8 @@ package com.ims.eval.service;
 import com.ims.eval.entity.OrganizationStructure;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  *  服务类
@@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IOrganizationStructureService extends IService<OrganizationStructure> {
 
+	List<OrganizationStructure> getTree(String id,Integer num,String type );
 }

+ 20 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/IUserService.java

@@ -0,0 +1,20 @@
+package com.ims.eval.service;
+
+import com.ims.eval.entity.Myuser;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author wang
+ * @since 2023-03-03
+ */
+public interface IUserService extends IService<Myuser> {
+
+	List<Myuser> listAll(String id, String orgId,String unitId);
+
+}

+ 91 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationStructureServiceImpl.java

@@ -1,14 +1,22 @@
 package com.ims.eval.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ims.common.utils.StringUtils;
+import com.ims.eval.entity.OrganizationEvaluationRule;
 import com.ims.eval.entity.OrganizationStructure;
 import com.ims.eval.dao.OrganizationStructureMapper;
 import com.ims.eval.service.IOrganizationStructureService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author wang
@@ -17,4 +25,86 @@ import org.springframework.stereotype.Service;
 @Service
 public class OrganizationStructureServiceImpl extends ServiceImpl<OrganizationStructureMapper, OrganizationStructure> implements IOrganizationStructureService {
 
+	private static Integer length = 0;
+
+	private static String type = null;
+
+	@Override
+	public List<OrganizationStructure> getTree(String id, Integer num, String type1) {
+
+		if (null != type1 && type1.length()>0){
+			type = type1;
+		}
+
+		QueryWrapper<OrganizationStructure> qw = new QueryWrapper<>();
+
+		List<OrganizationStructure> list = baseMapper.selectList(qw);
+		List<OrganizationStructure> tr = convert(list, id, num);
+		return tr;
+	}
+
+	/**
+	 * 转换为有树形结构的列表
+	 *
+	 * @param source 源数据所有数据
+	 * @return
+	 */
+	public List<OrganizationStructure> convert(List<OrganizationStructure> source, String id, Integer num) {
+		if (CollectionUtil.isEmpty(source)) {
+			return new ArrayList<>();
+		}
+		List<OrganizationStructure> result = new ArrayList<>();
+		List<String> idList = new ArrayList<>();
+		if (null == id || id.length() <= 0) {
+			idList = source.stream().map(OrganizationStructure::getId).collect(Collectors.toList());
+			// 设置最外层顶级
+			for (OrganizationStructure domainTreeSelectVO : source) {
+				// 判断所有列表里面父级未在集合中放置到一级
+				if (!idList.contains(domainTreeSelectVO.getParentId())) {
+
+					result.add(domainTreeSelectVO);
+				}
+			}
+		} else {
+//			List<OrganizationStructure> list =baseMapper.selectById(id);
+			result.add(this.baseMapper.selectById(id));
+
+		}
+
+
+		for (OrganizationStructure domainTreeSelectVO : result) {
+			// 循环一级之后子级
+			length = num + domainTreeSelectVO.getParentIds().split(",").length;
+			getChildren(source, domainTreeSelectVO);
+		}
+		return result;
+	}
+
+
+	/**
+	 * 循环设置子级
+	 *
+	 * @param list         所有元素列表
+	 * @param treeSelectVO 父级元素
+	 * @return 父级元素
+	 */
+	public static OrganizationStructure getChildren(List<OrganizationStructure> list, OrganizationStructure treeSelectVO) {
+
+		for (OrganizationStructure domainTreeSelectVO : list) {
+			if (treeSelectVO.getId().equals(domainTreeSelectVO.getParentId())) {
+				List<OrganizationStructure> children = CollectionUtil.isEmpty(treeSelectVO.getChildren()) ? new ArrayList<>() : treeSelectVO.getChildren();
+				if (null != type && !type.equals(domainTreeSelectVO.getType())) {
+					continue;
+				}
+
+				if (null != length && length < domainTreeSelectVO.getParentIds().split(",").length) {
+					continue;
+				}
+				children.add(getChildren(list, domainTreeSelectVO));
+				treeSelectVO.setChildren(children);
+
+			}
+		}
+		return treeSelectVO;
+	}
 }

+ 46 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/UserServiceImpl.java

@@ -0,0 +1,46 @@
+package com.ims.eval.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ims.common.utils.StringUtils;
+import com.ims.eval.entity.Myuser;
+import com.ims.eval.dao.UserMapper;
+import com.ims.eval.entity.PersonnelEvaluationRule;
+import com.ims.eval.service.IUserService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 服务实现类
+ * </p>
+ *
+ * @author wang
+ * @since 2023-03-03
+ */
+@Service
+public class UserServiceImpl extends ServiceImpl<UserMapper, Myuser> implements IUserService {
+
+	@Override
+	public List<Myuser> listAll(String id, String orgId,String unitId) {
+
+		QueryWrapper<Myuser> qw = new QueryWrapper<>();
+
+		if (StringUtils.isNotEmpty(id)) {
+			qw.lambda().eq(Myuser::getId, id);
+		}
+
+		if (StringUtils.isNotEmpty(orgId)) {
+			qw.lambda().like(Myuser::getOrgId, orgId);
+		}
+
+		if (StringUtils.isNotEmpty(unitId)) {
+			qw.lambda().like(Myuser::getUnitId, unitId);
+		}
+
+		List<Myuser> list = baseMapper.selectList(qw);
+
+		return list;
+	}
+}