Forráskód Böngészése

优化员工查询功能

wuxw 6 éve%!(EXTRA string=óta)
szülő
commit
cd275c49fc

+ 66 - 5
Api/src/main/java/com/java110/api/listener/users/QueryStaffServiceListener.java

@@ -3,18 +3,30 @@ package com.java110.api.listener.users;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.api.listener.AbstractServiceApiDataFlowListener;
 import com.java110.api.listener.AbstractServiceApiDataFlowListener;
+import com.java110.api.listener.AbstractServiceApiListener;
+import com.java110.core.smo.user.IUserInnerServiceSMO;
+import com.java110.dto.UserDto;
+import com.java110.dto.org.OrgDto;
 import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.constant.ServiceCodeConstant;
 import com.java110.utils.constant.ServiceCodeConstant;
 import com.java110.utils.exception.ListenerExecuteException;
 import com.java110.utils.exception.ListenerExecuteException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
 import com.java110.utils.util.StringUtil;
 import com.java110.utils.util.StringUtil;
 import com.java110.core.annotation.Java110Listener;
 import com.java110.core.annotation.Java110Listener;
 import com.java110.core.context.DataFlowContext;
 import com.java110.core.context.DataFlowContext;
 import com.java110.core.factory.DataFlowFactory;
 import com.java110.core.factory.DataFlowFactory;
 import com.java110.entity.center.AppService;
 import com.java110.entity.center.AppService;
 import com.java110.event.service.api.ServiceDataFlowEvent;
 import com.java110.event.service.api.ServiceDataFlowEvent;
+import com.java110.vo.api.org.ApiOrgDataVo;
+import com.java110.vo.api.org.ApiOrgVo;
+import com.java110.vo.api.staff.ApiStaffDataVo;
+import com.java110.vo.api.staff.ApiStaffVo;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.*;
 import org.springframework.http.*;
 
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -22,12 +34,18 @@ import java.util.Map;
  * Created by Administrator on 2019/4/2.
  * Created by Administrator on 2019/4/2.
  */
  */
 @Java110Listener("queryStaffServiceListener")
 @Java110Listener("queryStaffServiceListener")
-public class QueryStaffServiceListener extends AbstractServiceApiDataFlowListener {
+public class QueryStaffServiceListener extends AbstractServiceApiListener {
+
+    @Autowired
+    private IUserInnerServiceSMO userInnerServiceSMOImpl;
+
     @Override
     @Override
     public int getOrder() {
     public int getOrder() {
         return 0;
         return 0;
     }
     }
 
 
+
+
     @Override
     @Override
     public String getServiceCode() {
     public String getServiceCode() {
         return ServiceCodeConstant.SERVICE_CODE_QUERY_STAFF_INFOS;
         return ServiceCodeConstant.SERVICE_CODE_QUERY_STAFF_INFOS;
@@ -42,13 +60,13 @@ public class QueryStaffServiceListener extends AbstractServiceApiDataFlowListene
      *
      *
      * @param event
      * @param event
      */
      */
-    @Override
-    public void soService(ServiceDataFlowEvent event) {
+
+    public void soService1(ServiceDataFlowEvent event) {
 
 
 
 
         DataFlowContext dataFlowContext = event.getDataFlowContext();
         DataFlowContext dataFlowContext = event.getDataFlowContext();
         AppService service = event.getAppService();
         AppService service = event.getAppService();
-        Map<String,String> headers = dataFlowContext.getRequestHeaders();
+        /*Map<String,String> headers = dataFlowContext.getRequestHeaders();
 
 
         Assert.hasKeyAndValue(headers,"page","请求报文中未包含page节点");
         Assert.hasKeyAndValue(headers,"page","请求报文中未包含page节点");
         Assert.hasKeyAndValue(headers,"rows","请求报文中未包含rows节点");
         Assert.hasKeyAndValue(headers,"rows","请求报文中未包含rows节点");
@@ -92,9 +110,43 @@ public class QueryStaffServiceListener extends AbstractServiceApiDataFlowListene
             JSONObject tmpObj = rows.getJSONObject(rowIndex);
             JSONObject tmpObj = rows.getJSONObject(rowIndex);
             queryUserInfoByUserId(dataFlowContext,tmpObj,appService);
             queryUserInfoByUserId(dataFlowContext,tmpObj,appService);
         }
         }
-
         dataFlowContext.setResponseEntity(new ResponseEntity(staffs.toJSONString(),HttpStatus.OK));
         dataFlowContext.setResponseEntity(new ResponseEntity(staffs.toJSONString(),HttpStatus.OK));
 
 
+*/
+
+    }
+
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+        Assert.hasKeyAndValue(reqJson,"page","请求报文中未包含page节点");
+        Assert.hasKeyAndValue(reqJson,"rows","请求报文中未包含rows节点");
+        Assert.hasKeyAndValue(reqJson,"storeId","请求报文中未包含storeId节点");
+    }
+
+    @Override
+    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
+
+        UserDto userDto = BeanConvertUtil.covertBean(reqJson, UserDto.class);
+
+        int count = userInnerServiceSMOImpl.getStaffCount(userDto);
+
+        List<ApiStaffDataVo> staffs = null;
+
+        if (count > 0) {
+            staffs = BeanConvertUtil.covertBeanList(userInnerServiceSMOImpl.getStaffs(userDto), ApiStaffDataVo.class);
+        } else {
+            staffs = new ArrayList<>();
+        }
+
+        ApiStaffVo apiStaffVo = new ApiStaffVo();
+
+        apiStaffVo.setTotal(count);
+        apiStaffVo.setRecords((int) Math.ceil((double) count / (double) reqJson.getInteger("row")));
+        apiStaffVo.setStaffs(staffs);
+
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiStaffVo), HttpStatus.OK);
+
+        context.setResponseEntity(responseEntity);
     }
     }
 
 
     /**
     /**
@@ -127,4 +179,13 @@ public class QueryStaffServiceListener extends AbstractServiceApiDataFlowListene
         }
         }
         tmpObj.putAll(JSONObject.parseObject(responseEntity.getBody().toString()));
         tmpObj.putAll(JSONObject.parseObject(responseEntity.getBody().toString()));
     }
     }
+
+
+    public IUserInnerServiceSMO getUserInnerServiceSMOImpl() {
+        return userInnerServiceSMOImpl;
+    }
+
+    public void setUserInnerServiceSMOImpl(IUserInnerServiceSMO userInnerServiceSMOImpl) {
+        this.userInnerServiceSMOImpl = userInnerServiceSMOImpl;
+    }
 }
 }

+ 18 - 0
UserService/src/main/java/com/java110/user/dao/IUserServiceDao.java

@@ -349,4 +349,22 @@ public interface IUserServiceDao {
      * @throws DAOException 数据处理异常
      * @throws DAOException 数据处理异常
      */
      */
     public void updateUserCredentialsInstance(Map businessUserCredentials) throws DAOException;
     public void updateUserCredentialsInstance(Map businessUserCredentials) throws DAOException;
+
+    /**
+     * 查询员工总量
+     * @param businessUser
+     * @return
+     * @throws DAOException
+     */
+    public int getStaffCount(Map businessUser) throws DAOException;
+
+
+    /**
+     * 查询组织信息(instance过程)
+     * 根据bId 查询组织信息
+     * @param info bId 信息
+     * @return 组织信息
+     * @throws DAOException DAO异常
+     */
+    List<Map> getStaffs(Map info) throws DAOException;
 }
 }

+ 21 - 0
UserService/src/main/java/com/java110/user/dao/impl/UserServiceDaoImpl.java

@@ -648,4 +648,25 @@ public class UserServiceDaoImpl extends BaseServiceDao implements IUserServiceDa
             throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "修改用户Instance数据失败:" + JSONObject.toJSONString(businessUserCredentials));
             throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "修改用户Instance数据失败:" + JSONObject.toJSONString(businessUserCredentials));
         }
         }
     }
     }
+
+    @Override
+    public int getStaffCount(Map businessUser) throws DAOException {
+        logger.debug("查询组织数据 入参 info : {}",businessUser);
+
+        List<Map> businessStaffInfos = sqlSessionTemplate.selectList("userServiceDaoImpl.getStaffCount", businessUser);
+        if (businessStaffInfos.size() < 1) {
+            return 0;
+        }
+
+        return Integer.parseInt(businessStaffInfos.get(0).get("count").toString());
+    }
+
+    @Override
+    public List<Map> getStaffs(Map info) throws DAOException {
+        logger.debug("查询组织信息 入参 info : {}",info);
+
+        List<Map> businessStaffs = sqlSessionTemplate.selectList("userServiceDaoImpl.getStaffs",info);
+
+        return businessStaffs;
+    }
 }
 }

+ 25 - 0
UserService/src/main/java/com/java110/user/smo/impl/UserInnerServiceSMOImpl.java

@@ -1,11 +1,14 @@
 package com.java110.user.smo.impl;
 package com.java110.user.smo.impl;
 
 
+import com.java110.dto.PageDto;
+import com.java110.dto.org.OrgDto;
 import com.java110.utils.constant.StatusConstant;
 import com.java110.utils.constant.StatusConstant;
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.core.smo.user.IUserInnerServiceSMO;
 import com.java110.core.smo.user.IUserInnerServiceSMO;
 import com.java110.dto.UserDto;
 import com.java110.dto.UserDto;
 import com.java110.user.dao.IUserServiceDao;
 import com.java110.user.dao.IUserServiceDao;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
@@ -42,6 +45,28 @@ public class UserInnerServiceSMOImpl implements IUserInnerServiceSMO {
         return BeanConvertUtil.covertBeanList(userServiceDaoImpl.queryUsersInfo(userInfo), UserDto.class);
         return BeanConvertUtil.covertBeanList(userServiceDaoImpl.queryUsersInfo(userInfo), UserDto.class);
     }
     }
 
 
+    @Override
+    public int getStaffCount(@RequestBody UserDto userDto) {
+
+        return userServiceDaoImpl.getStaffCount(BeanConvertUtil.beanCovertMap(userDto));
+    }
+
+    @Override
+    public List<UserDto> getStaffs(@RequestBody UserDto userDto) {
+        //校验是否传了 分页信息
+
+        int page = userDto.getPage();
+
+        if (page != PageDto.DEFAULT_PAGE) {
+            userDto.setPage((page - 1) * userDto.getRow());
+        }
+
+        List<UserDto> staffs = BeanConvertUtil.covertBeanList(userServiceDaoImpl.getStaffs(BeanConvertUtil.beanCovertMap(userDto)), UserDto.class);
+
+
+        return staffs;
+    }
+
 
 
     public IUserServiceDao getUserServiceDaoImpl() {
     public IUserServiceDao getUserServiceDaoImpl() {
         return userServiceDaoImpl;
         return userServiceDaoImpl;

+ 3 - 4
WebService/src/main/resources/components/staffPackage/staff-manage/staff.html

@@ -84,12 +84,11 @@
                             <tr>
                             <tr>
                                 <th>员工ID</th>
                                 <th>员工ID</th>
                                 <th>名称</th>
                                 <th>名称</th>
+                                <th>部门</th>
                                 <th>邮箱</th>
                                 <th>邮箱</th>
                                 <th>地址</th>
                                 <th>地址</th>
                                 <th>性别</th>
                                 <th>性别</th>
                                 <th>手机号</th>
                                 <th>手机号</th>
-                                <th>状态</th>
-                                <th>创建时间</th>
                                 <th>操作</th>
                                 <th>操作</th>
                             </tr>
                             </tr>
                             </thead>
                             </thead>
@@ -97,12 +96,12 @@
                             <tr class="gradeX" v-for="staff in staffData">
                             <tr class="gradeX" v-for="staff in staffData">
                                 <td>{{staff.userId}}</td>
                                 <td>{{staff.userId}}</td>
                                 <td>{{staff.name}}</td>
                                 <td>{{staff.name}}</td>
+                                <td>{{staff.orgName}}</td>
                                 <td>{{staff.email}}</td>
                                 <td>{{staff.email}}</td>
                                 <td>{{staff.address}}</td>
                                 <td>{{staff.address}}</td>
                                 <td>{{staff.sex == 0 ? '男' : '女'}}</td>
                                 <td>{{staff.sex == 0 ? '男' : '女'}}</td>
                                 <td>{{staff.tel}}</td>
                                 <td>{{staff.tel}}</td>
-                                <td>{{staff.statusCd == 0 ? '在用':'停用'}}</td>
-                                <td>{{vc.dateFormat(staff.createTime)}}</td>
+
                                 <td>
                                 <td>
                                     <i class="glyphicon glyphicon-edit" style="color: #17a2b8;"
                                     <i class="glyphicon glyphicon-edit" style="color: #17a2b8;"
                                        v-on:click="openEditStaff(staff)"></i>
                                        v-on:click="openEditStaff(staff)"></i>

+ 21 - 1
java110-bean/src/main/java/com/java110/dto/UserDto.java

@@ -10,7 +10,7 @@ import java.io.Serializable;
  * @Version 1.0
  * @Version 1.0
  * add by wuxw 2019/4/24
  * add by wuxw 2019/4/24
  **/
  **/
-public class UserDto extends Dto implements Serializable {
+public class UserDto extends PageDto implements Serializable {
 
 
     private String userId;
     private String userId;
 
 
@@ -32,6 +32,10 @@ public class UserDto extends Dto implements Serializable {
 
 
     private String levelCd;
     private String levelCd;
 
 
+    private String storeId;
+
+    private String orgName;
+
 
 
     public String getUserId() {
     public String getUserId() {
         return userId;
         return userId;
@@ -112,4 +116,20 @@ public class UserDto extends Dto implements Serializable {
     public void setLevelCd(String levelCd) {
     public void setLevelCd(String levelCd) {
         this.levelCd = levelCd;
         this.levelCd = levelCd;
     }
     }
+
+    public String getStoreId() {
+        return storeId;
+    }
+
+    public void setStoreId(String storeId) {
+        this.storeId = storeId;
+    }
+
+    public String getOrgName() {
+        return orgName;
+    }
+
+    public void setOrgName(String orgName) {
+        this.orgName = orgName;
+    }
 }
 }

+ 128 - 0
java110-bean/src/main/java/com/java110/vo/api/staff/ApiStaffDataVo.java

@@ -0,0 +1,128 @@
+package com.java110.vo.api.staff;
+
+import java.io.Serializable;
+
+public class ApiStaffDataVo implements Serializable {
+
+    private String userId;
+
+    private String userName;
+
+    private String tel;
+
+    private String email;
+
+    private String address;
+
+    private String password;
+
+    private String locationCd;
+
+    private int age;
+
+    private String sex;
+
+    private String levelCd;
+
+    private String storeId;
+
+    private String orgName;
+
+
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getTel() {
+        return tel;
+    }
+
+    public void setTel(String tel) {
+        this.tel = tel;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getLocationCd() {
+        return locationCd;
+    }
+
+    public void setLocationCd(String locationCd) {
+        this.locationCd = locationCd;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public String getSex() {
+        return sex;
+    }
+
+    public void setSex(String sex) {
+        this.sex = sex;
+    }
+
+    public String getLevelCd() {
+        return levelCd;
+    }
+
+    public void setLevelCd(String levelCd) {
+        this.levelCd = levelCd;
+    }
+
+    public String getStoreId() {
+        return storeId;
+    }
+
+    public void setStoreId(String storeId) {
+        this.storeId = storeId;
+    }
+
+    public String getOrgName() {
+        return orgName;
+    }
+
+    public void setOrgName(String orgName) {
+        this.orgName = orgName;
+    }
+}

+ 20 - 0
java110-bean/src/main/java/com/java110/vo/api/staff/ApiStaffVo.java

@@ -0,0 +1,20 @@
+package com.java110.vo.api.staff;
+
+import com.java110.vo.MorePageVo;
+import com.java110.vo.api.visit.ApiVisitDataVo;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class ApiStaffVo extends MorePageVo implements Serializable {
+    List<ApiStaffDataVo> staffs;
+
+
+    public List<ApiStaffDataVo> getStaffs() {
+        return staffs;
+    }
+
+    public void setStaffs(List<ApiStaffDataVo> staffs) {
+        this.staffs = staffs;
+    }
+}

+ 23 - 0
java110-core/src/main/java/com/java110/core/smo/user/IUserInnerServiceSMO.java

@@ -3,6 +3,7 @@ package com.java110.core.smo.user;
 import com.java110.core.feign.FeignConfiguration;
 import com.java110.core.feign.FeignConfiguration;
 import com.java110.dto.UserDto;
 import com.java110.dto.UserDto;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -34,4 +35,26 @@ public interface IUserInnerServiceSMO {
      */
      */
     @RequestMapping(value = "/getUserInfo", method = RequestMethod.GET)
     @RequestMapping(value = "/getUserInfo", method = RequestMethod.GET)
     List<UserDto> getUserInfo(@RequestParam("userIds") String[] userIds);
     List<UserDto> getUserInfo(@RequestParam("userIds") String[] userIds);
+
+
+    /**
+     * 查询员工总数
+     *
+     * @param userDto 用户ID
+     *                支持 多个查询
+     * @return 用户封装信息
+     */
+    @RequestMapping(value = "/getStaffCount", method = RequestMethod.GET)
+    int getStaffCount(@RequestBody UserDto userDto);
+
+
+    /**
+     * 查询员工信息
+     *
+     * @param userDto 用户ID
+     *                支持 多个查询
+     * @return 用户封装信息
+     */
+    @RequestMapping(value = "/getStaffs", method = RequestMethod.GET)
+    List<UserDto> getStaffs(@RequestBody UserDto userDto);
 }
 }

+ 57 - 0
java110-db/src/main/resources/mapper/user/UserServiceDaoImplMapper.xml

@@ -431,4 +431,61 @@
             and uc.credentials_id = #{credentialsId}
             and uc.credentials_id = #{credentialsId}
         </if>
         </if>
     </update>
     </update>
+
+    <!-- 查询员工总量 -->
+    <select id="getStaffCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from
+             u_user a
+            ,u_org uo
+            ,u_org_staff_rel uosr
+        where a.level_cd = '01'
+            and a.user_id = uosr.staff_id
+            and uosr.store_id = #{storeId}
+            and uosr.org_id = uo.org_id
+            and uo.parent_org_id = #{parentOrgId}
+            and uo.status_cd = '0'
+            and uosr.status_cd = '0'
+        <if test="tel !=null and tel != ''">
+            and a.tel= #{tel}
+        </if>
+        <if test="name !=null and name != ''">
+            and a.name like contact('%',#{name},'%')
+        </if>
+        <if test="staffId != null and staffId !=''">
+            and uosr.staff_id = #{staffId}
+        </if>
+    </select>
+
+    <!-- 查询员工总量 -->
+    <select id="getStaffs" parameterType="Map" resultType="Map">
+        select uo.org_name,uo.org_name orgName,u.user_id, u.user_id userId,u.name,u.name userName,u.email,u.address,u.password,u.location_cd,u.location_cd locationCd,
+        u.age,u.sex,u.tel,u.level_cd,u.b_id
+        from
+        u_user a
+        ,u_org uo
+        ,u_org_staff_rel uosr
+        where a.level_cd = '01'
+        and a.user_id = uosr.staff_id
+        and uosr.store_id = #{storeId}
+        and uosr.org_id = uo.org_id
+        and uo.parent_org_id = #{parentOrgId}
+        and a.status_cd = '0'
+        and uo.status_cd = '0'
+        and uosr.status_cd = '0'
+        <if test="tel !=null and tel != ''">
+            and a.tel= #{tel}
+        </if>
+        <if test="name !=null and name != ''">
+            and a.name like contact('%',#{name},'%')
+        </if>
+        <if test="staffId != null and staffId !=''">
+            and uosr.staff_id = #{staffId}
+        </if>
+        order by desc
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
+    </select>
+
 </mapper>
 </mapper>