Browse Source

添加总卡,添加是否上架字段

liu 1 year ago
parent
commit
87455a7a90

+ 1 - 1
src/main/java/com/template/AutoCode.java

@@ -56,7 +56,7 @@ public class AutoCode {
         mpg.setPackageInfo(pc);
         //4、策略配置
         StrategyConfig strategy = new StrategyConfig();
-        strategy.setInclude("blacklist_order"); // 设置要映射的表名
+        strategy.setInclude("total_card"); // 设置要映射的表名
         strategy.setNaming(NamingStrategy.underline_to_camel);//下划线转驼峰
         strategy.setColumnNaming(NamingStrategy.underline_to_camel);//下划线转驼峰
         strategy.setEntityLombokModel(true); // 自动lombok;

+ 26 - 0
src/main/java/com/template/api/TotalCardControllerAPI.java

@@ -0,0 +1,26 @@
+package com.template.api;
+
+import com.template.model.dto.TotalCardDto;
+import com.template.model.result.CommonResult;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+@RequestMapping("/auto/total-card")
+public interface TotalCardControllerAPI {
+
+    @PostMapping("/saveEmployeeTotalCard")
+    @ApiOperation(value = "添加员工总卡", notes = "添加员工总卡", httpMethod = "PSOT")
+    CommonResult saveTotalCard(@RequestBody TotalCardDto totalCardDto);
+
+    @GetMapping("/deleteEmployeeTotalCard")
+    @ApiOperation(value = "删除员工总卡", notes = "删除员工总卡", httpMethod = "GET")
+    CommonResult deleteTotalCard(@RequestParam Integer id);
+
+
+    @GetMapping("/listEmployeeTotalCard")
+    @ApiOperation(value = "员工总卡展示", notes = "员工总卡展示", httpMethod = "GET")
+    CommonResult listEmployeeTotalCard(@RequestParam Integer page,@RequestParam Integer size,String employeeName,Integer buildingId,String startTime,String endTime);
+
+}
+
+

+ 2 - 0
src/main/java/com/template/controller/HouseController.java

@@ -370,6 +370,8 @@ public class HouseController implements HouseAPI {
 
         LambdaQueryWrapper<House> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(House::getRoomType, type);
+//        上架
+        wrapper.eq(House::getIsAdded,1);
         IPage<House> page1 = houseService.page(new Page<>(page, size), wrapper);
 
         List<House> records = page1.getRecords();

+ 2 - 2
src/main/java/com/template/controller/HouseOrderController.java

@@ -222,9 +222,9 @@ public class HouseOrderController implements HouseOrderAPI {
         if (roomType == 1) {
 
             if (v > 0) {
-//                判断是否到12点了
+//                判断是否到13点了
                 LocalDateTime now = LocalDateTime.now();
-                LocalDateTime localDateTime = now.withHour(12).withMinute(0).withSecond(0);
+                LocalDateTime localDateTime = now.withHour(13).withMinute(0).withSecond(0);
                 if (now.isBefore(localDateTime)) {
                     return CommonResult.fail("未到预定时间");
                 }

+ 230 - 0
src/main/java/com/template/controller/TotalCardController.java

@@ -0,0 +1,230 @@
+package com.template.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.template.api.TotalCardControllerAPI;
+import com.template.model.dto.KeyCardDto;
+import com.template.model.dto.TotalCardDto;
+import com.template.model.pojo.*;
+import com.template.model.result.CommonResult;
+import com.template.model.result.PageUtils;
+import com.template.model.vo.TotalCardPageVo;
+import com.template.services.*;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * 前端控制器
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-09-27
+ */
+@RestController
+public class TotalCardController implements TotalCardControllerAPI {
+
+    @Autowired
+    TotalCardService totalCardService;
+
+    @Autowired
+    UnlockingEmployeeService unlockingEmployeeService;
+
+    @Autowired
+    PasswordIssController passwordIssController;
+
+    @Autowired
+    BuildingService buildingService;
+
+    @Autowired
+    HouseNumberService houseNumberService;
+
+    @Autowired
+    HouseLockService houseLockService;
+
+    @Autowired
+    EmployeeUsersService employeeUsersService;
+
+    @Autowired
+    OperatingRecordService operatingRecordService;
+
+    @Autowired
+    AdminService adminService;
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public CommonResult saveTotalCard(TotalCardDto totalCardDto) {
+        Integer adminId = totalCardDto.getAdminId();
+
+        Admin admin = adminService.getById(adminId);
+        if (ObjectUtils.isEmpty(admin)) {
+            return CommonResult.fail("该管理员不存在");
+        }
+
+        Integer buildingId = totalCardDto.getBuildingId();
+        Integer employeeUsersId = totalCardDto.getEmployeeUsersId();
+//        先判断是否已添加总卡
+        LambdaQueryWrapper<TotalCard> wrapperTc = new LambdaQueryWrapper<>();
+        wrapperTc.eq(TotalCard::getBuildingId, buildingId)
+                .eq(TotalCard::getEmployeeUsersId, employeeUsersId);
+        TotalCard totalCard = totalCardService.getOne(wrapperTc);
+        if (ObjectUtils.isNotEmpty(totalCard)) {
+            return CommonResult.fail("已存在该总卡");
+        }
+
+
+//        判断是否有该员工
+        EmployeeUsers employeeUsers = employeeUsersService.getById(employeeUsersId);
+        if (ObjectUtils.isEmpty(employeeUsers)) {
+            return CommonResult.fail("无该员工");
+        }
+
+//        获取该楼栋下的房间
+        LambdaQueryWrapper<HouseNumber> wrapperHn = new LambdaQueryWrapper<>();
+        wrapperHn.eq(HouseNumber::getBuildingId, buildingId);
+        List<HouseNumber> houseNumberList = houseNumberService.list(wrapperHn);
+        if (houseNumberList.size() == 0) {
+            return CommonResult.fail("该楼栋下无房间");
+        }
+        ArrayList<Integer> houseNumberIds = new ArrayList<>();
+        for (HouseNumber houseNumber : houseNumberList) {
+            houseNumberIds.add(houseNumber.getId());
+        }
+
+        LambdaQueryWrapper<HouseLock> wrapperHl = new LambdaQueryWrapper<>();
+        wrapperHl.in(HouseLock::getHouseNumberId, houseNumberIds);
+        List<HouseLock> houseLockList = houseLockService.list(wrapperHl);
+        if (houseLockList.size() == 0) {
+            return CommonResult.fail("该楼栋下无门锁设备");
+        }
+
+        //        添加总卡
+        try {
+            for (HouseLock houseLock : houseLockList) {
+                Integer houseNumberId = houseLock.getHouseNumberId();
+                HouseNumber houseNumber = houseNumberService.getById(houseNumberId);
+
+                KeyCardDto dto = new KeyCardDto();
+                dto.setLuid(houseLock.getEquipmentType());
+                dto.setCard(totalCardDto.getRoomCardInformation());
+                dto.setCardType(0);
+                dto.setStartTime(totalCardDto.getStartTime());
+                dto.setEndTime(totalCardDto.getEndTime());
+                dto.setHouseNumberId(houseLock.getHouseNumberId() + "");
+                dto.setAdminId(totalCardDto.getAdminId() + "");
+                dto.setType(4);
+
+                UnlockingAdmin unlockingAdmin = passwordIssController.addCard(dto);
+
+                unlockingAdmin.setName(employeeUsers.getUserName());
+                unlockingAdmin.setPhone(employeeUsers.getPhone());
+
+                UnlockingEmployee unlockingEmployee = new UnlockingEmployee();
+                BeanUtils.copyProperties(unlockingAdmin, unlockingEmployee);
+                unlockingEmployeeService.save(unlockingEmployee);
+
+//        添加操作记录
+
+                OperatingRecord operatingRecord = new OperatingRecord();
+
+                operatingRecord.setHouseNumberId(houseLock.getHouseNumberId());
+                operatingRecord.setRoomNumber(houseNumber.getRoomNumber());
+                operatingRecord.setOperatorName(admin.getName());
+                DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                operatingRecord.setDataTime(LocalDateTime.now().format(dateTimeFormatter1));
+                operatingRecord.setContent("姓名:" + employeeUsers.getUserName());
+                operatingRecord.setType("添加卡片钥匙");
+                operatingRecordService.save(operatingRecord);
+
+            }
+
+            TotalCard totalCard1 = new TotalCard();
+            BeanUtils.copyProperties(totalCardDto, totalCard1);
+            totalCardService.save(totalCard1);
+            return CommonResult.ok();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            return CommonResult.fail();
+        }
+
+
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public CommonResult deleteTotalCard(Integer id) {
+        TotalCard totalCard = totalCardService.getById(id);
+
+        if (ObjectUtils.isEmpty(totalCard)) {
+            return CommonResult.fail("无该总卡");
+        }
+
+        //        判断是否有该员工
+        EmployeeUsers employeeUsers = employeeUsersService.getById(totalCard.getEmployeeUsersId());
+        if (ObjectUtils.isEmpty(employeeUsers)) {
+            return CommonResult.fail("无该员工");
+        }
+
+
+        Integer buildingId = totalCard.getBuildingId();
+
+        //        获取该楼栋下的房间
+        LambdaQueryWrapper<HouseNumber> wrapperHn = new LambdaQueryWrapper<>();
+        wrapperHn.eq(HouseNumber::getBuildingId, buildingId);
+        List<HouseNumber> houseNumberList = houseNumberService.list(wrapperHn);
+        if (houseNumberList.size() == 0) {
+            return CommonResult.fail("该楼栋下无房间");
+        }
+        ArrayList<Integer> houseNumberIds = new ArrayList<>();
+        for (HouseNumber houseNumber : houseNumberList) {
+            houseNumberIds.add(houseNumber.getId());
+        }
+
+//        查询所有需要删除的锁
+        LambdaQueryWrapper<UnlockingEmployee> wrapperUe = new LambdaQueryWrapper<>();
+        wrapperUe.eq(UnlockingEmployee::getName, employeeUsers.getUserName())
+                .eq(UnlockingEmployee::getPhone, employeeUsers.getPhone())
+                .in(UnlockingEmployee::getHouseNumberId, houseNumberIds)
+                .eq(UnlockingEmployee::getStartTime,totalCard.getStartTime())
+                .eq(UnlockingEmployee::getEndTime,totalCard.getEndTime())
+                .eq(UnlockingEmployee::getLockStatus,2);
+
+        List<UnlockingEmployee> list = unlockingEmployeeService.list(wrapperUe);
+
+        try {
+            ArrayList<Integer> idUEs = new ArrayList<>();
+            for (UnlockingEmployee unlockingEmployee : list) {
+                String luid = unlockingEmployee.getLuid();
+                String lockUserId = unlockingEmployee.getLockUserId();
+                passwordIssController.deleteLockUser(luid, lockUserId);
+                idUEs.add(unlockingEmployee.getId());
+            }
+
+            unlockingEmployeeService.removeByIds(idUEs);
+            totalCardService.removeById(id);
+            return CommonResult.ok();
+
+        }catch (Exception e){
+            e.printStackTrace();
+            return CommonResult.fail();
+        }
+    }
+
+    @Override
+    public CommonResult listEmployeeTotalCard(Integer page, Integer size, String employeeName, Integer buildingId, String startTime, String endTime) {
+        PageUtils<TotalCardPageVo> pageUtils=totalCardService.totalCardPage(page,size,employeeName,buildingId,startTime,endTime);
+        return CommonResult.ok(pageUtils);
+    }
+
+
+}
+

+ 40 - 2
src/main/java/com/template/controller/UnlockingController.java

@@ -1,11 +1,17 @@
 package com.template.controller;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.template.api.UnlockingControllerAPI;
-import org.springframework.web.bind.annotation.RequestMapping;
-
+import com.template.model.pojo.Unlocking;
+import com.template.services.UnlockingService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
 /**
  * <p>
  *  前端控制器
@@ -17,5 +23,37 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 public class UnlockingController implements UnlockingControllerAPI {
 
+    @Autowired
+    UnlockingService unlockingService;
+
+
+    @Autowired
+    PasswordIssController passwordIssController;
+
+
+    //    定时删除过期用户
+//    @Scheduled(cron = "0 2 * * * ? ")
+//    @Scheduled(cron = "0 0/1 * * * ?")
+    public void deleteUnlocking() {
+//        先查询已过期的自定义的锁
+        LambdaQueryWrapper<Unlocking> wrapperUC = new LambdaQueryWrapper<>();
+        wrapperUC.le(Unlocking::getEndTime, new Date());
+        List<Unlocking> list = unlockingService.list(wrapperUC);
+        if (list.size() > 0) {
+            ArrayList<Integer> idUCs = new ArrayList<>();
+            for (Unlocking unlockingCustom : list) {
+                String luid = unlockingCustom.getLuid();
+                String lockUserId = unlockingCustom.getLockUserId();
+                passwordIssController.deleteLockUser(luid, lockUserId);
+                idUCs.add(unlockingCustom.getId());
+            }
+            unlockingService.removeByIds(idUCs);
+        }
+
+
+
+    }
+
+
 }
 

+ 23 - 0
src/main/java/com/template/mapper/TotalCardMapper.java

@@ -0,0 +1,23 @@
+package com.template.mapper;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.template.model.pojo.TotalCard;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.template.model.vo.TotalCardPageVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-09-27
+ */
+@Mapper
+public interface TotalCardMapper extends BaseMapper<TotalCard> {
+
+    IPage<TotalCardPageVo> totalCardPage(Page<TotalCardPageVo> pageVo,@Param("employeeName") String employeeName,@Param("buildingId") Integer buildingId,@Param("startTime") String startTime, @Param("endTime") String endTime);
+}

+ 6 - 5
src/main/java/com/template/model/dto/CustomKeyCardDto.java

@@ -5,11 +5,12 @@ import lombok.Data;
 import javax.validation.constraints.NotNull;
 
 @Data
-public class CustomKeyCardDto { /**
- * 锁设备ID
- */
-@NotNull(message = "锁设备ID不能为空")
-public String luid;
+public class CustomKeyCardDto {
+    /**
+     * 锁设备ID
+     */
+    @NotNull(message = "锁设备ID不能为空")
+    public String luid;
     /**
      * 卡号
      */

+ 25 - 0
src/main/java/com/template/model/dto/TotalCardDto.java

@@ -0,0 +1,25 @@
+package com.template.model.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class TotalCardDto {
+
+    private Integer adminId;
+
+    @ApiModelProperty(value = "员工id")
+    private Integer employeeUsersId;
+
+    @ApiModelProperty(value = "楼栋单元id")
+    private Integer buildingId;
+
+    @ApiModelProperty(value = "房卡特殊编码")
+    private String roomCardInformation;
+
+    @ApiModelProperty(value = "开始时间")
+    private String startTime;
+
+    @ApiModelProperty(value = "结束时间")
+    private String endTime;
+}

+ 3 - 0
src/main/java/com/template/model/pojo/House.java

@@ -66,6 +66,9 @@ public class House implements Serializable {
     @ApiModelProperty(value = "简介")
     private String introductory;
 
+    @ApiModelProperty(value = "是否上架  1:上架 ,2:下架")
+    private Integer isAdded;
+
     @ApiModelProperty(value = "创建时间")
     @TableField(fill = FieldFill.INSERT)
     private String createTime;

+ 68 - 0
src/main/java/com/template/model/pojo/TotalCard.java

@@ -0,0 +1,68 @@
+package com.template.model.pojo;
+
+import com.baomidou.mybatisplus.annotation.*;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-09-27
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="TotalCard对象", description="")
+public class TotalCard implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "员工id")
+    private Integer employeeUsersId;
+
+    @ApiModelProperty(value = "楼栋单元id")
+    private Integer buildingId;
+
+    @ApiModelProperty(value = "房卡特殊编码")
+    private String roomCardInformation;
+
+    @ApiModelProperty(value = "开始时间")
+    private String startTime;
+
+    @ApiModelProperty(value = "结束时间")
+    private String endTime;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(fill = FieldFill.INSERT)
+    private String createTime;
+
+    @ApiModelProperty(value = "更新时间")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private String updateTime;
+
+    @ApiModelProperty(value = "创建人员")
+    @TableField(fill = FieldFill.INSERT)
+    private String createUser;
+
+    @ApiModelProperty(value = "更新人员")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private String updateUser;
+
+    @ApiModelProperty(value = "逻辑删除 未删除:0;删除:1")
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic
+    private Integer deleted;
+
+
+}

+ 1 - 0
src/main/java/com/template/model/vo/HouseVo.java

@@ -14,4 +14,5 @@ public class HouseVo {
     private String visible;
 //    private Integer count;
     private Integer type;
+    private Integer isAdded;
 }

+ 40 - 0
src/main/java/com/template/model/vo/TotalCardPageVo.java

@@ -0,0 +1,40 @@
+package com.template.model.vo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class TotalCardPageVo {
+
+    private Integer id;
+
+    @ApiModelProperty(value = "员工id")
+    private Integer employeeUsersId;
+
+    @ApiModelProperty(value = "员工名称")
+    private String employeeUsersName;
+
+    @ApiModelProperty(value = "楼栋单元id")
+    private Integer buildingId;
+
+    @ApiModelProperty(value = "楼栋")
+    private String building;
+
+    @ApiModelProperty(value = "单元")
+    private String element;
+
+    @ApiModelProperty(value = "房卡特殊编码")
+    private String roomCardInformation;
+
+    @ApiModelProperty(value = "开始时间")
+    private String startTime;
+
+    @ApiModelProperty(value = "结束时间")
+    private String endTime;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(fill = FieldFill.INSERT)
+    private String createTime;
+}

+ 19 - 0
src/main/java/com/template/services/TotalCardService.java

@@ -0,0 +1,19 @@
+package com.template.services;
+
+import com.template.model.pojo.TotalCard;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.template.model.result.PageUtils;
+import com.template.model.vo.TotalCardPageVo;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-09-27
+ */
+public interface TotalCardService extends IService<TotalCard> {
+
+    PageUtils<TotalCardPageVo> totalCardPage(Integer page, Integer size, String employeeName, Integer buildingId,String startTime, String endTime);
+}

+ 1 - 1
src/main/java/com/template/services/impl/ElectricEquipmentServiceImpl.java

@@ -29,7 +29,7 @@ public class ElectricEquipmentServiceImpl extends ServiceImpl<ElectricEquipmentM
     /**
      * 获取所有房间的电表设备
      */
-//    @Scheduled(cron = "0 23 * * * ? ")
+//    @Scheduled(cron = "0 22 * * * ? ")
     @Transactional(rollbackFor = Exception.class)
     public void getHouseNumberEquipment(){
         String url="http://172.16.20.87/api/wechat/main/meterQuery?meterType=1";

+ 34 - 0
src/main/java/com/template/services/impl/TotalCardServiceImpl.java

@@ -0,0 +1,34 @@
+package com.template.services.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.template.mapper.TotalCardMapper;
+import com.template.model.pojo.TotalCard;
+import com.template.model.result.PageUtils;
+import com.template.model.vo.TotalCardPageVo;
+import com.template.services.TotalCardService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author ceshi
+ * @since 2024-09-27
+ */
+@Service
+public class TotalCardServiceImpl extends ServiceImpl<TotalCardMapper, TotalCard> implements TotalCardService {
+
+    @Autowired
+    TotalCardMapper totalCardMapper;
+
+    @Override
+    public PageUtils<TotalCardPageVo> totalCardPage(Integer page, Integer size, String employeeName, Integer buildingId, String startTime, String endTime) {
+        Page<TotalCardPageVo> pageVo = new Page<>(page,size);
+        IPage<TotalCardPageVo> result=totalCardMapper.totalCardPage(pageVo,employeeName,buildingId,startTime,endTime);
+        return new PageUtils(result);
+    }
+}

+ 2 - 4
src/main/java/com/template/services/impl/WaterEquipmentServiceImpl.java

@@ -3,12 +3,10 @@ package com.template.services.impl;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
-import com.template.model.pojo.ElectricEquipment;
-import com.template.model.pojo.WaterEquipment;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.template.mapper.WaterEquipmentMapper;
+import com.template.model.pojo.WaterEquipment;
 import com.template.services.WaterEquipmentService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.client.RestTemplate;

+ 2 - 1
src/main/resources/mapper/template/HouseMapper.xml

@@ -32,7 +32,8 @@
         h.visible AS visible,
 --         h.number AS count,
         h.room_type AS type,
-        h.id as id
+        h.id as id,
+        h.is_added as isAdded
         FROM
         house h
         <where>

+ 39 - 0
src/main/resources/mapper/template/TotalCardMapper.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.template.mapper.TotalCardMapper">
+
+    <select id="totalCardPage" resultType="com.template.model.vo.TotalCardPageVo">
+        SELECT
+        tc.id,
+        tc.employee_users_id as employeeUsersId,
+        eu.user_name as employeeUsersName,
+        tc.building_id as buildingId,
+        b.building,
+        b.element,
+        tc.room_card_information as roomCardInformation,
+        tc.start_time as startTime,
+        tc.end_time as endTime,
+        tc.create_time as createTime
+        FROM
+        `total_card` tc
+        LEFT JOIN employee_users eu ON tc.employee_users_id = eu.id
+        AND eu.deleted = 0
+        LEFT JOIN building b ON tc.building_id = b.id
+        AND b.deleted = 0
+        WHERE
+        tc.deleted = 0
+        <if test="employeeName != null and employeeName != ''">
+            AND eu.user_name LIKE '%' #{employeeName} '%'
+        </if>
+
+        <if test="buildingId != null and buildingId != ''">
+            AND tc.building_id = #{buildingId}
+        </if>
+
+        <if test="startTime != null and startTime != '' and endTime != null and endTime != ''  ">
+            AND #{endTime} >= tc.create_time
+            AND tc.create_time >= #{startTime}
+        </if>
+
+    </select>
+</mapper>