From e76c58f4c0e9c334a19c9c4418343ca99d5e3d0f Mon Sep 17 00:00:00 2001 From: whycxzp <glperry@163.com> Date: 星期六, 01 三月 2025 16:48:55 +0800 Subject: [PATCH] 更新 --- src/main/java/com/whyc/controller/InspectionRecordController.java | 22 +++ src/main/java/com/whyc/controller/QRCodeController.java | 12 + src/main/java/com/whyc/pojo/InspectionDetail.java | 58 ++++++++ src/main/java/com/whyc/service/InspectionRecordService.java | 29 ++++ src/main/java/com/whyc/service/BattRTStateService.java | 5 src/main/java/com/whyc/mapper/InspectionRecordMapper.java | 6 src/main/java/com/whyc/pojo/BattRTState.java | 198 ++++++++++++++++++++++++++++ src/main/java/com/whyc/service/QRCodeService.java | 31 +++ src/main/java/com/whyc/pojo/InspectionRecord.java | 50 +++++++ 9 files changed, 402 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/whyc/controller/InspectionRecordController.java b/src/main/java/com/whyc/controller/InspectionRecordController.java new file mode 100644 index 0000000..9b0e0e8 --- /dev/null +++ b/src/main/java/com/whyc/controller/InspectionRecordController.java @@ -0,0 +1,22 @@ +package com.whyc.controller; + +import com.whyc.dto.Response; +import com.whyc.service.InspectionRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("inspectionRecord") +public class InspectionRecordController { + + @Autowired + private InspectionRecordService service; + + //@PostMapping("start") + //public Response start(){ + //return service.start(); + //} + +} diff --git a/src/main/java/com/whyc/controller/QRCodeController.java b/src/main/java/com/whyc/controller/QRCodeController.java index 813106a..e9fd325 100644 --- a/src/main/java/com/whyc/controller/QRCodeController.java +++ b/src/main/java/com/whyc/controller/QRCodeController.java @@ -1,6 +1,7 @@ package com.whyc.controller; import com.whyc.dto.Response; +import com.whyc.pojo.BattRTState; import com.whyc.service.QRCodeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -24,10 +25,15 @@ } @PostMapping(value = "extractAndGetData") - private Response extractAndGetData(@RequestBody byte[] data){ + private Response<BattRTState> extractAndGetData(@RequestBody byte[] data){ //private Response extractAndGetData(@RequestBody String data){ - return new Response().set(1,"ok"); - //return service.extractAndGetData(data); + return service.extractAndGetData(data); + } + + @PostMapping(value = "uploadVideo") + private Response<BattRTState> uploadVideo(@RequestBody byte[] data){ + //private Response extractAndGetData(@RequestBody String data){ + return service.uploadVideo(data); } @GetMapping("test") diff --git a/src/main/java/com/whyc/mapper/InspectionRecordMapper.java b/src/main/java/com/whyc/mapper/InspectionRecordMapper.java new file mode 100644 index 0000000..77e7965 --- /dev/null +++ b/src/main/java/com/whyc/mapper/InspectionRecordMapper.java @@ -0,0 +1,6 @@ +package com.whyc.mapper; + +import com.whyc.pojo.InspectionRecord; + +public interface InspectionRecordMapper extends CustomMapper<InspectionRecord>{ +} diff --git a/src/main/java/com/whyc/pojo/BattRTState.java b/src/main/java/com/whyc/pojo/BattRTState.java index ccfe2e1..8a053bf 100644 --- a/src/main/java/com/whyc/pojo/BattRTState.java +++ b/src/main/java/com/whyc/pojo/BattRTState.java @@ -86,5 +86,203 @@ @ApiModelProperty(value = "娓╁害浼犳劅鍣ㄦ箍搴�") private Float devHumidity; + public Long getNum() { + return num; + } + public void setNum(Long num) { + this.num = num; + } + + public Integer getBattGroupId() { + return battGroupId; + } + + public void setBattGroupId(Integer battGroupId) { + this.battGroupId = battGroupId; + } + + public Integer getBattCount() { + return battCount; + } + + public void setBattCount(Integer battCount) { + this.battCount = battCount; + } + + public Date getRecDatetime() { + return recDatetime; + } + + public void setRecDatetime(Date recDatetime) { + this.recDatetime = recDatetime; + } + + public Float getOnlineVol() { + return onlineVol; + } + + public void setOnlineVol(Float onlineVol) { + this.onlineVol = onlineVol; + } + + public Float getGroupVol() { + return groupVol; + } + + public void setGroupVol(Float groupVol) { + this.groupVol = groupVol; + } + + public Float getGroupTmp() { + return groupTmp; + } + + public void setGroupTmp(Float groupTmp) { + this.groupTmp = groupTmp; + } + + public Float getGroupCurr() { + return groupCurr; + } + + public void setGroupCurr(Float groupCurr) { + this.groupCurr = groupCurr; + } + + public Integer getBattState() { + return battState; + } + + public void setBattState(Integer battState) { + this.battState = battState; + } + + public Integer getBattTestType() { + return battTestType; + } + + public void setBattTestType(Integer battTestType) { + this.battTestType = battTestType; + } + + public Date getBattTestStarttime() { + return battTestStarttime; + } + + public void setBattTestStarttime(Date battTestStarttime) { + this.battTestStarttime = battTestStarttime; + } + + public Date getBattTestRecordtime() { + return battTestRecordtime; + } + + public void setBattTestRecordtime(Date battTestRecordtime) { + this.battTestRecordtime = battTestRecordtime; + } + + public Integer getBattTestTlong() { + return battTestTlong; + } + + public void setBattTestTlong(Integer battTestTlong) { + this.battTestTlong = battTestTlong; + } + + public Float getBattTestCap() { + return battTestCap; + } + + public void setBattTestCap(Float battTestCap) { + this.battTestCap = battTestCap; + } + + public Float getBattRealCap() { + return battRealCap; + } + + public void setBattRealCap(Float battRealCap) { + this.battRealCap = battRealCap; + } + + public Float getBattRestCap() { + return battRestCap; + } + + public void setBattRestCap(Float battRestCap) { + this.battRestCap = battRestCap; + } + + public Integer getBattRestPower1Time() { + return battRestPower1Time; + } + + public void setBattRestPower1Time(Integer battRestPower1Time) { + this.battRestPower1Time = battRestPower1Time; + } + + public Integer getBattRestPower2Time() { + return battRestPower2Time; + } + + public void setBattRestPower2Time(Integer battRestPower2Time) { + this.battRestPower2Time = battRestPower2Time; + } + + public Integer getTestLoadertype() { + return testLoadertype; + } + + public void setTestLoadertype(Integer testLoadertype) { + this.testLoadertype = testLoadertype; + } + + public Integer getTestRecordnum() { + return testRecordnum; + } + + public void setTestRecordnum(Integer testRecordnum) { + this.testRecordnum = testRecordnum; + } + + public Integer getA059Num() { + return a059Num; + } + + public void setA059Num(Integer a059Num) { + this.a059Num = a059Num; + } + + public Float getDevTestPower() { + return devTestPower; + } + + public void setDevTestPower(Float devTestPower) { + this.devTestPower = devTestPower; + } + + public Integer getBattAlmState() { + return battAlmState; + } + + public void setBattAlmState(Integer battAlmState) { + this.battAlmState = battAlmState; + } + + public Float getDevTemperature() { + return devTemperature; + } + + public void setDevTemperature(Float devTemperature) { + this.devTemperature = devTemperature; + } + + public Float getDevHumidity() { + return devHumidity; + } + + public void setDevHumidity(Float devHumidity) { + this.devHumidity = devHumidity; + } } \ No newline at end of file diff --git a/src/main/java/com/whyc/pojo/InspectionDetail.java b/src/main/java/com/whyc/pojo/InspectionDetail.java new file mode 100644 index 0000000..679d793 --- /dev/null +++ b/src/main/java/com/whyc/pojo/InspectionDetail.java @@ -0,0 +1,58 @@ +package com.whyc.pojo; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +@TableName(schema = "web_site",value = "tb_inspection_detail") +public class InspectionDetail { + + private Integer id; + private Integer num; + private Integer deviceId; + private Float temperature; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date recordTime; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getNum() { + return num; + } + + public void setNum(Integer num) { + this.num = num; + } + + public Integer getDeviceId() { + return deviceId; + } + + public void setDeviceId(Integer deviceId) { + this.deviceId = deviceId; + } + + public Float getTemperature() { + return temperature; + } + + public void setTemperature(Float temperature) { + this.temperature = temperature; + } + + public Date getRecordTime() { + return recordTime; + } + + public void setRecordTime(Date recordTime) { + this.recordTime = recordTime; + } +} diff --git a/src/main/java/com/whyc/pojo/InspectionRecord.java b/src/main/java/com/whyc/pojo/InspectionRecord.java new file mode 100644 index 0000000..ff600d3 --- /dev/null +++ b/src/main/java/com/whyc/pojo/InspectionRecord.java @@ -0,0 +1,50 @@ +package com.whyc.pojo; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +@TableName(schema = "web_site",value = "tb_inspection_record") +public class InspectionRecord { + + private Integer id; + private Integer num; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date startTime; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date endTime; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getNum() { + return num; + } + + public void setNum(Integer num) { + this.num = num; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } +} diff --git a/src/main/java/com/whyc/service/BattRTStateService.java b/src/main/java/com/whyc/service/BattRTStateService.java index c8f5951..5be6afe 100644 --- a/src/main/java/com/whyc/service/BattRTStateService.java +++ b/src/main/java/com/whyc/service/BattRTStateService.java @@ -17,8 +17,9 @@ public Response getOneByBattGroupId(String battGroupId) { QueryWrapper<BattRTState> query = Wrappers.query(); - query.eq("batt_group_id", battGroupId); + query.eq("battGroupId", battGroupId); query.last(" limit 1"); - return new Response().set(1,mapper.selectOne(query)); + Response res = new Response().set(1,mapper.selectOne(query)); + return res; } } diff --git a/src/main/java/com/whyc/service/InspectionRecordService.java b/src/main/java/com/whyc/service/InspectionRecordService.java new file mode 100644 index 0000000..e3d2d40 --- /dev/null +++ b/src/main/java/com/whyc/service/InspectionRecordService.java @@ -0,0 +1,29 @@ +package com.whyc.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.whyc.dto.Response; +import com.whyc.mapper.InspectionRecordMapper; +import com.whyc.pojo.InspectionRecord; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class InspectionRecordService { + + @Resource + private InspectionRecordMapper mapper; + + /*public Response start() { + //鑾峰彇璁板綍鍐呮渶澶х殑缂栧彿 + QueryWrapper<InspectionRecord> query = Wrappers.query(); + query.select("num").orderByDesc("id").last(" limit 1"); + InspectionRecord recordInDB = mapper.selectOne(query); + int numNew = 1; + if(recordInDB != null){ + numNew = recordInDB.getNum() + 1; + } + + }*/ +} diff --git a/src/main/java/com/whyc/service/QRCodeService.java b/src/main/java/com/whyc/service/QRCodeService.java index e727279..f8272d8 100644 --- a/src/main/java/com/whyc/service/QRCodeService.java +++ b/src/main/java/com/whyc/service/QRCodeService.java @@ -6,14 +6,13 @@ import com.google.zxing.client.j2se.BufferedImageLuminanceSource; import com.google.zxing.common.HybridBinarizer; import com.whyc.dto.Response; +import com.whyc.pojo.BattRTState; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.FileInputStream; -import java.io.InputStream; +import java.io.*; @Service public class QRCodeService { @@ -38,13 +37,19 @@ public Response extractAndGetData(byte[] data) { String battGroupId = extract(data); + System.out.println("battGroupId:"+battGroupId); + //娴嬭瘯鏁堟灉,鐢ㄩ潤鎬佹暟鎹� + /*BattRTState battRTState = new BattRTState(); + battRTState.setBattGroupId(1); + battRTState.setGroupTmp(27.0f); + return new Response().set(1,battRTState);*/ return battRTStateService.getOneByBattGroupId(battGroupId); } public static String test() { try { //InputStream inputStream = new ByteArrayInputStream(data); - InputStream inputStream = new FileInputStream("C:\\code\\web\\InspectionSystem\\src\\main\\resources\\lib\\t11.jpg"); + InputStream inputStream = new FileInputStream("C:\\code\\web\\InspectionSystem\\src\\main\\resources\\lib\\r5.jpg"); BufferedImage bufferedImage = ImageIO.read(inputStream); BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(bufferedImage))); Result result = new MultiFormatReader().decode(binaryBitmap); @@ -61,4 +66,22 @@ } + public Response<BattRTState> uploadVideo(byte[] data) { + try { + //灏哾ata瀛樺偍涓鸿棰戞枃浠� + FileOutputStream fileOutputStream = new FileOutputStream("C:\\Users\\29550\\Desktop\\褰撳墠椤圭洰\\2023\\0AR鐪奸暅椤圭洰-宸℃绯荤粺\\椤圭洰鏂囦欢\\upload_test_1.mp4"); + //娴佸紡澶勭悊,缂撳啿涓�2048瀛楄妭 + InputStream videoFileStream = new ByteArrayInputStream(data); + byte[] buffer = new byte[2048]; + int bytesRead; + while ((bytesRead = videoFileStream.read(buffer)) != -1) { + fileOutputStream.write(buffer, 0, bytesRead); + } + System.out.println("瑙嗛鏂囦欢涓婁紶鎴愬姛"); + }catch (Exception e){ + e.printStackTrace(); + } + return null; + + } } -- Gitblit v1.9.1