use of com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary in project new-cloud by xie-summer.
the class PanoramicDailyInventorySummaryServiceImpl method countUsable.
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public Integer countUsable(String code, String date) {
// 最近7天历史消耗量数据值获取
List<PanoramicRealTimeConsumptionGather> sum = realTimeConsumptionGatherService.findNumberdayData(code, 7, date);
double sumSingle = 0.0;
if (null != sum && sum.size() != 0) {
// 当前仓库存量值获取
PanoramicDailyInventorySummary summary = queryByDateAndCode(code, date);
if (Optional.ofNullable(summary).isPresent()) {
for (int i = 0; i < sum.size(); i++) {
sumSingle = MathUtil.add(sumSingle, sum.get(i).getValue());
}
return Integer.parseInt(new java.text.DecimalFormat("0").format(summary.getValue() / sumSingle * sum.size()));
}
return null;
} else {
return null;
}
}
use of com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary in project new-cloud by xie-summer.
the class PanoramicDailyInventorySummaryServiceImpl method check.
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public Map<String, String> check(List<String> codeList, String date) {
Map<String, String> result = Maps.newHashMap();
codeList.forEach((String e) -> {
PanoramicDailyInventorySummary dailyInventorySummary = this.queryByDateAndCode(e, date);
PanoramicMaterialThresholdConfiguration configuration = materialThresholdConfigurationService.findByCode(ThresholdConfigConstant.STOCK, e);
result.put(e, ExceptionRecordStatusEnum.normal.getCode());
if (!Optional.ofNullable(configuration).isPresent()) {
// 3 库存配置异常
result.put(e, ExceptionRecordStatusEnum.configuration.getCode());
} else if ((!Optional.ofNullable(dailyInventorySummary).isPresent()) || dailyInventorySummary.getValue() < configuration.getLowerLimit()) {
// 1:库存偏低
result.put(e, ExceptionRecordStatusEnum.low.getCode());
} else if (dailyInventorySummary.getValue() > configuration.getUpperLimit()) {
result.put(e, ExceptionRecordStatusEnum.high.getCode());
}
});
return result;
}
use of com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary in project new-cloud by xie-summer.
the class PanoramicDailyInventorySummaryServiceImpl method queryByDateAndCode.
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public PanoramicDailyInventorySummary queryByDateAndCode(String code, String date) {
Condition condition = new Condition(PanoramicDailyInventorySummary.class, false);
condition.createCriteria().andCondition(" code ='" + code + "' and 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 (null == recordList || recordList.size() == 0) ? null : recordList.get(0);
}
use of com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary 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 com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary in project new-cloud by xie-summer.
the class PanoramicDailyInventorySummaryServiceImpl method getPanoramicDailyInventorySummary.
private PanoramicDailyInventorySummary getPanoramicDailyInventorySummary(Double value, Integer category) {
PanoramicDailyInventorySummary record = new PanoramicDailyInventorySummary();
record.setValue(value);
record.setCategory(category);
record.setUnit("吨");
record.setCtime(DateUtil.getCurFullTimestamp());
record.setUtime(record.getCtime());
record.setDeleteFlag(1);
record.setDtime(null);
record.setfId("2");
record.setId(null);
record.setOperator("auto_task");
return record;
}
Aggregations