瀏覽代碼

Merge branch 'fu-dev' of uskycloud/usky-modules into server-165

fuyuchuan 1 年之前
父節點
當前提交
b25ab573a1

+ 8 - 8
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/PatrolInspectionAttendanceController.java

@@ -1,17 +1,17 @@
 package com.usky.fire.controller.web;
 
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.usky.common.core.bean.ApiResult;
-import com.usky.common.core.bean.CommonPage;
 import com.usky.common.core.util.StringUtils;
 import com.usky.fire.domain.PatrolInspectionAttendance;
 import com.usky.fire.service.PatrolInspectionAttendanceService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.Map;
 
 
 /**
@@ -34,12 +34,12 @@ public class PatrolInspectionAttendanceController {
      * @return
      */
     @GetMapping("/pageQuery")
-    public ApiResult<CommonPage<PatrolInspectionAttendance>> pageQuery(@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
-                                                                       @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
-                                                                       @RequestParam(value = "typeId", required = false, defaultValue = "") Integer typeId,
-                                                                       @RequestParam(value = "operator",required = false, defaultValue = "") String operator,
-                                                                       @RequestParam(value = "startTime", required = false)String startTimeStr,
-                                                                       @RequestParam(value = "endTime", required = false)String endTimeStr) {
+    public ApiResult<IPage<Map<String, Object>>> pageQuery(@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
+                                                           @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
+                                                           @RequestParam(value = "typeId", required = false, defaultValue = "") Integer typeId,
+                                                           @RequestParam(value = "operator",required = false, defaultValue = "") String operator,
+                                                           @RequestParam(value = "startTime", required = false)String startTimeStr,
+                                                           @RequestParam(value = "endTime", required = false)String endTimeStr) {
         LocalDateTime startTime = StringUtils.isNotBlank(startTimeStr) ?
                 LocalDateTime.parse(startTimeStr, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) :
                 null;

+ 3 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionAttendanceService.java

@@ -1,10 +1,12 @@
 package com.usky.fire.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.usky.common.core.bean.CommonPage;
 import com.usky.fire.domain.PatrolInspectionAttendance;
 import com.usky.common.mybatis.core.CrudService;
 
 import java.time.LocalDateTime;
+import java.util.Map;
 
 /**
  * <p>
@@ -16,7 +18,7 @@ import java.time.LocalDateTime;
  */
 public interface PatrolInspectionAttendanceService extends CrudService<PatrolInspectionAttendance> {
 
-    CommonPage<PatrolInspectionAttendance> pageList( Integer pageNum,Integer pageSize,Integer typeId,String operator,LocalDateTime startTime,LocalDateTime endTime);
+    IPage<Map<String, Object>> pageList(Integer pageNum, Integer pageSize, Integer typeId, String operator, LocalDateTime startTime, LocalDateTime endTime);
 
     void add(PatrolInspectionAttendance patrolInspectionAttendance);
 }

+ 2 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionTypeService.java

@@ -19,4 +19,6 @@ public interface PatrolInspectionTypeService extends CrudService<PatrolInspectio
     void add(PatrolInspectionType patrolInspectionType);
 
     void softDelete(PatrolInspectionType deleteType);
+
+    String getName(Integer id);
 }

+ 43 - 11
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionAttendanceServiceImpl.java

@@ -4,16 +4,21 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.usky.common.core.bean.CommonPage;
 import com.usky.common.core.util.StringUtils;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.fire.domain.PatrolInspectionAttendance;
 import com.usky.fire.mapper.PatrolInspectionAttendanceMapper;
 import com.usky.fire.service.PatrolInspectionAttendanceService;
 import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.fire.service.PatrolInspectionTypeService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -26,14 +31,17 @@ import java.time.LocalDateTime;
  */
 @Service
 public class PatrolInspectionAttendanceServiceImpl extends AbstractCrudService<PatrolInspectionAttendanceMapper, PatrolInspectionAttendance> implements PatrolInspectionAttendanceService {
+    @Autowired
+    private PatrolInspectionTypeService patrolInspectionTypeService;
+
     @Override
-    public CommonPage<PatrolInspectionAttendance> pageList(Integer pageNum, Integer pageSize, Integer typeId, String operator, LocalDateTime startTime, LocalDateTime endTime) {
-        IPage<PatrolInspectionAttendance> page = new Page<>(pageNum,pageSize);
+    public IPage<Map<String, Object>> pageList(Integer pageNum, Integer pageSize, Integer typeId, String operator, LocalDateTime startTime, LocalDateTime endTime) {
+        IPage<PatrolInspectionAttendance> page = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<PatrolInspectionAttendance> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(PatrolInspectionAttendance::getTenantId,SecurityUtils.getTenantId());
+        queryWrapper.eq(PatrolInspectionAttendance::getTenantId, SecurityUtils.getTenantId());
 
-        if (typeId!=null){
-            queryWrapper.eq(PatrolInspectionAttendance::getTypeId,typeId);
+        if (typeId != null) {
+            queryWrapper.eq(PatrolInspectionAttendance::getTypeId, typeId);
         }
 
         if (StringUtils.isNotBlank(operator)) {
@@ -42,15 +50,39 @@ public class PatrolInspectionAttendanceServiceImpl extends AbstractCrudService<P
 
         if (startTime != null && endTime != null) {
             queryWrapper.between(PatrolInspectionAttendance::getOperateDate, startTime, endTime);
-        } else if(startTime == null && endTime !=null){
+        } else if (startTime == null && endTime != null) {
             queryWrapper.le(PatrolInspectionAttendance::getOperateDate, endTime);
         }
-
         queryWrapper.orderByDesc(PatrolInspectionAttendance::getId);
-        page = this.page(page,queryWrapper);
-        return new CommonPage<>(page.getRecords(),page.getTotal(),pageNum,pageSize);
-    }
 
+        IPage<PatrolInspectionAttendance> attendancePage = baseMapper.selectPage(page, queryWrapper);
+
+        List<Map<String, Object>> resultList = new ArrayList<>();
+        for (PatrolInspectionAttendance attendance : attendancePage.getRecords()) {
+            Map<String, Object> map = new HashMap<>();
+            map.put("id", attendance.getId());
+            map.put("deptId", attendance.getDeptId());
+            map.put("tenantId", attendance.getTenantId());
+            map.put("operator", attendance.getOperator());
+            map.put("operatorId", attendance.getOperatorId());
+            map.put("operateDate", attendance.getOperateDate());
+            map.put("operateType", attendance.getOperateType());
+            map.put("typeName", patrolInspectionTypeService.getName(attendance.getTypeId()));
+            map.put("deviceCode", attendance.getDeviceCode());
+            map.put("imagePath", attendance.getImagePath());
+            map.put("longitude", attendance.getLongitude());
+            map.put("latitude", attendance.getLatitude());
+            map.put("remarks", attendance.getRemarks());
+            map.put("identificationNumber", attendance.getIdentificationNumber());
+            resultList.add(map);
+        }
+        IPage<Map<String, Object>> resultPage = new Page<>();
+        resultPage.setRecords(resultList);
+        resultPage.setTotal(attendancePage.getTotal());
+        resultPage.setCurrent(attendancePage.getCurrent());
+        resultPage.setSize(attendancePage.getSize());
+        return resultPage;
+    }
 
     @Override
     public void add(PatrolInspectionAttendance patrolInspectionAttendance) {

+ 17 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionTypeServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.usky.common.core.bean.CommonPage;
 
+import com.usky.common.core.exception.BusinessException;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.fire.domain.PatrolInspectionType;
 import com.usky.fire.mapper.PatrolInspectionTypeMapper;
@@ -49,4 +50,20 @@ public class PatrolInspectionTypeServiceImpl extends AbstractCrudService<PatrolI
         deleteType.setDeleteFlag(1);
         baseMapper.updateById(deleteType);
     }
+
+    /**
+     * 查类型名字
+     */
+    @Override
+    public String getName(Integer id){
+        LambdaQueryWrapper<PatrolInspectionType> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.select(PatrolInspectionType::getTypeName)
+                .eq(PatrolInspectionType::getId,id);
+        PatrolInspectionType patrolInspectionType = baseMapper.selectOne(queryWrapper);
+        if (patrolInspectionType != null) {
+            return patrolInspectionType.getTypeName();
+        } else {
+            throw new BusinessException("未找到对应的操作类型");
+        }
+    }
 }