Commit a76f92f5da0d13189e5a5a0e942e5638bd6cd196

Authored by yiming
1 parent eab3bef4

逾期归还定时器

ruoyi-archives/src/main/java/com/ruoyi/domain/ArchivesBorrow.java
@@ -73,10 +73,9 @@ public class ArchivesBorrow extends ArchivesCollectBox @@ -73,10 +73,9 @@ public class ArchivesBorrow extends ArchivesCollectBox
73 @Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd") 73 @Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd")
74 private Date updateTime; 74 private Date updateTime;
75 75
76 - /** 待归还日期 */  
77 - @JsonFormat(pattern = "yyyy-MM-dd")  
78 - @Excel(name = "待归还日期", width = 30, dateFormat = "yyyy-MM-dd")  
79 - private Date returnDate; 76 + /** 借阅天数 */
  77 + @Excel(name = "借阅天数")
  78 + private int returnDate;
80 79
81 /** 实际还日期 */ 80 /** 实际还日期 */
82 @JsonFormat(pattern = "yyyy-MM-dd") 81 @JsonFormat(pattern = "yyyy-MM-dd")
@@ -219,11 +218,11 @@ public class ArchivesBorrow extends ArchivesCollectBox @@ -219,11 +218,11 @@ public class ArchivesBorrow extends ArchivesCollectBox
219 this.updateTime = updateTime; 218 this.updateTime = updateTime;
220 } 219 }
221 220
222 - public Date getReturnDate() { 221 + public int getReturnDate() {
223 return returnDate; 222 return returnDate;
224 } 223 }
225 224
226 - public void setReturnDate(Date returnDate) { 225 + public void setReturnDate(int returnDate) {
227 this.returnDate = returnDate; 226 this.returnDate = returnDate;
228 } 227 }
229 228
ruoyi-archives/src/main/java/com/ruoyi/mapper/ArchivesBorrowMapper.java
@@ -47,4 +47,6 @@ public interface ArchivesBorrowMapper @@ -47,4 +47,6 @@ public interface ArchivesBorrowMapper
47 */ 47 */
48 int updateArchivesBorrowByIds(@Param("archivesBorrow") ArchivesBorrow archivesBorrow, @Param("ids") Long[] ids); 48 int updateArchivesBorrowByIds(@Param("archivesBorrow") ArchivesBorrow archivesBorrow, @Param("ids") Long[] ids);
49 49
  50 + int updateArchivesBorrowById(ArchivesBorrow archivesBorrow);
  51 +
50 } 52 }
ruoyi-archives/src/main/java/com/ruoyi/service/impl/ArchivesBorrowServiceImpl.java
@@ -72,7 +72,7 @@ public class ArchivesBorrowServiceImpl implements IArchivesBorrowService @@ -72,7 +72,7 @@ public class ArchivesBorrowServiceImpl implements IArchivesBorrowService
72 @Override 72 @Override
73 public int archivesRenew(Long[] ids) { 73 public int archivesRenew(Long[] ids) {
74 ArchivesBorrow archivesBorrow=new ArchivesBorrow(); 74 ArchivesBorrow archivesBorrow=new ArchivesBorrow();
75 - archivesBorrow.setReturnedDate(new Date()); 75 + archivesBorrow.setBorrowDate(new Date());
76 archivesBorrow.setStatus("3"); 76 archivesBorrow.setStatus("3");
77 int i=archivesBorrowMapper.updateArchivesBorrowByIds(archivesBorrow, ids); 77 int i=archivesBorrowMapper.updateArchivesBorrowByIds(archivesBorrow, ids);
78 return i; 78 return i;
ruoyi-archives/src/main/resources/mapper/archives/ArchivesBorrowMapper.xml
@@ -62,6 +62,7 @@ @@ -62,6 +62,7 @@
62 <if test="borrowDateS != null and borrowDateS != ''"> and borrow_date >= #{borrowDateS}</if> 62 <if test="borrowDateS != null and borrowDateS != ''"> and borrow_date >= #{borrowDateS}</if>
63 <if test="borrowDateE != null and borrowDateE != ''"> and borrow_date &lt;= #{borrowDateE}</if> 63 <if test="borrowDateE != null and borrowDateE != ''"> and borrow_date &lt;= #{borrowDateE}</if>
64 <if test="borrowMark != null and borrowMark != ''"> and borrow_mark = #{borrowMark}</if> 64 <if test="borrowMark != null and borrowMark != ''"> and borrow_mark = #{borrowMark}</if>
  65 + <if test="status = 'wgh'"> and status !='1'</if>
65 </where> 66 </where>
66 </select> 67 </select>
67 68
@@ -89,7 +90,7 @@ @@ -89,7 +90,7 @@
89 <update id="updateArchivesBorrowByIds" parameterType="ArchivesBorrow"> 90 <update id="updateArchivesBorrowByIds" parameterType="ArchivesBorrow">
90 update archives_borrow 91 update archives_borrow
91 <trim prefix="SET" suffixOverrides=","> 92 <trim prefix="SET" suffixOverrides=",">
92 - <if test="archivesBorrow.returnDate != null">return_date = #{archivesBorrow.returnDate},</if> 93 + <if test="archivesBorrow.borrowDate != null">borrow_date = #{archivesBorrow.borrowDate},</if>
93 <if test="archivesBorrow.returnedDate != null">returned_date = #{archivesBorrow.returnedDate},</if> 94 <if test="archivesBorrow.returnedDate != null">returned_date = #{archivesBorrow.returnedDate},</if>
94 <if test="archivesBorrow.status != null">status = #{archivesBorrow.status},</if> 95 <if test="archivesBorrow.status != null">status = #{archivesBorrow.status},</if>
95 </trim> 96 </trim>
@@ -99,4 +100,12 @@ @@ -99,4 +100,12 @@
99 </foreach> 100 </foreach>
100 </update> 101 </update>
101 102
  103 + <update id="updateArchivesBorrowById" parameterType="ArchivesBorrow">
  104 + update archives_borrow
  105 + <trim prefix="SET" suffixOverrides=",">
  106 + <if test="status != null">status = #{status},</if>
  107 + </trim>
  108 + where id = #{id}
  109 + </update>
  110 +
102 </mapper> 111 </mapper>
103 \ No newline at end of file 112 \ No newline at end of file
ruoyi-service/src/main/java/com/ruoyi/service/timer/BorrowTimer.java 0 → 100644
  1 +package com.ruoyi.service.timer;
  2 +
  3 +import com.ruoyi.domain.ArchivesBorrow;
  4 +import com.ruoyi.mapper.ArchivesBorrowMapper;
  5 +import org.springframework.context.annotation.Configuration;
  6 +import org.springframework.scheduling.annotation.Scheduled;
  7 +
  8 +
  9 +
  10 +import javax.annotation.Resource;
  11 +import java.time.Instant;
  12 +import java.time.LocalDate;
  13 +import java.time.ZoneId;
  14 +import java.util.List;
  15 +import java.util.Date;
  16 +
  17 +@Configuration
  18 +public class BorrowTimer {
  19 +
  20 + @Resource
  21 + ArchivesBorrowMapper archivesBorrowMapper;
  22 +
  23 + @Scheduled(cron = "0 5 0 * * ?")
  24 +
  25 + void borrowTimer(){
  26 + ArchivesBorrow ab=new ArchivesBorrow();
  27 + ab.setStatus("wgh");
  28 + List<ArchivesBorrow> list=archivesBorrowMapper.selectArchivesBorrowList(new ArchivesBorrow());
  29 + list.forEach(archivesBorrow -> {
  30 + Date date=archivesBorrow.getBorrowDate();
  31 + Instant instant = date.toInstant();
  32 + ZoneId zoneId = ZoneId.systemDefault();
  33 + LocalDate borrowDate = instant.atZone(zoneId).toLocalDate();
  34 + LocalDate returnDate =borrowDate.plusDays(archivesBorrow.getReturnDate());
  35 + //逾期
  36 + if(LocalDate.now().isAfter(returnDate)){
  37 + archivesBorrow.setStatus("2");
  38 + archivesBorrowMapper.updateArchivesBorrowById(archivesBorrow);
  39 + }
  40 + });
  41 + }
  42 +
  43 +}
ruoyi-ui/src/views/service/borrowReturn/index.vue
@@ -60,7 +60,7 @@ @@ -60,7 +60,7 @@
60 <el-table-column label="部门" align="center" prop="dept" /> 60 <el-table-column label="部门" align="center" prop="dept" />
61 <el-table-column label="实体利用方式" align="center" prop="mode" /> 61 <el-table-column label="实体利用方式" align="center" prop="mode" />
62 <el-table-column label="领取日期" align="center" prop="borrowDate" /> 62 <el-table-column label="领取日期" align="center" prop="borrowDate" />
63 - <el-table-column label="待归还日期" align="center" prop="returnDate" /> 63 + <el-table-column label="借阅天数" align="center" prop="returnDate" />
64 <el-table-column label="借阅单号" align="center" prop="borrowMark" /> 64 <el-table-column label="借阅单号" align="center" prop="borrowMark" />
65 </el-table> 65 </el-table>
66 </el-col> 66 </el-col>