Browse Source

巡检签到记录增加、查询,操作类型添加、删除

fuyuhchuan 1 year ago
parent
commit
18b9838651

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

@@ -36,18 +36,11 @@ public class PatrolInspectionAttendanceController {
     @GetMapping("/pageQuery")
     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;
-        LocalDateTime endTime = StringUtils.isNotBlank(endTimeStr) ?
-                LocalDateTime.parse(endTimeStr, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) :
-                LocalDateTime.now();
-
-        return ApiResult.success(patrolInspectionAttendanceService.pageList(pageNum,pageSize,typeId,operator,startTime,endTime));
+                                                           @RequestParam(value = "operateCode", required = false, defaultValue = "") String operateCode,
+                                                           @RequestParam(value = "operator", required = false, defaultValue = "") String operator,
+                                                           @RequestParam(value = "startTime", required = false ) LocalDateTime startTime,
+                                                           @RequestParam(value = "endTime", required = false, defaultValue = "#{T(java.time.LocalDateTime).now()}") LocalDateTime endTime) {
+        return ApiResult.success(patrolInspectionAttendanceService.pageList(pageNum, pageSize, operateCode, operator, startTime, endTime));
     }
 
     /**
@@ -62,3 +55,4 @@ public class PatrolInspectionAttendanceController {
     }
 }
 
+

+ 6 - 5
service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/PatrolInspectionAttendance.java

@@ -33,7 +33,7 @@ public class PatrolInspectionAttendance implements Serializable {
     /**
      * 组织机构ID
      */
-    private Integer deptId;
+    private Long deptId;
 
     /**
      * 租户ID
@@ -48,7 +48,7 @@ public class PatrolInspectionAttendance implements Serializable {
     /**
      * 签到人id
      */
-    private Integer operatorId;
+    private Long operatorId;
 
     /**
      * 操作时间
@@ -59,12 +59,13 @@ public class PatrolInspectionAttendance implements Serializable {
     /**
      * 签到类型(0 签到,1 签退)
      */
-    private Integer operateType;
+    private Integer signInType;
 
     /**
-     * 类型表主键id
+     *
+     * 操作类型编码
      */
-    private Integer typeId;
+    private String operateCode;
 
     /**
      * 设备编号

+ 5 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/PatrolInspectionPersonnel.java

@@ -64,5 +64,10 @@ public class PatrolInspectionPersonnel implements Serializable {
      */
     private Integer companyId;
 
+    /**
+     * 签到状态(0,签到;1,签退)
+     */
+    private Integer operateType;
+
 
 }

+ 1 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/PatrolInspectionType.java

@@ -29,7 +29,7 @@ public class PatrolInspectionType implements Serializable {
     /**
      * 类型编号
      */
-    private String typeCode;
+    private String operateCode;
 
     /**
      * 类型名称

+ 2 - 5
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionAttendanceService.java

@@ -1,13 +1,10 @@
 package com.usky.fire.service;
 
-import com.baomidou.dynamic.datasource.annotation.DS;
 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.List;
 import java.util.Map;
 
 /**
@@ -20,9 +17,9 @@ import java.util.Map;
  */
 public interface PatrolInspectionAttendanceService extends CrudService<PatrolInspectionAttendance> {
 
-    IPage<Map<String, Object>> pageList(Integer pageNum, Integer pageSize, Integer typeId, String operator, LocalDateTime startTime, LocalDateTime endTime);
+    IPage<Map<String, Object>> pageList(Integer pageNum, Integer pageSize, String operateCode, String operator, LocalDateTime startTime, LocalDateTime endTime);
 
     void add(PatrolInspectionAttendance patrolInspectionAttendance);
 
-    String getDeptName(Integer id);
+    String getDeptName(Long id);
 }

+ 3 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionPersonnelService.java

@@ -30,4 +30,7 @@ public interface PatrolInspectionPersonnelService extends CrudService<PatrolInsp
 
     List<PatrolInspectionAreaVo> personnelLeftList();
 
+    void updateSignStatus(Integer status);
+
+
 }

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

@@ -20,5 +20,5 @@ public interface PatrolInspectionTypeService extends CrudService<PatrolInspectio
 
     void softDelete(PatrolInspectionType deleteType);
 
-    String getName(Integer id);
+    String getName(String code);
 }

+ 40 - 17
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionAttendanceServiceImpl.java

@@ -5,13 +5,14 @@ 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.exception.BusinessException;
+
 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.PatrolInspectionPersonnelService;
 import com.usky.fire.service.PatrolInspectionTypeService;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,14 +42,16 @@ public class PatrolInspectionAttendanceServiceImpl extends AbstractCrudService<P
     @Autowired
     private RemoteDeptService remoteDeptService;
 
+    @Autowired
+    private PatrolInspectionPersonnelService patrolInspectionPersonnelService;
     @Override
-    public IPage<Map<String, Object>> pageList(Integer pageNum, Integer pageSize, Integer typeId, String operator, LocalDateTime startTime, LocalDateTime endTime) {
+    public IPage<Map<String, Object>> pageList(Integer pageNum, Integer pageSize, String operateCode, String operator, LocalDateTime startTime, LocalDateTime endTime) {
         IPage<PatrolInspectionAttendance> page = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<PatrolInspectionAttendance> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(PatrolInspectionAttendance::getTenantId, SecurityUtils.getTenantId());
 
-        if (typeId != null) {
-            queryWrapper.eq(PatrolInspectionAttendance::getTypeId, typeId);
+        if (StringUtils.isNotBlank(operateCode)) {
+            queryWrapper.eq(PatrolInspectionAttendance::getOperateCode, operateCode);
         }
 
         if (StringUtils.isNotBlank(operator)) {
@@ -56,10 +59,11 @@ public class PatrolInspectionAttendanceServiceImpl extends AbstractCrudService<P
         }
 
         if (startTime != null) {
-            queryWrapper.between(endTime != null, PatrolInspectionAttendance::getOperateDate, startTime, endTime);
-        } else {
-            queryWrapper.le(endTime != null, PatrolInspectionAttendance::getOperateDate, endTime);
+            queryWrapper.between(endTime!=null,PatrolInspectionAttendance::getOperateDate, startTime, endTime);
+        }else {
+            queryWrapper.le(endTime!=null,PatrolInspectionAttendance::getOperateDate, endTime);
         }
+
         queryWrapper.orderByDesc(PatrolInspectionAttendance::getId);
 
         IPage<PatrolInspectionAttendance> attendancePage = baseMapper.selectPage(page, queryWrapper);
@@ -74,8 +78,8 @@ public class PatrolInspectionAttendanceServiceImpl extends AbstractCrudService<P
             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("signInType", attendance.getSignInType());
+            map.put("operateName", patrolInspectionTypeService.getName(attendance.getOperateCode()));
             map.put("deviceCode", attendance.getDeviceCode());
             map.put("imagePath", attendance.getImagePath());
             map.put("longitude", attendance.getLongitude());
@@ -94,20 +98,39 @@ public class PatrolInspectionAttendanceServiceImpl extends AbstractCrudService<P
 
     @Override
     public void add(PatrolInspectionAttendance patrolInspectionAttendance) {
+        patrolInspectionAttendance.setTenantId(SecurityUtils.getTenantId());
+        patrolInspectionAttendance.setOperator(SecurityUtils.getUsername());
+        patrolInspectionAttendance.setOperatorId(SecurityUtils.getUserId());
+        patrolInspectionAttendance.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
+        patrolInspectionAttendance.setOperateDate(LocalDateTime.now());
+        patrolInspectionAttendance.setRemarks(patrolInspectionAttendance.getRemarks());
+        patrolInspectionAttendance.setSignInType(patrolInspectionAttendance.getSignInType());
+        patrolInspectionAttendance.setOperateCode(patrolInspectionAttendance.getOperateCode());
+        patrolInspectionAttendance.setImagePath(patrolInspectionAttendance.getImagePath());
+        patrolInspectionAttendance.setLatitude(patrolInspectionAttendance.getLatitude());
+        patrolInspectionAttendance.setLongitude(patrolInspectionAttendance.getLongitude());
+        patrolInspectionAttendance.setIdentificationNumber(SecurityUtils.getLoginUser().getSysUser().getPhonenumber());
+        patrolInspectionAttendance.setDeviceCode(patrolInspectionAttendance.getDeviceCode());
         baseMapper.insert(patrolInspectionAttendance);
+        patrolInspectionPersonnelService.updateSignStatus(patrolInspectionAttendance.getSignInType());
     }
 
+    /**
+     * 获取部门名
+     * @param id
+     * @return
+     */
     @Override
-    public String getDeptName(Integer id) {
-        String name = "";
-        List<Map<String, Object>> deptList = remoteDeptService.getDeptList(SecurityUtils.getTenantId());
-        for (int i = 0; i < deptList.size(); i++) {
-            if (id.equals(deptList.get(i).get("dept_id"))){
-                name = deptList.get(i).get("dept_name").toString();
+        public String getDeptName(Long id) {
+            String name = "";
+            List<Map<String, Object>> deptList = remoteDeptService.getDeptList(SecurityUtils.getTenantId());
+            for (int i = 0; i < deptList.size(); i++) {
+                if (id.equals(deptList.get(i).get("dept_id"))){
+                    name = deptList.get(i).get("dept_name").toString();
+                }
             }
+            return name;
         }
-        return name;
-    }
 
 }
 

+ 10 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionPersonnelServiceImpl.java

@@ -1,6 +1,7 @@
 package com.usky.fire.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.usky.common.core.bean.ApiResult;
 import com.usky.common.core.bean.CommonPage;
@@ -215,6 +216,15 @@ public class PatrolInspectionPersonnelServiceImpl extends AbstractCrudService<Pa
         return patrolInspectionAreaVoListOne;
     }
 
+    public void updateSignStatus(Integer status) {
+        LambdaUpdateWrapper<PatrolInspectionPersonnel> updateWrapper = Wrappers.lambdaUpdate();
+        updateWrapper.eq(PatrolInspectionPersonnel::getUserId, SecurityUtils.getUserId())
+                .set(PatrolInspectionPersonnel::getOperateType, status);
+
+        baseMapper.update(null, updateWrapper);
+    }
+
+
     @Override
     public List<PatrolInspectionPersonnelVo> patrolInspectionPersonnelSelect(Integer areaId) {
         LoginUser loginUser = SecurityUtils.getLoginUser();

+ 6 - 11
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionTypeServiceImpl.java

@@ -6,7 +6,6 @@ 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;
@@ -39,12 +38,12 @@ public class PatrolInspectionTypeServiceImpl extends AbstractCrudService<PatrolI
     public CommonPage<PatrolInspectionType> pageList(Integer pageNum, Integer pageSize) {
         IPage<PatrolInspectionType> page = new Page<>(pageNum,pageSize);
         LambdaQueryWrapper<PatrolInspectionType> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper
-                .eq(PatrolInspectionType::getTenantId,SecurityUtils.getTenantId())
+        queryWrapper.eq(PatrolInspectionType::getTenantId,SecurityUtils.getTenantId())
                 .eq(PatrolInspectionType::getDeleteFlag,0)
                 .orderByDesc(PatrolInspectionType::getId);
         page = this.page(page,queryWrapper);
-        return new CommonPage<>(page.getRecords(),page.getTotal(),pageNum,pageSize);    }
+        return new CommonPage<>(page.getRecords(),page.getTotal(),pageNum,pageSize);
+    }
 
     /**
      * 添加操作类型
@@ -55,7 +54,7 @@ public class PatrolInspectionTypeServiceImpl extends AbstractCrudService<PatrolI
         DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
         Date date = new Date();
         String timestamp = dateFormat.format(date);
-        patrolInspectionType.setTypeCode(patrolInspectionType.getTypeCode()+"-"+timestamp);
+        patrolInspectionType.setOperateCode(patrolInspectionType.getOperateCode()+"-"+timestamp);
         baseMapper.insert(patrolInspectionType);
     }
 
@@ -73,15 +72,11 @@ public class PatrolInspectionTypeServiceImpl extends AbstractCrudService<PatrolI
      * 查类型名字
      */
     @Override
-    public String getName(Integer id){
+    public String getName(String code){
         LambdaQueryWrapper<PatrolInspectionType> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.select(PatrolInspectionType::getTypeName)
-                .eq(PatrolInspectionType::getId,id);
+                .eq(PatrolInspectionType::getOperateCode,code);
         PatrolInspectionType patrolInspectionType = baseMapper.selectOne(queryWrapper);
-        if (patrolInspectionType != null) {
             return patrolInspectionType.getTypeName();
-        } else {
-            throw new BusinessException("未找到对应的操作类型");
-        }
     }
 }