commit
b89efa1db2
@ -0,0 +1,46 @@ |
|||||||
|
package edu.ncst.ioreport.controller; |
||||||
|
|
||||||
|
import edu.ncst.ioreport.exception.CodeMsg; |
||||||
|
import edu.ncst.ioreport.model.IORecords; |
||||||
|
import edu.ncst.ioreport.service.IIORecordService; |
||||||
|
import edu.ncst.ioreport.utils.ResponseUtils; |
||||||
|
import edu.ncst.ioreport.utils.ResultUtils; |
||||||
|
import edu.ncst.ioreport.vo.ListResultVO; |
||||||
|
import edu.ncst.ioreport.vo.ResultVO; |
||||||
|
import edu.ncst.ioreport.vo.param.QRecord; |
||||||
|
import edu.ncst.ioreport.vo.param.QUser; |
||||||
|
import edu.ncst.ioreport.vo.result.UserInfoVO; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.http.ResponseEntity; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 报备记录 控制器 |
||||||
|
*/ |
||||||
|
@Api(description = "出入校报备记录控制器", tags = "IORecordsController") |
||||||
|
@Slf4j |
||||||
|
@RestController |
||||||
|
@RequestMapping("/api/records") |
||||||
|
public class IORecordsController { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IIORecordService iioRecordService; |
||||||
|
@ApiOperation("获取报备记录列表") |
||||||
|
@PostMapping("/list") |
||||||
|
public ResultVO<List<IORecords>> getIORecordsList(@RequestBody QRecord param){ |
||||||
|
List<IORecords> ioRecordsList = iioRecordService.getIORecordsList(param); |
||||||
|
return ResultUtils.success(ioRecordsList); |
||||||
|
} |
||||||
|
|
||||||
|
@ApiOperation("根据记录ID获取记录详细信息") |
||||||
|
@GetMapping("/detail") |
||||||
|
public ResultVO<IORecords> getIORecordByID(@RequestParam(name = "ID", required = true) Integer ID){ |
||||||
|
IORecords record = iioRecordService.getIORecordsDetail(ID); |
||||||
|
return ResultUtils.success(record); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,10 @@ |
|||||||
|
package edu.ncst.ioreport.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import edu.ncst.ioreport.model.IORecords; |
||||||
|
import edu.ncst.ioreport.model.Resource; |
||||||
|
import org.springframework.stereotype.Repository; |
||||||
|
|
||||||
|
@Repository |
||||||
|
public interface IORecordsMapper extends BaseMapper<IORecords> { |
||||||
|
} |
||||||
@ -0,0 +1,69 @@ |
|||||||
|
package edu.ncst.ioreport.model; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||||
|
import edu.ncst.ioreport.model.BaseEntity; |
||||||
|
import edu.ncst.ioreport.vo.QRToken; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* 角色 |
||||||
|
*/ |
||||||
|
@ApiModel(value="IORecords", description="报备记录") |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = false) |
||||||
|
@TableName("IORecords") |
||||||
|
public class IORecords { |
||||||
|
private static final long serialVersionUID=1L; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "报备记录ID") |
||||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||||
|
private Integer id; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "教师工号") |
||||||
|
private String teacherID; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "报备单类型:1-出;0-入") |
||||||
|
private String ioType; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "校外居住地") |
||||||
|
private String outerResidence; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "校内居住地") |
||||||
|
private String innerResidence; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "申请事由") |
||||||
|
private String reason; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "出入校时间") |
||||||
|
private Date commitTime; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "院级审核人") |
||||||
|
private Integer deptAuditorID; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "院级审核时间") |
||||||
|
private Date deptAuditTime; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "校级审核人") |
||||||
|
private Integer schoolAuditorID; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "校级审核时间") |
||||||
|
private Date schoolAuditTime; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "核验人") |
||||||
|
private Integer validatorID; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "核验时间") |
||||||
|
private Date validateTime; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "单据状态:0-保存;1-提交待审核;2-院级审核通过;3-校级审核通过;4-核验通过;9-院级审核不通过;8-校级审核不通过;7-核验不通过") |
||||||
|
private String status; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "二维码token") |
||||||
|
@TableField(exist = false) |
||||||
|
private QRToken qrToken; |
||||||
|
} |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
package edu.ncst.ioreport.service; |
||||||
|
|
||||||
|
import edu.ncst.ioreport.model.IORecords; |
||||||
|
import edu.ncst.ioreport.vo.param.QRecord; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public interface IIORecordService { |
||||||
|
|
||||||
|
List<IORecords> getIORecordsList(QRecord query); |
||||||
|
|
||||||
|
IORecords getIORecordsDetail(Integer ID); |
||||||
|
} |
||||||
@ -0,0 +1,67 @@ |
|||||||
|
package edu.ncst.ioreport.service.impl; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||||
|
import edu.ncst.ioreport.exception.BusinessException; |
||||||
|
import edu.ncst.ioreport.exception.CodeMsg; |
||||||
|
import edu.ncst.ioreport.mapper.IORecordsMapper; |
||||||
|
import edu.ncst.ioreport.model.IORecords; |
||||||
|
import edu.ncst.ioreport.service.IIORecordService; |
||||||
|
import edu.ncst.ioreport.vo.QRToken; |
||||||
|
import edu.ncst.ioreport.vo.param.QRecord; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.data.redis.core.RedisTemplate; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Random; |
||||||
|
import java.util.concurrent.TimeUnit; |
||||||
|
|
||||||
|
@Service |
||||||
|
public class IORecordServiceImpl implements IIORecordService { |
||||||
|
@Autowired |
||||||
|
private IORecordsMapper recordsMapper; |
||||||
|
@Autowired |
||||||
|
private RedisTemplate<String, String> stringRedisTemplate; |
||||||
|
@Override |
||||||
|
public List<IORecords> getIORecordsList(QRecord query) { |
||||||
|
IORecords ioRecords = new IORecords(); |
||||||
|
ioRecords.setTeacherID(query.getTeacherID()); |
||||||
|
ioRecords.setStatus(query.getStatus()); |
||||||
|
ioRecords.setIoType(query.getType()); |
||||||
|
QueryWrapper<IORecords> queryWrapper = new QueryWrapper(ioRecords); |
||||||
|
List<IORecords> list = recordsMapper.selectList(queryWrapper); |
||||||
|
|
||||||
|
return list; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public IORecords getIORecordsDetail(Integer ID) { |
||||||
|
if(null==ID){ |
||||||
|
throw new BusinessException(CodeMsg.PARAM_ERROR.fillArgs("记录单ID为空")); |
||||||
|
} |
||||||
|
|
||||||
|
IORecords records = recordsMapper.selectById(ID); |
||||||
|
|
||||||
|
if(records.getStatus().compareTo("SCHOOL_PASS")==0){ |
||||||
|
if(!stringRedisTemplate.hasKey("qrToken_"+ID)){ |
||||||
|
QRToken qrToken = new QRToken(); |
||||||
|
qrToken.setRecordID(ID); |
||||||
|
stringRedisTemplate.opsForValue().set("qrToken_"+ID,JSON.toJSONString(qrToken),1, TimeUnit.MINUTES); |
||||||
|
} |
||||||
|
String qrTokenStr = stringRedisTemplate.opsForValue().get("qrToken_"+ID); |
||||||
|
QRToken qrToken = JSON.parseObject(qrTokenStr,QRToken.class); |
||||||
|
if(qrToken!=null){ |
||||||
|
Long seconds = stringRedisTemplate.getExpire("qrToken_"+ID); |
||||||
|
qrToken.setExpireTime(seconds); |
||||||
|
records.setQrToken(qrToken); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if(null==records){ |
||||||
|
throw new BusinessException("记录不存在"); |
||||||
|
} |
||||||
|
return records; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,21 @@ |
|||||||
|
package edu.ncst.ioreport.vo; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.text.SimpleDateFormat; |
||||||
|
import java.util.Calendar; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class QRToken { |
||||||
|
private Integer recordID; |
||||||
|
private Date expireTime; |
||||||
|
|
||||||
|
public void setExpireTime(Long time){ |
||||||
|
Calendar calendar=Calendar.getInstance(); |
||||||
|
if(time!=null&&time>0){ |
||||||
|
calendar.add(Calendar.SECOND, time.intValue()); |
||||||
|
} |
||||||
|
this.expireTime = calendar.getTime(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,22 @@ |
|||||||
|
package edu.ncst.ioreport.vo.param; |
||||||
|
|
||||||
|
import edu.ncst.ioreport.vo.Query; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@ApiModel(description = "出入报备记录查询对象") |
||||||
|
@Data |
||||||
|
public class QRecord extends Query { |
||||||
|
@ApiModelProperty(value = "教师工号") |
||||||
|
private String teacherID; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "记录类型") |
||||||
|
private String type; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "记录状态") |
||||||
|
private String status; |
||||||
|
} |
||||||
@ -0,0 +1,60 @@ |
|||||||
|
package edu.ncst.ioreport.vo.result; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import edu.ncst.ioreport.model.User; |
||||||
|
import edu.ncst.ioreport.vo.QRToken; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@ApiModel(description = "当前用户信息") |
||||||
|
@Data |
||||||
|
public class RecordVO { |
||||||
|
@ApiModelProperty(value = "报备记录ID") |
||||||
|
private Integer ID; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "教师工号") |
||||||
|
private User Teacher; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "报备单类型:1-出;0-入") |
||||||
|
private Integer IOType; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "校外居住地") |
||||||
|
private String OuterResidence; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "校内居住地") |
||||||
|
private String InnerResidence; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "申请事由") |
||||||
|
private String Reason; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "出入校时间") |
||||||
|
private Date CommitTime; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "院级审核人") |
||||||
|
private User DeptAuditor; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "院级审核时间") |
||||||
|
private Date DeptAuditTime; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "校级审核人") |
||||||
|
private User SchoolAuditor; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "校级审核时间") |
||||||
|
private Date SchoolAuditTime; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "核验人") |
||||||
|
private User Validator; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "核验时间") |
||||||
|
private Date ValidateTime; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "单据状态:0-保存;1-提交待审核;2-院级审核通过;3-校级审核通过;4-核验通过;9-院级审核不通过;8-校级审核不通过;7-核验不通过") |
||||||
|
private String Status; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "二维码token") |
||||||
|
private QRToken qrToken; |
||||||
|
} |
||||||
Loading…
Reference in new issue