|
@@ -1,9 +1,26 @@
|
|
|
package com.huimv.receive.controller;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+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.service.IBillGateService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
+import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -15,6 +32,41 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/bill-gate")
|
|
|
+@CrossOrigin
|
|
|
public class BillGateController {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IBillGateService gateService;
|
|
|
+ @Autowired
|
|
|
+ private UploadImage uploadImage;
|
|
|
+
|
|
|
+ @RequestMapping("/getGateData")
|
|
|
+ public Result getDoorData(@RequestParam("time") String time,
|
|
|
+ @RequestParam(value = "plateNumber",required = false) String plateNumber,
|
|
|
+ @RequestParam("result") String result,
|
|
|
+ @RequestParam("image") MultipartFile image) throws ParseException, IOException {
|
|
|
+
|
|
|
+ BillGate gate = new BillGate();
|
|
|
+ gate.setBillStatus(Integer.parseInt(result));
|
|
|
+ DateFormat def = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ gate.setCheckDate(def.parse(time));
|
|
|
+ gate.setCarNum(plateNumber);
|
|
|
+ String imageCom = "";
|
|
|
+ if (ObjectUtil.isNotEmpty(image)) {
|
|
|
+ if (uploadImage.getImageCom(image).equals("上传失败")) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return new Result(10001, "图片上传失败", false);
|
|
|
+ }
|
|
|
+ imageCom = uploadImage.getImageCom(image);
|
|
|
+ gate.setCarUrl(imageCom);
|
|
|
+ }
|
|
|
+
|
|
|
+ //后面需要修改
|
|
|
+ gate.setFarmId(25);
|
|
|
+ gate.setLocationId(1);
|
|
|
+ gate.setCheckLocation("人员初级洗消");
|
|
|
+ gateService.save(gate);
|
|
|
+ return new Result(ResultCode.SUCCESS, time, imageCom);
|
|
|
+ }
|
|
|
+
|
|
|
}
|