|
@@ -1,21 +1,29 @@
|
|
|
package com.huimv.receive.controller;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.huimv.receive.common.utils.Result;
|
|
|
import com.huimv.receive.common.utils.ResultCode;
|
|
|
+import com.huimv.receive.common.utils.UploadImage;
|
|
|
import com.huimv.receive.entity.BillAccessDoor;
|
|
|
import com.huimv.receive.entity.BillGate;
|
|
|
+import com.huimv.receive.entity.vo.DoorVo;
|
|
|
import com.huimv.receive.service.IBillAccessDoorService;
|
|
|
import com.huimv.receive.service.IBillGateService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import sun.misc.BASE64Decoder;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.IOException;
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -35,18 +43,48 @@ public class BillAccessDoorController {
|
|
|
private IBillAccessDoorService doorService;
|
|
|
@Autowired
|
|
|
private IBillGateService gateService;
|
|
|
+ @Autowired
|
|
|
+ private UploadImage uploadImage;
|
|
|
+
|
|
|
@RequestMapping("/listById")
|
|
|
public Result listById(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
|
|
|
String farmId = paramsMap.get("farmId");
|
|
|
String type = paramsMap.get("type");//1为人脸门禁 2为车辆闸机
|
|
|
String id = paramsMap.get("id");
|
|
|
if ("1".equals(type)) {
|
|
|
- BillAccessDoor doorServiceOne = doorService.getOne(new QueryWrapper<BillAccessDoor>().eq("farm_id", farmId).eq("id", id));
|
|
|
+ BillAccessDoor doorServiceOne = doorService.getOne(new QueryWrapper<BillAccessDoor>()
|
|
|
+ .eq("farm_id", farmId).eq("id", id));
|
|
|
return new Result(ResultCode.SUCCESS, doorServiceOne);
|
|
|
} else {
|
|
|
- BillGate gate = gateService.getOne(new QueryWrapper<BillGate>().eq("farm_id", farmId).eq("id", id));
|
|
|
+ BillGate gate = gateService.getOne(new QueryWrapper<BillGate>().eq("farm_id", farmId)
|
|
|
+ .eq("id", id));
|
|
|
return new Result(ResultCode.SUCCESS, gate);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping("/getDoorData")
|
|
|
+ public Result getDoorData(@RequestParam("time") String time,
|
|
|
+ @RequestParam("result") String result,
|
|
|
+ @RequestParam("userId") String userId,
|
|
|
+ @RequestParam("image") MultipartFile image) throws ParseException, IOException {
|
|
|
+ BillAccessDoor door = new BillAccessDoor();
|
|
|
+ door.setBillStatus(Integer.parseInt(result));
|
|
|
+ DateFormat def = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ door.setCheckDate(def.parse(time));
|
|
|
+ door.setUserId(userId);
|
|
|
+ if (ObjectUtil.isNotEmpty(image)) {
|
|
|
+ if (uploadImage.getImageCom(image).equals("上传失败")) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return new Result(10001, "图片上传失败", false);
|
|
|
+ }
|
|
|
+ door.setUrlImg(uploadImage.getImageCom(image));
|
|
|
+ }
|
|
|
+ //后面需要修改
|
|
|
+ door.setFarmId(25);
|
|
|
+ door.setLocationId(1);
|
|
|
+ door.setCheckLocation("人员初级洗消");
|
|
|
+ doorService.save(door);
|
|
|
+ return new Result(ResultCode.SUCCESS, time);
|
|
|
+ }
|
|
|
}
|