Browse Source

巡查列表程序优化

dev_shibei_match
sunyuchao 4 years ago
parent
commit
0466477944
  1. 4
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/form/StaffListFormDTO.java
  2. 7
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/CustomerStaffDao.java
  3. 25
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  4. 16
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml
  5. 11
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StaffPatrolRecordDao.xml

4
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/form/StaffListFormDTO.java

@ -36,6 +36,10 @@ public class StaffListFormDTO implements Serializable {
* 工作人员姓名可空 * 工作人员姓名可空
*/ */
private String staffName; private String staffName;
/**
* 工作人员Id
*/
private String staffId;
/** /**
* 页码 * 页码
* */ * */

7
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/CustomerStaffDao.java

@ -23,6 +23,8 @@ import com.epmet.dataaggre.entity.epmetuser.CustomerStaffEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 政府工作人员表 * 政府工作人员表
* *
@ -37,4 +39,9 @@ public interface CustomerStaffDao extends BaseDao<CustomerStaffEntity> {
* @author sun * @author sun
*/ */
CustomerStaffDTO selectByMobile(@Param("customerId") String customerId, @Param("mobile") String mobile); CustomerStaffDTO selectByMobile(@Param("customerId") String customerId, @Param("mobile") String mobile);
/**
* @Description 按staffId查询基础信息
* @author sun
*/
List<CustomerStaffDTO> selectByStaffIds(@Param("staffIds") List<String> staffIds, @Param("realName") String realName);
} }

25
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java

@ -25,11 +25,11 @@ import com.epmet.dataaggre.service.epmetuser.StaffPatrolRecordService;
import com.epmet.dataaggre.service.govorg.GovOrgService; import com.epmet.dataaggre.service.govorg.GovOrgService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -274,10 +274,31 @@ public class EpmetUserServiceImpl implements EpmetUserService {
formDTO.setPageNo(pageIndex); formDTO.setPageNo(pageIndex);
//起始查询日期 //起始查询日期
formDTO.setPatrolStartTime(DateUtils.getBeforeMonthDate(formDTO.getTime(), "yyyyMMdd")); formDTO.setPatrolStartTime(DateUtils.getBeforeMonthDate(formDTO.getTime(), "yyyyMMdd"));
List<CustomerStaffDTO> staffList = new ArrayList<>();
//2-1.按名字检索时先查询人员基础信息
if (StringUtils.isEmpty(formDTO.getStaffName())) {
staffList = customerStaffDao.selectByStaffIds(null, formDTO.getStaffName());
if (!CollectionUtils.isEmpty(staffList)) {
formDTO.setStaffId(staffList.get(0).getUserId());
}
}
//2-2.查询业务数据
resultList = staffPatrolRecordDao.selectStaffPatrolList(formDTO); resultList = staffPatrolRecordDao.selectStaffPatrolList(formDTO);
//2-3.查询人员基本信息【之前sql关联人员表查性别、姓名效率低 所以分开查)
if (!CollectionUtils.isEmpty(staffList)) {
List<String> staffIdList = resultList.stream().map(StaffListResultDTO::getStaffId).collect(Collectors.toList());
staffList = customerStaffDao.selectByStaffIds(staffIdList, null);
}
//3.封装数据并返回 //3.封装数据并返回
resultList.forEach(re -> list.stream().filter(l -> re.getGridId().equals(l.getId())).forEach(s -> re.setGridName(s.getGridName()))); List<CustomerStaffDTO> finalStaffList = staffList;
resultList.forEach(re -> {
list.stream().filter(l -> re.getGridId().equals(l.getId())).forEach(s -> re.setGridName(s.getGridName()));
finalStaffList.stream().filter(l -> re.getStaffId().equals(l.getUserId())).forEach(s -> {
re.setGender(s.getGender().toString());
re.setStaffName(s.getRealName());
});
});
//NumberFormat numberFormat = NumberFormat.getInstance(); //NumberFormat numberFormat = NumberFormat.getInstance();
//numberFormat.setMaximumFractionDigits(NumConstant.ZERO); //numberFormat.setMaximumFractionDigits(NumConstant.ZERO);
resultList.forEach(re -> { resultList.forEach(re -> {

16
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml

@ -15,4 +15,20 @@
LIMIT 1 LIMIT 1
</select> </select>
<select id="selectByStaffIds" resultType="com.epmet.dataaggre.dto.epmetuser.CustomerStaffDTO">
SELECT
*
FROM
customer_staff
WHERE 1=1
<if test="realName != null and realName != '' ">
AND real_name = #{realName}
</if>
<if test="staffIds != null and staffIds.size() > 0">
<foreach collection="staffIds" item="userId" open="AND user_id IN (" separator="," close=")">
#{userId}
</foreach>
</if>
</select>
</mapper> </mapper>

11
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StaffPatrolRecordDao.xml

@ -59,8 +59,8 @@
SELECT SELECT
ssp.grid_id AS gridId, ssp.grid_id AS gridId,
ssp.staff_id AS staffId, ssp.staff_id AS staffId,
cs.real_name AS staffName, <!-- cs.real_name AS staffName,
cs.gender AS gender, cs.gender AS gender, -->
IFNULL(MAX(ssp.latest_patrol_time), '') AS patrolStartTime, IFNULL(MAX(ssp.latest_patrol_time), '') AS patrolStartTime,
IFNULL(SUM(ssp.patrol_total), 0) AS patrolTotal, IFNULL(SUM(ssp.patrol_total), 0) AS patrolTotal,
MAX(DATE_ID) dateId, MAX(DATE_ID) dateId,
@ -68,12 +68,15 @@
IFNULL(SUM(ssp.total_time), 0) AS timeNum IFNULL(SUM(ssp.total_time), 0) AS timeNum
FROM FROM
stats_staff_patrol_record_daily ssp stats_staff_patrol_record_daily ssp
LEFT JOIN customer_staff cs ON ssp.staff_id = cs.user_id <!-- LEFT JOIN customer_staff cs ON ssp.staff_id = cs.user_id -->
WHERE WHERE
ssp.del_flag = '0' ssp.del_flag = '0'
AND ssp.date_id >= #{patrolStartTime} AND ssp.date_id >= #{patrolStartTime}
<if test="staffName!= null and staffName != ''"> <!-- <if test="staffName!= null and staffName != ''">
AND cs.real_name = #{staffName} AND cs.real_name = #{staffName}
</if>-->
<if test="staffId!= null and staffId != ''">
AND ssp.staff_id = #{staffId}
</if> </if>
<if test="gridIds != null and gridIds.size() > 0"> <if test="gridIds != null and gridIds.size() > 0">
<foreach collection="gridIds" item="gridId" open="AND ssp.grid_id IN (" separator="," close=")"> <foreach collection="gridIds" item="gridId" open="AND ssp.grid_id IN (" separator="," close=")">

Loading…
Cancel
Save