use of tk.mybatis.mapper.entity.Condition in project new-cloud by xie-summer.
the class PanoramicDailyInventorySummaryServiceImpl method listByDateAndCode.
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public List<PanoramicDailyInventorySummary> listByDateAndCode(String date) {
Condition condition = new Condition(PanoramicDailyInventorySummary.class, false);
condition.createCriteria().andCondition(" f_id=2 and delete_flag=1 and utime >= '" + DateUtil.parseTimestamp(date, "yyyy-MM-dd") + "' and utime < '" + DateUtil.parseTimestamp(DateUtil.getSpecifiedDayBefor(date, -1), "yyyy-MM-dd") + "'");
condition.setOrderByClause(" utime desc ");
List<PanoramicDailyInventorySummary> recordList = dailyInventorySummaryMapper.selectByCondition(condition);
return recordList;
}
use of tk.mybatis.mapper.entity.Condition in project new-cloud by xie-summer.
the class PanoramicExceptionRecordServiceImpl method getPanoramicExceptionRecords.
private List<PanoramicExceptionRecord> getPanoramicExceptionRecords(String category, String startDate, String endDate) {
Condition condition = new Condition(PanoramicExceptionRecord.class, false);
StringBuilder sb = new StringBuilder("delete_flag=1 and alarm_time >='" + startDate + "' and alarm_time <='" + DateUtil.getSpecifiedDayBefor(endDate, -1));
if (StringUtils.isNotBlank(category)) {
sb.append("' and alarm_item = '" + category + "'");
}
condition.createCriteria().andCondition(sb.toString());
condition.setOrderByClause(" status desc ");
condition.setOrderByClause(" alarm_time desc ");
return exceptionRecordMapper.selectByCondition(condition);
}
use of tk.mybatis.mapper.entity.Condition in project new-cloud by xie-summer.
the class PanoramicIntoTheFactoryRecordsServiceImpl method regularlyRefreshTask.
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void regularlyRefreshTask() {
Condition condition = new Condition(PanoramicIntoTheFactoryRecords.class, false);
condition.createCriteria().andCondition(" err_msg is null and delete_flag=1 and status=1 and date_format(snapshot_time,'%Y%m%d') = date_format('" + DateUtil.currentTimeStr() + "','%Y%m%d') ");
condition.setOrderByClause(" snapshot_time desc ");
List<PanoramicIntoTheFactoryRecords> records = intoTheFactoryRecordsMapper.selectByCondition(condition);
if (null == records || records.size() == 0) {
return;
}
List<PanoramicExceptionRecord> exceptionRecords = Lists.newArrayList();
records.forEach(e -> {
try {
if (null == e.getNetWeight() || e.getNetWeight() == 0) {
e.setErrMsg("数据异常,记录数据没有净重值");
}
if (e.getTare() / e.getNetWeight() >= 0.006) {
e.setErrMsg("超重");
}
if (e.getTare() / e.getNetWeight() <= -0.006) {
e.setErrMsg("缺重");
}
if (StringUtils.isNotBlank(e.getErrMsg())) {
PanoramicExceptionRecord exceptionRecord = new PanoramicExceptionRecord();
exceptionRecord.setStatus(0);
exceptionRecord.setOperator("auto_task");
exceptionRecord.setId(null);
exceptionRecord.setDtime(null);
exceptionRecord.setCtime(DateUtil.getCurFullTimestamp());
exceptionRecord.setUtime(exceptionRecord.getCtime());
exceptionRecord.setAlarmTime(exceptionRecord.getCtime());
exceptionRecord.setAlarmContent(e.getErrMsg());
exceptionRecord.setAssociatedPerson(null);
exceptionRecord.setDeleteFlag(1);
exceptionRecord.setAlarmItem(ExceptionRecordCategoryConstant.IN_OR_OUT_EXCEPTION_RECORD);
exceptionRecords.add(exceptionRecord);
}
} catch (Exception e1) {
DB_LOGGER.error("数据异常,记录数据没有净重值");
}
if (Optional.ofNullable(e.getErrMsg()).isPresent()) {
e.setMemo("<-- auto task {\"更新异常信息\"}:" + e.getErrMsg() + DateUtil.currentTimeStr() + "-->");
e.setUtime(DateUtil.getCurFullTimestamp());
}
intoTheFactoryRecordsMapper.updateByPrimaryKeySelective(e);
});
if (null != exceptionRecords && exceptionRecords.size() > 0) {
exceptionRecordService.save(exceptionRecords);
}
}
use of tk.mybatis.mapper.entity.Condition in project new-cloud by xie-summer.
the class PanoramicIntoTheFactoryRecordsServiceImpl method findByDate.
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public PanoramicIntoTheFactoryRecords findByDate(String date) {
Condition condition = new Condition(PanoramicIntoTheFactoryRecords.class, false);
condition.createCriteria().andCondition(" delete_flag=1 and status=1 and date_format(snapshot_time,'%Y%m%d') = date_format('" + date + "','%Y%m%d') and err_msg is not null");
condition.setOrderByClause(" snapshot_time desc ");
List<PanoramicIntoTheFactoryRecords> factoryRecords = intoTheFactoryRecordsMapper.selectByCondition(condition);
return (null == factoryRecords || factoryRecords.size() == 0) ? null : factoryRecords.get(0);
}
use of tk.mybatis.mapper.entity.Condition in project new-cloud by xie-summer.
the class PanoramicInventoryEntryServiceImpl method manualEntryExceptionRecordTask.
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void manualEntryExceptionRecordTask(String date) {
Condition condition = new Condition(PanoramicInventoryEntry.class, false);
condition.createCriteria().andCondition(" f_id=2 and delete_flag=1 and utime > '" + DateUtil.parseTimestamp(date, "yyyy-MM-dd") + "' and utime < '" + DateUtil.parseTimestamp(DateUtil.getSpecifiedDayBefor(date, -1), "yyyy-MM-dd") + "'");
Integer count = inventoryEntryMapper.selectCountByCondition(condition);
if (6 == count) {
return;
}
PanoramicExceptionRecord record = new PanoramicExceptionRecord();
record.setAlarmItem(ExceptionRecordCategoryConstant.MANUAL_ENTRY_EXCEPTION_RECORD);
record.setDeleteFlag(1);
record.setAlarmContent("人工录入模块有数据漏录入");
record.setAssociatedPerson("当前管理员");
record.setAlarmTime(DateUtil.parseDate(date));
record.setCtime(DateUtil.getCurFullTimestamp());
record.setDtime(null);
record.setId(null);
record.setOperator("auto_task");
record.setRelatedPersonLog("定时任务自动扫描-人工录入异常遗漏数据");
record.setStatus(0);
record.setUtime(DateUtil.getCurFullTimestamp());
exceptionRecordService.save(record);
}
Aggregations