115 lines
3.9 KiB
Plaintext
115 lines
3.9 KiB
Plaintext
|
|
package com.nationalelectric.greenH5;
|
||
|
|
|
||
|
|
import java.util.ArrayList;
|
||
|
|
import java.util.Date;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
import org.codehaus.jackson.map.ObjectMapper;
|
||
|
|
import org.codehaus.jackson.type.TypeReference;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.stereotype.Controller;
|
||
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||
|
|
|
||
|
|
import com.nationalelectirc.Constant.Constant;
|
||
|
|
import com.nationalelectirc.utils.RestResult;
|
||
|
|
import com.nationalelectric.greenH5.po.GreenUserInfo;
|
||
|
|
import com.sgcc.uap.persistence.IHibernateDao;
|
||
|
|
|
||
|
|
/**
|
||
|
|
*
|
||
|
|
* @author Administrator
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
@Controller
|
||
|
|
@RequestMapping("/cameraManager")
|
||
|
|
public class CameraManagerController extends GreenBaseController{
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* HibernateDao逻辑构件
|
||
|
|
*/
|
||
|
|
@Autowired
|
||
|
|
IHibernateDao hibernateDao;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 新增记录
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@SuppressWarnings("unchecked")
|
||
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||
|
|
public @ResponseBody RestResult add(@RequestBody Object requestBody) {
|
||
|
|
try {
|
||
|
|
List<Object> params = new ArrayList<Object>();
|
||
|
|
String UUID = java.util.UUID.randomUUID().toString();
|
||
|
|
String crearaId = "1";
|
||
|
|
String photoPath = "1";
|
||
|
|
String userID = "1";
|
||
|
|
String userName = "1";
|
||
|
|
String userTemoerature = "36.5";
|
||
|
|
Date now = new Date();
|
||
|
|
String inserSql = "INSERT INTO creara_record (UUID, CAMERA_ID, PHOTO_PATH, USER_ID, USER_NAME, USER_TEMPERATURE, CAMERA_TIME, CREATE_TIME, CREATE_BY, UPDATE_TIME, UPDATE_BY, IS_DELETE) VALUES (?,?,?, ?, ?,?,?, ?, 'admin', ?, 'admin', 'N');";
|
||
|
|
params.add(UUID);
|
||
|
|
params.add(crearaId);
|
||
|
|
params.add(photoPath);
|
||
|
|
params.add(userID);
|
||
|
|
params.add(userName);
|
||
|
|
params.add(userTemoerature);
|
||
|
|
params.add(now);
|
||
|
|
params.add(now);
|
||
|
|
params.add(now);
|
||
|
|
hibernateDao.executeSqlUpdate(inserSql, params.toArray());
|
||
|
|
|
||
|
|
return new RestResult(Constant.SUCCESS,"成功", null);
|
||
|
|
} catch (Exception e) {
|
||
|
|
System.out.print(e.getMessage());
|
||
|
|
return new RestResult(Constant.FAILED, "提交失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查询抓拍记录
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@SuppressWarnings("unchecked")
|
||
|
|
@RequestMapping(value = "/query", method = RequestMethod.POST)
|
||
|
|
public @ResponseBody RestResult query(@RequestBody Object requestBody) {
|
||
|
|
try {
|
||
|
|
Map<String, Object> map = new ObjectMapper().convertValue(requestBody, new TypeReference<Map<String, Object>>(){});
|
||
|
|
String userId = map.get("userId") == null || "".equals(map.get("userId")) ? null : map.get("userId").toString();
|
||
|
|
// GreenUserInfo info = getUserInfo(userId);
|
||
|
|
// if (info == null) {
|
||
|
|
// return new RestResult(Constant.FAILED, "非法用户");
|
||
|
|
// }
|
||
|
|
//分页
|
||
|
|
Integer pageSize = map.get("pageSize") == null ? 10 : Integer.parseInt(map.get("pageSize").toString());
|
||
|
|
Integer pageNum = map.get("pageNum") == null ? 1 : Integer.parseInt(map.get("pageNum").toString());
|
||
|
|
pageNum = (pageNum-1) * pageSize;
|
||
|
|
//活动次数
|
||
|
|
Integer activityNo = map.get("activityNo") == null || "".equals(map.get("activityNo")) ? null : Integer.parseInt(map.get("activityNo").toString());
|
||
|
|
|
||
|
|
StringBuffer sql = new StringBuffer();
|
||
|
|
List<Object> params = new ArrayList<Object>();
|
||
|
|
sql.append(" select cr.PHOTO_PATH picPath,cr.USER_TEMPERATURE temperature,cr.CAMERA_TIME time from creara_record cr where cr.IS_DELETE = 'N' ");
|
||
|
|
|
||
|
|
sql.append(" order by cr.CREATE_TIME desc limit ?,? ");
|
||
|
|
|
||
|
|
params.add(pageNum);
|
||
|
|
params.add(pageSize);
|
||
|
|
|
||
|
|
List<Map<String,Object>> list = hibernateDao.queryForListWithSql(sql.toString(), params.toArray());
|
||
|
|
//获取图片地址
|
||
|
|
|
||
|
|
return new RestResult(Constant.SUCCESS,"成功", list);
|
||
|
|
} catch (Exception e) {
|
||
|
|
System.out.print(e.getMessage());
|
||
|
|
return new RestResult(Constant.FAILED, "提交失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|