Browse Source

#巡检打卡统计

zhongwei
yang_shj 2 weeks ago
parent
commit
908ed90392
  1. 30
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/ClockInStatisticsResponseDTO.java
  2. 15
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/ClockInController.java
  3. 6
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/ClockInMapper.java
  4. 22
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/ClockInMapper.xml
  5. 3
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/IClockInService.java
  6. 26
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/ClockInServiceImpl.java

30
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/ClockInStatisticsResponseDTO.java

@ -0,0 +1,30 @@
package com.hnac.hzinfo.inspect.ai.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author ysj
*/
@Data
@ApiModel(value = "巡检打卡统计分页响应对象", description = "巡检打卡统计分页响应对象")
public class ClockInStatisticsResponseDTO implements Serializable {
private static final long serialVersionUID = 8445346022067680992L;
@ApiModelProperty(value = "打卡人")
private Long clockPerson;
@ApiModelProperty(value = "打卡人名称")
private String clockPersonName;
@ApiModelProperty(value = "未完成打卡次数")
private Integer incomplete;
@ApiModelProperty(value = "完成打卡次数")
private Integer complete;
}

15
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/ClockInController.java

@ -8,6 +8,7 @@ import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzinfo.inspect.Constants;
import com.hnac.hzinfo.inspect.ai.vo.ClockInRequestDTO;
import com.hnac.hzinfo.inspect.ai.vo.ClockInResponseDTO;
import com.hnac.hzinfo.inspect.ai.vo.ClockInStatisticsResponseDTO;
import com.hnac.hzinfo.inspect.task.service.IClockInService;
import com.hnac.hzinfo.log.annotation.Business;
import io.swagger.annotations.Api;
@ -33,12 +34,16 @@ public class ClockInController extends BladeController {
private final IClockInService clockInService;
@GetMapping("/page")
@ApiOperationSupport(order = 4)
@OperationAnnotation(moduleName = "巡检打卡",
title = "打卡记录",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,
action = "分页查询打卡记录")
@ApiOperation(value = "分页")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "打卡记录")
public R<IPage<ClockInResponseDTO>> list(ClockInRequestDTO param, Query query) {
return R.data(clockInService.pageCondition(param, query));
}
@GetMapping("/statistics")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "打卡统计")
public R<IPage<ClockInStatisticsResponseDTO>> statistics(ClockInRequestDTO param, Query query) {
return R.data(clockInService.statistics(param, query));
}
}

6
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/ClockInMapper.java

@ -1,8 +1,13 @@
package com.hnac.hzinfo.inspect.task.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzinfo.inspect.ai.vo.ClockInRequestDTO;
import com.hnac.hzinfo.inspect.ai.vo.ClockInResponseDTO;
import com.hnac.hzinfo.inspect.ai.vo.ClockInStatisticsResponseDTO;
import com.hnac.hzinfo.inspect.task.entity.ClockInEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
@ -11,4 +16,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ClockInMapper extends BaseMapper<ClockInEntity> {
IPage<ClockInStatisticsResponseDTO> statistics(@Param("param") ClockInRequestDTO param, IPage<ClockInResponseDTO> page);
}

22
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/ClockInMapper.xml

@ -2,4 +2,26 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.hnac.hzinfo.inspect.task.mapper.ClockInMapper">
<select id="statistics" resultType="com.hnac.hzinfo.inspect.ai.vo.ClockInStatisticsResponseDTO">
SELECT CLOCK_PERSON,
SUM(CASE WHEN status = 0 THEN 1 ELSE 0 END) AS incomplete,
SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) AS complete
FROM HZ_ST_EX_CLOCK_IN
<where>
IS_DELETED = 0
<if test="param.clockPerson != null">
AND CLOCK_PERSON = #{param.clockPerson}
</if>
<if test="param.startTime != null">
AND PLAN_START_TIME &gt;= #{param.startTime}
</if>
<if test="param.endTime != null">
AND PLAN_END_TIME &lt;= #{param.endTime}
</if>
<if test="param.status != null">
AND STATUS = #{param.status}
</if>
</where>
GROUP BY CLOCK_PERSON;
</select>
</mapper>

3
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/IClockInService.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzinfo.inspect.ai.vo.ClockInRequestDTO;
import com.hnac.hzinfo.inspect.ai.vo.ClockInResponseDTO;
import com.hnac.hzinfo.inspect.ai.vo.ClockInStatisticsResponseDTO;
import com.hnac.hzinfo.inspect.task.entity.ClockInEntity;
import com.hnac.hzinfo.inspect.task.entity.TaskObjectEntity;
import org.springblade.core.mp.support.Query;
@ -18,5 +19,7 @@ public interface IClockInService extends IService<ClockInEntity> {
IPage<ClockInResponseDTO> pageCondition(ClockInRequestDTO param, Query query);
IPage<ClockInStatisticsResponseDTO> statistics(ClockInRequestDTO param, Query query);
List<TaskObjectEntity> pendingObjects(Long taskId);
}

26
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/ClockInServiceImpl.java

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzinfo.inspect.ai.vo.ClockInRequestDTO;
import com.hnac.hzinfo.inspect.ai.vo.ClockInResponseDTO;
import com.hnac.hzinfo.inspect.ai.vo.ClockInStatisticsResponseDTO;
import com.hnac.hzinfo.inspect.task.entity.ClockInEntity;
import com.hnac.hzinfo.inspect.task.entity.TaskObjectEntity;
import com.hnac.hzinfo.inspect.task.mapper.ClockInMapper;
@ -17,11 +18,15 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author ysj
@ -61,6 +66,27 @@ public class ClockInServiceImpl extends ServiceImpl<ClockInMapper, ClockInEntity
}
/**
* 分页打卡统计
* @param param
* @param query
* @return
*/
@Override
public IPage<ClockInStatisticsResponseDTO> statistics(ClockInRequestDTO param, Query query) {
IPage<ClockInStatisticsResponseDTO> page = this.baseMapper.statistics(param,Condition.getPage(query));
if(CollectionUtil.isEmpty(page.getRecords())){
return page;
}
page.setRecords(page.getRecords().stream().peek(record->{
User user = UserCache.getUser(record.getClockPerson());
if(ObjectUtil.isNotEmpty(user)){
record.setClockPersonName(user.getRealName());
}
}).collect(Collectors.toList()));
return page;
}
/**
* 待生成打卡记录巡检对象
* @param id
* @return

Loading…
Cancel
Save