|
|
@@ -11,6 +11,7 @@ import com.google.zxing.client.j2se.MatrixToImageWriter;
|
|
|
import com.google.zxing.common.BitMatrix;
|
|
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
|
|
import com.management.platform.entity.MealApplications;
|
|
|
+import com.management.platform.entity.MealTypes;
|
|
|
import com.management.platform.entity.User;
|
|
|
import com.management.platform.service.MealApplicationsService;
|
|
|
import com.management.platform.service.MealTypesService;
|
|
|
@@ -30,6 +31,7 @@ import java.io.ByteArrayOutputStream;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
|
|
|
@@ -46,6 +48,8 @@ import java.util.*;
|
|
|
public class MealApplicationsController {
|
|
|
@Autowired
|
|
|
private MealApplicationsService mealApplicationsService;
|
|
|
+ @Autowired
|
|
|
+ private MealTypesService mealTypeService;
|
|
|
@RequestMapping("/apply")
|
|
|
public HttpRespMsg apply(HttpServletRequest request,Integer mealType, String factory){
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
@@ -59,21 +63,21 @@ public class MealApplicationsController {
|
|
|
if (first.isPresent()){
|
|
|
return msg.fail("已申报过");
|
|
|
}
|
|
|
-// HttpRespMsg qrCode = this.getQrCode(request, mealType, factory);
|
|
|
-// if (qrCode.getCode().equals("ok")){
|
|
|
-// return msg.fail("已申报过");
|
|
|
-// }
|
|
|
+ MealTypes mealCategory = mealTypeService.getById(mealType);
|
|
|
+
|
|
|
try {
|
|
|
- // 生成二维码内容
|
|
|
-// String qrContent = "mealId:" + mealType + ",factoryId:" + factory + ",userId:" + userId;
|
|
|
-// // 生成二维码图片
|
|
|
-// String qrCodeBase64 = generateQRCode(qrContent, 300, 300);
|
|
|
MealApplications mealApplications = new MealApplications();
|
|
|
mealApplications.setUserId(userId);
|
|
|
mealApplications.setMealTypeId(mealType);
|
|
|
mealApplications.setFactoryId(Integer.valueOf(factory));
|
|
|
-// mealApplications.setQrCode(qrCodeBase64);
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
+ if (mealCategory != null && mealCategory.getDeadlineTime()!=null && !mealCategory.getDeadlineTime().isEmpty()){
|
|
|
+ LocalTime deadlineTime = LocalTime.parse(mealCategory.getDeadlineTime());
|
|
|
+ LocalDateTime deadlineDateTime = LocalDateTime.of(LocalDate.now(), deadlineTime);
|
|
|
+ if (now.isAfter(deadlineDateTime)){
|
|
|
+ return msg.fail("已超过截止时间,报餐截止时间为:"+mealCategory.getDeadlineTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
mealApplications.setApplicationDate(now.toLocalDate());
|
|
|
mealApplications.setAppliedAt(now);
|