| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- package com.xcgl.middleware;
- import java.text.ParsePosition;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import org.jeecgframework.core.common.service.CommonService;
- import org.jeecgframework.core.util.ApplicationContextUtil;
- import org.jeecgframework.web.system.service.SystemService;
- import org.joda.time.DateTime;
- import com.xcgl.sensorrecord.entity.SensorRecordEntity;
- import cn.com.lzt.common.util.StringUtil;
- public class MWTools {
-
- private static java.util.List<SensorRecordEntity> lsRecords ;
- private static SystemService systemService;
- private MWTools() {}
- /**
- * 制作一套空数据传感器记录数组,每次采集数据均为一套
- *
- * */
- public static java.util.List<SensorRecordEntity> getInitRecords(CommonService service) {
-
- if(lsRecords != null && !lsRecords.isEmpty())
- return lsRecords;
-
- String querySql = " select point.typeid, type.type_name as typename, type.type_code as typecode, point.id as pointid, \r\n" +
- "point.name as pointname, point.code as pointcode, device.id as deviceid, device.name as devicename,point.room as roomname, \r\n" +
- "type_unit as typeunit,point.upper as upper, point.floor as floor, now() as recordtime, \r\n" +
- "device.department as departmentname,point.projectid as projectid\r\n" +
- "from p_sensor_monitor_point point \r\n" +
- "left join p_sensor_type type on point.typeid = type.id\r\n" +
- "left join p_device device on point.deviceid = device.id ";
- java.util.List<Object[]> qrRet = service.findListbySql(querySql);
- lsRecords = new ArrayList<SensorRecordEntity>();
- if(!qrRet.isEmpty()){
- for (int i = 0; i < qrRet.size(); i++) {
- lsRecords.add(buildEntity(qrRet.get(i)));
- }
- }
- return lsRecords;
- }
- private static SensorRecordEntity buildEntity(Object[] re)
- {
- SensorRecordEntity record = new SensorRecordEntity();
- record.setTypeid(re[0].toString());
- record.setTypename(re[1].toString());
- record.setTypecode(re[2].toString());
- record.setPointid(re[3].toString());
- record.setPointname(re[4].toString());
- record.setPointcode(re[5].toString());
- record.setDeviceid(re[6].toString());
- record.setDevicename(re[7].toString());
- record.setRoomname(re[8].toString());
- record.setTypeunit(re[9].toString());
- record.setUpper(re[10]==null||re[10].toString().length()==0 ? null: Double.valueOf(re[10].toString()));
- record.setFloor(re[11]==null||re[11].toString().length()==0 ? null: Double.valueOf(re[11].toString()));
- //record.setRecordtime( new Date());
- record.setDepartmentname(re[13].toString());
- record.setProjectid(re[14].toString());
- return record;
- }
- /**
- * 获取现在时间
- *
- * @return返回长时间格式 yyyy-MM-dd HH:mm:ss
- */
- public static Date getNowDate() {
- Date currentTime = new Date();
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String dateString = formatter.format(currentTime);
- ParsePosition pos = new ParsePosition(8);
- Date currentTime_2 = formatter.parse(dateString, pos);
- return currentTime_2;
- }
- }
|