use of com.itrus.portal.db.ConditionRecord in project portal by ixinportal.
the class RecordController method getConditionBean.
public ConditionRecord getConditionBean(List<Map<String, Object>> sixMonthList) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
ConditionRecord record = new ConditionRecord();
int i = 0;
// 现在的年份
String now_year = String.valueOf(cal.get(Calendar.YEAR));
// 现在的月份
String now_month = String.valueOf((cal.get(Calendar.MONTH)) + 1);
Long oneCount = 0L;
BigDecimal a = null;
BigDecimal b = null;
Long sixCount = 0L;
for (Map<String, Object> map : sixMonthList) {
String record_time = ((String) map.get("date_time"));
String record_year = record_time.substring(0, 4);
String record_month = record_time.substring(5, 7);
i++;
a = (BigDecimal) map.get("sums");
sixCount += a.longValue();
if (record_year.equals(now_year) && record_month.equals(now_month)) {
b = (BigDecimal) map.get("sums");
oneCount = b.longValue();
}
if (sixMonthList.size() == i) {
record.setEnterpriseName((String) map.get("enterprise_name"));
record.setUserId((Long) map.get("user_id"));
record.setDateTime(formatter.format((Date) map.get("sign_time")));
}
record.setOneCount(oneCount);
record.setSixCount(sixCount);
}
return record;
}
use of com.itrus.portal.db.ConditionRecord in project portal by ixinportal.
the class RecordController method dealCondition.
public void dealCondition(Map<String, Object> param, Records records, List<RecordData> recordDataList, List<RecordData> srecordDataList) {
List<Record> conditionList = new ArrayList<>();
List<Record> s_conditionList = new ArrayList<>();
List<Map<String, Object>> conditionmonthList = sqlSession.selectList("com.itrus.portal.db.ConditionRecordMapper.selectOneMonth", param);
Map<String, String> conditionmap = dealMonthList(conditionmonthList);
convertList(conditionList, conditionmap);
List<Map<String, Object>> sixMonthList = sqlSession.selectList("com.itrus.portal.db.ConditionRecordMapper.selectSixMonth", param);
Map<String, String> sconditionmap = dealSixList(sixMonthList);
convertList(s_conditionList, sconditionmap);
RecordData recordData = new RecordData();
RecordData srecordData = new RecordData();
ConditionRecord record = getConditionBean(sixMonthList);
recordData.setType("3");
recordData.setValue(("null").equals(String.valueOf(record.getOneCount())) ? "0" : String.valueOf(record.getOneCount()));
recordData.setTime(record.getDateTime());
recordData.setName("环境检测");
recordDataList.add(recordData);
srecordData.setType("3");
srecordData.setValue(("null").equals(String.valueOf(record.getOneCount())) ? "0" : String.valueOf(record.getSixCount()));
// srecordData.setTime(record.getDateTime());
srecordData.setName("环境检测");
srecordDataList.add(srecordData);
records.setConditionList(conditionList);
records.setSconditionList(s_conditionList);
}
use of com.itrus.portal.db.ConditionRecord in project portal by ixinportal.
the class SignatureRecordService method dealCondition.
public void dealCondition(Map<String, Object> param, Records records, List<RecordData> recordDataList, List<RecordData> srecordDataList) {
List<Record> conditionList = new ArrayList<>();
List<Record> s_conditionList = new ArrayList<>();
List<Map<String, Object>> conditionmonthList = sqlSession.selectList("com.itrus.portal.db.SignatureRecordMapper.selectOneMonth", param);
Map<String, String> conditionmap = dealMonthList(conditionmonthList);
convertList(conditionList, conditionmap);
List<Map<String, Object>> sixMonthList = sqlSession.selectList("com.itrus.portal.db.SignatureRecordMapper.selectSixMonth", param);
Map<String, String> sconditionmap = dealSixList(sixMonthList);
convertList(s_conditionList, sconditionmap);
RecordData recordData = new RecordData();
RecordData srecordData = new RecordData();
ConditionRecord record = getConditionBean(sixMonthList);
recordData.setType("3");
recordData.setValue(String.valueOf(record.getOneCount()));
recordData.setTime(record.getDateTime());
recordData.setName("环境检测");
recordDataList.add(recordData);
srecordData.setType("3");
srecordData.setValue(String.valueOf(record.getSixCount()));
srecordData.setTime(record.getDateTime());
srecordData.setName("环境检测");
srecordDataList.add(srecordData);
records.setConditionList(conditionList);
records.setSconditionList(s_conditionList);
}
use of com.itrus.portal.db.ConditionRecord in project portal by ixinportal.
the class SignatureRecordService method getConditionBean.
public ConditionRecord getConditionBean(List<Map<String, Object>> sixMonthList) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
ConditionRecord record = new ConditionRecord();
int i = 0;
// 现在的年份
String now_year = String.valueOf(cal.get(Calendar.YEAR));
// 现在的月份
String now_month = String.valueOf((cal.get(Calendar.MONTH)) + 1);
Long oneCount = 0L;
BigDecimal a = null;
BigDecimal b = null;
Long sixCount = 0L;
for (Map<String, Object> map : sixMonthList) {
String record_time = ((String) map.get("date_time"));
String record_year = record_time.substring(0, 4);
String record_month = record_time.substring(5, 7);
i++;
a = (BigDecimal) map.get("sums");
sixCount += a.longValue();
if (record_year.equals(now_year) && record_month.equals(now_month)) {
b = (BigDecimal) map.get("sums");
oneCount = b.longValue();
}
if (sixMonthList.size() == i) {
record.setEnterpriseName((String) map.get("enterprise_name"));
record.setUserId((Long) map.get("user_id"));
record.setDateTime(formatter.format((Date) map.get("sign_time")));
}
record.setOneCount(oneCount);
record.setSixCount(sixCount);
}
return record;
}
use of com.itrus.portal.db.ConditionRecord in project portal by ixinportal.
the class RecordQueueThread method run.
@Override
public void run() {
boolean isException = false;
while (true) {
log.debug("execute run,the queue size is [" + OBJECT_QUEUE.size() + "]");
if (OBJECT_QUEUE.isEmpty()) {
try {
// 若队列中没有信息则等待3秒
sleep(3 * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
continue;
}
log.debug("execute run,the queue size is [" + OBJECT_QUEUE.size() + "]");
// 签名记录
Map<String, SignatureRecord> signatureRecordMap = new HashMap<>();
// 在线记录
Map<String, ActivityMsgTemp> activityMsgTempMap = new HashMap<>();
// 环境检测
Map<String, ConditionRecord> conditionRecordMap = new HashMap<>();
// 流水表
Map<Long, ChargingFlow> chargingFlowMap = new HashMap<>();
for (int i = 0; !OBJECT_QUEUE.isEmpty() && i < 500; i++) {
Object object = OBJECT_QUEUE.poll();
if (object instanceof SignatureRecord) {
SignatureRecord sr = (SignatureRecord) object;
signatureRecordMap.put(sr.getBy1(), sr);
} else if (object instanceof ActivityMsgTemp) {
ActivityMsgTemp am = (ActivityMsgTemp) object;
activityMsgTempMap.put(am.getThreadId(), am);
} else if (object instanceof ConditionRecord) {
ConditionRecord cr = (ConditionRecord) object;
conditionRecordMap.put(cr.getBy1(), cr);
} else if (object instanceof ChargingFlow) {
ChargingFlow cr = (ChargingFlow) object;
chargingFlowMap.put(cr.getId(), cr);
}
}
// 保存签名记录
if (!signatureRecordMap.isEmpty())
try {
sqlSession.insert("com.itrus.portal.db.SignatureRecordMapper.insertOrUpdate", signatureRecordMap.values().toArray());
} catch (Exception e) {
isException = true;
// 将错误信息显示,不进行操作
log.error(e);
}
// 保存在线记录
if (!activityMsgTempMap.isEmpty())
try {
sqlSession.insert("com.itrus.portal.db.ActivityMsgTempMapper.insertOrUpdate", activityMsgTempMap.values().toArray());
} catch (Exception e) {
isException = true;
// 将错误信息显示,不进行操作
log.error(e);
}
// 保存环境检测记录
if (!conditionRecordMap.isEmpty())
try {
sqlSession.insert("com.itrus.portal.db.ConditionRecordMapper.insertOrUpdate", conditionRecordMap.values().toArray());
} catch (Exception e) {
isException = true;
// 将错误信息显示,不进行操作
log.error(e);
}
// 暂时保存流水表记录
if (!chargingFlowMap.isEmpty())
try {
sqlSession.insert("com.itrus.portal.db.ChargingFlowMapper.bulkInsert", chargingFlowMap.values().toArray());
} catch (Exception e) {
isException = true;
// 将错误信息显示,不进行操作
log.error(e);
}
log.debug("the exception is [" + isException + "]");
// 若出现异常则暂停10秒钟
if (isException) {
try {
// 若队列中没有信息则等待3秒
sleep(3 * 1000);
} catch (InterruptedException e) {
log.error(e);
} finally {
isException = false;
}
}
}
}
Aggregations