| | |
| | | package com.thhy.materials.modules.biz.helmet.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.thhy.general.common.BasicResult; |
| | |
| | | import com.thhy.materials.modules.biz.helmet.entity.dto.TypeName; |
| | | import com.thhy.materials.modules.biz.helmet.mapper.HelmetMapper; |
| | | import com.thhy.materials.modules.biz.helmet.service.HelmetService; |
| | | import org.csource.common.MyException; |
| | | import org.csource.common.NameValuePair; |
| | | import org.csource.fastdfs.StorageClient; |
| | | import org.springframework.stereotype.Service; |
| | | import sun.misc.Cache; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.imageio.ImageIO; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | public class HelmetServiceImpl implements HelmetService { |
| | | |
| | | @Resource |
| | | private HelmetMapper helmetMapper; |
| | | |
| | | @Resource |
| | | private StorageClient storageClient; |
| | | |
| | | @Override |
| | | public List<THelmetDevice> helmetServiceList() { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public BasicResult dataBox(JSONObject result) { |
| | | public BasicResult dataBox(JSONObject result) throws IOException, MyException { |
| | | |
| | | Integer type = Integer.valueOf(result.get("type").toString()); |
| | | |
| | |
| | | tDataAi.setEnterName(result.get("enterName").toString()); |
| | | tDataAi.setEnterCode(result.get("enterCode").toString()); |
| | | //图片上传 |
| | | |
| | | //ByteArrayInputStream bais = null; |
| | | byte[] bytes = Base64.getDecoder().decode(result.get("signAvatar").toString()); |
| | | //构建字节数组输入流 |
| | | //bais = new ByteArrayInputStream(bytes); |
| | | // BufferedImage bufferedImage = ImageIO.read(bais); |
| | | // //通过ImageIO把字节数组输入流转为BufferedImage |
| | | // //构建文件 |
| | | // File imageFile = new File(imageFileName); |
| | | NameValuePair[] nv = new NameValuePair[2]; |
| | | nv[0] = new NameValuePair("name","ai报警图片"); |
| | | nv[1] = new NameValuePair("uploadTime",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
| | | String[] paths = storageClient.upload_file(bytes, "jpg",nv); |
| | | String p1 = paths[0]; |
| | | String p2 = paths[1]; |
| | | String path = p1+"/"+p2; |
| | | //上边缺少图片处理 |
| | | tDataAi.setSignTime(result.get("signTime").toString()); |
| | | tDataAi.setSignAvatar(path); |
| | | tDataAi.setSignBigAvatar(result.get("signBigAvatar").toString()); |
| | | tDataAi.setChannelNo(result.get("channelNo").toString()); |
| | | tDataAi.setX(result.getIntValue("x")); |
| | | tDataAi.setY(result.getIntValue("y")); |