From 6ef8b2124b86c940c29875a8d0b1657c1323e910 Mon Sep 17 00:00:00 2001 From: wulin Date: Thu, 3 Sep 2020 19:00:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=91=98=E5=B7=A5=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/EmployeeController.java | 135 ++++++++++++++++++ .../entity/model/FindEmployeeResModel.java | 35 +++++ 2 files changed, 170 insertions(+) create mode 100644 src/main/java/com/lz/modules/equipment/controller/EmployeeController.java create mode 100644 src/main/java/com/lz/modules/equipment/entity/model/FindEmployeeResModel.java diff --git a/src/main/java/com/lz/modules/equipment/controller/EmployeeController.java b/src/main/java/com/lz/modules/equipment/controller/EmployeeController.java new file mode 100644 index 00000000..2001294d --- /dev/null +++ b/src/main/java/com/lz/modules/equipment/controller/EmployeeController.java @@ -0,0 +1,135 @@ +package com.lz.modules.equipment.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.lz.common.utils.R; +import com.lz.common.utils.RedisUtils; +import com.lz.common.utils.StringUtil; +import com.lz.modules.app.annotation.Login; +import com.lz.modules.app.entity.StaffEntity; +import com.lz.modules.app.service.StaffService; +import com.lz.modules.equipment.entity.EquipmentInfo; +import com.lz.modules.equipment.entity.SpecialApplyInfo; +import com.lz.modules.equipment.entity.model.FindByNameModel; +import com.lz.modules.equipment.entity.model.FindEmployeeResModel; +import com.lz.modules.equipment.entity.model.FindEquipmentResModel; +import com.lz.modules.equipment.entity.model.FindEquipmentsByNameModel; +import com.lz.modules.equipment.service.IEquipmentInfoService; +import com.lz.modules.equipment.service.SpecialApplyInfoService; +import com.lz.modules.sys.controller.AbstractController; +import com.lz.modules.sys.oauth2.TokenGenerator; +import io.swagger.annotations.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.util.CollectionUtils; +import org.springframework.util.DigestUtils; +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 javax.validation.Valid; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: djc + * @Desc: + * @Date: 2020/7/24 17:21 + */ +@Slf4j +@RestController +@RequestMapping("api") +@Api(value = "员工相关接口", tags = { "Employees" }) +public class EmployeeController extends AbstractController { + + @Autowired + private StaffService staffService; + @Autowired + private RedisUtils redisUtils; + @Autowired + private SpecialApplyInfoService specialApplyInfoService; + @Autowired + private IEquipmentInfoService iEquipmentInfoService; + + @PostMapping("findEmployeeByName") + public R findEmployeeByName(@RequestBody @ApiParam FindByNameModel nameModel){ + List data = new ArrayList<>(); + Page employeesInfoPage = staffService.selectPage( + new Page<>(nameModel.getCurrPage(), nameModel.getPageSize()), + new EntityWrapper() + .eq("is_delete",0) + .like(StringUtil.isNotBlank(nameModel.getName()),"name",nameModel.getName())); + if(CollectionUtils.isEmpty(employeesInfoPage.getRecords())){ + return R.ok(); + } + employeesInfoPage.getRecords().stream().forEach(employeesInfo -> { + FindEmployeeResModel model = new FindEmployeeResModel(); + BeanUtils.copyProperties(employeesInfo,model); + model.setUserId(employeesInfo.getId()); + data.add(model); + }); + Page list = new Page<>(); + list.setTotal(employeesInfoPage.getPages()); + //list.setTotal(employeesInfoPage.getTotal()); + //list.setSize(employeesInfoPage.getSize()); + //long pages = list.getPages(); + list.setRecords(data); + return R.ok().put("data", list); + + } + + @PostMapping("findSpecialApplyByName") + public R findSpecialApplyByName(@RequestBody @ApiParam FindByNameModel nameModel){ + List data = new ArrayList<>(); + Page specialApplyInfoPage = specialApplyInfoService.selectPage( + new Page<>(nameModel.getCurrPage(), nameModel.getPageSize()), + new EntityWrapper() + .eq("is_delete", 0) + .like(StringUtil.isNotBlank(nameModel.getName()), "type_desc", nameModel.getName())); + + if(CollectionUtils.isEmpty(specialApplyInfoPage.getRecords())){ + return R.ok(); + } + specialApplyInfoPage.getRecords().stream().forEach(specialApplyInfo -> { + FindEmployeeResModel model = new FindEmployeeResModel(); + model.setUserId(specialApplyInfo.getId()); + model.setName(specialApplyInfo.getTypeDesc()); + data.add(model); + }); + Page list = new Page<>(); + list.setTotal(specialApplyInfoPage.getPages()); + list.setRecords(data); + return R.ok().put("data", list); + + } + + + @PostMapping("findUsersEquipmentsByName") + public R findUsersEquipmentsByName(@RequestBody @ApiParam FindEquipmentsByNameModel nameModel){ + Page data = new Page<>(); + Page equipmentInfoPage = iEquipmentInfoService.selectPage( + new Page<>(nameModel.getCurrPage(), nameModel.getPageSize()), + new EntityWrapper() + .eq("is_delete", 0) + .eq(nameModel.isEmployee(), "user_id", nameModel.getUserId()) + .eq(!nameModel.isEmployee(), "sai_id", nameModel.getUserId())); + + List records = equipmentInfoPage.getRecords(); + if(CollectionUtils.isEmpty(records)){ + return R.ok(); + } + List list = records.stream().map(info -> { + FindEquipmentResModel model = new FindEquipmentResModel(); + BeanUtils.copyProperties(info, model); + return model; + }).collect(Collectors.toList()); + data.setTotal(equipmentInfoPage.getPages()); + data.setRecords(list); + return R.ok().put("data", data); + + } + +} diff --git a/src/main/java/com/lz/modules/equipment/entity/model/FindEmployeeResModel.java b/src/main/java/com/lz/modules/equipment/entity/model/FindEmployeeResModel.java new file mode 100644 index 00000000..278c0166 --- /dev/null +++ b/src/main/java/com/lz/modules/equipment/entity/model/FindEmployeeResModel.java @@ -0,0 +1,35 @@ +package com.lz.modules.equipment.entity.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author: djc + * @Desc: + * @Date: 2020/7/28 17:56 + */ +@Data +@ApiModel(value = "查找用户信息响应") +public class FindEmployeeResModel { + //员工姓名 + @ApiModelProperty(value = "员工姓名", name = "name") + private String name; + //员工id + @ApiModelProperty(value = "员工id", name = "userId") + private Long userId; + //职务 + @ApiModelProperty(value = "职务", name = "job") + private String job; + //一级部门 + @ApiModelProperty(value = "一级部门", name = "oneDepartment") + private String oneDepartment; + //二级部门 + @ApiModelProperty(value = "二级部门", name = "twoDepartment") + private String twoDepartment; + //三级部门 + @ApiModelProperty(value = "三级部门", name = "threeDepartment") + private String threeDepartment; + @ApiModelProperty(value = "手机号", name = "phone") + private String phone; +}