src/main/java/com/whyc/controller/InspectionRecordController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/controller/QRCodeController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/mapper/InspectionRecordMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/BattRTState.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/InspectionDetail.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/InspectionRecord.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/BattRTStateService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/InspectionRecordService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/QRCodeService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/controller/InspectionRecordController.java
New file @@ -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(); //} } 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") src/main/java/com/whyc/mapper/InspectionRecordMapper.java
New file @@ -0,0 +1,6 @@ package com.whyc.mapper; import com.whyc.pojo.InspectionRecord; public interface InspectionRecordMapper extends CustomMapper<InspectionRecord>{ } 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; } } src/main/java/com/whyc/pojo/InspectionDetail.java
New file @@ -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; } } src/main/java/com/whyc/pojo/InspectionRecord.java
New file @@ -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; } } 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; } } src/main/java/com/whyc/service/InspectionRecordService.java
New file @@ -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; } }*/ } 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 { //将data存储为视频文件 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; } }