From e649974b8b39ce4961a2bc467021364f0bb7898d Mon Sep 17 00:00:00 2001
From: 81041 <81041@192.168.10.23>
Date: 星期四, 01 十一月 2018 14:38:45 +0800
Subject: [PATCH] 机房问题上传添加图片功能
---
gx_tieta/src/com/fgkj/services/Deverror_recordService.java | 13 +++
gx_tieta/src/com/fgkj/dao/impl/Deverror_recordImpl.java | 43 +++++++++-
gx_tieta/src/com/fgkj/actions/Deverror_recordAction.java | 66 ++++++++++++++++
gx_tieta/src/com/fgkj/dto/Deverror_record.java | 78 +++++++++++++++++++
4 files changed, 194 insertions(+), 6 deletions(-)
diff --git a/gx_tieta/src/com/fgkj/actions/Deverror_recordAction.java b/gx_tieta/src/com/fgkj/actions/Deverror_recordAction.java
index 5b7b313..d4aaaf0 100644
--- a/gx_tieta/src/com/fgkj/actions/Deverror_recordAction.java
+++ b/gx_tieta/src/com/fgkj/actions/Deverror_recordAction.java
@@ -1,6 +1,14 @@
package com.fgkj.actions;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.sql.Blob;
+import java.sql.SQLException;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import com.fgkj.dto.BattInf;
import com.fgkj.dto.Deverror_record;
@@ -12,11 +20,33 @@
private Deverror_recordService service=new Deverror_recordService();
private String json;
private String result;
+ private List<File> file;
//鐢ㄦ埛鎵嬪姩娣诲姞闂
public String add(){
Deverror_record dev_record=getGson("yyyy-MM-dd").fromJson(json, Deverror_record.class);
User_inf uinf=(User_inf) getUser();
dev_record.setUid(uinf.getUId());
+ if(file.size()>0&&file!=null){
+ for (int i=0;i<file.size();i++) {
+ switch (i) {
+ case 0:
+ dev_record.setPicture_one(file.get(i));
+ break;
+ case 1:
+ dev_record.setPicture_two(file.get(i));
+ break;
+ case 2:
+ dev_record.setPicture_three(file.get(i));
+ break;
+ case 3:
+ dev_record.setPicture_four(file.get(i));
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ dev_record.setPicture_num(file.size());
ServiceModel model=service.add(dev_record);
result=tojson(model);
return SUCCESS;
@@ -30,6 +60,36 @@
result=tojson(model);
return SUCCESS;
}
+ //鏍规嵁num鍜屽垪鍚嶆煡璇㈠浘鐗�(note鏀惧垪鍚嶅瓧)
+ public void serchByInfo(){
+ InputStream is = null;
+ OutputStream os =null;
+ Deverror_record dev_record=getGson("yyyy-MM-dd").fromJson(json, Deverror_record.class);
+ ServiceModel model=service.serchByInfo(dev_record);
+ if(model.code == 1){
+ List list = (List) model.getData();
+ Blob blob = (Blob) list.get(0);
+ try {
+ is = blob.getBinaryStream();
+ os = ActionUtil.getResponse().getOutputStream();
+ byte[] image = IStoByteArr(is);
+ os.write(image);
+ os.flush();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally{
+ if(os != null){
+ try {
+ os.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
public String getResult() {
return result;
@@ -37,6 +97,12 @@
public void setJson(String json) {
this.json = json;
}
+ public List<File> getFile() {
+ return file;
+ }
+ public void setFile(List<File> file) {
+ this.file = file;
+ }
}
diff --git a/gx_tieta/src/com/fgkj/dao/impl/Deverror_recordImpl.java b/gx_tieta/src/com/fgkj/dao/impl/Deverror_recordImpl.java
index cb870ad..35b03d1 100644
--- a/gx_tieta/src/com/fgkj/dao/impl/Deverror_recordImpl.java
+++ b/gx_tieta/src/com/fgkj/dao/impl/Deverror_recordImpl.java
@@ -1,5 +1,6 @@
package com.fgkj.dao.impl;
+import java.sql.Blob;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -14,6 +15,7 @@
import com.fgkj.dto.BattInf;
import com.fgkj.dto.Deverror_record;
import com.fgkj.dto.Page;
+import com.fgkj.dto.User_Chart;
public class Deverror_recordImpl implements BaseDAO,CallBack{
@@ -24,8 +26,20 @@
//鐢ㄦ埛鎵嬪姩娣诲姞闂
public boolean add(Object obj) {
Deverror_record dev_record=(Deverror_record) obj;
- String sql=" insert into db_battinf.tb_deverror_record(stationId,record_time,error_descript,uid) values(?,?,?,?)";
- boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{dev_record.getStationId(),dev_record.getRecord_time(),dev_record.getError_descript(),dev_record.getUid()});
+
+ List list=new ArrayList();
+ list.add(dev_record.getStationId());
+ list.add(dev_record.getRecord_time());
+ list.add(dev_record.getError_descript());
+ list.add(dev_record.getUid());
+ list.add(dev_record.getPicture_one());
+ list.add(dev_record.getPicture_two());
+ list.add(dev_record.getPicture_three());
+ list.add(dev_record.getPicture_four());
+
+ list.add(dev_record.getPicture_num());
+ String sql=" insert into db_battinf.tb_deverror_record(stationId,record_time,error_descript,uid,picture_one,picture_two,picture_three,picture_four,picture_num) values(?,?,?,?,?,?,?,?,?)";
+ boolean bl=DAOHelper.executeUpdatePicture(DBUtil.getConn(), sql, list);
return bl;
}
@@ -102,9 +116,28 @@
return list;
}
- public List serchByInfo(Object obj) {
- // TODO Auto-generated method stub
- return null;
+ //鏍规嵁num鍜屽垪鍚嶆煡璇㈠浘鐗�(note鏀惧垪鍚嶅瓧)
+ public List serchByInfo(Object obj){
+ final Deverror_record dev_record=(Deverror_record) obj;
+ String sql="select "+dev_record.getNote()+" from db_battinf.tb_deverror_record where num=? ";
+ List list=DAOHelper.executeQueryPicture(sql, DBUtil.getConn(), new Object[]{dev_record.getNum()}, new CallBack() {
+
+ public List getResults(ResultSet rs) {
+ List list=new ArrayList();
+ try {
+ while(rs.next()){
+ Blob blob=rs.getBlob(dev_record.getNote());
+ list.add(blob);
+ }
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return list;
+ }
+ });
+ return list;
+
}
public static void main(String[] args) {
Deverror_recordImpl dimpl=new Deverror_recordImpl();
diff --git a/gx_tieta/src/com/fgkj/dto/Deverror_record.java b/gx_tieta/src/com/fgkj/dto/Deverror_record.java
index b43f6d9..e92166b 100644
--- a/gx_tieta/src/com/fgkj/dto/Deverror_record.java
+++ b/gx_tieta/src/com/fgkj/dto/Deverror_record.java
@@ -1,7 +1,10 @@
package com.fgkj.dto;
+import java.io.File;
import java.io.Serializable;
import java.util.Date;
+
+import com.mysql.jdbc.Blob;
public class Deverror_record implements Serializable{
@@ -18,6 +21,18 @@
private int error_en; //闂鏄惁瑙e喅
private String note;
private Page page;
+
+ private Blob picture_one_blob;
+ private Blob picture_two_blob;
+ private Blob picture_three_blob;
+ private Blob picture_four_blob;
+
+ private File picture_one;
+ private File picture_two;
+ private File picture_three;
+ private File picture_four;
+
+ private int picture_num;
public int getNum() {
return num;
}
@@ -97,6 +112,60 @@
public void setPage(Page page) {
this.page = page;
}
+ public Blob getPicture_one_blob() {
+ return picture_one_blob;
+ }
+ public void setPicture_one_blob(Blob picture_one_blob) {
+ this.picture_one_blob = picture_one_blob;
+ }
+ public Blob getPicture_two_blob() {
+ return picture_two_blob;
+ }
+ public void setPicture_two_blob(Blob picture_two_blob) {
+ this.picture_two_blob = picture_two_blob;
+ }
+ public Blob getPicture_three_blob() {
+ return picture_three_blob;
+ }
+ public void setPicture_three_blob(Blob picture_three_blob) {
+ this.picture_three_blob = picture_three_blob;
+ }
+ public Blob getPicture_four_blob() {
+ return picture_four_blob;
+ }
+ public void setPicture_four_blob(Blob picture_four_blob) {
+ this.picture_four_blob = picture_four_blob;
+ }
+ public File getPicture_one() {
+ return picture_one;
+ }
+ public void setPicture_one(File picture_one) {
+ this.picture_one = picture_one;
+ }
+ public File getPicture_two() {
+ return picture_two;
+ }
+ public void setPicture_two(File picture_two) {
+ this.picture_two = picture_two;
+ }
+ public File getPicture_three() {
+ return picture_three;
+ }
+ public void setPicture_three(File picture_three) {
+ this.picture_three = picture_three;
+ }
+ public File getPicture_four() {
+ return picture_four;
+ }
+ public void setPicture_four(File picture_four) {
+ this.picture_four = picture_four;
+ }
+ public int getPicture_num() {
+ return picture_num;
+ }
+ public void setPicture_num(int picture_num) {
+ this.picture_num = picture_num;
+ }
@Override
public String toString() {
return "Deverror_record [num=" + num + ", stationId=" + stationId
@@ -106,8 +175,15 @@
+ stationName5 + ", record_time=" + record_time
+ ", error_descript=" + error_descript + ", uid=" + uid
+ ", error_en=" + error_en + ", note=" + note + ", page="
- + page + "]";
+ + page + ", picture_one_blob=" + picture_one_blob
+ + ", picture_two_blob=" + picture_two_blob
+ + ", picture_three_blob=" + picture_three_blob
+ + ", picture_four_blob=" + picture_four_blob + ", picture_one="
+ + picture_one + ", picture_two=" + picture_two
+ + ", picture_three=" + picture_three + ", picture_four="
+ + picture_four + ", picture_num=" + picture_num + "]";
}
+
}
diff --git a/gx_tieta/src/com/fgkj/services/Deverror_recordService.java b/gx_tieta/src/com/fgkj/services/Deverror_recordService.java
index 3b03f10..501c1ed 100644
--- a/gx_tieta/src/com/fgkj/services/Deverror_recordService.java
+++ b/gx_tieta/src/com/fgkj/services/Deverror_recordService.java
@@ -41,6 +41,19 @@
}
return model;
}
+ //鏍规嵁num鍜屽垪鍚嶆煡璇㈠浘鐗�(note鏀惧垪鍚嶅瓧)
+ public ServiceModel serchByInfo(Object obj){
+ List list=dao.serchByInfo(obj);
+ if (list!=null&&list.size()>0) {
+ model.setCode(1);
+ model.setData(list);
+ model.setMsg("鏌ヨ鎴愬姛!");
+ } else {
+ model.setCode(0);
+ model.setMsg("鏌ヨ澶辫触!");
+ }
+ return model;
+ }
}
--
Gitblit v1.9.1