Răsfoiți Sursa

模板调整

车车 1 an în urmă
părinte
comite
63b72e5067

+ 25 - 20
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsMaterialsLoanServiceImpl.java

@@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
 import java.time.Instant;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
@@ -111,10 +112,11 @@ public class IsMaterialsLoanServiceImpl extends ServiceImpl<IsMaterialsLoanMappe
                         && materialsLoan.getActualRestitutionTime() == null
                         && materialsLoan.getRestitutionToId() == null) {
                         // 没有归还则需要开始新增提醒消息
+                    IsMaterials materials = isMaterialsService.getById(materialsLoan.getMaterialsId());
                     Map<String, Object> templateParams = new HashMap<>();
-                    templateParams.put("用户", materialsLoan.getLoanUserId());
-                    templateParams.put("物资", materialsLoan.getMaterialsId());
-                    templateParams.put("应该归还时间", materialsLoan.getRestitutionTime());
+                    templateParams.put("借出时间", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(materialsLoan.getLoanTime()));
+                    templateParams.put("物资", materials.getMaterialsName());
+                    templateParams.put("归还时间", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(materialsLoan.getRestitutionTime()));
                     notifySendService.sendSingleNotifyToMember(materialsLoan.getLoanUserId(),
                             "REMINDER_RETURN", templateParams);
                 }
@@ -146,12 +148,13 @@ public class IsMaterialsLoanServiceImpl extends ServiceImpl<IsMaterialsLoanMappe
                         && materialsLoan.getActualRestitutionTime() == null
                         && materialsLoan.getRestitutionToId() == null) {
                     // 没有归还则需要开始新增提醒消息
+                    IsMaterials materials = isMaterialsService.getById(materialsLoan.getMaterialsId());
                     Map<String, Object> templateParams = new HashMap<>();
-                    templateParams.put("用户", materialsLoan.getLoanUserId());
-                    templateParams.put("物资", materialsLoan.getMaterialsId());
-                    templateParams.put("应该归还时间", materialsLoan.getRestitutionTime());
+                    templateParams.put("借出时间", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(materialsLoan.getLoanTime()));
+                    templateParams.put("物资", materials.getMaterialsName());
+                    templateParams.put("归还时间", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(materialsLoan.getRestitutionTime()));
                     notifySendService.sendSingleNotifyToMember(materialsLoan.getLoanUserId(),
-                            "REMINDER_RETURN", templateParams);
+                            "ALARM_RETURN", templateParams);
                 }
             }
         }
@@ -198,18 +201,19 @@ public class IsMaterialsLoanServiceImpl extends ServiceImpl<IsMaterialsLoanMappe
         int al = 0;
         // 1.物资信息
         IsMaterials materials = isMaterialsService.getById(isMaterialsLoan.getMaterialsId());
+        MaterialsTypePageVO materialsTypePageVO = new MaterialsTypePageVO();
         // 1.2开始读取类型和规则,然后计算归还时间,提醒时间
         if (materials != null) {
             // 1.2.1填充字段
             isMaterialsLoan.setLoanFromId(materials.getMaterialsCabinetId());
-            MaterialsTypePageVO materialsTypePageVO = isMaterialsTypeService.selectIsMaterialsTypeByMaterialsTypeId(materials.getMaterialsTypeId());
+            materialsTypePageVO = isMaterialsTypeService.selectIsMaterialsTypeByMaterialsTypeId(materials.getMaterialsTypeId());
             if (materialsTypePageVO != null) {
                 // 1.2.1.1填充字段
                 isMaterialsLoan.setRestitutionRequired(materialsTypePageVO.getRestitutionRequired());
                 if (materialsTypePageVO.getLoanDuration() != null) {
                     // 1.2.2计算应该归还时间
                     Date restitutionTime = formatDateTime(nowDate, materialsTypePageVO.getLoanDuration());
-                    isMaterialsLoan.setReminderTime(restitutionTime);
+                    isMaterialsLoan.setRestitutionTime(restitutionTime);
                     if (materialsTypePageVO.getReminderTime() != null) {
                         // 1.2.3计算提醒时间
                         re = materialsTypePageVO.getLoanDuration() - materialsTypePageVO.getReminderTime();
@@ -226,19 +230,20 @@ public class IsMaterialsLoanServiceImpl extends ServiceImpl<IsMaterialsLoanMappe
             }
         }
         int i = isMaterialsLoanMapper.insertIsMaterialsLoan(isMaterialsLoan);
-        // 开始处理消息
-        // 1.3.1处理归还提醒
-        if (materials != null && isMaterialsLoan.getReminderTime() != null) {
-            System.out.println("设置借用提醒消息");
-            reminderMessage(isMaterialsLoan.getMaterialsLoanId(), re);
-        }
-        // 1.3.2处理归还告警
-        if (materials != null && isMaterialsLoan.getTimeoutAlarm() != null) {
-            System.out.println("设置借用告警消息");
-            alarmMessage(isMaterialsLoan.getMaterialsLoanId(), al);
+        if (materialsTypePageVO != null && materialsTypePageVO.getRestitutionRequired().equals(1) ) {
+            // 开始处理消息
+            // 1.3.1处理归还提醒
+            if (materials != null && isMaterialsLoan.getReminderTime() != null) {
+                System.out.println("设置借用提醒消息");
+                reminderMessage(isMaterialsLoan.getMaterialsLoanId(), re);
+            }
+            // 1.3.2处理归还告警
+            if (materials != null && isMaterialsLoan.getTimeoutAlarm() != null) {
+                System.out.println("设置借用告警消息");
+                alarmMessage(isMaterialsLoan.getMaterialsLoanId(), al);
+            }
         }
 
-
         // 2.开始更新物资信息为借出状态
         LambdaUpdateWrapper<IsMaterials> set = Wrappers.<IsMaterials>lambdaUpdate()
                 .eq(IsMaterials::getMaterialsId, isMaterialsLoan.getMaterialsId())